akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  1000000007
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
#define maxi 500111

ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
ll intpoint(ll x1, ll y1, ll x2, ll y2) { return ( __gcd(abs(x1-x2),abs(y1-y2))+1); }
bool isvalid(ll x,ll y,ll n,ll m) { return (x>=0&&x<n&&y>=0&&y<m); }
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int pp = uniform_int_distribution<int>(0, kk-1)(rng);
// ---------------------///////////////---------------------------------
// ---------------------///////////////----------------------------------
// -------------/////////////////---------------------------------///////

// ll ap[26];

int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
      
    ll n;
    cin>>n;
    ll ap[n+11];
    for(ll i=0;i<n;i++){
      cin>>ap[i];
    }

    ll k=1;
    for(ll i=1;i<n;i++){
      if(ap[i]!=ap[i-1]){
        ap[k++] = ap[i]; 
      }
    }
    n = k;

    ll ans = 0;
    map<ll,ll>mp;
    
    for(ll i=0;i<n;i++){
      if(mp[ap[i]]){
        ans = (ans + mp[ap[i]])%mod;
        mp[ap[i]] = (ans+1)%mod;
      }else{
        mp[ap[i]] = (ans+1)%mod;
      }
    }


    cout<<(ans+1+mod)%mod;


    return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    char x=a.at(0);
    char y=a.at(1);
    char z=a.at(2);
    if(b.at(0)==z&&b.at(1)==y&&b.at(2)==x){cout<<"YES"<<endl;}
    else{cout<<"NO"<<endl;}
    return 0;
}

