akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>
using namespace std;

int main(void){
	int n;
	while(cin >> n){
		int ans=0;
		for(int a=0;a<=9;a++){
			for(int b=0;b<=9;b++){
				for(int c=0;c<=9;c++){
					for(int d=0;d<=9;d++){
						if(a+b+c+d==n)ans++;
					}
				}
			}
		}
		cout << ans << endl;
	}
    return 0;
}

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

int main() {
    int X;
    cin >> X;
    double x = sqrt(X);
    int res = 0;
    for (int j = 1; j <= x; j++) {
        for(int k = 2;k<10;k++) {
            int p =  pow(j, k);
            if(pow(j, k) > X) break;
             else res = max(res, p);
        }
    }
    
    cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <numeric>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

void solve()
{
	char s1[15], s2[15];
	cin >> s1 >> s2;
	bool flag = true;
	for ( int i=0; s1[i]!='\0'; i++ )
	{
		if ( s1[i] != s2[i] )
		{
			flag = false;
			break;
		}
	}
	if ( flag == false )
	cout << "No";
	else
	cout << "Yes";
}

int main()
{
	fastio;
	int t; t=1;
	while(t--)
		solve();
	return 0;
}


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

int main(){
    int N;
		string S;
		cin >> N >> S;

		bool flag = false;
		for(int i = 0; i < N / 2; ++i) {
			if(S.at(i) != S.at(i + N / 2)) {
				flag = true;
			}
		}

		if(flag == false && N % 2 == 0) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
}


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

//Compiler version g++ 6.3.0

int main()
{
   int x,n,m,k;
   bool vokk=false,bofo,lobo;
   cin>>x>>n;
   int p[n];
   if(n==0)
   {
     cout<<x;
     exit(0);
   }
   for(int i=0;i<n;i++)
   {
     cin>>p[i];
   }
   for(int i=0;i<n;i++)
   {
     if(p[i]==x)
     {
       vokk=true;
     }
   }
   if(vokk==false)
   {
     cout<<x;
     exit(0);
   }
   for(int i=0;i<100;i++)
   {
     bofo=false,lobo=false;
     m=x-i;
     k=x+i;
     for(int j=0;j<n;j++)
     {
     if(p[j]==m)
     {
       bofo=true;
     }
     if(p[j]==k)
     {
       lobo=true;
     }
     }
     if(bofo==false)
     {
       cout<<m;
       exit(0);
     }
     else if(lobo==false)
     {
       cout<<k;
       exit(0);
     }
   }
   
   
   
}

Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<cctype>
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back

using namespace std;

inline ll read()
{
	long long f=1,sum=0;
	char c=getchar();
	while (!isdigit(c)) {if (c=='-') f=-1;c=getchar();}
	while (isdigit(c)) {sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}
const int MAXN=100010;
const int MAXM=200010;
struct node{
	int x,col,cost;
	node () {}
	node (int _x,int _col,int _cost):x(_x),col(_col),cost(_cost) {}
};
//bool operator <(const node a,const node b){return a.cost>b.cost;}
vector <int> g[MAXN];
map <int,vector<int> > e[MAXN];
map <int,int> dis[MAXN];
queue <node> q; 
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int u,v,col;
		scanf("%d%d%d",&u,&v,&col);
		e[u][col].push_back(v),e[v][col].push_back(u);
		g[u].push_back(col),g[v].push_back(col);
	}
	q.push(node(1,0,0));
	dis[1][0]=0;
	while (!q.empty())
	{
		node x=q.front();
		q.pop();
//		cout<<x.x<<' '<<x.col<<' '<<x.cost<<endl;
		if (dis[x.x][x.col]!=x.cost) continue;
		if (dis[x.x].find(0)==dis[x.x].end() || dis[x.x][0]>x.cost)
		{
			dis[x.x][0]=x.cost;
			q.push(node(x.x,0,x.cost));
		}
		if (x.col==0)
		{
			for (int i=0;i<(int)g[x.x].size();i++)
			{
				int ncol=g[x.x][i];
				if (dis[x.x].find(ncol)==dis[x.x].end() || dis[x.x][ncol]>x.cost+1)
				{
					dis[x.x][ncol]=x.cost+1;
					q.push(node(x.x,ncol,x.cost+1));
				}
			}
			continue;
		}
		for (int i=0;i<(int)e[x.x][x.col].size();i++)
		{
			int v=e[x.x][x.col][i];
			if (dis[v].find(x.col)==dis[v].end() || dis[v][x.col]>x.cost)
			{
				dis[v][x.col]=x.cost;
				q.push(node(v,x.col,x.cost));
			}
		}
	}
	int ans=INF;
	map <int,int> ::iterator it;
	for (it=dis[n].begin();it!=dis[n].end();it++)
		ans=min(ans,it->second);
	if (ans==INF) cout<<-1;
	else cout<<ans;
	return 0;
}


