akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 10005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
char s[55];
int t[30],a[30];
void Solve() {
    read(N);
    for(int i = 0 ; i < 26 ; ++i) a[i] = 50;
    for(int i = 1 ; i <= N ; ++i) {
	scanf("%s",s + 1);
	int l = strlen(s + 1);
	memset(t,0,sizeof(t));
	for(int j = 1 ; j <= l ; ++j) t[s[j] - 'a']++;
	for(int j = 0 ; j < 26 ; ++j) a[j] = min(a[j],t[j]);
    }
    for(int i = 0 ; i < 26 ; ++i) {
	for(int j = 1 ; j <= a[i] ; ++j) {
	    putchar('a' + i);
	}
    }
    enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


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

using namespace std;

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

  long long n, m;
  cin >> n >> m;
  if (2*n > m) {
    cout << m/2 << endl;
  } else {
    cout << n + (m-2*n)/4 << endl;
  }

  return 0;
}



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

int main(){
	long long s,cou=1;
	cin>>s;
	if(s==4||s==2||s==1){
		cout<<4<<endl;
		return 0;
	}
	while(s!=4){
		if(s%2==0){
			s/=2;
		}else{
			s=s*3+1;
		}
		cou++;
	}
	cout<<cou+3<<endl;
	return 0;
}

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

using namespace std;

typedef long long int64;

void solve()
{
  int N, M, A[100000];

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

  vector< int > latte[100000], malta[100000];
  int64 beet[100000] = {}, common[100000] = {};

  int64 ret = 0;
  for(int i = 1; i < N; i++) {
    int right = (A[i] - A[i - 1] + M) % M;

    ret += right;
    int small = right;
    int range = small - 1;
    if(range > 0) {
      malta[A[i]].push_back(range);
    }
  }

  priority_queue< int, vector< int >, greater< int > > que;
  int64 sum = 0;
  int64 base = 0;


  base = sum = 0;
  for(int i = M - 1; i >= -M; i--) {
    while(!que.empty() && base == que.top()) que.pop();
    if(i >= 0) for(auto &p : malta[i]) que.emplace(p + base), sum += p;
    beet[(i + M) % M] += sum;
    sum -= que.size();
    ++base;
  }
  int64 sum2 = 1LL << 58;

  for(int i = 0; i < M; i++) {
    sum2 = min(sum2, ret - beet[i] + common[i]);
  }

  cout << sum2 << endl;
}

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

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

int main(){
    int a,b; 
    cin >> a >> b;
    if(b == 1) 
    cout<<0;
    else if(a >= b)
    {
        cout << 1 << endl;
    } 
  	else {
        cout << ((b - a) % (a -1) ? 1 :0 ) + (b-a)/(a-1) + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; cin >> N;
  vector<int> A(N); REP(i, N) cin >> A[i];

  ll ans = 0;
  for (int i = 0; i < N; ++i) {
    ll c = A[i]/2;
    A[i] -= 2*c;
    ans += c;

    if (i != N-1 && A[i] >= 1 && A[i+1] >= 1) {
      ll c = min(A[i], A[i+1]);
      A[i] -= c;
      A[i+1] -= c;
      ans += c;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  int key;
  struct node *r;
  struct node *l;
  struct node *p;
};
typedef struct node *Node;
Node root;

void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;
  z=malloc(sizeof(struct node));
  z->key=k;
  z->l=NIL;
  z->r=NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->l;
    }else {
      x=x->r;
    }
  }
  z->p=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key<y->key){
      y->l=z;
    }else{
      y->r=z;
    }
  }
}

void inoder(Node u){
  if(u==NIL)return;
  inoder(u->l);
  printf(" %d",u->key);
  inoder(u->r);
}
void preoder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preoder(u->l);
  preoder(u->r);
}

