akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int W = sc.nextInt();

		int w[] = new int[n];
		int v[] = new int[n];

		for(int i = 0; i < n; i++){
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}

		long dp[][] = new long[n + 1][100001];
		for(int i = 0; i <= n; i++){
			Arrays.fill(dp[i], Integer.MAX_VALUE);
		}
		dp[0][0] = 0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < v[i]; j++){
				dp[i + 1][j] = Math.min(dp[i][j], w[i]);
			}
			for(int j = v[i]; j < dp[i].length; j++){
				dp[i + 1][j] = Math.min(dp[i][j], w[i] + dp[i][j - v[i]]);
			}
		}

//		for(int i = 1; i <= n; i++){
//			for(int j = 1; j <= 100; j++){
//				System.out.print(dp[i][j] + " ");
//			}
//			System.out.println();
//		}

		for(int i = 100000; i >= 0; i--){
			if(dp[n][i] <= W){
				System.out.println(i);
				return;
			}
		}

		System.out.println(0);
	}

}


Measured memory_bytes: 131156
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll n, x;
    cin >> n;
    x = n % 10;
    if(n % 10 == 3)
        cout << "bon";
    else if(x == 0 || x == 1 || x == 8 || x == 6)
        cout << "pon";
    else
        cout << "hon";
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main(){
  int N,L;
  cin >> N >> L;
  int ans=L;
  for(int i=0;i<N;i++){
    if(abs(ans)>abs(L+i))ans=L+i;
  }
  cout << N*(2*L+N-1)/2-ans << endl;
  return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    Int n;
    string s;
    cin >> n >> s;
    string pre = s.substr(0, n);
    string suf = s.substr(n, n);
    map<pair<Int, string>, Int> mp1, mp2;
    for (Int bit = 0; bit < (1<<n); bit++) {
        Int cnt = 0;
        string add = "";
        string add2 = "";
        for (Int i = 0; i < n; i++) {
            if (bit & (1<<i)) {
                cnt++;
                add += pre[i];
            }
            else {
                add2 += pre[i];
            }
        }
        mp1[{cnt, add + add2}]++;
    }
    for (Int bit = 0; bit < (1<<n); bit++) {
        Int cnt = 0;
        string add = "";
        string add2 = "";
        for (Int i = 0; i < n; i++) {
            if (bit & (1<<i))  {
                cnt++;
                add = suf[i] + add;
            }
            else {
                add2 = suf[i] + add2;
            }
        }
        mp2[{cnt, add2 + add}]++;
    }
    Int res = 0;
    for (auto i : mp1) {
        res += i.se * mp2[{n - i.fi.fi, i.fi.se}];
    }
    dump(res);
    return 0;
}


Measured memory_bytes: 84608
import sys
def main():
    in1 = input()
    nums, length = in1.split(' ')
    nums= int(nums)
    length = int(length)
    bombs = []

    for i in range(nums):

        bombs.append(input())
    checked = [['']*length for i in range(nums)]
    for i in range(nums):
        for j in range(length):
            if bombs[i][j] == '#':
                checked[i][j] = '#'
            else:
                bombnum = 0
                if i != 0:
                    if j != 0:
                        if bombs[i-1][j-1] == '#':
                            bombnum += 1

                    if j != length -1:
                        if bombs[i-1][j+1] == '#':
                            bombnum += 1

                    if bombs[i-1][j] == '#':
                        bombnum += 1


                if j != 0:
                    if bombs[i][j-1] == '#':
                        bombnum += 1

                if j != length-1:
                    if bombs[i][j+1] == '#':
                        bombnum += 1


                if i != nums-1:
                    if j != 0:
                        if bombs[i+1][j-1] == '#':
                            bombnum += 1

                    if j != length -1:
                        if bombs[i+1][j+1] == '#':
                            bombnum += 1

                    if bombs[i+1][j] == '#':
                        bombnum += 1

                checked[i][j] = bombnum
    for i in checked:
        for j in i:
            print(j, end = '')
        print('')
if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll long long int
#define mi map<int,int>
#define mcr map<char,int>
using namespace std;

