akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	A, B := ReadInt(), ReadInt()
	fmt.Println(Max(A*B, A+B, A-B))
}

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 }


Measured memory_bytes: 1836
#!/usr/bin/env python3

n = int(input())

ans = []
while n > 0:
    if n%26 == 0:
        c = 26
    else:
        c = n%26
    ans.append(chr(c+96))
    if n%26 == 0:
        n = n//26 - 1
    else:
        n = n//26

ans = ''.join(ans[::-1])
print(ans)

Measured memory_bytes: 9044
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	int N;
	cin >> N;
	while (1) {
		int n = 2;
		bool p = 1;
		while(1) {
			if (n == N)
				break;
			if (N % n == 0) {
				p = 0;
				break;
			}
			n++;
			if (n * n > N)
				break;
		}
		if (p)
			break;
		N++;
	}
	cout << N << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define ARR_LIMIT 10000
#define NOT -1
#define CheckNumberFormat1(number) (	\
		(number) >= -1		&&			\
		(number) <= 50					\
)
#define CheckNumberFormat2(number) (	\
		(number) >= -1		&&			\
		(number) <= 100					\
)

typedef struct {
	int middle;
	int last;
	int retry;
} SCORE;

void InputNumber(int* number1, int* number2, int* number3);
char Judgment(SCORE score);

int main(void) {
	int size;
	int idx;
	SCORE scores[ARR_LIMIT];

	for (size = 0; size < ARR_LIMIT; size++) {
		int number1;
		int number2;
		int number3;
		InputNumber(&number1, &number2, &number3);

		if (number1 == NOT && number2 == NOT && number3 == NOT) {
			break;
		} else {
			SCORE* score = &scores[size];
			score->middle = number1;
			score->last = number2;
			score->retry = number3;
		}
	}

	for (idx = 0; idx < size; idx++) {
		SCORE score = scores[idx];
		printf("%c\n", Judgment(score));
	}

	return 0;
}

void InputNumber(int* number1, int* number2, int* number3) {
	int tmp1;
	int tmp2;
	int tmp3;
	do {
		scanf("%d %d %d", &tmp1, &tmp2, &tmp3);
	} while(!CheckNumberFormat1(tmp1) || !CheckNumberFormat1(tmp2) || !CheckNumberFormat2(tmp3));
	*number1 = tmp1;
	*number2 = tmp2;
	*number3 = tmp3;
}

char Judgment(SCORE score) {
	char res = 'F';

	int middle = score.middle;
	int last = score.last;
	int retry = score.retry;

	if (middle == NOT || last == NOT) {
		res = 'F';
	} else {
		int sum = middle + last;

		if (sum >= 80) {
			res = 'A';
		} else
		if (sum >= 65) {
			res = 'B';
		} else
		if (sum >= 50) {
			res = 'C';
		} else
		if (sum >= 30) {
			res = (retry >= 50) ? 'C' : 'D';
		} else {
			res = 'F';
		}
	}
	return res;
}


Measured memory_bytes: 2112
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int result = 0;
		for (int i = 1; i < 4; i++) {
		if (A==i || B==i){

		} else {
			result = i;
		}
	}
	System.out.println(result);
	}}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 500007;

int n;
char s[MAXN];
int a[MAXN];

void init ();
void input ();
void work ();



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	scanf ( "%s", s );
}

void work ()
{
	// main work
	
	n = strlen ( s );
	
	lp ( i, 0, n ){
		a[i] += ( s[n-i-1] - '0' ) * 9;
		a[i+1] += a[i] / 10;
		a[i] %= 10;
	}
	if ( a[n] ) ++n;
	
	int sum = 0;
	lp ( i, 0, n ) sum += a[i];
	
	for ( int ans = 1; ; ++ans ){
		a[0] += 9;
		sum += 9;
		lp ( i, 0, n ){
			if ( a[i] >= 10 ) ++a[i+1], a[i] -= 10, sum -= 9;
			else break;
		}
		if ( a[n] ) ++n;
		if ( sum <= 9 * ans ){
			printf ( "%d\n", ans );
			return;
		}
	}
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int main(){
	int h,w; cin >> h >> w;
	string s[55]; REP(i,0,h) cin >> s[i];
	
	int min_cost[55][55];
	REP(i,0,h) REP(j,0,w) min_cost[i][j] = INF;
	queue<P> qu; qu.push({0, 0}); min_cost[0][0] = 1;
	int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
	while(!qu.empty()){
		auto p = qu.front(); qu.pop();
		
		REP(i,0,4){
			int nx = p.first + vy[i], ny = p.second + vx[i];
			if(nx<0||ny<0||nx>=h||ny>=w) continue;
			if(s[nx][ny] == '#') continue;
			if(min_cost[p.first][p.second] + 1 >= min_cost[nx][ny]) continue;
			min_cost[nx][ny] = min_cost[p.first][p.second] + 1;
			qu.push({nx, ny});
		}
	}
	
	if(min_cost[h-1][w-1] == INF){cout << -1 << endl; return 0;}
	
	int c = 0;
	REP(i,0,h) REP(j,0,w) if(s[i][j] == '.') c++;
	cout << c - min_cost[h-1][w-1] << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int mx=-10000000;
        int mi=10000000;
        long sum=0;
        for(int i=0;i<N;i++){
            int a=sc.nextInt();
            sum+=a;
            if(mx<a){mx=a;}
            if(mi>a){mi=a;}
        }
        System.out.printf("%d %d %d\n",mi,mx,sum);
    }     
}


