akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
  FAST();

  int n;
  cin >> n;
  vi arr(n);
  REP(i, 0, n)  cin >> arr[i];

  int flag = true;

  REP(i, 0, n){
      if(arr[i]%2 == 0){
        if(arr[i]%3!=0 && arr[i]%5!=0)
            flag = false;
      }
  }

  cout << ((flag == true) ? "APPROVED\n" : "DENIED\n");

  return 0;
}


Measured memory_bytes: 256
def solve(string):
    n = len(string)
    ans = [0] * n

    def op(string, ans, forward=True):
        count = 0
        check = "R" if forward else "L"
        sign, base = 2 * forward - 1, (n - 1) * (1 - forward)
        for i, a in enumerate(string[::sign]):
            if a == check:
                count += 1
            elif count > 0:
                ans[base + sign * i] += count // 2
                ans[base + sign * (i - 1)] += (count + 1) // 2
                count = 0
        return ans

    ans = op(string, ans, True)
    return " ".join([str(a) for a in op(string, ans, False)])


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 10492
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ll n, a, b, c, d, e;
    cin >> n >> a  >> b >> c >> d >> e;
    ll mi = min({a, b, c, d, e});
    ll ans = (mi+n-1)/mi;

    ans += 4;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e12+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	double r;cin>>r;
	cout<<fixed<< setprecision(20);
	cout<<r*r*pai<<" "<<r*2*pai<<endl;
	RE;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  db n,m,d;
  cin>>n>>m>>d;
  db ans=0.0;
  if(d==0)
    {
      ans=(m-1.0)/n;
    }
  else
    {
      ans=(n-d)*2.0;
      ans/=(n*n);
      ans*=(m-1.0);
    }
  cout<<setprecision(10)<<fixed<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define chmin(x, y) x = min(x, y)
