akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> c(h);
    for(int i = 0; i < h; i++) {
        cin >> c[i];
    }
    for(int i = 1; i <= 2 * h; i++) {
        for(int j = 1; j <= w; j++) {
            cout << c[(i + 1) / 2 - 1][j - 1];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3664
def main():
    N, L = (int(x) for x in input().split())
    azi = [L + i for i in range(N)]
    ans = sum(azi)
    if 0 not in azi:
        if azi[0] > 0:
            ans -= azi[0]
        else:
            ans -= azi[N-1]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
<?php
    function delr($s) {
        $len = strlen($s);
        return substr($s, 0, $len-1);
    }
    
    function dell($s) {
        
        return substr($s, 1, 9);
    }

    fscanf(STDIN, "%s", $s);
    
    $len = strlen($s);
    $result = "";
    
    for ($i = 0; $i < $len; $i++) {
        $input = substr($s, 0, 1);
        $s = dell($s);
        if ($input != "B") {
            $result .= $input;
        } else {
            $result = delr($result);
        }
    }
    
    echo $result;
    
?>


Measured memory_bytes: 4604
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
const int N=3005;

string s,t,ans;
int dp[N][N];

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>s>>t;
    s=' '+s;
    t=' '+t;
    for (int i=1;i<s.size();++i)
    for (int j=1;j<t.size();++j)
        dp[i][j]=s[i]==t[j]?dp[i-1][j-1]+1:max(dp[i-1][j],dp[i][j-1]);
    int i=s.size()-1, j=t.size()-1;
    while (i && j) {
        if (dp[i-1][j]==dp[i][j]) --i;
        else if (dp[i][j-1]==dp[i][j]) --j;
        else ans+=s[i], --i, --j;
    }
    for (int i=ans.size()-1;i>=0;--i)
        cout<<ans[i];
    cout<<'\n';
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
char dat[100005];
bool zz[100005];
int n;
int main()
{
	scanf("%d%s",&n,&dat);
	for(int i=0;i<2;i++)
		for(int j=0;j<2;j++)
		{
			zz[0]=i,zz[1]=j;
			for(int k=1;k<n-1;k++)
				zz[k+1]=zz[k-1]^zz[k]^(dat[k]=='x');
			if((dat[n-1]=='x')==(zz[n-2]^zz[n-1]^zz[0])&&(dat[0]=='x')==(zz[n-1]^zz[0]^zz[1]))
			{
				for(int k=0;k<n;k++)
					cout<<(zz[k]?'W':'S');
				return 0;
			}
		}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll dp[10005][105][2];
int main(){
  string s;
  ll d;
  cin>>s>>d;
  memset(dp,0,sizeof(dp));
  dp[0][0][0]=1;
  ll n=sz(s);
  rep(i,n)rep(j,d)rep(z,2){
    rep(u,10){
      ll nd=s[i]-'0';
      ll ni=i+1,nj=(j+u)%d,nz=z;
      if(nz==0&&u<nd)nz=1;
      if(nz==0&&u>nd) continue;
      dp[ni][nj][nz]+=dp[i][j][z];
      dp[ni][nj][nz]%=MOD;
    }
  }
  ll ans=(dp[n][0][1]+dp[n][0][0]-1)%MOD;
  if(ans<0) ans+=MOD;
  COUT(ans);
  
}


Measured memory_bytes: 16640
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F0(i,n) for (int i = 0; i < n; i++)
#define F1(i,n) for (int i = 1; i <= n; i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
const int inf = 1000000009;
int i, j, k, m, n, l;
int ans;

int a[100];

int med(int a, int b, int c) {
	int d[3] = { a, b, c };
	sort(d, d + 3);
	return d[1];
}

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

	if (m >= 2 && m <= 2 * n - 2) {
		puts("Yes");
		vector<int> v;
		F1(i, 2 * n - 1) v.push_back(i);
		if (m < n) {
			rotate(v.begin(), v.begin() + m + n - 1, v.end());
		}
		else {
			rotate(v.begin(), v.begin() + m - n, v.end());
		}
		F0(i, SZ(v)) printf("%d\n", v[i]);
	}
	else {
		puts("No");
	}

	return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll H, A;
  cin >> H >> A;

  cout << divceil(H, A) << endl;
}

Measured memory_bytes: 768
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

class Info:
    def __init__(self,arg_start,arg_end,arg_S):
        self.start = arg_start
        self.end = arg_end
        self.S = arg_S


LOC = []
POOL = []

line = input()
loc = 0
sum_S = 0

for ch in line:

    if ch == '\\':

        LOC.append(loc)

    elif ch == '/':

        if len(LOC) == 0:
            continue

        tmp_start = int(LOC.pop())
        tmp_end = loc
        tmp_S = tmp_end-tmp_start;
        sum_S += tmp_S;

        #既に突っ込まれている池の断片が、今回の断片の部分区間になるなら統合する
        while len(POOL) > 0:
            if POOL[-1].start > tmp_start and POOL[-1].end < tmp_end:
                tmp_S += POOL[-1].S
                POOL.pop()
            else:
                break

        POOL.append(Info(tmp_start,tmp_end,tmp_S))

    else:
        pass

    loc += 1

print("%d"%(sum_S))
print("%d"%(len(POOL)),end = "")

while len(POOL) > 0:
    print(" %d"%(POOL[0].S),end = "") #先頭から
    POOL.pop(0)

print()



Measured memory_bytes: 7524
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

vector<int> g;
bool seen[200001];
vector<int> go;

int dfs(int s){
  if (seen[s]) return s;
  seen[s] = true;
  go.push_back(s);
  return dfs(g[s]);
}

int main(){
  int n;
  ll k;
  cin >> n >> k;
  g.resize(n);

  rep(i,n){
    int tmp;
    cin >> tmp;
    g[i]=(tmp-1);
  }

  int loop;
  loop = dfs(0);
  int start;
  int mod;
  int len;
  len = go.size();

  for (int i =0;i < len;i++){
    if (go[i] == loop) start = i;
    mod = len-start;
  }

  vector<int> to(mod);
  for (int j = start;j < len;j++){
     to[j%mod] = go[j];
  }
 
  if (k < len) cout << go[int(k)]+1 << endl;
  else {
    k%=(ll)mod;
    cout << to[int(k)]+1 << endl;
  }

  
  return 0;
}

Measured memory_bytes: 11348
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<complex>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;
const double EPS=1e-9;
typedef complex<double> C;
#define cx real()
#define cy imag()

ll N;
C point[51];
double PI=3.14159265358979;
C MidPoint(C a,C b){return C( (a.cx+b.cx)/2,(a.cy+b.cy)/2 ); }
double Dist(C a,C b){ return hypot(a.cx-b.cx,a.cy-b.cy); }
C Pivot(C a,C b,C c){
    C e=MidPoint(a,b);
    C f=MidPoint(b,c);
    double tanA=tan(atan((b.cy-a.cy)/(b.cx-a.cx))+PI/2);
    double tanB=tan(atan((c.cy-b.cy)/(c.cx-b.cx))+PI/2);
    double x=(e.cy-f.cy-e.cx*tanA+f.cx*tanB)/(tanB-tanA);
    double y=e.cy-(e.cx-x)*tanA;
    return C(x,y);
}
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        ll x,y;
        cin>>x>>y;
        point[i]=C(x,y);
    }
    if(N==2){
        cout<<Dist(point[0],point[1])/2<<endl;
        return 0;
    }
    double ans=INF;
    for(ll i=0;i<N;i++){
        for(ll j=i+1;j<N;j++){
            C p=MidPoint(point[i],point[j]);
            double r=Dist(p,point[i]);
            bool f=true;
            for(ll k=0;k<N;k++){
                if(Dist(p,point[k])>r+EPS){
                    f=false;
                    break;
                }
            }
            if(f){
                ans=min(ans,r);
            }            
        }
    }
    for(ll i=0;i<N;i++){
        for(ll j=i+1;j<N;j++){
            for(ll k=j+1;k<N;k++){
                C p=Pivot(point[i],point[j],point[k]);
                double r=Dist(p,point[i]);
                bool f=true;
                for(ll l=0;l<N;l++){
                    if(Dist(p,point[l])>r+EPS){
                        f=false;
                        break;
                    }
                }
                if(f){
                    ans=min(ans,r);
                }
            }
        }
    }
    cout<<setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N;
	cin >> N;
	vector<vector<int>> edge(N + 1);
	vector<int> A(N - 1), B(N - 1);
	map<P, int> mp;
	REP(i, N - 1) {
		int a, b;
		cin >> a >> b;
		A[i] = a;
		B[i] = b;
		edge[a].emplace_back(b);
		edge[b].emplace_back(a);
		mp.emplace(P(a, b), i);
		mp.emplace(P(b, a), i);
	}
	queue<P> qu;
	qu.emplace(A[0], 0);
	vector<int> c(N - 1), par(N + 1);
	par[A[0]] = A[0];
	int K = 0;
	while (!qu.empty()) {
		int i, color;
		tie(i, color) = qu.front();
		qu.pop();
		int new_color = 1;
		for (auto j : edge[i]) {
			if (par[i] == j) continue;
			par[j] = i;
			if (new_color == color) ++new_color;
			c[mp[P(i,j)]] = new_color;
			qu.emplace(j, new_color);
			K = max(K, new_color);
			++new_color;
		}
	}
	cout << K << "\n";
	REP(i, N - 1) {
		cout << c[i] << "\n";
	}

	return 0;
}