Measured memory_bytes: 41100
#include<iostream>
#include<cstdio>
#define _USE_MATH_DEFINES
#include<math.h>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<unordered_map>
#include<set>
#include <algorithm>
#include <utility>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::set;

typedef unsigned long long ull;
typedef long long ll;

#define Prime1 1000000007
#define Prime2 9999973

int i, j, k, l, m, n;
int H, W, N, M, Q;
int a, b, c;

//ユークリッドの互除法
ull gcd(ull a, ull b) {
	return b != 0 ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) {
	return a / gcd(a, b)*b;
}

int main()
{
	cin >> N ;
	vector<ull> T(N);
	for (i = 0; i < N; ++i)
	{
		cin >> T[i];
	}
	for(i=N-2;i>=0;--i)
	{
		T[i] = lcm(T[i], T[i + 1]);
	}
	cout << T[0] << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
const int N = 1e5+5;

struct Edge{
    int u,v,w,next;
}e[2*N]; int size = 0;
//双向边, 要开二倍空间
int head[N];
int d[N];
int ans[N];
int vis[N];

void add_edge(int u,int v,int w){
    e[size].u = u, e[size].v = v, e[size].w = w;
    e[size].next = head[u];
    head[u] = size;
    size++;
}

void dfs(int u,int cur){
    vis[u] = 1;
    d[u] = cur;
    for(int i = head[u]; i!=-1; i = e[i].next){
        int v = e[i].v, w = e[i].w;
        if(!vis[v]){
            dfs(v,cur^w);
        }
    }
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) head[i] = -1,vis[i] = 0; 
    for(int i = 0; i < n-1; i++){
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        add_edge(u,v,w);
        add_edge(v,u,w);
    }
    dfs(1,0);
    for(int i = 1; i <= n; i++){
        if(d[i]%2==0){
            printf("0\n");
        }
        else printf("1\n");
    }
    return 0;
}

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

bool seen[1002][1002];

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

  vector<pair<int, int>> q, nq;
  int W, H;
  cin >> H >> W;
  vector<string> grid(H);
  for (int i = 0; i < H; ++i) {
    cin >> grid[i];
    for (int j = 0; j < W; ++j) {
      if (grid[i][j] == '#') {
        q.push_back({i, j});
        seen[i][j] = true;
      }
    }
  }

  int di[] = {1, -1, 0, 0};
  int dj[] = {0, 0, 1, -1};

  int res = -1;
  while (!q.empty()) {
    ++res;
    for (auto p : q) {
      for (int ii = 0; ii < 4; ++ii) {
        int ni = p.first + di[ii];
        int nj = p.second + dj[ii];
        if (ni >= 0 && ni < H && nj >= 0 && nj < W && !seen[ni][nj]) {
          nq.push_back({ni, nj});
          seen[ni][nj] = true;
        }
      }
    }
    q = nq;
    nq.clear();
  }

  cout << res << '\n';
}


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