int main()
{
    ll a, ans = 0;
    double b;
    cin >> a >> b;
    ll c = b * 100 + 0.5;
    ans = (a * c)/ 100;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3696
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007;

struct fast_io {
  fast_io(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
  };
} fio;

signed main(){
  cout<<fixed<<setprecision(10);

  int H, W, K;
  vector<vector<int>> dp;

  cin>>H>>W>>K;

  dp.resize(H+1, vector<int>(W));

  dp[0][0] = 1;

  for(int i = 0; i < H; i++){

    for(int j = 0; j < (1<<(W-1)); j++){
      bool flag = true;

      for(int k = 0; k < (W-1); k++){
        if(k && ((j>>(k-1))&1) && ((j>>k)&1)) {
          flag = false;
          break;
        }
      }

      if(flag == false) continue;

      // cout<<"i = "<<i<<" j = "<<j<<endl;

      vector<int> hoge(W);

      for(int k = 0; k < (W-1); k++){
        if((j>>k)&1) { //cout<<"k = "<<k<<" "<<dp[i][k+1]<<" "<<dp[i][k]<<endl;
          dp[i+1][k] += dp[i][k+1];
          dp[i+1][k] %= MOD;

          dp[i+1][k+1] += dp[i][k];
          dp[i+1][k+1] %= MOD;

          hoge[k] = true;
          hoge[k+1] = true;
        } else {

        }
      }

      for(int k = 0; k < W; k++){
        if(hoge[k] == false) {
          dp[i+1][k] += dp[i][k];
          dp[i+1][k] %= MOD;
        }
      }

    }
  }

  cout<<dp[H][K-1]<<endl;

  return 0;
}


Measured memory_bytes: 256
from fractions import Fraction
import math
n,k=list(map(int,input().split()))
ans=0
for i in range(1,n+1):
    if i>=k:
        ans+=(Fraction(1,n))
    else:
        x=int(math.log((k/i),2))
        if (k/i)%(2**x)!=0:
            x+=1
        ans+=Fraction(1,n*(2**x))
print(float(ans))

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    if (n % m) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

}


Measured memory_bytes: 256
a,b = map(int,input().split())
if a < b:
	if a * b < 0:
		print(abs(abs(a) - b) + 1)
	else:
		print(b - a)
else:
	if a * b <= 0:
		print(abs(a - abs(b)) + 1)
	else:
		print(2 + abs(a - b))

Measured memory_bytes: 3060
s = list(input())
ac = 0
bc = 0
cc = 0
for i in s:
  if i == "a":
    ac += 1
  elif i == "b":
    bc += 1
  elif i == "c":
    cc += 1
if ac == 1 and bc == 1 and cc == 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define all(a) a.begin(),a.end()
#define endl '\n'
#define y1 y12312123
#define int ll

using namespace std;

const int N = 3e5 + 3;

int n, a, b;

main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin >> n >> a >> b;
    cout << min(n * a, b);

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 157b
a = []
b = []
check_list = [False] * 9
for _ in range(3):
  a.extend(list(map(int, input().split())))
n = int(input())
for _ in range(n):
  b.append(int(input()))

for _b in b:
  if _b in a:
    check_list[a.index(_b)] = True

if check_list[0] and check_list[1] and check_list[2]\
  or check_list[3] and check_list[4] and check_list[5]\
  or check_list[6] and check_list[7] and check_list[8]\
  or check_list[0] and check_list[3] and check_list[6]\
  or check_list[1] and check_list[4] and check_list[7]\
  or check_list[2] and check_list[5] and check_list[8]\
  or check_list[0] and check_list[4] and check_list[8]\
  or check_list[2] and check_list[4] and check_list[6]:
  print('Yes')
else:
  print('No')



Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#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()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int A,B,C; cin >> A >> B >> C;
    bool ok = true;
    if (A==B && B==C) ok = true;
    else if (A==B ||B==C||C==A) ok = false;
    cout << (ok ? "No" : "Yes") << ln;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

			int cnt = 0;

			for(int it = 0; it < s.length(); it++) {
				if(s.charAt(it) != t.charAt(it)) {
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
}


Measured memory_bytes: 41472
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define ye cout<<"YES";
#define no cout<<"NO";
#define ln cout<<"\n";
// cout<<"Case #"<<ts<<": ";
#include <bits/stdc++.h>
using namespace std;

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

	 ll t=1,r,n,a,d,c,b,x,y,sum,cnt,i,j,k,m,l,q,maxx,minn,temp,ans,flag,g,ts;
	
	 char ch;
	 double dans;
	 string str,ttr;
	 
//	 cin >> t;

	
	for(ts=1;ts<=t;ts++)
	{
	     flag=0;sum=0;cnt=0;ans=0;k=0;maxx=0;minn=0;a=0;b=0;temp=0;
	    
	     cin >>n;
	     string arr[n];
	     
	     for(i=0;i<n;i++)
	     cin >> arr[i];
	     
	     sort(arr,arr+n);
	     
	   //  for(i=0;i<n;i++)
	    // cout << arr[i]<<endl;
	     
	     for(i=0;i<n;i++)
	     {
	        str=arr[i];cnt++;
	        if(arr[i+1]==str){
	        while(arr[i]==str && i<n)
	        i++;
	        i--;
	        }
	        
	        
	     }
	     cout<<cnt;
	     
	     
	    
	     ln
	 }
	return 0;
}


