akhauriyash/Code-Regression huggingface dataset:
x, y = map(int, input().split())
#絶対値を一致させなければいけない
#かかるコストは、絶対値の差。+0 or+1 or +2
#ここは頑張って考える
if x == 0:
    if y >= 0:
        print(y)
    else:
        print(abs(y) + 1)
    exit()
elif y == 0:
    if x >= 0:
        print(1 + abs(x))
    else:
        print(abs(x))
    exit()
if y > 0 and x > 0:
    if y >= x:
        print(y - x)
    else:
        print(abs(x) - abs(y) + 2)
elif y < 0 and x > 0:
    if abs(y) > abs(x):
        print(abs(y) - x + 1)
    else:
        print(x - abs(y) + 1)
elif y > 0 and x < 0:
    if abs(x) < abs(y):
        print(y - abs(x) + 1)
    else:
        print(abs(x) - y + 1)
else:
    if y >= x:
        print(y - x)
    else:
        print(abs(y) - abs(x) + 2)




Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
long long h, n, a, sum;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> h >> n;
for (int i=0; i<n; i++) {
	cin >> a; sum+=a;}
if (h>sum) cout << "No";
else cout << "Yes";
return 0;
}


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

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

    if (a == b && a != c) cout << "Yes" << endl;
    else if (b == c && b != a) cout << "Yes" << endl;
    else if (c == a && c != b) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

