akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Run(args));
        }

        private static int Run(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var A = input[0];
            var B = input[1];

            var ret = 1;
            ret += (int)Math.Ceiling((float)(B - A) / (float)(A - 1));
            return ret;
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstring>
#include <cstdio>
#define ll long long
using namespace std;

inline int read(){
	int sum=0,f=1;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-') f=-1;c=getchar();}
	while(c<='9'&&c>='0'){sum=sum*10+c-'0';c=getchar();}
	return f*sum;
}

const int N=5005;
struct edge{int to,next;}e[N<<1];
int n,a[N],w[N],l[N];
int head[N],cnt;

inline void add(int x,int y){
	e[++cnt]=(edge){head[x],y};head[x]=cnt;
}

inline void dfs(int x,int fa){
	for(int i=head[x];i;i=e[i].to){
		int k=e[i].next;
		if(k==fa) continue;
		dfs(k,x);
		if(w[k]) continue;
		if(a[k]<a[x]) w[x]=1;
	}
}

signed main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<n;i++){
		int x=read(),y=read();
		add(x,y);add(y,x);
	}
	for(int i=1;i<=n;i++){
		memset(w,0,sizeof(w));
		dfs(i,0);
		if(w[i]) printf("%d ",i);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>
#define N 100000
using namespace std;

int main()
{
    int n;
    cin>>n;
    if(n!=1&&n!=2&&n!=3&&n!=5&&n!=6&&n!=9&&n!=10&&n!=13&&n!=17)
        cout<<"Yes";
    else
        cout<<"No";
}


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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long int lli;

int main()
{
	fio;
	lli n;
	cin>>n;
	if(n%2==0) cout<<n<<endl;
	else cout<<n*2<<endl;
	cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 101415
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

int n,m,k,arr[N];
string s;
void solve()
{
    oset dc[30];
    cin>>n;
    cin>>s;
    n = s.size();
    s = '.'+s;
    forn(i,1,n)
    {
        dc[s[i]-'a'].insert(i);
    }
    int q;
    cin>>q;
    while(q--)
    {
        int a,b,c;char x;
        cin>>a>>b;
        if(a == 1)
        {
            cin>>x;
            c = x-'a';
            dc[s[b]-'a'].erase(b);
            dc[c].insert(b);
            s[b] = x;
        }
        else
        {
            cin>>c;
            c++;
            int ans = 0;
            forn(i,0,25)
            {
                int p = dc[i].order_of_key(c) - dc[i].order_of_key(b);
                if(p == 0);else ans++;
            }
            cout<<ans;nl;
        }
    }
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       clang++ c.cpp ; ./a.out < a.txt ;  

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  string s[N]; rep(i,N) cin >> s[i];

  int result = 0;
  int a = 0, b = 0, ab = 0;
  rep(i,N) {
    int l = s[i].length();
    rep(j,l-1) {
      if (s[i].substr(j,2)=="AB") result++;
    }
    if (s[i][0]=='B'&&s[i][l-1]=='A') ab++;
    else if (s[i][0]=='B') b++;
    else if (s[i][l-1]=='A') a++;
  }
  if (ab) result += (a+b) ? ab+min(a,b) : ab-1;
  else result += min(a,b);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 768
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,n) for(int i=1;i<=n;i++)
#define sint(i) scanf("%d",&i);
#define sintt(i,j) scanf("%d%d",&i,&j);
#define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k);


int n,m;
int maxi;

int masu[100][100];

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

void saiki(int x,int y,int cont){
	
	if(x<0||y<0||x>=n||y>=m||masu[x][y]==0){
		maxi=max(maxi,cont);
		return;
	}
	
	masu[x][y]=0;
	rep(i,4){
		saiki(x+dx[i],y+dy[i],cont+1);
	}
	masu[x][y]=1;
}

int main(){
	while(1){
		sintt(n,m);
		if(n==0)break;
		rep(i,m){
			rep(j,n){
				sint(masu[j][i]);
			}
		}
		
		maxi=0;
		rep(i,m){
			rep(j,n){
				saiki(i,j,0);
			}
		}
		printf("%d\n",maxi);
	}
}

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  if(n == 0) {
    cout << 0 << endl;
    return 0;
  }
  string s = "";
  while(n) {
    if(n%2) {
      s += '1';
      --n;
    } else {
      s += '0';
    }
    n /= -2;
  }
  reverse(ALL(s));
  cout << s << endl;
  return 0;
}
/***** MAIN *****/


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

using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define INF 1e9




int main(){
    int n, k, r, s, p; cin >> n >> k >> r >> s >> p;
    string t; cin >> t;
    
    
    
    vector<string> a(k);
    
    rep(i,k){
        
        for(int j=i; j < n; j+=k){
            
            if(t[j] == 'r') a[i] += 'p';
            if(t[j] == 's') a[i] += 'r';
            if(t[j] == 'p') a[i] += 's';
            
            
            
        }
     
    }
    int ans = 0;
    rep(i,k){
        for(int j=1; j<a[i].size(); j++){
            
            if(a[i][j] == a[i][j-1]) {
                a[i][j] = 'x';
                continue;
                
            }
            if(a[i][j] == 'r') ans += r;
            if(a[i][j] == 's') ans += s;
            if(a[i][j] == 'p') ans += p;
        }
        if(a[i][0] == 'r') ans += r;
        if(a[i][0] == 's') ans += s;
        if(a[i][0] == 'p') ans += p;
    }
    
    cout << ans << endl;
    
    
    
}




Measured memory_bytes: 5120
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  while(true){
    string s;
    int l;
    cin >> s >> l;
    if(s == "0" && l == 0) break;

    map<int, int> mp;

    mp[stoi(s)] = 0;

    int i = 1;
    while(true){
      
      while(s.length() < l){
        s += "0";
      }

      string mn = s, mx = s;
      sort(ALL(mn));
      sort(ALL(mx), greater<char>());
      
      int num = stoi(mx) - stoi(mn);
      
      if(mp.find(num) != mp.end()){
        cout << mp[num] << " " << num << " " << i - mp[num] << endl;
        break;
      }
      mp[num] = i;
      
      s = to_string(num);
      i++;
   }
  }
  return 0;
}