Measured memory_bytes: 9916
function Main(input) {
	var input = input.split("\n");
	var str = input[0].split(" ");
	var a = input[1].split(" ")[0];
	var b = input[1].split(" ")[1];
	var u = input[2];

	if(str[0] === u) {
		a = a - 1;
	} else {
		b = b - 1;
	}

	console.log(a+" "+b);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
// Problem : E - Bomber
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_e
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*

WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

int main()
{
    io;
    ll h,w,m,ans=0;
    cin>>h>>w>>m;
    map<ll,ll> cntx,cnty;
    multiset<pll,greater<pll> > mx,my;
    map<pll,bool> check;
    FOR(i,0,m)
    {
    	ll x,y;
    	cin>>x>>y;
    	cntx[x]++;
    	cnty[y]++;
    	check[{x,y}]=true;
    }
    for(auto x:cntx)
    {
    	mx.insert(mp(x.S,x.F));
    }
    for(auto x:cnty)
    {
    	my.insert({x.S,x.F});
    }
    
    ans=(*mx.begin()).F+(*my.begin()).F; //temporary
    
    ll xmax=(*mx.begin()).F,ymax=(*my.begin()).F;
    
    vll x,y;
    for(auto a: mx)
    {
    	if(a.F==xmax)
    	{
    		x.pb(a.S);
    	}
    	else{break;}
    }
    for(auto a: my)
    {
    	if(a.F==ymax)
    	{
    		y.pb(a.S);
    	}
    	else{break;}
    }
    
    if(x.size()*y.size()>300000){cout<<ans;return 0;}
    //cout<<x.size()<<" "<<y.size();newl;
    FOR(i,0,x.size())
    {
    	FOR(j,0,y.size())
    	{
    		if(check.find({x[i],y[j]})==check.end())
    		{
    			cout<<ans;return 0;
    		}
    	}
    }
    cout<<ans-1;
    return 0;
}



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

bool judge(int h, int w, int k, vector<vector<bool>> &black, int &bit1, int &bit2) {
  bool ans = false;
  int cnt = 0;
  for (int i = 0; i < h; i++) {
    if (bit1 & (1 << i)) {
      for (int j = 0; j < w; j++) {
        black[i][j]=false;
      }
    }
  }
  for (int i = 0; i < w; i++) {
    if (bit2 & (1 << i)) {
      for (int j = 0; j < h; j++) {
        black[j][i]=false;
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (black[i][j]==true) cnt++;
    }
  }
  if (cnt==k) ans=true;
  return ans;
}


int main() {
  int h,w,k;
  cin >> h >> w >> k;
  vector<vector<bool>> black(h, vector<bool>(w, false));
  vector<string> field(h);
  for (int i = 0; i < h; i++) {
    cin >> field.at(i);
    for (int j = 0; j < w; j++) {
      if (field[i][j]=='#') black[i][j]=true;
    }
  }
  int ans = 0;
  vector<vector<bool>> black2(h, vector<bool>(w, false));
  for (int bit1 = 0; bit1 < (1 << h); bit1++) {
    for (int bit2 = 0; bit2 < (1 << w); bit2++) {
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          black2[i][j] = black[i][j];
        }
      }
       if (judge(h, w, k, black2, bit1, bit2)) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
#define MAX 100000
#define INF 200000000
typedef struct {
  char suit;
  int value;
}Card;

Card L[MAX/2+2],R[MAX/2+2];
void merge(Card A[], int n,int l,int m,int r){
  int i,j,k;
  int n1=m-l,n2=r-m;
  for(i=0;i<n1;i++)L[i]=A[l+i];
  for(i=0;i<n2;i++)R[i]=A[m+i];
  L[n1].value=R[n2].value=INF;
  i=j=0;
  for(k=l;k<r;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }else{A[k]=R[j++];}
  }
} 
void mergeSort(Card A[],int n,int l,int r){
  int m;
  if(l+1<r){
    m=(l+r)/2;
    mergeSort(A,n,l,m);
    mergeSort(A,n,m,r);
    merge(A,n,l,m,r);
  }
}

int partition(Card A[],int n,int p,int r){
  int i,j;
  Card t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
}
}
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}
void quickSort(Card A[],int n,int p,int r){
    int q;
    if(p<r){
      q=partition(A,n,p,r);
      quickSort(A,n,p,q-1);
      quickSort(A,n,q+1,r);
    }
}