int main() {
  int N = 0, l = 0, r = 0, ans = 0, i = 0;
  cin >> N ;
  
  for (i = 0; i < N; i++) {
    cin >> l >> r;
    ans += (r - l) + 1;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <queue>

using namespace std;

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

    int a, b, t;
    cin >> a >> b >> t;

    int ans = (t / a) * b;

    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 60, mod = 1e9 + 7;

int n, k;

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

    int h = 0;
    while(k--)
    {
        int x;
        cin >> x;
        h |= (1 << x);
    }

    for(int i = n; ; i++)
    {
        int v = 0, t = i;
        while(t)
        {
            v |= (1 << (t % 10));
            t /= 10;
        }

        if((h & v) == 0)
        {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define double long double
#define int long long
#define pb push_back 
#define eb emplace_back
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef pair<pii,pii> ppp;
typedef vector< pii > vp;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }

void mina(int &a,int b)
{ a=(a<b?a:b); }

void maxa(int &a,int b)
{ a=(a>b?a:b); }

  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=1e18;
  const int N=3e5+35;
  const int M=1005;
 

 void doit()         
 {
   vvi v; int n,m,q; cin>>n>>m>>q;

   rep(i,1,m+1) v.pb(vector<int>{i});

   rep(i,1,n){
      vvi a;
      tr(j,v){
         vi b(j);
        rep(k,L(j),m+1){
           b.pb(k);
           a.pb(b);
           b.pop_back();
        }
      }

      v=a;
   }
   
   vi val(Z(v));

   rep(i,0,q){
      int a,b,c,d; cin>>a>>b>>c>>d;

      rep(i,0,Z(v)){
        if(v[i][b-1]-v[i][a-1]==c)
          val[i]+=d;
      }
   }


   cout<<*max_element(all(val));
   
 }

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

   int tc=1;                         
 //   cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
    
   doit();
   if(i<tc)
   cout<<nl;
  }

 return 0; 
}

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

#include <algorithm>

int main() {
	int n;
	while (1) {
		cin >> n;
		if (n==0) break;
		int p1=0, p2=0;
		int c1, c2;
		for (int i=0; i<n; i++) {
			cin >> c1 >> c2;
			if (c1==c2) p1+=c1, p2+=c2;
			if (c1>c2) p1+=c1+c2;
			if (c1<c2) p2+=c1+c2;
		}
		cout << p1 << " " << p2 << endl;
	}
	return 0;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  int anko = min(a,b);
  int maojini = min(c,d);
  
  cout << anko + maojini << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
    long long minu(long long a, long long b){
        return mod(mod(a)-mod(b));
    }
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
    
    vector<int>dirX={-1,0,1};
    vector<int>dirY={-1,0,1};
 
 
    ll dp[2005];
    ll ok(int s){
        // cout<<"in "<<s<<"\n";
        if(s==0)
            return 1LL;
        else if(s==1 || s==2)
            return 0LL;
        else if(s>=3 && s<=5)
            return 1LL;
        else if(dp[s]!=-1)
            return dp[s];
        else{
            ll total=0;
            for(int i=3;i<=s;i++){
                if(s-i>=0)
                    total=add(total,ok(s-i));
            }
            return dp[s]=total;
        }
    }
    void solve(){
        int s;
        cin>>s;
        memset(dp,-1,sizeof(dp));
        dp[0]=1;
        cout<<ok(s);
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
        //    cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;

    int ans = 0;
    set<int> s;
    FOR(i, 1, 1000001) if(N % i == 0){
        s.insert(i);
        s.insert(N / i);
    }
    for(int i: s) if(i > 1){
        int m = i - 1;
        if(N / m == N % m) ans += m;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <random>
#include <vector>
//#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
 
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()
#define cae cout<<ans<<endl
 
int main()
{
	int a,b,x;
	cin>>a>>b>>x;
	if(a<=x&&x<=a+b){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

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

using namespace std;

class State{
public:
  int x, y;
  int hp;
  int time;
};
int w, h;
char data[8][8];
int sx, sy;

int bfs();

main(){
  while(1){
    cin >> w >> h;
    if(w==0 && h==0) break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> data[i][j];
	if(data[i][j]=='2'){
	  data[i][j]='1';
	  sx=j;
	  sy=i;
	}
      }
    }
    cout << bfs() << endl;
  }
  return 0;
}

int bfs(){
  State u, v;
  queue<State> Q;
  bool visited[8][8][6];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=0;k<6;k++){
	visited[i][j][k]=false;
      }
    }
  }
  int dx[4]={0, 1, 0, -1};
  int dy[4]={-1, 0, 1, 0};
  u.time=0;
  u.hp=6;
  u.x=sx;
  u.y=sy;
  Q.push(u);
  while(!Q.empty()){
    u=Q.front(), Q.pop();
    if(u.hp==0) continue;
    if(data[u.y][u.x]=='3') return u.time;
    if(data[u.y][u.x]=='4') u.hp=6;
    for(int i=0;i<4;i++){
      int ty=u.y+dy[i];
      int tx=u.x+dx[i];
      if(ty>=0 && ty<h){
	if(tx>=0 && tx<w){
	  if(data[ty][tx]!='0'){
	    if(!visited[ty][tx][u.hp-1]){
	      visited[ty][tx][u.hp-1]=true;
	      v.time=u.time+1;
	      v.x=tx;
	      v.y=ty;
	      v.hp=u.hp-1;
	      Q.push(v);
	    }
	  }
	}
      }
    }
  }
  return -1;
}

Measured memory_bytes: 0
//bit全探索
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 int pp[110];

int main(){cout<<fixed<<setprecision(10);
		   int n;
           cin>>n;
           map<pair<string,int>,int> book;
           string s;
           map<string,int> cnt;
           int p;
           rep(i,0,n){
             cin>>s>>p;
             book[mp(s,p)]=i+1;
             cnt[s]++;
           }
           //sort(all(book));
           int f=0;
          
           for(auto v:book){
             int r=cnt[v.first.first];
             int e=v.second;
            if(r==1){
             cout<<e<<endl; 
              f=0;
            }
             else{
               f++;
               pp[f]=e;
             }
             if(f==r){
               rep(j,0,f){
                cout<<pp[f-j]<<endl; 
               }
               f=0;
             }
           }
}

Measured memory_bytes: 3612
// https://www.youtube.com/watch?v=1CaS4pSpS3c     lana is <3
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < ll , ll >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 
const ll inf=1e18+1e17;
const ll mod = 1e9+7;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}
ll sub( ll a, ll b){ if ( a-b<0) return a-b+mod; return a-b;}
ll add( ll a, ll b){ if ( a+b>=mod) return a+b-mod; return a+b;}
ll mul( ll a, ll b){ return (a*b)%mod;}
const ll N =2000+5;
ll fac[N];
ll ncr( int a, int b){
	return mul(mul(fac[a],modInverse(fac[b],mod)),modInverse(fac[a-b],mod));
}
void solve(){
	int s;
	cin>>s;
	int ans=0;
	int x=0;
	while ( s-3>=0){
		s-=3;
		x++;
		ans=add( ans, ncr(s+x-1,x-1));
	}
	cout<<ans<<'\n';

}


int main(){

	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);

	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif
	fac[0]=1;
	for ( int i=1;i<N;i++)
		fac[i]=(fac[i-1]*i)%mod;
	int t=1;
	//cin>>t;
	while ( t-- )
		solve();
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    vector<vector<string>> vec(N, vector<string>(3));
    for(ll i=0;i<N;i++){
        ll ve;
        cin>>vec[i][0]>>ve;
        vec[i][1]=to_string(INF-ve);
        vec[i][2]=to_string(i+1);
    ;}
    sort(vec.begin(), vec.end());
    for(ll i=0;i<N;i++){
        cout<<vec[i][2]<<endl;
    ;}
    return 0;
}


Measured memory_bytes: 256
from collections import deque

a = deque(list(input()))
b = deque(list(input()))
c = deque(list(input()))
a.append('0')
b.append('1')
c.append('2')

