akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 200005;
const int K = 50;
pair < int, int > a[N];
vector < pair < int, int > > b;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i].F >> a[i].S;
        if (a[i].S > a[i].F) swap(a[i].F, a[i].S);
    }
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
    int rmax = a[1].F;
    int rmin = a[1].F;
    int bmax = a[1].S;
    int bmin = a[1].S;
    int ans = 2e18;
    int p = 1;
    int x = a[1].S;
    for (int i = 2; i <= n; i++){
        if (x > a[i].S){
            p = i;
            x = a[i].S;
        }
        if (x > a[i].F){
            p = -i;
            x = a[i].F;
        }
    }
    if (p == 1){
        bmin = x;
       for (int i = 2; i <= n; i++){
            if (a[i].F > a[i].S) swap(a[i].F, a[i].S);
            rmin = min(rmin ,a[i].S);
            bmax = max(bmax, a[i].F);
       }
       ans = (rmax - rmin) * (bmax - bmin);
       cout << ans;
       return 0;
    } else{
        if (p < 0){
            bmin = a[-p].F;
            rmin = min(rmin, a[-p].S);
        }
        else{
            bmin = a[p].S;
            rmin = min(rmin, a[p].F);
        }
        p = abs(p);
        for (int i = 2; i <= n; i++){
            if (i == p) continue;
            if (a[i].F > a[i].S) swap(a[i].F, a[i].S);
            rmin = min(rmin ,a[i].S);
            bmax = max(bmax, a[i].F);
       }
       ans = (rmax - rmin) * (bmax - bmin);
    }
    rmax = a[1].F;
    rmin = x;
    int y;
    if (p < 0) y = a[-p].S; else y = a[p].F;
    bmax = max(a[1].S, y);
    bmin = min(a[1].S, y);
    for (int i = 2; i <= n; i++){
        if (i == p) continue;
        if (a[i].F < bmin && a[i].S < bmin){
            bmin = max(a[i].F, a[i].S);
        } else
        if (a[i].F > bmax && a[i].S > bmax){
            bmax = min(a[i].F, a[i].S);
        } else
        if (a[i].F <= bmax && a[i].F >= bmin) continue; else
        if (a[i].S <= bmax && a[i].S >= bmin) continue; else
        if (a[i].F > a[i].S){
            swap(a[i].F, a[i].S);
            b.pb({a[i].F, a[i].S});
        } else b.pb({a[i].F, a[i].S});
    }
    sort(b.begin(), b.end());
    if (b.empty()){
        ans = min(ans, (rmax - rmin) * (bmax - bmin));
    } else{
        int rb = bmax;
        for (int i = 0; i < b.size(); i++){
            ans = min(ans, (rmax - rmin) * (max(rb, bmax) - min(b[i].F, bmin)));
            rb = max(rb, b[i].S);
        }
    }
    cout << ans;
}