int main(){
  Card A[MAX],B[MAX];
  int n,i,v;
  char S[10];
  int stable=1;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  } 
  //
  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);
  //
  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit)stable=0;
}
  if(stable==1)printf("Stable\n");
  else printf("Not stable\n");

  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
}

return 0;
}

Measured memory_bytes: 2952
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf 10000000000000000ll
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define eps 1e-9
#define endl "\n"
/*ll gcd(ll a,ll b)
{
    if(a==0){return b;}
    return gcd(b%a,a);
}
ll modexp(ll x,ll y,ll p)
{
    ll res=1;x%=p;
    while(y>0)
    {   if(y%2==1){res=(res*x)%p;}
        y=y>>1;x=(x*x)%p;
    }return res;
}*/
const int maxn=1e5+10;
ll a[maxn];
ll b[maxn];
ll n;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    rep(i,1,n)
    {
        cin>>a[i];
    }
    ll s=0;
    rep(i,1,n)
    {
        if(i%2==0)
        {
            s-=a[i];
        }
        else
        {
            s+=a[i];
        }
    }
    b[1]=s;
    rep(i,2,n)
    {
        b[i]=a[i-1]-b[i-1]/2;
        b[i]=2*b[i];
    }
    rep(i,1,n)
    {
        cout<<b[i]<<" ";
    }



    return 0;

    /*check for long long or int*/
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    vector<int> now(N, inf+1);
    rep3(i, N-1, 0){
        int j = upper_bound(all(now), A[i]) - now.begin();
        now[j] = A[i];
    }
    cout << upper_bound(all(now), inf) - now.begin() << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

struct edge{ll s, t, cost;};

bool comp(edge& e1, edge& e2){
    return e1.cost < e2.cost;
}

struct UnionFind
{
    vector<long long> d;
    UnionFind(long long n = 0) : d(n, -1)
    {
    }

    //root : -size, not root: root
    long long root(long long x){
        if(d[x] < 0){
            return x; 
        }
        return d[x] = root(d[x]);
    }