int main(){
  int n,i,x;
  char com[20];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }else if(com[0]=='p'){
      inoder(root);
      printf("\n");
      preoder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25220
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 200010
vector<ll> g[55];
ll n,m,a[55],b[55];
ll dist[55][55];
void dfs(ll x,ll root,ll par,ll di){
    dist[root][x]=di;
    for(auto y:g[x])if(y!=par){
	dfs(y,root,x,di+1);
    }
}
ll v[55];
ll dp[(1<<20)];
int main(){
    cin>>n;
    rep(i,n-1){
	cin>>a[i]>>b[i]; a[i]--,b[i]--;
	g[a[i]].push_back(b[i]);
	g[b[i]].push_back(a[i]);
    }
    rep(i,n)dfs(i,i,-1,0);
    rep(i,n)v[i]=0;
    cin>>m;
    rep(i,m){
	ll s,t; cin>>s>>t; s--,t--;
	rep(j,n-1){
	    if(dist[s][a[j]]+dist[a[j]][t]==dist[s][t]&&dist[s][b[j]]+dist[b[j]][t]==dist[s][t]){
		v[j]+=(1LL<<i);
	    }
	}
    }
    rep(i,(i<<m))dp[i]=0;
    dp[0]=1;
    rep(i,n-1)for(int j=(1<<m)-1;j>=0;j--){
	dp[j|v[i]]+=dp[j];
    }
    cout<<dp[(1<<m)-1]<<endl;
}




Measured memory_bytes: 8448
use std::io;

fn oneline() -> String {
    let mut st = String::new();
    match io::stdin().read_line(&mut st) {
        Ok(_) => st,
        Err(_) => "".to_string(),
    }
}

fn main() {
    let line = oneline();
    let x = line.split_whitespace().nth(0).unwrap().parse::<i64>().unwrap();
    let y = line.split_whitespace().nth(1).unwrap().parse::<i64>().unwrap();

    let ans = if x * y < 0 {
        (x + y).abs() + 1
    }
    else if x < y {
        y - x
    }
    else if x * y == 0 {
        (x + y).abs() + 1
    }
    else {
        (x - y).abs() + 2
    };

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


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = a*c;
  ans = max(ans,a*d);
  ans = max(ans,b*c);
  ans = max(ans,b*d);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include<math.h>
int fact(int x);

int main()

{
  int n,m,sum,even,odd;
scanf("%d %d",&n,&m);
even=fact(n)/2;
odd=fact(m)/2;
   sum=even+odd;
   printf("%d",sum);
}
int fact(int x){
int c=1;
if(x==0){
   return c;}
    else{
        for(int i=x;i>x-2;i--){
         c=c*i;
        }
    }
        return (c);
}

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

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

	std::vector<int> X(N);
	for(int i = 0; i < N; i++) {
		std::cin >> X[i];
	}

	std::vector<int> sortedX = X;
	std::sort(sortedX.begin(), sortedX.end());

	int median2x = (sortedX[N / 2 - 1] + sortedX[N / 2]);
	int medianLeft = sortedX[N / 2 - 1];
	int medianRight = sortedX[N / 2];

	for(int i = 0; i < N; i++) {
		int B;
		if(X[i] * 2 > median2x) {
			B = medianLeft;
		} else {
			B = medianRight;
		}
		printf("%d\n", B);
	}

	return 0;
}

Measured memory_bytes: 3712
#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 d, t, s;
  cin >> d >> t >> s;
  if (s * t >= d) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0; 
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

int main(){
	int n; cin >> n;
	map<string, int> a;
	rep(i,n){
		string s; cin >> s;
		a[s] ++;
	}
	int mx = 0;
	for(auto p:a) mx = max(mx, p.second);
	for(auto p:a){
		if(p.second==mx) cout << p.first << endl;
	}

}

Measured memory_bytes: 25216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		int n=s.length();
		int l=(n-1)/2;
		int r=n/2;
		char c=s.charAt(l);
		while(0<=l) {
			if(s.charAt(l)==c&&s.charAt(r)==c) {
				l--;r++;
			}
			else {
				break;
			}
		}
		System.out.println(r);
		}
	}


Measured memory_bytes: 24776
#include <stdio.h>

int search(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while(A[i] != key) i++;
    return i != n;
}

int main(){
    int i, n, A[10000+1], q, key, sum = 0;
    scanf("%d", &n);
    for(i=0; i<n; i++) scanf("%d",&A[i]);

    scanf("%d",&q);
    for(i = 0; i<q; ++i) {
        scanf("%d", &key);
        if(search(A, n, key)) sum++;
    }

    printf("%d\n",sum);

    return 0;    
    
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
 vector<int> primes;
bool prime[1000001];
int till[1000001];
  void sieve(){
    for(int i=2;i<1e6+1;i++)
        prime[i]=true;
        int cnt=0;
    prime[0]=prime[1]=false;
for(int i=2;i*i<1e6+1;i++)
{
    for(int j=2*i;j<1e6+1;j+=i)
    {
        prime[j]=false;

    }
}
    }
    int main()
    {
        sieve();
        int x;
        cin>>x;
        for(int i=x;i<=1000000;i++)
        {
            if(prime[i])
            {cout<<i<<e;
            break;}
        }
    }


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

class Cube{
public:
 int f[6];
 Cube(){}
 void roll_z(){roll(1,2,4,3);} //
 void roll_y(){roll(0,2,5,3);} // to W
 void roll_x(){roll(0,1,5,4);} // to N
 void roll(int i, int j, int k, int l){
  int t=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
 }
};

int getRight(Cube c1, int f1, int f2){
 for(int i=0; i<6; i++){
  for(int j=0; j<4; j++){
   if(c1.f[0]==f1 && c1.f[1]==f2) return c1.f[2];
   c1.roll_z();
  }
  if(i%2==0) c1.roll_y();
  else c1.roll_x();
 }
 return -1;
}

int main(){
 Cube c;
 int f1, f2;
 for(int i=0; i<6; i++) cin >> c.f[i];
 int q; cin >> q;
 for(int i=0; i<q; i++){
  cin >> f1 >> f2;
  cout << getRight(c, f1, f2) << endl;
 }
 return 0;
}
 


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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(M);
    vector<int> A(N + 1, 0);
    REP(i, N){scanf("%d", &(A[i + 1])); getchar();}
    vector<int> ssum(N + 1, 0);
    for (int i = 1; i <= N; ++i){
        ssum[i] = (A[i] % M + ssum[i - 1]) % M; 
    }
    unordered_map<int, ll> count;
    for (auto& ai : ssum){
        count[ai]++;
    }
    ll result = 0;
    for (auto& e : count){
        // cout << e.first << ": " << e.second << endl;
        result += (e.second * (e.second - 1) / 2);
    }
    cout << result << endl;
}

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