int main(void){
    int width;
    char input[10000];
    
    cin >> width;
    cin >> input;
    
    int i = 0;
    char tmp;
    while(input[i]!=0x00){
        tmp = (input[i]-'A'+width)%26+'A';
        printf("%c", tmp);
        i++;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>

using namespace std;

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

int N;

int main() {

	cin >> N;
	
	int ans = (N+1) / 2;

	cout << ans <<endl;
}


Measured memory_bytes: 256
//I am so vegetable
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = 3.141593;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
	ll a,b,c,k;cin>>a>>b>>c>>k;
    ll ans = 0;
    ans += (k>0?(a>k?k:a):0);
    k -= a;
    k -= b;
    ans += (k>0?(c>k?k:c):0)*(-1);
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;




int main(){
	int N; cin >> N;
	int ans = 0;
	for(int i = 1; i <= N; i+=2){
		int cnt = 0;
		repr(j,1,i+1){
			if(i%j == 0) cnt++;
		}
		if(cnt == 8) ans++;
	}
	cout << ans << endl;
}



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

int main(){
  long long N;
  cin >> N;
  map<long long , long long>data;
  for(int i=0; i<N-1; i++){
    int x;
    cin >> x;
    if(data.count(x)){
      data.at(x) +=1;
    }else{
      data.emplace(x, 1);
    }
  }
  for(int i=1; i<=N; i++){
    if(data.count(i)){
      cout << data.at(i) << endl;
    }
    else{
      cout << 0 << endl;
    }
  }
  return 0;
}

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

int main() {
  vector<ll> a(1000000);
  ll i, N, sum=0;
  
  cin >> N;
  rep(i,3*N) cin >> a[i];
  
  sort(a.begin(),a.begin()+3*N,greater<ll>());
  
  
  for(i=0;i<N;i++){
    sum += a[2*i+1];
  }
  
  cout << sum;
  
}

Measured memory_bytes: 10984
/* ****revpro**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  100005
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll a,b;
		cin>>a>>b;
		ll ans=1;
		rep(i,0,100){
			if(ans>=b){
				cout<<i;
				return 0;
			}
			ans+=a-1;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    string S;
    string Sb="";
    string Se="";
    int Q;
    bool rev=false;
    cin >>S>>Q;
    REP(i,Q){
        int a;
        cin >>a;
        if(a==1){
            rev = !rev;
        }
        else{
            int b;
            char c;
            cin >>b>>c;
            if((b==1 &&rev==false)||(b==2 &&rev==true)){
                Sb+=c;
            }
            if((b==1 &&rev==true)||(b==2 &&rev==false)){
                Se+=c;
            }
        }
    }
    reverse(Sb.begin(),Sb.end());
    string ans =Sb+S+Se;
    if(rev){
        reverse(ans.begin(),ans.end());
    }
    cout << ans <<endl;
}


Measured memory_bytes: 1348
/*
  AOJ 0600
  Title:Baumkuchen
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))
  
int n;
int a[100000];
long long t1_3_fw[100000];
long long t1_3_bk[100000];
long long all,all31; // one third of all

 
prepare()
{
  long long s;
  int i,j;
 
  for(i=s=0;i<n;i++)
    {
      s+=a[i];
 
      if(s>all31)
	{
	  t1_3_fw[0]=s;
	  j=i+1;
	  j %= n;
	  break;
	}
    }
 
  for(i=1;i<n;i++)
    {
      s -= a[i-1];
      while(s<all31)
	{
	  s += a[j];
	  j++;
	  j %= n;
	}
      t1_3_fw[i]=s;
    }
}
 
prepare2()
{
  long long s;
  int i,j;
 
  for(i=n-1,s=0;i>=0;i--)
    {
      s+=a[i];
      if(s>all31)
	{
	  t1_3_bk[n-1]=s;
	  j=i-1;
	  if(j<0)j+=n;
	  break;
	}
    }

  for(i=n-2;i>=0;i--)
    {
      s -= a[i+1];
      while(s<all31)
	{
	  s += a[j];
	  j--;
	  if(j<0)j+=n;
	}
      t1_3_bk[i]=s;
     }
}
  
long long proc2(int i_half,int s3)
{
  int i;
  long long s1,s2,max_;
  max_=0;

  for(i=s1=0;i<n-1;i++)
    {
      s1 += a[(i_half+1+i)%n];
      s2 = all - s3 -s1;
      //printf("%lld %lld %d\n",s1,s2,s3);
      max_ = max(max_,min(s1,s2));
    }
  return(max_);
}

main()
{
  int i,j,k,over;
  long long s1,s2,s3; // s1 shortest s2 longest s3 2nd
  long long max_;

  memset(t1_3_fw,0,sizeof(t1_3_fw));
  memset(t1_3_fw,0,sizeof(t1_3_bk));
  scanf("%d",&n);
  for(i=all=0;i<n;i++)
    {
      scanf("%d",&a[i]);
      all += a[i];
    }
 
  all31=all/3;
  
  for(i=0;i<n;i++)
    if(a[i]>all31)
      {
	max_=proc2(i,a[i]);
	goto END;
      }
 
  max_=0;  s1=0;
  prepare();prepare2();

  for(j=0;j<n;j++)
    {
      s1 += a[j];
      if(s1>all31)
	break;

      s2=t1_3_fw[j+1];
      s3=all-s1-s2;
      //printf("%lld %lld %lld\n",s1,s2,s3);
 
      if(s3 >= s1)
	{
	  max_=max(max_,s1);
	}
      
      s2=t1_3_bk[n-1];
      s3=all-s1-s2;
 
      if(s3 >= s1)
	{
	  //printf("%lld %lld %lld\n",s1,s2,s3);
	  max_=max(max_,s1);
	}
    }
  j++;
  for(i=1;i<n;i++)
    {
      s1 -= a[i-1];

      for(;;j++,j%=n)
	{
	  if(s1+a[j]>all31)
	    break;

	  s1 += a[j];

	  if(s1<max_)
	    continue;
	  
	  s2=t1_3_fw[(j+1)%n];
	  s3=all-s1-s2;
	  
	  if(s3 >= s1)
	    {
	      //printf("%lld %lld %lld[%d]\n",s1,s2,s3,j);
	      max_=max(max_,s1);
	    }
	  
	  s2=t1_3_bk[i-1];
	  s3=all-s1-s2;
  
	  if(s3 >= s1)
	    {
	      //printf("%lld %lld %lld\n",s1,s2,s3);
	      max_=max(max_,s1);
	    }
 	}
    }
 END:
  printf("%lld\n",max_);
  
  return(0);
}

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

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


Measured memory_bytes: 256
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const _n = stdin.split('\n')[0]
const n = Number(_n)

const a = stdin
  .split('\n')[1]
  .split(' ')
  .map(Number)

let tmp = 0
const l = a.map((e, i) => {
  if (i === 0) {
    tmp = e
    return e
  }
  tmp = gcd(tmp, e)
  return tmp
})

const r = a
  .slice(0)
  .reverse()
  .map((e, i) => {
    if (i === 0) {
      tmp = e
      return e
    }
    tmp = gcd(tmp, e)
    return tmp
  })
  .reverse()

let max = 0

a.forEach((e, i) => {
  let g = 0
  if (i === 0) {
    g = r[1]
  } else if (i === a.length - 1) {
    g = l[i - 1]
  } else {
    g = gcd(l[i - 1], r[i + 1])
  }

  max = max < g ? g : max
})

console.log(max)


function gcd(a, b) {
  let R
  while (a % b > 0) {
    R = a % b
    a = b
    b = R
  }
  return b
}


Measured memory_bytes: 31908
#include<cstdio>

int G[110][110]={};
int d[110];
int f[110];

int cnt = 0;

void dfs(int i, int n)
{
  int j;

  d[i] = ++cnt;
  for(j = 1;j <= n;j++){
    if(G[i][j] != 1) continue;
    else G[i][j] = 0;
    
    if(d[j] == 0) dfs(j, n);
  }
  f[i] = ++cnt;
}

int main()
{
  int n;
  int i,j;
  int u,k,v;
  
  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%d%d", &u, &k);

    for(j = 0;j < k;j++){
      scanf("%d", &v);
      G[u][v] = 1;
    }
  }

  for(i = 1;i <= n;i++)
    if(d[i] == 0) dfs(i, n);

  for(i = 1;i <= n;i++)
    printf("%d %d %d\n", i, d[i], f[i]);
  
  return 0;
}



Measured memory_bytes: 2728
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
    int N,change;
    cin>>N;
    
    if (N<=1000){
        cout<<""<<(1000-N);
    }
    else if (N<=2000 && N>1000){
        cout<<""<<(2000-N);
    }
    else if (N<=3000 && N>2000){
        cout<<""<<(3000-N);
    }
    else if (N<=4000 && N>3000){
        cout<<""<<(4000-N);
    }
    else if (N<=5000 && N>4000){
        cout<<""<<(5000-N);
    }
    else if (N<=6000 && N>5000){
        cout<<""<<(6000-N);
    }
    else if (N<=7000 && N>6000){
        cout<<""<<(7000-N);
    }
    else if (N<=8000 && N>7000){
        cout<<""<<(8000-N);
    }
    else if (N<=9000 && N>8000){
        cout<<""<<(9000-N);
    }
    else if (N<=10000 && N>9000){
        cout<<""<<(10000-N);
    }
    else {
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 3616
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,avx2,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0)
typedef long long ll;


ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

//#######################################

int main(){
  boost;

  ll n,k;
  cin>>n>>k;
  cout<<min(n%k,k-n%k);

}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
int dp[2005][2];

int dfs(int pos, int turn,vector<int> &v) {
	if (dp[pos][turn] != -1) return dp[pos][turn];

	int ret = (turn == 0) ? 0 : INF;
	for (int i = pos + 1; i <= N+1; i++) {
		int tmp;
		if (i == N + 1) {
			tmp = abs(v[pos] - v[i]);
		}
		else {
			tmp = dfs(i, 1 - turn,v);
		}

		if (turn == 0) {
			ret = max(ret, tmp);
		}
		else {
			ret = min(ret, tmp);
		}
	}
	return dp[pos][turn] = ret;
}
int main() {
	cin >> N >> Z >> W;
	for (int i = 0; i < N + 2; i++)dp[i][0] = -1, dp[i][1] = -1;
	vector<int>a(N + 2);
	a[0] = Z, a[1] = W;
	for (int i = 2; i <= N+1; i++)cin >> a[i];
	cout << dfs(1, 0, a) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
struct node{
    int l,r;
    node(int l,int r):l(l),r(r){}
    bool operator < (const node a)const{
        return a.r>r;
    }
};
const int inf=0x3f3f3f3f;
vector<node>v;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;++i){
        int x,l;
        cin>>x>>l;
        v.emplace_back(node(x-l,x+l));
    }
    sort(v.begin(),v.end());
    int pos=-inf;
    int ans=0;
    for(auto i:v){
        if(pos<=i.l){
            ans++;
            pos=i.r;
        }
    }
    cout<<ans<<endl;
}


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

int main(){
  long long sum=0,x,w,l,n;
  cin>>l>>n;
  for(int i=0;i<n;i++){
    cin>>x>>w;
    sum+=x*w;
  }
  if(sum==0)cout<<"0"<<endl;
  else  if(sum>0)cout<<"1"<<endl<<"-1"<<" "<<sum<<endl;
  else if(sum<0)cout<<"1"<<endl<<"1"<<" "<<sum*-1<<endl;
  return 0;
}

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

using namespace std;

string ans[] = {"pon", "pon", "hon", "bon", "hon",
                "hon", "pon", "hon", "pon", "hon"};

int main() {
  int n;
  cin >> n;
  int m = n % 10;
  cout << ans[m] << endl;
  return 0;
}


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

int n;
int x[24],y[24],r[24],c[24];
bool memo[1<<24];
//char bit_count[1<<24];

bool ok(int a,int bit){
    for(int i=0;i<a;i++){
        if(((bit>>i)&1)==0)continue;
        int dist=(x[i]-x[a])*(x[i]-x[a])+(y[i]-y[a])*(y[i]-y[a]);
        int sum=(r[i]+r[a])*(r[i]+r[a]);
        if(dist<sum)return false;
    }
    return true;
}

int dfs(int bit){
    memo[bit]=true;

    int ret=n;
    for(int i=0;i<n;i++)if((bit>>i)&1)ret--;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(((bit>>i)&1)==0)continue;
            if(((bit>>j)&1)==0)continue;
            int to_bit=(bit^(1<<i))^(1<<j);
            if(c[i]==c[j]&&ok(i,bit)&&ok(j,bit)&&!memo[to_bit]){
                ret=max(ret,dfs(to_bit));
            }
        }
    }


    return ret;
}

void solve(){
    fill_n(memo,1<<n,false);

    cout<<dfs((1<<n)-1)<<endl;
}

bool input(){
    cin>>n;
    if(!n)return false;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>r[i]>>c[i];
    return true;
}
/*
void init(){
    for(int i=0;i<(1<<24);i++){
        for(int j=0;j<24;j++)if((i>>j)&1){
            bit_count[i]++;
        }
    }
}*/

int main(){
    //init();
    while(input())solve();
    return 0;
}

Measured memory_bytes: 17544
import scala.collection.mutable._

object Main extends App {
	val sc = new java.util.Scanner(System.in)
	val pw = new java.io.PrintWriter(System.out)
	
	val n, k = sc.nextInt
	val p = Seq.fill(n)(sc.nextInt).map(pi => (1 + pi).toDouble / 2.0)
	val q = p.scanLeft(0.0)(_ + _)
	
	pw.println((0 to n-k).foldLeft(0.0){ case (res, i) =>
		Math.max(q(k + i) - q(i), res)
	})
	pw.flush()
}

Measured memory_bytes: 81316
#include <bits/stdc++.h>
typedef long long ll;
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define dbg2(x,y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define dbg3(x,y,z) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<endl
#define dbg4(x,y,z,q) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<", "<<#q<<" = "<<q<<endl
#define dbg_array(x,sz) for (int i = 0; i < sz; ++i) cout << x[i] << " \n"[i==sz-1]
using namespace std;

const ll N = 1e5 + 9, M = 400 - 9, Max_ans = 1LL * (1e16);
int ans[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
#ifdef ECLIPSE
	freopen("input.in", "rt", stdin);
	//freopen("output.out", "wt", stdout);
#endif
	int n;
	cin >> n;
	for (int i = 1; i <= 100; ++i)
		for (int j = 1; j <= 100; ++j)
			for (int k = 1; k < 100; ++k) {
				int num = i * i + j * j + k * k + i * j + j * k + i * k;
				++ans[num];
			}
	for (int i = 1; i <= n; ++i)
		printf("%d\n", ans[i]);
	return 0;
}



Measured memory_bytes: 3908
/*
	DATE:		2020-03-12 13:02:27
	NAME:		
	PROBLEM:	ATDPN
*/
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 400;
const long long LLINF = 1e15;

int a[MAXN + 7];
long long pre[MAXN + 7];

long long sum(int l, int r) {
  return pre[r] - pre[l - 1];
}

long long dp[MAXN + 7][MAXN + 7];

long long dpf(int l, int r) {
  if (l > r) {
    return 0;
  }
  long long &d = dp[l][r];
  if (d != -1) {
    return d;
  }
  if (l == r) {
    return d = a[l];
  }
  if (l == r - 1) {
    return d = a[l] + a[r];
  }
  d = LLINF;
  for (int i = l; i <= r - 1; i++) {
    long long temp = dpf(l, i) + dpf(i + 1, r) + sum(l, r);
    if (i == l) {
      temp -= a[l];
    }
    if (i == r - 1) {
      temp -= a[r];
    }
    d = min(d, temp); 
  }
  return d;
}

int main() {
  memset(dp, -1, sizeof dp);
  int n;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    pre[i] = pre[i - 1] + a[i];
  }

  cout << dpf(1, n) << "\n";

  return 0;
}

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

int main() 
{
	int k;
	
	cin>>k;
	
	int a,b;
	cin>>a>>b;
	
	int temp = a / k;
	temp = temp * k;
	
	if(temp == a || temp + k <= b){
			cout<<"OK";
	}else
		cout<<"NG";
}
 
 
 


Measured memory_bytes: 3636
#include <iostream>
#include <map>
#include <utility>
using namespace std;

typedef long long lint;

int main(){
    lint H,W,N;
    cin >> H >> W >> N;
    map<pair<lint,lint>,lint> B;
    lint cnt[10];
    cnt[0]=(H-2)*(W-2);
    for(int i=1;i<=9;i++) cnt[i]=0;

    for(int i=0;i<N;i++){
        lint a,b;
        cin >> a >> b;
        for(int y=-1;y<=1;y++){
            for(int x=-1;x<=1;x++){
                if(a+y<=1 || a+y>=H) continue;
                if(b+x<=1 || b+x>=W) continue;
                B[make_pair(a+y,b+x)]++;
                cnt[B[make_pair(a+y,b+x)]]++;
                cnt[B[make_pair(a+y,b+x)]-1]--;
            }
        }
    }
    for(int i=0;i<10;i++) cout << cnt[i] << endl;

    return 0;
}//

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

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

template <class T>
T next()
{
    T x;
    cin >> x;
    return (x);
}

int main()
{
    auto n = next<int>();
    set<int> S;
    rep(i, n)
    {
        S.insert(next<int>());
    }

    auto q = next<int>();
    auto cnt = 0;
    rep(i, q)
    {
        auto ti = next<int>();
        cnt = S.count(ti) > 0 ? cnt + 1 : cnt;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 7768
#include <bits/stdc++.h>
using namespace std;
int a[4];
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();++i){
    if(s[i]=='N')a[0]++;
    if(s[i]=='S')a[1]++;
    if(s[i]=='W')a[3]++;
    if(s[i]=='E')a[4]++;
  }
  if((a[0]==0&&a[1]!=0)||
     (a[0]!=0&&a[1]==0)||
     (a[3]==0&&a[4]!=0)||
     (a[3]!=0&&a[4]==0))
    cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

const int MAX_N = 100;
const int MAX_K = 100000;
int a[MAX_N + 1];
bool f[MAX_K + 1];

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  int n, k;
  std::cin >> n >> k;
  f[0] = false;
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  for (int i = 1; i <= k; ++i) {
    f[i] = false;
    for (int j = 0; j < n; ++j) {
      if (i - a[j] >= 0 && !f[i - a[j]]) {
        f[i] = true;
        break;
      }
    }
  }
  if (f[k]) {
    std::cout << "First";
  } else {
    std::cout << "Second";
  }
}

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

int main(){
        int a, b;
        char op;
        
        while(true) {
        cin >> a >> op >> b;
               if(op == '?') break;
                switch(op) {
                        case '+':
                                cout << a + b << endl;
                                break;
                        case '-':
                                cout << a - b << endl;
                                break;
                        case '/':
                                cout << a / b << endl;
                                break;
                        case '*':
                                cout << a * b << endl;
                                break;
                }
        }
}


Measured memory_bytes: 3116
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int r, D, x; cin >> r >> D >> x;
    vector<int> X(11, 0);
    X[0] = x;
    for (int i = 1; i < 11; i++) {
        X[i] = r * X[i - 1] - D;
        printf("%d\n", X[i]);
    }
}


Measured memory_bytes: 3720
#include <iostream>
using namespace std;
#define MAX_N 1000
// 入力
int h, w, a, b;
int ans[MAX_N][MAX_N];

void solve()
{
    for (int i = 0; i < b; i++)
    {
        for (int j = 0; j < a; j++)
        {
            ans[i][j] = 1;
        }
    }
    for (int i = b; i < h; i++)
    {
        for (int j = a; j < w; j++)
        {
            ans[i][j] = 1;
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cout << ans[i][j];
        }
        cout << endl;
    }
}

int main()
{
    cin >> h >> w >> a >> b;

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            ans[i][j] = 0;
        }
    }

    solve();
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;

  int dx = gx - sx;
  int dy = gy - sy;

  string r1, r2, r3, r4;

  // s to g
  r1 = string(dy, 'U') + string(dx, 'R');
  // g to s
  r2 = string(dy, 'D') + string(dx, 'L');
  // s to g
  r3 = string(1, 'L') + string(dy + 1, 'U') + string(dx + 1, 'R') +
       string(1, 'D');
  // g to s
  r4 = string(1, 'R') + string(dy + 1, 'D') + string(dx + 1, 'L') +
       string(1, 'U');

  cout << r1 << r2 << r3 << r4 << endl;
  // cout << dx << " " << dy << endl;
  // cout << r1 << endl;
  // cout << r2 << endl;
  // cout << r3 << endl;
  // cout << r4 << endl;
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



