akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int a, b, n, m;

int main(void){
  cin >> a >> b;
  n = 100, m = 100;  
  vector<string> s(n);
  for(int i=0;i<n;i++){
    s[i] = "";
    for(int j=0;j<m;j++){
      s[i] += (i<n/2) ? '.' : '#';
    }
  }
  
  int cnt = 1;
  for(int i=0;i<n/2;i+=2){
    for(int j=0;j<m;j+=2){
      if (cnt==b) break;
      s[i][j] = '#';
      cnt++;
    }if (cnt==b) break;
  }
  
  cnt = 1;
  for(int i=n-1;i>n/2;i-=2){
    for(int j=0;j<m;j+=2){
      if (cnt==a) break;
      s[i][j] = '.';
      cnt++;
    }if (cnt==a) break;
  }  
  
  
  cout << n << " " << m << endl;
  for(int i=0;i<n;i++) cout << s[i] << endl;  
  return 0;
}


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

int main()
{
  int K, S;
  cin >> K >> S;

  int cnt = 0;
  for (int X = 0; X < K + 1; X++)
  {
    for (int Y = 0; Y < K + 1; Y++)
    {
      if (0 <= S - X - Y && S - X - Y <= K)
        cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstring>
using namespace std;
int const maxn=2e5+10;
struct ed
{
    int to,next,before;
}e[2*maxn];
struct bkn
{
    int x,d;
    friend bool operator <(bkn a,bkn b)
    {
        return a.d>b.d;
    }
};
int head[maxn],tot=-1,dis[maxn];
priority_queue<bkn> q;
void add(int a,int b)
{
    e[tot].to=b;
    e[tot].next=head[a];
    head[a]=tot++;
}
int main()
{
    int n,m,x,y;
    cin>>n>>m;
    int i;
    tot=0;
    memset(head,-1,sizeof(head));
    while (m--)
    {
        cin>>x>>y;
        add(x,y);
        add(y,x);
    }
    for (i=1;i<=n;i++)
        dis[i]=100000000;
    bkn gg;
    dis[1]=0;
    gg.x=1;
    gg.d=0;
    q.push(gg);
    int d;
    while (!q.empty())
    {
        x=q.top().x;
        q.pop();
        for (i=head[x];i!=-1;i=e[i].next)
        {
            y=e[i].to;
            if (dis[y]>dis[x]+1)
            {
                dis[y]=dis[x]+1;
                gg.x=y;
                gg.d=dis[y];
                q.push(gg);
            }
        }
    }
    //cout<<dis[n]<<endl;
    if (dis[n]<=2) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}



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

int main() {
    int n;
    cin >> n;
    int ac = 0, wa = 0, tle = 0, re = 0;

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == "AC") ac++;
        else if (s == "WA") wa++;
        else if (s == "TLE") tle++;
        else re++;
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define vint vector<signed>
#define pint pair<signed,signed>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define isEven(t) t%2==0
signed main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,n)cin>>a[i];
  int res=0;
  rep(i,n){
    while(a[i]%2==0){
      res++;
      a[i]/=2;
    }
  }
  cout<<res++;
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  
  vector<int> vec(N);
  for (int i=0;i<N;i++) {
    cin >> vec.at(i);
  }
  
  int a = -1;
  for (int i=0;i<N;i++) {
    if (a<vec.at(i)) {
      a = vec.at(i);
    }
  }
  
  int b = 1000000000;
  for (int i=0;i<N;i++) {
    if (b>vec.at(i)) {
      b = vec.at(i);
    }
  }
    
  cout << a - b << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, n) for (int i = 0; i < n; i++)
#define repn(i, a, b) for (int i = a;i<=b;i++)
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define mem(x) memset(x, 0, sizeof(x))
#define ritr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define pai pair < int, int> 
#define pal pair < ll, ll> 
#define vi vector <int> 
#define vl vector < ll > 
#define vpai vector < pii > 

const int mod = 1e9+7;
const int INF = INT_MAX;
const int sze = 10001;

ll dp[sze][101][2];

ll calc(string str,int pos,int d,int tight,int sum){
    if(pos==(int)str.length()){
        if(sum==0) return 1;
        else return 0;
    }
    if(dp[pos][sum][tight]!=-1) return dp[pos][sum][tight];
    ll res=0;
    if(tight&1){
        for(int i=0;i<=str[pos]-'0';i++){
            if(i==str[pos]-'0'){
                res=(res+calc(str,pos+1,d,1,(sum+i)%d))%mod;
            }else res=(res+calc(str,pos+1,d,0,(sum+i)%d))%mod;
        }
    }else{
        for(int i=0;i<10;i++) res=(res+calc(str,pos+1,d,0,(sum+i)%d))%mod;
    }
    return dp[pos][sum][tight]=res;
}

void solve() {
    string str;
    cin>>str;
    int d;
    cin>>d;
    memset(dp,-1,sizeof(dp));
    
    cout<<(calc(str,0,d,1,0)-1+mod)%mod;
}

int main() {
    IOS;

    int t = 1;
    // cin >> t;
    while (t--) {
       solve();
    }

  return 0;
}

Measured memory_bytes: 118520
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define MAX 100005
 
int V,E;
vector<int> G[MAX];
 
int depth[MAX];
int cnt[MAX];
int visited[MAX];
 
vector<P> ans;
 
void dfs(int pos,int prev){
  visited[pos]=true;
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    if(!visited[to]){
      depth[to]=depth[pos]+1;
      dfs(to,pos);
      cnt[pos]+=cnt[to];
      if(cnt[to]==0)ans.push_back( P( min(pos,to) , max(pos,to) ) );
    }else if(depth[to]<depth[pos]){
      cnt[pos]++;
      cnt[to]--;
    }
  }
}
 