Measured memory_bytes: 20224
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s_1,s_2,s_3;
    cin >> s_1 >> s_2 >> s_3;
    s_1.at(0) -= 32;
    s_2.at(0) -= 32;
    s_3.at(0) -= 32;
    cout << s_1.at(0) << s_2.at(0) << s_3.at(0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,l; cin >> n >> l;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    sort(s.begin(),s.end());
    rep(i,n) cout << s[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
//   //  /////       ///      
//  //   //  //     // //     
// //    //   //   //   //    
////     //   //  //     //   
// //    //   //  /////////    
//  //   //  //   //     //    
//   //  /////    //     //    

#include <bits/stdc++.h>
using namespace std;
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define iter(it,a,b) for(a::iterator it=b.begin(); it!=b.end();++it)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (binary me 1 kitne hai) (if longlong popcount ll)
#define ln "\n"
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it<<ln;} cerr<<endl
#define dbgstlp32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cerr<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(n) n.begin() , n.end() 
#define tfi first.first
#define tse first.second
#define tth second
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
typedef pair< pair<int,int> , int> tri;
typedef vector<bool> vbool;
typedef priority_queue<p32> pq32;
typedef priority_queue<p32, vector<p32>, greater<p32> > pq32l;

#pragma GCC optimize ("-O2")
const ll LIM = 2e5+5;
const ll MOD = 1e9+7;
const ll inf = 1e10;



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

	int N, W;
	cin >> N >> W;

	ll w[N], v[N];

	forn(i,N) cin >> w[i] >> v[i];

	ll dp[N+1][W+1];

	forn(i,N+1) forn(j,W+1) dp[i][j] = 0;

	forn(i,N){
		forn(j,W){
			if(j+1 >= w[i]){
				dp[i+1][j+1] = max(dp[i][j+1], dp[i][j+1-w[i]] + v[i]);
			}
			else{
				dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
			}
		}
	}

	cout << dp[N][W];


}


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