    bool unite(long long x, long long y){
        x = root(x);
        y = root(y);
        if(x == y){
            return false;
        }
        if(d[x] > d[y]){
            swap(x, y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    long long size(long long x){
        return -d[root(x)];
    }

    bool issame(long long a, long long b){
        return root(a) == root(b);
    }
};

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll v, e; cin >> v >> e;
    edge es[e];
    rep(i, e){
        cin >> es[i].s >> es[i].t >> es[i].cost;
    }
    sort(es, es + e, comp);
    UnionFind uf(v);
    ll ans = 0;
    for(ll i = 0; i < e; i++){
        edge e = es[i];
        if(!uf.issame(e.s, e.t)){
            uf.unite(e.s, e.t);
            ans += e.cost;           
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5512
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

int isVowel(char c){
	if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
		return 1;
	}
	else return 0;
}

string code(string str,int num){

	int cnt=1;
	string tmp = str.substr(0,1);

	for(int i=0;i<str.length()-1;i++){
		if(cnt==num)break;

		if(isVowel(str.at(i))){
			tmp += str.substr(i+1,1);
			cnt++;
		}
	}

	return tmp;

}

int main(){

	int num;
	while(cin>>num){
		if(num==0)break;
		vector<string> v;
		string tmp;
		for(int i=0;i<num;i++){
			cin>>tmp;
			v.push_back(tmp);
		}
		int ansFlag=0;
		for(int k=50;k>=1;k--){
			set<string> s;
			for(int j=0;j<num;j++){
				//cout<<code(v.at(j),k)<<endl;
				s.insert(code(v.at(j),k));
			}
			if(s.size()!=num){
				if(k==50){
					cout<<-1<<endl;
				}
				else{
					cout<<k+1<<endl;
				}
				ansFlag=1;
				break;
			}
		}
		if(ansFlag==0){
			cout<<1<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3132
// Vivek Rai
// Blazer_007

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define fastio      ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define ppi         pair<int,pii>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define bit(x, y)   (((x)>>(y))&1)
#define bpt(x)      (__builtin_popcount(x))
#define bptl(x)     (__builtin_popcountll(x))
#define loop(i,a,b)  for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)

using namespace std;
using namespace __gnu_pbds;

typedef priority_queue<int> maxHeap;
typedef priority_queue<int, vector<int>, greater<int> > minHeap;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(index) -> value at given index or Kth smaintest element in set
// order_of_key(X) -> number of elements strictly less than X
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> OST;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cout << name << " : " << arg1 << endl;
    //use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

template <typename T>
istream &operator>>(istream &in, vector<T> &arr)
{
    for(int i = 0 ; i < arr.size() ; i++)
        cin >> arr[i];
    return in;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> arr)
{
    for(int i = 0 ; i < arr.size() ; i++)
        cout << arr[i] << " ";
    cout << endl;
    return os;
}


void solution()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a*c,a*d,b*c,b*d}) << endl;
}

signed main()
{
    fastio
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    // cin >> t;
    loop(i, 1, t + 1)
    {
        //cout<<"Case #"<<i<<": ";
        solution();
    }
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll N,K;
ll p[101];
ll l,r;
bool found;

int main() {
    cin >> N >> K;
    for(int i=0;i<K;i++){
        cin >> p[i];
    }
    sort(p,p+K);
    for(int i=0;i<K;i++){
        if(p[i] == N){
            found = true;
            l = p[0] -1;
            r = p[K-1] + 1;
            for(int j=1;j<=i;j++){
                if(p[i-j+1] - p[i-j] != 1){
                    l = p[i-j+1]-1;
                    break;
                }
            }
            for(int j=1;j<K-i;j++){
                if(p[i+j] - p[i+j-1] != 1){
                    r = p[i+j-1]+1;
                    break;
                }
            }
        }
    }
    if(found){
        if(r-N<N-l){
            cout << r << endl;
        }else{
            cout << l << endl;
        }
    }else{
        cout << N << endl;
    }
    
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long LL;
using namespace std;
const int N=1e5+5;
int n,m,fa[N],p[N];
LL sum[N],f[N],a[N],b[N];
int head[N],ce;
bool vis[N];
struct edge{int to,nxt;} e[N<<1];
bool cmp(int x,int y) {return a[x]<a[y];}
void adde(int x,int y) {e[++ce].to=y,e[ce].nxt=head[x],head[x]=ce;}
int find(int x)
{
	if(x==fa[x]) return x;
	return fa[x]=find(fa[x]);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld%lld",&a[i],&b[i]);
		a[i]=max(a[i]-b[i],0ll);
		p[i]=fa[i]=i,f[i]=a[i],sum[i]=b[i];
	}
	for(int i=1;i<=m;++i)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		adde(x,y); adde(y,x);
	}
	sort(p+1,p+n+1,cmp);
	for(int i=1;i<=n;++i)
	{
		int u=p[i]; vis[u]=1;
		for(int j=head[u];j;j=e[j].nxt)
		{
			int v=e[j].to;
			if(!vis[v]) continue;
			int x=find(u),y=find(v);
			if(x!=y)
			{
				fa[y]=x,sum[x]+=sum[y];
				f[x]=min(f[x],max(f[y],a[x]-sum[y]));
			}
		}
	}
	printf("%lld",f[find(1)]+sum[find(1)]);
	return 0;
}

Measured memory_bytes: 6144
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 1e5;
int N;
ll A[Nmax];

int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> A[i];

	deque<ll> deq;
	deq.push_back(A[0]);

	for(int i=1; i<N; i++){
		auto lb = lower_bound(deq.begin(), deq.end(), A[i]);
		if(lb==deq.begin()){
			deq.push_front(A[i]);
		} else {
			lb--;
			*lb = A[i];
			if(lb+1 != deq.end() && *lb > *(lb+1)) swap(*lb, *(lb+1));
		}
		//cout << i << " ";
		//for(ll x: deq) cout << x << " ";
		//cout << endl;
	}

	cout << deq.size() << endl;

	return 0;
}


Measured memory_bytes: 1792
/*input
6 6
0101010
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<ll,ll>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=1e6+1;
const ll MOD=1e18;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}

// default code end
const ll maxn=1e5+5;
const ll maxlg=__lg(maxn)+2;
int dp[maxn],q[maxn];
int main(){
    int n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    dp[0]=0;
    int head=1,tail=0;
    q[++tail]=0;
    REP1(i,n){
        if(s[i]=='1'){
            dp[i]=INF;
            while(i-q[head]+1>m and head<=tail) head++;
            while(dp[i]<dp[q[tail]] and head<=tail) tail--;
        }
        else{
            dp[i]=dp[q[head]]+1;
            while(i-q[head]+1>m and head<=tail) head++;
            while(dp[i]<dp[q[tail]] and head<=tail) tail--;
        }
        //cout<<head<<' '<<tail<<'\n';
        //cout<<dp[i]<<'\n';
        q[++tail]=i;
    }
    if(dp[n]>=INF){
        cout<<-1;
        return 0;
    }
    //return 0;
    int cur=n,stps=dp[n];
    vector<int> v;
    while(cur>0){
        //cout<<cur<<'\n';
        for(int j=m;j>=1;j--){
            if(cur>=j and dp[cur-j]==dp[cur]-1){
                v.pb(j);
                cur-=j;
                break;
            }
        }
    }
    reverse(ALL(v));
    for(auto x:v) cout<<x<<' ';
}

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

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



int main(){
    int n;
    cin>>n;
    
    
    int a,mi=9999999,ma=0;
    
    rep(i,n){
        cin>>a;
        mi = min(mi,a);
        ma = max(ma,a);
    }
    
    cout<<ma-mi<<endl;
    
    
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc077/tasks/arc084_a

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int A_I_MAX = 1e9;
const int B_I_MAX = 1e9;
const int C_I_MAX = 1e9;

int N;
int A[N_MAX];
int B[N_MAX];
int C[N_MAX];

ll acc[N_MAX + 1];

void solve() {
  sort(A, A + N);
  sort(B, B + N);
  sort(C, C + N);
  REP(i, N) {
    acc[i + 1] = acc[i] + N - (upper_bound(C, C + N, B[i]) - C);
  }
  ll ans = 0;
  REP(i, N) {
    int k = upper_bound(B, B + N, A[i]) - B;
    ans += acc[N] - acc[k];
  }
  printf("%lld\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", A + i);
  REP(i, N) scanf("%d", B + i);
  REP(i, N) scanf("%d", C + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
#define inf 0x3f3f3f3f
#define N 4000010
//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
ll a[N];

int main(){
	ll n,cnt=0;
	scanf("%lld",&n);
	ll len=sqrt(n);
	for(ll i=1;i<=len;i++)
    {
        if(n%i==0)
            a[++cnt]=i;
    }
    printf("%lld\n",a[cnt]+n/a[cnt]-2);
	return 0;
}


Measured memory_bytes: 3808
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n; cin >> n;
    vector<pair<pair<string, int>, int>> v(n);
    rep(i,n){cin >> v[i].first.first >> v[i].first.second; v[i].second = i; v[i].first.second = 100 - v[i].first.second;}
    sort(all(v));
    rep(i,n) cout << v[i].second+1 << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::cmp;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn main() {
    let v = read_vec::<usize>();
    let k = read::<usize>();
    let max = cmp::max(cmp::max(v[0],v[1]),v[2]);
    let rest = v[0] + v[1] + v[2] - max;
    println!("{}",max * 2usize.pow(k as u32) + rest);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
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 dp[n][3];
    dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];
    for (int i = 1; i < n; i++) {
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
    }
    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;
}


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

#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0);
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(x) x.begin(),x.end()
#define V(x) vector<x>
#define P(x,y) pair<x,y>
#define UMP(x,y) unordered_map<x,y>
#define MP(x,y) map<x,y>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define inf 1e18
#define endl "\n"
#define coutd(n) cout << fixed << setprecision(n)
#define watch(x) cout<<#x<<" = "<<x<<endl;
typedef double db;
typedef long double ld;	
const int mod = 1000000007;

using namespace std;

int32_t main(){
    fast
    	
    //int t;
	//cin>>t;
	//rep(_,0,t){
		
	//}
	string s,t,result = "Yes";
	cin>>s>>t;
	for(int i=0;i<s.length();i++){
		if(s[i] != t[i])
			result = "No";
	}
	
	cout<<result;
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	string s;
	cin >> s;
	if (s == "Sunny") cout << "Cloudy\n";
	else if (s == "Cloudy") cout << "Rainy\n";
	else if (s == "Rainy") cout << "Sunny\n";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  long long N, K,gou=0,a;

   cin >> N >> K;
  if(K == 0){
    cout << N*N << endl;
    return 0;
  }

  for(int i=1; i<=N; i++){
    a = (i-K);
    if(a > 0){
      gou += (N/i)*a;
      if(N%i >= K){
        gou += N%i-(K-1);
      }
    }
  }
  cout << gou << endl;
  return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int
#define Vec vector

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }
int gcd(int a, int b){ return a == 0 ? b : gcd(b % a, a); }

int main(){
	int N;
	cin >> N;
	Vec<int> A(N);
	for(int i=0;i<N;i++) cin >> A[i];
	int g = A[0];
	for(int i=0;i<N;i++) g = gcd(g, A[i]);
	cout << g << endl;

	
    return 0;
}


Measured memory_bytes: 640
fun <T> permutation(sortedList: List<T>): List<List<T>> {
    val queue = mutableListOf<List<T>>()
    queue += arrayListOf<T>()
    val permutations = mutableListOf<List<T>>()
    while (queue.isNotEmpty()) {
        val p = queue.removeAt(0)

        if (p.size == sortedList.size) {
            permutations += p
            continue
        }

        for (item in (sortedList - p)) {
            queue += (p + item)
        }
    }

    return permutations
}

fun main(args: Array<String>) {
    val n = readInteger()
    val p = readIntegerList().joinToString("")
    val q = readIntegerList().joinToString("")

    val per = permutation((1..n).toList()).map { it.joinToString("") }
    Math.abs(per.indexOf(p) - per.indexOf(q)).let(::println)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 59508
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(n: usize) -> usize {
    let mut dp = vec![std::usize::MAX; n+1];

    dp[0] = 0;

    for i in 0..n+1 {
        let v = dp[i];
        for j in 0.. {
            let total = i + 6usize.pow(j);
            if total > n {
                break
            }
            if v+1 < dp[total] {
                dp[total] = v+1;
            }
        }

        for j in 0.. {
            let total = i + 9usize.pow(j);
            if total > n {
                break
            }
            if v+1 < dp[total] {
                dp[total] = v+1;
            }
        }
    }

    dp[n]
}

fn main() {
    let n = parse_line!(usize);

    println!("{}", solve(n));
}

#[test]
fn solve_test() {
    assert_eq!(solve(127), 4);
    assert_eq!(solve(3), 3);
    assert_eq!(solve(44852), 16);
    assert_eq!(solve(1), 1);
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    cin >> n;

    int ans = 0;
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        while(a % 2 == 0){
            a /= 2;
            ++ ans;
        }
    }
    cout << ans << endl;

    return 0;
}


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

ll N;
int ans = 0;

void dfs(int t,ll x){
    if (x > N) return;
    {
        ll y = x;
        vector<int> a(10);
        while (y > 0) {
            a[y%10]++;
            y /= 10;
        }
        if (a[3] == 0 || a[5] == 0 || a[7] == 0) ans--;
        ans++;
    }
    if(1<=x && x<=N){
        ans--;
    }
    if (1 <= x && x <= N) {
        ans++;
    }
    if(x <= N) ans--;
    if (false) {
        return;
        dfs(t+1,x*10+7);
    }
    if (x <= N) {
        ans++;
    }
    dfs(t+1,x*10+3);
    dfs(t + 1, x * 10 + 5);
    dfs(t+1,x*10+7);
}

int main(){
    cin >> N;
    dfs(0,0);
    cout << ans << endl;
}


Measured memory_bytes: 256
$K=<>;
@A=glob<>;
exit!print-1if 2!=pop@A;
$l=2;$r=3;
for(reverse@A){
	$l=(~-$l/$_+1|0)*$_;
	$r=($r/$_+1|0)*$_-1;
	exit!print-1if$l>$r
}
print"$l $r";


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1005,INF=1000;

int main(){
    
    int N,M;cin>>N>>M;
    vector<int> S(N,0);
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        S[a]++;
        S[b]++;
    }
    
    bool flag=true;
    
    for(int i=0;i<N;i++){
        if(S[i]%2==1) flag=false;
    }
    
    if(flag) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 640
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	S := sc.nextStr()
	ans := ""
	for i := 0; i < len(S); i++ {
		if (i+1)%2 != 0 {
			ans += string(S[i])
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 10880
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


#define ALL(x) (x).begin(),(x).end()

LL mod = 1000000007;

int main() {
	string s;
	cin >> s;
	char a = s[0];
	char b = s[s.size() - 1];
	if (a == b&&s.size() % 2 == 1) {
		cout << "Second" << endl;
	}else
		if (a == b&&s.size() % 2 == 0) {

			cout << "First" << endl;
		}else
			if (a != b&&s.size() % 2 == 1) {
				cout << "First" << endl;
			}
			else
				if (a != b&&s.size() % 2 == 0) {

					cout << "Second" << endl;
				}
}

Measured memory_bytes: 512
let readCharArray _ = stdin.ReadLine().ToCharArray()

stdin.ReadLine()

()
|> readCharArray
|> Array.map (fun x -> if x = 'I' then 1 else -1)
|> Array.mapFold (fun state num -> (state, state + num)) 0
|> fun (a, b) -> Array.append a [| b |]
|> Array.max
|> printfn "%d"


Measured memory_bytes: 29968
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
String s=sc.next();
int c=0;
    for (char i = 'a'; i <= 'z'; i++) {
        if(s.contains(Character.toString(i)))c++;
    }
    if(c==s.length()){
        out.println("yes");
    }else{
        out.println("no");
    }
}
}

Measured memory_bytes: 21844
#![allow(unused)]

use proconio::input;
use proconio::marker::{Bytes, Chars, Usize1};
use std::cmp::{Reverse, min, max};
use itertools::Itertools;

#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        ps: [Usize1; n * n],
    }

    let mut cs = vec![vec![0; n + 2]; n + 2];
    for i in 1..=n {
        for j in 1..=n {
            cs[i][j] = *[i - 1, j - 1, n - i, n - j].iter().min().unwrap()
        }
    }

    let mut exited = vec![vec![false; n + 2]; n + 2];
    let mut ans = 0;
    for p in ps {
        let i = p / n + 1;
        let j = p % n + 1;

        exited[i][j] = true;
        ans += cs[i][j];

        let mut q = vec![(i, j)];
        while let Some((i1, j1)) = q.pop() {
            let c = cs[i1][j1] + if exited[i1][j1] { 0 } else { 1 };
            for &(i2, j2) in &[
                (i1 - 1, j1),
                (i1 + 1, j1),
                (i1, j1 - 1),
                (i1, j1 + 1),
            ] {
                if cs[i2][j2] > c {
                    cs[i2][j2] = c;
                    q.push((i2, j2));
                }
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 9804
#include "./bits/stdc++.h"
using namespace std;
typedef long long ll;
int N;

int main(){
    cin>>N;
    int h[N];
    int ans=0;
    int x=0;
    int b;

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

    for(int i=0;i<N;i++){
        if(x < h[i]){
            ans+=h[i]-x;
            x=h[i];
        }else{
            x=h[i];
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
	long long int n,ans=0,s=0,i,s1=0,ans1=0;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++){
	cin>>a[i];
	s+=a[i];}
	s1=(int)ceil(1.0*s/n);
	s/=n;
	for(i=0;i<n;i++){
	ans+=(1ll)*(a[i]-s)*(a[i]-s);
	ans1+=(1ll)*(a[i]-s1)*(a[i]-s1);}
	cout<<min(ans,ans1);
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

s = [int(s) for s in list(input()) if s != '\n']

odd = sum(s[::2])
even = sum(s[1::2])
if even >= odd:
    ans = len(s)//2-even+odd
elif len(s) % 2 == 1:
    ans = len(s)//2-odd+even+1
else:
    ans = len(s)//2-odd+even
print(ans)


Measured memory_bytes: 4652
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
As = [(0, 0, 0)]
for i in range(H):
    for j in range(W):
        As.append((A[i][j], i+1, j+1))
Q = int(input())
Qs = [list(map(int, input().split())) for _ in range(Q)]
As.sort()
dp = [0] * (H*W+1)
for i in range(1, H*W+1- D):
    a1, j, k = As[i]
    a2, x, y = As[i+D]
    dp[i+D] = dp[i] + abs(x-j) + abs(y-k)
    
for l, r in Qs:
    print(dp[r] -dp[l])

Measured memory_bytes: 81500