int main(){
  scanf("%d %d",&V,&E);
  for(int i=0;i<E;i++){
    int a,b;
    scanf("%d %d",&a,&b);
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(0,-1);
  sort(ans.begin(),ans.end());
   
  cout<<ans.size()<<endl;
  return 0;
}


Measured memory_bytes: 2560
r, c = map(int, raw_input().split())
a = []
for _ in range(r):
	a.append(map(int, raw_input().split()))

for i in range(r):
	a[i].append(sum(a[i]))
	print ' '.join(map(str, a[i]))

b = [0 for _ in range(c+1)]
for j in range(c+1):
	for i in range(r):
		b[j] += a[i][j]
print " ".join(map(str, b))

Measured memory_bytes: 4696
a, b = map(int, input().split())
if b%2 == 1:
    F0_b = (b+1) // 2 % 2
else:
    F0_b = (b) // 2 % 2 ^ b
c = a - 1
if (c)%2 == 1:
    F0_c = (c+1) // 2 % 2
else:
    F0_c = (c) // 2 % 2 ^ c

print(F0_b ^ F0_c)


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, a, b;
	cin >> n >> m >> a >> b;
	int A = a, B = b;
	vector<string> v(n, string(m, '.'));
	if (n % 2) {
		REP(i, m / 2) {
			if (a > 0 && i * 2 + 1 < m&&v[n - 1][i * 2] == '.') {
				v[n - 1][i * 2] = '<';
				v[n - 1][i * 2 + 1] = '>';
				a--;
			}
		}
	}
	if (m % 2) {
		RFOR(i,1, n) {
			if (b > 0 && v[i][m-1]=='.'&&v[i][m-1]=='.') {
				v[i-1][m - 1] = '^';
				v[i][m - 1] = 'v';
				b--;
				i--;
			}
		}
	}
	RREP(i, n / 2) {
		REP(j, m / 2) {
			if (a >= 2) {
				v[i * 2][j * 2] = '<';
				v[i * 2 + 1][j * 2] = '<';
				v[i * 2][j * 2 + 1] = '>';
				v[i * 2 + 1][j * 2 + 1] = '>';
				a -= 2;
			}
			else if (b >= 2) {
				v[i * 2][j * 2] = '^';
				v[i * 2 + 1][j * 2] = 'v';
				v[i * 2][j * 2 + 1] = '^';
				v[i * 2 + 1][j * 2 + 1] = 'v';
				b -= 2;
			}
		}
	}

	if (a == 1) {
		RREP(j, m-1) {
			REP(i, n) {
				if (v[i][j] == '.'&&v[i][j + 1] == '.') {
					a--;
					v[i][j] = '<';
					v[i][j + 1] = '>';
					goto a;
				}
			}
		}
	}
a:;
	if (b == 1) {
		RREP(i, n - 1) {
			REP(j, m) {
				if (v[i][j] == '.'&&v[i + 1][j] == '.') {
					b--;
					v[i][j] = '^';
					v[i + 1][j] = 'v';
					goto b;
				}
			}
		}
	}
b:;
	if (a == 0 && b == 0) {
		cout << "YES" << endl;
		REP(i, n)cout << v[i] << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    string w;
    cin >> w;
    int n = w.size();
    vector<int> num(40, 0);
    for (int i=0; i<n; i++){
        num[w[i]-97] ++;
    }
    for (int i=0; i<40; i++){
        if(num[i] % 2 != 0){
            out("No");
            return 0;
        }
    }
    out("Yes");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100009];
int fun(int a[],int n){
	dp[0]=0;
  for(int i=1;i<=n;i++){
  	if(i==1||i==2){
     	dp[i]=abs(a[i]-a[0]);
    }
    else{
      dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
  }
  return dp[n];
}
int main(){
	int n;
    cin>>n;
  	int a[n];
  for(int i=0;i<n;i++){
  	cin>>a[i];
  }
  cout<<fun(a,n-1)<<endl;
}

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

int main() {
  char b;
  cin >>b;
  if(b=='A'){
    cout<<'T'<<endl;
  }
  if(b=='T'){
    cout<<'A'<<endl;
  }
  if(b=='G'){
    cout<<'C'<<endl;
  }
  if(b=='C'){
    cout<<'G'<<endl;
  }
}

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

using namespace std;

int main()
{
	vector <int> v;
	for (int i = 0; i < 3; i++)
	{
		int t;
		cin >> t;
		v.push_back(t);
	}
	sort(v.begin(), v.end());
	if (v[0] == 5 && v[1] == 5 && v[2] == 7) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,m;
	cin >> n >> m;
	vector<ll> c(m);
	FOR(i,0,m)cin >> c[i];
	vector<ll> dp(n+1);
	FOR(i,0,n+1)dp[i]=i;
	FOR(i,0,m){
		FOR(j,0,n+1){
			if(j+c[i]<=n)dp[j+c[i]] = min(dp[j+c[i]],dp[j]+1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 3284
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,m,a[100][100],b[100][100],dp[85][85][14000],ans=1e9;

int main()
{
	cin>>n>>m;
	rep(i,n) rep(j,m) cin>>a[i][j];
	rep(i,n) rep(j,m) cin>>b[i][j];
	dp[0][0][a[0][0]-b[0][0]+7000]=dp[0][0][b[0][0]-a[0][0]+7000]=1;
	rep(i,n) rep(j,m)
	{
		for(int k=300;k<=13700;k++)
		{
			if(dp[i][j][k]==0) continue;
			if(i+1<n)
			{
				dp[i+1][j][k+a[i+1][j]-b[i+1][j]]=1;
				dp[i+1][j][k+b[i+1][j]-a[i+1][j]]=1;
			}
			if(j+1<m)
			{
				dp[i][j+1][k+a[i][j+1]-b[i][j+1]]=1;
				dp[i][j+1][k+b[i][j+1]-a[i][j+1]]=1;
			}
		}
	}
	for(int k=300;k<=13700;k++) if(dp[n-1][m-1][k]==1) ans=min(ans,abs(k-7000));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 371584
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i) 
#endif

#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int EPS = 1e-9;
const int MOD = 1e9+7;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 0;
  REP(i,n){
    int a;
    cin >> a;
    while(a%2 == 0){
      ans++;
      a /= 2;
    }
  }
  cout << ans << endl;
  return 0;
}



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

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

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

ld a, b, C;

ld S, L, h;

int main(){
	cin.tie(0);
	
	cin>>a>>b>>C;
	C = C/180.0 * M_PI;
	
	S = a*b*sin(C)/2.0;
	L = a+b+sqrt(a*a+b*b-2*a*b*cos(C));
	h = b*sin(C);
	
	cout<<fixed<<setprecision(6)<<S<<' '<<L<<' '<<h<<endl;
	
	return 0;
}



Measured memory_bytes: 3504
n = int(input())
c = list(input())

ans = 0
i = 0
j = n-1
while j>i:
    if c[i] == 'W' and c[j] == 'R':
        ans+=1
        i+=1
        j-=1
    elif c[i] == 'W' and c[j] == 'W':
        j-=1
    elif c[i] == 'R' and c[j] == 'R':
        i+=1
    else: # R W
        i+=1
        j-=1
print(ans)


Measured memory_bytes: 10784
#include <stdio.h>
int main()
{
  int h,w,g,r;
  scanf("%d %d",&h,&w);
  while(h!=0||w!=0){
    for(g=0;g<h;g++){
      for(r=0;r<w;r++){
	printf("#");
      }
      printf("\n");
    }
    printf("\n");
    scanf("%d %d",&h,&w);
  }
  return 0;
}

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

vector<int> z_algorithm(string s) {
    vector<int> a(s.size());
    
    int c = 0;
    for (int i = 1; i < s.size(); i++){
        if (i+a[i-c] < c+a[c]) {
            a[i] = a[i-c];
        } else {
            int j = max(0, c+a[c]-i);
            while (i+j < s.size() && s[j] == s[i+j]) ++j;
            a[i] = j;
            c = i;
        }
    }
    a[0] = a.size();   
    
    return a;
}

int main() {
    int n;
    string s;
    
    cin >> n >> s;
    
    int ans = 0;
    
    for (int i = 0; i < n - 1; i++) {
        auto z = z_algorithm(s.substr(i));
    
        for (int j = 0; j < z.size(); j++) {
            if (z[j] - 1 < j) {
                ans = max(ans, z[j]);   
            }
        }
    }
    
    cout << ans << endl;
}

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

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


  bool isDboule = true;

  if(s.size()%2 != 0) isDboule = false;
  else {
    int mid = (s.size()/2) - 1;
    int last = s.size() - 1;
    string a = s.substr(0, mid +1);
    string b = s.substr(mid+1, last);


    for(int i=0; i<= mid ; ++i) {
      if(a[i] != b[i]) {
        isDboule = false;
      }
  }
}


  if(isDboule) cout << "Yes" << endl; else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String a = scan.nextLine();
		String[] a2 = a.split("");
		String b = scan.nextLine();
		String[] b2 = b.split("");
		int al = a.length();
		int bl = b.length();
		if(al<bl){
			int n=al; al=bl; bl=n;
			String[] nu=a2; a2=b2; b2=nu;
		}
		int[][] dp = new int[bl+1][al+1];
		for(int i=1;i<=al;++i){
			dp[0][i]=dp[0][i-1]+1;
		}
		for(int i=1;i<=bl;++i){
			dp[i][0]=dp[i-1][0]+1;
		}
		for(int i=1;i<=bl;++i){
			for(int j=1;j<=al;++j){
				int min=0;
				if(b2[i-1].equals(a2[j-1])==true){
					min = Min(dp[i-1][j-1],dp[i][j-1]+1,dp[i-1][j]+1);
				} else {
					min = Min(dp[i-1][j-1]+1,dp[i][j-1]+1,dp[i-1][j]+1);
				}
				dp[i][j]=min;
			}
		}
		System.out.println(dp[bl][al]);
	}

	public static int Min(int a, int b, int c){
		int min=a;
		if(a>b){
			min=b;
		}
		if(min>c){
			min=c;
		}
		return min;
	}
}

Measured memory_bytes: 31352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	lint N;
	while (cin >> N, N != 0) {
		lint ans = 0;
		lint cnt = 1;
		while (1) {
			ans += N / pow(5, cnt);
			cnt++;
			if (N / pow(5, cnt) == 0) {
				cout << ans << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 3388
def solve_abc065d():
    from collections import namedtuple
    from operator import attrgetter
    from itertools import tee
    import sys

    input = sys.stdin.readline

    City = namedtuple('City', 'x y idx')
    Edge = namedtuple('Edge', 'cost a b')
    N = int(input())

    cities = []
    for city_idx in range(N):
        x, y = map(int, input().split())
        c_ = City(x, y, city_idx)
        cities.append(c_)
    cities_x_asc = sorted(cities, key=attrgetter('x'))
    cities_y_asc = sorted(cities, key=attrgetter('y'))

    edges = []

    it_x = iter(cities_x_asc)
    gx1, gx2 = tee(it_x, 2)
    next(gx2)
    for c1, c2 in zip(gx1, gx2):
        d_ = c2.x - c1.x
        e_ = Edge(d_, c1.idx, c2.idx)
        edges.append(e_)
    # x方向にN-1本の辺を張る

    it_y = iter(cities_y_asc)
    gy1, gy2 = tee(it_y, 2)
    next(gy2)
    for c1, c2 in zip(gy1, gy2):
        d_ = c2.y - c1.y
        e_ = Edge(d_, c1.idx, c2.idx)
        edges.append(e_)
    # y方向にN-1本の辺を張る

    edges.sort(key=attrgetter('cost'))

    # <Kruskal’s Algorithm>
    # https://tjkendev.github.io/procon-library/python/graph/min_st_kruskal.html
    # E = [(cost, v, w), ...]
    #   G上の全ての辺(v, w)とそのcostを含むlist

    # Union-Findを使うことで頂点間の連結判定を行う
    *p, = range(N)

    def root(x):
        if x == p[x]:
            return x
        p[x] = y = root(p[x])
        return y

    def unite(x, y):
        px = root(x)
        py = root(y)
        if px == py:
            return 0
        if px < py:
            p[py] = px
        else:
            p[px] = py
        return 1

    mi = 0
    for e_ in edges:
        if unite(e_.a, e_.b):
            mi += e_.cost

    # miが最小全域木の解

    print(mi)
    return


if __name__ == '__main__':
    solve_abc065d()


Measured memory_bytes: 51348
/**So..a**/
#include<bits/stdc++.h>
//#include <chrono>
// Success after trying 5 hour 11 minute :(


using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define PB(x, v) x.push_back(v);
#define M_P(a, b) make_pair(a, b)
#define pll pair<ll, ll>
#define ll long long
#define mll map<ll, ll>
#define vl vector<ll>
#define fa(x, v) for(auto x: v)
#define fr(i, a, b) for(ll i= a;i <=b; i++)
#define TEST  int test; cin >> test; while(test--)
#define FTEST int TesT; cin >> TesT; for(int test = 1; test<=TesT; test++)

#define B_ begin()
#define E_ end()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define NL_ "\n"
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second

#define MOD 998244353
#define  ull unsigned long long

ll cnt[2000000+10];
ll MAX;

void update(ll i, ll val)
{
    while(i<=MAX)
    {
        cnt[i]+=val;
        cnt[i]%= MOD;
        i += (i&-i);
    }
}
ll getsum(ll i)
{
    ll sum = 0;
    while(i)
    {
        sum+= cnt[i];
        sum%=MOD;
        i-=(i&-i);
    }
    return sum%MOD;
}

int main()
{
    ll n;
    cin >> n;
    ll k;
    cin >> k;
    MAX = n;
    update(n, 1);


    ll l[k+1], r[k+1];
    for(ll i = 1; i<=k; i++)
    {
        cin >> l[i] >> r[i];
    }
    for(ll i=n-1; i>=1; i--)
    {
        ll a = 0;
        for(ll j= 1; j<=k; j++)
        {
            if(i+l[j]>n) continue;
            else if(i+r[j]<=n)
            {
                ll t = getsum(i+r[j]) - getsum(i+l[j]-1);

                t += MOD;
                t%=MOD;
                a+=t;
                a%=MOD;

            }
            else
            {
                ll t = getsum(n) - getsum(i+l[j]-1);
                t += MOD;
                t%=MOD;
                a+=t;
                a%=MOD;

            }
        }
        update(i, a);
    }
    cout<<getsum(1);


    return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

struct UnionFind
{
    int i;
    vector<int> par;
    vector<int> size;
    UnionFind(int n): par(n),size(n,1){
        for(i = 0;i < n;++i){
            par.at(i) = i;
        }
    }
    
    int root(int x){
        if(par.at(x) == x){
            return x;
        }else{
            return par.at(x) = root(par.at(x));
        }
    }
    
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return;
        }else{
            if(size.at(rx) < size.at(ry)){
                swap(rx,ry);
            }
            par.at(ry) = rx;
            size.at(rx) += size.at(ry);
            return;
        }
    }
    
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    int get_size(int x){
        return size.at(root(x));
    }
};

int main()
{
    ll i,j;
    ll n,q;
    cin >> n >> q;
    UnionFind uf(n);
    for(i = 0;i < q;++i){
        ll com, x, y;
        cin >> com >> x >> y;
        if(com == 0){
            uf.unite(x, y);
        }else{
            cout << uf.same(x, y) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3172
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (ll& x : a) cin >> x;

  ll ans = 0;
  ll mx = 1;
  rep(i, 0, n) {
    if (a[i] < mx) continue;
    if (a[i] == mx) {
      ++mx;
      continue;
    }
    ll yoyu = a[i] - mx;
    ans += (yoyu + mx - 1) / mx;
    if (mx == 1) ++mx;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4048
N = [int(e) for e in input().split()]
nums = [int(t) for t in input().split()]
ans = 0
if(nums[-1] > N[0]//2):
    Max = (N[0]-nums[-1]) + nums[0]
    t = 0
else:
    Max = nums[-1] - nums[0]
    t = 0
for i in range(N[1]-1):
    if(nums[i+1] - nums[i])>Max:
        Max = nums[i+1] - nums[i]
        t = i
if(t==0):
    for i in range(N[1]-1):
        ans += nums[i+1] - nums[i]
else:
    for k  in range(0,t):
        ans += nums[k+1] - nums[k]
    for j in range(t+1,N[1]-1):
        ans += nums[j+1] - nums[j]
    if(nums[-1] > N[0]//2):
        ans += (N[0]-nums[-1]) + nums[0]
    else:
        ans += nums[-1] - nums[0]
print(ans)

Measured memory_bytes: 77516
function Main(input){
  input = input.split("\n")  
  var array = input[1].split(" ")
  array = array.map(e=>parseInt(e))  
  var array2=array.slice().sort((a,b)=>(a<b?-1:1))  
  var count = 0;
  array.forEach((e,i)=>{
    if(e!=array2[i])count++
  })  
  if(count==2 || count==0){
    console.log("YES")
  }else{
    console.log("NO")
  }
}

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

Measured memory_bytes: 7372
from collections import deque
N = int(input())

G = {k: [] for k in range(N)}
for i in range(N):
    S = input()
    for j in range(N):
        if S[j] == '1':
            G[i].append(j)
            G[j].append(i)


def bfs(i):
    visited = [-1 for _ in range(N)]
    visited[i] = 1
    M = 1
    que = deque([(i, -1)])

    while que:
        ci, p = que.popleft()

        for ni in G[ci]:
            if ni != p:
                if visited[ni] != -1:
                    if (visited[ci]+1-visited[ni]) % 2 == 1:
                        print(-1)
                        exit()
                else:
                    que.append((ni, ci))
                    visited[ni] = visited[ci]+1
                    M = max(M, visited[ni])

    return M


ans = 0
for i in range(N):   # start node
    ans = max(ans, bfs(i))
print(ans)


Measured memory_bytes: 74672
package main

import "fmt"

type dice struct {
	a [7]int
}

func (d *dice) init(a [6]int) {
	for i := range a {
		d.a[i+1] = a[i]
	}
}

func (d *dice) top() int {
	return d.a[1]
}

func (d *dice) front() int {
	return d.a[2]
}

func (d *dice) right() int {
	return d.a[3]
}

func (d *dice) north() {
	d.a[1], d.a[2], d.a[5], d.a[6] = d.a[2], d.a[6], d.a[1], d.a[5]
}

func (d *dice) south() {
	d.a[1], d.a[2], d.a[6], d.a[5] = d.a[5], d.a[1], d.a[2], d.a[6]
}

func (d *dice) west() {
	d.a[1], d.a[4], d.a[6], d.a[3] = d.a[3], d.a[1], d.a[4], d.a[6]
}

func (d *dice) east() {
	d.a[1], d.a[4], d.a[6], d.a[3] = d.a[4], d.a[6], d.a[3], d.a[1]
}

func (d *dice) spin() {
	d.a[4], d.a[2], d.a[3], d.a[5] = d.a[2], d.a[3], d.a[5], d.a[4]
}

func (d *dice) eq(other *dice) bool {
	for i := range d.a {
		if d.a[i] != other.a[i] {
			return false
		}
	}
	return true
}

func (d *dice) rotate(other *dice) bool {
	for i := 0; i < 2; i++ {
		for j := 0; j < 4; j++ {
			for k := 0; k < 4; k++ {
				if d.eq(other) {
					return true
				}
				d.spin()
			}
			d.north()
		}
		d.east()
	}
	return false
}

func main() {
	var a [6]int
	for i := range a {
		fmt.Scan(&a[i])
	}
	var d1 dice
	d1.init(a)

	var b [6]int
	for i := range b {
		fmt.Scan(&b[i])
	}
	var d2 dice
	d2.init(b)

	if d1.rotate(&d2) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <bitset>
#include <cmath>

std::bitset<100000000> array(0);
auto eratosthenes(long long int n)
 -> void{
	for(long long int i = 0; i < n;i++){
		array[i] = 1;
	}
	array[0] = 0;
	array[1] = 0;
	for(long long int i = 2; i <= sqrt(n);i++){
		if(array[i]){
			for(long long int j = 0;i*(j+2) <= n;j++){
				array[i*(j+2)] = 0;
			}
		}
	}
}

auto main()
 -> int{

	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);

	long long int n, a, Max = 0, result = 0;

	std::cin>>n;
	std::vector<int> A(n);
	for(auto &a : A){
		std::cin>> a;
		if(Max < a){
			Max = a;
		}
	}

	eratosthenes(Max+1);

	for(auto a : A){
		if(array[a]){
			result++;
		}
	}
	std::cout<<result<<"\n";
	return 0;
}

Measured memory_bytes: 13452
#include <iostream>
using namespace std;
bool prime[1000000];
void sieve() {
    fill_n(prime, 1000000, true);
    for (int i=2; i<=1000; ++i) {
        if (prime[i]) {
            for (int j=i*i; j<1000000; j+=i) {
                prime[j] = false;
            }
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    sieve();
    int n;
    while (cin >> n) {
        int cnt = 0;
        for (int i=2; i<=n; ++i) {
            if (prime[i]) {
                cnt ++;
            }
        }
        cout << cnt << "\n";
    }
    return 0;
}

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    string s;cin>>s;
    ll n=s.size();
    ll ans=INF;
    rep(i,n-2){
        ll sum=0;
        if(i+2<n){
            sum = 100 * (ll)(s[i] - '0') + 10 * (ll)(s[i + 1] - '0') + (ll)(s[i + 2] - '0');
        }
        chmin(ans,abs(sum-753));
    }

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

Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
	int A, B, C, X;
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &X);
	X /= 50;
	long output = 0;
	//10a+2b+c=X,a<=A,b<=B,c<=Cとなるような組の数
	//Cでしか支払えない場合
	if (X % 2 == 1){
		X -= 1;
		C--;
	}
	/*if (C < 0){
		goto END;
	}*/

	int num = X;
	for (int a = 0; a <= A; a++){		
		for (int b = 0; b <= B; b++){
			X = num - a * 10-b*2;
			if (X>=0 && X <= C)output++;
		}
	}

	END:
	printf("%ld\n", output);
	return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a>12){
    cout << b << endl;
  }else if(a>5){
    cout << b/2 << endl;
  }else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <limits>

int main() {

    int64_t N, M;
    std::cin >> N >> M;
 
    std::string str;
    switch (N) {
    case 1: str = "a"; break;
    case 2: str = "aa"; break;
    case 3: str = "aaa"; break;
    }
 
    for (int64_t i = 0; i < M; ++i) {
        int64_t s;
        char c;
        std::cin >> s >> c;
        s--;
 
        if (N != 1 && s == 0 && c == '0') {
            std::cout << -1 << std::endl;
            return 0;
        }

        if (str.at(s) != 'a' && str.at(s) != c) {
            std::cout << -1 << std::endl;
            return 0;
        }
 
        if (str.at(s) > c) {
            str.at(s) = c;
        }
    }
 
    for (int64_t i = 0; i < N; ++i) {
        if (N != 1 && i == 0 && str.at(0) == 'a') {
            str.at(0) = '1';
        }
        if (str.at(i) == 'a') {
            str.at(i) = '0';
        }
    }
 
    std::cout << std::atoi(str.c_str()) << std::endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+50;
int n,vis[maxn];
void init()
{
    memset(vis,0,sizeof vis);
    vis[1]=1;
    for(int i=2;i<=n;++i)
    {
        for(int j=2;j*i<maxn;++j)
        {
            vis[i*j]++;
        }
    }
}
int main()
{
    cin>>n;
    init();
    int sum=0;
    //for(int i=1;i<=10;++i) cout<<vis[i]<<endl;
    for(int i=1;i<n;++i)
    {
        sum+=vis[i]+2;
    }
    cout<<sum-2<<endl;
    return 0;
}

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

#define ll long long
#define endl '\n'

void max_self(int &a, int b){ a = max(a, b);}
void min_self(int &a, int b){ a = min(a, b);}

const int maxn = 100005;
vector< int > par(maxn), cnt(maxn), sze(maxn), chld(maxn);

int find(int a){
	if(a == par[a]) return a;
	return par[a] = find(par[a]);
}

void merge(int a, int b){
	a = find(a), b = find(b);
	if(a == b) return;

	if(sze[a] < sze[b]) swap(a, b);
	par[b] = a;
	sze[a] += sze[b];
}

void solve(){
	int n, m, k; cin>>n>>m>>k;
	for(int i = 1; i<=n; i++){
		par[i] = i;
		sze[i] = 1;
		cnt[i] = 0;
		chld[i] = 0;
	}
	for(int i = 0; i<m; i++){
		int a, b; cin>>a>>b;
		merge(a, b);
		chld[a]++;
		chld[b]++;
	}
	for(int i = 0; i<k; i++){
		int c, d; cin>>c>>d;
		if(find(c) == find(d)){
			cnt[c]++;
			cnt[d]++;
		}
	}
	for(int i = 1; i<=n; i++){
		int x = i; x = find(x);
		cout<<(sze[x] - chld[i] - cnt[i] - 1)<<endl;
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	for(int i = 1; i<=t; i++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 4556
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
#define v(T) vector<T>
#define vv(T) vector<v(T)>
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
const int N = 10050;

vi bfs(int s, int n, vvi g){
    vi dist(n), p(n, -1);
    queue<int> q;
    dist[s] = 0;
    q.push(s);

    while (not q.empty())
    {
        int v = q.front();q.pop();
        for (int nv : g[v]){
            if (p[v] == nv) continue;
            p[nv] = v;
            dist[nv] = dist[v]+1;
            q.push(nv);
        }
    }
    return dist;
}

int main()
{
    int n, u, v;
    cin >> n >> u >> v;
    u--;v--;
    vvi g(n);
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vi a = bfs(u, n, g);
    vi b = bfs(v, n, g);
    int ans = 0;
    rep(i, n){
        if (a[i]<b[i]) ans = max(ans, b[i]);
    }
    ans--;
    cout << ans << endl;
}

Measured memory_bytes: 15404
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x, jumlah=0, maks=-9999999999	;
	cin >> x;
	int h[x+1];
	h[0]=0;
	for(int i=1;i<=x;i++){
		cin >> h[i];
		if(maks<=h[i]){
			maks=h[i];
		}
		if(maks<=h[i]){
			jumlah++;
		}
	}
	cout << jumlah << endl;
}

Measured memory_bytes: 256
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

n = gif
a = gi
size = a.size
num4 = a.select{|aa| aa % 4 == 0}.size
num  = a.select{|aa| aa % 2 != 0}.size
num2 = a.select{|aa| aa % 2 == 0 && aa/2 % 2 != 0 }.size
ans = num4 - num
if num2 == 0
  puts ans >= -1 ? "Yes" : "No"
else
  puts ans >= 0 ? "Yes" : "No"
end


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


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

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

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,k,sum=0;
    c_p_c();
    cin>>n>>m;
    string s[n];
    for (int i = 0; i < n; ++i)
    {
    	/* code */
    	cin>>s[i];
    }


    // cout<
    for (int i = 0; i < m+2; ++i)
    {
    	/* code */
    	cout<<"#";
    }
    cout<<endl;
    for (int i = 0; i < n; ++i)
    {
    	/* code */
    	cout<<'#';
    	cout<<s[i];
    	cout<<'#'<<endl;

    }
        for (int i = 0; i < m+2; ++i)
    {
    	/* code */
    	cout<<"#";
    }
  	
 	return 0;

   }

Measured memory_bytes: 3644
#import random
import numpy as np
def main():
  d=int(input())
  c=np.array(list(map(int,input().split())))
  s=[None]*d
  r0=[None]*d
  r1=[None]*d
  cm=np.array([0]*26)
  cd=np.array([0]*26)
#t=[None]*d
  for i in range(d):
    s[i]=list(map(int,input().split()))
  s=np.array(s)
#for i in range(d):
#  t[i]=int(input())-1
  for j in range(d):  
    #rand = np.random.randint(26, size = 10) 
    #print(np.argmax(s[j])+1)
    r_i=np.argmax(s[j])
    cd=c*cm
    if np.max(cd>s[i][r_i]):
      r_i=np.argmax(cd)
    r0[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
    
  score0=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  for j in range(d):
    r0_j=r0[j]
    score0+=s[j][r0_j]
    for k in range(26):
      cm[k]+=1
      cm[r0_j]=0
    cd=c*cm
    score0+=-np.sum(cd)
  #r_i+=1
  #print(r_i)
  """
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  rand = np.random.randint(100, size = d) 
  for j in range(d):  
    #print(np.argmax(s[j])+1)
    r_i=r0[j]
    cd=c*cm
    if rand[j]>80:
      r_i=np.argmax(cd)
    r1[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
#r0=t
  """
    
  testc=(90,80,85,75,70,65,60,55,50,45,40,35,30,25,20,15,99,98,97,96,95,94,93,92,91)
  for l in testc:
    cm=np.array([0]*26)
    cd=np.array([0]*26)  
    rand = np.random.randint(100, size = d) 
    for j in range(d):  
    #print(np.argmax(s[j])+1)
      r_i=r0[j]
      cd=c*cm
      if rand[j]>l:
        r_i=np.argmax(cd)
      r1[j]=r_i
      for k in range(26):
        cm[k]+=1
      cm[r_i]=0
      
    score1=0
    cm=np.array([0]*26)
    cd=np.array([0]*26)  
    for j in range(d):
      r0_j=r1[j]
        #print(score1)
      score1+=s[j][r0_j]
      for k in range(26):
        cm[k]+=1
        cm[r0_j]=0
      cd=c*cm
      #print(cm)
      score1+=-np.sum(cd)
      #print(score0)
      #print(score1)
    if score1>score0:
      r0=r1
      score0=score1
    
  
  for j in range(d):  
    print(r0[j]+1) 
 
main()

Measured memory_bytes: 27568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int a,b; cin>>a>>b;
    cout<<(a+b)%24<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//useful 
#define rep(i,n) for(int i = 0; i < (n); i++)
int long long gcd(int long long a, int long long b){
    return b?gcd(b,a%b):a;
} //最大公約数
int long long lcm(int long long a, int long long b){
    return a/gcd(a,b)*b;
} //最小公倍数
int long long GetDigit(int long long num){
    int long long digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
} //桁数
int long long GetDigitN(int long long num, int long long N){
    int long long digit=0;
    while(num!=0){
        num /= N;
        digit++;
    }
    return digit;
} //十進数でnumの際のN進数における桁数

int main(){
    char C;
    cin >> C;
    if(isupper(C)){
        cout << 'A' << endl;
    }
    else{
        cout << 'a' << endl;
    }
    return 0;
}

Measured memory_bytes: 3588
a = input()
b = input()

if len(a) > len(b):
	print('GREATER')
elif  len(a) < len(b):
	print('LESS')
elif a == b:
	print('EQUAL')
else:
	for i in range(len(a)):
		if int(a[i]) < int(b[i]):
			print('LESS')
			break
		elif int(a[i]) > int(b[i]):
			print('GREATER')
			break
		

Measured memory_bytes: 2940
from fractions import gcd
def lcm(a,b):
    return a*b/gcd(a,b)
def f(a,m):
        i, b = 1, a%m
        while b!=1:
            b = (a*b)%m
            i += 1
        return i
while True:
    tmp = map(int, raw_input().split(" "))
    if not tmp[1]:
        break
    print reduce(lcm,map(f,tmp[::2],tmp[1::2]))

Measured memory_bytes: 5900
N, M = map(int,input().split())
list_L = []
list_R = []
for i in range(M):
    L, R = map(int,input().split())
    list_L.append(L)
    list_R.append(R)
print(min(list_R)-max(list_L)+1 if min(list_R)>=max(list_L) else 0)

Measured memory_bytes: 10996
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int n,x;
  cin >> n;
  for(int i = 1; i <= n; i++){
    if(i % 3 == 0){
      cout << " " << i;
    }else{
      if(i % 10 == 3){
        cout << " " << i;
      }else{
        x = i;
        while(x /= 10){
          if(x % 10 == 3){
            cout << " " << i;
            break;
          }
        }
      }
    }
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vb=vector<bool>;
using pii=pair<int,int>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    vi conne[n];
    rep(i,0,n){
        int id;cin>>id;
        id--;
        int r; cin>>r;
        rep(j,0,r){
            int in; cin>>in; in--;
            conne[id].push_back(in);
        }
    }
    vi dist(n,-1);
    queue<pii> q;
    q.emplace(0,0);
    while(!q.empty()){
        pii n=q.front(); q.pop();
        int i=n.first; int d=n.second;
        if(dist[i]==-1)dist[i]=d;
        for(int itr:conne[i]){
            if(dist[itr]!=-1)continue;
            q.emplace(itr,d+1);
        }
    }
    rep(i,0,n)cout<<i+1<<" "<<dist[i]<<endl;
    return 0;
}





Measured memory_bytes: 3436
#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() {
  int n;
  cin >> n;
  vector<ll> a(n+1,0);
  ll ans=100100100100100;
  a[0]=0;
  for(int i=1; i<=n; i++) {
    int x;
    cin >> x;
    a[i]=a[i-1]+x;
  }
  for(int i=1; i<n; i++) {
    ans = min(ans,abs(a[n]-2*a[i]));
  }

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

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
	int n; cin >> n;
	vector<int> h(n);
	for(int i = 0; i < n; ++i){
		cin >> h[i];
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
		int j = i+1;
		for(; j < n; ++j){
			if(h[j-1]<h[j]){break;}
        }
        ans = max(ans, j-i-1);
        i = j-1;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>

typedef long long int64;

int main(void) {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> hs;
  for (int i = 0; i < n; i++) {
    int h;
    std::cin >> h;
    hs.push_back(h);
  }
  int cnt = 0;
  for (auto h : hs) {
    if (h >= k) cnt++;
  }
  std::cout << cnt << std::endl;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

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

  int A[5];
  int sum = 0;
  rep(i, 5) {
    in(A[i]);
    sum += A[i] / 10;
    A[i] %= 10;
  }
  sum *= 10;
  sort(A, A+5);
  bool first = true;
  rep(i, 5) {
    if (A[i] == 0)
      continue;
    if (first)
      sum += A[i];
    else
      sum += 10;
    first = false;
  }
  out(sum);

  return 0;
}


Measured memory_bytes: 256