akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int size = sqrt(n);
	int blocks = (n + size-1) / size;
	int v[blocks][27] = {0};
	for(int i = 0; i < blocks; i++){
		for(int j = i*size; j < (i+1)*size && j < n; j++){
			v[i][s[j] - 'a']++;
		}
	}
	int q;
	cin >> q;
	while(q--){
		int type;
		cin >> type;
		if(type == 1){
			int pos;
			char c;
			cin >> pos >> c;
			pos--;
			if(s[pos] == c)
				continue;
			int inBlock = pos / size;
			v[inBlock][s[pos]-'a']--;
			v[inBlock][c-'a']++;
			s[pos] = c;
		}
		else{
			int l, r;
			cin >> l >> r;
			l--;	r--;
			int start = l / size, end = r / size;
			if(start == end){
				int cnt[26] = {0};
				for(int i = l; i <= r; i++){
					cnt[s[i]-'a']++;
				}
				int ans = 0;
				for(int i = 0; i < 26; i++)
					if(cnt[i])
						ans++;
				cout << ans << endl;
			}
			else{
				int cnt[26] = {0};
				for(int i = l; i < (start+1)*size && i < n; i++){
					cnt[s[i]-'a']++;
				}
				for(int i = start+1; i < end; i++){
					for(int j = 0; j < 26; j++)
						cnt[j] += v[i][j];
				}
				
				for(int i = end*size; i <= r; i++)
					cnt[s[i]-'a']++;
				
				int ans = 0;
				for(int i = 0; i < 26; i++)
					if(cnt[i])
						ans++;
						
				cout << ans << endl;
			}
		}
	}

	return 0;
}



Measured memory_bytes: 1028
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<functional>

#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define rrep(i, n) for(int i=(int)(n); i>=0;i--)

using namespace std;

int main() {

  int a,b,c;
  cin >> a >> b >> c;
  int ans = c - (a - b) < 0 ? 0 : c - (a - b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>> 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define pll pair <lli,lli>
#define vll vector <lli>
#define vpll vector <pll>
#define f first
#define s second
#define pb push_back
#define priq priority_queue
#define unm unordered_map
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld double
#define eb emplace_back
const long double pi = 3.1415926535898;
const lli mod=1e9+7;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i*i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=2*i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
lli n;
lli a[401];
lli pre[401];
lli dp[401][401];
lli find(lli l,lli r)
{
    if (l>=r)
    return 0;
    if (dp[l][r]!=-1)
    return dp[l][r];
    dp[l][r]=1e18;
    for (int i=l;i<=r-1;i++)
    {
        dp[l][r]=min(dp[l][r],find(l,i)+find(i+1,r)+pre[r]-pre[l-1]);
    }
    return dp[l][r];
}
int main()
{
    fio;
    cin>>n;
    a[0]=0;
    pre[0]=0;
    mem(dp,-1);
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
        pre[i]=a[i]+pre[i-1];
        dp[i-1][i]=a[i-1]+a[i];
    }
    find(1,n);
    cout<<dp[1][n];
    return 0;
}

Measured memory_bytes: 4888
#include<iostream> 
#include<algorithm> 
#include<cstdio> 
#include<string>
#include<cmath>
#include<cstring>
using namespace std; 
int main() 
{ 
 	int k,s;
	cin>>k;
	s=k/2;
	if(k%2==0)
	cout<<s*s;
	else
	cout<<(s+1)*s;
	return 0; 
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int i, k, n, m, st;
    int A[102];

    cin >> n >> m;
    for (i = 0; i < n; i++) {
        cin >> A[i];
    }
    for (k = 1; k <= m; k++) {
        for (i = 0; i < n-1; i++) {
            if (A[i]%k > A[i+1]%k) {
                st = A[i];
                A[i] = A[i+1];
                A[i+1] = st;
            }
        }
    }
    for (i = 0; i < n; i++) {
        cout << A[i] << endl;
    }
//    cout << endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i, s.size()){
        ans += (s[i]-'0');
        ans %= 9;
    }
    if (ans == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3748
#include <stdio.h>

int main(){
  int n, i, j = 0;
  int prime[10001];
  for(i = 2; i <= 10000; i++) {
    prime[i] = 1;
  }
  for(i = 2; i*i <= 10000; i++) {
    if(prime[i]) {
      for(j = 2 * i; j <= 10000; j += i) {
        prime[j] = 0;
      }
    }
  }
  while(1){
    scanf("%d", &n);
    if(n == 0) break;
    for(i=n ; i >= 5 ; i--){
      if(prime[i] && prime[i-2]) break;
    }
    printf("%d %d\n", i - 2, i);
  }
  return 0;
}

Measured memory_bytes: 1900
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define R cin>>
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

vector<double> sieve(int n) {
  vector<double> p(n);
  REP(i,2,n) p[i]=i;
  for(int i=2; i*i<n; i++) {
    if(p[i]) {
      for(int j=i*i; j<n; j+=i) p[j]=0;
    }
  }
  p.erase(remove(all(p),0),p.end());
  return p;
}

int main() {
  vector<double> p=sieve(100000);
  double n,a,b;
  while(R n >> a >> b && n) {
    double M=0;
    int x,y;
    rep(i,p.size()) {
      REP(j,i,p.size()) {
	if(n<p[i]*p[j]) break;
	if(p[i]/p[j]<a/b) break;
	if(M<p[i]*p[j]) {
	  M=p[i]*p[j];
	  x=p[i],y=p[j];
	}
      }
    }
    PR(x,y);
  }
  return 0;
}


Measured memory_bytes: 1800
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}
 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;
}

