akhauriyash/Code-Regression huggingface dataset:
import math

def norm(x, y):
    result = 0
    for i in range(len(x)):
        result += (x[i] - y[i]) * (x[i] - y[i])
    result = math.sqrt(result)
    return result

n, d = list(map(int, input().split(' ')))
x = []
for _ in range(n):
    x.append(list(map(int, input().split(' '))))

result = 0
for i in range(0, n-1):
    for j in range(i+1, n):
        if norm(x[i], x[j]).is_integer():
            result += 1

print(result)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl


/*--------------------template--------------------*/


int main()
{
	cin >> s;
	string t = "abcdefghijklmnopqrstuvwxyz";
	vc u;
	REP(i, s.size())
	{
		u.push_back(s[i]);
	}
	sort(ALL(u));
	REP(i, t.size())
	{
		REP(j, u.size())
		{
			if (t[i] == u[j]) {
				break;
			} else {
				if (j == u.size() - 1) {
					cout << t[i] << endl;
					return 0;
				}
			}
		}
	}
	cout << "None" << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll n,m;
cin>>n>>m;
ll p[m+1];
string s[m+1];
ll c1=0,c2=0;
ll corr[n];
ll w[n];
bool vis[n];
 for(int i = 1; i <= n; i++) {
        w[i] = 0;
        corr[i]=0;
        vis[i]=false;
    }
 
for(int i=0;i<m;i++){
    cin>>p[i]>>s[i];
    if(vis[p[i]]) continue;
    if(s[i]=="AC"){
        corr[p[i]]++;
        vis[p[i]]=true;
        if(corr[p[i]]==1){
       c1++;
        }
        c2+=w[p[i]];
      
    }
    else if(s[i]=="WA"){
        w[p[i]]++;
        //cout<<w[p[i]]<<endl;
    }
}
    
cout<<c1<<" "<<c2<<endl;
 
}

Measured memory_bytes: 8192
F =-> {gets.split.map &:to_i}
N,M = F[]
*H = F[]
R = H.dup
M.times {
  a,b = F[]
  R[a] = nil  if H[a-=1] <= H[b-=1]
  R[b] = nil  if H[a] >= H[b]
}
p R.count{|r| r}

Measured memory_bytes: 23436
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
ll x[100010],p[100010];
int main()
{	int n,s,l=1,r; ll ans=0; cin>>n>>s; r=n;
	for(rint i=1;i<=n;i++) scanf("%lld%lld",&x[i],&p[i]);
	while(l<=r)
	{	if(s<=x[l]) return !printf("%lld\n",ans+x[r]-s);
		if(s>=x[r]) return !printf("%lld\n",ans+s-x[l]);
		ans+=x[r]-x[l];
		if(p[l]>=p[r]) while(p[l]>=p[r]&&l<r) p[l]+=p[r--];
		else while(p[l]<p[r]&&l<r) p[r]+=p[l++];
	}
	assert(0);
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<ctime>
#include<cstdlib>
#include<vector>
using namespace std;
int a,b,c;
int main()
{
cin>>a>>b>>c;
if(a==b){
	cout<<c;return 0;
}
if(b==c){
	cout<<a;return 0;
}
if(a==c){
	cout<<b;return 0;
}
	return 0;
}



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

int main(void) {
	int n, num = 0;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		if (s[i] == "Y") num = 1;
	}
	cout << (num == 0 ? "Three" : "Four") << endl;
	return 0;
}

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

using std::cin;
using std::cout;
using std::endl;
using std::string;;

// #define int long long


int main(void) {
  int num = 0;
  int N;

  cin >> N;

  if (N % 2 == 0) cout << N << endl;
  else cout << 2 * N << endl;

  // cout << num << endl;
  return 0;
  
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Question[] questions = new Question[n];
        for (int i = 0; i < n; i++) {
            questions[i] = new Question(sc.nextInt(), sc.nextInt());
        }
        Arrays.sort(questions);
        int max = 0;
        int[] dp = new int[n + 1];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for (Question q : questions) {
            for (int i = max; i >= 0; i--) {
                if (dp[i] + q.mine <= q.other) {
                    dp[i + 1] = Math.min(dp[i + 1], dp[i] + q.mine);
                    max = Math.max(max, i + 1);
                }
            }
        }
        System.out.println(max);
    }
    
    static class Question implements Comparable<Question> {
        int mine;
        int other;
        
        public Question(int mine, int other) {
            this.mine = mine;
            this.other = other;
        }
        
        public int compareTo(Question another) {
            return other - another.other;
        }
    }
}