next_turn = a.popleft()
while a or b or c:
    if next_turn == 'a':
        next_turn = a.popleft()
    elif next_turn == 'b':
        next_turn = b.popleft()
    else:
        next_turn = c.popleft()
        
    if next_turn == '0':
        print('A')
        break
    elif next_turn == '1':
        print('B')
        break
    elif next_turn == '2':
        print('C')
        break

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

int main(){
    int N;
    long long ans=0,cou[5]={0};
    int P [10]={0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2};
    int Q [10]={1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3};
    int R [10]={2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4};
    string s;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>s;
            if(s[0]=='M'){cou[0]++;}
            else if(s[0]=='A'){cou[1]++;}
            else if(s[0]=='R'){cou[2]++;}
            else if(s[0]=='C'){cou[3]++;}
            else if(s[0]=='H'){cou[4]++;}
    }
    for(int j=0;j<10;j++){
        ans += cou[P[j]]*cou[Q[j]]*cou[R[j]];
    }
        printf("%lld",ans);
        return 0;
}

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

int main(){
  ll n,k,K,a[100010],b[42]={},ans=0;
  cin>>n>>k;
  fr(i,42){
    if(k>>i==0){K=i;break;}
  }
  fr(i,n) cin>>a[i];
  fr(i,n){
    fr(j,42){
      if((a[i]>>j)&1){
        b[j]++;
      }
    }
  }
  if(k==0){
//    fr(i,42) cout<<(1<<i)*b[i]<<endl;;
    fr(i,42) ans+=((ll)1<<i)*b[i];
    cout<<ans<<endl;
    return 0;
  }
//  fr(j,42) cout<<b[j]<<endl;
  ll kari2=0;
  for(int l=K;l<42;l++) kari2+=((ll)1<<l)*b[l];
  fr(i,K){
    ll kari=kari2,j=K-1-i;
    if((k>>j)&1){
      kari+=((ll)1<<j)*b[j];
      fr(l,j) kari+=((ll)1<<l)*max(b[l],n-b[l]);
      ans=max(ans,kari);
      kari2+=((ll)1<<j)*(n-b[j]);
      if(j==0) ans=max(ans,kari2);
    }
    else{
      kari2+=((ll)1<<j)*b[j];
      if(j==0) ans=max(ans,kari2);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
def main():
    """
    1 <= N  <= 10^9

    七五三数とは以下の条件を満たす正の整数
    十進法で表記したとき、
    数字 7, 5, 3 がそれぞれ 1回以上現れ、これら以外の数字は現れない
    """
    N = int(input())

    ans = f(N)
    print(ans)


def f(N):
    """
    Nの桁数がdのとき、d-1桁の数で753数であれば満たす
    上記d-1桁の753数に対して、
    753のそれぞれの数について
    桁追加をして、それがN以下であれば良い

    もっと簡単に考える
    d桁のとき並べる数字は3種類とその桁を使わないときに0埋めすると考えられる
    よって、並べ方の最大は (3+1)^9 = 262,144
        実際は実装上 349,525
    """
    d = len(str(N))
    ans = run_perm(N, d, [0, 3, 5, 7])
    # ans = TLE(N)

    return ans


def run_perm(N, d, types):
    """
    全列挙: TLE, 文字列処理がダメ

    http://www.geisya.or.jp/~mwm48961/kou3/onajimono1.htm
    による並べ方をやろうとしたけど断念
    """
    from collections import Counter
    a = [0] * d
    # nth = 0

    def perm(N, i, d, ans):
        # nonlocal nth
        # nth += 1

        if i == d:
            s = "".join(str(x) for x in a).lstrip("0")
            c = Counter(s)
            if c["0"] == 0 and \
                c["7"] >= 1 and \
                c["5"] >= 1 and \
                c["3"] >= 1 and \
                    int(s) <= N:

                ans += 1

            return ans

        for t in types:
            a[i] = t
            ans = perm(N, i+1, d, ans)

        return ans

    ans = perm(N, 0, d, 0)
    # print(nth)

    return ans


def TLE(N):
    ans = 0
    for i in range(357, N + 1):
        s = str(i)
        c7, c5, c3 = s.count("7"), s.count("5"), s.count("3")
        if len(s) == c7 + c5 + c3 and \
                c7 >= 1 and c5 >= 1 and c3 >= 1:
            ans += 1

    return ans


if __name__ == '__main__':
    main()


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

#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORTASC(c) sort((c).begin(), (c).end())
#define SORTDESC(c, t) sort((c).begin(), (c).end(), std::greater<t>());
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

const double PI = acos(-1.0);

using ll = long long;
using namespace std;

int main()
{
    string s;

    cin >> s;

    int first_half  = stoi(s.substr(0, 2));
    int second_half = stoi(s.substr(2));

    if (1 <= first_half && first_half <= 12 &&
        1 <= second_half && second_half <= 12){
        cout << "AMBIGUOUS"  << endl;
    } else if (1 <= first_half && first_half <= 12) {
        cout << "MMYY" << endl;
    } else if (1 <= second_half && second_half <= 12) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }

    return 0;
}

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

int calc_digit(long long N) {
    int res = 0;
    while (N) {
        ++res;
        N /= 10;
    }
    return res;
}

int main() {
    long long N;
    cin >> N;
    int res = (1<<29); // 十分大きい値で初期化
    for (long long A = 1; A * A <= N; ++A) {
        if (N % A == 0) {
            long long B = N / A;
            int F = max(calc_digit(A), calc_digit(B));
            res = min(res, F);
        }
    }
    cout << res << endl;
}

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

int main() {
  string s;cin>>s;
  s.at(5) = ' ';
  s.at(13) = ' ';
  cout << s << endl;
}


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

constexpr int K = 10;

void solve() {
    int n, k;
    std::cin >> n >> k;

    std::vector<std::vector<int>> css(K);
    while (n--) {
        int c, g;
        std::cin >> c >> g;
        css[--g].push_back(c);
    }

    std::vector<int> dp(k + 1, 0);

    for (auto& cs : css) {
        std::sort(cs.rbegin(), cs.rend());
        int m = cs.size();
        std::vector<int> sums(m + 1, 0);

        for (int i = 0; i < m; ++i) sums[i + 1] = sums[i] + cs[i];
        for (int i = 1; i <= m; ++i) sums[i] += i * (i - 1);

        for (int i = k; i >= 0; --i) {
            for (int d = 0; d <= m && i - d >= 0; ++d) {
                dp[i] = std::max(dp[i], dp[i - d] + sums[d]);
            }
        }
    }

    std::cout << dp[k] << "\n";
}

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

    solve();

    return 0;
}



Measured memory_bytes: 3204
a, b, c, d = map(int, input().split())
s = 0
start = a // c
end = b // c
if start * c < a:
    s += end - (start + 1) + 1
else:
    s += end - start + 1
if d % c != 0:
    start = a // d
    end = b // d
    if start * d < a:
        s += end - (start + 1) + 1
    else:
        s += end - start + 1
    def gcd(x, y):
        while y != 0:
            (x, y) = (y, x % y)
        return x
        return gcd
    last = c * d // gcd(c, d)
    start = a // last
    end = b // last
    if start * last < a:
        s -= end - (start + 1) + 1
    else:
        s -= end - start + 1
print((b - a + 1) - s)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

void gen() {exit(0);}
int main() {
    #ifdef DEBUG
//    freopen("input", "r", stdin);
//    freopen("output", "w", stdout);
//    gen();
    #endif
    
    int n;
    scanf("%d", &n);
    int x = n / 1000;
    cout << "AB" << (char)('C' + x) << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))