int bfs(vector< vector<int> > &adj ,int s,int cnt)
{
	int max=-1;
	queue<int> q;
	vector<bool> used(cnt);
	vector<int> d(cnt),p(cnt);
	
	q.push(s);
	used[s]=true;
	d[s]=0;
	p[s]=-1;
	
	while(!q.empty())
	{
		int v=q.front();
		q.pop();
		for(int u: adj[v])
		{
			if(!used[u])
			{
				used[u]=true;
				q.push(u);
				d[u]=d[v]+1;
				p[u]=v;
				
				if(d[u]>max)
					max=d[u];
			}
		}
	}
	return max;
}


int main()
{
	int n,i,j,k,h,w,cnt=1;
	cin>>h>>w;
	
	char arr[h][w];
	int nadj[h][w];
	memset(nadj,-1,sizeof(nadj));
//	vector< vector<int> > adj
	
	for(i=0;i<h;i++)
		for(j=0;j<w;j++)
			cin>>arr[i][j];
			
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(arr[i][j]=='.')
			{
				nadj[i][j]=cnt;
				++cnt;
			}
				
		}
	}		
	vector< vector<int> > adj(cnt);
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(nadj[i][j]!=-1)
			{
				if(nadj[i-1][j]!=-1 && i!=0) adj[nadj[i][j]].push_back(nadj[i-1][j]);
				if(nadj[i+1][j]!=-1 && i<h-1) adj[nadj[i][j]].push_back(nadj[i+1][j]);
				if(nadj[i][j+1]!=-1 && j<w-1) adj[nadj[i][j]].push_back(nadj[i][j+1]);
				if(nadj[i][j-1]!=-1 && j!=0) adj[nadj[i][j]].push_back(nadj[i][j-1]);
				
			}
		}
	}
	
	int ans=0;
	for(i=1;i<cnt;i++)
		ans=max(ans,bfs(adj,i,cnt));
	
	cout<<ans<<endl;
}

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

