akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long LL;
LL n,m,l,A[100][100],B[100][100],C[100][100],t;
int main() {
	cin>>n>>m>>l;
	for(int i =0; i<n; i++)
		for(int j=0; j<m; j++) {
			cin>>t,A[i][j]=t;
		}
	for(int i =0; i<m; i++)
		for(int j=0; j<l; j++) {
			cin>>t,B[i][j]=t;
		}
	for(int i =0; i<n; i++)
		for(int j=0; j<l; j++) {
			t=0;
			for(int k=0;k<m;k++)
				t+=A[i][k]*B[k][j];
			C[i][j]=t;
		}
	for(int i =0; i<n; i++) {
		for(int j=0; j<l; j++) {
			if(j==l-1)
			cout<<C[i][j];
			else
			cout<<C[i][j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  vector<string>ans(9);
  ans[0]=s[0];
  for(int bit=0;bit<(1<<3);bit++){
    //cout<<bit<<endl;
    int sum=s[0]-'0';
    for(int i =0; i<3;i++){
      //cout<<i<<"aaa"<<endl;
      if(bit&(1<<i)){
        sum+=s[i+1]-'0'; 
        ans[2*(i+1)]=s[i+1];
        ans[2*i+1]='+';
      }
      else{
        sum-=s[i+1]-'0';
        ans[2*(i+1)]=s[i+1];
        ans[2*i+1]='-';
      }
    }

    if(sum==7){
      ans[7]='=';
      ans[8]='7';
      break;
    }
    
  }
  rep(i,9)cout<<ans[i];
  }

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*{
  }*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

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

signed main() {
  int n, m;
  cin >> n >> m;

  vi a(n);
  rep(i, 0, n){
    cin >> a[i];
  }
  
  vi b(n);
  rep(i, 0, n){
    int t = a[i];
    while(t%2 == 0){
      t /= 2;
      b[i]++;
    }
    
    if(i > 0 and b[i-1] != b[i]){
      cout << 0 << endl;
      return 0;
    }
  }


  int lcm = a[0]/2;
  rep(i, 1, n) lcm = lcm * a[i]/2 / gcd(a[i]/2, lcm);

  int ans = m / lcm;
  if(ans%2) ans++;
  cout << ans/2 << endl;

  return 0;
}



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

int main() {
  int a,b,n;
  cin >> n >> a >> b;
  int x,y;
  if (a-b>=0) {
    x=b;/*両方読んでいる最大数*/
  }
  else {
    x=a;
  }
  if (a+b-n>0) {
    y=a+b-n;
  }
  else{
    y=0;
  }
  cout << x << " " << y << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define mp make_pair
#define PI acos(-1)
using namespace std;
ll a[104];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i,j,k,x,y,z,m,t,n,b,c,d,l,r;
    cin>>n;
    for(i=1; i<=n; i++)
        cin>>a[i];
    ll cnt=0;
    for(i=1; i<=n; i++)
    {
        for(j=i+1; j<=n; j++)
        {
            for(k=j+1; k<=n; k++)
            {
                if(a[i]==a[j] || a[i]==a[k] || a[j]==a[k])
                    continue;
                if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i])
                    cnt++;
            }
        }
    }
    cout<<cnt<<'\n';
}








Measured memory_bytes: 3652
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int x, y, z; cin >> x >> y >> z;
    cout << (x - z) / (y + z) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int a[200005];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	long long ans1=0,ans2=0,r=0;
	long long cnt=0;
	for(int l=1;l<=n;l++){
		while(((ans1+a[r+1])==(ans2^a[r+1]))&&r<n) ans1+=a[++r],ans2^=a[r];
		cnt+=(r-l+1);
		ans1-=a[l];
		ans2^=a[l];
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
int n,x[N],y[N];
string ans;
vector<int>v;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&x[i],&y[i]);
    for(int i=2;i<=n;i++)
        if((abs(x[i])+abs(y[i]))%2!=(abs(x[i-1])+abs(y[i-1]))%2)
    {
        printf("-1\n");return 0;
    }
    if((abs(x[1])+abs(y[1]))%2==0) v.push_back(1);
    for(int i=0;i<=30;i++) v.push_back(1<<i);
    printf("%d\n",v.size());
    for(int i=0;i<v.size();i++)
        printf(i==v.size()-1?"%d\n":"%d ",v[i]);
    for(int i=1;i<=n;i++)
    {
        ans="";
        for(int j=v.size()-1;j>=0;j--)
        {
            if(abs(x[i])>abs(y[i]))
            {
                if(x[i]<0) x[i]+=v[j],ans+='L';
                else x[i]-=v[j],ans+='R';
            }
            else
            {
                if(y[i]<0) y[i]+=v[j],ans+='D';
                else y[i]-=v[j],ans+='U';
            }
        }
        for(int i=ans.size()-1;i>=0;i--)
            printf("%c",ans[i]);
        putchar('\n');
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){
    char input;
    cin >> input;

    if (isupper(input)) {
        cout << 'A';
    } else {
        cout << 'a';
    }
    cout << endl;

  return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	string s,s1;
	cin>>s>>s1;
	int i,j,mx=0;
	for(i=0;i<=s.length()-s1.length();i++)
	{
		int x=i,cnt=0;
		for(j=0;j<s1.length();j++)
		{
			if(s1[j]==s[x])
				cnt++;
			x++;
		}
//		cout<<i<<" "<<cnt<<endl;
		if(cnt>mx)
			mx=cnt;
	}
	cout<<s1.length()-mx;
	return 0;
}


Measured memory_bytes: 3600
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;
//約数の列挙O(√n)
vector<int>divisor(int n){
  vector<int>res;
  for(int i=1;i*i<=n;i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(n/i);
    }
  }
  return res;
}

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  if(n==2){
    cout<<max(a[0],a[1])<<endl;
    return 0;
  }
  vector<int>a0=divisor(a[0]);
  vector<int>a1=divisor(a[1]);
  int MAX=1;
  for(int i=0;i<a0.size();i++){
    int count=0;
    for(int j=0;j<n;j++){
      if(a[j]%a0[i]==0)count++;
    }
    if(count>=n-1)MAX=max(a0[i],MAX);
  }
  for(int i=0;i<a1.size();i++){
    int count=0;
    for(int j=0;j<n;j++){
      if(a[j]%a1[i]==0)count++;
    }
    if(count>=n-1)MAX=max(a1[i],MAX);
  }
  cout<<MAX<<endl;
}
  