import bisect
ans=0
for i in B:
  a=bisect.bisect_left(A,i)
  b=N-bisect.bisect_right(C,i)
  ans+=a*b
print(ans)

Measured memory_bytes: 22452
import bisect
N,M,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

SumA = [0]
SumB = [0]
cnt = 0
for i in range(N):
    SumA.append(SumA[i] + A[i])
for i in range(M):
    SumB.append(SumB[i] + B[i])

for i in range(N+1):
    if SumA[i] > K:
        break
    tmpcnt = bisect.bisect_right(SumB, K - SumA[i]) - 1
    #print([SumA,SumB])
    #print(SumA[i])
    #print(K - SumA[i])
    #print(tmpcnt)
    #print([i,tmpcnt])
    cnt = max(cnt, i + tmpcnt)
print(cnt)





Measured memory_bytes: 132572
#include  "bits/stdc++.h"
//#include  <iostream>
 using namespace std;
 
#define IOS         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define mem(a,v)    memset((a), (v), sizeof (a))
#define FOR(i,a,n)  for(int i = (a); i<(n); ++i) 
#define FORE(i,a,n) for(int i = (a); i<=(n); ++i)
#define mp(a , b)   make_pair(a , b)
#define pb(a)       push_back(a)

#define anal         '\n'

#define M 1000000007 
typedef long long ll;