Measured memory_bytes: 83200
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [a, b]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    return `${a <= b * 2 ? "0" : a - b * 2}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 7372
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

/**
 *  gcd(greatest common divisor), lcm(least common multiple)
**/

template<typename T> T gcd(T x, T y) {
  while (y > 0){
    T tmp = x % y;
    x = y;
    y = tmp;
  }
  return x;
}

template<typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0) return 0;
  else return x * y / gcd(x, y);
}

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

  int x, y; cin >> x >> y;
  cout << gcd(x, y) << '\n';
  

  return 0;
}


Measured memory_bytes: 3168
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] lst = new long[N];
        for(int i = 0; i < N; i++){
            lst[i] = sc.nextInt();
        }
        sc.close();

        int cnt = 0;
        for(int i = 0; i < N -2; i++){
            for(int j = i + 1; j < N -1; j++){
                if( lst[i] == lst[j]){
                    continue;
                }
                for(int k = j + 1; k < N; k++){
                    if( lst[i] == lst[k] || lst[j] == lst[k]){
                        continue;
                    }
                    long c = lst[i] + lst[j] + lst[k];
                    if ( lst[i] * 2 < c && lst[j] * 2 < c && lst[k] * 2 < c ){
                        cnt++;
                    }
                }
            }
        }
        System.out.println(cnt);
    }
}

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

typedef long long ll;
const int MAXN = 2010;
const ll MOD = 924844033;
int n, K, cnt;
ll dp[MAXN*3][MAXN][2];
ll fac[MAXN], ans;
bool ban[MAXN*3];

inline void update(ll &cur, ll val) {
	cur += val;
	if(cur >= MOD) cur -= MOD;
}

int main() {
	cin >> n >> K;
	fac[0] = 1;
	for(int i = 1; i <= n; i++) fac[i] = fac[i-1]*i%MOD;

	cnt = 0;
	for(int i = 1; i <= K; i++) {
		int len = n/K;
		if(i > n%K) len--;
		cnt += len; cnt++;
		ban[cnt] = true;
		cnt += len; cnt++;
		ban[cnt] = true;
	}
	dp[0][0][0] = 1;
	for(int i = 1; i <= cnt; i++) {
		for(int j = 0; j <= n; j++) {
			if(!ban[i]) update(dp[i][j][1], dp[i-1][j-1][0]);
			update(dp[i][j][0], dp[i-1][j][1]);
			update(dp[i][j][0], dp[i-1][j][0]);
		}
	}
	for(int i = 0; i <= n; i++) {
		ll f = i&1 ? -1 : 1;
		ll res = f*fac[n-i]%MOD*dp[cnt][i][0]%MOD;
		res = (res+MOD)%MOD;
		ans = (ans+res)%MOD;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 127360
#include <bits/stdc++.h> 
#include <string> 
#define ll long long int
#define ld long double
using namespace std;

ll ipow(ll base, ll exp)
{
    ll result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }
    return result;
}

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    ll a,b,c,k,sum=0;
    cin>>a>>b>>c>>k;
    if(k>=a)
    {
        sum+=a;
        k=k-a;
        if(k>=b)
        {
            sum=sum;
            k=k-b;
            if(k>=0)
            {
                sum =sum-k;
            }
        }
    }
    else
    {
        sum+=k;
    }
    cout<<sum<<"\n";

   
    
}

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

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

    string s,t;
    cin>>s>>t;

    int cost=0,ans=t.size();
    for(int i=0;i<=s.size()-t.size();i++)
    {
        cost=0;
        for(int j=0;j<t.size();j++)
            if(t[j]!=s[i+j])
                cost++;
        ans=min(ans,cost);        
    }
    cout<<ans<<'\n';
    return 0;
}



Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N, M;

int main() {
    cin >> N >> M;

    int ans = max(0, N - 2 * M);

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


Measured memory_bytes: 256
#include<stdio.h>
int dp[3001];
int max(int a,int b){return a>b?a:b;}
int main(){
	int n,t,s;
	int i,j;
	scanf("%d %d %d",&n,&t,&s);
	for(i=0;i<=t;i++)dp[i]=0;
	for(i=0;i<n;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		for(j=t-b;j>=0;j--){
			if(!(j<s&&s<j+b)){
				dp[j+b]=max(dp[j+b],dp[j]+a);
			}
		}
	}
	int ans=0;
	for(i=0;i<=t;i++)ans=max(ans,dp[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1044
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  int a,b,c,n=0;
  cin >> a >> b >> c;

  for (int i=1; i<=c; i++) {
    if (c%i == 0) {
      if (a <= i && i <= b) {
        n++;
      }
    }
  }
  cout << n << endl;
  return 0;
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
int main()
{
int n;
cin>>n;
int a[n],b[n],c[n];
for(int i=0;i<n;i++)
{
cin>>a[i]>>b[i]>>c[i];
}
int x=a[0],y=b[0],z=c[0];
int ans=max(a[0],max(c[0],b[0]));
for(int i=1;i<n;i++)
{
int q=x,w=y,e=z;
x=max(y,z)+a[i];
y=max(q,e)+b[i];
z=max(q,w)+c[i];
ans=max(ans,max(x,max(y,z)));
}
cout<<ans<<endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    LL a[7];
    for(int i=0;i<7;i++){
        cin >> a[i];
    }
        cout <<(a[0]&&a[3]&&a[4]?max(((a[0]-1)/2+(a[3]-1)/2+(a[4]-1)/2)*2+a[1]+3,(a[0]/2+a[3]/2+a[4]/2)*2+a[1]):(a[0]/2+a[3]/2+a[4]/2)*2+a[1]) << endl;
    return 0;
}


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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  vector<int>x;

  for (int i = 1; i < min(a, b)+1; i++) {
    if ((a%i==0) && (b%i==0)) {
      x.push_back(i);
    }
  }

  reverse(x.begin(), x.end());

  cout << x[k-1];

}

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

int main() {
  int S,ans=0;
  cin >> S;
  for (int i=0;;i++){
  if (S==4 || S == 2 || S==1){
  cout << ans+4 << endl;
  break;
  }
  else if (S%2==0){
  S/=2;
  ans++;
  }
  else if (S%2==1){
  S=S*3+1;
  ans++;
  }
  }
 }

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
const long long INF = 10000000000;
int n;


long long f(long long b, vector<long long> a){

    long long res = 0;
    for(int i = 0; i < n; i++){
        res += (long long)abs(a[i] - b);
    }

    return res;
}

int main(){

    cin >> n;
    vector<long long> a(n);
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i] += (n - i);
        //cout << a[i] << " ";
    }

    long long x0 = 0;
    long long x3 = INF;

    while(x3 - x0 != 3){

        //cout << x0 << " " << x3 << endl;
        long long x1 = x0 + (x3 - x1) / 3;
        long long x2 = x3 - (x3 - x1) / 3;
        if(f(x1, a) > f(x2, a)) x0 = x1;
        else x3 = x2;
    }

    long long ans = min(f(x0, a), f(x0 + 1, a));
    ans = min(ans, f(x0 + 2, a));
    ans = min(ans, f(x0 + 3, a));

    //cout << min(min(f(x0, a), f(x0 + 1 + a)), min(f(x0 + 2, a), f(x0 + 3, a))) << endl;
    cout << ans << endl;
    
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  ll X,Y;
  cin>>X>>Y;
  ll n=X;
  ll ans=0;
  while(n<=Y){
    ans++;
    n*=2;
  }
  cout<<ans<<endl;
  return 0;
}


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


using namespace std;


typedef long long int lli;
typedef long double ld;


const lli MOD = (lli)1000000007;



lli getPow(lli b, lli e) {
  if (e == 0) return 1;
  if (e == 1) return b % MOD;
  if (e % 2 == 0) {
    lli hp = getPow(b, e/2);
    return (hp*hp) % MOD;
  } else {
    return (b * getPow(b, e-1)) % MOD;
  }
}


lli getInv(lli x) {
  return getPow(x, MOD-2);
}


int main() {

  
  int X, Y;
  cin >> X >> Y;

  int m1 = 0, m2 = 0;
  while (X  > 0 && Y > 0 && (2*Y > X)) {
    m1++;
    X--;
    Y -= 2;
  }

  while (X > 0 && Y > 0) {
    m2++;
    Y--;
    X -= 2;
  }

  if (X == 0 && Y == 0) {
    lli f1 = 1, f2 = 1, f1p2 = 1;
    for (int i = 1 ; i <= m1 ; i++) {
      f1 *= i;
      f1 %= MOD;
    }
    for (int i = 1 ; i <= m2 ; i++) {
      f2 *= i;
      f2 %= MOD;
    }
    for (int i = 1 ; i <= m1+m2 ; i++) {
      f1p2 *= i;
      f1p2 %= MOD;
    }
    lli den = (f1 * f2) % MOD;
    lli ans = (f1p2 * getInv(den)) % MOD;
    cout << ans;
  } else {
    cout << 0;
  }




  return 0;
}


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

#define ll long long
#define lp(i,n) for(int i=0; i<n; i++)
#define pb push_back
const long double pi=3.141592654;
#define OSOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

const ll inf = 1e9 +5, mod = 1e9+7,N = 1e5+5;

    int val[N],weights[N];
    ll dp[102][N];
int main()
{
    OSOS
	ll n,w;
    cin>>n>>w;

    for(int i=1; i<=n; i++)
    	cin>>weights[i]>>val[i];

    for(int rem = 1; rem <= w; rem++)
    	for(int item = 1; item <= n; item++)
    	{
    		ll op1,op2;
    		op1 = dp[item-1][rem];
    		op2 = 0;
    		if(rem >= weights[item])
    		{
    			op2 = val[item] + dp[item-1][rem - weights[item]];
    		}
    		dp[item][rem] = max(op1,op2);
    	}

    cout<<dp[n][w];

    return 0;
}



Measured memory_bytes: 79360
from collections import Counter

n = int(input().strip())
vs = list(map(int, input().strip().split()))
oddv = [v for i, v in enumerate(vs) if i % 2 == 0]
evenv = [v for i, v in enumerate(vs) if i % 2 == 1]

oddc = Counter(oddv)
evenc = Counter(evenv)
if oddc.most_common(1)[0][0] != evenc.most_common(1)[0][0]:
  print(len(oddv) - oddc.most_common(1)[0][1] + len(evenv) - evenc.most_common(1)[0][1])
else:
  if len(oddc.most_common()) == 1 and len(evenc.most_common()) == 1:
    print(len(oddv))
  elif len(oddc.most_common()) == 1:
    print(len(evenv) - evenc.most_common(2)[1][1])
  elif len(evenc.most_common()) == 1:
    print(len(oddv) - oddc.most_common(2)[1][1])
  else:
    print(min(len(oddv) - oddc.most_common(2)[1][1] + len(evenv) - evenc.most_common(1)[0][1], len(oddv) - oddc.most_common(1)[0][1] + len(evenv) - evenc.most_common(2)[1][1]))


Measured memory_bytes: 19040
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
///#define int long long int

using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using li = pair<ll, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod =  1000000007;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
// const double pi = 3.14159265359;
const double eps = 0.00000001;

int32_t main() {
    $
    int r, D, x;
    cin >> r >> D >> x;
    int last = x;
    for (int i = 0; i < 10; ++i) {
        last = r * last - D;
        cout << last << '\n';
    }
}   



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

using namespace std;
int main (){
    int n;
    string s;
    cin >> n >> s;
    int m=0;
    int x=0;
    for (int i = 0; i < n; i++){
        if(s[i]=='I') x++;
        else          x--;
        m=max(m,x);
    }
    cout << m <<"\n";
}

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

int main() {
    uint N;
    std::cin >> N;

    std::bitset<32> b(N);
    std::cout << b << std::endl;

    auto c = b;
    c.flip();
    std::cout << c << std::endl;

    c = b;
    c <<= 1;
    std::cout << c << std::endl;

    c = b;
    c >>= 1;
    std::cout << c << std::endl;
    return 0;
}



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


n=int(input())

def f(i):
  c=0
  while i>0:
    if i%2==0:
      c=c+1
      i=int(i/2)
    else:
      break
  return c

t=0
a=0
if n==1:
    print(1)
else:
    for i in range(n):
      fa=f(i+1)
      if t<fa:
        t=fa
        a=i+1

    print(a)
    



Measured memory_bytes: 3060
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    
    for i in range(1,1251):
        if int(i*0.08)==a and int(i*0.1)==b:
            ans=i
            break
        ans=-1
    
    print(ans)
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
using pii=std::pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); <-- PUT IN main()/solve()!

using namespace std;

string s,t;
int lens,lent,ans[3005][3005],parent[3005][3005];
class FLCS {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> s >> t;
		lens=s.length();
		lent=t.length();
		f(i,0,lens+1)
            f(j,0,lent+1)
            {
		        if(i==0||j==0)
		            ans[i][j]=0;
                else
                {
                    int ans1=ans[i-1][j],ans2=ans[i][j-1],ans3=ans[i-1][j-1]+1;
                    if(ans1>ans2)
                    {
                        ans[i][j]=ans1;
                        parent[i][j]=1;
                    }
                    else
                    {
                        ans[i][j]=ans2;
                        parent[i][j]=2;
                    }
                    if(s[i-1]==t[j-1]&&ans3>ans[i][j])
                    {
                        ans[i][j]=ans3;
                        parent[i][j]=3;
                    }
                }
            }
        string lcs;
		int i=lens,j=lent;
		while(i>0&&j>0)
        {
            switch(parent[i][j])
            {
                case 1:
                    i-=1;
                    break;
                case 2:
                    j-=1;
                    break;
                case 3:
                    lcs+=s[i-1];
                    i-=1;
                    j-=1;
                    break;
            }
        }
        reverse(lcs.begin(),lcs.end());
		out << lcs << "\n";
	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	FLCS solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 141312
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
const int maxn=1e5+10;
char s[maxn];
int p,last,cnt;
int main(){
    scanf("%s",s+1);int n=strlen(s+1);
    if(s[n]=='1'||s[1]=='0') return puts("-1"),0;
    rep(i,1,n-1) if(s[i]!=s[n-i]) return puts("-1"),0;
    rep(i,1,n-1) if(s[i]=='1'){
        s[n-i]='0';
        ++cnt;if(last) printf("%d %d\n",last,cnt);last=cnt;
        rep(j,1,i-1-p) printf("%d %d\n",last,++cnt);
        p=i;
    }
    if(cnt<n){
        ++cnt;printf("%d %d\n",last,cnt);last=cnt;
        while(cnt<n) printf("%d %d\n",last,++cnt);
    }
    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,ans=0;
  string s;
  cin >> n >> s;
  ll dp[n+1][n+1];
  fill(dp[0],dp[n+1],0);
  for(ll i=n-1;i>=0;i--){
    for(ll j=n-1;j>i;j--){
      if(s[i]==s[j]){
        dp[i][j] = max(dp[i][j],dp[i+1][j+1]+1);
        ans = max(ans,min(dp[i][j],j-i));
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 195584
#include<bits/stdc++.h>
#define lson (o<<1)
#define rson (o<<1|1)
#define fi first
#define sc second
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
using namespace std;
const double pi=acos(-1);
const double eps=1e-6;
inline int lowbit(int x){return x&(-x);}
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
template<typename T> inline T max(T x,T y,T z){return max(max(x,y),z);}
template<typename T> inline T min(T x,T y,T z){return min(min(x,y),z);}
template<typename T> inline T sqr(T x){return x*x;}
template<typename T> inline void checkmax(T &x,T y){x=max(x,y);}
template<typename T> inline void checkmin(T &x,T y){x=min(x,y);}
template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
template<typename A,typename B,typename C> inline A fpow(A x,B p,C yql){
	A ans=1;
	for(;p;p>>=1,x=1LL*x*x%yql)if(p&1)ans=1LL*x*ans%yql;
	return ans;
}
struct FastIO{
	static const int S=1310720;
	int wpos;char wbuf[S];
	FastIO():wpos(0){}
	inline int xchar(){
		static char buf[S];
		static int len=0,pos=0;
		if(pos==len)pos=0,len=fread(buf,1,S,stdin);
		if(pos==len)return -1;
		return buf[pos++];
	}
	inline int read(){
		int c=xchar(),x=0;
		while(c<=32&&~c)c=xchar();
		if(c==-1)return -1;
		for(;'0'<=c&&c<='9';c=xchar())x=x*10+c-'0';
		return x;
	}
}io;
//#define read io.read
int main()
{
	int n,k;
	cin >> n >> k;
	bool d[1001],flag=true;
	memset(d,true,sizeof(d));
	for(int i=1;i<=k;i++)
	{
		int x;
		cin >> x;
		d[x]=false;
	}
	for(int i=n;;i++)
	{
		flag=true;
		int tmp=i;
		while(tmp)
		{
			int a=tmp%10;
			tmp/=10;
			if(d[a]==false)
			{
				flag=0;
				break;
			}
		}
		if(flag==1)
		{
			cout << i;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <cmath>
 
using namespace std;
 
int main(){
    int n;
    double x[100] = {0},y[100] = {0},p_1 = 0,p_2 = 0,p_3 = 0,p_infinity = -1;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) scanf("%lf",&x[i]);
    for(int i = 0; i < n; i++) scanf("%lf",&y[i]);
 
    for(int i = 0; i < n; i++){
        p_1 += abs(x[i] - y[i]);
        p_2 += (x[i] - y[i])*(x[i] - y[i]);
        p_3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
        p_infinity = (p_infinity >= abs(x[i] - y[i]))? p_infinity:abs(x[i] - y[i]);
    }
    printf("%.6lf\n",p_1);
    printf("%.6lf\n",sqrt(p_2));
    printf("%.6f\n",cbrt(p_3));
    printf("%.6lf\n",p_infinity);
 
}


Measured memory_bytes: 2920
#include<bits/stdc++.h>
using namespace std;
int gs(int a)
{
	int p=0;
	for(int i=1;i<=a;i++)
	if(a%i==0)
	p++;
	return p;
}

int main()
{
	int a,b=0;
	cin>>a;
	for(int i=1;i<=a;i+=2)
	if(gs(i)==8) b++;
	cout<<b;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if((z->key) < (x->key)) {
      x = x->left;
    }else {
      x = x->right;
    } 
  }

  z->parent = y;
  if(y == NIL) {
    root = z;
  }else {
    if((z->key) < (y->key)) {
      y->left = z;
    }else {
      y->right = z;
    }
  }
}

Node find(Node u, int k){
  while(u != NIL && k != (u->key)){
    if(k < (u->key)) u = u->left;
    else u = u->right;
  }
  return u;
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){ 
    scanf("%s", com);
    if(strcmp(com,"find") == 0) {
      scanf("%d",&x);
      Node t = find(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }else if(strcmp(com,"insert") == 0) {
      scanf("%d", &x);
      insert(x);
    }else if (strcmp(com,"print") == 0) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}



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


int main() {
    long long s, i, j;
    long long N = 1000000000+7;
    cin >> s;
    vector<int> v(s+1, 0);

    for (i=3;i<=s;i++) {
        v[i]++;
        v[i] %= N;
        for (j=3;j<i;j++) {
            v[i] += v[i-j] % N;
            v[i] %= N;
        }
    }

    cout << v[s] << endl;
    
    

    return 0;
}


Measured memory_bytes: 3600
import java.io.IOException;
import java.util.Scanner;
public class Main {
	static int count;
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int[] a = new int[x];

		for(int i=0;i<x;i++) {
			a[i] = sc.nextInt();
		}

		bubbleSort(a, x);
		show(a, x, count);
		sc.close();
	}

	public static void bubbleSort(int[] a, int x) {
		boolean flag = true;
		count = 0;
		while(flag) {
			flag = false;
			for(int i=x-1;i>0;i--) {
				if(a[i]<a[i-1]) {
					int tmp = a[i];
					a[i] = a[i-1];
					a[i-1] = tmp;
					flag = true;
					count++;
				}
			}
		}
	}

	public static void show(int[] a, int x, int count2) {
		for(int i=0;i<x;i++) {
			System.out.print(a[i]);
			if(i!=x-1) {
				System.out.print(" ");
			}
		}
		System.out.println();
		System.out.println(count);
	}
}


Measured memory_bytes: 26372
a,b,c = map(int,input().split())

lst = [a,b,c]

cnt = len(list( filter(lambda x:x%2==0,lst)))

if(0<cnt):
    print(0)
else:
    lst.sort()

    res = 0
    if(lst[2]%2 == 1):  
        res = lst[0]*lst[1]
    else:
        res = 0

    print(res)

Measured memory_bytes: 3064
n=int(input())
x=[]
for i in range(n):
    a,b=map(int,input().split())
    x.append([a,b])

                

d=[]
discount=[]
for i in range(n):
    for j in range(n):
        if i!=j:

            tmp=[x[i][0]-x[j][0],x[i][1]-x[j][1]]

            if tmp not in d:
                d.append(tmp)
                discount.append(1)
            else:
                discount[d.index(tmp)]+=1
     
    
if n==1:
    print(1)
else:
    print(n-max(discount))
                
                


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

int main(){
    int min = 100000;
    int i, N, K, tmp, min_i, cnt = 0;
    vector <int> A, min_pos;

    cin >> N >> K;
    for(i = 0; i < N; i++){
        cin >> tmp;
        A.push_back(tmp);
        if(min >= tmp){
            min = tmp;
            min_i = i;
        }
    }

    
    for(i = 0; i < N - 1; i += (K - 1)){
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}


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

#define pi 3.141592654
#define fix(n) cout << fixed << setprecision(n)

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)

#define ll  long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define vi      vector<int>
#define pii     pair<int,int>
#define piii    pair<pair<int,int>,int>
#define all(v)  v.begin(), v.end()

int mod = 1000000007;
const int N = 1000005;

// gcd
ll gcd(ll a , ll b)
{
    if ( b == 0)
    return a;
    return gcd( b, a % b);
}
int a[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int t;
	t  = 1;
	while ( t-- )
	{
		string s;
		cin >> s;
		string ans = "YAKI";
		if ( s.length() < 4)
		{
			cout << "No\n";
			return 0;
		}
		string a = "";
		 a+= s[0];
		a += s[1];
		a += s[2];
		a += s[3];
		if ( ans == a)
			cout << "Yes\n";
		else
			cout << "No\n";
	} 
	return 0;
}


Measured memory_bytes: 256
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val a = cin.nextInt()
    val b = cin.nextInt()

    var ans = 0

    if ( a*n > b) {
        ans = b
    } else {
        ans = a*n
    }
    println(ans)
}

Measured memory_bytes: 31384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll a, b, c, d;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    ll res= LLONG_MIN;
    res= max(res, a*c);
    res= max(res, a*d);
    res= max(res, b*c);
    res= max(res, b*d);
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 3824
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    
    int[] num;
    num = new int[N];
    for ( int i = 0 ; i < N ; i++ ){
      num[i] = sc.nextInt();
    }
    
    int max = 0;
    int cnt = 0;
    for(int i = 0; i < num.length ; i++) {
      if(max <= num[i]){
        cnt++;
        max = num[i];
      }
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 22740
n = int(input())

alphabet_cnt = [[0] * n for i in range(26)]
# [listA, listB, listC, ..., listZ]
# listA = [0, 1, 3, 2, 1, 4, ...] -> the number of A in Si (only min val is needed)
alphabet = list("abcdefghijklmnopqrstuvwxyz")
alphabet_map = dict(zip(alphabet, list(range(26))))

for i in range(n):
  si = input()
  for j in range(len(si)):
    alphabet_cnt[alphabet_map[si[j]]][i] += 1

alphabet_intersect = [min(alp) for alp in alphabet_cnt]
print("".join([alphabet[idx] * cnt for idx, cnt in enumerate(alphabet_intersect)]))

Measured memory_bytes: 9140
#include <stdio.h>

int selection_sort(int *a, int n) {
    int i, j, tmp, count=0, mini;

    for (i=0;i<n;i++) {
        mini=i;
        for (j=i;j<n;j++) {
            if (a[j]<a[mini]) {
                mini=j;
            }
        }
        tmp=a[i];
        a[i]=a[mini];
        a[mini]=tmp;
        if (i!=mini) count++;
    }
    return count;
}

int main(void) {
    int i, n, count, arr[100];

    scanf("%d", &n);
    for (i=0;i<n;i++) scanf("%d", &arr[i]);
    count=selection_sort(arr, n);
    for (i=0;i<n;i++) {
        printf("%d", arr[i]);
        if (i<n-1) printf(" ");
    }
    printf("\n");
    printf("%d\n", count);
    return 0;
}



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

using namespace std;

int main()
{
  int  ani,leg;
  cin>>ani>>leg;
  if(leg%2)
  {
    cout<<"No\n";
    return 0;
  }
  int y=leg/2;
  y-=ani;
  int x=ani-y;
  if(x>=0 && y>=0)
  	cout<<"Yes\n";
   else
     cout<<"No\n";
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;

signed main(){
    ll n,m,x=-1,y=-1,ans=1;
    cin>>n>>m;
    vector<ll> fib(n+1);
    fib.at(0)=1;
    fib.at(1)=1;

    for(ll i=2;i <= n;i++)
    {
        fib.at(i)=fib.at(i-1)%mod+fib.at(i-2)%mod;
        fib.at(i)%=mod;
    }

    for(ll i=0;i < m;i++)
    {
        cin>>y;
        if(y==x+1){
            cout << 0 << endl;
            return 0;
        }
        ans*=fib.at(y-x-2);
        ans%=mod;
        x=y;
    }
    ans*=fib.at(n-y-1);
    ans%=mod;
    
    cout << ans%mod << endl;
}
//入力がない時初期値が効いてくるので、初期値はちゃんと考えて置くこと

Measured memory_bytes: 1024
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (sx, sy, tx, ty) = (input[0], input[1], input[2], input[3])
let (dx, dy) = (tx-sx, ty-sy)
print("D", terminator: "")
(0...dx).forEach{_ in print("R", terminator: "")}
(0...dy).forEach{_ in print("U", terminator: "")}
(0...dx).forEach{_ in print("L", terminator: "")}
(0..<dy).forEach{_ in print("D", terminator: "")}
print("L", terminator: "")
(0...dy).forEach{_ in print("U", terminator: "")}
(0...dx).forEach{_ in print("R", terminator: "")}
(0...dy).forEach{_ in print("D", terminator: "")}
(0..<dx).forEach{_ in print("L", terminator: "")}

Measured memory_bytes: 1152
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, M_a: int, M_b: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    INF = float('inf')
    dp = [[INF] * 401 for _ in range(401)]
    dp[0][0] = 0
    for i in range(N):
        for x in range(400, -1, -1):
            for y in range(400, -1, -1):
                if dp[x][y] < INF:
                    dp[x + a[i]][y + b[i]] = min(dp[x + a[i]][y + b[i]], dp[x][y] + c[i])
    ret = INF
    for i in range(1, 401):
        for j in range(1, 401):
            if i % M_a == 0 and j % M_b == 0 and i // M_a == j // M_b:
                ret = min(ret, dp[i][j])
    if ret == INF:
        print(-1)
    else:
        print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M_a = int(next(tokens))  # type: int
    M_b = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]" 
    b = [int()] * (N)  # type: "List[int]" 
    c = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M_a, M_b, a, b, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4852
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
const double PI = acos(-1.0);

int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double alpha = (60 * H + M) / 720 * (2 * PI); // 長針の進んだ距離
    double beta = M / 60 * (2 * PI); // 短針の進んだ距離
    double theta = alpha - beta;
    double kyori =sqrt(A*A + B*B - (2.0 * A * B * cos(theta)));
    cout << fixed << setprecision(10) << kyori << endl;
    return 0;
}

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

bool found(int x,int a[],int n){
	for(int i=0;i<n;i++){
		if(x==a[i]){
			
			return true;
		}
	}
	return false;
}
int32_t main(){
int x;
int n;
cin>>x>>n;
int a[n];
for(int i=0;i<n;i++){
	cin>>a[i];
}
if(n==0){
	cout<<x<<endl;
}else{
	bool flag=false;
sort(a,a+n);
int d=x;
int pos=0;
while(pos==0){
	if(!found(d,a,n)) {
	pos=d;break;
	if(d==0)
	{
		cout<<d<<endl;
		flag=true;
		break;
	}}
	d++;
}
int e=x;
int nex=0;
while(nex==0){
	if(!found(e,a,n)){
	nex=e;break;
	if(e==0){
		cout<<e<<endl;flag=true;break;
	}
	}
	
	e--;
}
if(flag==false){

if(abs(x-nex)>abs(pos-x) ){
	cout<<pos<<endl;
}else if(abs(x-nex)<abs(pos-x)){
	cout<<nex<<endl;
}
else if(abs(x-nex)==abs(pos-x)){
	cout<<min(nex,pos)<<endl;
}
}}
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;
typedef struct pp
{   char x[50];
    int t,R;
}S;
S s[105];
bool cmp(int a,int b)
{   return a>b;
}
int main()
{   int i,j,T,n,maxn=0,k,s=0,q;
    int y[26]={0};
    char x[6000];
    scanf("%d",&n);
    scanf("%s",x);
    for(i=0;i<n-1;i++)
    {
        for(j=i+1;j<n;j++)
        {   if(x[i]==x[j]&&x[i-1]!=x[j-1])
            {   //if(j==2)printf("##\n");
                q=1;
                for(k=1;k<j-i;k++)
                {   if(x[i+k]==x[j+k])q++;
                    else break;
                }
                if(q>maxn&&j-i>=q)maxn=q;
                //if(j==2)printf("##%d\n",q);
            }
        }
    }
    printf("%d\n",maxn);
    return 0;
}



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

int main(){
  

 
 int n,m,c;
   cin >> n >> m>> c;
   vector <int> b(m);
  for(int i = 0; i < m; i++){
      int bi;
      cin >> bi;
      b.at(i) = bi;
  }
  int max = 0;
  for(int i =0 ;i< n; i++){
      int sum = 0;
      for(int j = 0; j < m; j++){
          int aa;
          cin >> aa;
          sum += aa*b.at(j);
      }
      if(sum + c > 0){
        max += 1;
      }
  }
  cout << max << endl;
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
 int a,b,c;
 cin>>a>>b>>c;

 if(a+b>=c)cout<<"Yes"<<endl;
 else cout<<"No"<<endl;



return 0;}


Measured memory_bytes: 256
#include<stdio.h>
#define max 100
#define inf 10000000
int main(){
 
  int n, u, k,v, c, i, j, min;
  int d[max],node[max][max],jud[max];
 
  scanf("%d",&n);
  for(i = 0; i < n;i++){
    for(j = 0;j <n;j++){
      node[i][j] = -1;
    }
  }
 
  for(i = 0;i < n ;i++){
    scanf("%d %d",&u,&k);
    for(j = 0;j < k;j++){
      scanf("%d %d",&v,&c);
      node[i][v] = c;
    }
  }
 
  for(i = 0;i <n;i++){
    d[i] = inf;
    jud[i] = 1;
  }
 
  d[0] = 0;
 
  while(1){
    min = inf;
    for(i = 0;i <n;i++){
      if(min > d[i] &&jud[i] == 1){
    u = i;
    min = d[i];
      }
    }
    if(min == inf)break;
    jud[u] = 0;
    for(j = 0;j < n;j++){
      if(node[u][j] == -1)continue;
    if(d[j] > d[u] + node[u][j]){
      d[j] = d[u] + node[u][j];
    }
    }
  }
 
  for(i = 0;i < n;i++){
    printf("%d %d\n",i,d[i]);
  }
 
  return 0;
}

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

typedef long long LL;
typedef unsigned long long ULL;

#define debug printf("fuck %d\n", __LINE__);

inline LL read() {
	LL res = 0, bo = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if (ch == '-') bo = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') { res = (res << 1) + (res << 3) + ch - '0'; ch = getchar(); }
	return bo * res;
}

template<typename T> void read(T &x) { x = read(); }
template<typename T, typename ...Argv> void read(T &a, Argv &...argv) { read(a); read(argv...); }

const int N = 3000, p = 1e9 + 7;

struct Edge {
	int u, v, d;
	friend bool operator < (const Edge &a, const Edge &b) { return a.d < b.d; } 
} e[N];

int fa[N], n, m;
LL f[N];

int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
void init() { for (int i = 1; i <= n; ++ i) fa[i] = i; }

LL Get_f(int x) {
	LL ans = 0;
	for (int i = 1; i <= m; ++ i) {
		int u = e[i].u, v = e[i].v, d = e[i].d;
		if (find(u) == find(v)) continue;
		ans += d; fa[find(u)] = find(v);
		if (x == n - 1) return ans;
	}
	return ans;
}

LL ksm(LL x, int y) {
	LL res = 1;
	for (; y; y >>= 1, x = x * x % p) if (y & 1) res = res * x % p;
	return res;
}

int main() {
	read(n, m); LL x = read();
	for (int i = 1; i <= m; ++ i) read(e[i].u, e[i].v, e[i].d);
	std::sort(e + 1, e + m + 1); init(); LL F = Get_f(0), ans = 0;
	if (F > x) return puts("0"), 0;
	if (F == x) ans = 1LL * (ksm(2, n - 1) - 2) * ksm(2, m - n + 1) % p;
	for (int i = 1; i <= m; ++ i) {
		init(); fa[e[i].u] = e[i].v; f[i] = Get_f(1) + e[i].d;
	}
	std::sort(f + 1, f + m + 1);
	for (int i = n; i <= m; ++ i) {
		if (f[i] == x) ans = (ans + ksm(2, m - i + 1)) % p;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,a;
  cin >> n >> a;

  cout << n*n -a << endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.strip.to_i
len = Math.log10(n.to_i).to_i + 1
if len==1
  puts n
elsif len==2
  puts 9
elsif len==3
  puts 9+n-99
elsif len==4
  puts 909
elsif len==5
  puts 909+n-9999
elsif len==6
  puts 90909
end

Measured memory_bytes: 1788
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7




def main():
    r = int(input())
    print(r*r)



            
            
            
            
            
        


if __name__ == '__main__':
    main()


Measured memory_bytes: 69996
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

#ifdef EBUG
#define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n";
#else
#define debug(x)
#endif

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

ld a, b;

int main() {
  cin >> a >> b;
  cout << ll(a * b) << endl;
}

Measured memory_bytes: 3728
s = input()
K = int(input())

D = {c:[] for c in "abcdefghijklmnopqrstuvwxyz"}
for i,c in enumerate(s):
    D[c].append(i)

ans = []
for I in D.values():
    t = []
    for l in range(1,K+1):
        for i in I:
            if i+l < len(s)+1:
                t.append(s[i:i+l])
    ans += sorted(list(set(t)))
    if len(ans)>=K:
        break
print(ans[K-1])


Measured memory_bytes: 40688
A,B,M=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=[]
wari=[]
warik=0
ans=0
for i in range(M):
    c+=list(map(int, input().split()))
for i in range(M):
    wari.append(a[c[i*3]-1]+b[c[2*i+(i+1)]-1]-c[2+3*i])    
warik=min(wari)
ans=min(a)+min(b)
if ans<warik:
    print(ans)
else:
    print(warik)

Measured memory_bytes: 28068
#include <iostream>
using namespace std;
 
int main() {
	long long int n,x,ans=0;
	long long int i,j,k;
	cin>>n>>x;
	int a[n],b[n-1];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=1;i<n-1;i++){
		if(a[i-1]>x&&a[i+1]>x){
			j=a[i-1]-x;
			k=a[i+1]-x;
			a[i-1]=x;
			a[i+1]=x;
			ans+=j+k;
		}
	}
	for(i=0;i<n-1;i++){
		b[i]=a[i]+a[i+1];
	}
	
	for(i=0;i<n-1;i++){
		if(b[i]>x){
			k=b[i]-x;
			b[i]=x;
			b[i+1]-=k;
			ans+=k;
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long M = sc.nextLong();
        
        long ans = 0;
        if( N > 2 && M > 2 ) {
            ans = (M-2) * (N-2);
        } else if( N == 2 || M == 2 ) {
            ans = 0;
        } else if( N == 1 || M == 1 ) {
            if( N == 1 && M == 1 ) {
                ans = 1;
            } else if( N == 1 ) {
                ans = M - 2;
            } else {
                ans = N - 2;
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 35656
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
   int n; ll W; cin >> n >> W;
   vector<vector<ll>> V(4);
   ll num;
   rep(i, n){
       ll w, v; cin >> w >> v;
       if(i==0)num=w;
       V[w-num].push_back(v);
   }
   rep(i, 4)sort(all(V[i]), greater<ll>());
   vector<vector<ll>> S(4);
   rep(i, 4){
       S[i].push_back(0);
       rep(j, V[i].size()){
           ll tmp = S[i][j] + V[i][j];
           S[i].push_back(tmp);
       }
   }

   ll res = 0;
   rep(a, V[0].size()+1){
       rep(b, V[1].size()+1){
           rep(c, V[2].size()+1){
               rep(d, V[3].size()+1){
                   ll sum = S[0][a] + S[1][b] + S[2][c] + S[3][d];
                   ll weight = a*num + b*(num+1) + c*(num+2) + d*(num+3);
                   if(weight <= W)chmax(res, sum);
               }
           }
       }
   }
   cout << res << ln;
}


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

signed main(){
    
  int a,b,m;
  cin>>a>>b>>m;

  vector<int>ref,mic,disc;

  for(int i=0;i<a;i++){
  	int x;
  	cin>>x;
  	ref.push_back(x);
  }

  for(int i=0;i<b;i++){
  	int x;
  	cin>>x;
  	mic.push_back(x);
  }
  
  int ans = INT_MAX;

  for(int i=0;i<m;i++){
  	int x,y,z;
  	cin>>x>>y>>z;
    ans = min(ans,ref[x-1]+mic[y-1]-z);
  }

  sort(ref.begin(),ref.end());
  sort(mic.begin(),mic.end());
  
  ans = min(ans,ref[0]+mic[0]);

  cout<<ans<<endl;
   

	return  0;
}

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

using namespace std;

int n;
int dpp[200005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    int a;
    for (int i = 2; i <= n; i++)
    {
        cin >> a;
        dpp[a]++;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << dpp[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 4360
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main(void){
  int n,k;
  ll ans=0;
  cin>>n>>k;
  vector<ll> h(n);
  if(k>=n){
    cout<<0<<endl;
    return 0;
  }
  else{
    rep(i,n){
      cin>>h[i];
    }
    sort(h.begin(),h.end());
    rep(i,n-k){
      ans+=h[i];
    }
    cout<<ans<<endl;
    return 0;
  }
}
      

Measured memory_bytes: 1792