Measured memory_bytes: 640
a = int(input())
if a % 10 == 2 or a % 10 == 4 or a % 10 == 5 or a % 10 == 7 or a % 10 == 9: 
  print("hon")
elif a % 10 == 0 or a % 10 == 1 or a % 10 == 6 or a % 10 == 8:
  print("pon")
else:
  print("bon")
  

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define I(x, a) for(auto x : a)
#define F(i, l, r) for(auto i = l; i != r; ++i)
#define DF(i, l, r) for(auto i = l; i != r; --i)
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define all(x) x.begin(),x.end()
#define ret return
#define cont continue
#define brk break
#define ins insert

typedef long long ll;
typedef unsigned long long ull;
typedef long double dbl;
typedef pair <int, int> pii;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int) 1e9 + 7;
const dbl eps = (dbl) 1e-8;
const int maxn = (int) 1e5 + 5;
const dbl pi = acos(-1);


int main()
{
//    fin("t.in");
    sync;
    ll n;
    cin >> n;
    F(i, 1, 3502)
    {
    	F(j, 1, 3502)
    	{
    		ll a, b, c;
    		a = i;
    		b = j;
    		if ((4 * a * b - n * b - n * a) <= 0)
    			cont;
    		c = (n * a * b) / (4 * a * b - n * b - n * a);
    		if (c > 0 && 4 * a * b * c == n * (b * c + a * c + a * b))
    		{
    			cout << a << " " << b << " " << c << endl;
    			exit(0);
    		}
    	}
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int m,n,min1;
int main()
{
	cin>>n>>m;
	min1=m/n;
	for(long long int i=min1;i>=1;i--)
	{
		if(m%i!=0) continue;
		if(m/i>=n)
		{
			cout<<i;
			return 0;
		}
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* [💭] [💡] [🎈] */

using namespace std;

int cnt[100001];

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

    ll s = 0;

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

    int q;
    cin >> q;
    while (q--) {
        int b, c;
        cin >> b >> c;
        s += (ll) (c - b) * cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << s << '\n';
    }

    return 0;
}

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

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

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  vector<int> A(N);
  map<int, int> cnt;
  bool f = false;
  for ( int i = 0; i < N; i++ ) {
    cin >> A[i];
    cnt[A[i]]++;
    if ( cnt[A[i]] >= 2 ) f = true;
  }

  if ( f ) cout << "NO" << endl;
  else cout << "YES" << endl;
  
  return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
using namespace std;
// fflush(stdout); to flush after every print ;,use \n in interactive prob;

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
char ch;
ll int z;
cin>>ch;
z=(ll int)ch;
ch=(char)(z+1);
cout<<ch<<endl;

return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int ans=0;
int a[21],b[21];
int main(){
	int n,m,c;
	cin>>n>>m>>c;
	for (int i=0;i<m;i++) cin>>b[i];
	while (n--){	
		int cnt=0;
		for (int i=0;i<m;i++){
			cin>>a[i];
			cnt+=a[i]*b[i];
		}
		if (cnt+c>0) ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <queue>
#include <memory>
#include <fstream>

#pragma GCC optimize("no-stack-protector,Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,popcnt,abm,mmx,tune=native,avx,avx2")

#define int long long
#define ld long double
#define eb emplace_back
#define pb pop_back
#define mp make_pair
#define ss second
#define ff first
#define sqr(x) (x) * (x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair < int, int >
#define vi vector < int >
#define vvi(x, y) vector < vi > (x, vi(y))

typedef int(*func)(int a, int b);

using namespace std;

random_device rd;
mt19937 get_rand(rd());

template < typename T1, typename T2 >
istream& operator>>(istream& in, pair < T1, T2 >& p) {
	in >> p.ff >> p.ss;
	return in;
}

template < typename T1, typename T2 >
ostream& operator<<(ostream& out, pair < T1, T2 >& p) {
	out << p.ff << ' ' << p.ss;
	return out;
}

template < typename T1 >
istream& operator>>(istream& in, vector < T1 >& v) {
	for (int i = 0; i < sz(v); i++)
		in >> v[i];
	return in;
}

template < typename T1 >
ostream& operator<<(ostream& out, vector < T1 >& v) {
	for (int i = 0; i < sz(v); i++)
		out << v[i] << ' ';
	out << '\n';
	return out;
}

int gcd(int a, int b) {
	return (!a ? b : gcd(b % a, a));
}

const int INF = 1e9 + 7;
const int B = 100003;
const int MOD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.14159265358979323;
const int MAXLL = 9223372036854775807;

bool npr[10000010];

signed main() {
	//ifstream cin("kdivision.in");
	//ofstream cout("kdivision.out");
#ifdef _LOCAL
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	srand(time(NULL));

	int ttt = 1;
	//cin >> ttt;
	while (ttt--) {
		int k, a, b;
		cin >> k >> a >> b;
		for (int i = a; i <= b; i++)
			if (i % k == 0)
				return cout << "OK\n", 0;
		cout << "NG\n";
	}
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,r,n) for(int i=r;i<(int)n;i++)
using namespace std;
int in(){int x;cin>>x;return x;}

string s[10]={"1","2","4","8","16","32","64","128","256","512"};
int ss[10]={1,2,4,8,16,32,64,128,256,512};

string ans[1200];
void sss(string z,int y,int l)
{
	ans[y]=z;
	if(l==10)return ;
	sss(z,y,l+1);
	if(z!="")z+=" ";
	z+=s[l];
	y+=ss[l];
	sss(z,y,l+1);
	return ;

}


int main ()
{
	int a;
	sss("",0,0);	
	while(scanf("%d",&a)!=EOF)
	{
		cout<<ans[a]<<endl;
	}

	return 0;
}

Measured memory_bytes: 1292
N,A,B=[int(s) for s in input().split(" ")]
S=str(input())

Count=0
b=0
for i in range(N):
    if Count<A+B:
        if S[i]!="c":
                if S[i]=="b":
                    if b<B:
                        print("Yes")
                        b+=1
                        Count+=1
                    else:
                        print("No")
                else:
                    print("Yes")
                    Count+=1
        else:
            print("No")
    else:
        print("No")

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

int n,k,ren[100005],ans;
bool ch[100005];

int main(){
	while(1){
		scanf("%d%d",&n,&k);
		if(n+k == 0)break;
		ans = 0;
		for(int i = 0;i <= n+1;i++) ch[i]=false,ren[i]=0;
		for(int i = 1;i <= k;i++){
			int t;
			scanf("%d",&t);
			ch[t] = true;
		}

		for(int i = 1;i <= n;i++){
			if(ch[i] == true){
				ren[i] = ren[i-1] + 1;
			}else{
				ren[i-ren[i-1]] = ren[i-1];
			}
			ans = max(ans,ren[i]);
		}
		ren[n+1-ren[n]] = ren[n];

		if(ch[0] == true){
			for(int i = 1;i <= n;i++){
				if(ch[i] == true)continue;
				ans = max(ans,ren[i-1]+1+ren[i+1]);
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}


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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define  endl 			"\n"
#define  FOR(i, a, n)   for (ll i = a; i < n; i++)
#define  ROF(i, a, n)   for (ll i = a; i >= n; i--)
#define  all(x)         (x).begin(), (x).end()
#define  mset(x, val)   memset(x,val,sizeof(x))
#define  dline          cout<<"///REACHED///\n";

typedef long long ll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  4e+5+7;



// 6




int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	if(((16-(2*min(a,b))+1)/2+min(a,b))>= max(a,b)){
		cout<<"Yay!";
	}
	else{
		cout<<":(";
	}

	return 0;
}

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

bool s[2000][2000];
int hc[2000][2000] = {}, wc[2000][2000] = {};

void sethc(int H, int h, int w) {
  if (!s[h][w]) return;
  if (h == 0 || !s[h - 1][w]) {
    int c = 0;
    for (int i = h; i < H; i++) {
      if (s[i][w])
        c++;
      else
        break;
    }
    hc[h][w] = c;
  } else {
    hc[h][w] = hc[h - 1][w];
  }
}

void setwc(int W, int h, int w) {
  if (!s[h][w]) return;
  if (w == 0 || !s[h][w - 1]) {
    int c = 0;
    for (int i = w; i < W; i++) {
      if (s[h][i])
        c++;
      else
        break;
    }
    wc[h][w] = c;
  } else {
    wc[h][w] = wc[h][w - 1];
  }
}

int main() {
  int H, W;
  cin >> H >> W;
  char S;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S;
      s[i][j] = S == '.';
    }
  }

  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      sethc(H, i, j);
      setwc(W, i, j);
      ans = max(ans, hc[i][j] + wc[i][j] - 1);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35456
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a;
    int minx=1001;
    int maxx=-1;
    for(int i=0; i<n; i++){
        cin>>a;
        minx=min(minx,a);
        maxx=max(maxx,a);
    }
    cout<<maxx-minx<<endl;
    return 0;
}


Measured memory_bytes: 256
import bisect
from collections import deque

n=int(input())
seq= [int(input()) for i in range(n)]

# dp[k]:最適に部分列を繋げた時の集合
dp = deque([seq[0]])

for i in range(1,len(seq)):
    if seq[i] <= dp[0]:
        dp.appendleft(seq[i])

    else:
        dp[bisect.bisect_left(dp, seq[i])-1] = seq[i]

print(len(dp))

Measured memory_bytes: 53592
package main
     
import (
    "fmt"
)
 
func main() {
	var a,b int
    fmt.Scan(&a, &b)

    i := 0
    for i <= 1000 {
        if int(float64(i)*0.08) == a && int(float64(i)*0.1) == b {
            fmt.Println(i)
            return
        }
        i++
    }

    // ans := int(float64(a)/0.08)
    // fee := int(float64(ans) * 0.1)

    // if fee == b {
    //     if int(float64(ans) * 0.08) == a && int(float64(ans) * 0.1) == b {
    //         fmt.Println(ans)
    //         return
    //     }
    // }

    // ans2 := int(float64(b)/0.1)
    // fee2 := int(float64(ans2) * 0.08)
    
    // if fee2 == a {
    //     if int(float64(ans2) * 0.08) == a && int(float64(ans2) * 0.1) == b {
    //         fmt.Println(ans2)
    //         return
    //     }
    // }

    fmt.Println("-1")
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b;
  cin>>a>>b;
  cout<<(a + b + 1) / 2 << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define P pair<ll,ll>
int t[2005], u[200];
ll mod = 1000000007;
P p[200005];
ll i, a, b, c, k, n, m, z = 0;
char s[100005];
int main() {
	cin >> n ;
	rep(i, n) {
		cin >> a >> b;
		p[i].first = b;
		p[i].second = a;
	}
	sort(p, p + n);

	rep(i, n) {
		if (p[i].first-p[i].second < z) {
			cout << "No";
			return 0;
		}
		z = z + p[i].second;
	//	cout << i << " " << z << " " << p[i].second<<"\n";
	}
	
 cout << "Yes";
 return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
string s;
bool valid(string a)
{
	int y=atoi(a.substr(0,2).c_str());
	int m=atoi(a.substr(2).c_str());
	if(y<0)
		return false;
	if(m<=0||m>12)
		return false;
	return true;
}
int main()
{
	cin>>s;
	string t=s.substr(2)+s.substr(0,2);
	if(valid(s)&&valid(t))
		cout<<"AMBIGUOUS"<<endl;
	else if(valid(s)&&!valid(t))
		cout<<"YYMM"<<endl;
	else if(valid(t)&&!valid(s))
		cout<<"MMYY"<<endl;
	else
		cout<<"NA"<<endl;
	return 0;
}

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

int main(){
int n;
cin >> n;
long long a[n+1],b[n],c=0;
for(int i=0;i<(n+1);i++)
  cin >> a[i];
for(int i=0;i<n;i++)
  cin >> b[i];
for(int i=0;i<n;i++)
{
	if(a[i]>b[i]) {c+=b[i]; b[i]=0;}
  	else {c+=a[i]; b[i]=b[i]-a[i];}
  	
  	if(a[i+1]>b[i]){c+=b[i]; a[i+1]=a[i+1]-b[i];}
  	else {c+=a[i+1]; a[i+1]=0;}
}
cout << c;
return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
"""
D - Mixing Experiment
https://atcoder.jp/contests/abc054/tasks/abc054_d

"""
import sys


def solve(N, Ma, Mb, items):
    d = dict()
    d[(0, 0)] = 0
    for a, b, c in items:
        nd = dict()
        for k, v in d.items():
            t = d.get((k[0], k[1]), float('inf')) + c
            if d.get((k[0]+a, k[1]+b), float('inf')) > t:
                nd[(k[0]+a, k[1]+b)] = t
        d.update(nd)
    res = []
    for k, v in d.items():
        if k == (0, 0):
            continue
        a, b = k
        if a*Mb == b*Ma:
            res.append(v)
    return min(res) if res else -1


def main(args):
    N, Ma, Mb = map(int, input().split())
    items = [[int(i) for i in input().split()] for _ in range(N)]
    ans = solve(N, Ma, Mb, items)
    print(ans)


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


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

#define fi first
#define se second
#define ll long long

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;

void solve1()
{
    int n;
    cin >> n;
    vector < int > v(n + 2 , 0);
    for( int i = 1; i <= n; i++ ){
        cin >> v[i];
    }
    int sum = 0;
    for( int i = 1; i <= n; i++ ){
        sum = sum + abs(v[i] - v[i - 1]);
    }
    sum += abs(v[n]);
    for( int i = 1; i < n; i++ ){
        cout << sum - abs(v[i] - v[i - 1]) - abs(v[i] - v[i + 1]) + abs(v[i - 1] - v[i + 1]) << "\n";
    }
    cout << sum - abs(v[n]) + abs(v[n - 1]) - abs(v[n] - v[n - 1]);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0); srand(time(0));
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


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



int main(){
    string s;cin>>s;
    ll n=s.size(),an=0;
    rep(i,0,(n+1)/2){
        if(s[i]=='p')an--;
    }
    rep(i,(n+1)/2,n)if(s[i]=='g')an++;
    cout<<an<<endl;
}







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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	int G=0;
	FOR(i,N) {
		cin>>A[i];
		G=__gcd(G,A[i]);
	}
	cout<<G<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define M1 (ll)1000000007
#define M2 (ll)998244353
#define Pi 3.141592653
#define exp 2.71828
#define ll long long
#define ull unsigned long long
#define pi pair<int,int>
#define pl pair<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define di deque<int>
#define dl deque<ll>
#define dii deque<pi>
#define dll deque<pl>
#define vvi vector<vi>
#define vvl vector<vl>
#define vii vector<pi>
#define vll vector<pl>
#define pb push_back
#define pp pop_back
#define pf push_front
#define pt pop_front
#define mp make_pair
#define in insert
#define er erase
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define rp(i,a,b) for(int i=a;i<b;i++)
#define rpt(i,a,b,t) for(int i=a;i<b&&t<1;i++)
#define rep(i,n) for(int i = 0 ; i<n ; i++)
#define rept(i,n,t) for(int i = 0 ; i<n&&t<1 ; i++)
#define repr(i,n) for(int i = n-1 ; i>=0 ; i--)
#define reprt(i,n,t) for(int i=n-1;i>=0&&t<1;i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define SORT(v) sort(v.begin(),v.end())
using namespace std;
int dp[100005];
vi graph[100005];
int v[100005]={0};
bool cmp(pair<int,int> i,pair<int,int> j){
    return i.first<j.first;
}
void longest_path(int node){
    if(graph[node].empty()){
        dp[node]=0;
        return;
    }
    for(auto u:graph[node]){
        if(dp[u]==-1) longest_path(u);
        dp[node] = max(dp[node],dp[u]);
    }
    dp[node]+=1;
    // visited
}
int main() {
    fast
    int n,m,x,y;
    cin>>n>>m;
    for(int i=0;i<m;++i){
        cin>>x>>y;
        graph[x-1].pb(y-1);
    }
    for(int i=0;i<n;++i) dp[i]=-1;
    for(int i=0;i<n;++i){
        if(dp[i]!=-1) continue;
            longest_path(i);
    }
    cout<<*max_element(dp,dp+n);
}


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

int main() {
    int a[4];
    rep(i, 4) cin >> a[i];
    sort(a, a + 4);
    string ans = "YES";
    if (a[0] != 1 || a[1] != 4 || a[2] != 7 || a[3] != 9) ans = "NO";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
class Program{
	const int mod=1000000007;
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		long[] fo=new long[s[0]+s[1]-1];
		long[] a=new long[s[1]-s[3]];
		long[] b=new long[s[1]-s[3]];
		
		fo[0]=1;a[0]=1;b[0]=1;
		for(int i=1;i<=s[0]+s[1]-2-s[2]||i<s[2]+(s[1]-s[3])-1;i++){
			fo[i]=(fo[i-1]*i)%mod;
			if(i>=s[0]+s[3]-1-s[2]&&i<=s[0]+s[1]-2-s[2]){a[i-(s[0]+s[3]-1-s[2])]=fo[i];}
			if(i>=s[2]-1&&i<s[2]+(s[1]-s[3])-1){b[(i-s[2]+1)]=fo[i];}
		}
		for(int i=0;i<s[1]-s[3];i++){
			a[i]=(a[i]*(mi(fo[s[0]-1-s[2]]*fo[s[3]+i])%mod))%mod;
			b[i]=(b[i]*(mi(fo[s[2]-1]*fo[i])%mod))%mod;
		}
		long ans=0;
		for(int i=0;i<s[1]-s[3];i++){ans=(ans+a[i]*b[s[1]-s[3]-i-1])%mod;}
		Console.WriteLine(ans);
	}
	static long mi(long a){
		long b=mod,u=1,v=0;
		while(b>0){
			long t=a/b;
			a-=t*b;a^=b;b^=a;a^=b;
			u-=t*v;u^=v;v^=u;u^=v;
		}
		u%=mod;
		if(u<0){u+=mod;}
		return u%mod;
	}
}

Measured memory_bytes: 12768
n = int(input())
a = list(map(int,input().split()))
x = [0 for _ in range(n)]

x0 = 0
for i in range(n):
  if i%2 ==0 :
    x0 += a[i]
  else:
    x0-= a[i]
    
x[0] = x0
print(x[0],end = ' ')
for j in range(1,n):
  x[j] = 2*a[j-1] -x[j-1]
  print(x[j],end = ' ')

Measured memory_bytes: 14032
#include<cstdio>
#include<algorithm>
using namespace std;

#define ll long long 
#define debug if (debug_message)

#define file_io 0
#define debug_message 0

ll i,t,j;
ll n,nt,a[100],cnt;

int main(){
	if (file_io){
		freopen(".in","r",stdin);
		freopen(".out","w",stdout);
	}
	
	scanf("%lld",&n);
	
	while(n>0){
		--n;
		a[++cnt]=n%26;
		n/=26;
	}
	
	for (i=cnt; i>=1; --i){
		printf("%c",char(a[i]+int('a')));
	}
	printf("\n");
	
	return 0;
}
/*

*/

Measured memory_bytes: 1608
#include<iostream>
using namespace std;
int main()
{
    long long n,i,mi,c=1;
    cin>>n;
    long long m[n];
    for(i=0;i<n;i++)
    {
        cin>>m[i];
    }
    mi=m[0];
    for(i=1;i<n;i++)
    {
        if(mi>=m[i])
        {
            c++;
        }
        mi=min(mi,m[i]);
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 5100
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    int a = 1;
    for (int i = k-n+1;i<n+k;i++){
        if(a){
            printf("%d",i);
            a = 0;
        }
        else printf(" %d",i);
    }
    cout<<endl;
}


Measured memory_bytes: 256
#define DEBUG 0

/**
 * File    : D2.cpp
 * Author  : Kazune Takahashi
 * Created : 2/16/2019, 10:46:37 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
int M;
map<int, int> X;
int H[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
typedef vector<int> num;
vector<num> Y;
vector<num> Z;

void dfs(num V, int used, int R)
{
  if (R == 0)
  {
    Y.push_back(V);
  }
  else
  {
    for (auto x : X)
    {
      int cost = x.first;
      int value = x.second;
      if ((V.empty() || used <= value) && R >= cost)
      {
        V[value]++;
        dfs(V, value, R - cost);
        V[value]--;
      }
    }
  }
}

ll max_value(num V)
{
  string ans = "";
  for (auto i = 9; i >= 0; i--)
  {
    for (auto j = 0; j < V[i]; j++)
    {
      ans += to_string(i);
      if (ans.size() > 12)
      {
        break;
      }
    }
    if (ans.size() > 12)
    {
      break;
    }
  }
  return stoll(ans);
}

void flush(num V)
{
  for (auto i = 9; i >= 0; i--)
  {
    for (auto j = 0; j < V[i]; j++)
    {
      cout << i;
    }
  }
  cout << endl;
}

int main()
{
  cin >> N >> M;
  for (auto i = 0; i < M; i++)
  {
    int A;
    cin >> A;
    int cost = H[A];
    if (X.find(cost) == X.end())
    {
      X[cost] = A;
    }
    else
    {
      X[cost] = max(X[cost], A);
    }
  }
  vector<int> V(10, 0);
  int mini_cost = (*X.begin()).first;
  int mini_value = (*X.begin()).second;
  while (N > 100)
  {
    V[mini_value]++;
    N -= mini_cost;
  }
  dfs(V, 0, N);
  int maxi_digit = 0;
  for (auto v : Y)
  {
    int digit = 0;
    for (auto i = 0; i < 10; i++)
    {
      digit += v[i];
    }
    maxi_digit = max(digit, maxi_digit);
  }
  for (auto v : Y)
  {
    int digit = 0;
    for (auto i = 0; i < 10; i++)
    {
      digit += v[i];
    }
    if (digit == maxi_digit)
    {
      Z.push_back(v);
    }
  }
  ll maxi = 0;
  num ans;
  for (auto x : Z)
  {
    ll t_maxi = max_value(x);
    if (maxi < t_maxi)
    {
      maxi = t_maxi;
      ans = x;
    }
  }
  flush(ans);
}

Measured memory_bytes: 2488
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<Pair> L = new List<Pair>();
		for(int i=0;i<N;i++){
			if(IsOnTheKabe(P[i][0],P[i][1]) && IsOnTheKabe(P[i][2],P[i][3])){
				long f = Enc(P[i][0],P[i][1]);
				long t = Enc(P[i][2],P[i][3]);
				if(f > t){ var tmp = t; t = f; f = tmp; }
				L.Add(new Pair(f,t));
			}
		}
		
		L.Sort((p,q) => p.Fr.CompareTo(q.Fr));
		
		
		Stack<Pair> Stk = new Stack<Pair>();
		foreach(var p in L){
			while(Stk.Count > 0){
				var enclosure = Stk.Peek();
				if(p.Fr > enclosure.To){
					Stk.Pop();
					continue;
				} 
				if(p.Fr > enclosure.Fr && p.To < enclosure.To){
					break;
				} 
				Console.WriteLine("NO");
				return;
			}
			Stk.Push(p);
		}
		Console.WriteLine("YES");
	}
	
	class Pair{
		public long Fr,To;
		public Pair(long f, long t){
			Fr = f; To = t;
		}
	}
	
	bool IsOnTheKabe(long x, long y){
		return (x == 0 || x == R) || (y == 0 || y == C);
	}
	long Enc(long x, long y){
		if(y == 0) return x;
		if(x == R) return R + y;
		if(y == C) return R + C + (R - x);
		if(x == 0) return R + C + R + (C - y);
		return 0;
	}
	
	long R,C;
	int N;
	long[][] P;
	public Sol(){
		var d = rla();
		R = d[0]; C = d[1]; N = (int)d[2];
		P = new long[N][];
		for(int i=0;i<N;i++) P[i] = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    vector<pair<int, int>> c(n), d(n);
    for(int i = 0; i < n; i++)
    {
        int ta, tb;
        cin >> ta >> tb;
        a[i] = ta, b[i] = tb;
        c[i].first = ta + tb;
        c[i].second = i;
    }

    sort(all(c));
    reverse(all(c));

    int p1 = 0, cnt = 0;
    ll res = 0;
    while(cnt<n){
        cnt++;
        res += (ll)a[c[p1++].second];
        if(cnt>=n)
            break;
        cnt++;
        res -= (ll)b[c[p1++].second];
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#define MAX 100000
#define N -1
  
int D[MAX],H[MAX];
int n;
int A;
 
void print(int);
  
struct Node{ int p, l, r;};
struct Node T[MAX];
 
void arr(int a){
  if(getD(a) == 0){
    printf("root\n");
  }else if(T[a].r ==N && T[a].l ==N){ 
    printf("leaf\n");
  }else if(T[a].r!=N || T[a].l!= N){
    printf("internal node\n"); 
  }
}
  
  
int getD(int u){
  int d = 0;
  int i;
  if(u == A) return 0;
  else{
    i = n-1;
    while(1){
      if(u == A) break;
      if(T[i].l == u || T[i].r == u){
    d++;
    u = T[i].p;
      }
      i--;
      if(i<0) i = n-1;
    }
    return d;
  }
    
}
  
int par(int a){
  int i;
  if(a==A) return -1;
  else {
    for(i=0;i<n;i++){
      if(T[i].l==a || T[i].r == a){
    return T[i].p;
    break;
      }
    }
  }
}
  
int sibling(int b){
  int i;
  if(b==A) return -1;
  else {
    for(i=0;i<n;i++){
      if(T[i].l == b){
    return T[i].r;
      }
      if(T[i].r == b){
    return T[i].l;
      }
    }
  }
}
  
int degree(int d){
  if(T[d].l==-1 && T[d].r == -1){
    return 0;
  }
  else if(T[d].l != -1 && T[d].r != -1){
    return 2;
  }
  else if((T[d].l == -1 && T[d].r != -1) || (T[d].l != -1 && T[d].r == -1)){
    return 1;
  }
   
}
int hei(int c){
  int l=0;
  int r=0;
  
  if(T[c].l==-1 && T[c].r == -1){
    return 0;
  }
  if(T[c].l!=-1 && T[c].r != -1){
    l = hei(T[c].l)+1;
    r = hei(T[c].r)+1;
    if(l<r){
      return r;
    }
    else return l;
  }
  else if(T[c].l==-1&&T[c].r!=-1){
    return hei(T[c].r)+1;
  }
  else if(T[c].l!=-1&&T[c].r==-1){
    return hei(T[c].l)+1;
  }
}
void print(int u){
   
    
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",u,par(u),sibling(u),degree(u),D[u],hei(u));
  arr(u);
}
  
  
main(){
  int i, j, d, v, c, l;
  int t;
  int f=0;
  
  scanf("%d", &n);
   
  for ( i = 0; i < n; i++ ) {
    T[i].p = T[i].l = T[i].r = N;
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v, &d, &c);
  
    T[v].p = v;
    T[v].l = d;
    T[v].r = c;
  }
  A = 0;
  for(i=n-1;i>0;i--){
    if(T[i].l==A || T[i].r==A){
      A = T[i].p;   
      f++;
      if(A == 0){
    break;
      }
      else {
    i = n-1;
      }
    } 
  }
 
  if(f == 0){
    A= 0;
  }
   
  for(i=0;i<n;i++){
    D[i] = getD(i);
  }
  
  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}

Measured memory_bytes: 620
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define NODE_MAX 100001
vector<ll> lg[NODE_MAX],hg[NODE_MAX];
ll lang_used[NODE_MAX]={},human_used[NODE_MAX]={};
void lang_dfs(ll p);
void human_dfs(ll p);

void human_dfs(ll p){
  if(human_used[p]){
    return;
  }
  human_used[p]=true;
  for(ll i=0;i<hg[p].size();i++){
    lang_dfs(hg[p][i]);
  }
}
void lang_dfs(ll p){
  if(lang_used[p]){
    return;
  }
  lang_used[p]=true;
  for(ll i=0;i<lg[p].size();i++){
    human_dfs(lg[p][i]);
  }
}
signed main(){
  ll n,m,tl;
  bool can=true;
  cin >> n >> m;
  ll k[n];
  for(int i=0;i<n;i++){
    cin >> k[i];
    for(int j=0;j<k[i];j++){
      cin >> tl;
      tl--;
      lg[tl].push_back(i);
      hg[i].push_back(tl);
    }
  }
  human_dfs(0);
  for(int i=0;i<n;i++){
    if(human_used[i]==false){
      can=false;
      break;
    }
  }
  if(can){
    cout <<"YES\n";
  }else{
    cout <<"NO\n";
  }
}


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

using namespace std;

int main(){
	string s;
	cin >> s;
	int ans=0;
	for(int i=0;i<s.size();i++){
		if(s.substr(i,1) == "1") ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3144
def main26():
    num = int(input())
    vd = input().split()
    cd = input().split()
    v = []
    c = []
    for i in range(num):
        v.append(int(vd[i]))
        c.append(int(cd[i]))
    result = 0
    for i in range(num):
        if v[i] > c[i]:
            result = result + v[i] - c[i]
    print(result)

if __name__ == "__main__":
    main26()

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int k;

void sum(int *valor){
	int n;
	for (int i = 0; i < k; i++) {
		n = *valor;
		*valor = 2 * n;
	}
}

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

	int a, b, c;
	cin >> a >> b >> c;

	cin >> k;
	
	if (a >= b and a >= c)
		sum(&a);
	else if (b >= c)
		sum(&b);
	else 
		sum(&c);

	cout << a + b + c << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
	 ios::sync_with_stdio(false);
	 int a,b;
	 int square;
	 while(cin>>a>>b){
	 	square=a*b-1*a-1*b+1;
	 	cout<<square<<endl;
	 }
	 return 0;
}


Measured memory_bytes: 256
a, b = list(map(int, input().split()))
#h, w = list(map(int, input().split()))
count = 0
for i in range(a, b+1):
    x = str(i)
    flag = True
    for j in range(len(x)//2):
        if x[j]!=x[len(x)-1-j]:
            flag = False
        #print(x[j]+" "+x[len(x)-1-j])
        #print(flag)
    
    #print("--------")
    if flag:
        count += 1          

print(count)



Measured memory_bytes: 2940
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
N,X = map(int,input().split())
A = list(map(int,input().split()))

ans = 0
if A[0] > X:
    ans = A[0]-X
    A[0] = X

for i in range(1,N):
    if A[i]+A[i-1] > X:
        s = A[i]+A[i-1] - X
        ans += s
        A[i] -= s

print(ans)


Measured memory_bytes: 14656
# include <iostream>
using namespace std;
int main(void)
{
	int n,a[100],ans = 0;
	scanf("%d",&n);
	for(int i = 0;i < n;i++) scanf("%d",&a[i]);
	for(int i = 0;i < n-1;i++)
	{
		for(int j = n-1;j >= i+1;j--)
		{
			if(a[j] < a[j-1])
			{
				swap(a[j-1],a[j]);
				ans++;
			}
		}
	}
	for(int i = 0;i < n;i++) printf("%d%c",a[i],(i == n-1)?'\n':' ');
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3196
#include<stdio.h>
int main(void){
  int x,a,b,c,d,e;
  scanf("%d",&x);
  a = x/500;
  b = x%500/5;
  c = a*1000;
  d = b*5;
  e = c+d;
  printf("%d\n",e);
  
  return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
	while (1) {
		int n, m;
		cin >> n >> m;
		if (n + m == 0)return 0;
		int a[1000];
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		vector<int> ans;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				ans.push_back(a[i] + a[j]);
			}
		}
		sort(ans.begin(), ans.end());
		if (*(upper_bound(ans.begin(), ans.end(), m)) == ans[0]) {
			cout << "NONE" << endl;
		}
		else
			cout << *(upper_bound(ans.begin(), ans.end(), m) - 1) << endl;
	}
	return 0;
}


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

int euclidean_gcd(int a, int b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

signed main(void){
    int a,b; cin >> a >> b;
    int c = euclidean_gcd(a,b);
    cout << a*b/c << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
count=sum(B)
for i in range(N-1):
    if A[i]+1==A[i+1]:
        count=count+C[A[i]-1]
print(count)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int L, R; cin >> L >> R;
	int d; cin >> d;

	cout << R / d - (L - 1) / d << endl;

	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rp(i,n) for(int i=1;i<=(int)n;i++)
int main(){
int k;cin>>k;
string s;cin>>s;
if(s.size()<=k)cout<<s<<endl;
else {
    for(int i=0;i<k;i++){
        cout<<s[i];
    }
    cout<<"..."<<endl;
}

}

Measured memory_bytes: 3628
#include<stdio.h>
int main(){
    while(1){
        int n,m,p,sum=0,d;
        scanf("%d %d %d",&n,&m,&p);
        if(n==0&&m==0&&p==0) return 0;
        for(int i=0;i<n;i++){
            int x;
            scanf("%d",&x);
            sum+=x;
            if(m==i+1) d=x;
        }
        if(d!=0) printf("%d\n",(100-p)*sum/d);
        else printf("0\n");
    }
}

Measured memory_bytes: 1036
N, M, X = map(int, input().split())
FS = list(map(int, input().split()))
cost_N = 0
cost_0 = 0

for i in range(X, N+1):
    if i in FS:
        cost_N += 1

for i in range(1, X+1):
    if i in FS:
        cost_0 += 1

print(min(cost_N, cost_0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
vector<int>v;
void cc(int p){
	++v[p];
	if(p==0 and v[p]>9){
		v[0]=1;
		v.push_back(0);
		return;
	}
	if(v[p]>9 or (p and abs(v[p]-v[p-1]>1))){
		cc(p-1);
		v[p]=max(0,v[p-1]-1);
	}
	return;
}
int main(){
	v.push_back(1);
	int k;
	cin>>k;
	assert(k<=100000 and k>=1);
	while(--k>0){
		cc(v.size()-1);
	}
	for(int i=0;i<v.size();++i)cout<<v[i];
	cout<<endl;
	return 0;
}

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

int main(){
	int N, L, s = 0, m = 100000, p;
	cin >> N >> L;
	for(int i = 0; i < N; i++){
		if(abs(L+i) < m){
			p = i;
			m = abs(L+i);
		}
	}
	for(int i = 0; i < N; i++){
		if(i != p)
			s += L+i;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
int H,W,h,w;
int main()
{
#ifndef ONLINE_JUDGE
//	freopen("A.in","r",stdin);
#endif
	H=gi();W=gi();h=gi();w=gi();
	printf("%d\n",H*W-(W*h+w*(H-h)));
	return 0;
}


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

#define count_ones __builtin_popcountl
#define all(a) a.begin(), a.end()
#define gcd(a, b) __gcd(a, b)
#define lca(a, b) a / __gcd(a, b) * b
typedef long long ll;
typedef long double ld;
using namespace std;

ll const MOD = 1e9 + 7;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) cin >> a[i];
    ll total = 0;
    for (ll i = 0; i < 60; i++) {
        ll cnt0 = 0;
        ll cnt1 = 0;
        for (ll j = 0; j < n; j++) {
            if ((a[j] >> i) & 1) cnt1++;
            else cnt0++;
        }
        ll sum = cnt0 * cnt1;
        for (ll j = 0; j < i; j++) {
            sum *= 2;
            sum %= MOD;
        }
        total += sum;
        total %= MOD;
    }
    cout << total;

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N;cin>>N;
  std::vector<int> a(N+1),b(N);
  for(int i=0;i<=N;i++)cin>>a[i];
  for(int i=0;i<N;i++)cin>>b[i];
  int ans=0;
  for(int i=0;i<N;i++){
    int k=min(a[i],b[i]);
    ans+=k;
    a[i]-=k;
    b[i]-=k;
    int l=min(a[i+1],b[i]);
    ans+=l;
    a[i+1]-=l;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792