int main(){
     
    IOS;
    
   // freopen("input.in", "r", stdin);
    //freopen("output.in", "w", stdout);
    
   int n, m;
    cin>>n>>m;
    
    int a[m];
    ll s = 0;
    
    FOR(i,0,m){
        cin>>a[i];
         s += a[i];
     }
     
     if(s <= n) cout<<(n - s);
     else cout<<"-1";     


 

  return  0 ;
   	    
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
class P{
public static List<long> a=new List<long>();
  static void Main(){
     long n=long.Parse(Console.ReadLine());
     foreach(long x in new long[]{3,5,7})b(x,n);
     Console.WriteLine(a.Count(x=>3==x.ToString().ToCharArray().Distinct().Count()));
  }
  static void b(long num,long lim){
    if(num<=lim){
      a.Add(num);
      b(num*10+3,lim);
      b(num*10+5,lim);
      b(num*10+7,lim);
    }
  }
}

Measured memory_bytes: 17992
#include<iostream>
#include<cstdio>
#include<cstring>
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<=0 && b>=0)printf("Zero\n");
	else if(a>0 || (((b-a+1)%2)==0))printf("Positive\n");
	else printf("Negative\n");
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

	    while(true){
			
		//縦Hと横Wの値を受け取る
		String s1 = sc.next();
	        int H = Integer.parseInt(s1);
	        String s2 = sc.next();
	        int W = Integer.parseInt(s2);
	        
	        //値が条件（３００以下であるか）にあっているか確認
	        if(H <= 300 && W <= 300){
	        
	            //０と０が入力された時プログラムは終了する
	            if(H == 0 && W == 0){
	        	    break;
	            }
	            
	            //長方形になるよう出力
	            for(int i = 1; i <= H; i++){
	            	
	            	//奇数行のときは”＃””.”の順番で表示
	            	if(i % 2 == 1){
	            		for(int j = 1; j <= W; j++){
	            			if(j % 2 == 1){
	            				System.out.print("#");
	            			}
	            			else{
	            				System.out.print(".");
	            			}
	            		}
	            	}
	            	
	            	//偶数行のときは”.””#”の順番で表示
	            	else{
	            		for(int j = 1; j <= W; j++){
	            			if(j % 2 == 1){
	            				System.out.print(".");
	            			}
	            			else{
	            				System.out.print("#");
	            			}
	            		}
	            	}
	            	System.out.println("");
	            }
	            System.out.println("");
	        }
	    }     
	}
}

Measured memory_bytes: 25748
#include <bits/stdc++.h>
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (int)(n); (i) += (step))
#define ROF(i, a, n, step) for (int (i) = (a); (i) >= (int)(n); (i) += (step))
#define FOREACH(it, v) for (auto (it) : (v))

using namespace std;

typedef unsigned long long ull;
typedef long long ll ;
typedef long double ld;
typedef pair <int, int> pii;

template <class T>
const bool is_impar(const T &x) {return (bool) (x & 1);}

int a, b;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> a >> b;
    if (a + b == 15)
        cout << '+';
    else if (a * b == 15)
        cout << '*';
    else cout << 'x';
}

Measured memory_bytes: 384
#from fractions import gcd
#A,B = map(int, input().split())
#print(A*B//gcd(A,B))
def gcd(a,b):
    if(a<b):
         b,a=a,b
    if(b==0):
        return a
    r = a%b
    if(r!=0) :
        a,b,r=b,r,b%r
        return gcd(b,r)
    else:
        return b