Measured memory_bytes: 3292
#include <stdio.h>

int main(){
int n,min,max;
double sum = 0;
int val;
int n_memoly;


scanf("%d",&n);
n_memoly = n;
while(n != 0){

scanf("%d",&val);
if (n_memoly == n){
max = val;min = val;sum = val;
n--;
continue;
}
sum += val;
if (min > val){
min = val;
}
if (max < val){
max = val;
}
n--;
}

printf("%d %d %.0lf\n",min,max,sum);
return 0;
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
 
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int x;
cin >> x;
((x / 10 == 9) || (x%10==9)) ? cout << "Yes\n" : cout << "No\n";
return 0;
}

Measured memory_bytes: 256
var
  n,i,j,ax,ay,ah:longint;
  x,y,h:array[0..100]of longint;
  f:boolean;
begin
  readln(n);
  for i:=1 to n do
    readln(x[i],y[i],h[i]);
  for ax:=0 to 100 do
    for ay:=0 to 100 do
      begin
        ah:=-1;  f:=true;
        for i:=1 to n do
          if h[i]<>0 then
            begin
              if ah=-1 then ah:=h[i]+abs(ax-x[i])+abs(ay-y[i]) else
              if ah<>h[i]+abs(ax-x[i])+abs(ay-y[i]) then
                begin
                  f:=false;
                  break;
                end;
            end;
		for i:=1 to n do if h[i]=0 then 
		if ah-(abs(ax-x[i])+abs(ay-y[i]))>0 then f:=false;
        if f=true then begin  write(ax,' ',ay,' ',ah); exit; end;
      end;
end.


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string arr;
	cin>>arr;
	
	int sum=0; //hitam 0 duluan
	for (int i=0;i<arr.length();i++)
	{
		if (i%2==1)
		{
			if (arr[i]=='1')
			{
				sum++;
			}
		}
		else
		{
			if (arr[i]=='0')
			{
				sum++;
			}
		}
	}
	
	int mini=sum;
	
	int suma=0; //putih 1 duluan
	for (int i=0;i<arr.length();i++)
	{
		if (i%2==1)
		{
			if (arr[i]=='0')
			{
				suma++;
			}
		}
		else
		{
			if (arr[i]=='1')
			{
				suma++;
			}
		}
	}
	
	if (suma<mini)
	{
		mini=suma;
	}
	
	cout<<mini<<"\n";
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,d;
long long read(){
    long long ret=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-f;ch=getchar();}
    while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
    return ret*f;
}

signed main(){
    //ios::sync_with_stdio(false);
    n=read();d=read();
    int num=2*d+1;
    int ans=n/num;
    if(n%num){
    	ans++;
	}
	cout <<ans<<endl;
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
dp=[float('inf')]*(n+1)
dp[1]=0
dp[0]=0
dp[2]=dp[1]+abs(h[1]-h[0])
for i in range(1,n-1):
  dp[i+2]=min(dp[i+1]+abs(h[i+1]-h[i]),dp[i]+abs(h[i+1]-h[i-1]))
  

print(dp[n])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
class UF {
public:
    vector<int> fa;
    vector<int> sz;
    int n;
    int comp_cnt;

public:
    UF(int _n) : n(_n), comp_cnt(_n), fa(_n), sz(_n, 1) {
        iota(fa.begin(), fa.end(), 0);
    }

    int findset(int x) {
        return fa[x] == x ? x : fa[x] = findset(fa[x]);
    }

    void unite(int x, int y) {
        if (sz[x] < sz[y]) {
            swap(x, y);
        }
        fa[y] = x;
        sz[x] += sz[y];
        --comp_cnt;
    }

    bool findAndUnite(int x, int y) {
        int x0 = findset(x);
        int y0 = findset(y);
        if (x0 != y0) {
            unite(x0, y0);
            return true;
        }
        return false;
    }
};
int main() {
    int n, m;
    cin >> n >> m;
    UF uf(2e5 + 100);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        uf.findAndUnite(a, b);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, uf.sz[i]);
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4816
#include<bits/stdc++.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	if (S == "SUN") { cout << 7 << endl; }
	if (S == "MON") { cout << 6 << endl; }
	if (S == "TUE") { cout << 5 << endl; }
	if (S == "WED") { cout << 4 << endl; }
	if (S == "THU") { cout << 3 << endl; }
	if (S == "FRI") { cout << 2 << endl; }
	if (S == "SAT") { cout << 1 << endl; }
}