Measured memory_bytes: 26464
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (b % a > 0) {
                out.println(b - a);
            } else {
                out.println(a + b);
            }
        }
    }

    public static void main(String argds[]) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}



Measured memory_bytes: 20820
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main(int argc, char *argv[]){
  int N;
  cin>>N;
  pair<int,int> pint;
  vector<vector<pair<int,int> > > vec;
  vec.resize(N);
  for(int i=0; i<N; i++){
    int A; cin>>A;
    vec[i].resize(A);
    for(int j=0; j<A; j++){
      int x,y;
      cin>>x>>y;
      vec[i][j].first=x-1;
      vec[i][j].second=y;
    }
  }
  int res=0;
  for(int bit=0; bit < (1 << N); bit++){
    int flag=1;
    for(int i=0; i<N; i++){
      if(!(bit&(1<<i))) continue;
      
      for(int j=0; j<vec[i].size(); j++){
	if(vec[i][j].second==1 && !(bit&(1<<vec[i][j].first))){
	  flag=-1;
	  break;
	}
	if(vec[i][j].second==0 && bit&(1<<vec[i][j].first)){
	  flag=-1;
	  break;
	}
      }
      if(flag==-1) break;
    }
    if(flag==1){
      int count=0;
      for(int k=0; k<N; k++){
	if(bit&(1<<k)) count++;
      }
      res=max(res,count);
    }
  }
  cout<<res<<endl;
}
    
    
	
	 


Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int i,k,n;
  int a[1000000];
  scanf("%d %d",&k,&n);
  for(i = 0;i < n;i++) {
    scanf("%d",&a[i]);
  }
  a[n] = a[0] + k;
  i = 0;
  int max = a[1] - a[0];
  for(i = 0;i < n;i++) {
    if(max < a[i+1]-a[i]) {
      max = a[i+1] - a[i];
    }
  }
  printf("%d\n",k-max);

}


Measured memory_bytes: 2944
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
ll iinf;
ll a[200005],sum[200005],n;
ll get(int pos){
	ll val,lo,hi,ans,i,j,val1,val2,val3,minn=iinf,maxx=0,res;
	res=iinf;
	vl v,v1;
	val=sum[pos];
	lo=0;
	hi=pos;
	val/=2;
	while(lo<=hi){
		int mid=(lo+hi)/2;
		if(sum[mid]>=val){
			ans=mid;
			hi=mid-1;
		}
		else{
			lo=mid+1;
		}
	}
	if(ans!=pos)
	v.pb(ans);
 	if(ans-1>=0){
 		v.pb(ans-1);
 	}
 	val=sum[n-1]-sum[pos];
	lo=pos+1;
	hi=n-1;
	val/=2;
	while(lo<=hi){
		int mid=(lo+hi)/2;
		if(sum[mid]-sum[pos]>=val){
			ans=mid;
			hi=mid-1;
		}
		else{
			lo=mid+1;
		}
	}
	if(ans!=n-1)
	v1.pb(ans);
 	if(ans-1>pos){
 		v1.pb(ans-1);
 	}
 	rep(i,v.size()){
 		rep(j,v1.size()){
 			maxx=0;
			minn=iinf;
 			val=sum[v[i]];
 			val1=sum[pos]-sum[v[i]];
 			val2=sum[v1[j]]-sum[pos];
 			val3=sum[n-1]-sum[v1[j]];
 			maxx=max(maxx,max(val,max(val1,max(val2,val3))));
			minn=min(minn,min(val,min(val1,min(val2,val3))));
			res=min(res,maxx-minn);
 		}
 	}
 	return res;
}
int main(){
	std::ios::sync_with_stdio(false);
	ll res,i;
	cin>>n;
	iinf=inf;
	iinf*=inf;
	res=iinf;
	rep(i,n){
		cin>>a[i];
		sum[i]=i>0?sum[i-1]+a[i]:a[i];
	}
	f(i,1,n-2){
		res=min(res,get(i));
	}
	cout<<res<<endl;
} 
	

Measured memory_bytes: 3328
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (2000)
#define INF (922337203685477580)