Measured memory_bytes: 256
N,A,B=map(int,input().split())
if (A-B)%2==0:
    print(abs(A-B)//2)
else:
    if (A+B)>N:
        print((abs(A-B)-1)//2+(min(N-A,N-B)+1))
    else:
        print((abs(A-B)-1)//2+(min(A-1,B-1)+1))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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 (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;
void solve()
{
	int h,w,m;
	cin>>h>>w>>m;
	unordered_set<int>hs,ws;
	vector<int>hm(3e5+1),wm(3e5+1);
	map<pair<int,int>,int>target;
	rep(i,m){
		int hi,wi;
		cin>>hi>>wi;
		target[make_pair(hi,wi)]=1;
		hm[hi]++;
		wm[wi]++;
		hs.insert(hi);
		ws.insert(wi);
	}
	int hmax=0;
	deque<int>hcand;
	for(auto i=hs.begin(); i!=hs.end(); i++){
		if(hmax<hm[*i]){
			hmax=hm[*i];
		}
	}
	for(auto i=hs.begin(); i!=hs.end(); i++){
		if(hmax==hm[*i]){
			hcand.push_back(*i);
		}
	}
	
	int wmax=0;
	deque<int>wcand;
	for(auto i=ws.begin(); i!=ws.end(); i++){
		if(wmax<wm[*i]){
			wmax=wm[*i];
		}
	}
	for(auto i=ws.begin(); i!=ws.end(); i++){
		if(wmax==wm[*i]){
			wcand.push_back(*i);
		}
	}
	//cout<<hmax<<" "<<wmax<<endl;
	int ans=0;
	rep(i,size(hcand))rep(j,size(wcand)){
		if(target[make_pair(hcand[i],wcand[j])]){
			ans=max(ans,hmax+wmax-1);
		}else{
			ans=max(ans,hmax+wmax);
			cout<<ans<<endl;
			return ;
		}
	}
	cout<<ans<<endl;

}

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


Measured memory_bytes: 53808
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    else {
        return false;
    }
}
struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    string w; cin >> w;
    int w_len = w.size();
    int ans = 0;
    string t;
    while (cin >> t) {
        if (t == "END_OF_TEXT") break;
        for (auto& c : t) {
            if ('A' <= c && c <= 'Z') {
                c = c - 'A' + 'a';
            }
        }
        if (w == t) {
            ans++;
        }
        //int t_len = t.size();
        //if (w_len > t_len) {
        //    continue;
        //}
        //rep(i, 0, t_len) {

        //}
    }
    cout << ans << endl;
}


Measured memory_bytes: 3196
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
string q="RDLU";
int n,m,to,co;
vs in;
void dfs(int x,int y,int to,string out){
	if(!co){
		cout<<out<<endl;
		return;
	}
	rep(k,4)if(k!=to){
		int nx=x,ny=y;
		while(nx>=0&&ny>=0&&nx<n&&ny<m&&in[nx][ny]!='o')nx+=dx[k],ny+=dy[k];
		if(nx>=0&&ny>=0&&nx<n&&ny<m);else continue;
		in[nx][ny]='.';co--;
		dfs(nx,ny,(k+2)%4,out+q[k]);
		in[nx][ny]='o';co++;
	}
}
signed main(){
	int x,y;
	cin>>n>>m;
	in=vs(n);
	rep(i,n)cin>>in[i];
	rep(i,n)rep(j,m)co+=in[i][j]=='o';
	rep(i,n)rep(j,m)rep(k,4)if(in[i][j]==q[k])
		x=i,y=j,to=(k+2)%4;
	
	dfs(x,y,to,"");
}






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

bool checkValidity(int a, int b, int c) 
{ 
    // check condition 
    if (a + b <= c || a + c <= b || b + c <= a) 
        return false; 
    else
        return true; 
}

int main(){
    
    int t;
    //cin >> t;
    t = 1;
    while(t--){
        int n;
        cin >> n;
        vector<int>l(n);
        for(int i = 0; i < n; i++){
            cin >> l[i];
        }
        
        int res = 0;
        for(int i = 0; i  <n; i++){
            for(int j = i + 1; j < n; j++){
                for(int k = j + 1; k < n; k++){
                    if(l[i] != l[j] && l[i] != l[k] && l[j] != l[k]){
                        if(checkValidity(l[i], l[j], l[k])){
                            res += 1;
                        }
                    }
                }
            }
        }
        
        cout << res << endl;
        
    }
    
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
typedef pair<ll,ll> ipair;
#define F first
#define S second
 
/*
//functions from gfg
 
long long int power(long long int x,long long int y,long long  int p)
{
    long long int res = 1;     // Initialize result
 
    x = x % p;  // Update x if it is more than or 
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            {//d=(long double)x/p;
            res = (res*x) % p;
            }
 
        // y must be even now
        y = y>>1; // y = y/2
        x=(x*x)%p;
        
    }
    return res%p;
}
 
long long int gcd(long long int a,long long int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
 
long long int binomialCoeff(long long int n, ll k) 
{ 
    ll res = 1; 
  
    // Since C(n, k) = C(n, n-k) 
    if (k > n - k) 
        k = n - k; 
  
    // Calculate value of [n*(n-1)*---*(n-k+1)] / [k*(k-1)*---*1] 
    for (ll i = 0; i < k; ++i) 
    { 
        res *= (n - i); 
        res /= (i + 1); 
    } 
  
    return res; 
} 
 

void sieve(int n, vector<ll> &primes) 
{ 
    vector<int> prime(n,1);
    ll p;
    for ( p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == 1) 
        { 
            
            for (int i=p*p; i<=n; i += p) 
                prime[i] = 0; 
        } 
    } 
  
    for(p=2;p<=n;p++)
    {
        if(prime[p])
        primes.pb(p);
    }
   
} 


void dfs(vector<ll> adj[] ,ll src,vector<ll> &vis)
{
    vis[src]=1;
    for(ll i=0;i<adj[src].size();i++)
    {
        if(vis[adj[src][i]]==0)
        dfs(adj,adj[src][i],vis)
    }
}
 
*/

int main() {
	ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
    
    
	ll n,i,j,p,k,m,ans=0;
    cin>>n;
    vector<ll> a(n);
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll sum=0;ll xr=0;
    ll val=1;
    ans=1;
    sum=a[0];
    xr=a[0];
    for(i=1;i<n;i++)
    {
       sum+=a[i];
       xr^=a[i];
       if(sum==xr)
       {
           ans+=val+1;
           val++;
       }
       else
       {
           while(val>0 && sum!=xr)
           {
               sum-=a[i-val];
               xr^=a[i-val];
               val--;
           }
           if(sum==xr)
           {ans+=val+1;
           val++;}
       }
    }
    cout<<ans<<endl;
    
    
    
    
    
    // for(i=0;i<n;i++)
    // {
    //     cout<<a[i]<<" ";
    // }
    // cout<<endl;
    
	return 0;
}

Measured memory_bytes: 4764
#include<cstdio> 
#include<cmath>
using namespace std;
long long n,ans;
int s;
int main(){
    scanf("%lld",&n); 
    for(int i=sqrt(n);i>0;--i)
        if(n%i==0){
            ans=n/i;
            break;
        }
    while(ans>0){
        ++s;
        ans/=10;
    }
    printf("%d\n",s);
    return 0;
} 

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] map = new int[n][n];
		int a, b;
		for (int i = 0; i < m; i++) {
			a = sc.nextInt() - 1;
			b = sc.nextInt() - 1;
			map[a][b]++;
			map[b][a]++;
		}
		int cnt;
		for (int i = 0; i < n; i++) {
			cnt = 0;
			for (int j = 0; j < n; j++) {
				if (map[i][j] > 0) {
					cnt += map[i][j];
				}
			}
			sb.append(cnt + "\n");
		}
		System.out.print(sb);
	}
}


Measured memory_bytes: 21844
# -*- coding utf-8 -*-
import numpy

N = int(input())
WN = list(map(int, input().split()))

W = [0] + list(numpy.cumsum(WN))

s = sum(W)
ans = 1e9
for i in range(N):
    ans = min(ans, abs((W[N] - W[i]) - W[i]))

