akhauriyash/Code-Regression huggingface dataset:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	int[] arr;
	int[] rep;
	boolean[] edge;
	int d;

	int get(int i) {
		if (!edge[i / d]) {
			return rep[i / d];
		} else {
			return arr[i];
		}
	}

	void modify(int src, int dst, int x) {
		for (int i = src / d + 1; i <= dst / d - 1; ++i) {
			edge[i] = false;
			rep[i] = x;
		}
		if (!edge[src / d]) {
			for (int i = src / d * d; i < (src / d + 1) * d; ++i) {
				arr[i] = rep[src / d];
			}
		}
		if (!edge[dst / d]) {
			for (int i = dst / d * d; i < (dst / d + 1) * d; ++i) {
				arr[i] = rep[dst / d];
			}
		}
		edge[src / d] = true;
		edge[dst / d] = true;
		for (int i = src; i <= Math.min((src / d + 1) * d - 1, dst); ++i) {
			arr[i] = x;
		}
		for (int i = Math.max(src, dst / d * d); i <= dst; ++i) {
			arr[i] = x;
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		d = (int) Math.sqrt(n);
		arr = new int[n];
		Arrays.fill(arr, Integer.MAX_VALUE);
		edge = new boolean[n / d + 1];
		rep = new int[n / d + 1];
		Arrays.fill(rep, Integer.MAX_VALUE);
		Arrays.fill(edge, true);
		while (q-- > 0) {
			int t = sc.nextInt();
			if (t == 1) {
				System.out.println(get(sc.nextInt()));
			} else {
				int src = sc.nextInt();
				int dst = sc.nextInt();
				int x = sc.nextInt();
				modify(src, dst, x);
			}
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  vector<vector<int>> G(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (G[i].empty()) {
      res++;
    } else {
      bool flag = true;
      for (int v : G[i]) {
        if (H[i] <= H[v]) flag = false;
      }
      if (flag) res++;
    }
  }
  cout << res << '\n';
  return 0;
}


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

const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    rep(i, b) cout << a;
}

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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  int k, x;
  cin >> k >> x;
  if (500 * k >= x)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
#include<functional>
using namespace std;
int n,root,mr;
vector<int> edge[100005];
long long dp[100005];
void dfs(int dep,int prev)
{
	long long y=0;
	for(int i=0;i<edge[dep].size();i++)
	{
		int x=edge[dep][i];
		if(x!=prev)
		{
			dfs(x,dep);
			dp[dep]+=dp[x];
			if(dp[x]==0)
				y++;
		}
	}
	dp[dep]+=max((long long)0,y-1);
}
int main()
{
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	for(int i=0;i<n;i++)
		if(edge[i].size()>mr)
		{
			root=i;
			mr=edge[i].size();
		}
	dfs(root,-1);
	if(dp[root]==0)
		cout<<1;
	else
		cout<<dp[root];
	return 0;
}


Measured memory_bytes: 12672
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, K = MI()
    d = []
    A = [None for i in range(K)]
    AD = [set() for i in range(N)]

    for i in range(K):
        d = I()
        A[i] = LI()

    for i in range(K):
        for k in A[i]:
            AD[k-1].add(i+1)

    ans = 0
    for i in range(len(AD)):
        if len(AD[i]) == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68528
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=100100,P=1000000007;
int i,j,k,n,m,a,b,ans;
int Jc[N<<1],Jc_[N<<1];
int ksm(int x,int y) {
	int z=1;
	for (;y;y>>=1,x=(ll) x*x%P) if (y&1) z=(ll) z*x%P;
	return z;
}
void pre(int n) {
	Jc[0]=Jc_[0]=1;
	for (i=1;i<=n;i++) Jc[i]=(ll) Jc[i-1]*i%P;
	Jc_[n]=ksm(Jc[n],P-2);
	for (i=n-1;i;i--) Jc_[i]=(ll) Jc_[i+1]*(i+1)%P;
}
int C(int n,int m) {
	if (n<m) return 0;
	return (ll) Jc[n]*Jc_[m]%P*Jc_[n-m]%P;
}
int Js(int x1,int y1,int x2,int y2) {
	int x=x2-x1,y=y2-y1;
	return C(x+y,x);
}
int main() {
	scanf("%d%d%d%d",&n,&m,&a,&b);
	pre(n+m);
	for (i=1;i<=n-a;i++) ans=((ll) Js(1,1,i,b)*Js(i,b+1,n,m)+ans)%P;
	printf("%d\n",ans);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int n, a;
  cin >> n >> a;
  int ans = n*n - a;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    string s;cin>>s;
    ll cntS=0,cntT=0;
    ll n=(ll)s.size();
    ll p=0;
    rep(i,n){
        if(s[i]=='S'){
            cntS++;
        }
        else{
            if(cntS>0){
                cntS--;
                p++;
            }
        }
    }
    cout<<n-p*2<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000;
const int MOD = 1e9+7;
const int EPS = 1e-6;
#define pi 3.14159265358979323846
#define VI vector<int>
#define PII pair<int, int>
#define pb push_back
#define eb emplace_back
#define sz size
#define ll long long
#define REP(i, l, r, inc) for(int i=(l);i<(r);i+=(inc))
#define RREP(i, r, l, dec) for(int i=(r-1);i>=(l);i-=(dec))
#define endl '\n'

int dp[2][3];
int n;

signed main() {
	cin.tie(0); cout.sync_with_stdio(0);
	cin >> n;
	REP(i, 1, n+1, 1) {
		int a, b, c;
		cin >> a >> b >> c;
		dp[i&1][0] = max(dp[(i-1)&1][1], dp[(i-1)&1][2])+a;
		dp[i&1][1] = max(dp[(i-1)&1][0], dp[(i-1)&1][2])+b;
		dp[i&1][2] = max(dp[(i-1)&1][0], dp[(i-1)&1][1])+c;
	}
	cout << max(max(dp[n&1][0], dp[n&1][1]), dp[n&1][2]) << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
long long n,d,a,x,h,idx;long long diff,toadd,out=0;
vector<pii> vii;
vector<int>bombs;
vector<long long>sums;
int bsearch(int val)
{
    int b,e,mid,ans=-1;
    b=0,e=bombs.size()-1;

    while(b<=e)
    {
        mid=b+(e-b)/2;

        if(bombs[mid]==val)
        {
            ans=mid;
            return ans;
        }
        else if(bombs[mid]<val)
        {
            b=mid+1;
        }
        else
        {
            ans=mid;
            e=mid-1;
        }
    }
    return ans;
}
int main(){
   cin>>n>>d>>a;
   for(int i=0;i<n;i++)
   {
       cin>>x>>h;
       vii.push_back(make_pair(x,h));
   }
   sort(vii.begin(),vii.end());

   for(int i=0;i<n;i++)
   {
       x= vii[i].first;
       h= vii[i].second;
       idx = bsearch(x-2*d);
       if(idx>=0&&bombs[idx]>=x-2*d)
       {
           diff= out-(idx==0?0:sums[idx-1]);
           h-=(diff*a);
           if(h>0)
           {
               bombs.push_back(x);
               out += (long long)ceil(h*1.0/a);
               sums.push_back(out);
           }
       }
       else
       {
           bombs.push_back(x);
           out += (long long)ceil(h*1.0/a);
           sums.push_back(out);
       }
   }
   cout<<out<<endl;
	return 0;
}


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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  
  if ((10 * g + b) % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull  unsigned long long ;
#define _CRT_SECURE_NO_WARNINGS 
const double  pai= acos(-1.0);
const int max1=5;
ll mod	;
char a[max1],b[max1];
int main()
{
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int i,sum=0;
	cin>>a>>b;
	for(i=0;i<3;i++)
	if(a[i]==b[i])sum++;
	cout<<sum<<endl;
	return 0;
 }

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

int main()
{
    ll a, b;
    cin >> a >> b;
    ll k = abs(a-b);
    if(k%2)
    {
        cout << "IMPOSSIBLE" << endl;
    }
    else
    {
        cout << min(a, b) + k/2 << endl;
    }
    return 0;
}


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

/// read the question correctly (is y a vowel?)
/// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

const int mx =  1234567;
const double exp1 =  1e-6;
const int md =  1e9+7;
typedef long long ll;

int ar[mx],xar[mx],uses[mx];
ll arr[mx];
int tab[1000][1000];
string st[1000];
int ar1[mx],ar2[mx];
map<int ,int>mpii;
map<int ,char>mpic;
map<char ,int>mpci;

int main(){

    int tk=1,n,m=0;
//    freopen("in.txt","r", stdin);
//    freopen("out.txt","w", stdout);
    string s1,s2;
    while(cin>>s1){
            cin>>s2;
            int cnt  =0;
            for(int i = 0; i < 3; i++){
                if(s1[i] == s2[i])cnt++;
            }
            cout<<cnt<<endl;

    }

    return 0;
}


Measured memory_bytes: 2304
#![allow(dead_code)]
 
// This file is a "Hello, world!" in Rust language for wandbox.
use std::process;
 
 
fn main()
{
    let nums: usize = read(); // 10000, 5000, 1000
    
	let str: String = read();
  	
  	if str.len() <= nums {
      println!("{}", str);
  } else {
  	println!("{}...", &str[0..nums]);
  }
  
}
    
// Rust language references:
//   https://www.rust-lang.org/
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
 
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 2120
#include <iostream>
#include <cmath>

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

    int count = 0;
    for (int i = 0; i < n; i++)
    {
        int x, y;
        std::cin >> x >> y;
        if (sqrt(std::pow(x, 2) + std::pow(y, 2)) <= d)
        {
            count++;
        }
    }
    
    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 3672
#include <iostream>                                             
#include <string>                                               
using namespace std;                                            
                                                                
int main() {                                                    
  string str;                                                   
  cin >> str;                                                   
  for (int i=str.size(); i--;) {                                
    cout << str[i] << flush;                                    
  }                                                             
  cout << endl;                                                 
  return 0;                                                     
}                                                               
                                                                
                                                                
                       

Measured memory_bytes: 3184
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string s;
  cin>>s;
  ll k;
  cin>>k;
  rep(i,sz(s)){
    if(s[i]=='a') continue;
    if('z'-s[i]+1<=k){
      k-=(ll)('z'-s[i]+1);
      s[i]='a';
    }
  }
  s[sz(s)-1]=(char)(s[sz(s)-1]+k%26);
  COUT(s);
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


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

    ll n; cin>>n;
    vint a(n); rep(i,n) cin>>a[i];

    map<ll,ll> m;
    for(auto e:a) m[e]++;
    ll ans = 0;
    for(auto e:a) ans += e;

    ll q; cin>>q;
    while(q>0){
        ll b,c; cin>>b>>c;
        ans -= m[b]*b;
        ans += m[b]*c;
        m[c] += m[b];
        m[b] = 0;
        cout<<ans<<endl;
        q--;
    }




    return 0;

}

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

int main() {
    int A, B;
    cin >> A >> B;
    int result = -1;
    for (int i = 1; i <= 1000; i++) {
        double a = i * 0.08;
        double b = i * 0.1;
        int a_kirisute = a;
        int b_kirisute = b;
        if (A == a_kirisute && B == b_kirisute) {
            result = i;
            break;
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define f first
#define s second
using namespace std;

const int maxn = 2e5+7;
int ans[maxn], k;
vector<int> edges[maxn], v;
bitset<maxn> done;

void dfs(int c)
{
    done[c]=1;
    ++k;
    v.push_back(c);
    for (int i : edges[c])
        if (!done[i])
            dfs(i);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,mini;
    cin>>n;
    pair<pii,int> p[n];
    for (int i=0;i<n;++i)
    {
        cin>>p[i].f.f>>p[i].f.s;
        p[i].s=i+1;
    }
    sort(p,p+n);
    stack<pii> st;
    for (int i=0;i<n;++i)
    {
        mini=p[i].f.s;
        while (sz(st)&&st.top().f<p[i].f.s)
        {
            edges[st.top().s].push_back(p[i].s);
            edges[p[i].s].push_back(st.top().s);
            mini=min(mini,st.top().f);
            st.pop();
        }
        st.push({mini,p[i].s});
    }
    for (int i=1;i<=n;++i)
    {
        if (!done[i])
        {
            k=0;
            v.clear();
            dfs(i);
            for (int i : v)
                ans[i]=k;
        }
        cout<<ans[i]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 27524
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
static const int MAX = 100;
static const int INF = 1000000;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int main(void) {
    int n, i;
    cin >> n;
    int a[n+2], d[n+2], dsum;
    a[0]=0;
    a[n+1]=0;
    for(i=1; i<=n; i++)
        cin >> a[i];
    d[0]=0;
    for(i=1; i<=n; i++) {
        d[i] = d[i-1] + abs(a[i]-a[i-1]);
    }
    dsum = d[n] + abs(a[n]);
    
    
    for(i=1; i<=n; i++) {
        cout << dsum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]) << endl;
    }
}


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
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;}
//end

template<unsigned mod=1000000007>struct fp {
   unsigned v;
   static unsigned get_mod(){return mod;}
   unsigned inv() const{
      int tmp,a=v,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0){x+=mod;} return x;
   }
   fp():v(0){}
   fp(ll x):v(x>=0?x%mod:mod+(x%mod)){}
   fp operator-()const{return fp(-v);}
   fp pow(ll t){fp res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;} return res;}
   fp& operator+=(const fp& x){if((v+=x.v)>=mod)v-=mod; return *this;}
   fp& operator-=(const fp& x){if((v+=mod-x.v)>=mod)v-=mod; return *this;}
   fp& operator*=(const fp& x){v=ll(v)*x.v%mod; return *this;}
   fp& operator/=(const fp& x){v=ll(v)*x.inv()%mod; return *this;}
   fp operator+(const fp& x)const{return fp(*this)+=x;}
   fp operator-(const fp& x)const{return fp(*this)-=x;}
   fp operator*(const fp& x)const{return fp(*this)*=x;}
   fp operator/(const fp& x)const{return fp(*this)/=x;}
   bool operator==(const fp& x)const{return v==x.v;}
   bool operator!=(const fp& x)const{return v!=x.v;}
}; using Fp=fp<>;

int main(){
   int n; cin>>n;
   map<pair<ll,ll>,int> cnt; int zero=0;
   rep(i,0,n){
      ll x,y; cin>>x>>y;
      if(x==0 and y==0){
         zero++; continue;
      }
      ll g=gcd(x,y);
      x/=g; y/=g;
      if(y==0)x=1; else if(y<0)x*=-1,y*=-1;
      cnt[{x,y}]++;
   }
   Fp res=1;
   for(auto& [p,val]:cnt){
      ll x,y; tie(x,y)=p;
      ll t=0;
      if(cnt.count({-y,x})){
         t=cnt[{-y,x}]; cnt[{-y,x}]=0;
      }
      else if(cnt.count({y,-x})){
         t=cnt[{y,-x}]; cnt[{y,-x}]=0;
      }
      res*=(Fp(2).pow(val)+Fp(2).pow(t)-1); val=0;
   } res-=1; res+=zero; cout<<res.v<<endl;
   return 0;
}

Measured memory_bytes: 15932
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

struct UnionFind{
    vector<int> d;
    UnionFind(int n=0):d(n,-1){}
    int root(int x){
        if(d[x]<0)return x;
        return d[x]=root(d[x]);
    }
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return false;
        if(d[x]>d[y])swap(x,y);
        d[x]+=d[y];
        d[y]=x;
        return true;
    }
    bool same(int x,int y){return root(x)==root(y);}
    int usize(int x){return -d[root(x)];}
};

int main(){
    int n,m;cin >>n>>m;
    UnionFind uni(n);
    for (int i = 0; i < m; ++i) {
        int a,b;cin >>a>>b;
        a--;b--;
        uni.unite(a,b);
    }
    int ans=-1;
    for (int i = 0; i < n; ++i) {
        ans=max(ans,uni.usize(i));
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 4048
s = input()

a = int(s[0:2])
b = int(s[2:4])

p = False
q = False
if 1 <= a <= 12:
  p = True
if 1 <= b <= 12:
  q = True
    
if p and q:
  print("AMBIGUOUS")
if p and not q:
  print("MMYY")
if not p and q:
  print("YYMM")
if not p and not q:
  print("NA")

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
int dp[1<<21];
int cnt[21][100010];
int ccnt[21];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n,a,b;cin>>n>>a>>b;
    ll c=b-a+1;
    ll minm=(n-1)*a+b;
    ll maxm=(n-1)*b+a;
    cout<<mmax(0,maxm-minm+1)<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------


































Measured memory_bytes: 384
#include <iostream>
#include <tuple>
#include <algorithm>
#include <cstring>
#include <bitset>
using namespace std;
using Large2 = tuple<int, int>;

int N;
Large2 A[1<<18];

int mergetmp[4];
Large2 mergeLarge2(Large2 &l, Large2 &r) {
    tie(mergetmp[0], mergetmp[1]) = l;
    tie(mergetmp[2], mergetmp[3]) = r;
    sort(mergetmp, mergetmp+4);
    return Large2(mergetmp[3], mergetmp[2]);
}

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

    cin>>N;
    for(int i = 0; i < (1<<N); i++) {
        int v;cin>>v;
        A[i] = Large2(v, 0);
    }

    for(int k = 0; k < N; k++) {
        for(int i = 0; i < (1<<N); i++) {
            if(!((i>>k) & 1)) A[i | (1<<k)] = mergeLarge2(A[i | (1<<k)], A[i]);
        }
    }

    for(int i = 1, maxv = 0; i < (1<<N); i++) {
        int M, m;tie(M, m) = A[i];maxv = max(maxv, M + m);
        cout<<maxv<<'\n';
    }

    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int main(){
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    string a;
    cin >> a;
    int flag = 0;
    for(int i = 0;i < a.size();++i){
        for(int j = i + 1;j < a.size();++j){
            if(a[i] == a[j]){
                flag = 1;
            }
        }
    }
    if(flag == 1){
        cout << "no" << endl;
    }else{
        cout << "yes" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn];
int cnt[2][3005];
int main()
{
    ios::sync_with_stdio(false);
    string temp;
    cin >> temp;
    int n = temp.length();
    for (int i = 1 ; i <= n ; i++) a[i] = temp[i - 1] - '0';
    int now = 0;
    ll ans = 0;
    cnt[0][0] = 1;
    int v;
    for (int i = 1 ; i <= n ; i++){
        v = i&1;
        for (int j = 0 ; j < 2019 ; j++){
            cnt[v][j * 10 % 2019] = cnt[!v][j];
        }
        now = (now * 10 + a[i])%2019;
        ans = ans + cnt[v][now];
        cnt[v][now]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4588
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b; cin>>a>>b;
	int st=(a*100)/8;
	int ed=(b*100)/10;
	if(st>ed)swap(st,ed);
	for(int i=st-1;i<=ed+1500;i++){
		int cur_a=i*(0.08);
		int cur_b=i*(0.1);
		if(cur_a==a && cur_b==b){
			cout<<i<<'\n';
			return 0;
		}
	}
	cout<<-1<<'\n';
	return 0;
}

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

int main(){
	int n,t=1;
	while(cin>>n&&n){
		cout<<"Case "<<t++<<":\n";
		for(int y=0;y<n;y++){
			for(int x=0;x<n;x++){
				int a=x+y,b;
				if(a<n){
					b=(a+1)*a/2;
				}else{
					a-=n;
					b=(n+1)*n/2+(n-1+n-1-a-1)*a/2-1;
				}
				cout<<setw(3)<<1+b+(x+y&1?y:x);
			}
			cout<<endl;
		}
	}
	return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;  typedef pair<int,ll> pii;
typedef vector<int> VI; typedef vector<ll> VL;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

VL  fct(200200), inv(200200);
void init(int cmx, ll mod){
	auto bin_pows =[](ll x, ll n, ll mod){
		ll res = 1LL;
		for(; n > 0; n >>=1, x = x*x %mod) if(n & 1) res = res * x %mod;
		return res;
	};
	fct[0] = fct[1] = inv[1] = 1;
	for(int i=2;i<cmx+3;i++) fct[i] = fct[i-1] * i % mod;
	inv[cmx] = bin_pows(fct[cmx], mod-2, mod);
	for(int i=cmx;i>=1;i--) inv[i-1] = inv[i] * i % mod;
}

ll nCk(ll n, ll k, ll mod=MD) {
	if(k > n) return 0;
	ll ret =fct[n] * inv[k] % mod * inv[n-k] % mod;
	return ret;
}
int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n+1);
	rep(i, n+1) cin >>a[i];
	
	
	init(200100, MD);
	VI mp(n+5, -1);
	int lf=0, rg=0;
	rep(i, n+1){
		if(mp[a[i]] !=-1){
			rg = i; lf = mp[a[i]]; break;
		}
		mp[a[i]] = i;
	}
	
	//dbg(lf, rg, a[lf]);
	rep2(k, 1, n+2){
		ll ans = nCk(n+1, k, MD);
		ans += MD - nCk(n+1 -(rg-lf+1), k-1, MD);
		cout << ans %MD <<"\n";
	}
	
	return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int n;
  cin >> n;
  vector<int64> xs(n);
  int64 sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    sum += xs[i];
  }

  int64 ans = INT64_MAX;
  int64 a = 0;
  for (int i = 0; i < n - 1; i++) {
    a += xs[i];
    int64 b = sum - a;
    UpdateMin(ans, abs(a - b));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
s1, s2, s3 = input()
t1, t2, t3 = input()
if s1 == t1:
    if s2 == t2:
        if s3 == t3:
            print(3)
        else:
            print(2)
    else:
        if s3 == t3:
            print(2)
        else:
            print(1)
else:
    if s2 == t2:
        if s3 == t3:
            print(2)
        else:
            print(1)
    else:
        if s3 == t3:
            print(1)
        else:
            print(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    vector<ll> cnt(n, 0);
    rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        cnt[a]++; cnt[b]++;
    }

    rep(i, n) {
        if (cnt[i] % 2 != 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define all(v) v.begin(),v.end()
#define fi first
#define se second
const int inf = 1e9;
int mod = 1e9+7;

int a[100001];
signed main(){
	int n;
	scanf("%lld", &n);
	rep(i,n){
		int x;
		scanf("%lld", &x);
		a[x]++;
	}
	int sum = 0;
	rrep(i,100000)sum += max((int)0, a[i]-1);
	int d = (sum+1)/2;
	printf("%lld\n", n-2*d);
	return 0;
}

Measured memory_bytes: 1024
import sys,math
input = sys.stdin.readline

a_max=0
b = []
N,H = map(int,input().split())
for i in range(N):
    an,bn = map(int,input().split())
    b.append(bn)
    a_max = max(a_max,an)

b = sorted([ bn for bn in b if bn>=a_max])
cnt = 0
for i in range(len(b)):
    H -= b.pop()
    cnt += 1
    if H <=0:
        print(cnt)
        exit()

cnt += math.ceil(H/a_max)
print(cnt)

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

using namespace std;

int main()
{
    int x,y,z;
    cin>>x>>y>>z;
    int temp1=x;
    x=y;
    y=temp1;
    int temp2=x;
    x=z;
    z=temp2;
    cout<<x<<" "<<y<<" "<<z<<" ";
    return 0;
}


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

using namespace std;
string a,b,c;
int main() {
	cin >> a >> b >> c ;
	string rule;
	rule = (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) ? "YES" : "NO";
	cout << rule<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    map <char,int> m;
    string s;
    cin >> s;
    rep(i,4){
        m[s[i]] ++;
    }
    if(m[s[0]]==2 && m[s[1]]==2 && m[s[2]]==2 && m[s[3]]==2){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;

}

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

int main() {
	
	int N, M, X;
	cin >> N >> M >> X;
	int count_ZERO = 0, count_N = 0;
	vector<int>A;
	
	for (int i = 0; i < M; i++) {

		int tmp;
		cin >> tmp;
		
		if (tmp < X) count_ZERO++;
		else if (X < tmp) count_N++;
	}

	if (count_ZERO < count_N) cout << count_ZERO;
	else cout << count_N;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;

int main(void)
{
  int n;
  int a[100];

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

  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 0 && (a[i] % 3 != 0 && a[i] % 5 != 0)) {
      cout << "DENIED";
      return 0;
    }
  }

  cout << "APPROVED";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
  cin>>n;
  long long int a[n+1];
  for(long long int i=1;i<=n;i++)
  {
    cin>>a[i];
  }
  long long int b[n+1];
  b[1]=0;
  b[2]=abs(a[2]-a[1]);
  for(long long int i=3;i<=n;i++)
  {
    b[i]=min((b[i-1]+abs(a[i]-a[i-1])),(b[i-2]+abs(a[i]-a[i-2])));
  }
  cout<<b[n];
  return 0;
}


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

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

	if((a+b)%2 == 0) cout << (a+b)/2 << endl;
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

func main() {
	var L, R int
	fmt.Scanf("%d %d\n", &L, &R)
	if L%2019 == 0 || R%2019 == 0 {
		fmt.Println(0)
		return
	}
	if R-L >= 2019 {
		fmt.Println(0)
		return
	}
	min := 5000
	for i := L; i < R; i++ {
		for j := L + 1; j <= R; j++ {
			r := (i * j) % 2019
			if min > r {
				min = r
			}
		}
	}
	fmt.Println(min)
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public static void Main(){
        long N = long.Parse(Console.ReadLine());
        int ans = 20;
        for(var i = 1;i <= Math.Sqrt(N);i++){
            if(N % i == 0){
                long x = N / i;
                ans = Math.Min(ans,x.ToString().Length);
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2012;
vector<int> a[maxn];
char s[maxn];
int f[maxn],g[maxn],d[maxn];
void dfs(int x,int fa){
	if(s[x]=='1')d[x] = 1;
	else d[x] = 0;
	f[x] = g[x] = 0;
	int maxi = 0,id = 0;
	for(int y:a[x]){
		if(y==fa)continue;
		dfs(y,x);
		d[x] += d[y];
		g[x] += g[y] + d[y];
		if((g[y]-f[y])+d[y]>maxi){
			maxi = (g[y]-f[y])+d[y];
			id = y;
		}
	}
	int tmp = g[x] - (g[id]+d[id]);
//	cout<<"!"<<x<<" "<<maxi<<" "<<tmp<<endl;
	if(maxi<=tmp)f[x] = g[x];
	else f[x] = f[id]+tmp*2;
	if(f[x]%2)f[x]--;
}
int  main()
{
	int n;cin>>n;
	int ans = 1<<30;
	scanf("%s",s+1);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for(int i=1;i<=n;i++){
//		cout<<i<<"****************"<<endl;
		dfs(i,0);
		
//		for(int j=1;j<=n;j++)
//			cout<<j<<": "<<f[j]<<" "<<g[j]<<endl;
		if(f[i]==g[i]){
			ans = min(ans,f[i]/2);
		}
	}
	if(ans==1<<30)puts("-1");
	else cout << ans << endl;
} 


Measured memory_bytes: 512
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n,m;cin>>n>>m;
  for(int i = 0; max(n,m) > i; i++){
    cout << min(n,m);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	
	int a,b,i;
	
	for(i=0;i<3000;i++)
	{
		scanf("%d %d",&a,&b);
		if(a==0 && b==0)
		{
			break;
		}
		if(a>b)
		{
			printf("%d %d\n",b,a);
			
		}
		else
		{
			printf("%d %d\n",a,b);
		}
		
	}
	
	
	
	// your code goes here
	return 0;
}



Measured memory_bytes: 2052
N = int(input())
A = list(map(int, input().split()))
Sum = sum(A)//2
ans = [0]*N
res = Sum
for i in range(1, N-1, 2):
    res -= A[i]
ans[0] = res*2
for i in range(1, N):
    ans[i] = A[i-1]*2-ans[i-1]

ans = map(str, ans)
print(' '.join(ans))

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

int n;
string s[13];
map<char,int> alc,dame;
bool used[13];
int res;

void dfs(int i,int d,int sum){
  if(i==n-1&&d==0){
    if(alc[s[i][d]]==sum||(alc[s[i][d]]==-1&&sum<10&&sum!=0&&!used[sum])){
      res++;
    }
  }else if(i==n-1){
    if(alc[s[i][d]]==sum%10){
      dfs(0,d-1,sum/10);
    }else if(alc[s[i][d]]==-1&&!used[sum%10]&&(sum%10!=0||!dame[s[i][d]])){
      used[sum%10]=true;
      alc[s[i][d]]=sum%10;
      dfs(0,d-1,sum/10);
      used[sum%10]=false;
      alc[s[i][d]]=-1;
    }
  }else if(alc[s[i][d]]==-1){
    repl(j,dame[s[i][d]],10){
      if(used[j])continue;
      alc[s[i][d]]=j;
      used[j]=true;
      dfs(i+1,d,sum+j);
      alc[s[i][d]]=-1;
      used[j]=false;
    }
  }else{
    dfs(i+1,d,sum+alc[s[i][d]]);
  }
  return ;
}

int main(){
	cin.sync_with_stdio(false);
  while(1){
    cin>>n;
    if(n==0)break;
    alc.clear(); dame.clear();
    int maxl=0;
    rep(i,n){
      cin>>s[i];
      rep(j,s[i].length()){
        if(j==0&&s[i].length()!=1)dame[s[i][j]]=1;
        alc[s[i][j]]=-1;
      }
      maxch(maxl,(int)s[i].length());
    }
    rep(i,n){
      while(s[i].length()<maxl)s[i]="-"+s[i];
    }
    memset(used,0,sizeof(used));
    alc['-']=0;
    res=0;
    dfs(0,maxl-1,0);
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    REP(i,N){
        cin >> A[i];
        cin >> B[i];
    }
    if(N%2 == 1){
        sort(ALL(A));
        sort(ALL(B));
        cout << B[(N+1)/2-1] - A[(N+1)/2-1] + 1<< "\n";
    }else{
        sort(ALL(A));
        sort(ALL(B));
        cout << B[N/2-1] + B[N/2] - A[N/2-1] - A[N/2] + 1 << "\n";
    }
}

Measured memory_bytes: 6376
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=1,r=-1,n=t.in(),i=0;n>0;){var o=n%10;o==r?e++:(r=o,e=1),e>i&&(i=e),n=Math.floor(n/10)}i>=3?console.log("Yes"):console.log("No")}}]);

Measured memory_bytes: 7372
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
int execute(){
    int n, m;
    if(!~scanf("%d %d", &n, &m))
        return 0;
    vector<long long> cnt(m + 1), add(m + 1);
    int last;
    scanf("%d", &last); last --;
    long long full = 0;
    for(int e = 1; e < n; e++){
        int nxt; scanf("%d", &nxt); nxt--;
        if(last < nxt){
            // (nxt - x + 1)
            add[last + 1] += nxt + 1;
            add[nxt + 1] += - nxt - 1;

            cnt[last + 1]++;
            cnt[nxt + 1]--;

            add[nxt + 1] += nxt - last;
            add[0] += nxt - last;
            add[last + 1] += - nxt + last;

        } else {
            // (nxt - x + m + 1)
            add[last + 1] += nxt + m + 1;
            cnt[last + 1]++;
            add[0] += nxt + 1;
            add[nxt + 1] += - nxt - 1;
            cnt[0]++;
            cnt[nxt + 1]--;

            add[nxt + 1] += nxt - last + m;
            add[last + 1] += - nxt + last - m;
        }
        full += (nxt - last + m)%m;
        last = nxt;
    }
    for(int e = 1; e < m; e++)
        add[e] += add[e-1], cnt[e] += cnt[e-1];
    for(int e = 0; e < m; e++)
        full = min(full, add[e] - cnt[e] * e);
    printf("%lld\n", full);
    return 1;
}
int main(){
    while(execute());
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, z, n) for(ll i = z; i <= n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
using namespace std;

int main(){
  ll n,m,sum;
  cin >> n >> m;
  sum =0;
  rep(i,1,m){
    ll temp;
    cin >> temp;
    sum += temp;
  }
  if(n<sum){
    cout << -1 << endl;
    return 0;
  }
  cout << n-sum << endl;
    
  return 0;
}


Measured memory_bytes: 3604