Measured memory_bytes: 256
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N, T;
int c[110], t[110];

int main() {
  // cout.precision(15);

  cin >> N >> T;
  int min_ = 3000;
  loop(n,0,N) {
    cin >> c[n] >> t[n];
    if (t[n] <=T) chmin(min_, c[n]);
  }

  if (min_ == 3000) cout << "TLE" << endl;
  else cout << min_ << endl;
  return 0;
}


Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    string O, E;
    cin >> O >> E;
    string ans = "";
    while(O.size() > 0 | E.size() > 0) {
        if (O.size() > 0) {
            ans += O.substr(0,1);
            O = O.substr(1, O.size()-1);
        }
        if (E.size() > 0) {
            ans += E.substr(0,1);
            E = E.substr(1, E.size()-1);
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<ll, ll>;
const int maxn = 4079, mlg = 17, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
	cin.tie(0)->sync_with_stdio(0);
	string s;
	cin >> s;
	for(auto &i : s) if(i == '?') i = 'D';
	cout << s;
}


Measured memory_bytes: 3748
use std::io::*;

struct Dice {
  top: usize,
  front: usize,
  right: usize
}

impl Dice {
  fn build(top: usize, front: usize) -> Self {
    Self {
      top: top,
      front: front,
      right: Self::right_of(top, front)
    }
  }

  fn right_of(top: usize, front: usize) -> usize {
    let (a, b) = (top > 2, front > 2);

    let t = if a { 5 - top } else { top };
    let f = if b { 5 - front } else { front };

    let right = match (t, f) {
      (0, 1) => 2,
      (1, 2) => 0,
      (2, 0) => 1,
      (1, 0) => 3,
      (2, 1) => 5,
      (0, 2) => 4,
      _ => unreachable!()
    };

    if a ^ b { 5 - right } else { right }
  }

  fn left(&self) -> usize { 5 - self.right }

  fn back(&self) -> usize { 5 - self.front }

  fn bottom(&self) -> usize { 5 - self.top }
}

fn main() {
  let stdin = stdin();
  let mut lines = stdin.lock().lines();

  let n = lines.next().unwrap().unwrap().parse::<usize>().unwrap();

  let dices = (0..n).map(|_| {
    let line = lines.next().unwrap().unwrap();
    line.split_whitespace().map(|s| s.parse::<usize>().unwrap()).collect::<Vec<_>>()
  }).collect::<Vec<_>>();

  for (i, labels_a) in dices.iter().take(n - 1).enumerate() {
    let top    = labels_a[0];
    let front  = labels_a[1];
    let right  = labels_a[2];
    let left   = labels_a[3];
    let back   = labels_a[4];
    let bottom = labels_a[5];

    for labels_b in dices.iter().skip(i + 1) {
      // top
      let tops = labels_b.iter().enumerate()
        .filter(|&(_, &b)| top == b);

      for (i, _) in tops {
        // front
        let fronts = labels_b.iter().enumerate()
          .filter(|&(j, &b)| front == b && j != i && j != (5 - i));

        for (j, _) in fronts {
          let dice = Dice::build(i, j);

          if right != labels_b[dice.right] { break; }

          if left != labels_b[dice.left()] { break; }

          if back != labels_b[dice.back()] { break; }

          if bottom != labels_b[dice.bottom()] { break; }

          println!("No");
          return;
        }
      }
    }
  }

  println!("Yes");
}



Measured memory_bytes: 5036
n,m = map(int, input().split())
l = [list(map(int,input().split())) for _ in range(n)]
cnt = 0
ans = 0
l.sort(key=lambda x:x[0])
for i in range(n):
    cnt += l[i][1]
    ans += l[i][0] * l[i][1]
    if cnt > m:
        ans -= l[i][0] * l[i][1]
        ans += l[i][0]*(m-(cnt-l[i][1]))
        break
print(ans)


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

set <pair <int, int>> s;
int tmin[200010]; /// cand ajung cel mai devreme pe col i
int hmin[200010];

int main()
{
	int n, h, w;
	cin >> h >> w >> n;

	if (h == 1) {
		cout << 1 << '\n';
		return 0;
	}

	vector <pair <int, int>> v(n);

	for (auto & i : v) {
		cin >> i.first >> i.second;
		s.insert({ i.first, i.second });
	}

	if (s.find({ 2, 1 }) != s.end()) {
		cout << "1\n";
		return 0;
	}

	int ans = h;

	hmin[1] = 1;

	for (int i = 2; i <= w; i++) {
		hmin[i] = 1 + hmin[i - 1];
		while (s.find({ hmin[i], i }) != s.end())
			hmin[i]++;
	}

	for (auto i : v) {
		if (i.first < hmin[i.second])
			continue;
		ans = min(ans, i.first - 1);
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 11904
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;
static const int N=100;
static const int INFTY = (1<<21);

int n,M[N][N];
int d[N];

void bfs (int s){
    queue <int> q;
    q.push(s);
    for (int i=0;i<n;i++){
        d[i] = INFTY;
    }
    d[s] = 0;
    int u;
    while (!q.empty()){
        u = q.front();
        q.pop();
        for (int v=0;v<n;v++){
            if (M[u][v] == 0){
                continue;
            }
            if(d[v] != INFTY){
                continue;
            }
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for (int i=0;i<n;i++){
        cout << i+1 << " " << ((d[i]==INFTY) ? (-1) : d[i]) << endl;
    }
}

int main(){
    
    int u,k,v;
    cin >> n;
    for (int i=0;i<n;i++){
        for (int j=0;j<n;j++){
            M[i][j] = 0;
        }
    }
    for (int i=0;i<n;i++){
        cin >> u >> k;
        u--;
        for (int j=0;j<k;j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    bfs(0);

}


Measured memory_bytes: 3152
#include <stdio.h>

int main (void){
int k,i,j,x,y,n,adj[200][200];

scanf("%d",&n); 

for(k=0;k<n;k++){
scanf("%d",&x); 
scanf("%d",&i);
for(j=0;j<i;j++){
scanf("%d",&y);
adj[x][y]=1;
}
}

for(k=1;k<=n;k++){
for(i=1;i<=n;i++){
printf("%d",adj[k][i]);
if(i!=n) printf(" ");
}
printf("\n");
}

}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define x real()
#define y imag()
using namespace std;
typedef complex<double> point;

double dot(point a,point b){return a.x*b.x+a.y*b.y;}
double cross(point a,point b){return a.x*b.y-a.y*b.x;}
int ccw(point a,point b,point c){
  point d = b-a,e = c-a;
  if(cross(d,e)>0) return 1;//"COUNTER_CLOCKWISE"
  if(cross(d,e)<0) return -1;//"CLOCKWISE"
  if(dot(d,e)<0) return 2;//"ONLINE_BACK"
  if(abs(d) < abs(e)) return -2;//"ONLINE_FRONT"
  return 0;//"ON_SEGMENT"
}

point crosspoint(point a,point b,point c,point d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

vector<point> ConvexCut(vector<point> &polygon,point a,point b){
  vector <point> res;
  for(int i=0;i<polygon.size();i++){
    point A=polygon[i],B=polygon[(i+1)%polygon.size()];
    if(ccw(a,b,A)!=-1)res.push_back(A);
    if(ccw(a,b,A)*ccw(a,b,B)==-1)res.push_back(crosspoint(a,b,A,B));
  }
  return res;
}

double get_area(vector <point> &polygon){
  if(polygon.size()<3)return 0;
  double res=0;
  for(int i=0;i<polygon.size();i++)
    res+=cross(polygon[i],polygon[(i+1)%polygon.size()])/2;
  return res;
}

int main(){
  while(1){
    int n,d;
    double V;
    vector <point> pl;
    cin>>n>>d>>V;
    if(!n&&!d&&!V) break;
    for(int i=0,a,b;i<n;i++) cin>>a>>b,pl.push_back(point(a,b));
    V=min(get_area(pl)*d,V);

    double ans=0;
    for(int i=0;i<n;i++){
      double L=0,M,R=2010;
      int I=100;
      while(I--){
	M=(L+R)/2;
	point h=pl[(i+1)%n]-pl[i],b=h;
	h=(point(0,M)*h/abs(h))+pl[i];
	vector<point> a=ConvexCut(pl,h+b,h);
	if(get_area(a)*d>=V)R=M;
	else L=M+0.00000001;
      }
      ans=max(ans,L);
    }
    printf("%.8f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1276
n, k = map(int, input().split())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

ans = Base_10_to_n(n,k)

print(len(ans))

Measured memory_bytes: 3060
#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<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

int prime(int n){
    int cnt = 0;

    for (int i = 1; i <= n; ++i) {
        if(n % i == 0){
            cnt++;
        }
    }

    return cnt;
}


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

    int n;
    cin >> n;
 
    int ans = 0;
    for (int i = 1; i <= n; i += 2) {
        if(prime(i) == 8){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import math
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

x,y=map(int,input().split())
if x/2>y:
 print(0)
else:
 if y/2>x:
  print(0)
 else:
  if (x+y)%3==0:
   a=(2*x-y)/3
   b=(2*y-x)/3
   c = cmb(int(a+b),int(a),mod)
   print(int(c))
  else:
   print(0)


Measured memory_bytes: 121964
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
struct Grid{
    int a,num;
    bool operator<(const Grid&right)const{return a<right.a;}
};
struct Edge{
    int len,a,b;
    bool operator<(const Edge&right)const{return len<right.len;}
};

int n,par[100009],ans,cnt;
Grid X[100009],Y[100009];
vector<Edge> e;

int root(int x){
    if(x==par[x])return x;
    else return par[x]=root(par[x]);
}

signed main(){
    cin>>n;
    cnt=n-1;
    rep(i,n){
        int x,y;
        cin>>x>>y;
        X[i]={x,i};
        Y[i]={y,i};
        par[i]=i;
    }
    sort(X,X+n);
    sort(Y,Y+n);
    rep(i,n-1){
        e.push_back({X[i+1].a-X[i].a,X[i].num,X[i+1].num});
        e.push_back({Y[i+1].a-Y[i].a,Y[i].num,Y[i+1].num});
    }
    sort(e.begin(),e.end());
    for(int i=0;cnt;i++){
        if(root(e[i].a)!=root(e[i].b)){
            par[root(e[i].b)]=root(e[i].a);
            ans+=e[i].len;
            cnt--;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12272
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, std::vector<long long> A){
  ll ans = 0;
  ll cnt = 0;
  for(auto x: A) {
    if(x) {
      cnt+=x;
    } else {
      ans+=cnt/2;
      cnt=0;
    }
  }
  ans+=cnt/2;
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}



Measured memory_bytes: 1024
n = int(input())
l = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    l.append((i + 1, s, p))
l.sort(key=lambda x: x[2], reverse=True)
l.sort(key=lambda x: x[1])
for i in range(n):
    print(l[i][0])

Measured memory_bytes: 3064
#include <cstdio>

int N,T;
int ts[200008];
int main() {
	scanf("%d%d",&N,&T);
	int sol=T;
	for(int i=0;i<N;i++) {
		scanf("%d",&ts[i]);
		if(i) {
			if(ts[i-1]+T>ts[i]) {
				sol+=ts[i]-ts[i-1];
			} else {
				sol+=T;
			}
		}
	}
	printf("%d\n",sol);
	return 0;
}


Measured memory_bytes: 896
/* B Partition */

#include<stdio.h>
int n; /* 1<=n<=100000 */

int Partition(int A[], int p, int r);

int main(){
  int i;
  int q;

  scanf("%d",&n);
  int A[n];

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  q=Partition(A, 0, n-1);

  for(i=0;i<n-1;i++){
    if(q==i)printf("[%d] ",A[i]); /* to print [] */
    else printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);

  return 0;
}


int Partition(int A[], int p, int r){
  int i, j, x;
  int temp;

  x=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i=i+1;
      temp=A[i]; /* exchange */
      A[i]=A[j];
      A[j]=temp;
    }
  }
  temp=A[i+1]; /* exchange */
  A[i+1]=A[r];
  A[r]=temp;
  return i+1;
}

Measured memory_bytes: 800
n = int(input())
abc = [list(input()) for _ in range(3)]
ans = 2 * n
for j in range(n):
    x = 0
    for i in range(3):
        if abc[i][j] == abc[(i + 1) % 3][j]:
            x += 1
        if x >= 2:
            break
    ans -= x
print(ans)

Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	int n,m;
	int i,j,k;
	int s[1000000];
	cin >> n;
	if(n==1){
		cout << "Yes";
		return 0;	
	}
	for(i=0;i<n;i++){
		cin>>s[i];
	}
	for(i=0;i<n-1;i++){
		if(s[i]>s[i+1]){
			int t=i;
			while(t<n){
				if(s[i]-s[t]>1){
					cout << "No";
					return 0;
				}
				t++;
			}
			
			
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 2304
function Main(input){
  input = input.trim().split('\n').map(x=>(x.split(' ').map(y=>parseInt(y))));
  var n = input[0][0];
  var m = input[0][1];
  var heights = input[1];
  var good = Array(n).fill(1);
  for (let i=0;i<m;i++){
    var mts = input[i+2];
    if (heights[mts[0] - 1] <= heights[mts[1] - 1]){
      good[mts[0] - 1] = 0;
    }
    if (heights[mts[1] - 1] <= heights[mts[0] - 1]){
      good[mts[1] - 1] = 0;
    }
  }
  var ans = 0;
  for (let i=0;i<n;i++){
    if (good[i] == 1){
      ans++;
    }
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 67932
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define maxn 100005
#define ll long long

#define DEBUG
#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << "  "
#else
#define debug(x) ;
#endif

ll x;

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

    cin >> x;
    ll h;
    h = x / 500;
    h = h * 1000 + (x - h*500) / 5 * 5;
    cout << h << endl;

    return 0;
}

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

int N, Q;
typedef pair<int, pair<bool, int>> event; // time, operation, location
vector<event> events;
set<int> effective_x;

int main(){
    cin >> N >> Q;
    for(int n = 0; n < N; n++){
        int S, T, X;
        cin >> S >> T >> X;
        event e1 = make_pair(S - X, make_pair(true, X));
        event e2 = make_pair(T - X, make_pair(false, X));
        events.push_back(e1);
        events.push_back(e2);
    }
    sort(events.begin(), events.end());
    int next_event_idx = 0;
    for(int q = 0; q < Q; q++){
        int D;
        cin >> D;
        while(
              next_event_idx < events.size() &&
              D >= events[next_event_idx].first
              ){
            event e = events[next_event_idx];
            if(e.second.first){
                effective_x.insert(e.second.second);
            }else{
                effective_x.erase(e.second.second);
            }
            next_event_idx++;
        }
        if(effective_x.empty()){
            cout << -1 << endl;
        }else{
            cout << *effective_x.begin() << endl;
        }
    }
}


Measured memory_bytes: 16364
N = int(input())
A = list(map(int, input().split()))
sumD = {}
asum = 0
for i, a in enumerate(A):
    asum += a
    if asum in sumD:
        sumD[asum] += 1
    else:
        sumD[asum] = 1
ans = 0
for D in sumD:
    if D == 0:
        ans += sumD[0]        
    if sumD[D] > 1:
        ans += sumD[D] * (sumD[D] - 1) / 2
print(int(ans))

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

	
	return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ff first
#define ss second
using namespace std;
const int N=1005;
const long long M=1e9+7;
typedef long long ll;
typedef long double lb;
inline void read(int &x){x=0; char ch=getchar();while(ch<'0') ch=getchar();while(ch>='0'){x=x*10+ch-48; ch=getchar();}}
//------------------------------------------head---------------------------------------------------//
ll f[N][N],C[N][N],fac[N],inv[N];
inline ll po(ll x,ll y)
{
	ll ans=1;
	while(y)
	{
		if(y&1) ans=ans*x%M;
		x=x*x%M; y>>=1;
	}return ans;
}
int main()
{
	int n,a,b,c,d;read(n);read(a);read(b);read(c);read(d);
	fac[0]=1;rep(i,1,1000)
	{
		fac[i]=fac[i-1]*(ll)i%M;
		inv[i]=po(fac[i],M-2ll);
	}
	C[0][0]=1;rep(i,1,1000) 
	{
		C[i][0]=1;
		rep(j,1,i)
		{
			C[i][j]=C[i-1][j]+C[i-1][j-1];
			C[i][j]%=M;
		}
	}
	f[a][0]=1;
	rep(i,a,b)
	{
		rep(j,0,n)
		{
			ll tot=1;if(j+i*c<=n) rep(tt,1,c-1) tot=tot*C[n-j-(tt-1)*i][i]%M;
			for(int k=j+i*c;k<=n && k<=j+i*d;k+=i)
			{
				tot*=C[n-k+i][i]; tot%=M; f[i+1][k]+=f[i][j]*tot%M*inv[(k-j)/i]; 
				f[i+1][k]%=M;//printf("%d %d %d %lld\n",i,j,k,tot);
			}//puts("");
			f[i+1][j]+=f[i][j];
			if(f[i+1][j]>=M) f[i+1][j]-=M;
		}
	}
	printf("%d\n",(int)f[b+1][n]);return 0;
}

Measured memory_bytes: 14976
import sys
readline = sys.stdin.buffer.readline


def main():
    n = int(readline())
    m = int(readline())
    mod = 10**9 + 7
    n = str(n)
    n_len = len(n)
    dp = [[[0 for _ in range(m)] for _ in range(2)] for _ in range(n_len + 1)]
    dp[0][0][0] = 1

    for i in range(n_len):
        n_n = int(n[i])
        for j in range(2):
            for k in range(m):
                for d in range(10):
                    if j == 1 or (j == 0 and d < n_n):
                        j_n = 1
                    elif d == n_n:
                        j_n = 0
                    else:
                        continue
                    k_n = (k + d % m) % m
                    dp[i + 1][j_n][k_n] += dp[i][j][k] % mod
    print((dp[-1][0][0] + dp[-1][1][0] - 1) % mod)


if __name__ == "__main__":
    main()


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(1);
    int n;cin>>n;
    int sig=1;
    for(int i=0;i<n;++i){
        int c;cin>>c;
        if (c==sig) ++sig;
    }
    if (sig>1)
        cout << n - (sig-1);
    else
        cout << -1;

    return 0;
}



Measured memory_bytes: 256
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 998244353ll
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
int dp[310][100000][2][2];
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

    int n;
    cin>>n;
    vi in(n);
    rep(i,n)cin>>in[i];
    int sum=0;
    rep(i,n)sum+=in[i];
    rep(i,310)rep(j,100000)rep(k,2)rep(l,2)
        dp[i][j][k][l]=0;
    dp[0][0][0][0]=1;
    rep(i,n)rep(j,sum+1)rep(k,2)rep(l,2){
        (dp[i+1][j+in[i]][k][l]+=dp[i][j][k][l])%=MOD;
        (dp[i+1][j][k|1][l]+=dp[i][j][k][l])%=MOD;
        (dp[i+1][j][k][l|1]+=dp[i][j][k][l])%=MOD;
    }
    int out=powmod(3,n)-3*powmod(2,n)+3+3*MOD;
    out%=MOD;
    rep(i,sum+1)if(2*i>=sum)(out+=3*MOD-3*dp[n][i][1][1])%=MOD;
    cout<<out<<endl;
}


Measured memory_bytes: 968960
import sys
from string import digits

k = int(sys.stdin.readline().rstrip())

def main():
    r = k
    if r <= 9:
        print(digits[r])
        return
    res = list(digits[1:])
    r -= 9
    while True:
        nex = []
        for n in res:
            o = ord(n[-1])
            for i in range(-1, 2):
                tail = chr(o+i)
                if tail < '0' or tail > '9': continue
                nex.append(n+tail)
                r -= 1
                if r == 0:
                    print(nex[-1])
                    return
        res = nex.copy()    

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 9176
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>

#define REP(i,n) for(int i=0;i<n;i++)
#define ll long long int

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

int main() {
  int d, n;
  cin >> d >> n;
  int result;
  if (d == 1) {
    if (n == 100) {
      result = 100*n + 100;
    } else {
      result = 100*n;
    }
  } else if(d == 2) {
    if (n == 100) {
      result = 10000*n + 10000;
    } else {
      result = 10000*n;
    }
  } else {
    if(n == 100) {
      result = 101;
    } else {
      result = n;
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n,d,b[200005],a[200005],i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
	scanf("%d",&a[i]);
	b[i]=a[i];
	}
	sort(b,b+n);
	for(i=0;i<n;i++)
	{if(a[i]!=b[n-1])printf("%d\n",b[n-1]);
	 else printf("%d\n",b[n-2]);
	}
}


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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 1e4;

void solve () {
	ll n;
	cin >> n;
	ll cnt[n + 1] = {0};
	bool ok = false;
	for (ll x = 1; x <= N; x++) {
		if (x * x + 2 * x + 3 > n) 
			break;
		for (ll y = 1; y <= N; y++) {
			if (x * x + y * y + 1 + x * y + y + x > n)
				break;
			for (ll z = 1; z <= N; z++) {
				ll p = x * x + y * y + z * z + x * y + y * z + z * x;
				if (p > n) {
					break;
				}
				cnt[p]++;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << cnt[i] << "\n";
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
  #endif
	int t = 1;
	while (t--) {
		solve();
	}
 	return 0;
}

Measured memory_bytes: 3688
#include<stdio.h>
#include<stdio.h>
//小さい順にソート
int c[200002];
void merge(int i,int j,int *s){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d]=s[b];
        b++;
      }
      else if(j<b){
        c[d]=s[a];
        a++;
      }
      else if(s[a]<s[b]){
        c[d]=s[a];
        a++;
      }
      else{
        c[d]=s[b];
        b++;
      }
    }
    for(d=i;d<=j;d++)
      s[d]=c[d];
  }
}

int main(){
  int n,m,i;
  scanf("%d%d",&n,&m);
  int x[m+1],middle[m],min=0;
  for(i=0;i<m;i++)
    scanf("%d",&x[i]);
  merge(0,m-1,x);
  if(m==1){
    printf("0\n");
    return 0;
  }
  for(i=0;i<m-1;i++)
    middle[i]=x[i+1]-x[i];
  merge(0,m-2,middle);
  for(i=0;i<m-n;i++)
    min+=middle[i];
  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 1280
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost::multiprecision;  
//using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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


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

    int k;
    cin >> k;

    int x = 7;

    for(int i = 1; i <= 2e6; ++i){
        x %= k;
        if(x == 0){
            cout << i << '\n';
            return (0);
        }
        x = x * 10 + 7;
    }

    cout << -1 << '\n';

    return 0;
}



Measured memory_bytes: 3640
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //３つの整数 a、b、c を読み込み、
        //a から b までの整数の中に、c の約数がいくつあるかを求めるプログラムを作成してください
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int y = 0, x;
        for (x = a; x <= b; x++){
            if (c % x == 0) {
                y += 1;
            }
             
        }
        System.out.println(y);
    }
}


Measured memory_bytes: 26144
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A = int(_in[0])
    B = int(_in[1])
    C = int(_in[2])
    X = int(_in[3])
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    for a in range(A+1):
        for b in range(B+1):
            for c in range(C+1):
                if 500*a+100*b+50*c==X:
                    cnt += 1
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


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

int main(){
	int a,b;
	cin >> a >> b;
	if(a+b == 3){
		cout << 3 << endl;
	}else if(a+b == 4){
		cout << 2 << endl;
	}else if(a+b == 5){
		cout << 1 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define maxn 100003
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pi;

LL n,x,m,ans;
LL res[maxn];
LL sum[maxn];
map<LL,int> idx;
map<LL,int>::iterator it;

int main() {
	scanf("%lld%lld%lld",&n,&x,&m);
	res[1] = sum[1] = x;
	idx[x] = 1;
	for( int i = 2 ; i <= n ; i++ ) {
		LL val = (res[i-1]*res[i-1])%m;
		it = idx.find(val);
		if(it == idx.end()) {
			idx[val] = i;
			res[i] = val;
			sum[i] = sum[i-1]+val;
		}
		else {
			int l = it->se;
			int r = i;
			LL ans = sum[l-1];
			int len = r-l;
			LL times = (n-(l-1))/len;
			int rem = (n-(l-1))%len;
			LL block = sum[r-1]-sum[l-1];
			ans += block*times;
			ans += sum[l-1+rem] - sum[l-1];
			printf("%lld\n",ans);
			exit(0);
		}
	}
	printf("%lld\n",sum[n]);
	return 0;
}

Measured memory_bytes: 7728
from collections import deque

H, W = map(int,input().split())
CH, CW = map(int,input().split())
DH, DW = map(int,input().split())

S = []
for _ in range(H):
    S.append(list(input()))

d = [[-1 for i in range(W)] for j in range(H)]

Q = deque([[CH - 1, CW - 1, 0]])

while len(Q) != 0:
    x, y, cnt = Q.popleft()
    
    if d[x][y] != -1:
        continue
    
    d[x][y] = cnt
    
    for tx in range(-2, 3):
        for ty in range(-2, 3):
            nx = x + tx
            ny = y + ty
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == ".":
                if abs(tx) + abs(ty) == 1:
                    Q.appendleft([nx, ny, cnt])
                elif abs(tx) + abs(ty) >= 2:
                    Q.append([nx, ny, cnt + 1])

print(d[DH - 1][DW - 1])

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

#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector< pi > 
#define ff first
#define ss second
const int N=2000010;
int a[N],mx[N],mn[N];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<(1<<n);i++)
    {
        cin>>a[i];
        mx[i]=a[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int k=1;k<(1<<n);k++)
        {
            if(k&(1<<i))
            {
                if(mx[k-(1<<i)]>=mx[k])
                {
                    mn[k]=mx[k];
                    mx[k]=mx[k-(1<<i)];
                }
                else if(mx[k-(1<<i)]>mn[k])
                    mn[k]=mx[k-(1<<i)];
                if(mn[k-(1<<i)]>mn[k])
                    mn[k]=mn[k-(1<<i)];
            }
        }
    }
    int res=0;
    for(int k=1;k<(1<<n);k++)
    {
        res=max(res,mx[k]+mn[k]);
        cout<<res<<"\n";
    }
    return 0;
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fo(i,n) for(i=0;i<n;i++)
#define fok(i,k,n) for(i=k;i<n;i++)
#define ci(x) cin>>x;
#define ci2(x,y) cin>>x>>y;
#define co(x) cout<<x<<"\n";
#define co2(x,y) cout<<x<<" "<<y<<"\n";
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;

void Main() {
  
}


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

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

	long long c[n];
	c[0] = a[0];
	for (int i = 1; i < n; i++) {
	c[i] = a[i] + c[i - 1];
	}
	long long ans = 9999999999999999;
	long long f = 0, b = 2;
	for (int i = 1; i < n - 2; i++){
	long long p = c[f], q = c[i] - c[f];
	for (int j = f + 1; j < i; j++) {
		if (abs(p - q) > abs(c[j] - (c[i] - c[j]))) {
			p = c[j];
			q = c[i] - c[j];
			f = j;
		}
		else{
			break;
		}
	}

    long long r = c[b] - c[i], s = c[n - 1] - c[b];
    for (int j = b + 1; j < n; j++) {
      if (abs(r - s) > abs((c[j] - c[i]) - (c[n - 1] - c[j]))) {
        r = c[j] - c[i];
        s = c[n - 1] - c[j];
        b = j;
      } else {
        break;
      }
    }

    long long ma = max(max(max(p, q), r), s);
    long long mi = min(min(min(p, q), r), s);
    ans = min(ans, ma - mi);

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


Measured memory_bytes: 2560
n = int(input())
graph = [[0 for i in range(n)] for j in range(n)]

for i in range(n):
   a = list(map(int, input().split()))
   for j in range(0, a[1], 1):
       graph[a[0] - 1][a[2 + j] - 1] = 1

for i in range(n):
    print(' '.join(map(str, graph[i])))


Measured memory_bytes: 5684
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;


long long int N, M, K, H, W, L, R;

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

	cin >> N;
	set<int>s;
	s.insert(1999);
	for (int i = 2; i <= 1000; i++) {
		int box = i * i;
		while (box <= 1000) {
			s.insert(2000-box);
			box *= i;
		}
	}
	cout << 2000 - *s.lower_bound(2000 - N) << endl;
	return 0;
}


Measured memory_bytes: 256