int main(void)
{
	//変数の宣言
	int a,b;
	int ans;
	
	//データの読み込み
	scanf("%d",&a);
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	
	
//	printf("計算部分終了\n");
	
	//出力
	
	if(a<1000){
		printf("ABC");
	}else{
		printf("ABD");
	}
	
//	printf("結果の出力終了\n");
	
	return 0;
}



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

int64_t f(int64_t n, int64_t x) {
  if (n >= 0) return n/x + 1;
  else return 0;
}

int main() {
  int64_t a, b, x;
  cin >> a >> b >> x;
  int64_t n = f(b, x) - f(a-1, x);
  cout << n << endl;
}


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


int32_t main() {
    ios_base::sync_with_stdio(0);

    string s;
    cin >> s;
    const int MOD = 1000*1000*1000 + 7;

    int a_cnt = 0;
    int c_cnt = 0;

    int l = 0;
    int r = 0;

    vector<int> pows(s.length() + 1);

    pows[0] = 1;
    for (int i = 1; i <= (int)s.length(); ++i) {
      pows[i] = pows[i - 1] * 3 % MOD;
    }

    for (auto x: s) {
      if (x == 'C') c_cnt++;
      if (x == '?') r++;
    }

    int res = 0;
    for (int i = 0; i < (int)s.length(); ++i) {
      if (s[i] == '?') r--;
      if (s[i] == 'C') c_cnt--;

      if (s[i] == '?' || s[i] == 'B') {
        int z = a_cnt * pows[l] + l * pows[max(l-1, 0LL)];
        z %= MOD;
        int y = c_cnt * pows[r] + r * pows[max(r-1, 0LL)];
        y %= MOD;
        res = (res + z * y) % MOD;
      }

      if (s[i] == 'A') a_cnt++;
      if (s[i] == '?') l++;
    }

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 1232
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
int main() {
	ll n;
	cin >> n;
	ll a[5];
	rep(i, 5) cin >> a[i];
	sort(a, a + 5);
	cout << 4 + (n + a[0]-1) / a[0] << endl;
	return 0;
}


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

const int64_t mod = 1000000007;

int64_t power(int64_t n, int64_t k) {
  if (k == 0) return 1;
  int64_t ans = power(n * n % mod, k / 2);
  if (k % 2) ans = ans * n % mod;
  return ans;
}

int64_t comb(int64_t n, int64_t r) {
  int64_t ans = 1;
  for (int64_t i = 0; i < r; i++) {
    ans *= n - i;
    ans %= mod;
    ans *= power(i + 1, mod - 2);
    ans %= mod;
  }
  return ans;
}

int main() {
  int64_t n, a, b;
  cin >> n >> a >> b;
  int64_t ans = power(2, n);
  ans += mod - comb(n, a) + mod - comb(n, b) + mod - 1;
  ans %= mod;
  cout << ans << endl;
}


Measured memory_bytes: 256
#https://atcoder.jp/contests/abc158/tasks/abc158_b B - Count Balls

N,A,B = map(int,input().split())
sumab = A + B
quot,mod = divmod(N, sumab)
if A > mod:
    ans = (A * quot) + mod
else:
    ans = (A * quot) + A
    
print(ans)



Measured memory_bytes: 9188
import java.util.*;
import java.io.*;

public class Main {	
	private static void solve(){
		//Implement solution here.
		String S = next();
		String T = next();
		int A = ni();
		int B = ni();
		String U = next();
		if(U.equals(S)) {
			System.out.println((A - 1) + " " + B);
		} else {
			System.out.println(A + " " + (B - 1));
		}
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 22612
def ascan; gets.split.map(&:to_f);end

n = gets.to_i

tt = ascan
vv = ascan

tt.unshift(0.0)
vv.unshift(0.0)
tt.push(0.0)
vv.push(0.0)
n+=2

(1..(n-2)).each do |i|
    t = tt[i]
    v = [vv[i], vv[i-1]+t].min
    v = [v, vv[i+1]+t].min
    
    vv[i] = v
end

(1..(n-2)).to_a.reverse.each do |i|
    t = tt[i]
    v = [vv[i], vv[i-1]+t].min
    v = [v, vv[i+1]+t].min
    
    vv[i] = v
end

#p vv

#simulate_vel = 0.0

area = 0.0
(1..(n-2)).each do |i|
    uptime = [vv[i]-vv[i-1], 0.0].max
    downtime = [vv[i]-vv[i+1], 0.0].max
    
    if uptime + downtime > tt[i]
        v = (tt[i]+vv[i-1]+vv[i+1])/2.0
        uptime = (vv[i-1]-v).abs
        downtime = (vv[i+1]-v).abs
    end
    midtime = tt[i]-uptime-downtime
    
    area += (vv[i-1])*uptime+uptime*uptime/2.0
    area += midtime*vv[i]
    area += (vv[i+1])*downtime+downtime*downtime/2.0
    
    
    #p [uptime,midtime,downtime, vv[i]]
    #p area
    
    #simulate_vel += uptime
    #abort "up" unless
end
p area

Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!

int main(void){
    ll N, canPA=0, ans=0;
    char s[100100];
    scanf("%s", s);
    for(ll i=0; s[i]!='\0'; i++) {
        if(s[i]=='g') {
            if(canPA) {
                ans++;
                canPA--;
            }
            else canPA++;
        }
        else {//s[i]==p
            if(canPA) canPA--;
            else {
                ans--;
                canPA++;
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <bits/stdc++.h>
using namespace std;
static const unsigned long MOD = 1000000007LL;
static const unsigned long INF = 1000000007LL;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

int N, M;
int a[1050], c[1050];

void input() {
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        int b;
        cin >> a[i] >> b;
        for(int j = 1; j <= b; j++) {
            int t;
            cin >> t;
            c[i] |= (1 << (t - 1));
        }
    }
}

void solve() {
    input();
    const int INF = 1e9;
    vector<int> dp(5000, INF);
    dp[0] = 0;
    for(int item = 1; item <= M; item++) {
        int now = c[item];
        for(int bits = 0; bits < (1 << N); bits++) {
            chmin(dp[bits | now], dp[bits] + a[item]);
        }
    }
    if(dp[(1 << N) - 1] == INF) dp[(1 << N) - 1] = -1;
    cout << dp[(1 << N) - 1] << endl;
    return;
}

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

Measured memory_bytes: 256
N = int(input())
mod = 10 ** 9 + 7

memo = [{} for _ in range(N + 1)]

def valid(S):
    for i in range(4):
        t = list(S)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]
        if "AGC" in "".join(t):
            return False
    return True

def dfs(cur, S):
    if S in memo[cur]:
        return memo[cur][S]
    if cur == N:
        return 1

    count = 0
    for c in "ACGT":
        if valid(S + c):
            count = (count + dfs(cur + 1, S[1:] + c)) % mod
    memo[cur][S] = count
    return count

print(dfs(0, "TTT"))


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

void cookie(int &a,int &b,int &c,bool &same,bool &check){
  int S=a+b+c;
  if(a!=b || b!=c || c!=a){
  a= (S-a)/2;
  b= (S-b)/2;
  c= (S-c)/2;
    if(a+b+c!=S){
      check=false;
    }
  }else if(a%2==1){
    check = false;
  }else{
    same = true;
  }
}
    
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int sum = A+B+C;
  int count = -1;
  bool check=true;
  bool same = false;
  while(check==true && same == false){
    count++;
    cookie(A,B,C,same,check);
  }
  if(!(same)){
  cout << count << endl;
  }else{
    cout << -1 << endl;
  }
}


Measured memory_bytes: 256
// C++ implementation of the approach 
#include <bits/stdc++.h> 
using namespace std; 
#define int long long
// Function to return the XOR of elements 
// from the range [1, n] 
int findXOR(int n) 
{ 
	int mod = n % 4; 

	// If n is a multiple of 4 
	if (mod == 0) 
		return n; 

	// If n % 4 gives remainder 1 
	else if (mod == 1) 
		return 1; 

	// If n % 4 gives remainder 2 
	else if (mod == 2) 
		return n + 1; 

	// If n % 4 gives remainder 3 
	else if (mod == 3) 
		return 0; 
} 

// Function to return the XOR of elements 
// from the range [l, r] 
int findXOR(int l, int r) 
{ 
	return (findXOR(l - 1) ^ findXOR(r)); 
} 

// Driver code 
signed main() 
{ 
	int l,r;
	cin>>l>>r;
	if(l==r){
		cout<<l;
		return 0;
	}
	else if(l==0){
		l=1;
	}
	cout << findXOR(l, r); 

	return 0; 
} 


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;
struct sch{
    int from;
    int to;
    void in(){
        scanf("%d%d",&from,&to);
        return ;
    }
};
struct cmp{
    bool operator ()(sch a,sch b){
        return a.from<b.from;
    }
};
bool cmp1(pair<sch,int> a,pair<sch,int> b){
    return a.first.from>b.first.from;
}
const int N=1e5+10;
int val[N];
void add(int n){
    while(n<N){
        val[n]++;
        n+=n&-n;
    }
    return ;
}
int ask(int n){
    int ans=0;
    while(n){
        ans+=val[n];
        n^=n&-n;
    }
    return ans;
}
int main(){
    int n,m,q,ans[N];
    sch temp;
    pair<sch,int> a[N];
    priority_queue<sch,vector<sch>,cmp> pq;
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=n;i++)val[i]=0;
    for(int i=0;i<m;i++){
        temp.in();
        pq.push(temp);
    }
    for(int i=0;i<q;i++){
        a[i].first.in();
        a[i].second=i;
    }
    sort(a,a+q,cmp1);
    for(int i=0;i<q;i++){
        while(!pq.empty()){
            if(a[i].first.from<=pq.top().from){
                add(pq.top().to);
                pq.pop();
            }
            else break;
        }
        ans[a[i].second]=ask(a[i].first.to);
    }
    for(int i=0;i<q;i++)printf("%d\n",ans[i]);
}

Measured memory_bytes: 4208
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0}; 
using P = pair<int, int>;
const double pi = acos(-1.0);

using Graph = vector<vector<ll>>;

int main(){
  bool x;
  cin>>x;
  if(x)cout<<0<<endl;
  else cout<<1<<endl;
    
    
  return 0;
}


Measured memory_bytes: 3588
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [N, K]= nextIntArray()
    const a = nextIntArray()
    if(K >= N){
        console.log(1)
        return
    }
    N = N - K
    let cnt = Math.ceil(N/(K-1))
    console.log(cnt+1)
}
Main()



Measured memory_bytes: 37812
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n; ll k; cin >> n >> k;
    vector<ll> A(n); rep(i, n) cin >> A[i], A[i]--;

    //ダブリング
    vector<vector<ll>> D(60, vector<ll>(n));
    rep(i, n)D[0][i] = A[i];
    rept(i, 1, 60){
        rep(j, n){
            D[i][j] = D[i-1][D[i-1][j]];
        }
    }

    int v = 0;
    rep(i, 60){
        if(k&1){
            v = D[i][v];
        }
        k /= 2;
    }
    cout << v + 1 << ln;
}
    