struct edge{
	int to;
	long long dis;
};

int n, m;
vector<edge>e[N];
long long d[N];
bool used[N];
bool zz;

void init(void){
	memset(used, 0, sizeof(used));
	return;
}

void bellmanford(int x){
	f(i, N)d[i] = INF;
	zz = true;
	d[x] = 0;
	f(ii, n - 1){
		f(i, n){
			f(j, e[i].size()){
				if (d[e[i][j].to] > d[i] + e[i][j].dis)d[e[i][j].to] = d[i] + e[i][j].dis;
			}
		}
	}
	f(i, n){
		f(j, e[i].size()){
			if (d[e[i][j].to] > d[i] + e[i][j].dis){
              if(d[i]<(INF/10))zz = false;
            }
		}
	}
}


int main(void){
	int k;
	int x, y;
long long z;
	long long s, ans;
	scanf("%d %d %d", &n, &m,&k);
	init();
	f(i, m){
		scanf("%d %d %lld", &x, &y, &z);
		e[x].push_back({ y, z });
	}
	bellmanford(k);


	if (zz){
		f(i, n){
			if(d[i]<(INF/10))printf("%lld\n", d[i]);
			else printf("INF\n");
		}
	}
	else printf("NEGATIVE CYCLE\n");

	return 0;
}



Measured memory_bytes: 2888
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

const int INF = 1001001001;

int n, m, X;
int c[15];
int a[15][15];
int ans = INF;

void dfs(int x, int vb, vi va, int yen) {
  if (x == n) {
    bool ok = true;
    REP(i, m) {
      // cout << va[i] << endl;
      if (va[i]<X) {
        ok = false;
        break;
      }
    }
    if(ok) {
      chmin(ans, yen);
    }
    return;
  }
  vi ta = va;
  int ty = yen;
  if(x>=0){
    if(vb) {
      REP(i, m) {
        ta[i] += a[x][i];
      }
      ty += c[x];
    }
  }
  dfs(x+1, 0, ta, ty);
  dfs(x+1, 1, ta, ty);
}

int main() {
  cin>>n>>m>>X;
  REP(i, n) {
    cin >> c[i];
    REP(j, m) cin >> a[i][j];
  }
  dfs(-1,0,vi(m),0);
  if(ans==INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; ++i) // マクロ
using namespace std; // stdの省略
using pii = pair<int, int>; // pairの略記
using ll = long long; // long longの略記


int main(void) {
   
   int d, t, s;
   cin >> d >> t >> s;
   
   string ans = "No";
   if (s*t >= d) ans = "Yes";
   
   cout << ans << endl;
   
   return 0;
}

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

int n;
void dfs(string s,char mx){
    if(s.size()==n){
        cout<<s<<endl;
        return;
    }
    for(char c='a'; c<=mx+1; ++c){
        string t=s;
        t+=c;
        dfs(t,max(mx,c));
    }
}

int main(){
    cin>>n;
    dfs("",'a'-1);
    return 0;
}

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

using namespace std;

string s[3];

int main(void)
{
	cin >> s[0] >> s[1] >> s[2];
	
	int t, turn = 0;
	while(1){
		if(s[turn].size() == 0) break;
		t = s[turn][0] - 'a';
		s[turn].erase(s[turn].begin());
		turn = t;
	}
	
	cout << (char)(turn + 'A') << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define MAX 3

using namespace std;

int main() {
	int list[MAX], n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> list[0] >> list[1] >> list[2];
		for (int j = 0; j < MAX; j++) {
			list[j] *= list[j];
		}

		bool judge = false;
		for (int j = 0; j < MAX; j++) {
			if (list[j] == list[(j+1)%3] + list[(j+2)%3]) {
				judge = true;
				break;
			}
		}

		if (judge) {
			cout << "YES";
		}
		else {
			cout << "NO";
		}

		cout << endl;
	}

	return 0;
}

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

int main(){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    if(a == 0){
        cout << 1 << endl;
    }else if (b == 0){
        cout << 2 << endl;
    }else if(c == 0){
        cout << 3 << endl;
    }else if (d == 0){
        cout << 4 << endl;
    }else if (e == 0){
        cout << 5 << endl;
    }
}


Measured memory_bytes: 3612
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    string s; cin >> s;
    rep(i, (s.size() + 1) / 2)cout << s.at(i * 2);
    cout << endl;
}

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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;