#define ll long long
#define ld long double
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int r; cin >> r;
  cout << r*r << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n, k;
	cin>> n >>k;
	string s;
	cin>> s;
	char c=s[k-1];
	if(c=='A'){
		c = 'a';
	}else if(c=='B'){
		c ='b';
	}else{
		c='c';
	}
	s[k-1] = c;
	cout<< s <<endl;
}


Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
ll modpow(int n, int k, int p) {
    intmax_t res = 1;
    for (intmax_t i = n; k; k >>= 1) {
        if (k & 1)res = res * i%p;
        i = i * i % p;
    }
    return res;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> m >> n;
    cout << modpow(m, n, MOD) << endl;;
    return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

const uint64_t MOD = 1e+9 + 7;

class ModuloOps
{
private:
  std::vector<uint64_t> _fact, _fact_inv;

  void _calc_fact(uint64_t n)
  {
    for (uint64_t i = 2; i <= n; ++i) {
      _fact[i] = (_fact[i - 1] * i) % MOD;
      _fact_inv[i] = inv(_fact[i]);
    }
  }

public:
  ModuloOps(uint64_t n)
  {
    _fact = std::vector<uint64_t>(n + 1);
    _fact_inv = std::vector<uint64_t>(n + 1);

    _fact[0] = 1;
    _fact[1] = 1;
    _fact_inv[0] = 1;
    _fact_inv[1] = 1;

    _calc_fact(n);
  }

  uint64_t power(uint64_t x, uint64_t y) const
  {
    if (y <= 1) {
      return (y == 0) ? 1 : (x % MOD);
    }

    uint64_t w = power(x, y >> 1);
    uint64_t z = (w * w) % MOD;

    if (y % 2 == 1) {
      z = (x * z) % MOD;
    }

    return z;
  }

  uint64_t inv(uint64_t n) const { return power(n, MOD - 2); } 

  uint64_t fact(uint64_t n) const { return _fact[n]; }
  uint64_t fact_inv(uint64_t n) const { return _fact_inv[n]; }

  uint64_t perm(uint64_t n, uint64_t k) const {
    return (_fact[n] * _fact_inv[n - k]) % MOD;
  }

  uint64_t comb(uint64_t n, uint64_t k) const {
    return (perm(n, k) * _fact_inv[k]) % MOD;
  }

  uint64_t prem_rep(uint64_t k, uint64_t l) const
  {
    uint64_t x = _fact[k + l];
    x = (x * _fact_inv[k]) % MOD;
    x = (x * _fact_inv[l]) % MOD;
    return x;
  }

  uint64_t prem_rep(const std::vector<uint64_t> &a) const
  {
    uint64_t n = std::accumulate(a.begin(), a.end(), 0);
    uint64_t x = _fact[n];
    for (uint64_t y : a) {
      x = (x * _fact_inv[y]) % MOD;
    }
    return x;
  }

  uint64_t comb_rep(uint64_t n, uint64_t k) const {
    return comb(n + k - 1, k);
  }
};

int main()
{
  uint64_t N, K;
  cin >> N >> K;

  ModuloOps mod_ops(N << 1);

  uint64_t S = 0;
  N_TIMES(k, min(N, K + 1)) {
    uint64_t s = (mod_ops.comb(N, k) * mod_ops.comb_rep(N - k, k)) % MOD;
    S = (S + s) % MOD;
  }
  cout << S << endl;

  return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<queue>
#include<utility>

#define VMAX 10000
using namespace std;
typedef pair<long long, pair<int, int>> pli;
vector<pli> edge[VMAX];
int color[VMAX];

long long Prim(int n, int s){
    priority_queue<pli, vector<pli>, greater<pli>> q;
    for(int i=0; i<n; ++i){
        color[i] = 0;
    }
    for(int i=0; i<edge[s].size(); ++i){
        q.push(edge[s][i]);
    }
    color[s] = 1;
    int u, v, w;
    long long res = 0;
    while(!q.empty()){
        w = q.top().first;
        v = q.top().second.first;
        u = q.top().second.second;
        q.pop();
        if(!color[v]){
            color[v] = 1;
            res += w;
            for(int i=0; i<edge[v].size(); ++i){
                q.push(edge[v][i]);
            }
        }
    }
    return res;
}

int main(){
    int v, e, w, s, t;
    cin>>v>>e;
    for(int i=0; i<e; ++i){
        cin>>s>>t>>w;
        edge[s].push_back(make_pair(w, make_pair(t, s)));
        edge[t].push_back(make_pair(w, make_pair(s, t)));
    }

    long long res = Prim(v, 0);
    cout<<res<<endl;

    return 0;
}


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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main() {

    int N, x;
    cin >> N;
    map<string,ll> mp;
    forn(i, N) {
        string s; cin >> s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    ll ans = 0;
    for(auto p : mp) {
        ll x = p.second;
        ans += x*(x-1)/2;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>

int main(void){
	
	int n,c1,m1,s1,m2,s2,m3,s3,m4,s4;
	int i,j,tmp,ones=1000000,onen,secs=1000000,secn,minn,mins=0,minin,minis=0;

	while(scanf("%d",&n) != EOF){

		if(n==0)
			break;
			
		for(i=0;i<n;i++){
			
			scanf("%d %d %d %d %d %d %d %d %d",&c1,&m1,&s1,&m2,&s2,&m3,&s3,&m4,&s4);
			
			tmp=((m1+m2+m3+m4)*60)+s1+s2+s3+s4;
			
			if(ones>tmp){
				secs=ones;
				secn=onen;
				ones=tmp;
				onen=c1;
			}
			else if(secs>tmp){
				secs=tmp;
				secn=c1;
			}
			if(mins<tmp){
				minis=mins;
				minin=minn;
				mins=tmp;
				minn=c1;
			}
			else if(minis<tmp){
				minis=tmp;
				minin=c1;
			}

		}

		printf("%d\n%d\n%d\n",onen,secn,minin);
		
		ones=1000000;
		secs=1000000;
		mins=0;
		minis=0;

	}
	
	return 0;
	
}

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

signed main(){
  int x,n;cin>>x>>n;
  set<int> s;
  while(n--){
    int a;cin>>a;
    s.insert(a);
  }
  int ans=0,mn=1e9;
  for(int j=-200;j<=200;j++){
    if(s.count(j))continue;
    if(abs(j-x)<mn)ans=j,mn=abs(j-x);
  }
  cout<<ans<<endl;
}


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

#ifdef DEBUG
#define NDEBUG
#include "cout11.h"
#endif
#undef NDEBUG
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

int solve(int N, vvi& a) {
    vi t0(N, 0), t1(N, 0);

    t0[0] = a[0][0];
    rep1(i, N-1) t0[i] = t0[i-1] + a[0][i];

    t1[0] = t0[0] + a[1][0];
    rep1(i, N-1) t1[i] = max(t1[i-1], t0[i]) + a[1][i];

    return t1[N-1];
}

int main() {
    int N;cin>>N;
    vvi a(2, vi(N));
    rep(i, 2){
        rep(j, N){
            cin >> a[i][j];
        }
    }
    cout << solve(N, a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
#include <cstdint>

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

double r,PI = 3.1415926535897932;
cin >> r;
cout << 2*r*PI << endl;


//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 3800
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const S = {
    A: input[0][0].split(""),
    B: input[1][0].split(""),
    C: input[2][0].split(""),
  };

  let current: keyof typeof S = "A";

  while (S[current].length !== 0) {
    current = S[current].shift()!.toUpperCase() as keyof typeof S;
  }

  return current;
};

console.log(main(read()));


Measured memory_bytes: 29536
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  double p[n];
  for(int i=0;i<n;i++)
    cin>>p[i];
  double dp[n+1][n+1];
  
  dp[1][0]=p[0];
  dp[1][1]=1-p[0];
  double ans=0.0;
  for(int k=2;k<=n;k++){
  	for(int i=0;i<=k;i++){
    	if(i==0)
          dp[k][i]=dp[k-1][0]*p[k-1];
      else if(k==i)
        dp[k][i]=dp[k-1][i-1]*(1-p[k-1]);
      else
        dp[k][i]=dp[k-1][i-1]*(1-p[k-1])+dp[k-1][i]*p[k-1];
      
      if(k==n && i<=n/2)
        ans+=dp[k][i];
    
    }
  
  
  }
  if(n==1)
    ans = dp[1][0];
cout<<setprecision(10)<<ans<<endl;

}

Measured memory_bytes: 70400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;

#define rep(i, n) for (int i = 0; i < (int)(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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  ll mean = 0;
  vector <ll> v(n);
  rep(i, n) {
    cin >> v.at(i);
    mean += v.at(i);
  }
  mean /= n;
  ll ans1 = 0, ans2 = 0;
  rep(i, n) {
    ans1 += (ll)pow(v.at(i)-mean, 2);
    ans2 += (ll)pow(v.at(i)-(mean+1), 2);
  }
  cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 256
require "set"
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i)

hash = {}
a_arr.each do |a|
  hash[a] ||= 0
  hash[a] += 1
end

max = 0
set3 = Set.new
hash.each do |k, v|
  if v == 1
    set3 << k
    max = k if k > max
  end
end

hash.each do |k, v|
  i = 2
  tmp = k * i
  while tmp <= max do
    set3.delete(tmp)
    i += 1
    tmp = k * i
  end
end

puts set3.size

Measured memory_bytes: 47032
#include <iostream>
#include <string>
#include <bitset>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){

    string str;
    long long sum = 0;
    cin >> str;
    
    // 各計算の式のプラスが入る場所を作る
    for(int tmp = 0; tmp < (1 << (str.size()-1)); tmp++){
        bitset<10> s(tmp);
        string now_Str = "";
        now_Str = str[0];
        
        // 各計算の式を作る場所、bitset<>でプラスがある場所を設定
        for(int i = 0; i < (str.size()-1); i++){
            if(s.test(i)) now_Str += "+";
                now_Str += str[i+1];
        }
    
        int pos = 0; // 現在地、find()で現在見ている場所が変化するから。
        
        // プラス前までの数を sum に加える
        while(now_Str.find("+", pos) != string::npos){
            int next_Pos = now_Str.find("+", pos);
            sum += stoll(now_Str.substr(pos, next_Pos - pos));
            pos = next_Pos + 1;
        }
        // 最後プラス後の数を sum に加える
        sum += stoll(now_Str.substr(pos));
        
    }
    
    cout << sum << endl;
    
}


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


int main() {
  int a[5];
  int b = 10;
  int c = 0;
  for(int i = 0;i < 5;i++){
    cin >> a[i];
    if(a[i]%10 < b && a[i]%10 != 0){
      c = i;
      b = a[i]%10;
    }
  }
  int ans = 0;
  for(int i = 0;i < 5;i++){
    if(i == c){
      ans += a[i];
    }else{
      int x = a[i]%10;
      if(x != 0){
        x = a[i] + 10 - x;
        ans += x;
      }else{
        x = a[i];
        ans += x;
      }
    }

  }
  cout << ans << endl;


}


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

int main(void){
  char s[20];
  int i,j,ans=0,cnt;
  scanf("%s",s);
  for(i=0;i<strlen(s);i++){
    cnt=0;
    if(s[i]=='A' || s[i]=='T' || s[i]=='C' || s[i]=='G'){
      for(j=i;;j++){
        if(!(s[j]=='A' || s[j]=='T' || s[j]=='C' || s[j]=='G')) break;
        cnt++;
      }
    }
    if(ans<cnt) ans=cnt;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
from collections import Counter
# from fractions import gcd # >=Python3.5 # lcm（最小公倍数） = (a*b)//gcd(a,b)
# from fractions import Fraction
# from math import gcd # <Python3.5
# from math import sqrt

#input = sys.stdin.readline
#def main():

#---------------------------------------------------------

n = int(input())
li = list(map(int,input().split()))
q = int(input())
ope = [list(map(int,input().split())) for i in range(q)]

cnt = Counter(li)

ans = sum(li)

for i in range(q):
    sub = ope[i][1]-ope[i][0]
    ans += cnt[ope[i][0]]*sub
    print(ans)
    cnt[ope[i][1]]+=cnt[ope[i][0]]
    cnt[ope[i][0]]=0

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

ll n,m;
vector<ll> a;
ll f_ind(ll i, ll x){ 
    auto it = lower_bound(a.begin(), a.end(), x - a[i]); // (2)
    return a.end() - it;
}
ll fint(ll x){ // x 以下となるペアの数
    ll ans = 0;
    REP(i,n) ans += f_ind(i,x);
    return ans;
}
bool f(ll x){
    return fint(x) <= m;
}

signed main(){
    cin >> n >> m;
    a.resize(n);
    REP(i,n) cin >> a[i];
    sort(a.begin(), a.end());

    ll ng = 0;
    ll ok = 2 * a[n-1] + 1; // (1)
    while(abs(ok-ng) > 1){
        ll mid = (ok + ng)/2;
        (f(mid) ? ok : ng) = mid;
    }
    ll rem = m - fint(ok);
    ll border = 0;

    REP(i,n) {
        if (f_ind(i,ok) == n) continue; // (3)
        border = max(border, a[i] + a[n-1-f_ind(i,ok)]);
    }
    ll ans = border * rem;

    vector<ll> acum = a;
    acum.push_back(0);
    REP(i,n) acum[n-1-i] += acum[n-i];

    REP(i,n) {
        ans += f_ind(i,ok) * a[i] + acum[n-f_ind(i,ok)];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  if ((a + b) % 2 == 0){
    ll ans = (b-a) / 2;
    cout << ans << endl;
  }
  else{
    ll x1 = max(n - a, n - b);
    ll x2 = min(n - a, n - b);
    ll y1 = max(a - 1, b - 1);
    ll y2 = min(a - 1, b - 1);
    if (x1 >= y1){
      cout << (a + b - 1) / 2 << endl;
    }
    else{
      cout << (x1 + x2 + 1) / 2 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int A, B;
    cin >> A >> B;
    cout << max(A - 2 * B, 0) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int)n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}
 
int main(){
	//in_o();
	int n,m;
	cin>>n>>m;
	int l_max=1,r_min=n;
	while(m--){
		int l,r;
		cin>>l>>r;
		l_max=max(l_max,l);
		r_min=min(r_min,r);
	}
	cout<<max(r_min-l_max+1,0)<<endl;
	return 0;
}


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

int main(){
  int N;
  cin>>N;
  double ans=0;
  for(int i=0;i<N;i++){
    double x;
    string u;
    cin>>x>>u;
    if(u=="JPY"){
      ans+=x;
    }else{
      ans+=x*380000.0;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int gcd(int a, int b) {
    if (a < b) return gcd(b, a);
    if(!b) return a;
    return gcd(b, a % b);
}

signed main() {
    int a, b;
    cin >> a >> b;
    int d = __gcd(a, b);
    int _d = d;
    int result = 1;
    for(int i = 2; i * i <= _d; ++i) {
        if (d % i == 0) {
            result++;
            while (d % i == 0)
                d /= i;
        }
    }
    if (d != 1) result++;
    cout << result << "\n";
}

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

int main(){
    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  for ( ; ; ) {
    int n, x;
    scanf("%d %d", &n, &x);

    if (n==0 && x==0) return 0;

    int cnt=0;
    for (int i=1; i<=n-2; i++) {
      for (int j=i+1; j<=n-1; j++) {
        for (int k=j+1; k<=n; k++) {
          if (i+j+k==x) cnt++;
        }
      }
    }
    printf("%d\n", cnt);
  }
  return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
int main()
{
    long long int arr[100009]={},n,m,i,j,k,l,p,q,r,brr[100009]={};
    scanf("%lld",&n);
    k=0;
    for(i=0;i<n;i++){
        scanf("%lld",&m);
        arr[m]++;
        brr[i]=m;
        if(m>k)
            k=m;
    }
    if(arr[0]!=1 || brr[0]!=0)
        printf("0");
    else{
        for(i=0;i<n;i++){
            if(arr[i]==0){
                    if(k>=i){
                        printf("0");
                        return 0;
                    }
                break;
            }
        }
        m=1;
        for(i=0;i<k;i++){
            j=arr[i+1];
            l=arr[i];
            p=1;
            for(q=1;q<=j;q++){
                p*=l;
                p=p%mod;
            }
        m=m*p;
        m=m%mod;
        }
        printf("%lld",m);
    }
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(){
    int a,b,k,i,temp[100];
    int c=1;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&k);
    for(i=1;i<=100;i++){
        if(a<i && b<i)break;
        if(a%i!=0)continue;
        if(b%i!=0)continue;
        temp[c++] = i;
    }
    printf("%d\n",temp[c-k]);
    return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut tbl = vec![vec![vec![0.0; n + 1]; n + 1]; n + 1];

    for c3 in 0..n + 1 {
        for c2 in 0..n + 1 {
            for c1 in 0..n + 1 {
                if (c1, c2, c3) == (0, 0, 0) {
                    continue;
                }

                let p1 = c1 as f64 / n as f64;
                let p2 = c2 as f64 / n as f64;
                let p3 = c3 as f64 / n as f64;
                let p0 = 1.0 - p1 - p2 - p3;

                // t = p1*x1 + p2*x2 + p3*x3 + p0 * t + 1
                // (1 - p0) * t = p1*x1 + p2*x2 + p3*x3 + 1
                // t = (p1*x1 + p2*x2 + p3*x3 + 1) / (1 - p0)

                let x1 = if c1 > 0 { tbl[c1 - 1][c2][c3] } else { 0.0 };
                let x2 = if c2 > 0 && c1 + 1 <= n {
                    tbl[c1 + 1][c2 - 1][c3]
                } else {
                    0.0
                };
                let x3 = if c3 > 0 && c2 + 1 <= n {
                    tbl[c1][c2 + 1][c3 - 1]
                } else {
                    0.0
                };

                let t = (p1 * x1 + p2 * x2 + p3 * x3 + 1.0) / (1.0 - p0);
                tbl[c1][c2][c3] = t;
            }
        }
    }

    let a1 = a.iter().filter(|a| **a == 1).count();
    let a2 = a.iter().filter(|a| **a == 2).count();
    let a3 = a.iter().filter(|a| **a == 3).count();

    let ans = tbl[a1][a2][a3];
    println!("{}", ans);
}


Measured memory_bytes: 237820
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, k;
	cin >> n >> k;

	int ans = k;
	int i = 1;
	while (i < n) {
		ans *= (k - 1);
		++i;
	}

	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<29;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N, Y; cin >> N >> Y;
  int Y2 = Y / 1000;

  bool flag = false;
  int x, y, z;
  for (int i = 0; i < 20000; ++i){
    if ((Y2 - N - 9 * i) % 4 == 0 && Y2 - N - 9 * i>= 0) {
      x = i;
      y = (Y2 - N - 9 * x) / 4;
      z = N - x - y;
      if (x >=0 && y >= 0 && z >= 0){
        flag = true;
        break;
      }
    }
  }
  if(flag) cout << x << " " << y << " " << z << endl;
  else cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
from collections import defaultdict
element = defaultdict(int)
def is_prime(n):
    if n == 1:
        return False
    for k in range(2, int(n**0.5) + 1):
        if n % k == 0:
            return False
    return True

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

    divisors.sort()
    return divisors
ans = 1
N = int(input())
for num in range(1, N+1):
    div = make_divisors(num)
    while num > 1:
        for d in div[1:]:
            if num % d == 0:
                element[d] += 1
                num //= d
                break
    # print(num, element)
for v in element.values():
    ans *= (v+1)
    ans %= (10**9+7)
print(ans)

Measured memory_bytes: 40304
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.14159265;
const ll MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
struct Spell {
    int a, b;
};
Spell spls[MAXN];

int dp[10005];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d%d", &m, &n);
    for (int i = 1; i <= n; i++) scanf("%d%d", &spls[i].a, &spls[i].b);
    for (int i = 1; i <= m; i++) dp[i] = INF2;
    for (int i = 1; i <= n; i++) {
        for (int j = spls[i].a; j <= m; j++)
            dp[j] = min(dp[j], dp[j - spls[i].a] + spls[i].b);
    }
    int ans = dp[m];
    for (int i = 1; i <= n; i++) {
        int lm = max(0, m - spls[i].a);
        for (int j = m; j >= lm; j--) {
            ans = min(ans, dp[j] + spls[i].b);
        }
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll N, X;
  cin >> N >> X;
  auto x = mvec<ll>(N);
  for(auto&& i : x){
    cin >> i;
    i = abs(i-X);
  }
  ll ans = x[0];
  rep(i, 1, N){
    ans = gcd(ans, x[i]);
  }
  cout << ans << rt;
}

Measured memory_bytes: 1024
ans' h [] = h
ans' h ([p,c]:cs) =
  let x = take c $ drop (p-1) h
      y = take (p-1) h
      z = drop (p-1+c) h
  in
    ans' (x++y++z) cs
  
ans ([0,0]:_) = []
ans ([n,r]:xs) =
  let c = take r xs
      y = drop r xs
      h = reverse [1..n]
      a = head $ ans' h c
  in
    a:(ans y)
    
main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  mapM_ print o



Measured memory_bytes: 4916
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n + 1];
		int sum = 0;
		for (int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}
		int min = 999999;
		int sum2 = 0;

		for (int i = 1; i <= n; i++) {

			sum2 += a[i];
			if (min > Math.abs(sum - sum2 - sum2)) {
				min = Math.abs(sum - sum2 - sum2);
			}

		}
		System.out.println(min);
	}
}

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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    vector<pair<int, int>> BC(M);
    for(int i=0; i<N; ++i){
        cin >> A[i];
    }
    for(int i=0; i<M; ++i){
        cin >> BC[i].first >> BC[i].second;
    }
    sort(BC.begin(), BC.end(), [](auto l, auto r){
        return l.second>r.second;
    });
    sort(A.begin(), A.end(), [](auto l, auto r){
        return l<r;
    });
    int left = 0;
    for(int i=0; i<M; ++i){
        int count = 0;
        for(int j=left; j<N; ++j){
            if(A[j]<BC[i].second){
                A[j] = BC[i].second;
                ++left;
                ++count;
            }
            else break;
            if(count>=BC[i].first) break;
        }
    }
    long long s = 0;
    for(int i=0; i<N; ++i){
        s += A[i];
    }
    cout << s << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

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

int main(){
    ll n;cin>>n;
    ll b[n-1];
    for(ll i=0;i<n-1;i++){
        cin>>b[i];
    }
    ll ans=0;
    if(n>2){
        ans=b[0]+b[n-2];
        for(ll i=0;i<=n-3;i++){
            ans+=min(b[i],b[i+1]);
        }
    }else{
        ans=2*b[0];
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int count=0;
  for(int i=0; i<S.size(); i++){
    if(S.at(i)!=S.at(S.size()-(i+1))){
      count++;
    }
  }
  cout << count/2 << endl;
}

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

int main(){
    int a,b,c; cin >> a >> b >> c;
    if((a==b && b != c) || (c==b && b != a) || (a==c && b != c)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

void printSort(int a[], int N){
    rep(i, N){
        if(i != 0){
            cout << " ";
        }
        cout << a[i];
    }
    cout << endl;
}

void insertSort(int a[], int N){
    int v, j;
    for(int i = 1; i < N; i++){
        v = a[i];
        j = i - 1;
        while(j >= 0 && a[j] > v){
            a[j+1] = a[j]; //a[i]のいちに後ろにずらしていく
            j--;
        }
        a[j+1] = v; //最後はj--してあるから
        printSort(a, N);
    }
}

int main(){
    int N, a[100];
    cin >> N;
    rep(i, N){
        cin >> a[i];
    }
    printSort(a, N);
    insertSort(a, N);
}


Measured memory_bytes: 3076
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#define MP make_pair
#define fi first
#define se second 
#define pb push_back
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const ll INF=1000000000000000ll;
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int a,b,c,n,m,i;
	scanf("%d%d%d",&a,&b,&c);scanf("%d%d",&n,&m);
	ll ans,tmp;
	ans=INF;
	rep(i,0,max(n,m)){
		tmp=1ll*2*i*c;
		if(i<n)	tmp+=1ll*a*(n-i);
		if(i<m)	tmp+=1ll*b*(m-i);
		ans=min(ans,tmp);
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int count32bit(unsigned v) {
	unsigned count = (v & 0x55555555) + ((v >> 1) & 0x55555555);
	count = (count & 0x33333333) + ((count >> 2) & 0x33333333);
	count = (count & 0x0f0f0f0f) + ((count >> 4) & 0x0f0f0f0f);
	count = (count & 0x00ff00ff) + ((count >> 8) & 0x00ff00ff);
	return (count & 0x0000ffff) + ((count >> 16) & 0x0000ffff);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	vector<int> F(N,0);
	REP(i,N){
		REP(j,10){
			F[i]*=2;
			F[i]+=in();
		}
	}
	vector<vector<int>> P(N,vector<int>(11,0));
	REP(i,N){
		REP(j,11) P[i][j]=in();
	}
	
	int maxP = -atcoder_mod;
	for(int i=1;i<1024;i++){
		int thisP = 0;
		REP(j,N){
			int B = count32bit(i&F[j]);
			thisP += P[j][B];
		}
		maxP = max(maxP,thisP);
	}
	
	out(maxP);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    int n; cin >> n;
    vector<int>p(n);
    rep(i,n)cin >> p[i];
    int cnt=0;
    rep(i,n-2){
        if(p[i]<p[i+1] && p[i+1]<p[i+2]){
            cnt++;
        }else if(p[i+2]<p[i+1] && p[i+1]<p[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}




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

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '1')
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
import numpy as np
N = int(input())
a = list(map(int,input().split()))
flg = 1
ans = 0
while flg == 1:
    for i in range(N):
        if a[i]%2!=0:
            flg = 0
    if flg == 1:
        ans +=1
        for i in range(N):
            a[i]=a[i]/2
print(ans)

Measured memory_bytes: 12464
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    int N;cin>>N;
    vector<int> x;
    REP(i,N){
        int xi;cin>>xi;
        x.push_back(xi);
    }
    LL L;cin>>L;

    vector<int> doub[N];
    doub[N-2].push_back(N-1);
    auto findNext = [&](int i){return upper_bound(ALL(x),x[i]+L) - x.begin() -1;};

    for(int i=N-3;i>=0;i--){
        int pointer=0;
        int next = findNext(i);
        doub[i].push_back(next);
        while(doub[next].size()>pointer){
            next = doub[next][pointer++];
            doub[i].push_back(next);
        }
    }

    LL two[30];
    two[0]=1;
    REP(i,29)two[i+1]=two[i]*2;


    auto culcNum = [&](int a,int b){
        int ans=0;
        int next=a;
        while(true){
            int nextp = lower_bound(ALL(doub[next]),b) - doub[next].begin()-1;
            if(nextp<0){
                ans++;
                return ans;
            }
            ans += two[nextp];
            next = doub[next][nextp];
        }
    };

    int q;cin>>q;
    REP(i,q){
        int a,b;cin>>a>>b;
        a--;b--;
        cout<<culcNum(min(a,b),max(a,b))<<endl;
    }
    return 0;
}

Measured memory_bytes: 13560
#include<stdio.h>
int w,h;
int c[100][100];

int qx[1000000];
int qy[1000000];
int X,Y,left,right;

void push(int x,int y){
  right++;
  qx[right]=x;
  qy[right]=y;
}

void pop(){
  X=qx[left];
  Y=qy[left];
  left++;
}

void bfs(int sx,int sy){
  left=0;
  right=-1;
  push(sx,sy);
  c[sx][sy]=0;
  while(left<=right){
    pop();
    for(int nx=X-1;nx<=X+1;nx++){
      for(int ny=Y-1;ny<=Y+1;ny++){
        if(nx>=0 && ny>=0 && c[nx][ny]!=0){
          c[nx][ny]=0;
          push(nx,ny);
        }
      }
    }
  }
}

int main(){

  while(1){
    scanf("%d %d",&w,&h);
    if(w==0&&h==0)break;
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        scanf("%d",&c[i][j]);
      }
    }

    int ans=0;
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(c[i][j]!=0){
          ans++;
          bfs(i,j);
        }
      }
    }

    printf("%d\n",ans);
    
  }
  return 0;
}

Measured memory_bytes: 2628