Measured memory_bytes: 100136
#![allow(unused_imports)]
    #![allow(dead_code)]
    use std::io::prelude::*;
    use std::cmp::{max, min};
    use std::collections::BinaryHeap;

    const MOD: i64 = 1e9 as i64 + 7; 

    fn main(){
        let a: isize = read();
        let b: isize = read();
        let c: isize = read();
        let mut f = false;
        for i in 0..10000{
            if(a * i) % b == c{
                f = true;
                break;
            }
        }
        let ans = if f {"YES"} else {"NO"};
        println!("{}", ans);
    }

    fn read<T>() -> T
    where
        T: std::str::FromStr,
    {
        let stdin = std::io::stdin();
        let token: String = stdin
            .lock()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        token.parse().ok().unwrap()
    }


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
string int2string(int x){
        stringstream ss;
        ss << x;
        string tmp;
        ss >> tmp;
        return tmp;
    }
int string2int(string s){
    stringstream ss;
    ss << s;
    int x;
    ss >> x;
    return x;
}
long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
long long bigpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    ll r= a/gcd(a,b)*b;
    return r;
}
//***********************CODE*****************
int main(){
    
cin.tie(NULL);
cout.tie(NULL);
ios_base::sync_with_stdio(false);
string s;
cin>>s;
if(s[0]==s[1] && s[1]==s[2])
cout<<"No\n";
else cout<<"Yes\n";
    
    return 0;
}

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