print(ans)


Measured memory_bytes: 12508
#include<iostream>

using namespace std;

void swap(int& a,int& b)
{
    int tmp;
    if(a>b){
        tmp=a; a=b;  b=tmp;
    }
}

int main()
{
    int x[3000],y[3000];    

    for(int i=0;;i++){
        cin>>x[i]>>y[i];
        if(x[i]==0 && y[i]==0)  break;
    }

    for(int i=0;;i++){
        if(x[i]==0 && y[i]==0)  break;
        swap(x[i],y[i]);
        cout<<x[i]<<' '<<y[i]<<'\n';        
    }

}


Measured memory_bytes: 3072
#include"iostream"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"iomanip"
using namespace std;
typedef long long ll;
const ll maxn=55;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,p;cin>>n>>p;
    ll e=0,o=0;
    for(int i=0;i<n;++i)
    {
        int x;cin>>x;
        if(x&1)
        {
            o++;
        }
        else e++;
    }
    ll ans=(1LL<<e);
    ll ans1=(1LL<<o);
    if(p==0)
    {
        if(o>0)
        {
            cout<<ans*ans1/2<<'\n';
        }
        else
        {
            cout<<ans<<'\n';
        }
    }
    else
    {
        if(o>0)
            cout<<ans*ans1/2<<'\n';
        else
        {
            cout<<"0\n";
        }
    }
}

Measured memory_bytes: 256
def main():
    n = int(input())

    print(0,flush=True)
    s = input()
    if s=="Vacant": return 0
    cap = 0
    if s=="Female": cap = 1

    lo = 0
    hi = n
    while True:
        mid = (hi+lo)//2
        print(mid, flush=True)
        s = input()

        if s=="Vacant": return 0
        gen = 0
        if s=="Female": gen = 1

        if (cap+mid)%2 == gen:
            lo = mid
        else:
            hi = mid

main()


Measured memory_bytes: 3660
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int h, w; cin >> h >> w; std::vector<std::vector<int>> a(h, std::vector<int>(w));
	for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) cin >> a[i][j];
	
	int mi = 1 << 30;
	for(int x = 0; x < h; x++) {
		for(int y = 0; y < w; y++) {
			int cost = 0;
			for(int i = 0; i < h; i++) {
				for(int j = 0; j < w; j++) {
					cost += a[i][j] * std::min(std::abs(i - x), std::abs(j - y));
				}
			}
			mi = std::min(mi, cost);
		}
	}
	
	cout << mi << endl;
	return 0;
}



Measured memory_bytes: 3128
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



n, k = LI()
AB = LIR(n)

def count(d):
    ret = 0
    for a, b in AB:
        if not ~d & a:
            ret += b
    return ret

ans = count(k)
for i in range(k.bit_length()):
    if k >> i & 1:
        ans = max(ans, count(((k >> i) << i) - 1))

print(ans)



Measured memory_bytes: 59868
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H);
    for (auto &b : a)
    {
        b.resize(W);
        for (int i = 0; i < W; i++)
        {
            cin >> b[i];
        }
    }

    for (int i = 0; i < H; i++)
    {
        bool isDel = true;
        for (int j = 0; j < W; j++)
        {
            if (a[i][j] == '#')
            {
                isDel = false;
            }
        }
        if (isDel)
        {
            a.erase(a.begin() + i);
            H--;
            i--;
        }
    }

    for (int i = 0; i < W; i++)
    {
        bool isDel = true;
        for (int j = 0; j < H; j++)
        {
            if (a[j][i] == '#')
            {
                isDel = false;
            }
        }
        if (isDel)
        {
            for (int j = 0; j < H; j++)
            {
                a[j].erase(a[j].begin() + i);
            }
            W--;
            i--;
        }
    }

    for (auto b : a)
    {
        for (auto c : b)
        {
            cout << c;
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
  int h,w,k;
  cin >> h >> w >> k;
  vector<vector<int>> c(h,vector<int>(w));
  char a;
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      cin >> a;
      if(a=='.') c[i][j] = 0;
      else c[i][j] = 1;
    }
  }
  
  int c1,c2;
  int n=1;
  int r[h+w];
  int lp;
  c2 = 0;
  for(int i=0;i<h+w;++i) n*=2;
  for(int l=0;l<n;++l){
    lp = l;
    vector<vector<int>> cr(h,vector<int>(w));
    for(int p=0;p<h+w;++p){
      r[p] = lp%2;
      //cout<<r[p]<<endl;
      lp = (lp-r[p])/2;
    }
    for(int p=0;p<h;++p){
      if(r[p]==1) continue;
      for(int q=0;q<w;++q) cr[p][q] = 2;
    }
    for(int p=h;p<h+w;++p){
      if(r[p]==1) continue;
      for(int q=0;q<h;++q) cr[q][p-h] = 2;
    }
    c1=0;
    for(int i=0;i<h;++i){
      for(int j=0;j<w;++j){
        //cout<<cr[i][j]<<" ";
        if(c[i][j]==1 && cr[i][j]!=2) c1++;
      }
      //cout<<" "<<endl;
    }
    if(c1==k) c2++;
  }
  cout<<c2<<endl;

      
      

}

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