Measured memory_bytes: 4600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define Vector vector<ll>
vector<Vector> dp;
#define rr(f) f.begin(),f.end()
int main() {
	ll t = 1;
	ll i, j, k, l, r;
	//cin>>t;
	while(t-->0)
	{
	    int n; cin>>n;
	    Vector v(n),dp(n+1,0);
	    for(i=0; i<n; i++) cin>>v[i];
	    for(i=n-2; i>=0; i--)
	    {
	        if(i == n-2)
	        {
	            dp[i] = abs(v[i+1] - v[i]);
	        }
	        else 
	        {
	            dp[i] = min(abs(v[i+1]-v[i]) + dp[i+1] , abs(v[i+2]-v[i]) + dp[i+2]);
	        }
	    }
	    cout<<dp[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

vll Eratosthenes(ll N){
    vll a(N + 1, 1);
  	for(ll i = 0; i < N; i++){
		a[i] = 1;
	}
	for(ll i = 2; i < sqrt(N); i++){
		if(a[i]){
			for(ll j = 0; i * (j + 2) < N; j++){
				a[i *(j + 2)] = 0;
			}
		}
	}
    a[0] = a[1] = 0;
    return a;
}

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

    ll q;
    cin >> q;
    ll l, r;

    vll isprime = Eratosthenes(1e5 + 10);
    vll sss(1e5 + 11);
    REP(i, 1e5 + 10){
        if(i == 0) continue;
        sss[i] = sss[i - 1] + isprime[i] * isprime[(i + 1) / 2];
    }
    while(q){
        cin >> l >> r;
        ll res = sss[r] - sss[l - 1];
        cout << res << endl;
        q--;
    }
    return 0;
}

Measured memory_bytes: 2176
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
  int k, a, b;
  cin >> k;
  cin >> a >> b;
  for(int i = a; i <= b; ++i) {
    if (i % k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


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


int main() {
  string s;
  cin >> s;
  int ans=0;
  rep(i,s.size()-1){   
    if(s.at(i)!=s.at(i+1)){
      ans++;
    }
  }
  
 
 cout<<ans<<endl;
  
}

Measured memory_bytes: 512
#include<iostream>
main(){for(int a,b,d,x,y,i,t;std::cin>>a>>b>>d,d;printf("%d %d\n",x,y)){x=y=1<<29;for(i=1<<16;i-->0;){t=d-a*i;if(!(d<a*i|t%b)&&x+y>i+t/b|(x+y==i+t/b&a*x+b*y>a*i+t)){x=i;y=t/b;}t=a*i-d;if(!(a*i<d|t%b)&&x+y>i+t/b|(x+y==i+t/b&a*x+b*y>a*i+t)){x=i;y=t/b;}t=a*i+d;if(t%b==0&&x+y>i+t/b|(x+y==i+t/b&a*x+b*y>a*i+t)){x=i;y=t/b;}}}}

Measured memory_bytes: 868
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int *dp = new int[n];
  for(int i=0;i<n;i++)
    dp[i] = INT_MAX;
  dp[0]=0;
  int *arr = new int[n];
  for(int i=0;i<n;i++)
	cin >> arr[i];
  for(int i=0;i<n;i++){
    for(int j=i+1;j<=i+2;j++){
	if(j<n)
	  dp[j]=min(dp[j],dp[i]+abs(arr[i]-arr[j]));
    }

  }
  cout<<dp[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    string str;
    long long N, i, ans=0;
    map <string, long long> mp;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> str;

        sort(str.begin(), str.end());

        mp[str]++; // mpの2番目を文字列が出現した回数にする
    }

    for(auto a : mp){
        auto x = a.second;

        ans += x*(x-1)/2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<vector>

using namespace std;

#define rep(i,n) for(int i=0;i<n;++i)

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(M);
  rep(i,M) {
    int k;
    cin >> k;
    S[i].resize(k);
    rep(j,k){
      cin >> S[i][j];
      --S[i][j];
    }
  }
  
  vector<int> P(M);
  rep(i,M) cin >> P[i];
  int ans = 0;
  rep(i, 1<<N){
    bool ok = true;
    rep(j,M){
      int x = 0;
      rep(k,S[j].size()) if ((i >> S[j][k] & 1)) ++x;
      x %= 2;
      if (x != P[j]) ok = false;
    }
    if (ok) ++ans;
  }
  cout << ans << endl;          
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n=3;
    vector<vector<int>>g(3, vector<int>(3));
    vector<vector<bool>>f(3, vector<bool>(3,false));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>g[i][j];
        }
    }
    cin>>n;
    vector<int> bin(n);
    for(int i=0;i<n;i++){
        cin>>bin[i];
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            for(int k =0;k<n;k++){
                if(bin[k] == g[i][j]){
                    f[i][j] = true;
                    break;
                }
            }
        }
    }
    for(int i=0;i<3;i++){
        bool t= 1;
        for(int j=0;j<3;j++){
            t= t&f[i][j];
        }
        if(t==1){cout<<"Yes";
        return 0;}
    }
    for(int i=0;i<3;i++){
        bool t= 1;
        for(int j=0;j<3;j++){
            t= t&f[j][i];
        }
        if(t==1){cout<<"Yes";
        return 0;}
    }
    if(f[0][0]&&f[1][1]&&f[2][2]){
        cout<<"Yes";
        return 0;
    }
    if(f[0][2]&&f[1][1]&&f[2][0]){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		char[] cs=sc.next().toCharArray();
		int ans=700;
		for(char c:cs) if(c=='o')ans+=100;
		pw.println(ans);
		pw.close();
	}

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

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
#define INF 10000000

int main(){
  int com[]={4,1,4,1,2,1,2,1};
  int c[8]={0};
  while(cin >> c[0]){
    for(int i=1;i<8;i++){
      cin >> c[i];
    }
    int nmin = INF;
    int pos = 0;
    int mmin = 0;
    for(int i=0;i<8;i++){
      int sum = 0;
      for(int j=0;j<8;j++){
	sum += max(0,c[j] - com[(i+j)%8]);
      }
      int tmp = 0;
      int cou = 7;
      for(int z=0;z<8;z++){
	tmp += com[(i+z)%8] * (int)pow(10,(double)cou);
	cou--;
      }
      if(nmin > sum || (nmin == sum && tmp < mmin)){
	pos = i;
	nmin = sum;
	int cou = 7;
	mmin = 0;
	for(int z=0;z<8;z++){
	  mmin += com[(i+z)%8] * (int)pow(10,(double)cou);
	  cou--;
	}
      }
    }
    bool flg=false;
    for(int i=0;i<8;i++){
      if(flg) cout << " ";
      cout << com[(pos+i)%8];
      flg = true;
    }
    cout << endl;
  } 
}

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

int main(){
    int n,q;
    string s;
    cin >> n >> q;
    cin >> s;
    vector<int> sum(n+1,0);
    for(int i=0;i<n;i++){
        if(s[i]=='A' && s[i+1]=='C'){
            sum[i+1] = sum[i]+1;
        }else{
            sum[i+1] = sum[i];
        }
    }
    int ans[q];
    for(int i=0;i<q;i++){
        int l,r;
        cin >> l >> r;
        l--;
        r--;
        ans[i] = sum[r] - sum[l];
    }
    for(int i=0;i<q;i++){
        cout << ans[i] << endl;
    }
}

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

using namespace std;

typedef long long LL;
typedef vector<int>    VI;
typedef vector<bool>   VB;
typedef vector<string> VS;

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int main(void) {
	int n;
	cin >> n;
	rep (i, n) {
		string order, msg;
		cin >> order >> msg;
		reverse(ALL(order));
		rep (j, order.size()) {
			switch (order[j]) {
				case 'J':
					msg = msg[msg.size() - 1] + msg.substr(0, msg.size() - 1);
					break;
				case 'C':
					msg = msg.substr(1) + msg[0];
					break;
				case 'E':
					if (msg.size() % 2) {
						string s1 = msg.substr(0, msg.size() / 2);
						string s2 = msg.substr(msg.size() / 2 + 1);
						msg = s2 + msg[msg.size() / 2] + s1;
					} else {
						string s1 = msg.substr(0, msg.size() / 2);
						string s2 = msg.substr(msg.size() / 2);
						msg = s2 + s1;
					}
					break;
				case 'A':
					reverse(ALL(msg));
					break;
				case 'P':
					for (char &c : msg) {
						if ('0' <= c && c <= '9') {
							c = (c == '0'? '9' : c - 1);
						}
					}
					break;
				case 'M':
					for (char &c : msg) {
						if ('0' <= c && c <= '9') {
							c = (c == '9'? '0' : c + 1);
						}
					}
					break;
				default:
					break;
			}
		}
		cout << msg << endl;
	}

    return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
const int N=200005;
int s[N],vis[N],n,a[N],f,r[N];
char ss[N];
long long ans;
std::vector<int> e[26];
int lowbit(int x){
	return x&(-x);
}
void upd(int x,int y){
	if (!x) return;
	while (x<=n){
		s[x]+=y;
		x+=lowbit(x);
	}
}
int getsum(int x){
	if (!x) return 0; 
	int ret=0;
	while (x){
		ret+=s[x];
		x-=lowbit(x);
	} 
	return ret;
} 
int sum(int l,int r){
	if (l>r) return 0;
	return getsum(r)-getsum(l-1);
}
int main(){
	scanf("%s",ss+1);
	n=strlen(ss+1);
	for (int i=1;i<=n;i++){
		a[i]=ss[i]-'a';
		e[a[i]].push_back(i);
	} 
	for (int i=0;i<26;i++){
		int siz=e[i].size();
		if (siz&1) f++;
		for (int j=0,p=siz-1;j<p;j++,p--) r[e[i][j]]=e[i][p];
	}
	if (f>1){
		puts("-1");
		return 0;
	}
	for (int i=1;i<=n;i++) upd(i,1);
	for (int i=1;i<=n;i++){
		if (vis[i]) continue;
		if (!r[i]) ans+=sum(i+1,n)/2;
		else ans+=sum(r[i]+1,n);
		upd(i,-1);
		upd(r[i],-1);
		vis[i]=vis[r[i]]=1;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 7524
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	vector<int> v(n);
	int maxi = 0, mini = 1e8;
	rep(i,n){
		cin >> v[i];
		mini = min(mini, v[i]);
		maxi = max(maxi, v[i]);
	}


	if(maxi - mini >= 2){
		cout << "No" << endl;
	}else if(maxi - mini == 0){
		if(mini == n - 1 || mini * 2 <= n){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else{
		//if(m[maxi] - 1 == n - 1 - mini){
		int mins = count(all(v),mini);
		int maxs = count(all(v),maxi);
		//if(mini == mins){
		if(mins < maxi && 2 * (maxi - mins) <= maxs){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 640
//file_name:ABC68_A.cpp
#include <bits/stdc++.h>
#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)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);


    

    cout << "ABC" << n << endl;
    return 0;
}



Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
H.append(10**9+1)
res = 0
t = 0

for i in range(N):
    if (H[i] >= H[i+1]):
        t += 1
    else:
        res = max(t, res)
        t = 0

print(res)

Measured memory_bytes: 63984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
#define PI 3.14159265359
typedef long long ll;
//

int main(){
    int a,b,c;cin>>a>>b>>c;
    int k;cin>>k;
    bool flag=false;
    vector<int> v{a,b,c};
    vector<vector<int>> vv{v};
    rep(l,k){
        vector<vector<int>> vv3=vv;
        rep(i,3){
            for(auto e:vv){
            vector<int> v2=e;   
           v2[i]*=2;
           vv3.push_back(v2);     
            }
           
        }
        vv=vv3;
    }
    for(auto e:vv){
        if(e[2]>e[1]&&e[1]>e[0])flag=true;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 5428
#include <stdio.h>

int main()
{
  int N;
  int R;
  
  scanf("%d%d", &N, &R);
  if (N >= 10)
  {
    printf("%d", R);
  }
  else
  {
    printf("%d", R + (100 * (10 - N))); 
  }
}


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


Measured memory_bytes: 256
import array
import bisect


def answer(n: int) -> int:
    numbers = array.array('L')

    i = 0
    while 100 ** i <= n:
        start = 100 ** i
        stop = int('9' * len(str(start))) + 1
        numbers.extend(range(start, stop))
        i += 1

    return bisect.bisect_right(numbers, n)


def main():
    n = int(input())
    print(answer(n))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9816
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main() {
    int n;
    cin >> n;

    auto m = map<string, int>();
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        m[s]++;
    }
    auto inv = map<int, vector<string>>();
    for (auto &kv : m) {
        inv[kv.second].push_back(kv.first);
    }

    auto &kv = *inv.rbegin();
    auto &vec = kv.second;
    sort(vec.begin(), vec.end());
    for (auto &name : vec)
        cout << name << "\n";

    return 0;
}

Measured memory_bytes: 26868
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    S = input()
    cnt_w = [0]*(len(S) + 1)
    for i in range(len(S) - 1,-1,-1):
        if S[i] == 'W':
            cnt_w[i] = cnt_w[i + 1] + 1
        else:
            cnt_w[i] = cnt_w[i + 1]
    ans = 0
    for i in range(len(S)):
        if S[i] == 'B':
            ans += cnt_w[i]
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 11112
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

const int maxn = 1e6+5;
int n,m;
int d[105][105];
const int INF = (1<<30)-1;

struct edge{
	int u,v,w;
}e[maxn];

int main(){
	scanf("%d %d",&n,&m);
	int u,v,w;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++) {
			if(i == j) d[i][j] = 0;
			else d[i][j] = INF;
		}
	}
	for(int i = 1;i <= m;i++){
		scanf("%d %d %d",&u,&v,&w);
		e[i].u = u;
		e[i].v = v;
		e[i].w = w;
		d[u][v] = w;
		d[v][u] = w;
	}

	for(int k = 1;k <= n;k++){
		for(int i = 1;i <= n;i++){
			for(int j = 1;j <= n;j++){
				d[i][j] = min(d[i][j],d[i][k]+d[k][j]);	
			}
		}
	}
	int ans = 0;
	for(int i = 1;i <= m;i++){
		int l = e[i].w;
		int r = d[e[i].u][e[i].v];
		if(l != r) ans++;
	}

	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<bool, int>> box(N);
    box[0] = make_pair(true, 1);
    rep2(i,1, N) {
        box[i] = make_pair(false, 1);
    }
    int ans = 0;
    rep(i, M) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        if (!box[x].first) {
            box[x].second--;
            box[y].second++;
            continue;
        }
        if (box[x].second == 1) {
            box[x].first = false;
            box[y].first = true;
            box[x].second--;
            box[y].second++;
            continue;
        }
        box[x].second--;
        box[y].first = true;
        box[y].second++;
    }
    rep(i, N) {
        if (box[i].first) {
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int a, b, c, d, e;
  cin >> a;
  b = a / 1000;
  c = a / 100 % 10;
  d = a / 10 % 10;
  e = a % 10;
  if ( b == c && c == d && d == e) {
    cout << "Yes" << endl;
  }
  else if ( b != c && c ==d  && d == e) {
    cout << "Yes" << endl;
  }
  else if ( b == c &&c  == d && d != e) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int M1 = Integer.parseInt(sc.next());
			double result = Math.ceil(M1/1.08);
			double res = Math.floor(result*1.08);
			if(M1 == (int)res) {
				System.out.println((int)result);
			}else {
				System.out.println(":(");
			}
		}
	}
}

Measured memory_bytes: 35648
// B - Picking Up

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int x[50], y[50];

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

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

	map<pair<int, int>, int> cnt;

	for (int i=0; i<N; i++) {
		for (int j=0; j<N; j++) {
			if (i == j) continue;

			cnt[make_pair(x[j] - x[i], y[j] - y[i])]++;

		}
	}

	int max_cnt = 0;
	for (auto itr : cnt) {
		max_cnt = max(max_cnt, itr.second);
	}

	int ans = N - max_cnt;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3668
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define re register
#define rep(i,s,t) for(re int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(re int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define pt(x) putchar(x)
#define pti(x) printf("%d",x)
#define ptll(x) printf("%lld",x)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
using namespace std;
il ll ci(){
	ll x;
	scanf("%lld",&x);
	return x;
}

int a[64][2];
ll pow2[64];
const int mod = 1e9+7;

int main(){
	int n=ci();
	ll ans= 0;
	pow2[0]= 1;
	rep(j,1,59) pow2[j]= pow2[j-1]*2%mod;
	rep(i,1,n){
		ll x=ci();
		rep(j,0,59){
			bool o= x&(1ll<<j);
			ans= (ans+a[j][o^1]*pow2[j])%mod;
			a[j][o]++;
		}
//		rep(j,0,4) printf("%d ",a[j][0]); pt('\n');
//		rep(j,0,4) printf("%d ",a[j][1]); pt('\n'); pt('\n');
	}
	ptll(ans),pt('\n');
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    ll k;
    cin >> n >> k >> q;
    int a[q];
    int cor[n];
    memset(cor, 0, sizeof(cor));
    rep(i, q){
        cin >> a[i];
        cor[a[i] - 1] ++;
    }
    rep(i, n){
        if(k - q +  cor[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }


}

Measured memory_bytes: 1408
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    int N;
    cin >> N;

    long sum = 0;

    for (int i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }

    cout << sum;

    return 0;
}


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

const int INF = 1000000;

typedef pair<int, int> P;

int h, w;
char field[25][25];
int d[25][25];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int ans;

void bfs(int y, int x){
	queue<P> que;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			d[i][j] = INF;
		}
	}
	que.push(P(x, y));
	d[y][x] = 0;
	while(que.size()){
		P p = que.front(); que.pop();
		for(int i = 0; i < 4; i++){
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
			if(field[ny][nx] == '#') continue;
			if(d[ny][nx] != INF) continue;
			que.push(P(nx, ny));
			d[ny][nx] = d[p.second][p.first] + 1;
			ans = max(d[ny][nx], ans);
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> field[i][j];
		}
	}
	ans = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(field[i][j] == '#') continue;
			bfs(i, j);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 3005
const int mod=1e9+7;
int n,m;
int dp[2][N][2];
int main(){
    scanf("%d%d",&n,&m);
    int now=0;
    for(int i=1;i<=n;i++) dp[now][i][0]=1;
    dp[now][0][1]=1;
    for(int i=1;i<=m;i++){
        memset(dp[now^1],0,sizeof(dp[0]));
        for(int j=0;j<=n;j++)
            for(int k=0;k<=1;k++){
                if(j!=0) 
                    (dp[now^1][j-1][(k==1)|(j==1)]+=dp[now][j][k])%=mod,
                    (dp[now^1][j][(k==1)|(j==1)]+=dp[now][j][k])%=mod;
                if(j!=n)
                    (dp[now^1][j][k]+=dp[now][j][k])%=mod,
                    (dp[now^1][j+1][k]+=dp[now][j][k])%=mod;
            }
        now^=1;
    }
    long long ans=0;
    for(int i=0;i<=n;i++)
        ans+=dp[now][i][1];
    cout<<ans%mod<<endl;
    return 0;
}

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

int main(){
	string str1, str2;
	cin >> str1 >> str2;
	sort(str1.begin(), str1.end());
	sort(str2.begin(), str2.end());
	reverse(str2.begin(), str2.end());

	if(str1<str2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}



Measured memory_bytes: 256
import scala.io.StdIn

object Main {

  def main(args: Array[String]): Unit = {

    val n: Int = StdIn.readLine().toInt
    println(solve(n))

  }

  def solve(n: Int): Int = {

    if (n == 0) {
      0
    } else if (n % 10 == 2) {
      solve(n / 10) + 1
    } else {
      solve(n / 10)
    }

  }

}


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

int main() {
  int X, A, B;
  cin >> X >> A >> B;
  if (A>=B) {
    cout << "delicious" << endl;
  }
  else {
    if (B-A<=X) {
      cout << "safe" << endl;
    }
    else {
      cout << "dangerous" << endl;
    }
  }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;
//嘘
int main(){
  string s,t;
  cin >> s >> t;
  int n = s.size();
  vector<char> ens(26,'?'), ent(26,'?');
  bool fs = true, ft = true;
  rep(i,n){
    char bufs = s[i];
    char buft = t[i];
    if(ens[bufs - 'a'] == '?') ens[bufs - 'a'] = t[i];
    else if (ens[bufs - 'a'] != t[i]) fs = false;
    if(ent[buft - 'a'] == '?') ent[buft - 'a'] = s[i];
    else if (ent[buft - 'a'] != s[i]) ft = false;
  }
  if(!(fs && ft)){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}



Measured memory_bytes: 776
#include<queue> // priority_queue
#include<iostream>
using namespace std;
#define df 0

int main(){
  if(df) printf("*debug mode*\n");
  int n,m; cin >>n >>m;
  priority_queue<int> que;
  for(int i=0;i<n;i++){
    int a; cin >>a; que.push(a);
  }
  for(int i=0;i<m;i++){
    int a=que.top(); que.pop();
    a/=2; que.push(a);
  }
  long int s=0;
  while(not que.empty()){
    s+=que.top();
    que.pop();
  }
  cout << s;
}
/// confirm df==0 ///

Measured memory_bytes: 892
n, m = map(int, input().split())
ac = [0] * (n+1)
pena = 0

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        if ac[p] != -1:
            pena += ac[p]
            ac[p] = -1

    else:
        if ac[p] != -1:
            ac[p] += 1


print(ac.count(-1), pena)


Measured memory_bytes: 3828
#include<stdio.h>
#include<math.h>
float h[1009];
int main()
{
	int a,b,n,m,j,t,i;
	float l;
	 scanf("%d%d%d",&n,&t,&a);
	 for(i=1;i<=n;i++){ 
	 scanf("%f",&h[i]);
	 	h[i]=fabs(t-0.006*h[i]-a);
	 }
	 l=h[1];m=1;
	 for(i=1;i<=n;i++){
	 	if(fabs(h[i])<l){
	 		l=fabs(h[i]);
	 		m=i;
		 }
	 }
	 printf("%d",m);
	
	
} 

Measured memory_bytes: 128
package main

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

func main() {
	log.SetFlags(log.Lshortfile)
	scn := newScanner()
	H := scn.nextInt()
	W := scn.nextInt()
	a := make([]string, 0)
	red := make([][]byte, 0)
	blue := make([][]byte, 0)
	for i := 0; i < H; i++ {
		s := scn.nextLine()
		a = append(a, s)
		red = append(red, []byte(s))
		blue = append(blue, []byte(s))
	}
	for j := 0; j < H; j++ {
		// red
		if j%2 == 0 {
			for k := 0; k < W; k++ {
				red[j][k] = '#'
			}
		}
		red[j][0] = '#'
		red[j][W-1] = '.'
		// blue
		if j%2 != 0 {
			for k := 0; k < W; k++ {
				blue[j][k] = '#'
			}
		}
		blue[j][0] = '.'
		blue[j][W-1] = '#'
	}
	for i := 0; i < H; i++ {
		fmt.Println(string(red[i]))
	}
	fmt.Println("")
	for i := 0; i < H; i++ {
		fmt.Println(string(blue[i]))
	}
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) nextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) nextInt() int {
	v, _ := strconv.Atoi(s.next())
	return v
}

func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 2816
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  queue<pair<int, int>> que;
  for (int i=1; i<n-1; i++) {
    if (a[i] >= 0) {
      que.push({a[0], a[i]});
      a[0] -= a[i];
    } else {
      que.push({a.back(), a[i]});
      a.back() -= a[i];
    }
  }
  que.push({a.back(), a[0]});
  a.back() -= a[0];
  cout << a.back() << endl;
  while (!que.empty()) {
    int x, y;
    tie(x, y) = que.front();
    que.pop();
    cout << x << ' ' << y << endl;
  }
  return 0;
}

Measured memory_bytes: 3072
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val n = readInt()
    val a = readIntList()
    val s = a.reduce { acc, i -> acc xor i }
    val res = a.map { it xor s }
    println(res.joinToString(separator = " "))
}


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

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

  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

int n, c;
vector<int> a, b;

int f(int a){
    a = (a & 0x5555) + ((a & 0xAAAA) >> 1);
    a = (a & 0x3333) + ((a & 0xCCCC) >> 2);
    a = (a & 0x0F0F) + ((a & 0xF0F0) >> 4);
    a = (a & 0x00FF) + ((a & 0xFF00) >> 8);
    return a;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        cin >> n >> c;
        if(n == 0 && c == 0) break;
        a.assign(n, 0);
        b.assign(c, 0);
        REP(i, n) REP(j, 16) {
            int x; cin >> x;
            if(j != 0) a[i] <<= 1;
            a[i] += x;
        }
        REP(i, c) REP(j, 16) {
            int x; cin >> x;
            if(j != 0) b[i] <<= 1;
            b[i] += x;
        }

        vector<vector<int>> dp(35, vector<int>((1<<16), -1));
        dp[0][a[0]] = 0;
        REP(i, n){
            for(int mask = 0; mask < (1 << 16); mask++){
                if(dp[i][mask] != -1){
                    int m = mask | a[i];
                    REP(j, c){
                        int andnum = m & b[j];
                        int notandnum = m & ~b[j];
                        dp[i+1][notandnum] = max(dp[i+1][notandnum], dp[i][mask] + f(andnum));
                    }
                }
            }
        }

        int ans = 0;
        REP(i, (1 << 16)){
            ans = max(ans, dp[n][i]);
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 21368
#include<stdio.h>
#include<math.h>
#include<stdbool.h>

static int count = 0;
static int prime[500000] = {2,3};
static bool primebool[500000] = {true,true};

int primesearch(int);
void primecount(int,int);
void reset();

int main(){
  int n;
  while(scanf("%d", &n) != EOF){
    if (n>1){
      primecount(0,n);
      printf("%d\n", count);
      reset();
    }
    else{
      printf("0\n");
    }
  }
  return 0;
}

void primecount(int i,int n){
  if (!primebool[i]){
    prime[i] = primesearch(prime[i-1]+2);
    primebool[i] = true;
  }
  if (prime[i]<=n){
    count++;
    primecount(i+1,n);
  }
}

int primesearch(int x){
  int i,sq;
  sq = (int)sqrt(x);
  for(i=3;i<=sq;i=i+2){
    if(x%i==0){
      return primesearch(x+2);
    }
  }
  return x;
}

void reset(){
    count = 0;
}



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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        string s,t;
        cin>>s>>t;
        n = s.length();
        int ans = 0;
        for(int i=0;i<n;i++)ans += (s[i]!=t[i]);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3752
import java.util.Scanner;

class Main {

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

  private static Scanner sc;

  private void run() {
    sc = new Scanner(System.in);
    String N = sc.next();
    char c = N.charAt(N.length() - 1);
    if (c == '2' || c == '4' || c == '5' || c == '7' || c == '9') {
      System.out.println("hon");
    } else if (c == '0' || c == '1' || c == '6' || c == '8') {
      System.out.println("pon");
    } else {
      System.out.println("bon");
    }
  }
}


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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const ll NN = 1e10 + 7;
const int N = 5e5 + 7;
const int M = 11;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;

void solve1()
{
    ll n,k;
    cin >> n >> k;
    n %= k;
    cout << min( abs(n - k) , abs(n) );
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0); srand(time(0));
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  char a;
  
  for (int i=0; i<H+2; i++) {
    for (int j=0; j<W+2; j++) {
      
      if ( i == 0 || i == H+1 ||
           j == 0 || j == W+1   ) {
        cout << '#';
      }
      else {
        cin >> a;
        cout << a;
      }
        
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
from collections import defaultdict
ncr1 = {}
ncr2 = {}
d = defaultdict(int)

for i in range(N):
    a = A[i]
    d[a] += 1

sumA = 0

for key, value in d.items():
    ncr1[key] = value * (value-1) // 2
    ncr2[key] = (value-1)*(value-2) // 2
    sumA += ncr1[key]

for i in range(N):
    a = A[i]
    ans = sumA - ncr1[a] + ncr2[a]
    print(ans)


Measured memory_bytes: 107340
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int R;
  cin >> R;
  if(R<1200){
  cout << "ABC" << endl;
  }
  else if(1200<=R && R<2800){
  cout << "ARC" << endl;
  }
  else{
  cout << "AGC" << endl;
  }
}
  



  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1
using namespace std;
const int INF = 1e18;
const int MOD = 1000000007;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int ans = 0;
    rep(i, n)
    {
        int a;
        cin >> a;
        if (i == 0)
        {
            ans = gcd(a, a);
        }
        else
        {
            ans = gcd(ans, a);
        }
    }
    cout << ans << endl;
}

signed main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
/*
    NEVER GIVE UP!
    THE EXPERT IN ANYTHING WAS ONCE A BEGINNER
*/

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;


void solve()
{
    ll l,c=0;
    string s;
    cin >> l >> s;
    
    f(i,0,l-3)
    {
        if(s.substr(i,3)=="ABC")
            c++;
    }
    cout << c;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int a, b;

int main() {
	cin >> a >> b;
	
	cout << (b % a == 0 ? a + b : b - a) << endl;
	
	return 0;
}


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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  stack<int> s;
  int n;
  while(cin>>n){
    if(n!=0)s.push(n);
    else{
      cout <<s.top() <<endl;s.pop();
    }
  }
  return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll X(N);
        rep(i, 0, N) cin >> X[i];

        ll ans = inf;
        rep(i, 1, 101) {
                ll sm = 0;
                rep(j, 0, N) {
                        sm += intpow((X[j] - i), 2);
                }
                chmin(ans, sm);
        } 

        cout << ans << endl;
}

Measured memory_bytes: 3612