A,B = map(int, input().split())
print(A*B//gcd(A,B))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int a, b, c, d;
int main() {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if(abs(a - c) <= d)
    {
        printf("Yes\n");
    }
    else if(abs(a - b) <= d && abs(b - c) <= d)
    {

        printf("Yes\n");
    }
    else printf("No\n");
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] list = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            list[i] = sc.nextInt();
            sum += list[i];
        }

        int ave = (int)Math.round((double)sum / n);

        int ans = 0;

        for (int i = 0; i < n; i++) {
            int value = Math.abs(list[i] - ave);
            ans += value * value;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb(a) push_back(a)
typedef long double ld;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ld> vd;
typedef vector<vd> vvd;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;
const ll INF = 0x3f3f3f3f;
const ll inf =  pow(10,18);
ll modulo = pow(10,9) + 7;
#define MAX (int)(pow(10,6) + 10)

ll pow_mod(ll a, ll b){
	a = a%modulo;
	ll has = 1;
	for(ll i = 62; i>-1; i--){
		has*=has;
		has%=modulo;
		if(((ll)1<<i)&b)
			has*=a, has%=modulo;
	}
	return has;
}

ll inv(ll a){
	return pow_mod(a, modulo-2);
}


ll fkt[MAX];
ll inv_fkt[MAX];

void pre(){
	fkt[0] = 1;
	inv_fkt[0] = 1;
	for(ll i = 1; i<MAX; i++){
		fkt[i] = fkt[i-1] * i;
		fkt[i] %= modulo;
		inv_fkt[i] = inv(fkt[i]);
	}
}

ll kmb(ll i, ll j){
	return fkt[i]*inv_fkt[j]%modulo*inv_fkt[i-j]%modulo;
}

vector<ll> active(set<ll> all){
	return vector<ll>(all.begin(), all.end());
}

void deal(){
	pre();
	ll h ,w , badcount;
	cin>>h>>w>>badcount;
	vector<pair<ll,ll> > bad;
	vector<ll> save;
	fori(badcount){
		ll x,y;
		cin>>x>>y;
		bad.pb(mp(x,y));
	}
	sort(bad.begin(), bad.end());
	ll ans = kmb(h-1+w-1, h-1);
	fori(bad.size()){
		ll x = bad[i].ff, y = bad[i].ss;
		ll cur = kmb(x-1+y-1, x-1);
		forj(i){
			ll x1 = bad[j].ff, y1 = bad[j].ss;
			if(x1 <= x && y1 <= y){
				ll minus = save[j] * kmb(x-x1+y-y1, x-x1);
				minus %= modulo;
				cur -= minus;
				cur += modulo;
				cur %= modulo;
			}
		}
		save.pb(cur);
		ll mult = kmb(h-x+w-y, h-x);
		mult *= cur;
		mult %= modulo;
		ans-=mult;
		ans+=modulo;
		ans%=modulo;
	}
	cout<<ans;
}

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

















Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	int k = 1;
	rep(i,n){
		if(a.at(i) == k) k++;
	}
	if(k == 1) cout << -1 << endl;
	else cout << n - k + 1 << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[6]={0};
	for(int i=0;i<5;i++)
	{
		int v;cin>>v;
		a[v]++;
	}
	for(int i=0;i<6;i++)
		if(a[i]==0)
			cout<<i;
	return 0;
 } 

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
map<char,vector<int> > mp;
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	string s,t; cin>>s>>t;
	for(int i=0; i<(int)s.length(); i++) {
		mp[s[i]].push_back(i);
	}
	int cur=-1;
	ll tot=0;
	for(int i=0; i<(int)t.length(); i++) {
		if(!(int)mp[t[i]].size()) {
			cout<< -1<<endl;
			return 0;
		}
		else{
			int ans=-1;
			int l=0;
			int r=mp[t[i]].size()-1;
			while(l<=r) {
				int mid=(l+r)/2;
				if(mp[t[i]][mid]>cur) {
					ans=mp[t[i]][mid];
					r=mid-1;
				}
				else{
					l=mid+1;
				}
			}

			if(ans==-1) {

				int diff=((int)s.length()-cur)+mp[t[i]][0];
				//cout<<cur<<" "<<mp[t[i]][0]<<" "<<diff<<endl;;

				tot+=diff;
				cur=mp[t[i]][0];
			}
			else{
				tot+=(ans-cur);
				cur=ans;
			}
		}
		//cout<<i<<" "<<cur<<endl;
	}

	cout<<tot<<endl;
	return 0;
}


Measured memory_bytes: 1228
import math

A, B, H, M = map(int, input().split())

x = abs(6 * M - (30 * H + 0.5 * M))
if x > 180:
    x = 360 - x

c = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(x)))

print(c)


Measured memory_bytes: 9276
n = int(input())
a = list(map(int, input().split()))


count = 0