void solve()
{
	vector<long long> x(2), y(2);
	cin >> x[0] >> x[1];
	cin >> y[0] >> y[1];

	long long mx = -1e18;
	for(int i = 0; i < 2; i++)
	{
		for(int j = 0; j < 2; j++)
		{
			mx = max(mx, x[i]*y[j]);
		}
	}

	cout << mx << endl;
}

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

	solve();
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

long ret = 0;

void foo(long s, long accum, long current) {
  if (s == 0) {
    ret += accum + current;
    return;
  }

  long count = 1;
  while (true) {
    if (s / count / 10) {
      count *= 10;
    } else {
      break;
    }
  }

  long first = s / count;
  long rest = s % count;

  // +挿入
  foo(rest, first, current + accum);
  // +挿入しない
  foo(rest, accum * 10 + first, current);
}

int main(void) {
  long S;
  cin >> S;
  foo(S, 0, 0);
  cout << ret / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100005
#define pb push_back
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;

int stringToInteger(string x){
    int gg=0;
    //stringstream geek(x);
    //geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}

ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}
ll modInverse(ll a, ll m)
{
    a = a%m;
    for (int x=1; x<m; x++)
       if ((a*x) % m == 1)
          return x;
}
ll maxDivide(ll a, ll b)
{
  while (a%b == 0)
   a = a/b;
  return a;
}
  set<ll>ans;
void primeFactors(ll n)
{

    while (n % 2 == 0)
    {
       ans.insert(2);
        n = n/2;
    }

    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            ans.insert(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        ans.insert(n);
}
ll is(ll no)
{   if(no==1) return 0;
    set<ll>::iterator it;
for(it=ans.begin();it!=ans.end();it++){
  no = maxDivide(no, *it);
  if(no==1) return 1;
//  if()
 // no = maxDivide(no, 3);
 // no = maxDivide(no, 5);
}
//if(no==1) return 1;
//for(it=ans.begin();it!=ans.end();it++){
//if(no==*it) return 1;
//}
  return 0;
}

int comp(string a,string b)
{
    string aa = a.append(b);
    string bb = b.append(a);

    return aa.compare(bb) > 0 ? 1: 0;

}
vector<pair<int,int> >adj[100005];
int colors[100005]={0};
void dfs(int i,int color,int prev1=-1)
{
 for(int j=0;j<adj[i].size();j++)
 {
     if(adj[i][j].first==prev1) continue;
//cout<<adj[i][j].second<<endl;
     if(adj[i][j].second&1)
     {

         colors[adj[i][j].first]=1-color;
     }
     else
         colors[adj[i][j].first]=color;
     dfs(adj[i][j].first,colors[adj[i][j].first],i);

 }
}
bool com(const pair<string,pair<int,int> >&a, const pair<string,pair<int,int> >&b )
{
    if(a.first!=b.first) return a.first<b.first;
    else return a.second.first>b.second.first;

}
int main()
{


  int n;
  cin>>n;
  vector<pair<int,int> >v(n);
  for(int i=0;i<n;i++) {cin>>v[i].first; v[i].second=i;}
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++)
  {

      if(v[n-1].second!=i) cout<<v[n-1].first<<endl;
      else cout<<v[n-2].first<<endl;
  }
}


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

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

  int amari = N % 500;

  if (amari >A) {
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;

int main() {
	bool prime[500000] = { false };
	for (int i = 2; i <= sqrt(500000); i++) {
		if (!prime[i]) {
			for (int j = 2; j*i <= 500000; j++) {
				prime[j*i] = true;
			}
		}
	}
	int n; unsigned int sum;
	while (cin >> n) {
		if (n == 0)break;
		sum = 0; int count = 0;
		for (int i = 2;; i++) {
			if (!prime[i]) { sum += i; count++; }
			if (count == n)break;
		}
		cout << sum << endl;
	}
}


Measured memory_bytes: 3560
#include<stdio.h>
#define N 100000
int main(){
  int Buf[N],RL=0,V=0,SV=0;
  int stack[100],st=0,i=1,j,m;
  char c,CBuf[N];
  Buf[0]=0;
  while(scanf("%c",&c)!=EOF){
   CBuf[i-1]=c;
    switch(c){
    case '/':
      Buf[i]=Buf[i-1]+1;
      break;
    case '_':
      Buf[i]=Buf[i-1];
      break;
    case '\\':
      Buf[i]=Buf[i-1]-1;
      break;
    }
    i++;
  }
  i--;  //iの数をBufとそろえる。
  for(j=0;j<i;j++){   
    if(CBuf[j]=='\\'){
      for(m=j+1;Buf[m]!=Buf[j]&&m<i;m++);
      if(m==i)continue;
      else{
	if(RL>m){
	  SV+=(m-j-1);
	}
	else {
	  stack[st]=SV;
	  st++;
	  V+=SV;
	  SV=m-j-1;
	  RL=m;
	}
      }
    }
  }
  V+=SV;
  stack[st]=SV;
  if(st!=0)printf("%d\n%d ",V,st);else printf("%d\n%d",V,st);
  for(i=1;i<=st;i++)if(i==st)printf("%d",stack[i]);else printf("%d ",stack[i]);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define pb push_back
#define mp make_pair
#define inff 100000
#define ff first
#define ss second
#define sz(x) ((int) (x).size())
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define rep(i,N) for(int i = 0;i < N;i++)
#define frep(i,a,b) for(int i = a;i <= b;i++)
#define pii pair<int , int>
#define pll pair<ll , ll>
#define vii vector<int>
#define vpii vector< pii >
#define fill(A,v) memset(A,v,sizeof(A))
#define setbits(x) __builtin_popcountll(x)
#define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n"
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
#define CASES int t;cin>>t;while(t--)
#define FILE freopen("inp.txt" , "r" , stdin);
#define ld long double

const int MOD = 1e9 + 7;
const int N = 1e6 + 5;
const int K = (1 << 17) + 10;
const ll INF = 2e18 + 500;
const int inf = 0x7fffffff;
const int SQRT = 500;
const int lgN = 20;

int main(int argc, char const *argv[])
{
	fast;

	string s;
	cin >> s;

	int n = s.size();
	vector<bool> dp(n + 10 , false);

	map<string , int> M;
	M["dream"] = 1;
	M["dreamer"] = 1;
	M["erase"] = 1;
	M["eraser"] = 1;

	if (n < 5) {
		cout << "NO\n";
		return 0;
	}

	dp[0] = true;
	for(int i = 1;i <= n;i++) {
		string curr = "";
		for(int j = i , k = 7;k > 0 && j > 0;j--,k--) {
			curr.insert(curr.begin() , s[j - 1]);
			// cout << "curr " << curr << '\n';
			if (M[curr] && dp[j - 1]) {
				dp[i] = true;
			}
		}
	}

	cout << (dp[n] ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 512
import math
from collections import Counter

def mycounter(d,i):
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    return d
    
def ABC159D(a):
    if a<2:
        return 0
    else:
        return math.factorial(a)//math.factorial(a-2)//2

n=int(input())
a=list(map(int,input().split()))
d = dict()
#for i in a:
#    d=mycounter(d,i)
dd=Counter(a)
#print(d)
p=0
for i in dd.values():p+=ABC159D(i)
for i in a:
    print(p-dd[i]+1)

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

using namespace std;

int N;

int Search(int x, int L, int R, int* p) {
	if (R - L == 1) {
		if (x >= p[L])
			return R;
		return L;
	}

	int Mid = (L + R) / 2;

	if (x >= p[Mid])
		return Search(x, Mid, R, p);
	return Search(x, L, Mid, p);
		

}


int main() {

	cin >> N;

	int * A = new int[N];
	int * B = new int[N];
	int * C = new int[N];

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

	sort(A, A + N);
	sort(B, B + N);
	sort(C, C + N);

	long long int * S = new long long int[N];
	//for (int i = 0; i < N; i++)
	//	S[i] = N - Search(B[i], 0, N, C);

	//for (int i = N - 1; i > 0; i--)
	//	S[i - 1] += S[i];

	//long long int Ans = 0;
	//for (int i = 0; i < N; i++) {
	//	if (Search(A[i], 0, N, B) == N)
	//		continue;
	//	Ans += S[Search(A[i], 0, N, B)];
	//}

	long long int Ans = 0;
	long long int p1 = 0;
	long long int p2 = 0;
	for (int i = 0; i < N; i++) {
		while (true) {
			if (p1 == N)
				break;
			if (B[i] > A[p1])
				p1++;
			else
				break;
		}
		while (true) {
			if (p2 == N)
				break;
			if (B[i] >= C[p2])
				p2++;
			else
				break;
		}
		Ans += p1 * (N - p2);
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
pair<long long,long long>xh[200009];
int n;
long long d,a,ans[200009];
int main() {
	scanf("%d%lld%lld",&n,&d,&a);
	for(int i=0;i<n;i++) scanf("%lld%lld",&xh[i].first,&xh[i].second),xh[i].second=(xh[i].second+a-1)/a;
	sort(xh,xh+n);
	for(int i=0;i<n;i++) {
		int pos=upper_bound(xh,xh+n,make_pair(xh[i].first-2*d-1,(long long)1e18))-1-xh;
		ans[i]=(i>0?ans[i-1]:0)+max(xh[i].second-(i>0?ans[i-1]:0)+(pos>=0?ans[pos]:0),(long long)0);
	}
	printf("%lld\n",ans[n-1]);
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define rep(i,x) for(int i=0;i<(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)

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

const int inf = 1e9;

int M, N;
int P[10000], C[500], E[500];
int dp[20010];

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

	rep(i, M) cin >> P[i];

	rep(i, N) cin >> C[i] >> E[i];

	sort(P, P + M, greater<int>());

	fill_n(dp, M + 10000 + 1, inf);
	dp[0] = 0;

	rep(i, N) {
		rrep(j, M + 1) {
			if (dp[j] != inf) {
				chmin(dp[j + C[i]], dp[j] + E[i]);
			}
		}
	}

	int ma = 0;
	int sum = 0;

	for (int i = 1; i <= M + 10000; ++i) {
		if (i <= M) sum += P[i - 1];
		chmax(ma, sum - dp[i]);
	}

	cout << ma << endl;
}

Measured memory_bytes: 1296
package main

import (
	"fmt"
)

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func findLast(nums []int) (i int) {
	i = 0
	x := nums[0]
	for j := 1; j < len(nums); j++ {
		if y := nums[j] % 10; 0 < y && y < x%10 {
			i = j
			x = nums[j]
		}
	}
	return
}

func calcTime(nums []int) (t int) {
	t = 0
	for i, x := range nums {
		if i == findLast(nums) {
			t += x
		} else {
			if x%10 == 0 {
				t += x
			} else {
				t += (x/10 + 1) * 10
			}
		}
	}
	return
}

func main() {
	nums := scanNums(5)
	fmt.Println(calcTime(nums))
}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ", 3);
        int n = Integer.parseInt(line[0]);
        int k = Integer.parseInt(line[1]);
        int s = Integer.parseInt(line[2]);
        int another;
        if (s == 1000000000) {
            another = 1;
        } else {
            another = 1000000000;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (i != 0) {
                sb.append(" ");
            }
            if (i < k) {
                sb.append(s);
            } else {
                sb.append(another);
            }
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 30356
def bb

    s = gets.chomp.scan(/./).map {|x| x.to_i}

    ns = []
    for i in 0..(s.length-3)
        ns.push(((s[i]*100 + s[i+1]*10 + s[i+2]) - 753).abs)
    end

    puts ns.min
end

bb

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;


int main() { 
    int H, W; cin >> H >> W;
    vector<vector<char>> m;
    m.resize(H);
    REP(i, H) {
        m[i].resize(W);
        REP(j, W) {
            cin >> m[i][j];
        }
    }

    vector<bool> row(H, false);
    vector<bool> col(W, false);
    REP(h, H) {
        REP(w, W) {
            if(m[h][w] == '#') {
                row[h] = true;
                col[w] = true;
            }
        }
    }

    REP(h, H) {
        if(row[h]) {
            bool show = false;
            REP(w, W) {
                if(col[w]) {
                    cout << m[h][w];
                    show = true;
                }
            }
            if(show) cout << endl;
        }
    }


    // vector<int> mh;
    // vector<int> mw;
    // REP(w, W) {
    //     bool allWhite = true;
    //     REP(h, H) {
    //         if(m[h][w] != '.') {
    //             allWhite = false;
    //         }
    //     }
    //     if (allWhite) {
    //         mw.push_back(w);
    //     }
    // }
    // REP(h, H) {
    //     bool allWhite = true;
    //     REP(w, W) {
    //         if(m[h][w] != '.') {
    //             allWhite = false;
    //         }
    //     }
    //     if (allWhite) {
    //         mh.push_back(h);
    //     }
    // }
    // vector<vector<char>> comp;
    // REP(h, H) {
    //     comp.resize(comp.size()+1);
    //     REP(w, W) {
    //         if(find(mh.begin(), mh.end(), h) == mh.end()) {
    //             if(find(mw.begin(), mw.end(), w) == mw.end()) {
    //                 int hh = comp.size()-1;
    //                 int ww = comp[hh].size();
    //                 // print(hh, ww);
    //                 // print(h, w, m[h][w]);
    //                 comp[hh].resize(comp[hh].size()+1);
    //                 comp[hh][ww] = m[h][w];
    //             }
    //         }
    //     }
    // }
    // REP(h, comp.size()) {
    //     REP(w, comp[h].size()) {
    //         cout << comp[h][w];
    //     }
    //     if(comp[h].size() > 0) cout << endl;
    // }

    
    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

void solve(int n,int m){
    vector<int> cnt1(2000000);
    vector<int> a(n+1),b(m+1);
    rep(i,n)cin>>a[i+1];
    rep(i,n)a[i+1]+=a[i];
    rep(i,n+1)REP(j,i+1,n+1)cnt1[a[j]-a[i]]++;
    rep(i,m)cin>>b[i+1];
    rep(i,m)b[i+1]+=b[i];
    ll ans=0;
    rep(i,m+1)REP(j,i+1,m+1)ans+=cnt1[b[j]-b[i]];
    cout<<ans<<endl;
}


int main(){
    int n,m;
    while(cin>>n>>m,n!=0)solve(n,m);
    return 0;
}


Measured memory_bytes: 10920
n = int(input())
a = [int(x) for x in input().split()]
b = [0] * n

for i in range(n):
    x = n-i
    if(a[x-1] == 0):
        tmp = 0
        for j in range(int(n/x)):
            if(b[x*(j + 1)-1] == 1):
                tmp += 1
        if(tmp % 2 == 1):
            b[x-1] = 1
    else:
        tmp = 0
        for j in range(int(n/x)):
            if(b[x*(j + 1)-1] == 1):
                tmp += 1
        if(tmp % 2 == 0):
            b[x-1] = 1

ans = 0
ANS = []
for i in range(n):
    if(b[i] == 1):
        ans += 1
        ANS.append(i)
print(ans)
for i in range(len(ANS)):
    print(ANS[i]+1, end=' ')


Measured memory_bytes: 12088