const ll N=2e6+5;

ll dp[N];

bool use[N];

int main()
{ 

  IOS;

  ll n,k;
  cin>>n>>k;

  ll ans=0;

  for(int i=0;i<n;i++){
    ll x;cin>>x;
    ans+=2*min(x,abs(k-x));
  }

  cout<<ans<<endl;

return 0;
 
}


/*0
0
4
4
12
990998587
804665184
*/

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

int dp[105][5][2];

int main() {
    string s;
    int K;
    cin >> s >> K;
    dp[0][0][0] = 1;
    int n=s.length();

    rep(i, n) rep(k, K+1) rep(t, 2) {
        int d=s[i]-'0';
        rep(j, 10) {
            if(t == 0 && j>d) continue;
            if(t == 0 && j==d) {
                dp[i+1][k+(j>0)][0] += dp[i][k][t];
            } else {
                dp[i+1][k+(j>0)][1] += dp[i][k][t];
            }
        }
    }
    cout << dp[n][K][0]+dp[n][K][1] << endl;
    return 0;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}
ll n,m;
vector<ll> g[50];
bool reached[8];
void dfs(ll pre,ll& sum){
  reached[pre]=true;
  bool flag=true;
  rep(i,n) if(!reached[i]) flag=false;
  if(flag) sum++;
  for(auto tmp:g[pre]) if(!reached[tmp]) dfs(tmp,sum);
  reached[pre]=false;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  
  cin>>n>>m;
  
  rep(i,m){
    ll a,b;cin>>a>>b;a--;b--;
    g[b].push_back(a);
    g[a].push_back(b);
  }
  ll ans=0;
  dfs(0,ans);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;
 
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;
 
int n,m,s[2001],t[2001]={0};

signed main()
{
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }
    int out = 1;
 
    std::vector<int> sumarray(n, 0);
    for (int i = 0; i < m; i++) {
        int temp = 0;
        for (int j = 0; j < n; j++) {
            if (j == 0) {
                temp += sumarray[j];
                if (t[i] == s[j]) {
                    sumarray[j] += 1;
                }
            } else {
                if (t[i] == s[j]) {
                    int prev = temp + sumarray[j];
                    sumarray[j] += (temp + 1) % MOD;
                    temp = prev;
                } else {
                    temp += sumarray[j];
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        out += sumarray[i];
        out %= MOD;
    }
    cout << out << endl;
    return 0;
}


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

int main() {
	int L, R;
	cin >> L >> R;
	if (L / 2019 != R / 2019) {
		cout << 0 << endl;
		return 0;
	}
	L %= 2019;
	R %= 2019;
	int ans = 2020;
	for (int i = L;i <= R;i++) {
		for (int j = i + 1;j <= R;j++) {
			ans = min(ans, (i*j) % 2019);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#import <atcoder/all>
int T, n, m, a, b;
class FastIO
{
    static const int rdata_sz = (1 << 25), wdata_sz = (1 << 25);
    char rdata[rdata_sz], wdata[wdata_sz], *rb, *wb;
    char tmp_s[20];

public:
    FastIO()
    {
        fread(rdata, 1, rdata_sz, stdin);
        rb = rdata;
        wb = wdata;
    }
    ~FastIO()
    {
        fwrite(wdata, 1, wb - wdata, stdout);
    }

    template <typename T>
    inline void read(T &x)
    {
        bool neg = false;
        x = 0;
        while ((*rb < '0' || *rb > '9') && *rb != '-')
            ++rb;
        if (*rb == '-')
        {
            neg = true;
            ++rb;
        }
        while ('0' <= *rb && *rb <= '9')
        {
            x = 10 * x + (*rb - '0');
            ++rb;
        }
        if (neg)
            x = -x;
    }

#define pc(x) *(wb++) = x
    template <typename T>
    inline void write(T x)
    {
        if (x == 0)
        {
            pc('0');
            pc('\n');
            return;
        }
        if (x < 0)
        {
            pc('-');
            x = -x;
        }
        char *t = tmp_s;
        while (x)
        {
            T y = x / 10;
            *(t++) = (x - y * 10) + '0';
            x = y;
        }
        while (t != tmp_s)
            pc(*(--t));
        pc('\n');
    }
#undef pc
};
main()
{
    FastIO io;
    io.read(T);
    for (int i = 0; i < T; i++)
    {
        io.read(n);
        io.read(m);
        io.read(a);
        io.read(b);
        io.write(atcoder::floor_sum(n, m, a, b));
    }
}

Measured memory_bytes: 7396
S=str(input())
T=str(input())
co=0
cou=0
lista=[]
listb=[]
for i in S:
    co+=1
    lista.append(i)
for j in T:
    cou+=1
    listb.append(j)
del listb[-1]
if lista==listb:
    if cou-co==1:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 9076
function main(input){
  var line1 = parse(input[0]);
  var n = line1[0];
  var a = parse(input[1]);
  var sorted = a.slice(0, a.length).sort((k, l) => k - l);
  var max = sorted[n-1];

  var r = sorted[0];
  for (var i = 1; i < n-1; i++){    
    var d1 = max / 2 - sorted[i];
    var d2 = max / 2 - r;
    if (Math.abs(d1) < Math.abs(d2)) {
      r = sorted[i];
    }
    if (d1 <= 0) {
      break;
    }
  }
  console.log(max + ' ' + r);
}

function parse(line){
  var ret = [];
  var arr = line.split(' ');
  for (var i = 0; i < arr.length; i++) {
    ret.push(parseInt(arr[i]));
  }
  return ret;
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});


Measured memory_bytes: 42924
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    string S; cin >> S;
    int A = S[0] - '0';
    int B = S[1] - '0';
    int C = S[2] - '0';
    int D = S[3] - '0';
    if     (A + B + C + D == 7) cout << A << '+' << B << '+' << C << '+' << D << '=' << 7 << endl;
    else if(A + B + C - D == 7) cout << A << '+' << B << '+' << C << '-' << D << '=' << 7 << endl;
    else if(A + B - C + D == 7) cout << A << '+' << B << '-' << C << '+' << D << '=' << 7 << endl;
    else if(A + B - C - D == 7) cout << A << '+' << B << '-' << C << '-' << D << '=' << 7 << endl;
    else if(A - B + C + D == 7) cout << A << '-' << B << '+' << C << '+' << D << '=' << 7 << endl;
    else if(A - B + C - D == 7) cout << A << '-' << B << '+' << C << '-' << D << '=' << 7 << endl;
    else if(A - B - C + D == 7) cout << A << '-' << B << '-' << C << '+' << D << '=' << 7 << endl;
    else if(A - B - C - D == 7) cout << A << '-' << B << '-' << C << '-' << D << '=' << 7 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, m, a[310][310];
int ans = INF;
int cnt[310];
int k[310];
bool bl[310];

signed main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
			if (!j)cnt[a[i][j]]++;
		}
	}
	fill(bl, bl + m + 5, true);
	for (int i = 0; i < m; i++) {
		int s = 0, ma = 0;
		for (int j = 1; j <= m; j++) {
			if (ma < cnt[j]) {
				ma = cnt[j];
				s = j;
			}
		}
		bl[s] = false;
		cnt[s] = 0;
		ans = min(ans, ma);
		for (int j = 0; j < n; j++) {
			if (a[j][k[j]] == s) {
				while (!bl[a[j][k[j]]])k[j]++;
				cnt[a[j][k[j]]]++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
if(a+b>c+d){
cout<<"Left"<<endl;
}
else if(a+b<c+d){
cout<<"Right"<<endl;
}
else{
cout<<"Balanced"<<endl;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=3e5+7;
map<int,int> mp;
int main()
{
	int n,k,m;cin>>n>>k>>m;
	for(int i=1;i<=m;i++)
	{
		int x;cin>>x;mp[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		int tmp;
		if(mp.count(i)) tmp=mp[i];
		else tmp=0;
		if(k+tmp>m) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3584
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long N, long long W, std::vector<long long> w,
           std::vector<long long> v) {
  vector<vector<ll>> max_value(N, vector<ll>(W + 1, 0));

  max_value[0][w[0]] = v[0];
  for (int i = 1; i < N; ++i) {
    for (int j = 0; j <= W; j++) {
      if (j - w[i] >= 0) {
        max_value[i][j] = max(max_value[i - 1][j],
                              max_value[i - 1][j - w[i]] + v[i]);
      } else {
        max_value[i][j] = max_value[i - 1][j];
      }
    }
  }
  ll max_ = 0;
  for (int j = 0; j <= W; j++) {
    max_ = max(max_, max_value[N - 1][j]);
  }
  std::cout << max_ << std::endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long W;
  scanf("%lld", &W);
  std::vector<long long> w(N);
  std::vector<long long> v(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &w[i]);
    scanf("%lld", &v[i]);
  }
  solve(N, W, std::move(w), std::move(v));
  return 0;
}


Measured memory_bytes: 79488
#include<bits/stdc++.h>
#define MAXN 100005
#define inf 1000000000001
using namespace std;

int main (){
	
	//freopen("t.txt","r",stdin);
	int n;	long b[111],a[111];
	cin>>n;
	for(int i=1;i<=n-1;i++){
		cin>>b[i];
	}
	long long sum=0;
	a[1]=b[1];
	for (int i=2;i<n;i++){
		a[i]=min(b[i],b[i-1]);
	}
	a[n]=b[n-1];
	for (int i=1;i<=n;i++){
		sum+=a[i];
	}
	cout<<sum;
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fr(i,k) for(i=0;i<k;i++)
#define ALL(c) (c).begin(),(c).end()
#define deb(x) cerr<<#x<<"  = "<<x<<endl;
#define SZ(x) (x).size();
#define ll long long
#define MOD 1000000007
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define em emplace_back
#define ulli unsigned long long int
#define INF 1e18
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
void solve();

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main() {
	fastio;
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	int t;
	t=1;

    //cin>>t;
	while (t--)
	{
		solve();
	}
	return 0;
}

ll calc(ll a[],ll i,ll j,vector<vector<ll>> &dp)
{
    if(i>j)
        return 0;

    if(dp[i][j]!=-1)
    return dp[i][j];

    dp[i][j]=max(a[i]+min(calc(a,i+2,j,dp),calc(a,i+1,j-1,dp)),a[j]+min(calc(a,i,j-2,dp),calc(a,i+1,j-1,dp)));

    return dp[i][j];
}

void solve()
{
    ll n,i,s=0,k,b;
    cin>>n;

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

    vector<vector<ll>> dp(n,vector<ll>(n,-1));

    k=calc(a,0,n-1,dp);
    b=s-k;

    cout<<k-b<<endl;
}


Measured memory_bytes: 73924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  cin >> n;
  vector<int> c(n), s(n), f(n);
  for(int i=0; i<n-1; i++){
    cin >> c[i] >> s[i] >> f[i];
  }
  for(int i=0; i<n; i++){
    int ans = 0;
    for(int j=i; j<n-1; j++){
      if(ans<s[j]) ans=s[j];
      else if(ans%f[j]==0) ans += 0;
      else ans = ans + f[j] - ans%f[j];
      ans += c[j];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}





Measured memory_bytes: 25216
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
using namespace std;

const double PI=acos(-1);

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int diffx = x2-x1, diffy = y2-y1;
    int x3 = x2 - diffy, y3 = y2 + diffx;
    int x4 = x3 - diffx, y4 = y3 - diffy;
    printf("%d %d %d %d\n", x3, y3, x4, y4);
    return 0;
}

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
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()))

def dfs(s,p):
    for v in edges[s]:
        if v == p:
            continue
        dist[v] = dist[s] + 1
        dfs(v,s)
    return 
    
n = I()
edges = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = LI()
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
dist = [0]*n
dfs(0,-1)
R,B = 0,0
r,b = [],[]
for i in range(n):
    if dist[i] % 2:
        R += 1
        r.append(i)
    else:
        B += 1
        b.append(i)

ans = [None]*n
f = defaultdict(lambda:0)
if R <= n//3:
    tmp = 3
    for i in r:
        ans[i] = tmp
        f[tmp] = 1
        tmp += 3
    for i in range(1,n+1):
        if f[i]:
            continue
        if b:
            v = b.pop()
            ans[v] = i
            f[i] = 1
elif B <= n//3:
    tmp = 3
    for i in b:
        ans[i] = tmp
        f[tmp] = 1
        tmp += 3
    for i in range(1,n+1):
        if f[i]:
            continue
        if r:
            v = r.pop()
            ans[v] = i
            f[i] = 1
else:
    for i in range(1,n+1):
        if i % 3 == 1:
            if r:
                v = r.pop()
                ans[v] = i
                f[i] = 1
                continue
        elif i % 3 == 2:
            if b:
                v = b.pop()
                ans[v] = i
                f[i] = 1
                continue
    for i in range(1,n+1):
        if i % 3 == 0:
            if r:
                ans[r.pop()] = i
            elif b:
                ans[b.pop()] = i
print(*ans)

Measured memory_bytes: 182148
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define make make_pair
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
      	ll n,l;cin>>n>>l;
	ll orig=0;
	rep(i,1,n+1)
	orig+=(l+i-1);

	vii v;
	rep(i,1,n+1)
	{
		ll curr=0;
		rep(j,1,n+1)
		{
			if(i==j)
			continue;
			curr+=(l+j-1);
		}
		v.pb(make_pair(abs(curr-orig),curr));
	}
	sort(all(v));
	cout<<v[0].ss<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	char a;
	cin>>a;
	if(a>='a' && a<='z') cout<<"a";
	else cout<<"A";
	
	return 0;
}

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

int main() {
  string a,b;
  cin>>a>>b;
  a=a+b;
  long double c=stoi(a);
  long int d=pow(c,0.5);
  d*=d;
  if(c==d)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(W: int, a: int, b: int):
    if abs(a-b) <= W:
        return 0
    return abs(a-b) - W

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    W = int(next(tokens))  # type: int
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    print(solve(W, a, b))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
#define B begin()
#define E end()
#define F first
#define S second
#define pub push_back
#define mkp make_pair
#define migmig ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long double ld;
typedef long long ll; 
typedef vector<ll> vll;
typedef map<ll,ll> mll;
const ll N=1e5+5;
ll n, k, sum, l, x, m, i, a[N], ans;
int main(){
	cin>> n;
	for(ll i=0; i<n; i++){
		cin>> a[i];
	}
	x = 2;
	ans = a[0] - 1;
	for(ll i=1; i<n; i++){
		ans += (a[i]) / x;
		if(a[i] % x == 0) ans--;
		if(a[i]==x)x++;
	}
	cout<<ans;
}










Measured memory_bytes: 4288
#include <iostream>
#include <map>
#include <numeric>
#include <vector>

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

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

const int MOD = 1000000007;

ll modpow(ll x, ll n) {
  if (n == 0) return 1;
  if (n % 2 == 0) {
    return modpow((x % MOD) * (x % MOD), n / 2);
  } else {
    return (x % MOD) * (modpow((x % MOD) * (x % MOD), n / 2) % MOD);
  }
}

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

  ll zero = 0;

  map<pair<ll, ll>, P> mp;

  rep(i, n) {
    ll x, y;
    cin >> x >> y;

    if (x == 0 && y == 0) {
      ++zero;
      continue;
    }

    ll g = gcd(x, y);
    x /= g;
    y /= g;

    if (y < 0) { x = -x, y = -y; }
    if (y == 0 && x < 0) x = -x, y = -y;
    bool rot = x <= 0;
    if (rot) {
      ll temp = x;
      x = y;
      y = -temp;
    }

    if (rot)
      ++mp[{x, y}].first;
    else
      ++mp[{x, y}].second;
  }

  ll ans = 1;
  for (auto p : mp) {
    int s = p.second.first;
    int t = p.second.second;

    ll now = 1;
    now += modpow(2, s) - 1;
    now %= MOD;
    now += modpow(2, t) - 1;
    now %= MOD;
    ans *= now;
    ans %= MOD;
  }

  ans -= 1;
  ans = (ans + MOD) % MOD;
  ans += zero;
  ans %= MOD;

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 15924
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
class Main {
	public static void main (String[] args) {
		Scanner input = new Scanner(System.in);
		String s = input.next().toUpperCase();
		HashSet<Character> set = new HashSet<>();
		for(int i=0;i<s.length();i++)
		    set.add(s.charAt(i));
		    
		if(set.size()!=1)
		    System.out.println("Yes");
		else
		    System.out.println("No");
	}
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int a = 0, b = 0, c = 0;
    
    REP(i, n) {
        if(s[i] == 'a') a++;
        else if(s[i] == 'b') b++;
        else c++;
    }

    bool ans;

    if(n == 1) ans = true;
    else if(n == 2 || n == 3) {
        if(a > 1 || b > 1 || c > 1) ans = false;
        else ans = true;
    } else {
        int sa1 = abs(a-b), sa2 = abs(b-c), sa3 = abs(c-a);
        if(sa1 < 2 && sa2 < 2 && sa3 < 2) ans = true;
        else ans = false;
    }

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

    return 0;
}

Measured memory_bytes: 512
n,l=map(int,input().split())

t=[] #各リンゴの味

for i in range(1,n+1):
  a=l+i-1
  t.append(a)

t_total=sum(t) #N個のリンゴの味の総和


t2=[] #全リンゴの味の総和から1個のリンゴを引いたもの味

for j in t:
  b=t_total-j
  t2.append(b)

ans=[]

for k in t2:
  c=t_total-k
  ans.append(abs(c))

ind=ans.index(min(ans))

print(t_total-t[ind])

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int a,b;cin>>a>>b;
  if(a>0 && a<10 && b>0 && b<10){
    cout<<a*b<<endl;
  }else{
    cout<<-1<<endl;
  }
}

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

int main()
{
    cin>>s;
    int len=s.size();
    if((s[0]==s[len-1] && len%2==0) || (s[0]!=s[len-1] && len%2==1))  printf("First\n");
    else  printf("Second\n");
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }

int main(){
    int a,b,c; cin >> a >> b >> c;
    cout << a+b+c+9*max(a,max(b,c)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    char strs[55]={0};
    char strt[55]={0};
    scanf("%s", strs);
    scanf("%s", strt);

    long lens=strlen(strs);
    long lent=strlen(strt);

    set<string> ans;
    if(lens>=lent) {
        long i,j,k;
        for(i=0; i<=lens-lent; i++) {
            char  curr[55]={0};
            strcpy(curr, strs);

            for(j=0; j<lent; j++) {
                if(curr[i+j]=='?') {
                    curr[i+j]=strt[j];
                }
                else if(curr[i+j]!=strt[j]) {
                    break;
                }
            }
            if(j==lent) {
                for(k=0; k<lens; k++) {
                    if(curr[k]=='?') curr[k]='a';
                }
                //printf("%s\n", curr.c_str());
                ans.insert(string(curr));
            }
        }        
    }
    if( !ans.empty() ) {
        auto it = ans.begin();
        printf("%s\n", (*it).c_str());
        return 0;
    }

    printf("UNRESTORABLE\n");

    return 0;
}


Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))
r = 0
#for i in range(N):
#  for j in range(i+1, N):
#    r = (r+(As[i]^As[j]))%1000000007
for i in range(64):
  n = 0
  for A in As:
    if A&(1<<i) != 0:
      n += 1
  #print(i, n)
  d = n*(N-n)%1000000007
  d2 = (d<<i)%1000000007
  r = (r+d2)%1000000007
print(r)


Measured memory_bytes: 122808
import math
a = []
while True:
    ai = int(input())
    if ai == 0:
        break
    a.append(ai)
for i in range(len(a)):
    dp = [0] * (a[i] + 10)
    dp[0] = 1
    dp[1] = 1
    dp[2] = 2
    for j in range(3, a[i] + 1):
        dp[j] = dp[j - 1] + dp[j - 2] + dp[j - 3]
    #print(dp)
    print(math.ceil(dp[a[i]] / 3650))


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    string S;
    cin >> S;
    unordered_set<char> ss;

    for (int i = 0; i < (int)S.size(); i++) {
        ss.insert(S[i]);
    }

    int num = ss.size();

    if (num == 2) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

set<int> s;

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

	for (int i = a; i <= min(a + k - 1, b); i++)
	{
		s.insert(i);
	}
	for (int i = b; i >= max(b - k + 1, a); i--)
	{
		s.insert(i);
	}

	for (int n : s)
	{
		cout << n << endl;
	}
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int x,y;
int main()
{
	scanf("%d%d",&x,&y);
	for (int i=0;i<=x;i++)
	if (i*2+(x-i)*4==y)
	{
		printf("Yes\n");
		return 0;
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 3760
#include<stdio.h>
#define MAX 36
#define True 1
#define False 0
  
typedef struct{
  char c;
  int num;
} card;
  
void cardsort(card []);
void select(card []);
int search(card [],card []); 
  
int number;
  
int main(){
  int i,j;
  card data[MAX];
  card data2[MAX];
    
    
  scanf("%d",&number);
  for(i=0;i<number;i++) {
    scanf(" %c%d",&data[i].c,&data[i].num);
  }
    
  for(i=0;i<number;i++) {
    data2[i] = data[i];
  }
    
  cardsort(data);
  select(data2);
  
    
  for(i=0;i<number-1;i++){
    printf("%c%d ",data[i].c,data[i].num);
  }
  printf("%c%d\n",data[number-1].c,data[number-1].num);
  printf("Stable\n");
  
    
  for(i=0;i<number-1;i++){
    printf("%c%d ",data2[i].c,data2[i].num);
  }
  printf("%c%d\n",data2[number-1].c,data2[number-1].num);
  
  if(search(data,data2)==1) printf("Stable\n");
  else printf("Not stable\n");
  return 0;
}
  
  
void cardsort (card n[]){
  int i,j,tmp;
  char tmpc;
  for(i=0;i<number;i++){
    for(j=number-1;j>i;j--){
      if(n[j].num<n[j-1].num){
    tmp=n[j].num;
    n[j].num=n[j-1].num;
    n[j-1].num=tmp;
  
    tmpc=n[j].c;
    n[j].c=n[j-1].c;
    n[j-1].c=tmpc;
      }
    }
  }
}
  
  
void select(card n[]){
  
  int min,i,j,tmp;
  char tmpc;
  for(i=0;i<number;i++){
    min=i;
    for(j=i;j<number;j++){
      if(n[j].num<n[min].num){
    min=j;
      }
    }
    if(min != i){
      tmp=n[i].num;
      n[i].num=n[min].num;
      n[min].num=tmp;
  
      tmpc=n[i].c;
      n[i].c=n[min].c;
      n[min].c=tmpc;
    }
  }
}
  
int search(card data[],card data2[]){
  int i,count=0;
    for(i=0;i<number;i++){
      if(data[i].c != data2[i].c || data[i].c != data2[i].c){
    return False;
      }
    }
    return True;
}



Measured memory_bytes: 2112
n, k = map(int, input().split())
ans = 0

cnt = dict(zip(range(1,k+1), [0] * k))
for i in range(1, k+1)[::-1]:
    cnt[i] = pow((k // i), n, 10**9+7)

    for j in range(2*i, k+1, i):
        cnt[i] -= cnt[j]
    
    ans += i * cnt[i]

print(ans % (10 ** 9 + 7))

Measured memory_bytes: 20228
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template <class T1, class T2>
ostream &operator<<(ostream &os, pair<T1, T2> &p);
template <class T>
ostream &operator<<(ostream &os, vector<T> &v);
template <class T>
ostream &operator<<(ostream &os, set<T> &v);
template <class T>
ostream &operator<<(ostream &os, multiset<T> &v);
template <class T1, class T2>
ostream &operator<<(ostream &os, map<T1, T2> &v);
#ifdef APURBA
#define debug(a) cout << #a << " --> " << (a) << "\n";
#define debug2(a) cout << #a << " --> " << (a) << " ";
#define HERE cout << "here - " << __LINE__ << "\n";
#else
#define debug(a)
#define debug2(a)
#define HERE
#endif
const ll mod = 1e9 + 7;
const int N = 2e5 + 5;
typedef pair<int, int> pii;

void TEST_CASES(int cas)
{
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    string s;
    cin >> s;
    if (s[n - 1] == '1')
    {
        cout << 1 << "\n";
        return;
    }
    vector<ll> v;
    for (ll i = n - 1; i >= 0; i--)
    {
        ll now = a[i];
        for (auto it : v)
        {
            now = min(now, now ^ it);
        }
        if (s[i] == '0')
        {
            v.push_back(now);
        }
        else if(now)
        {
            cout<<1<<"\n";
            return;
        }
    }
    cout << "0\n";
}

/*

*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t = 1, cas = 0;
    cin >> t;
    while (t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, pair<T1, T2> &p)
{
    os << "{" << p.first << ", " << p.second << "} ";
    return os;
}
template <class T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "[ ";
    for (int i = 0; i < v.size(); i++)
    {
        os << v[i] << " ";
    }
    os << " ]";
    return os;
}

template <class T>
ostream &operator<<(ostream &os, multiset<T> &v)
{
    os << "[ ";
    for (T i : v)
    {
        os << i << " ";
    }
    os << " ]";
    return os;
}

template <class T>
ostream &operator<<(ostream &os, set<T> &v)
{
    os << "[ ";
    for (T i : v)
    {
        os << i << " ";
    }
    os << " ]";
    return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, map<T1, T2> &v)
{
    for (auto i : v)
    {
        os << "Key : " << i.first << " , Value : " << i.second << endl;
    }
    return os;
}


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

using namespace std;
const long long INF = 1LL << 60;

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  vector<long long> dp(N + K, INF);

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

  dp[0] = 0;  //忘れずに
  for (int i = 0; i < N; i++) {
    for (int j = 1; j <= K; j++) {
      chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }

  cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1408