signed main(){
    int N, K, S;
    cin >> N >> K >> S;
    vector<int> A(N);
    
    std::random_device rnd;
    std::mt19937 mt(rnd());
    
    rep(i,K) A[i] = S;
    for(int i=K; i<N; i++){
        A[i] = mt()%100000000+1;
    }
    rep(i, N) cout << A[i] << " ";
    cout << endl;
}


Measured memory_bytes: 2048
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

import qualified Data.Set as Set

------------------------------------------

main :: IO ()
main = do
  n <- readInt
  colors <- map toColor <$> readInts
  let numAny = length $ filter (== Any) colors
      cs = foldl' (flip Set.insert) Set.empty $ filter (/= Any) colors
  putStrLn $ show (max 1 (Set.size cs)) ++ " " ++ show (Set.size cs + numAny)
  
data Color = Gray | Brown | Green | Cyan | Blue | Yellow | Orange | Red | Any
  deriving (Enum, Eq, Ord, Show)

toColor :: Int -> Color
toColor rate
  | rate < 400 = Gray
  | rate < 800 = Brown
  | rate < 1200 = Green
  | rate < 1600 = Cyan
  | rate < 2000 = Blue
  | rate < 2400 = Yellow
  | rate < 2800 = Orange
  | rate < 3200 = Red
  | otherwise = Any