int main(){
	int H,W;
	while(1){
		cin >> H >> W;
		if(H == 0 && W == 0)break;
		for(int i = 1;i <= H;i++){
			for(int j = 1;j <= W;j++){
				if((i+j)%2 == 0)cout << "#";
				else{cout << ".";}
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}

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

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

    string T = S;
    while(T != ""){
        bool check = false;
        if(T.size() >= 5 && T.substr(T.size() - 5) == "dream"){
            T = T.substr(0, T.size() - 5);
            check = true;
        }
        if(T.size() >= 7 && T.substr(T.size() - 7) == "dreamer"){
            T = T.substr(0, T.size() - 7);
            check = true;
        }
        if(T.size() >= 5 && T.substr(T.size() - 5) == "erase"){
            T = T.substr(0, T.size() - 5);
            check = true;
        }
        if(T.size() >= 6 && T.substr(T.size() - 6) == "eraser"){
            T = T.substr(0, T.size() - 6);
            check = true;
        }
        if(!check){
            break;
        }
    }
    cout << (T == "" ? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

class UnionFind {
public:
	vector<int> par;
  vector<int> rank;
  vector<int> size;
 
	UnionFind(int n){
		rep(i,n){
      par.push_back(i);
      rank.push_back(0);
      size.push_back(1);
    }
	}
 
	int find(int x) {
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
            size[y]+=size[x];
        }else{
            par[y]=x;
            size[x]+=size[y];
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  vector<vector<int>> cnt(m),g(n);
  rep(i,n){
    int k;
    cin>>k;
    rep(j,k){
      int l;
      cin>>l;
      l--;
      cnt[l].push_back(i);
    }
  }
  UnionFind uf(n);
  rep(i,m){
    int now=-1;
    for(auto itr:cnt[i]){
      if(now<0) now=itr;
      else{
        uf.unite(now,itr);
      }
    }
  }
  if(uf.size[uf.find(1)]==n) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 6904
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
int m,d;
int main() {
	read(m);read(d);int res=0;
	rep(i,1,m)rep(j,1,d){
		int x=j%10,y=j/10;
		res+=x>=2&&y>=2&&x*y==i;
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        String s1 = s.substring(0,(n-1)/2);
        String s2 = s.substring(((n+3)/2)-1,n);
        if(checkPalindrome(s) && checkPalindrome(s1) && checkPalindrome(s2)){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
    private static boolean checkPalindrome(String s){
        int left = 0;
        int right = s.length()-1;
        while (left<=right){
            if(s.charAt(left) == s.charAt(right)){
                left++;
                right--;
                continue;
            }
            return false;
        }
        return true;
    }
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	set<int> s;
	int extra = 0;
	for (int i = 0; i < N; i++) {
		int v; cin >> v;
		if (v < 3200) {
			s.insert(v / 400);
		} else {
			extra ++;
		}
	}
	cout << max(1, int(s.size())) << ' ' << int(s.size()) + extra << '\n';

	return 0;
}


Measured memory_bytes: 256
def parse(s):
    res = []

    p, f = 0, False
    while p != len(s):
        if f and s[p] == "R":
            res.append(s[:p])
            s = s[p:]
            p, f = 0, False
        elif s[p] == "L":
            f = True

        p += 1

    res.append(s)

    return res



S = input()
parts = parse(S)

for part in parts:
    p = part.index("L")
    n = len(part)

    l = p
    r = n - p

    ln = l // 2 + r // 2 + (l % 2)
    rn = l // 2 + r // 2 + (r % 2)

    for _ in range(l - 1):
        print("0 ", end="")
    print("{} {} ".format(ln, rn), end="")
    for _ in range(r - 1):
        print("0 ", end="")

Measured memory_bytes: 6856
s = input()
li = [-1,1]
a = '+'
b = '+'
c = '+'
for i in li:
	for j in li:
		for k in li:
			if int(s[0])+(i*int(s[1]))+(j*int(s[2]))+(k*int(s[3])) == 7:
				if i == -1:
					a = '-'
				if j == -1:
					b = '-'
				if k == -1:
					c = '-'
				print(s[0] + a + s[1] + b + s[2] + c + s[3] + '=7')
				break
		else:
			continue
		break
	else:
		continue
	break

Measured memory_bytes: 3064
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

from decimal import Decimal
a,b = input().split()
a = int(a)
b = Decimal(b)
b = int(100*b)
print(a*b//100)


Measured memory_bytes: 71436
#include<iostream>
#include<algorithm>

using namespace std;

int a[10];

int main(){
  for(int i=0;i<10;i++){
    cin>>a[i];
  }
  sort(a,a+10);
  cout<<a[9]<<'\n'<<a[8]<<'\n'<<a[7]<<'\n';
  return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(a) -- no. of elements strictly less than a
// s.find_by_order(i) -- itertor to ith element (0 indexed)
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll a,b,c,d;
ll ans;
ll cc;
map<ll,ll>m1[10];
ll findans(ll n){
    if(n==0)return 0;
    if(m1[t][n]>0)return m1[t][n];
    ll val=2e18;
    if(n<=2e9)val=min(val, d*n);
    for(ll temp=n-4;temp<=n+4;temp++){
        if(temp<0)continue;
        if(temp%2==0 && temp/2<n){
            val= min(val ,a+ abs(temp-n)*d+ findans(temp/2) );
        }
        if(temp%3==0 && temp/3 < n)val= min(val, b+ abs(temp-n)*d+ findans(temp/3));
        if(temp%5==0 && temp/5<n)val=min(val,c+ abs(temp-n)*d +findans(temp/5) );

    }
    m1[t][n]=val;
    cc++;
    return val;
    cc++;

}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef NOOBxCODER
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    #define NOOBxCODER 0
    #endif
    cin>>t;
    //t=1;
    while(t--){
        cin>>n>>a>>b>>c>>d;
        cout<<findans(n)<<endl;
        //cout<<cc;





        
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 26924
H, W = gets.chomp.split.map(&:to_i)
a = H.times.map{gets.chomp.chars}

a.reject{|line| line.all?{|i| i == "."}}
2.times{a = a.reject{|line| line.all?{|i| i == "."}}.transpose}
puts a.map(&:join)

Measured memory_bytes: 2684
#include <iostream>
#include <string>
#include<vector>
using namespace std;
int main() {
	long long int sum = 0;
	long int n;
	cin >> n;
	for (long int i = n; i > 0; i--) {
		if (i % 3!= 0 && i%5) {
			sum += i;
		}
	}
	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

#define mem(dp,a)       memset(dp,a,sizeof dp)
#define ninja           ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb(x)           push_back(x)
#define all(c)          c.begin(), c.end()
#define int             long long
#define ff              first
#define ss              second
#define nl              '\n'

int32_t main()
{
	ninja
	int n; cin>>n;
	unordered_map<int, int> mp;
	int x;
	int res=0;
	for(int i=1;i<=n;i++){
		cin>>x;
		res += mp[i-x];
		mp[i+x]++;
	}
	cout<<res;
}



Measured memory_bytes: 18416
A,B,C,K = map(int,input().split())

S = int()

if K >= A:
    S = S + A
    K = K - A

    if K >= B:
        K = K - B

        if K > 0:
            S = S - K
            print(S)
        else:
            print(S)

    else:
        print(S)

else:
    S = S + K
    print(S)

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

int main(void){

  int a,b;
  
  while(cin >> a >> b){
    if(a == 0 && b == 0) break;
    if(a >= b) cout << b << " " << a << endl;
    else cout << a << " " << b << endl;
  }
  
  return 0;
}

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

ll modpow(ll a, ll n, int mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll mod(ll val, ll m) {
  ll res = val % m;
  if (res < 0) res += m;
  return res;
}

ll popcnt(ll n) {
  ll c;
  c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555);
  c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333);
  c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f);
  c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff);
  c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff);
  c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff);
  return c;
}

int main() {
  ll n; string X;
  cin >> n >> X;
  vector<int> x(n);
  int s = 0;
  rep(i,0,n) {
    x[i] = stoi(X.substr(i,1));
    if (x[i] == 1) s++;
  }
  ll a = 0, b = 0;
  rep(i,0,n) {
    if (x[i] == 0) continue;
    a += modpow(2,n-i-1,s+1);
    a %= s+1;
    if (s == 1) continue;
    b += modpow(2,n-i-1,s-1);
    b %= s-1;
  }
  rep(i,0,n) {
    int cnt = 1;
    int p = 0;
    if (x[i] == 0) {
      p = (a + modpow(2,n-i-1,s+1)) % (s+1);
    } else {
      if (s == 1) {
        cout << 0 << endl;
        continue;
      } 
      p = mod(b - modpow(2,n-i-1,s-1), s-1);
    }
    while (p > 0) {
      p %= popcnt(p);
      cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 4460
#include<stdio.h>
int main(void){

    char pic;
    char ch;
    int n;
    int students[4][3][10]={{{0}}};
    //     [b棟][f階][r番目]にnum人入るor出る
    scanf("%d",&n);//入力データ数n
    
    for (int i = 0; i < n; i++){
        int b,f,r,num;
        scanf("%c",&ch);
        scanf("%d %d %d %d",&b,&f,&r,&num);
        students[b-1][f-1][r-1]+=num;
    }
    for (int b = 0; b <4 ; b++)
    {
        for (int f = 0; f < 3; f++)
        {   
            for (int  r = 0; r <10 ; r++)
            {
                printf(" %d",students[b][f][r]);
            }
        printf("\n");
        }
        if(b!=3)printf("####################\n");
    }
        

    return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
long long n,m,l,i,j,k,x[100005],a,b,c,A,B,C,bz[35][3][3]={{{1,0,1},{1,1,1},{1,2,2}}};
void jzksm(long long v){
	for(l=0;l<=29;l++)
		if(v&(1<<l)){
			a=(A*bz[l][0][0]+B*bz[l][0][1]+C*bz[l][0][2])%mo;
			b=(A*bz[l][1][0]+B*bz[l][1][1]+C*bz[l][1][2])%mo;
			c=(A*bz[l][2][0]+B*bz[l][2][1]+C*bz[l][2][2])%mo;
			A=a;
			B=b;
			C=c;
		}
}
int main(){
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=m;i++)
		scanf("%lld",&x[i]);
	A=1;
	for(l=1;l<=29;l++)
		for(i=0;i<=2;i++)
			for(j=0;j<=2;j++)
				for(k=0;k<=2;k++)
					bz[l][i][j]=(bz[l][i][j]+bz[l-1][i][k]*bz[l-1][k][j])%mo;
	x[0]=-1;
	for(i=1;i<=m;i++){
		jzksm(x[i]-x[i-1]-1);
		C=(C+B*2+A)%mo;
		B=(B+A)%mo;
	}
	jzksm(n-x[m]-1);
	printf("%lld\n",C);
	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}


int main() {
    int N; cin >> N;
    vector<ll> p(N); REP(i, N) cin >> p[i];

    int cnt = 0;
    REP(i, N - 1) {
        if(i + 1 == p[i]) {
            swap(p[i], p[i + 1]);
            cnt++;
        }

        if(i == N - 2) {
            if(i + 2 == p[i + 1]) {
                swap(p[i], p[i + 1]);
                cnt++;
            }
        }
        /*
        REP(k, N) {
            cout << p[k] << " ";
        }
        cout << endl; */
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int Solve(int n) {
  int result = 0;
  for (int div = 2; div <= n; div++) {
    if (div % 2 == 1) {
      if (n % div == 0) {
        int median = n / div;
        if (median - (div / 2) >= 1) {
          // cerr << div << endl;
          result++;
        }
      }
    } else {
      if (n % div == div / 2) {
        int median = n / div;
        if (median - (div / 2 - 1) >= 1) {
          // cerr << div << endl;
          result++;
        }
      }
    }
  }
  return result;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  while (1) {
    int n;
    cin >> n;
    if (n == 0) break;
    cout << Solve(n) << endl;
  }

  return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define in1(n) cin >> n;
#define in2(n, k) cin >> n >> k;
#define in3(n, k, s) cin >> n >> k >> s;
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (int i = j; i < k; i += in)
#define rloop(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define inar(n, a) \
    rep(i, n)      \
            cin >> \
        a[i];
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
    return (a.second < b.second);
}
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

VI parent1(200002);
VI parent(200002);
void make_set(int v)
{
    parent[v] = v;
    parent1[v] = 1;
}

int find_set(int v)
{
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b)
{
    a = find_set(a);
    b = find_set(b);
    if (a != b)
    {
        if (parent1[a] < parent1[b])
            swap(a, b);
        parent[b] = a;
        parent1[a] += parent1[b];
    }
}

int main()
{
    int n, m;
    cin>>n>>m;
    rep(i, n) make_set(i + 1);
    while (m--)
    {
        int x, y;
        cin>>x>>y;
        union_sets(x, y);
    }
    cout << *max_element(parent1.begin(), parent1.end());
    return 0;
}


Measured memory_bytes: 4660
#python3
from math import floor
from math import sqrt
def g(x):
    cnt = 0
    if x == 0:
        return 1
    while x:
        x //= 10
        cnt += 1
    return cnt

def F(x, y):
    return max(g(x), g(y))

def main():
    n = int(input())
    ans = 100
    for a in range(1, floor(sqrt(n))+1):
        if n%a == 0:
            b = n//a
            ans = min(ans, F(a, b))
    print(ans)
main()


Measured memory_bytes: 3060
#include<stdio.h>
#define N 10

int main(){
  int i, j, k, n, data[N], _data[N];

  data[0] = 1;
  for(i=1; i<N; i++)
    data[i] = 2 * data[i-1];

  while(scanf("%d", &n) != EOF){
    j = 0;
    for(i=N-1; i>=0; i--){
      if(n >= data[i]){
        n -=  data[i];
        _data[j] = data[i];
        j++;
      }
    }

    for(k=j-1; k>0; k--)
      printf("%d ", _data[k]);
    printf("%d\n", _data[0]);
  }

  return 0;
}

Measured memory_bytes: 0
class UnionFind():
    def __init__(self, n: int):
        self.n = n
        self.parents = [-1] * n

    def find(self, x: int) -> int:
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x: int, y: int) -> None:
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x: int) -> int:
        return -self.parents[self.find(x)]

    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)

    def members(self, x: int):
        root = self.find(x)
        return (i for i in range(self.n) if self.find(i) == root)

    def roots(self):
        return (i for i, x in enumerate(self.parents) if x < 0)

    def group_count(self) -> int:
        return len(self.roots())

    def sizes(self):
        return {x: self.size(x) for x in self.roots()}

    def all_group_members(self):
        d = {}
        for i in range(self.n):
            p = self.find(i)
            d[p] = d.get(p, []) + [i]
        return d

    def __str__(self):
        return '\n'.join('{}: {}'.format(k, v) for k, v in self.all_group_members().items())


def resolve():
    n, q = map(int, input().split())
    u = UnionFind(n)
    for _ in range(q):
        t, a, b = map(int, input().split())
        if t == 0:
            u.union(a, b)
        else:
            if u.same(a, b):
                print(1)
            else:
                print(0)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 11804
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int n;
vector<int> A;
int main(){
	int q ,a ,k=0;
	cin>>n;
	for(int i = 0;i<n;i++){
		cin>>a;
		A.push_back(a);
	}
	cin>>q;
	for(int i = 0;i<q;i++){
		cin>>a;
		if(*lower_bound(A.begin(),A.end()-1, a)==a) k++;
	}
	cout<<k<<endl;
	return 0;

}


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

int main(){
  int k;
  string s;
  cin >> k >> s;
  if(s.size()<=k){
    cout << s << endl;
  }else{
    for(int i=0;i<k;i++){
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3628
from functools import lru_cache


def PrimeFactorization(n):
    pf = {}
    i = 2
    while i ** 2 < n:
        while n % i == 0:
            pf[i] = pf.get(i, 0) + 1
            n //= i
        i += 1
    if n > 1:
        pf[n] = 1
    return pf


@lru_cache(maxsize=100000)
def f(x):
    return int((-1 + (1 + 8 * x) ** 0.5) // 2 + 0.001)


def resolve():
    n = int(input())
    d = PrimeFactorization(n)
    ans = 0
    for v in d.values():
        ans += f(v)
    print(ans)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, k; cin >> n >> k;
    VL h(n); cin >> h;
    VL a = h;
    a.push_back(0);
    SORT(a);
    a.erase(unique(all(a)), a.end());
    int m = a.size();
    unordered_map<ll, int> ma;
    FOR(i, 0, m)ma[a[i]] = i;

    auto dp = defvec<ll>(LLINF, n + 1, k + 1, m);
    dp[0][0][0] = 0;
    FOR(i, 0, n)eFOR(j, 0, k)FOR(s, 0, m) {
        chmin(dp[i + 1][j][ma[h[i]]], dp[i][j][s] + max(h[i] - a[s], 0LL));
        if (j == k)continue;
        chmin(dp[i + 1][j + 1][s], dp[i][j][s]);
    }

    ll ans = LLINF;
    eFOR(j, 0, k)FOR(s, 0, m)chmin(ans, dp[n][j][s]);
    cout << ans << "\n";
}

Measured memory_bytes: 216832
// Author:: MUKUL KUMAR RAI
// Institution:: Jalpaiguri Government Engineering College
//If you are not doing well now just stick to it and learn new things one day you will be...
//Compete with yourself 
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
///*template{{{
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
#define trav(a,x) for(auto &a:x)
#define fr(i,a,b)  for(ll i=a;i<=b;i++)
#define fr1(i,a)   for(ll i=0;i<a;i++)
#define frr(i,a,b) for(ll i=b;i>=a;i--)
#define frr1(i,a)   for(ll i=a-1;i>=0;i--)
#define sorta(a,n) sort(a,a+n)
#define sortd(a,n) sort(a,a+n,greater<ll>())
#define sortva(a) sort(a.begin(),a.end())
#define sortvd(a) sort(a.begin(),a.end(),greater<ll>())
#define tc(t) while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
using vi= vector<ll>;
using vvi= vector<vi>;
using vb =vector<bool>;
using vc =vector<char>;
using vs =vector<string>;
using vld =vector<ld>;
using pii =pair<ll,ll>;
using psi =pair<string,ll>;
using pci =pair<char,ll>;
using vpii =vector<pii>;
//}}}template*/
ll mod=1e9+7;
ll const maxn=1e3;
ll const inf=1e18;
bool ss(const pair<ll,ll> &a, const pair<ll,ll> &b) { 
    return a.first*b.second+a.second<b.first*a.second+b.second;
}
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
ll modinverse(ll a, ll m){
    return powm(a,m-2,m);
}
bool prime(ll x){
    if(x<=1)return false;
    for(int i=2;i<=sqrt(x);i++)if(x%i==0)return false;
    return true;
}
ll divisor(ll x){
    ll cnt=0;
    for(int i=1;i<=sqrt(x);i++){
        if(x%i==0){
            if(i!=x/i)cnt+=2;
            else cnt+=1;
        }
    }
    return cnt;
}
vector<ll> sieve(ll n) {     
    bool prim[n+1]; 
    memset(prim, true, sizeof(prim)); 
  
    for (ll p=2; p*p<=n; p++) {
        if (prim[p] == true) { 
            for (int i=p*p; i<=n; i += p) 
                prim[i] = false; 
        } 
    }
    vector<ll>v;
    for(int i=2;i<=n;i++)if(prim[i])v.push_back(i);
    return v; 
}
// vvi adj(maxn);
// vb vis(maxn,false);
// ll ans;
// ll dfs(ll u,ll x){
//     vis[u]=true;
//     for(auto v:adj[u]){
//         if(!vis[v]){
//             ans++;
//             if(ans==x)return v;
//             dfs(u,x);
//         }
//     }
//     return -1;
// }
ll fact(ll x){
    ll ans=1;
    fr(i,1,x)ans*=i;
    return ans;
}
ll ncr(ll n,ll r){
    if(r>n)return 0;
    ll ans=fact(n);
    ans/=fact(r);
    ans/=fact(n-r);
    return ans;
}
int main(){

    ll a,b;
    cin>>a>>b;
    if(a>=10 or b>=10 )cout<<-1;
    else cout<<a*b; 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,c=0;
  cin>>n;
  ll a[n],b[n];
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  for(int i=n-1;i>=0;i--){
    a[i]+=c;
    if(a[i]%b[i]!=0)
      c+=b[i]-(a[i]%b[i]);
  }
  cout<<c;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int sn=s.length(),tn=t.length();
    int dp[sn+1][tn+1];
    int flag=0;
    dp[0][0]=0;
    for(int i=1;i<=tn;i++){
            dp[0][i]=0;
        if(s[0]==t[i-1]||flag==1){
            dp[1][i]=1;
            flag=1;
        }
    }
    flag=0;
    for(int i=1;i<=sn;i++){
            dp[i][0]=0;
        if(t[0]==s[i-1]||flag==1){
            dp[i][1]=1;
            flag=1;
        }

    }
    for(int i=1;i<=sn;i++){
        for(int j=1;j<=tn;j++){
            if(s[i-1]==t[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }else{
            dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            }
        }
    }
    //cout<<dp[sn][tn]<<"\n";
    int a=sn,b=tn;
    string res="";
    while(a>0&&b>0){
        if(dp[a][b]!=dp[a-1][b]&&dp[a][b]!=dp[a][b-1]){
           res+=s[a-1] ;
           a--;
           b--;
        }else if(dp[a][b]==dp[a-1][b]){
            a--;
        }else if(dp[a][b]==dp[a][b-1]){
            b--;
        }
    }
    reverse(res.begin(),res.end());
    cout<<res<<endl;



}


Measured memory_bytes: 35456
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

int main()
{
	int N, K;
	cin >> N >> K;
	int x = (N + 1) / 2;
	string ans = x >= K ? "YES" : "NO";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  string s;
  cin >> s;
  if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]) cout<< "Bad" <<endl;
  else cout<< "Good" <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>

int main() {
	int n, m;
	std::cin >> n >> m;

	std::vector<std::vector<int>> nodes(n);
	for (int i = 0; i < m; ++i) {
		int a, b;
		std::cin >> a >> b;
		--a, --b;

		nodes[b].push_back(a);
	}

	std::vector<int> ans;
	ans.reserve(n);
	std::function<void(int)> visit = [&, visited = std::vector<bool>(n)](int x) mutable {
		if (visited[x])
			return;

		visited[x] = true;
		for (auto&& d : nodes[x])
			visit(d);

		ans.push_back(x);
	};
	for (int i = 0; i < n; ++i)
		visit(i);

	bool isUnique = [&]() {
		for (int i = n - 1; i > 0; --i) {
			bool flag = false;
			for (auto&& d : nodes[ans[i]])
				flag = flag | (d == ans[i - 1]);

			if (!flag)
				return false;
		}

		return true;
	}();

	for (auto&& e : ans)
		std::cout << e + 1 << std::endl;

	std::cout << (isUnique ? 0 : 1) << std::endl;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________


	int n;
	cin >> n;
	int a[n];
	int b[n];
	zip(i, 0, n)
	{
		cin >> a[i] >> b[i];
	}
	sort(a, a + n);
	sort(b, b + n);
	if (n % 2)
	{
		cout << b[n / 2] - a[n / 2] + 1 << en;
	}
	else

	{
		cout << b[n / 2] + b[n / 2 - 1] - a[n / 2] - a[n / 2 - 1] + 1 << en;
	}

	return 0;
}



Measured memory_bytes: 6784
import sys

sys.setrecursionlimit(10**6)
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,M = MI()
Graph = [[] for _ in range(N+1)]
for i in range(M):
    a,b = MI()
    Graph[a].append(b)
    Graph[b].append(a)

# 二部グラフであれば、(色1で塗る頂点の個数)*(色-1で塗る頂点の個数)-M
# 二部グラフでなければ、N*(N-1)//2-M

colors = [0]*(N+1)


def dfs(v,color):  # 二部グラフ判定
    colors[v] = color
    for w in Graph[v]:
        if colors[w] == color:
            return False
        if colors[w] == 0 and not dfs(w,-color):
            return False
    return True


if dfs(1,1):
    red = colors.count(1)
    blue = colors.count(-1)
    print(red*blue-M)
else:
    print(N*(N-1)//2-M)


Measured memory_bytes: 35336