akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N),sum(N+1),B;
    rep(i,N){
        cin >> A[i];
        sum[i+1] = sum[i] + A[i];
    }
    rep(i,N) FOR(j,i+1,N+1){
        B.push_back(sum[j] - sum[i]);
    }
    ll ans = 0;
    rrep(k,45){
        ll cnt = 0;
        ll x = ans + (ll)pow(2,k);
        rep(i,B.size()){
            ll y = x & B[i];
            if(y == x) cnt++;
        }
        if(cnt >= K){
            ans += (ll)pow(2,k);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6260
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

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

    int ans = 0;
    int i = 0;
    while (i < n) {
        if (p[i] == i+1) {
            i++;
            int tmp = 1;
            while (i < n && p[i] == i+1) {
                i++;
                tmp++;
            }
            ans += (tmp+1)/2;
        }
        i++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
  	cin >> n;
  
  	vector<int> a(n);
  	for(int i=0; i<n; i++){
  	cin >> a[i];
  	}
  
  
  	int ok=0;
  
  for(int j=0; j<n; j++){
  if(a[j]%2==0 && a[j]%3 != 0 && a[j]%5 != 0){
    ok++;
    }
  }
  
  if(ok!=0){
    cout << "DENIED" << endl;
  }
  else{
    cout << "APPROVED" << endl;
  }
  
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    vector<string> a(h);
    for (auto &x: a) cin >> x;
    int x = 0, y = 0;
    while (true) {
        a[x][y] = '.';
        if (x == h-1 && y == w-1) break;
        if (x < h-1 && a[x+1][y] == '#') x++;
        else if (y < w-1 && a[x][y+1] == '#') y++;
        else {
            cout << "Impossible\n";
            return 0;
        } 
    }
    for (auto &s: a) {
        for (auto &x: s) {
            if (x == '#') {
                cout << "Impossible\n";
                return 0;
            }
        }
    }
    cout << "Possible\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {//0_index add(i,x) a_i+=x;
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {//0_index sum(i):a_0~a_iの和
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {//0_index sum(l,r):[a_l,a_r)の和
    return sum(r-1) - sum(l-1);
  }
  void print(){
    for(int i=0;i<n;i++){
      cout << sum(i,i+1);
    }
    cout << endl;
  }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cout.tie(nullptr);
  int n,q;
  string s;
  cin >> n >> s >> q;
  vector<BIT<int>> bit(26,BIT<int>(n));
  rep(i,n){
    bit[s[i]-'a'].add(i,1);
  }
  rep(_,q){
    int id;
    cin >> id;
    if(id==1){
      int i;
      char c;
      cin >> i >> c;
      i--;
      bit[s[i]-'a'].add(i,-1);
      bit[c-'a'].add(i,1);
      s[i]=c;
    }else{
      int ans = 0;
      int l,r;
      cin >> l >> r;
      l--,r--;
      rep(j,26){
        if(bit[j].sum(l,r+1))ans++;
      }
      cout << ans << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 53752
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll x;
  cin >> x;
  
  rep2(i, 360) if(x*i%360==0) {cout << i << newl; return 0;}
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace div2019a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);

            Console.WriteLine(N - K +1);

        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include<cassert>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

/////////////////////////////////////

int main() {
	string S;
	cin >> S;
	char c = S[S.size() - 1];
	if (c == 's') { cout << S << "es" << endl; }
	else { cout << S << "s" << endl; }
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  for(int i=0;i<s.size();i++){
  	if( (s.at(i) + n) >90){
    	s.at(i) += n-26;
    }else{
      s.at(i) += n;
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>

using namespace std;

int main()
{
    char ar, br;

    vector<char> aa;
    vector<char> bb;

    char *aaa;
    char *bbb;
    char *ccc;

    while (1) {
        ar = cin.get();

        if (ar == '\n') {
            break;
        }

        aa.push_back(ar);
    }

    int n = aa.size();
    aaa = new char[n];

    for (int i = 0; i < n; i++) {
        aaa[i] = aa[i];
    }
    
    //for (int i = 0; i < n;i++) {
    //    cout << aaa[i] << endl;
    //}

    while (1) {
        br = cin.get();
        
        if (br == '\n') {
            break;
        }
        bb.push_back(br);
        
    }
   
    int m = bb.size();
    bbb = new char[m];

    for (int i = 0; i < m; i++) {
        bbb[i] = bb[i];
    }

    //for (int i = 0; i < m ; i++) {
    //    cout << bbb[i] << endl;
    //}

    ccc = new char[2 * n];

        for (int i = 0; i < n; i++) {
            ccc[i] = aaa[i];
        }

        for (int i = 0; i < n; i++) {
            ccc[i + n] = aaa[i];
        }

       // for (int i = 0; i < 2 * n;i++) {
       // cout << ccc[i] << endl;
       //}

        if (strstr(ccc, bbb) == NULL) {
            cout << "No" << endl;
        }
        else {
            //cout << strstr(aaa, bbb) << endl;
            cout << "Yes" << endl;
        }

        delete[] aaa;
        delete[] bbb;
        delete[] ccc;

    return 0;
}


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

using namespace std;


int main(void){
  
  int A,B,C,D,flag=0;

  
  
  cin >> A >> B >> C >>D; 

  while(1){
    C -= B;
  if(C <=0 ){
    break;
  }
      
    A-=D;
    if(A <=0 ){
      flag=1;
      break;
    }
  }
  
  if(flag==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}




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

int main()
{
    ll n,d,cnt = 0;
    cin>>n>>d;
    for(ll i = 0 ;i < n ; i++)
    {   
        ll x,y;
        cin>>x>>y;
        if(sqrt(x*x + y*y) <= d)
            ++cnt;
    }
    cout<<cnt<<"\n";
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 1; i <= 10000; i++) {
		if (i * 8 / 100 == a && i * 10 / 100 == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int h,w;
  cin>>h>>w;
  string s[h];
  for(int i=0;i<h;i++) cin>>s[i];
  int ans[h][w];
  memset(ans,-1,sizeof(ans));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='c'){
	int tmp=0;
	for(int k=j;k<w;k++)
	  if(ans[i][k]<0||ans[i][k]>tmp)
	    ans[i][k]=tmp++;
      }
    }
  }
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      cout<<ans[i][j]<<" \n"[j==w-1];
  return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
int n, m;
bool ck (int k, vector<vector<int>>& a) {
  set<int> st;
  for (int j = 0; j < m; j++) st.insert(j);
  vector<int> pos(n, 0);
  while (true) {
    multiset<int> mlt;
    int sus = -1;
    for (int i = 0; i < n; i++) {
      int crr = a[i][pos[i]];
      mlt.insert(crr);
      if (mlt.count(crr) > k) {
        sus = crr;
        break;
      }
    }
    if (sus == -1) return true;
    st.erase(sus);
    for (int i = 0; i < n; i++) {
      for (int j = pos[i]; j <= m; j++) {
        if (j == m) return false;
        if (st.find(a[i][j]) != st.end()) {
          pos[i] = j;
          break;
        }
      }
    }
  }
}
int main() {
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  int ng(0), ok(n), md;
  while (ok - ng > 1) {
    md = (ng + ok) >> 1;
    if (ck(md, a)) ok = md;
    else ng = md;
  }
  cout << ok << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int n;
	int ans = 100000;
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++){
		ans += ans * 0.05;
		ans = (ans + 999) / 1000 * 1000;
	}
	
	printf("%d\n", ans);
	
	return (0);
}

Measured memory_bytes: 0
//                          **********  YATIN KWATRA  ********** 

#include <bits/stdc++.h>
#define ll                      long long 
#define ld                      long double
#define ull                     unsigned long long 
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                      unordered_map                
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int> 
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define pi                      3.1415926535897932384626433832795
// #define node                    Node


using namespace std;

void INPUT() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

}


const int MAX = 10000001; 
  
// code reference geeks for geeks
 
ll factor[MAX] = { 0 }; 
  

void generatePrimeFactors() 
{ 
    factor[1] = 1; 
  
   for (int i = 2; i < MAX; i++) 
        factor[i] = i; 
  
    for (int i = 4; i < MAX; i += 2) 
        factor[i] = 2; 
  
    for (int i = 3; i * i < MAX; i++) { 
        if (factor[i] == i) { 
            for (int j = i * i; j < MAX; j += i) { 
                if (factor[j] == j) 
                    factor[j] = i; 
            } 
        } 
    } 
} 
  
ll calculateNoOFactors(int n) 
{ 
    if (n == 1) 
        return 1LL; 
  
    ll ans = 1; 
  
    ll dup = factor[n]; 
  
    ll c = 1; 
  
    ll j = n / factor[n]; 
 
     while (j != 1) { 
  
       if (factor[j] == dup) 
            c += 1; 
  

        else { 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        } 
  
    
        j = j / factor[j]; 
    } 
  

    ans = ans * (c + 1LL); 
  
    return ans; 
} 


void solve()
{ 
        ll n;
        cin >> n;

        generatePrimeFactors();

        ll ans = 0;

        fo(i,1,n)
        {
            ans += i*(calculateNoOFactors(i));
        }

        cout << ans << endl;
        
        

       
}
int main() {
    
    FIO
    INPUT();
    
    int t;
    t = 1;
    //cin >> t;
    
    while(t--)
    {
       solve();
    }
    return 0;
}


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

int main() {


    ll s; cin >> s;
    ll count = 0;
    map<ll, ll> a;

    while(1){
        count++;
        if(a[s]!=0)break;
        a[s]++;
        if(s % 2 == 0){
            s = s/2;
        }else{
            s = 3*s+1;
        }


    }

    cout << count << endl;




}
/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;

const vector<pair<int, int>> MOVELIST = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

int main(){
    int h, w;
    cin >> h >> w;
    vv(char) a(h);
    queue<pair<int, int>> que;
    rep(i, h){
        // vector<char> tp;
        rep(j, w){
            char ta;
            cin >> ta;
            a[i].push_back(ta);
            // if(ta == '#') que.push(make_pair(j, i));
        }
        // a.push_back(tp);
    }

    vvint times(h, vint (w, -1));
    rep(i, h){
        rep(j, w){
            if(a[i][j] == '#'){
                que.push(make_pair(j, i));
                times[i][j] = 0;
            }
        }
    }

    int ans = 0;
    while(!que.empty()){
        auto tmp = que.front();
        que.pop();
        auto px = tmp.first;
        auto py = tmp.second;
        for(auto next : MOVELIST){
            int nx = px + next.first;
            int ny = py + next.second;
            if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
            if(a[ny][nx] == '#') continue;
            if(times[ny][nx] != -1) continue;
            que.push(make_pair(nx, ny));
            a[ny][nx] = '#';
            times[ny][nx] = times[py][px] + 1;
        }
        ans = max(ans, times[py][px]);
    }

    cout << ans << endl;
    return 0;
}


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

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

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

	int ans = 0;
	for (int i = a; i <= t; i += a) {
		ans += b;
	}

	cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll sum[3001][3001];
ll dp[3001][3001];
#define inf (1ll<<60)
void preprocess(vector<ll> &v,ll n){
    for(ll i=1;i<=n;i++){
        for(ll j=i;j<=n;j++){
            sum[i][j]=v[j]+((i==j) ? 0 : sum[i][j-1]);
        }
    }
}
ll solve(vector<ll> v,ll i,ll j)
{
    if(i==j){
        return 0;
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    ll mincost=inf;
    for(ll k=i;k<j;k++){
        mincost=min(mincost,sum[i][j]+solve(v,i,k)+solve(v,k+1,j));
    }
    return dp[i][j]=mincost;
}
int main(){
    ll n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    vector<ll> v(n+1);
    for(ll i=1;i<=n;i++){
        cin>>v[i];
    }
    preprocess(v,n);
    cout<<solve(v,1,n)<<endl;
    return 0;
}

Measured memory_bytes: 78540
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
k=int(input())
count=0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      count+=gcd(gcd(a,b),c)
print(count)


Measured memory_bytes: 76908
#include<iostream>
int main(){
    int a,b,c,x,y,max_i,yasui;
    std::cin>>a>>b>>c>>x>>y;
    max_i=std::max(x,y);
    yasui=std::min(x,y);
    if(a+b<=c)std::cout<<x*a+y*b<<std::endl;
    else if(c*2<=a&&c*2<=b)std::cout<<c*max_i*2<<std::endl;
    else if(c*2<=a&&c*2>=b){
        if(x>y)std::cout<<c*x*2<<std::endl;
        else std::cout<<c*x*2+(y-x)*b<<std::endl;
    }
    else if(c*2>=a&&c*2<=b){
        if(x<y)std::cout<<c*y*2<<std::endl;
        else std::cout<<c*y*2+(x-y)*a<<std::endl;
    }
    else if((a+b)>=c*2&&x>=y)std::cout<<c*yasui*2+(max_i-yasui)*a<<std::endl;
    else if((a+b)>=c*2&&x<=y)std::cout<<c*yasui*2+(max_i-yasui)*b<<std::endl;
    else if(a+b<c*2)std::cout<<a*x+b*y<<std::endl;
    return 0;
}


Measured memory_bytes: 3612
from math import factorial
N, A, B = map(int, input().split())
MOD = 10 ** 9 + 7


def calc(n):
    ret = 1
    for i in range(n):
        ret = ret * (N - i) % MOD
    return ret * pow(factorial(n), MOD - 2, MOD) % MOD


print(max(0, (pow(2, N, MOD) - ((calc(A) + calc(B)) % MOD) - 1) % MOD))


Measured memory_bytes: 5472
import sys
sys.setrecursionlimit(10 ** 7)

def solve(G, p, ans, st, fst, arr, x):
    arr[p] = x
    cnt_1 = 0
    z = -1
    for nxt in G[p]:
        if nxt in st:
            cnt_1 += 1
            z = nxt
    cnt_2 = 0
    for v in st:
        if p in G[v]:
            cnt_2 += 1
    if cnt_1 > 1 or cnt_2 > 1:
        return False
    elif cnt_1 == 1 and cnt_2 == 1:
        if fst in G[p]:
            for v in st:
                ans.append(v)
            return True
        else:
            k = arr[z]
            for v in st:
                if arr[v] >= k:
                    ans.append(v)
            return True
    for nxt in G[p]:
        st.add(nxt)
        if solve(G, nxt, ans, st, fst, arr, x+1):
            return True
        st.remove(nxt)
    arr[p] = 0
    return False

def main():
    n, m = map(int, input().split())
    G = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        G[a].append(b)
    ans = []
    f = False
    st = set()
    arr = [0]*(n+1)
    for i in range(1, n+1):
        st.add(i)
        if solve(G, i, ans, st, i, arr, 1):
            f = True
            break
        st.remove(i)
    if f:
        print(len(ans))
        ans.sort()
        for v in ans:
            print(v)
    else:
        print(-1)

if __name__ == "__main__":
    main()

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

unordered_map<string, string> m;
string s;

int main(){
  cin >> s;
  m["Sunny"] = "Cloudy";
  m["Cloudy"] = "Rainy";
  m["Rainy"] = "Sunny";
  cout << m[s] << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var N int
	fmt.Scanf("%d", &N)

	X := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &X[i])
	}

	var sum int
	var result int = 1000000
	for i := 1; i <= 100; i++ {
		sum = 0
		for k := 0; k < N; k++ {
			sum = sum + (X[k]-i)*(X[k]-i)
		}
		if result > sum {
			result = sum
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 1832
#include <bits/stdc++.h>
typedef long long int lli;
#define mod 1000000007
#define MOD 1003
#define li long int
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int arr[n+1];
    for (int i=0;i<n;i++) cin>>arr[i];
    int dp[n+1];
    for (int i=0;i<n+1;i++) dp[i]=INT_MAX;
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);
    for (int i=2;i<n;i++){
        dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]),dp[i-1]+abs(arr[i-1]-arr[i]));
    }
    cout<<dp[n-1]<<'\n';

}


Measured memory_bytes: 4388
#include<stdio.h>
int main(){
  int n,l[2001],i,j,k,cnt=0,tmp=0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&l[i]);
  }
  for(i=0; i<n-1; i++){
    for(j=i+1; j<n; j++){
      if(l[j]<l[i]){
        tmp=l[i];
        l[i]=l[j];
        l[j]=tmp;
      }
    }
  }
  for(i=0; i<n-2; i++){
    for(j=i+1; j<n-1; j++){
      for(k=j+1; k<n; k++){
        if(l[i]+l[j]>l[k]){
          cnt++;
        }
        else{
          break;
        }
      }
    }
  }
  printf("%d\n",cnt);
  return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;

const ll maxn = 222, MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

ll a[maxn];

int main(){
    int n; cin>>n;
    for (int i = 0; i < n; i++) cin>>a[i];
    sort(a,a+n);
    if (a[n - 1] <= 0) {
        cout<<-(a[0] - a[1])<<endl;
    } else cout<<a[n - 1] - a[0]<<endl;
    return 0;
}



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

#define GYOU_MAX 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define s_pri(str) printf("%s\n",str);
#define PRINT(str) printf(#str "\n")
#define v_pri(val) printf("%d\n",val);
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define pi acos(-1.0)
#define sca(x) scanf("%d",&x);

typedef long long int ll;

int main(void) {
	
	int N;
	sca(N);
	int a[3000];
	rep(i, N) {
		sca(a[i]);
	}

	int sum = 0;
	rep(i, N) {
		sum += a[i] - 1;
	}
	
	v_pri(sum);
	
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX / 2;
constexpr lint LINF = LLONG_MAX / 2;
constexpr double eps = 1e-9;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
lint mypow(lint a, lint b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	lint memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
std::string to_string(std::vector<int>& vec) {
	std::string res = "[";
	rep(i, vec.size() - 1)res += std::to_string(vec[i]) + ", ";
	res += std::to_string(vec.back()) + "]";
	return res;
}
int main() {
	std::string s,t;
	std::cin>>s>>t;
	if(t.substr(0,s.size())==s)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
    int m1, m2, d1, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 + 1 == m2)
        cout << '1' << endl;
    else if(m1 == 12 && m2 == 1)
        cout << '1' << endl;
    else cout << '0' << endl;
    return 0;
}

Measured memory_bytes: 3628
package main 

import (
        "fmt"
        "sort"
)

func main () {
        var a, b, c, x, y int
        var k int
        fmt.Scan(&a,&b,&c)
        fmt.Scan(&k)
        ko := []int{a, b, c}
        sort.Sort(sort.IntSlice(ko))
        x = ko[2]
        y = x 
        for i := 0 ; i < k ; i++ {
                x = x * 2
        }
        if y == a {
                fmt.Println(x + b + c)
        }  else if y == b {
                fmt.Println(a + x + c)
        }  else if y == c {
                fmt.Println(a + b + x)
        }
}


Measured memory_bytes: 512
#include <stdio.h>
int main() {
    short int n, cnt = 0, max = 0;
    scanf("%hi", &n);
    for (short int i = 0; i < n; i++) {
        short int a, b;
        scanf("%hi%hi", &a, &b);
        if (a == b) {
            cnt++;
        }
        if (max < cnt) max = cnt;
        if (a != b) {
            cnt = 0;
        }
    }
    if (max >= 3) {
        printf("Yes");
    }
    else printf("No");
}


Measured memory_bytes: 1728
from collections import deque
n, m = map(int, input().split())
dat = deque([])
dat_finish = [False] * (n + 1)

for i in range(m):
    a, b = map(int, input().split())
    dat.append((a, b))

for i in range(m):
    a, b = dat[i]
    if b == n:
        dat_finish[a] = True

c = False
for i in range(m):
    a, b = dat[i]
    if a == 1:
        if dat_finish[b]:
            c = True

print("POSSIBLE" if c else "IMPOSSIBLE")

Measured memory_bytes: 53592
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar[500009],br[500009];
int main()
{
    ll a,b,c,i,j,k=0;
    string s;
    cin>>a>>s;
    for(i=0;i<a;i++)
    {
        if(s[i]=='A')
        {
            if(i+1<a)
            {
                if(s[i+1]=='B')
                {
                    if(i+2<a)
                    {
                        if(s[i+2]=='C')
                        {
                            k++;
                        }
                    }
                }
            }
        }
    }
    cout<<k<<endl;
}


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

using namespace std;

main(){
	int a,b;
	cin >> a >> b;
	if(a<b){
		printf("a < b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}
	else if(a==b){
		printf("a == b\n");
	}
}


Measured memory_bytes: 3068
from collections import Counter as ct
n, k = map(int, input().split())
td = [list(map(int, input().split())) for i in range(n)]

kind = len(ct(list(map(lambda x: x[0], td))))
std = sorted(td, key=lambda x: x[1], reverse=True)
dup = []
eat_k = set()
ans = 0
for i in range(k):
    ans += std[i][1]
    if std[i][0] in eat_k:
        dup.append(std[i])
    eat_k.add(std[i][0])
ans += len(eat_k)** 2
tmpa = ans
for i in range(k, n):
    if len(dup) == 0:
        break
    if std[i][0] not in eat_k:
        t = dup.pop()
        tmpa -= t[1]
        tmpa += std[i][1]
        tmpa -= len(eat_k)** 2
        eat_k.add(std[i][0])
        tmpa += len(eat_k)** 2
        ans = max(tmpa, ans)
print(ans)


Measured memory_bytes: 37840
#include <bits/stdc++.h>
using namespace std;
#define double long double
typedef complex<double> P;
 
int W,H,N;
P ps[200];
map<double,double> memo;
double EPS = 1e-12;
double f(double y_off){
    if( memo.count(y_off) ) return memo[y_off];
    vector<double> s;
    for(int i = 0 ; i < 2 * N ; i++){
        double x = ps[i].real();
        double y = ps[i].imag() - y_off;
        double t = atan2(y,x);
        // cout << "(" << x << "," << " " << y << " " << t << ")" << endl;
        s.push_back(t);
    }
    sort(s.begin(),s.end());
    // cout << 
    // cout << s[N-1] << "|" << s[N] << endl;
    double Y_L = max<double>(0.0  , y_off + tan(s[N-1]) );
    double Y_H = min<double>(1.0, y_off + tan(s[N]) );
    // cout << Y_L << " " << Y_H << endl;
    return memo[y_off] = max<double>(Y_H - Y_L, 0.0);
}
double g(double l,double r){
    return (f(l) + 4 * f((l+r)/2) + f(r)) * (r-l) / 6;
}
double G(double l,double r,int k=4){
    double m = (l+r) / 2;
    double S1 = g(l,r);
    double S2 = g(l,m) + g(m,r);
    if( fabs(S1-S2) < EPS and k <= 0){
        return S1;
    }else{
        return G(l,m,k-1) + G(m,r,k-1);
    }
}
int main(){
    while( cin >> W >> H >> N && N){  
		vector<double> tp;
		tp.push_back(0);
		tp.push_back(1);
        for(int i = 0 ; i < 2 * N ; i++){
            double x,y;
            cin >> x >> y;
			x /= W;
			y /= H;
            ps[i] = P(x,y);
			if( x < EPS ) tp.push_back(y);
        }
		sort(tp.begin(),tp.end());
		tp.erase(unique(tp.begin(),tp.end()),tp.end());
        memo.clear();
		double ans = 0;
		for(int i = 0 ; i+1 < tp.size() ; i++){
			ans += G(tp[i],tp[i+1]);
		}
        printf("%.15Lf\n",ans);
    }
}

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

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int ans=0;
  if((k-a)<=0) {
    ans+=k;
    goto END;
  }
  else {
    ans+=a;
    k-=a;
  }
  if((k-b)<=0) {
    goto END;
  }
  else {
    k-=b;
  }
  if((k-c)<=0) {
    ans-=k;
    goto END;
  }
  else {
    ans-=k;
  }
END:
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 1;
  ll n, p;
  cin >> n >> p;
  mllll m;
  while(p % 2 == 0) {
    m[2]++;
    p /= 2;
  }
  for(int i = 3; i <= sqrt(p); i += 2) {
    while(p % i == 0) {
      m[i]++;
      p /= i;
    }
  }
  if(p > 2)
    m[p]++;

  for(auto x: m) {
    ans *= pow(x.first, x.second / n);
  }

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;


int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    ll m=max(k,1LL);
    for(ll b=k+1;b<=n;b++){
        for(ll j=0;;j+=b){
            if(j){
                if(j+k>n){
                    break;
                }else if(j+b-1>n){
                    ans+=(n-j-k+1);
                    break;
                }else{
                    ans+=b-k;
                }
            }else{
                if(j+m>n){
                    break;
                }else if(j+b-1>n){
                    ans+=(n-j-m+1);
                    break;
                }else{
                    ans+=b-m;
                }
            }
        }

    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long x = in.nextLong();
        long d = 100;
        int count = 0;
        while(d<x) {
            d = (long)Math.floor(d * 1.01);
            count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 35832
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s;
    cin >> s;
    ll n = s.size();

    ll cntN = 0, cntW = 0, cntS = 0, cntE = 0;
    rep(i, n) {
        if(s[i] == 'N') {
            cntN = 1;
        }
        if(s[i] == 'W') {
            cntW = 1;
        }
        if(s[i] == 'S') {
            cntS = 1;
        }
        if(s[i] == 'E') {
            cntE = 1;
        }
    }

    if(cntN + cntS == 1) {
        out("No");
    }
    else if(cntW + cntE == 1) {
        out("No");
    }
    else {
        out("Yes");
    }
    
    re0;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func solve(n, x, m, k int, d []int) int {
	a := []int{x, 0}
	ret := 0
	for j := 1; j < n; j++ {
		idx := (j - 1) % k
		a[1] = a[0] + d[idx]
		if a[0]%m < a[1]%m {
			ret++
		}
		a[0] = a[1]
	}
	return ret
}

func solve2(n, x, m, k int, d []int) int {
	x0 := x
	xn1 := x
	eqn := 0
	for i := 0; i < k; i++ {
		num := (n - 1) / k
		if (n-1)%k > i {
			num++
		}
		xn1 += (d[i] % m) * num
		if d[i]%m == 0 {
			eqn += num
		}
	}
	ans := (n - 1) - (xn1/m - x0/m) - eqn

	return (ans)
}

func main() {
	sc.Split(bufio.ScanWords)

	k, q := getInt(), getInt()
	d := make([]int, k)
	for i := 0; i < k; i++ {
		d[i] = getInt()
	}
	n := make([]int, q)
	x := make([]int, q)
	m := make([]int, q)
	for i := 0; i < q; i++ {
		n[i], x[i], m[i] = getInt(), getInt(), getInt()
		out(solve2(n[i], x[i], m[i], k, d))
	}
}


Measured memory_bytes: 1152
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
    if(ch =='A') return 1;
    else if(ch == 'C') return 2;
    else if(ch == 'G') return 3;
    else if(ch == 'T') return 4;
    else return 0;
}

long long getKey(char str[]){
    long long sum = 0, p = 1, i;
    for(i = 0; i < strlen(str); i++){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    
    return sum;
}

int h1(int key){return key % M;}
int h2(int key){return 1 + (key % (M - 1));}

int find(char str[]){
    long long key, i, h;
    key = getKey(str);
    for(i = 0;; i++){
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0) return 1;
        else if(strlen(H[h]) == 0) return 0;
    }
    
    return 0;
}

int insert(char str[]){
    long long key, i, h;
    key = getKey(str);
    for(i = 0;  ; i++){
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0) return 1;
        else if(strlen(H[h]) == 0){
            strcpy(H[h], str);
            return 0;
        }
    }
    
    return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for(i = 0; i < M; i++) H[i][0] = '\0';
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%s %s", com, str);
        
        if(com[0] == 'i'){
            insert(str);
        }else{
            if(find(str)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 16976
#include<stdio.h>
#define NUM 250

int main(){
  int h,i,a[NUM];
  scanf("%d",&h);
  for(i=1;i<=h;i++){
    scanf("%d",&a[i]);
  }

  for(i=1;i<=h;i++){
    printf("node %d: ",i);
    printf("key = %d, ",a[i]);
    if(i/2>=1&&i/2<=h){
      printf("parent key = %d, ",a[i/2]);
    }
    if(2*i<=h){
      printf("left key = %d, ",a[2*i]);
    }
    if(2*i+1<=h){
      printf("right key = %d, ",a[2*i+1]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2104
while input = gets.chomp

	input_sep = input.split()

	if input_sep[1] == "?" then
		exit(0);
	else

		if input_sep[1] == "+" then
			puts input_sep[0].to_i + input_sep[2].to_i
		elsif input_sep[1] == "-" then
			puts input_sep[0].to_i - input_sep[2].to_i
		elsif input_sep[1] == "*" then
			puts input_sep[0].to_i * input_sep[2].to_i
		elsif input_sep[1] == "/" then
			puts input_sep[0].to_i / input_sep[2].to_i
		end

	end

end

Measured memory_bytes: 8644
#include <array>
#include <cstddef>
#include <functional>
#include <type_traits>
#include <utility>

template <class Key, class T, Key Empty, std::size_t N,
	class Hash = std::hash<Key>>
	struct mu_hashmap {

	std::array<std::pair<Key, T>, N> table;
	Hash hash;

	explicit mu_hashmap(Hash hash = Hash()) : table(), hash(hash) {
		for (auto itr = table.begin(), end = table.end(); itr != end; ++itr) {
			itr->first = Empty;
		}
	}

	T& operator[](const Key key) {
		typename std::array<std::pair<Key, T>, N>::iterator itr =
			table.begin() + hash(key) % N;
		while (itr->first != key) {
			if (itr->first == Empty) {
				itr->first = key;
				break;
			}
			++itr;
			if (itr == table.end()) {
				itr = table.begin();
			}
		}
		return itr->second;
	}
};

#include<cstddef>
#include<cstdint>
#include<iostream>

int main() {
	using usize = std::size_t;
	using u32 = std::uint_fast32_t;
	using i64 = std::int_fast64_t;

	usize n;
	std::cin >> n;

	u32 ans = 0;
	i64 acc = 0;
	mu_hashmap<i64, u32, 200000ULL * 1000000000 + 1, (1ULL<<20)+1> count;
	++count[acc];

	for (usize i = 0; i != n; ++i) {
		i64 a;
		std::cin >> a;

		acc += a;
		ans += count[acc];
		++count[acc];
	}

	std::cout << ans << std::endl;

	return 0;
}



Measured memory_bytes: 16640
n = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

bit_count = [0] * 60
ans = 0
for a in A:
    for bit in range(60):
        if (a >> bit) & 1:
            count = bit_count[bit]
            ans += (2 ** bit) * (n-1-count*2)
            bit_count[bit] += 1
            ans %= mod
        else:
            continue

print(ans)

Measured memory_bytes: 122808
import sys
input = sys.stdin.readline

N, M, Q = map(int, input().split())
cum = [[0]*(N+1) for _ in range(N+1)]
for _ in range(M):
    l, r = map(int, input().split())
    cum[l][r] += 1
for i in range(1, N+1):
    for j in range(i+1, N+1):
        cum[i][j] += cum[i][j-1]
for _ in range(Q):
    p, q = map(int, input().split())
    tot = 0
    for i in range(p, q+1):
        tot += cum[i][q]
    print(tot)


Measured memory_bytes: 72580
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;
struct node
{
    int x,y;
    int bu;
};
int n,m;
char mp[55][55];
int vis[55][55];
int fx[4][2] = {1,0,0,1,-1,0,0,-1};
int bfs(int qx,int qy)
{
    memset(vis,0,sizeof(vis));
    vis[qx][qy] = 1;
    node kai,xia,xian;
    kai.x = qx;
    kai.y = qy;
    kai.bu = 1;
    queue<node>q;
    q.push(kai);
    while(!q.empty())
    {
        xian = q.front();
        q.pop();
        if(xian.x == (n-1)&&xian.y == (m-1))
            return xian.bu;
        for(int i=0; i<4; i++)
        {
            xia.x = xian.x + fx[i][0];
            xia.y = xian.y + fx[i][1];
            if(xia.x<0||xia.y<0||xia.x>=n||xia.y>=m||vis[xia.x][xia.y]||mp[xia.x][xia.y]=='#')
                continue;
            vis[xia.x][xia.y] = 1;
            xia.bu = xian.bu +1;
            q.push(xia);
        }
    }
    return -1;
}
int main()
{
    scanf("%d %d",&n,&m);
    int lz=0;
    for(int i=0; i<n; i++)
    {
        scanf("%s",mp[i]);
        for(int j=0; j<m; j++)
        {
            if(mp[i][j]=='.')
                lz++;
        }
    }
    int x = bfs(0,0);
    if(x==-1)
        puts("-1");
    else
    {
        printf("%d\n",lz-x);
    }

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	int N;
	cin >> N;
	vi A(N);
	REP(i, N) {
		cin >> A[i];
	}
	
	int ans = 1, inc = 0;
	REP(i, N - 1) {
		if (A[i] < A[i+1]) {
			if (inc == -1) {
				ans++;
				inc = 0;
			}
			else {
				inc = 1;
			}
		}
		else if (A[i] > A[i+1]) {
			if (inc == 1) {
				ans++;
				inc = 0;
			}
			else {
				inc = -1;
			}
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640