using namespace std;

int main()
{
   int n,m;
   cin>>n>>m;
   vector<int>h(n+1);
   for(int i=1;i<=n;i++){
     cin>>h[i];
   }
   vector<int>adj[n+1];
   for(int i=0;i<m;i++){
      int a,b;
      cin>>a>>b;
      adj[a].push_back(b);
      adj[b].push_back(a);
   }
   int cnt=0;
   for(int i=1;i<=n;i++){
    if(adj[i].size()==0){++cnt;continue;}
    bool ok=true;
    for(int j=0;j<(int)adj[i].size();j++){
        if(h[i]>h[adj[i][j]])continue;
        else{ok=false;break;}
    }
    if(ok)++cnt;
   }
   cout<<cnt<<endl;
}


Measured memory_bytes: 8744
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    ll sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    set<ll> cand;
    for(ll i = 1; i*i <= sum; i++){
        if(sum%i == 0){
            cand.insert(i);
            cand.insert(sum/i);
        }
    }
    ll ans = 1;
    for(ll x : cand){
        ll need;
        vector<ll> r(n);
        rep(i,n) r[i] = a[i] % x;
        sort(r.begin(), r.end());
        ll A = 0, B = 0;
        rep(i,n) B += x - r[i];
        need = 1e18;
        rep(i,n){
            A += r[i];
            B -= x - r[i];
            chmin(need, max(A, B));
        }
        if(need <= k) chmax(ans, x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string a, b ,c;
  cin >> a >> b >> c;
  string ans;
  ans.push_back(a[0]);
  ans.push_back(b[0]);
  ans.push_back(c[0]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*I wanna be the very best, like no one ever was...*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int MAX = 1e4;
const ll MOD = 1e9 + 7;
ll fact[MAX];
void calculate() {
	fact[0] = 1;
	for(int i = 1; i < MAX; i ++) {
		fact[i] = (fact[i - 1] * i) % MOD;
	}
}
ll modExp(ll b, ll p) {
	ll res = 1;
	while(p > 0) {
		if(p & 1) res = (res * b) % MOD;
		b = (b * b) % MOD, p >>= 1;
	}
	return res;
}
ll modInverse(ll n) {
	return modExp(n, MOD - 2); 
}
ll nCr(ll n, ll r) {
	return (fact[n] * modInverse(fact[n - r]) % MOD * modInverse(fact[r]) % MOD) % MOD;
}
void add(ll &a, ll b) {
	b %= MOD;
	a = (a + b) % MOD;
}
void mul(ll &a, ll b) {
	b %= MOD;
	a = (a * b) % MOD;
}
void sub(ll &a, ll b) {
	b %= MOD;
	a = (a - b) % MOD;
	a = (a + MOD) % MOD;
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	calculate();
	int s; cin >> s;
	ll ans = 0;
	for(int i = 1; i <= 2000; i ++) {
		if(3 * i > s) break;
		add(ans, nCr(s - 3 * i + i - 1, i - 1));
	}
	cout << ans;
	
	return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARGBCards solver = new ARGBCards();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARGBCards {
        private static final String YES = "YES";
        private static final String NO = "NO";

        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints() * 100 + in.ints() * 10 + in.ints();
            out.println(n % 4 == 0 ? YES : NO);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int c = 1;
	string a, b;
	cin >> a >> b;
	REPR(i, a.size() - b.size()) {
		FOR(j, i, i + b.size()) {
			if (a[j] == b[j - i] or a[j] == '?') {
				c = 1;
			}
			else {
				c = 0;
				break;
			}
		}
		if (c == 1) {
			FOR(j, i, i + b.size()) if (a[j] == '?') a[j] = b[j - i];
			REP(j, a.size()) if (a[j] == '?') a[j] = 'a';
			cout << a << endl;
			return 0;
		}
	}
	cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	A := make([][]int, 3)
	for i := 0; i < 3; i++ {
		A[i] = make([]int, 3)
		for j := 0; j < 3; j++ {
			fmt.Scanf("%d", &A[i][j])
		}
	}
	var N int
	fmt.Scanf("%d", &N)
	for i := 0; i < N; i++ {
		var b int
		fmt.Scanf("%d", &b)
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if A[j][k] == b {
					A[j][k] = 0
				}
			}
		}
	}
	for i := 0; i < 3; i++ {
		bingo := true
		for j := 0; j < 3; j++ {
			if A[i][j] != 0 {
				bingo = false
				break
			}
		}
		if bingo {
			fmt.Println("Yes")
			return
		}
		bingo = true
		for j := 0; j < 3; j++ {
			if A[j][i] != 0 {
				bingo = false
				break
			}
		}
		if bingo {
			fmt.Println("Yes")
			return
		}
	}
	if A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0 {
		fmt.Println("Yes")
		return
	}
	if A[2][0] == 0 && A[1][1] == 0 && A[0][2] == 0 {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 10100;
const int maxd = 110;
const ll modd = 1LL * 1e9 + 7;
ll dp[maxn][maxd][2][2];
string x;
ll d;

void solve() {

    dp[0][0][1][1] = 1LL;
    for(int len=0;len<x.length();len++) {
        for(int mod=0;mod<d;mod++) {
            for(int limit=0;limit<2;limit++) {
                for(int leading=0;leading<2;leading++) {
                    if(dp[len][mod][limit][leading] == 0) continue;

                    //cout<<len<<", "<<mod<<", "<<limit<<", "<<leading<<" -> "<<dp[len][mod][limit][leading]<<"\n";

                    if(leading) {
                        dp[len+1][mod][0][1] += dp[len][mod][limit][1];
                        if(limit) {
                            for(int ndigit=1;ndigit<(x[len]-'0');ndigit++) {
                                dp[len+1][(mod+ndigit)%d][0][0] += dp[len][mod][limit][leading];
                                dp[len+1][(mod+ndigit)%d][0][0] %= modd;
                            }
                            dp[len+1][(mod+(x[len]-'0'))%d][1][0] += dp[len][mod][limit][leading];
                            dp[len+1][(mod+(x[len]-'0'))%d][1][0] %= modd;
                        }
                        else {
                            for(int ndigit=1;ndigit<=9;ndigit++) {
                                dp[len+1][(mod+ndigit)%d][0][0] += dp[len][mod][limit][leading];
                                dp[len+1][(mod+ndigit)%d][0][0] %= modd;
                            }
                        }
                    }
                    else {
                        if(limit) {
                            for(int ndigit=0;ndigit<(x[len]-'0');ndigit++) {
                                dp[len+1][(mod+ndigit)%d][0][0] += dp[len][mod][limit][leading];
                                dp[len+1][(mod+ndigit)%d][0][0] %= modd;
                            }
                            dp[len+1][(mod+(x[len]-'0'))%d][1][0] += dp[len][mod][limit][leading];
                            dp[len+1][(mod+(x[len]-'0'))%d][1][0] %= modd;
                        }
                        else {
                            for(int ndigit=0;ndigit<=9;ndigit++) {
                                dp[len+1][(mod+ndigit)%d][0][0] += dp[len][mod][limit][leading];
                                dp[len+1][(mod+ndigit)%d][0][0] %= modd;
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<dp[x.length()][0][0][0] + dp[x.length()][0][1][0]<<"\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>x>>d;
    solve();
    return 0;
}


Measured memory_bytes: 34688
import sys

n=1001
a=[0]*2001
for i in range(n):
  for j in range(n):
    a[i+j]+=1
for n in map(int,sys.stdin):
  x=0
  for i in range(max(0,n-2000),min(n,2000)+1):
    x+=a[i]*a[n-i]
  print x

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

using namespace std;

#define int 		long long
#define endl		"\n"
#define mod			1000000007
#define inf			1e12
#define IOS			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

vector<vector<long double>> m;

long double dp(int i, int n, int heads, vector<long double>& p) {
	if (i == n || heads == 0)
		return 1;

	if (m[i][heads] != -1)
		return m[i][heads];

	long double ans;
	if (heads == n - i) {
		ans = p[i] * dp(i + 1, n, heads - 1, p);
	}
	else {
		ans = (1 - p[i]) * dp(i + 1, n, heads, p) + p[i] * dp(i + 1, n, heads - 1, p);
	}

	return m[i][heads] = ans;
}

int32_t main() {

	IOS;

	int n;
	cin >> n;
	vector<long double> p(n);

	for (int i = 0; i < n; i++)
		cin >> p[i];

	long double ans;
	m = vector<vector<long double>>(n, vector<long double>(n + 1, -1));

	ans = dp(0, n, n / 2 + 1, p);

	cout << setprecision(10) << ans << endl;

	return 0;
}

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

    unsigned long long X,m,n,x,y,z,sum;
    scanf("%llu",&X);
    m=X/500;
    n=m*1000;
    x=X%500;
    y=x/5;
    z=y*5;
    sum=n+z;
    printf("%llu\n",sum);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main(){
  int i,j,k;
  int p,c,n,r,s[5133];
  s[0]=2;
  for(i=3,j=1;i<50000;i+=2){
    r=(int)sqrt(i)+1;
    for(k=3;k<r;k+=2){
      if(i%k==0)
	r=0;
    }
    if(r){
      s[j]=i;
      j++;
    }
  }
  n=j;
  for(;;){
    scanf("%d",&p);
    if(p==0)
      break;
    c=0;
    if(p%2){
      for(i=(int)(p/9.75);;i++){
	if(s[i]==p-2){
	  c=1;
	  break;
	}else if(s[i]>p-2)
	  break;
      }
    }else{
      if(p==4)
	c=1;
      else{
	for(i=1;s[i]*2<=p;i++){
	  for(j=(i<(p-s[i])/9.75?(int)((p-s[i])/9.75):i);;j++){
	    if(s[i]+s[j]==p){
	      c++;
	      break;
	    }else if(s[i]+s[j]>p)
	      break;
	  }
	}
      }
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 428
import java.io.*;
import java.math.*;
import java.util.*;
import java.lang.*;

// import java.text.DecimalFormat; 
// import java.text.DecimalFormatSymbols; 
 
 
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
 
public class Main {
    
    
    public static void main(String args[] ) throws Exception {
        StringBuffer str = new StringBuffer();
        PrintWriter pw=new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
        int n = sc.nextInt();
        int w = sc.nextInt();
        int[][] a = new int[n][2];
        for(int i=0;i<n;i++){
            a[i][0] = sc.nextInt();
            a[i][1] = sc.nextInt();
        }
        long[][] dp = new long[n+1][w+1];
        for(int i=1;i<=n;i++){
            for(int j=0;j<=w;j++){
                int t = j-a[i-1][0];
                dp[i][j]=dp[i-1][j];
                if(t>=0){
                    dp[i][j]=Math.max(dp[i][j],dp[i-1][t]+a[i-1][1]);
                }
                //System.out.print(dp[i][j]+" ");
            }
            //System.out.println();
        }
        str.append(dp[n][w]);
        
        
        
        pw.println(str.toString());
        
        pw.close();
    }
     
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		public String next(int k) {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return "Not able to read";
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
		
	    
	}
   
}

Measured memory_bytes: 138520
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::collections::BinaryHeap;

fn main() {
  let mut n = read::<i32>();
  let m = read::<i32>();
  let mut bh_x: BinaryHeap<i32> = BinaryHeap::new();
  for _ in 0..m {
    let x = read::<i32>();
    bh_x.push(x);
  }

  let mut dist: BinaryHeap<i32> = BinaryHeap::new();

  let mut prev_v = 1000000;
  let mut index = 0;

  while true {
    let pop_x = match bh_x.pop() {
      Some(s) => s,
      None => break,
    };

    if prev_v == 1000000 {
      prev_v = pop_x;
      continue;
    } else {
      dist.push((prev_v - pop_x).abs())
    }
    prev_v = pop_x;
    index += 1;
  }

  while n - 1 > 0 {
    n -= 1;
    dist.pop();
  }

  let ans: i32 = dist.iter().sum();
  println!("{}", ans);
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
using namespace atcoder;
using ll = long long;

int main() {
    int n, m;
    cin >> n >> m;
    dsu d(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        d.merge(a, b);    
    }
    vector<int> ans;
    int cnt = 0, bef = -1;
    rep(i, n) ans.push_back(d.leader(i));
    sort(ans.begin(), ans.end());
    for (auto i : ans) {
        if (i != bef) {
            cnt++;
            bef = i;
        }
    }
    cout << cnt - 1 << endl;
    
    return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
using namespace std;
long long N, M, X;
vector<vector<long long>> A;
vector<long long> C;
long long INF = 1e18;
long long dfs(int x, int i, vector<int> use){
  if(i == N){
    vector<long long> sum(M, 0);
    long long res = 0;
    for(int j = 0; j < N; j++){
      if(use[j] == 1){
        for(int k = 0; k < M; k++) sum[k] += A[j][k];
        res += C[j];
      }
    }
    int flag = 0;
    for(int j = 0; j < M; j++){
      if(sum[j] < X) flag = 1;
    }
    if(flag == 1) return INF;
    else return res;
  }
  use[i] = x;
  long long t = dfs(0, i + 1, use);
  long long s = dfs(1, i + 1, use);
  return min(t, s);
}
int main(){
  cin >> N >> M >> X;
  A.resize(N, vector<long long> (M));
  C.resize(N);
  for(int i = 0; i < N; i++){
    cin >> C[i];
    for(int j = 0; j < M; j++) cin >> A[i][j];
  }
  vector<int> used(N);
  long long ans = INF;
  long long res1 = dfs(0, 0, used), res2 = dfs(1, 0, used);
  ans = min(ans, min(res1, res2));
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}



Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<math.h>
#include<iomanip>

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
const int INF = 1<<30;
int main(){
  ll n, p;cin>>n>>p;
  if(n==1){cout<<p<<endl;return 0;}
  ll ans=1;
  ll i=2;
  while(p!=1){
    if(pow(i, n)>p)break;
    if(p%i==0){
      ll tmp=pow(i, n);
      int count=0;
      while(p%tmp==0){
        p/=tmp;count++;
      }
      ans*=pow(i, count);
    }
    i++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
n = int(input())
list_v = list(map(int, input().split()))
list_c = list(map(int, input().split()))
list_k = []

for i in range(n):
    l = list_v[i]-list_c[i]
    if l > 0:
        list_k.append(l)

print(sum(list_k))

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

int main(){
    std::string str;
    std::cin >> str;

    std::string rev = str;
    std::reverse(str.begin(), str.end());
    if(str == rev){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }

    return 0;
}


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

int main(){
  string S,T;
  cin >> S >> T;
  vector<int> res(0);
  
  for (int i = 0; i < S.size() - T.size() + 1; i++){
    int ans = 0;
    
    for (int j = 0; j < T.size(); j++){
      if (S[i + j] != T[j]){
        ans++;
      }
    }
    
    res.push_back(ans);
  }
  
  sort(res.begin(), res.end());
  cout << res[0] << endl;
}

Measured memory_bytes: 3628
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int b = sc.nextInt(); 
        int c = 0;
        while (a>0){a/=b; c++;}
		System.out.println(c);
	}
}


Measured memory_bytes: 21844
#include<iostream>
int main() {
    int a,b,c,j=0;
    std::cin>>a>>b>>c;
    for(int i=a,j=1;j<=1000;i+=a,++j)
        if(i%b==c){
            std::cout<<"YES"<<std::endl;
            return 0;
        }
    std::cout<<"NO"<<std::endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    val sc: List<String> = readLine()!!.split(" ")
    if(sc[0].toInt() < 10 && sc[1].toInt() < 10) {
        println(sc[0].toInt() * sc[1].toInt())
    }else{
        println("-1")
    }
}

Measured memory_bytes: 37676
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, ans;
	cin >> n;
	for(int i = 1; i <= 1000000; i++)
	{
		if(i * i > n)
		{
			cout << ans << endl;
			return 0;
		}
		ans = i * i;
	}
	return 0;
}



Measured memory_bytes: 256
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

A, B = map(int, input().split())
AY = make_divisors(A)
BY = make_divisors(B)
AB = set(AY) & set(BY)
AB = list(AB)
cnt = [i for i in range(len(AB)) if is_prime(AB[i])]
print(len(cnt))

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

int N;
int A[210];         // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

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

    int res = 0;

    // 操作が行える限り操作を繰り返す
    while (true) {
        bool exist_odd = false;  // A[i] がすべて偶数かどうかを判定するフラグ
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;  // 奇数があったらフラグを立てる
        }

        if (exist_odd) break;  // 奇数があったら break

        // 操作を行えるなら操作を実際に行う
        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res;  // 操作回数をインクリメント
    }

    cout << res << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

map<char, int> mp;

int compute(string &t, int price[3]){
	int n = t.size();
	int dp[n + 1][3];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = dp[1][0] = dp[2][0] = 0;
	for(int i = 1; i <= n; i++){
		int val = (mp[t[i - 1]] + 1)%3;
		for(int pr = 0; pr < 3; pr++){
			for(int nx = 0; nx < 3; nx++){
				if(nx == pr)continue;
				if(nx != val)dp[i][nx] = max(dp[i][nx], dp[i - 1][pr]);
				else dp[i][nx] = max(dp[i][nx], dp[i - 1][pr] + price[val]);
			}
		}
	}
	return max({dp[n][0], dp[n][1], dp[n][2]});
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	mp['r'] = 0; mp['p'] = 1; mp['s'] = 2;
	int n, k, r, s, p;
	string t;
	cin>>n>>k>>r>>s>>p>>t;
	int price[3] = {r, p, s};
	int ans = 0;
	for(int i = 0; i < k; i++){
		string str = "";
		for(int j = i; j < n; j += k){
			str += t[j];
		}
		ans += compute(str, price);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

N = int(input())
X = list(map(int, input().split()))

## Logic

ans = 0
ave = round(sum(X)/len(X))

for i in range(0,N):
    ans += (X[i]-ave)**2
print(ans)

Measured memory_bytes: 65772
import sys
from collections import defaultdict
from operator import itemgetter

input = sys.stdin.readline

N, M = map(int, input().split())

A = defaultdict(list)
for i in range(M):
    P, Y = map(int, input().split())
    A[P].append((Y, i))

ans = [None] * M
for k, v in A.items():
    v.sort(key=itemgetter(0))
    for i in range(len(v)):
        _, j = v[i]
        c1 = str(k).zfill(6)
        c2 = str(i + 1).zfill(6)
        ans[j] = c1 + c2
print('\n'.join(ans))


Measured memory_bytes: 47248
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    ll q;
    cin >> q;

    while(q--) {

        ll a, b;
        cin >> a >> b;

        if (a == b || a + 1 == b) {
            cout << 2 * a - 2 << endl;
        } else {
            ll p = a * b;
            ll res = static_cast<long long int>(sqrt(p));
            if(res * res == p)res--;
            if (res * (res + 1) >= p)cout << 2 * res - 2 << endl;
            else cout << 2 * res - 1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC59 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x,y = LI()
if abs(x-y) <= 1:
    print('Brown')
else:
    print('Alice')


Measured memory_bytes: 40636
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<iterator>
#define ll long long
#define mod 1000000007
#define inf 100000000000000
using namespace std;
vector<int> adj[100001];
void addEdge(int u, int v)
{
	adj[u].push_back(v);
}
void dfs(int node, bool vis[], int dp[])
{
	vis[node]=true;
	vector<int>:: iterator i;
	for(i=adj[node].begin(); i!=adj[node].end(); i++)
	{
		if(!vis[*i])
		{
			dfs(*i,vis,dp);
		}
		dp[node]=max(dp[node],1+dp[*i]);
	}
}
int FindPath(int n)
{
	bool vis[n+1];
	memset(vis,false,sizeof(vis));
	int dp[n+1]; 
	memset(dp,0,sizeof(dp));
	int i;
	for(i=1; i<=n; i++)
	{
		if(!vis[i])
		{
			dfs(i,vis,dp);
		}
	}
	int max1=0;
	for(i=1; i<=n; i++)
	{
		max1=max(max1,dp[i]);
	}
	return max1;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	int i,j;
	for(i=0; i<m; i++)
	{
		int u,v;
		cin>>u>>v;
		addEdge(u,v);
	}
	cout<<FindPath(n+1)<<"\n";
	return 0;
}


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

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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int n,k;
  cin>>s>>k;
  n=len(s);
 vector<int> cnt(n);
 rep(i,n){
   if(s[i]=='a') continue;
   cnt[i]=(int)'{'-s[i];
 }
 rep(i,n){
   if(k>=cnt[i]){
     k-=cnt[i];
     s[i]='a';
     if(k==0) break;
   }
   if(i==n-1 && k>0){
     k%=26;
     while(k){
       s[i]++;
       if(s[i]=='{') s[i]='a';
       k--;
     }
   } 
 }
 cout<<s<<endl;
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
#define P pair<long long, long long>

using namespace std;

int main(){
  long long x;
  cin >> x;
  for(long long i=-1000;i<=1000;i++){
    for(long long j=-1000;j<=1000;j++){
      long long value=i*i*i*i*i-j*j*j*j*j;
      if(value==x){
        cout << i << ' ' << j << endl;
        return 0;
      }      
    }
  }
}



Measured memory_bytes: 3608
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
len_set = len(list(set(A)))
CA = Counter(A)
count = 0
for i,j in CA.items():
  if j%2 == 0:
    count += 1

if count%2 == 0:
  ans = len_set
else:
  ans = len_set - 1

print(ans)

Measured memory_bytes: 20188
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll n;
ill DFS(ll n){
	if(n==1) return 1;
	return 2*DFS(n>>1)+1;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	print(DFS(n));
	return 0;
}

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

int main(){
    int x,y;
    cin>>x>>y;
    for(int i=0;i<=x;i++){
        if((2*i+4*(x-i))==y){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll ch[100010],cnt,ans[100010],cnt2[100010];
vector<ll>c[100010];
void dep(ll now){
	for(ll i=0;i<c[now].size();i++){
		ll next=c[now][i];
		if(ch[next]==0){
			ch[next]=cnt;
			dep(next);
		}
	}
}
int main() {
	ll n,m,k;
	cin>>n>>m>>k;
	for(ll i=0;i<m;i++){
		ll a,b;
		cin>>a>>b;
		a--;b--;
		c[a].push_back(b);
		c[b].push_back(a);
	}
	cnt=1;
	for(ll i=0;i<n;i++){
		if(ch[i]==0){
			ch[i]=cnt;
			dep(i);
			cnt++;
		}
	}
	for(ll i=0;i<k;i++){
		ll a,b;
		cin>>a>>b;
		a--;b--;
		if(ch[a]==ch[b]){
			cnt2[a]--;
			cnt2[b]--;
			//cout << "k"<<endl;
		}
	}
	for(ll i=0;i<n;i++){
		ll now=ch[i];
		ans[now]++;
	}
	for(ll i=0;i<n;i++){
		ll now=ch[i];
		cout <<ans[now]-c[i].size()-1+cnt2[i]<<" ";		
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 9728
#include <iostream>
#include <set>
#include <string>

using namespace std;

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

    bool ans = true;
    if (S.front() != 'A') {
        ans = false;
    }
    multiset<char> cnt;
    for (int i = 2; i < S.size() - 1; ++i) {
        cnt.insert(S[i]);
    }
    if (cnt.count('C') != 1) {
        ans = false;
    }
    for (int i = 1; i < S.size(); ++i) {
        if (S[i] == 'C') continue;
        if (isupper(S[i])) {
            ans = false;
        }
    }
    if (ans) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
}


Measured memory_bytes: 888