while True:
  even_count = 0
  for i in range(n):
    if a[i] % 2 == 0:
      even_count += 1

  if even_count == len(a):
    a = list(map(lambda x : x // 2, a))
    count += 1

  else:
    break

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	LL sides[3];
	rep(i, 0, 3)	sides[i] = scanLong();
	sort(sides, sides+3);
	LL area = (sides[0]*sides[1])/2;
	pll(area); nl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

class uft{
  vector<int>p,rank;
public:
  map<int,int>mp;
  uft(){}
  uft(int size){
	p.resize(size,0);
	rank.resize(size,0);
	for(int i=0;i<size;++i)
	  make_uft(i);
  }
  void make_uft(int x){
	p[x]=x;rank[x]=0;
	mp[x]=1;
  }
  bool same(int x, int y){return find_par(x)==find_par(y);}
  void unite(int x,int y){link(find_par(x),find_par(y));}
  void link(int x,int y){
	if(rank[x]>rank[y]){
	  p[y]=x;
	  int t=mp[y];
	  mp.erase(y);
	  mp[x]+=t;
	}
	else{
	  p[x]=y;
	  int t=mp[x];
	  mp.erase(x);
	  mp[y]+=t;
	  if(rank[x]==rank[y])
		++rank[y];
	}
  }
  int find_par(int x){
	if(x!=p[x])
	  p[x]=find_par(p[x]);
	return p[x];
  }
};

int main(){
  pair<int,int>bridge[100010];
  long long n,m;cin>>n>>m;
  for(int i=m-1;i>=0;--i){
	cin>>bridge[i].first>>bridge[i].second;
	bridge[i].first--;bridge[i].second--;
  }

  long long count[100010]={n*(n-1)/2};
  uft ut(n);
  for(int i=1;i<m;++i){
	int a=bridge[i-1].first,b=bridge[i-1].second;
	if(ut.same(a,b)){count[i]=count[i-1];continue;}
	count[i]=count[i-1]-ut.mp[ut.find_par(a)]*ut.mp[ut.find_par(b)];
	ut.unite(a,b);
  }
  for(int i=m-1;i>=0;--i)
	cout<<count[i]<<endl;
  return 0;
}


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

using namespace std;

int main(){
	long long a, b, x;
	scanf("%lld %lld %lld", &a, &b, &x);
	long long k = a / x;
	if (k * x < a)
		k = (k + 1) * x;
	else 
		k = k * x;
	long long s = b / x;
	if ((s + 1) * x == a)
		s = (s + 1) * x;
	else 
		s = s * x;
	printf("%lld\n", (s - k) / x + 1);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    ll x,y,z,k;
    vector<ll> a,b,c;
    cin >>x>>y>>z>>k;
    ll tmp;

    rep(i,x){
        cin >> tmp;
        a.push_back(tmp);
    }
    rep(i,y){
        cin >> tmp;
        b.push_back(tmp);
    }
    rep(i,z){
        cin >> tmp;
        c.push_back(tmp);
    }
    sort(a.begin(),a.end(),greater<ll>());
    sort(b.begin(),b.end(),greater<ll>());
    sort(c.begin(),c.end(),greater<ll>());
    vector<ll> res;
    rep(i,x){
        rep(j,y){
            if(i*j>3000)break;
            rep(l,z){
                if(i*j*l>3000)break;
                res.push_back(a[i]+b[j]+c[l]);
            }
        }
    }
    sort(res.begin(),res.end(),greater<ll>());
    rep(i,k){
        cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 35184
import java.util.*;
import java.lang.*;
import java.util.stream.*;
import java.util.function.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // String[] firstArr = sc.nextLine().split(" ");
        // System.out.println(solve(getInputAsArray(sc, "1")));
        System.out.println(solve(sc.nextLine().split(" ")));
    }

    private static List<String[]> getInputAsArray(Scanner sc, String count) {
        List<String[]> result = new ArrayList<>();
        IntStream.range(0, Integer.parseInt(count)).forEach(i -> result.add(sc.nextLine().split(" ")));
        return result;
    }

    private static Long[] convertStrToInt(String[] strArray) {
        return Arrays.stream(strArray).map(e -> new Long(Long.parseLong(e))).toArray(Long[]::new);
    }

    private static long outputResult(long a, long b) {
        return LongStream.range(0, b).reduce((long) 0, (sum, i) -> sum += (Math.pow(10, i) * a));
    }

    // private static String solve(List<String[]> input) {
    private static String solve(String[] input) {
        long a = Long.parseLong(input[0]);
        long b = Long.parseLong(input[1]);
        long k = Long.parseLong(input[2]);

        if (a >= k) {
            return String.valueOf(a - k) + " " + String.valueOf(b);
        } else {
            if (a + b >= k) {
                return String.valueOf(0) + " " + String.valueOf(b - k + a);
            } else {
                return String.valueOf(0) + " " + String.valueOf(0);
            }
        }
    }
}

class Resp {
    private long min = Long.MAX_VALUE;
    private int cont = 0;

    public Resp(long min, int cont) {
        this.min = min;
        this.cont = cont;
    }

    public long getMin() {
        return this.min;
    }

    public void setMin(long min) {
        this.min = min;
    }

    public int getCont() {
        return this.cont;
    }

    public void setCont(int cont) {
        this.cont = cont;
    }

    public void addCont() {
        this.cont++;
    }

}


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

#define f first
#define s second
using namespace std;
typedef long long ll;
const ll minn=-1e9;
const ll limit = 1e6+2;
long long a,b,c;
long long t,n,k,temp=0,m,res=0,tp,mp,op,check=1,lp,d=0,s,w;

int main()
{
    cin>>a>>b>>c>>d;
    if (a%d!=0)a=a/d+1;
    else a=a/d;
    if (c%b!=0)c=c/b+1;
    else c=c/b;
    if (a>=c)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3632
use std::io::Read;

fn lower_bound(v: &Vec<i32>, x: i32) -> i32 {
    let mut l: i32 = 0;
    let mut r: i32 = v.len() as i32;

    loop {
        if l==r {
            break;
        }
        let c: i32 = (l + r)/2;
        match v[c as usize].cmp(&x) {
            std::cmp::Ordering::Less => {
                l = c + 1;
            }
            std::cmp::Ordering::Equal | std::cmp::Ordering::Greater => {
                r = c;
            }
        }
    }
    l
}

fn main() {
    let mut buf = String::new();
    let _ = std::io::stdin().read_to_string(&mut buf);
    let mut it = buf.split_whitespace();
    let n: i32 = it.next().unwrap().parse().unwrap();
    let m: i32 = it.next().unwrap().parse().unwrap();
    let x: i32 = it.next().unwrap().parse().unwrap();
    let a: Vec<i32> = (0..m).map(|_| {
        it.next().unwrap().parse().unwrap()
    }).collect();

    let x_idx = lower_bound(&a, x);
    let ans = std::cmp::min(x_idx, m-x_idx);
    println!("{}", &ans);
}


Measured memory_bytes: 4352
#include <iostream>
 
int main(void)
{
 
    int N = 0;
    std::cin >> N;
 
    int f = 0;
    int temp = N;
    while(temp!=0){
        f += temp % 10; 
        temp /= 10; 
    }   
    std::cout << (N % f == 0 ? "Yes" : "No") << std::endl;
 
    return 0;
}

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

int main(){

	int a,b,c,n;
	cin >> n;

	for(int i=0; i<n; i++){
		cin >> a >> b >> c;
		if(a*a+b*b==c*c) cout << "YES" << endl;
		else if(a*a+c*c==b*b) cout << "YES" << endl;
		else if(b*b+c*c==a*a) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
    return 0;
}

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

typedef long long ll;

int x_point[11][11];


int func(int i , int j, int D){
    int sum = 0;
    for (int d = 0; d < D; d++)
    {   
        sum += (x_point[i][d] - x_point[j][d]) * (x_point[i][d] - x_point[j][d]);
    }
    //printf("%d", sum);
    for (int k = 0; k < 150; k++)
    {
        if (sum == (k*k)){
            return 1;
        }
    }
    return 0;
}

int main()
{
    int D,N;
    cin >> N >> D;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < D; j++)
        {
            int tmp;
            cin >> tmp;
            x_point[i][j] = tmp; 
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            ans += func(i , j, D);
        }        
    }
    
    cout << ans << endl;
}



Measured memory_bytes: 256
/*"You can do anything you set your mind to,man" - Eminem*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define llpow(a,b) (ll)(pow(a,b)+0.5)
#define l_b(a,val) min((int)a.size()-1, (int)(lower_bound(a.begin(),a.end(),val)-a.begin()))
#define f first
#define up(a,b) max(a,b)
#define s second
#define INF 1e18L+5
const  int mod = 1000000007;
void add(ll& a, ll b){a+=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
void mul(ll& a, ll b){a*=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
void up_self(ll& a, ll b){a = up(a,b);}
void min_self(ll& a, ll b){a = min(a,b);}
ll binexpomodulo(ll x, ll y){ll res =1;x%=mod;if(!x)return 0;while(y){if(y&1){mul(res, x);}mul(x,x);y>>=1;}return res;}
ll nCrInOr(ll n, ll r){ll res = 1;if(r>n-r)r = n-r;ll rin = 1;for(ll i = 1; i <=r ; i++)rin = (rin*i)%mod;rin = binexpomodulo(rin,mod-2);for(ll i = 1; i <= r; i++)res = (res*(n-i+1))%mod;res = (res*rin)%mod;return res;}
int msb(ll n){int ans;for(int i = 0 ; i < 64;  i++)if(n&(1LL<<i))ans = i+1;return ans;}
void strrev(string& s){int n = (s.size());for(int i = 0 ; i < n/2; i++)swap(s[i],s[n-1-i]);}
int main()
{
	int n,w; cin>>n>>w;
	vector<int> weight(n), values(n);
	ll sum = 0;
	for(int i = 0 ; i < n ; i++){
		cin>>weight[i]>>values[i];
		sum+=values[i];
	}
	vector<ll> dp(sum+1,INF);
	dp[0] = 0;
	for(int i = 0 ; i < n ; i++){
		for(int val_already = sum-values[i]; val_already>=0; val_already--){
			min_self(dp[val_already+values[i]], dp[val_already] + weight[i]);
		}
	}
	ll ans = -1;
	for(int i =0  ; i <=sum; i++)
	{
		if(dp[i]<=w)
			ans = i;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn exe(k: u32, n: usize, a: Vec<u32>) -> u32 {
    let mut max = 0;
    for i in 0..n-1 {
        let dis = a[i+1] - a[i];
        if max < dis {
            max = dis;
        }
    }
    let dis = a[0] + (k - a[n-1]);
    if max < dis {
        max = dis;
    }
    return k - max;
}

fn main() {
    input! {
        k: u32,
        n: usize,
        a: [u32;n],
    }
    let ans = exe(k, n, a);
    println!("{}", ans);
}

#[test]
fn test() {
    assert_eq!(exe(20, 3, vec![5,10,15]), 10);
    assert_eq!(exe(20, 3, vec![0,5,15]), 10);
}


Measured memory_bytes: 6396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		String ans = "";
		ans = calc(n) ? "Yes" : "No";
		System.out.println(ans);
	}

	public static boolean isPrime(int n) {
		if (n % 2 == 0)
			return true;
		for (int i = 3; i <= 100; i += 2) {
			if (n % i == 0)
				return true;
		}
		return false;
	}

	public static boolean calc(int n) {
		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				if (i * j == n)
					return true;
			}
		}
		return false;
	}

}


Measured memory_bytes: 21972