string s, t;
ll a, b;
set< int > st[1000];
int main()
{
	cin >> s >> t;
	for(int i = 0; i < s.size(); i++)
		st[s[i]].insert(i);
	for(int i = 0; i < t.size(); i++){
		if(st[t[i]].empty()){
			cout << -1;
			return 0;
		}
        if(st[t[i]].lower_bound(b) == st[t[i]].end())
			a++, b = 0;
		b = *st[t[i]].lower_bound(b);
		b++;		
	}
	cout << a * s.size() + b;
	return 0;
}


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

using namespace std;

long double sum;
int n;
pair<int,int> coord[10];
int cont;
long long dist(pair<int,int> p1, pair<int,int> p2){
    int x = p1.first - p2.first;
    int y = p1.second - p2.second;
    
    return (x*x + y*y);
}

int fact(int x){
    if (x<=1) return 1;
    return x * fact(x-1);
}
/*
long long dfs(int v, vector<int> visited){
    visited[v] = 1;
    cont++;
    for(int i=0; i<n; i++){
        if(visited[i] == 0){
            sum += sqrt(dist(v,i));
            //cout << "sum: " << sum << endl;
            dfs(i, visited);
        }
    }
}
*/
int main(){

    vector<vector<int>> abc(5);
    

    cin >> n;
    vector<int> vis = {0,0,0,0,0,0,0,0,0};
    
    for(int i=0; i<n; i++)
        cin >> coord[i].first >> coord[i].second;
    

    for(int x=0; x<fact(n); x++){
        /*
        cout << "perm" << endl;
        for(int i=0; i<n; i++){
            cout << coord[i].first << " " << coord[i].second << endl;
        }
        */
        for(int i=1; i<n; i++){
            sum += sqrt(dist(coord[i], coord[i-1]));
        }
        
        next_permutation(coord, coord+n);
    }        
        
    /*
    for(int i=0; i<n; i++){
        dfs(i, vis);
    }
    */
    cout << setprecision(20);

  
    cout << sum/fact(n)<<endl;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define rep(i,n) for(ll i=0;i<n;i++)
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
// using namespace atcoder;

const ll mod=1000000007;//998244353;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

ll powmod(ll a,ll n,ll m) {
    if(n == 0)
        return 1;

    if(n % 2 ==0){
        ll r = powmod(a,n/2,m);
        return r*r % m;
    }

    return a*powmod(a,n-1,m)%m;
}

ll factmod(ll a,ll b,ll m) {
  if(a<b)return 0;
  ll s=1;
  while(a>=b){
    s = s*a % m;
    a -= 1;
  }
  return s;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

ll combmod(ll a,ll b,ll m){
  if(b==0)return 1;
  ll c=factmod(a,a-b+1,m);
  ll d=modinv(factmod(b,1,m),m);
  ll e=(c*d)%m;
  return e;
}

void modsum(ll &a,ll b,ll m){
  a+=b;
  a%=m;
}

void modsub(ll &a,ll b,ll m){
  a-=b;
  a+=m;
  a%=m;
}

void modmul(ll &a,ll b,ll m){
  a*=b;
  a%=m;
}

void modquo(ll &a,ll b,ll m){
  a*=modinv(b,m);
  a%=m;
}

int main(){

  ll n,k;
  cin >> n >> k;
  k=min(k,n-1);

  ll ans=0;
  ll a=1,b=1;
  ans+=a*b;
  for(ll i=1;i<=k;i++){//誰もいない部屋がi個
    modmul(a,n+1-i,mod);
    modquo(a,i,mod);    
    modmul(b,n-i,mod);
    modquo(b,i,mod);
    modsum(ans,a*b%mod,mod);
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 3584
#!/usr/local/bin/ruby
while line=gets
   n=line.to_i
   m=gets.to_i
   arr=(1..n).to_a
   m.times{
      rec=gets.split(",")
      x,y=rec[0].to_i,rec[1].to_i
      tmp=arr[x-1]
      arr[x-1]=arr[y-1]
      arr[y-1]=tmp
   }
   puts arr
end

Measured memory_bytes: 6108
#include <stdio.h>
int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    if (a > b){
        printf("a > b\n");
    }

    else if (a < b){
        printf("a < b\n");
    }
    else {
        printf("a == b\n");
    }
    return 0;
    
}


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int ms = 100100;

bool bad[ms];
int par[ms];

int getPar(int x) { return par[x] == x ? x : par[x] = getPar(par[x]); }
void makeUnion(int a, int b) {
	a = getPar(a), b = getPar(b);
	if(a == b) return;
	bad[a] = bad[a] != bad[b];
	par[b] = a;
}

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	std::string str;
	std::cin >> str;
	int n = (int) str.size();
	std::vector<int> a(n+1, 0);
	for(int i = 0; i < n; i++) {
		if(str[i] == '1') {
			a[i] ^= 1;
			a[i+1] ^= 1;
		}
	}
	auto check = [&](int x) {
		for(int i = 0; i <= n; i++) {
			bad[i] = a[i] == 1;
			par[i] = i;
		}
		for(int i = x; i <= n; i++) {
			makeUnion(i-x, i);
			makeUnion(0, i);
			makeUnion(n-i, i);
		}
		for(int i = 0; i <= n; i++) {
			if(bad[getPar(i)]) return false;
		}
		return true;
	};
	int l = 1, r = n;
	while(l != r) {
		int mid = (l + r + 1) / 2;
		if(check(mid)) {
			l = mid;
		} else {
			r = mid - 1;
		}
	}
	std::cout << l << '\n';
}

Measured memory_bytes: 1744
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;


int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int N;
    while(cin>>N, N){
        int cnt = 0;
        for(int s=1; s<=N/2; s++){
            int i = s;
            int sum = 0;
            while(sum<N){
                sum += i++;
            }
            cnt += sum==N;
        }
        cout << cnt << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 15; int n;
bool honest[maxN];
vector<pair<int, int>> testemonies[maxN];

bool valid(int bitmask)
{
  for (int i = 0; i < n; i ++)
    if (bitmask & (1 << i))
      for (auto &v: testemonies[i])
        if (v.second != ((bitmask >> v.first) & 1))
          return false;
  return true;
}

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    for (int i = 0; i < n; i ++) honest[i] = true, testemonies[i].clear();
    for (int i = 0; i < n; i ++)
    {
      int a; scanf("%d", &a);
      for (int j = 0; j < a; j ++)
      {
        int u, is; scanf("%d %d", &u, &is); u --;
        testemonies[i].push_back({u, is});
      }
    }

    int ans = 0;
    for (int bitmask = 0, end = 1 << n; bitmask < end; bitmask ++)
    {
      if (valid(bitmask))
        ans = max(ans, __builtin_popcount(bitmask));
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long


signed main(){
  int n;
  cin>>n;
  int a[100001];
  int sum=0;
  lp(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  a[n]=a[0];
  int cnt=sum*2/((n+1)*n);
  double cnc=(double)sum*2/(double)((n+1)*n);
  if(cnt!=cnc){
    cout<<"NO"<<endl;
    return 0;
  }
  int ans=cnt;
  lp(i,n){
    int x=a[i+1]-a[i]-cnt;
    //cout<<x<<endl;
    if(x==0) continue;
    if((-1*x)%n!=0||x>0){
      cout<<"NO"<<endl;
      return 0;
    }
    ans+=x/n;
  }
  if(ans==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int result = 0;
        if(a - 2 * b > 0){
            result = a - 2 * b;
        }
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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 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 set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
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;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  int ans = 0;
  srep(i,1,N) {
    string l = S.substr(0,i);
    string r = S.substr(i,N-i);
    vi a(26,0);
    vi b(26,0);
    rep(k,sz(l)) {
      a[l[k]-'a']++;
    }
    rep(k,sz(r)) {
      b[r[k]-'a']++;
    }
    int n = 0;
    rep(k,26) {
      if(a[k] > 0&& b[k] > 0 ){
        n++;
      }
    }
    ans = max(ans,n);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define N 100009
int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (a >= k)
		cout << k << endl;
	else if ((a + b) >= k)
		cout << a << endl;
	else
		cout << (a - (k - a - b)) << endl;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
	ll h,w;
	cin>>h>>w;
	ll m;
	cin>>m;
	vector<ll> row[h+1];
	set<ll> col[w+1];
	multiset<pair<ll,ll>> st;
	rep(i,m)
	{
		ll x,y;
		cin>>x>>y;
		row[x].pb(y);
		col[y].insert(x);
	}
	repA(i,1,w)
	{
		st.insert(mp(col[i].size(),i));
	}
	ll ans=-1e18;
	repA(i,1,h)
	{
		ll mx=-1;
		ll num=row[i].size();
		ll val=(*st.rbegin()).fi;
		auto it=st.lower_bound(mp(val,0ll));
		for(auto iter=it;iter!=st.end();iter++)
		{
			pair<ll,ll> p=*iter;
			ll val=p.fi;
			ll colno=p.se;
			if(col[colno].count(i)) mx=max(mx,num+val-1);
			else 
			{
				mx=max(mx,num+val);
				break;
			}
		}
		ans=max(ans,mx);
	}
	cout<<ans<<'\n';
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 66872
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <unordered_map>
#define fi first
#define se second
#define iis std::ios::sync_with_stdio(false)
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int, int> pii;

const int INF = 0x3f3f3f3f;
const int MXN = 1e6 + 5;
const int MXT = 2e7 + 6;
const uLL base = 99959;

unordered_map<uLL, int> mp;
int n, m, tn;
int head[MXN], tot;
struct lp {
    int v, c, nex;
}cw[MXT];
int dis[MXT], vis[MXT], fa[MXN];
void add_edge(int u,int v,int w) {
    cw[++tot].v = v;cw[tot].c = w;cw[tot].nex = head[u];
    head[u] = tot;
    cw[++tot].v = u;cw[tot].c = w;cw[tot].nex = head[v];
    head[v] = tot;
}
void dij() {
    priority_queue<pii,vector<pii>,greater<pii> >Q;
    for(int i = 1; i <= n; ++i) dis[i] = INF, vis[i] = 0;
    dis[1] = 0;
    Q.push({dis[1], 1});
    while(!Q.empty()) {
        pii now = Q.top();Q.pop();
        int u = now.se;
        if(vis[u]) continue;
        vis[u] = 1;
        for(int i = head[u]; ~i; i = cw[i].nex) {
            int v = cw[i].v;
            if(vis[v]) continue;
            if(dis[v] > dis[u] + cw[i].c) {
                dis[v] = dis[u] + cw[i].c;
                Q.push({dis[v], v});
            }
        }
    }
    int ans = dis[tn];
    while(!Q.empty()) Q.pop();
    if(ans == INF) ans = -2;
    printf("%d\n", ans/2);
}
int Fi(int x) {
    return fa[x] == x? x: fa[x] = Fi(fa[x]);
}
int get(int x, int y) {
    uLL tmp = x;
    tmp = tmp * base * base + y * base + x ^ y;
    if(mp[tmp]) return mp[tmp];
    mp[tmp] = ++n;
    return n;
}
int main(int argc, char const *argv[]) {
    while(~scanf("%d%d", &n, &m)) {
        memset(head, -1, sizeof(head));
        tot = -1;
        mp.clear();
        tn = n;
        for(int i = 1; i <= n; ++i) fa[i] = i;
        for(int i = 0, u, v, c, pa, pb, uc, vc; i < m; ++i) {
            scanf("%d%d%d", &u, &v, &c);
            pa = Fi(u), pb = Fi(v);
            fa[pa] = pb;
            uc = get(u, c); vc = get(v, c);
            add_edge(u,uc,1);add_edge(uc,vc,0);add_edge(vc,v,1);
            add_edge(v,vc,1);add_edge(vc,uc,0);add_edge(uc,u,1);
        }
        if(Fi(tn) != Fi(1)){
            printf("-1\n");
            continue;
        }
        dij();
    }
    return 0;
}

Measured memory_bytes: 61940
N, A, B = map(int, input().split())
s = str(input())

passed = []
count = 0
for i in range(N):
  if s[i] == "a" and len(passed) < A + B:
    passed.append(s[i])
    print("Yes")
  elif s[i] == "b" and len(passed) < A + B and count < B:
    passed.append(s[i])
    count += 1
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 4784
#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 OUT(a) cout << (a) << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll n;
    ll p[200010];
    string s;

    cin >> s;

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

    return 0;
}

Measured memory_bytes: 3584
/*
Author : Devil088
*/
#include<bits/stdc++.h>
using namespace std;
#define MOD 998244353
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c,d;
	
	cin>>a>>b>>c>>d;
	int x = ceil(c/(float)b);
	int y = ceil(a/(float)d);
	if(x<=y)cout<<"Yes";
	else cout<<"No";
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

li n;

inline bool ok(li x) {
    li xx = (x * 1.08);
    return n == xx;
}

int main() {
    cin >> n;
    repp(i, 1, n + 1) {
        if (ok(i)) {
            cout << i << endl;
            return 0;
        }
    }
    puts(":(");

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long llint;
int compare(const void *a, const void *b){return *(llint *)a - *(llint *)b;}


int main(void){
    llint n,i,defeated=0,mark;
    scanf("%lld",&n);
    llint a[n];
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    while(defeated!=n-1){
        qsort(a,n,sizeof(llint),compare);
        mark = defeated;
        for(i=mark+1;i<n;i++){
            a[i]%=a[mark];
            if(a[i]==0) defeated++;
        }
    }
    qsort(a,n,sizeof(llint),compare);

    printf("%lld\n",a[n-1]);
    return 0;
}


Measured memory_bytes: 1788
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

int digits(ll x){
  int count=0;
  while(x>0){
    x/=10;
    count++;
  }
  return count;
}

int main(){
  int ans=11;
  ll N;
  cin>>N;

  for(ll i=1;i<=100000;i++){
    if(N%i==0){
      ans=min(ans,(int)digits(max(i,N/i)));
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        double sum = 0;
        for (int i = 1; i <= n; i++) {
            double p = 1;
            int score = i;
            while (score < k) {
                score *= 2;
                p /= 2;
            }
            sum += p;
        }
        System.out.println(sum / n);
    }

}


Measured memory_bytes: 21460
o = input()
e = input()
a=[]
if len(o) == len(e):
  for i in range(len(e)):
  	a.append(o[i])
  	a.append(e[i])
  print(''.join(a))
else:
  for i in range(len(e)):
  	a.append(o[i])
  	a.append(e[i])
  a.append(o[-1])
  print(''.join(a))

Measured memory_bytes: 3060
N, K = map(int, input().split())

flag = 0
if K == 1:
    print(0)
    quit()
if K == 2:
    if N % 2:
        print(1)
        quit()
    else:
        print(0)
        quit()

i = N // K
N = N - K * i
while True:
    i = N // K
    ab = abs(N - K)
    if N > ab:
        N = ab
    else:
        break

print(N)


Measured memory_bytes: 38256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(X, Y):
    ans = 0
    a = X
    while a <= Y:
        ans += 1
        a *= 2
    return ans


def main():
    X, Y = read_int_n()
    print(slv(X, Y))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5484
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    string s;
    cin >> s;
    for (size_t i = 0; i < s.size() - 8; i++) {
        cout << s.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  int cnt = 0;
  rep(i, n){
    int a;
    cin >> a;
    if(i%2 == 1) continue;
    if(a%2 == 1) cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3564
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
            if (p[i] != i+1) {
                cnt++;
            }
        }
        if (cnt > 2) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }

}


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

const int N = 150;

int n, m, sum;
int a[N];
int main ()
{
	cin >>n >>m;
	for (int i = 1; i <= n; i++)
	{
		cin >>a[i];
		sum += a[i];
	}
	sort(a + 1, a + n + 1);
	for (int i = n; i >= n - m + 1; i--)
	{
		//cout <<i <<" " <<a[i] <<" " <<sum <<endl;
		if (a[i] * 4 * m < sum)
		{
			cout <<"No";
			return 0;
		}
	}
	cout <<"Yes";
	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def pow(x, n):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = ans*x
      ans %= mod
    x = x*x
    x %= mod
    n = n >> 1
  return ans % mod

nums = [0 for _ in range(10**5 + 1)]

def f(i, N, K):
    # i no baisuu
    # i = K, K-1, ..., 1
    cnt = pow(K // i, N)
    # subtract 2i, 3i, 4i, ...
    j = i
    while j + i <= K:
        cnt -= nums[j+i]
        j += i
    nums[i] = cnt
    return nums[i]

def main():
    N, K = LI()
    cnt = 0
    for i in range(1, K+1)[::-1]:
        cnt += (i * f(i, N, K) % mod)
        cnt %= mod
    print(cnt)

main()



Measured memory_bytes: 13296
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=50005;
int n,m,t;
int x[Maxn*2],y[Maxn*2];
bitset<Maxn> cur[Maxn];
int f[Maxn],ans[Maxn*2];
void Solve1(){
	for (int i=1;i<=n;i++){
		cur[i][i]=1;
	}
	for (int i=m-1;i>=0;i--){
		cur[x[i]]|=cur[y[i]];
		cur[y[i]]|=cur[x[i]];
	}
	bitset<Maxn> tmp;
	for(int i=1;i<=n;i++) tmp[i]=1;
	for (int i=1;i<=n;i++) tmp&=cur[i];
	for(int i=1;i<=n;i++){
		if (tmp[i]){
			f[i]=1;
			for (int j=m-1;j>=0;j--){
				if (f[x[j]]){
					ans[j]=0;
					f[y[j]]=1;
				} 
				else if (f[y[j]]){
					ans[j]=1;
					f[x[j]]=1;
				}
			}
			for (int j=1;j<=n;j++){
				assert(f[j]);	
			}
			for (int j=0;j<m;j++){
				if (ans[j]){
					putchar('v');
				}
				else{
					putchar('^');
				}
			}
			puts("");
			exit(0);
		}
	}
	printf("-1\n");
}
void Solve2(){
	if (n==2){
		printf("-1\n");
		return;
	}
	int a=-1,lst=-1,b,c,d;
	vector<pair<int,pair<int,int> > > V;
	for (int i=0;i<m;i++){
		int X=x[i],Y=y[i];
		if (X>3) continue;
		if (Y>3){
			ans[i]=0;
			continue;
		}
		V.pb(mp(i,mp(X,Y)));
	}
	if (!V.empty()){
		for (int i=1;i<V.size();i++){
			int NA=6-V[i-1].second.first-V[i-1].second.second,NB=6-V[i].second.first-V[i].second.second;
			if (NA!=NB){
				if (V[i-1].second.first==NB){
					ans[V[i-1].first]=0;
				}
				else{
					ans[V[i-1].first]=1;
				}
			}
		}
	}
	for (int i=0;i<m;i++){
		if (ans[i]){
			putchar('v');
		}
		else{
			putchar('^');
		}
	}
	printf("\n");
}
int main(){
	scanf("%d %d %d",&n,&m,&t);
	for (int i=0;i<m;i++){
		scanf("%d%d",&x[i],&y[i]);
	}
	if (t==1){
		Solve1();
		return 0;
	}
	Solve2();
	return 0;
}

Measured memory_bytes: 307200
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

int main(){
    long long X;
    cin >> X;
    long long m = 100;
    long long count = 0;
    while(X > m){
        m = (long long) m*1.01;
        count++;
    }
    cout << count << endl;
}    

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
ll int gcd(
  ll a
  , ll b
)
{
  auto r = a%b;
  a = b;
  b = r;
  while (0 != b)
  {
  	r = a%b;
    a = b;
    b = r;
  }
  return a;
}
 
ll int lcm(
  ll a
  , ll b
)
{
  return a*b/gcd(a, b); 
}
int main(){
    ll int n,m;
    cin>>n>>m;
    ll int a[n];
    rep(i,n){
        ll int tmp;
        cin>>tmp;
        a[i]=tmp/2;
    }
    int mn=1;
    rep(i,n){
        mn = lcm(mn,a[i]);
    }
    ll int ans = 0;
    ll int i=1;

     rep(i,n){
        if (mn / a[i] % 2 == 0) {
			cout << 0 << endl;
			return 0;
		}
  }

    if(m/mn==0){
        cout<<ans<<endl; 
    }
    else{
        cout<<(m/mn+1)/2<<endl;
    }
    

}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<queue>
#include<utility>
#include<algorithm>
#include<math.h>
using namespace std;
long long L,R;
int main(){
	cin>>L>>R;
	int a,b;
	int flag=0,ans=4072325;
	for(int i=L;i<=R;i++){
		for(int j=i+1;j<=R;j++){
			a=i;b=j;
			//cout<<a<<' '<<b<<endl;
			a=a%2019;
			b=b%2019;
			a=a*b;
			a=a%2019;
			ans=min(a,ans);
			if(ans==0) flag=1;
			if(flag) break;
		}
		if(flag) break;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256