------------------------------------------



{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"


Measured memory_bytes: 508
N = int(input())
V = list(map(int, input().split()))

even_idx_cnt = {}
odd_idx_cnt = {}
for idx, v in enumerate(V):
    if idx % 2 == 0:
        if v not in even_idx_cnt:
            even_idx_cnt[v] = 0
        even_idx_cnt[v] += 1
    else:
        if v not in odd_idx_cnt:
            odd_idx_cnt[v] = 0
        odd_idx_cnt[v] += 1

if len(even_idx_cnt) == 1 and len(odd_idx_cnt) == 1:
    if even_idx_cnt.keys() == odd_idx_cnt.keys():
        print(N - even_idx_cnt[V[0]])
    else:
        print(0)
    exit()

even_idx_cnt = sorted(even_idx_cnt.items(), key=lambda  x:x[1], reverse=True)
odd_idx_cnt = sorted(odd_idx_cnt.items(), key=lambda  x:x[1], reverse=True)

if even_idx_cnt[0][0] != odd_idx_cnt[0][0]:
    print(N - even_idx_cnt[0][1] - odd_idx_cnt[0][1])
else:
    ans = []
    if len(odd_idx_cnt) >= 2:
        ans.append(N - even_idx_cnt[0][1] - odd_idx_cnt[1][1])
    if len(even_idx_cnt) >= 2:
        ans.append(N - even_idx_cnt[1][1] - odd_idx_cnt[0][1])
    print(min(ans))


Measured memory_bytes: 17644
import java.util.*;
import java.math.*;
class Main
{
    public static void main(String [] args)
    {
        Map<String,Integer> map =new HashMap<>();
        Scanner  sc =new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int arr[] =new int[n];
        // List<BigInteger> list = new ArrayList<>();
        // BigInteger val = new BigInteger("1");
        int start=0;
        for(int i=0;i<n;i++)
        {
            int value = sc.nextInt();
            arr[i]=value;
        }
        // System.out.println(list);
        for(int i=k;i<n;i++)
        {
            if(arr[i]>arr[start])
            {
                System.out.println("Yes");
            }
            else
            {
                System.out.println("No");
            }
            start++;
        }

    }
}

Measured memory_bytes: 60408
#include <bits/stdc++.h>
#include <queue>
#include <string>
#include <algorithm>
/*
#include <atcoder/all>
*/

/*
using namespace atcoder;
*/
using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep1(i, n) for (ll i = 1; i < n + 1; i++)
#define repr(i, n) for (ll i = n - 1; i >= 0; i--)
#define repr1(i, n) for (ll i = n; i > 0; i--)
#define FOR(i, j, n) for (ll i = j; i < n; i++)

const ll MOD = 1000000007; // 10^9+7
const ll MOD2 = 998244353;
const ll INF = 10000000000;

int main(void){
    ll k;
    cin >> k;
    rep(i,k){
        cout << "ACL";
    }
    cout << endl;
    return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int cnt[1000001];

int main() {
  in(int, n);
  rep(i, n) {
    in(int, a);
    ++cnt[a];
  }
  for (int i = 1; i <= 1000000; ++i) {
    if (cnt[i] == 0) continue;
    if (cnt[i] > 1) cnt[i] = 0;
    for (int j = i * 2; j <= 1000000; j += i) {
      cnt[j] = 0;
    }
  }
  int ans = 0;
  rep(i, 1000001) ans += cnt[i];
  out(ans);
}


Measured memory_bytes: 7532
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,i,j,k;
	scanf("%d%d",&a,&b);
	for(i=0;i<=a;i++)
	for(j=0;j<=a;j++)
	for(k=0;k<=a,i+j+k<=a;k++)
	{
		if(i+j+k==a&&i*1000+j*5000+k*10000==b)
		{
			printf("%d %d %d",k,j,i);
			return 0;   
		}
	}
    printf("-1 -1 -1");
    return 0;
}

Measured memory_bytes: 256
//ksun48 code - just to mark ac
#include <bits/stdc++.h>
using namespace std;


int main(){
	int n;
	cin >> n;
	vector<pair<int,int> > edges;
	int sum = n;
	if(n % 2 == 0) sum++;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j < i; j++){
			if(i + j == sum) continue;
			edges.push_back({i, j});
		}
	}
	cout << int(edges.size()) << '\n';
	for(auto x : edges){
		cout << x.first << ' ' << x.second << '\n';
	}
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
main()
{
    string t,p;
    getline(cin,t);
    getline(cin,p);
    int k,l,i,j;
    for(i=0;i<=t.size();i++)
    {
        k=1;
        l=i+1;
        if(t[i]==p[0])
        {
            for(j=1;j<p.size();j++,l++)
            {
               if(t[l]!=p[j])
               {
                   k=0;
                   break;
               }
            }
            if(k)
                cout<<i<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 1e5+10;
const int inf = 0x3f3f3f3f;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
#define X first
#define Y second


int main() {
	string x;
	cin>>x;
	if(x == "SUN")
	{
		puts("7");
	}
	else if(x == "MON")
	{
		puts("6");
	}
	else if(x == "TUE")
	{
		puts("5");
	}
	else if(x == "WED")
	{
		puts("4");
	}
	else if(x == "THU")
	{
		puts("3");
	}
	else if(x == "FRI")
	{
		puts("2");
	}
	else if(x == "SAT")
	{
		puts("1");
	}
	return 0;
}

Measured memory_bytes: 256
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

require 'pp'

INT_MAX = 999999999999999999999999

N,M=gets.chomp.split(' ').map{|n| n.to_i}
X = Array.new(N+1)
Y = Array.new(N+1)
Z = Array.new(N+1)
W = Array.new(N)
0.upto(N-1){|d|
	W[d]=gets.chomp.split(' ').map{|n| n.to_i}
}
# DP = Array.new(8){Array.new(M)}
# def sign(d)
# 	d == 0 ? "+"

max = 0
if(M==0)
	puts 0
	exit(0)
end
#max = W.sort{|a,b|b[0]+b[1]+b[2] <=> a[0]+a[1]+b[2]}[0..(M-1)].inject(0){|sum,a|}
max = W.map{|a| a[0]+a[1]+a[2]}.sort{|a,b|b <=> a}[0..(M-1)].inject(0){|sum,a| sum+a}

tmp = W.map{|a| a[0]+a[1]-a[2]}.sort{|a,b|b <=> a}[0..(M-1)].inject(0){|sum,a| sum+a}
if(max < tmp)
	max = tmp
end

tmp = W.map{|a| a[0]-a[1]+a[2]}.sort{|a,b|b <=> a}[0..(M-1)].inject(0){|sum,a| sum+a}
if(max < tmp)
	max = tmp
end

tmp = W.map{|a| a[0]-a[1]-a[2]}.sort{|a,b|b <=> a}[0..(M-1)].inject(0){|sum,a| sum+a}
if(max < tmp)
	max = tmp
end

tmp = W.map{|a| -a[0]+a[1]+a[2]}.sort{|a,b|b <=> a}[0..(M-1)].inject(0){|sum,a| sum+a}
if(max < tmp)
	max = tmp
end

tmp = W.map{|a| -a[0]+a[1]-a[2]}.sort{|a,b|b <=> a}[0..(M-1)].inject(0){|sum,a| sum+a}
if(max < tmp)
	max = tmp
end

tmp = W.map{|a| -a[0]-a[1]+a[2]}.sort{|a,b|b <=> a}[0..(M-1)].inject(0){|sum,a| sum+a}
if(max < tmp)
	max = tmp
end

tmp = W.map{|a| -a[0]-a[1]-a[2]}.sort{|a,b|b <=> a}[0..(M-1)].inject(0){|sum,a| sum+a}
if(max < tmp)
	max = tmp
end

puts max


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

void trace(int a[], int n) {
    for (int i=0; i<n; i++) {
        if ( i > 0 ) printf(" ");
        printf("%d", a[i]);
    }
    printf("\n");
}

int selectionSort(int a[], int n) { //N個の配列の要素を含む0-オリジンの配列a
    int sortNum = 0;
    for (int i=0; i<n; i++) {
        int minj = i;
        for (int j=i; j<n; j++) {
            if (a[j] < a[minj]) minj = j;
        }
        if (minj != i) {
            int temp = a[minj];
            a[minj] = a[i];
            a[i] = temp;
            sortNum++;
        }
    }
    return sortNum;
}

int main() {
    int n;
    int a[110];
    int ans;
    cin >> n;
    for (int i=0; i<n; i++) cin >> a[i];
    ans = selectionSort(a, n);
    trace(a, n);
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int A = 0;
  for(int i = 0; i < N; i++){
    int p , q;
    cin >> p >> q;
    A += q - p + 1;
  }
  cout << A << endl;
}


Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <list>
#include <string>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

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

int main()
{
    int N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
}

void cheatsheet()
{
    // loop
    // vector<int> vec(10);
    vector<int> vecloop;
    REP(i, 10)
    {
        vecloop.push_back(i);
    }

    // swap
    int a = 1;
    int b = 5;
    swap(a, b); // -> a = 5, b = 1

    // sort
    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    sort(arr, arr + 9, greater<int>()); // 9 8 7 6 5 4 3 2 1

    // lower
    vector<int> vec(arr, end(arr));
    sort(vec.begin(), vec.end());
    cout << lower_bound(vec.begin(), vec.end(), 2)[0]; // 2

    // map
    map<Pll, ll> m;
    m[Pll(10, 100)] = 100;
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#include<map>

#define ll long long
using namespace std;
int main() {
	ll a, b, x;
	cin >> a >> b >> x;
	if (a == 0) {
		cout << (b) / x - (max(a - 1, 0LL)) / x+1 << endl;
	}
	else {
		cout << (b) / x - (max(a - 1, 0LL)) / x << endl;
	}
	
}

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

using namespace std;
using p=pair<int,int>;
typedef long long ll;

int main() {
  string s;
  cin >> s;
  int k=s.size();
  string ans;
  rep(i,k){
    ans+='x';
  }
  cout << ans << endl;

  return 0;

}

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



int main() {
	int n = 3;
	vector<int>t(3);
	rep(0, n) {
		cin >> t[i];
	}
	sort(t.begin(), t.end());
	int tmp = 0,count=0;
	rep(0, n) {
		if (i != 0) {
			if (tmp == t[i]) {
				count++;
			}
		}
		tmp = t[i];
		
	}
	if (count == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
def C_Sugar_Water(A, B, C, D, E, F):
    import itertools
    x = set()  # 水の量が取りうるパターン
    y = set()  # 砂糖の量が取りうるパターン
    for i in range(F):
        for j in range(F):
            tmp = 100 * A * i + 100 * B * j
            if tmp <= F:
                x.add(tmp)
    for i in range(F):
        for j in range(F):
            tmp = i * C + j * D
            if tmp <= F:
                y.add(tmp)

    fill = list(itertools.product(x, y))
    concentration = 0  # 砂糖水の濃度
    for k in fill:
        water = k[0]
        sugar = k[1]

        if water == 0 and sugar == 0:
            # 水も砂糖も入れないパターン
            continue
        elif E * (water // 100) < sugar:
            # 砂糖を溶かしきれない
            continue
        elif water + sugar > F:
            # ビーカーに入れられる質量を超えた
            continue
        else:
            if (100 * sugar) / (water + sugar) >= concentration:
                concentration = (100 * sugar) / (water + sugar)
                ans = (water + sugar, sugar)
    print('{} {}'.format(ans[0], ans[1]))
    return None

A,B,C,D,E,F=[int(i) for i in input().split()]
C_Sugar_Water(A, B, C, D, E, F)

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

using namespace std;

int main() {
	int n;
	cin >> n;
	int a = 0;
	int b = n;
	while (b != 0) {
		a += b % 10;
		b /= 10;
	}
	if (n%a == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def resolve():
	seq = list(map(int, input().split()))
	m = max(seq)
	if (3*m - sum(seq)) % 2 == 0:
		print((3*m - sum(seq))//2)
	else:
		print((3*(m+1) - (sum(seq)+2))//2 + 1)
resolve()

Measured memory_bytes: 38700