akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

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

const ll MODBASE = 1000000007LL;
const int MAXN = 1000010;
const int MAXM = 110;
const int MAXK = 510;

int m, k, res[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> m >> k;
    if (k >= (1<<m)) cout << -1;
    else {
        if (m == 1 && k == 0) {
            cout << "0 0 1 1";
            return 0;
        }
        if (m == 1 && k == 1) {
            cout << -1;
            return 0;
        }
        res[0] = k;
        res[1<<m] = k;
        int now = (1<<m);
        FORE(i,(1<<m)-1,1) {
            now--;
            if (now == k) now--;
            res[i] = now;
        }
        now = (1<<m);
        FOR(i,(1<<m)+1,(1<<(m+1))-1) {
            now--;
            if (now == k) now--;
            res[i] = now;
        }
        FOR(i,0,(1<<(m+1))-1) cout << res[i] << ' ';
    }
    return 0;
}

Measured memory_bytes: 2816
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

using namespace std;

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

pair<int, int> solve(string s){
    rep(i, s.size()-1){
        if(s[i] == s[i+1]){
            return make_pair(i+1, i+2);
        }
    }
    rep(i, s.size()-2){
        if(s[i] == s[i+2]){
            return make_pair(i+1, i+3);
        }
    }
    return make_pair(-1, -1);
}

int main(){
    string s;
    cin >> s;
    pair<int, int> ans = solve(s);
    cout << ans.first << " " << ans.second << endl;
    return 0;
}

Measured memory_bytes: 512
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto a = RD;
	auto b = RD;
	auto x = RD;
	
	long ans = b / x - (a == 0 ? -1 : (a-1) / x);
	writeln(ans);
	stdout.flush();
	debug readln();
}

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

int k, m, n, h, w, b, c;
ll t[1 << 17], d[1 << 17];

int a[1000];

int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            int p;
            cin >> p;
            a[p]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= m; i++)
    {
        if (a[i] == n)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,mod=1e9+7,ans=1,pos=0;cin>>n;
  vector<char> c_(n);
  vector<vector<char>> C(2,c_);
  string s1,s2;cin>>s1>>s2;
  rep(i,n) {C[0][i]=s1[i];C[1][i]=s2[i];}
  char prev='z';
  while(pos<n) {
    if(C[0][pos]==C[1][pos]) {
      if(prev=='x') ans*=2;
      else if(prev=='y') ans*=1;
      else ans*=3;
      pos++;prev='x';
    }
    else {
      if(prev=='x') ans*=2;
      else if(prev=='y') ans*=3;
      else ans*=6;
      pos+=2;prev='y';
    }
    ans%=mod;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main(){
    int N;
    cin >> N;
    vector<ll> T(N);
    for(int i = 0; i < N; i++){
        cin >> T[i];
    }
    
    sort(T.begin(), T.end());
    
    ll ans = 1;
    
    for(int i = 0; i < N; i++){
        if(ans > T[i]){
            ans = lcm(ans, T[i]);
        }
        else{
            ans = lcm(T[i], ans);
        }
    }
    
    cout << ans << endl;
}

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

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

Measured memory_bytes: 256
/*
16:54 - 17;14
 */
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<climits>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 31

using namespace std;

struct Data{
  int cur,state,cost;
  Data(int cur=IINF,int state=IINF,int cost=IINF):cur(cur),state(state),cost(cost){}
  bool operator < (const Data& a)const{ return cost > a.cost; }
};

int H,W,sp,gp;
char G[MAX*MAX];
int mincost[MAX*MAX][(1<<9)];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
int Index[30];

inline bool isValid(int x,int y){ return (0 <= x && x < W && 0 <= y && y < H); }

void compute(){
  rep(i,H)rep(j,W)rep(k,(1<<9))mincost[j+i*W][k] = IINF;
  mincost[sp][0] = 0;
  priority_queue<Data> Q;
  Q.push(Data(sp,0,0));
  while(!Q.empty()){
    Data data = Q.top(); Q.pop();
    int x = data.cur % W, y = data.cur / W;

    if(G[data.cur] == '<'){
      cout << data.cost << endl;
      return;
    }
    rep(i,4){
      int nx = x + dx[i], ny = y + dy[i], nstate = data.state;

      if(!isValid(nx,ny))continue;
      if(G[nx+ny*W] == '#')continue;
      if('a' <= G[nx+ny*W] && G[nx+ny*W] <= 'z'){
	int index = Index[G[nx+ny*W]-'a'];
	if((nstate>>index) & 1)nstate  = nstate & ~(1<<index);
	else                   nstate |= (1<<index);
      } else if('A' <= G[nx+ny*W] && G[nx+ny*W] <= 'Z'){
	int index = Index[G[nx+ny*W]-'A'];
	if(!((data.state>>index) & 1))continue;
      }
      if(mincost[nx+ny*W][nstate] > data.cost+1){
	mincost[nx+ny*W][nstate] = data.cost+1;
	Q.push(Data(nx+ny*W,nstate,data.cost+1));
      }
    }
  }
  cout << -1 << endl;
}

int main(){
  while(cin >> W >> H,W|H){
    int idx = 0;
    rep(i,30)Index[i] = IINF;
    rep(y,H)rep(x,W){
      cin >> G[x+y*W];
      if(G[x+y*W] == '@')sp = x + y * W;
      if('a' <= G[x+y*W] && G[x+y*W] <= 'z')if(Index[G[x+y*W]-'a'] == IINF)Index[G[x+y*W]-'a'] = idx++;
    }
    compute();
  }
  return 0;
}

Measured memory_bytes: 3224
/*
      author : nishi5451
      created: 12.08.2020 15:21:28
*/

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


int main(){
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << endl;
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/02  Problem: 010_agc_b / Link: https://agc010.contest.atcoder.jp/tasks/agc010_b?lang=en  ----- */
/* ------問題------

N 個の箱が円環状に並んでおり、i 番目の箱には Ai 個の石が入っています。
以下の操作を繰り返して、全ての石を取り除くことができるか判定してください。
箱を一か所選ぶ。それを i 番目としたとき、1 から N の各 j に対して、i+j 番目の箱から石をちょうど j 個取り除く。
ただし、N+k 番目と表される箱は k 番目の箱と同一視するものとする。
各操作において、取り除きたい個数の石がない箱があるときは、その操作を行えないことに注意してください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VI a(2 * N);
	LL sum = 0;
	FOR(i, 0, N) {
		cin >> a[i];
		a[i + N] = a[i];
		sum += a[i];
	}

	ans = 1;
	LL k = sum / (N*(N + 1) / 2);

	if (k*(N*(N + 1) / 2) != sum)ans = 0;

	FOR(i, 0, N) {
		int diff = a[i + 1] - a[i];
		if (k - diff < 0 || ((k - diff) % N != 0))ans = 0;
	}
	if (ans) {
		cout << "YES" << endl;
	}
	else
		cout << "NO" << "\n";

	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    cin >> N;
    vector<ll> A(N), pl(N + 1), xo(N + 1);
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) {
        pl[i + 1] = pl[i] + A[i];
        xo[i + 1] = xo[i] ^ A[i];
    }

    ll ans = 0;
    rep(i, 1, N + 1) {
        int ng = -1;
        int ok = i - 1;

        while (ok - ng > 1) {
            int mid = (ok + ng) / 2;
            if (pl[i] - pl[mid] == (xo[i] ^ xo[mid])) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        ans += i - ok;
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  int n;
  long long d;
  cin >> n >> d;
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    
    if (x * x + y * y <= d * d) {
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main()
{
  int n;
  cin >> n;
  n %= 10;
  if (n == 3) cout << "bon" << endl;
  else if (n == 0 || n == 1 || n == 6 || n == 8) {
    cout << "pon" << endl;
  } else cout << "hon" << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
int main(void) {
    int i;
    vector<int> a;
    for(i=0; i<3; i++) {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    sort(a.begin(), a.end());
    int cnt=0;
    for(i=0; i<2; i++) {
        while(a[i]+2<=a[2]) {
            a[i]+=2;
            cnt++;
        }
    }
    
    if(a[0]==a[1]&&a[1]==a[2]);
    else if(a[0]==a[1])
        cnt++;
    else if(a[0]==a[2] || a[1]==a[2])
        cnt+=2;
    cout << cnt << endl;
}


Measured memory_bytes: 256
/*
  AOJ 2163
  Title:
  @kankichi573
*/
#include <stdio.h>
#include <string.h>

int H,W,T;
int room[20][21];

void search(int *y,int *x)
{
  int i,j;

  for(i=0;i<H;i++)
    for(j=0;j<W;j++)
      if(room[i][j]==0)
	{
	  *y=i;*x=j;
	  return;
	}
}

int check_cross(int y, int x)
{
  int c[4],i,j,s;

  if(y<0||x<0)
    return(0);

  for(i=0;i<2;i++)
    for(j=0;j<2;j++)
      c[i*2+j]=room[y+i][x+j];
  
  for(i=s=0;i<4;i++)
    for(j=0;j<4;j++)
      s += ((c[i]!=c[j])?1:0);

  return((s==12)?1:0);
}

void dump()
{
  int i,j;

  for(i=0;i<H;i++)
    {
      for(j=0;j<W;j++)
	{
	  printf ("%02d|",room[i][j]);
	}
      printf("\n");
    }
  printf("-------\n");
}


int solve(int tatami)
{
  int ret,y,x;

  if(tatami==T)
    {
      //dump();
    return(1);
    }
  search(&y,&x);
  //printf("EMPyx=%d %d\n",y,x);
  ret=0;
  if(x<W-1 && room[y][x+1]==0)
    {
      room[y][x]=room[y][x+1]=tatami+1;
      if(!check_cross(y-1,x+1))
	ret += solve(tatami+1);
      room[y][x]=room[y][x+1]=0;
    }
  if(y<H-1 && room[y+1][x]==0)
    {
      room[y][x]=room[y+1][x]=tatami+1;
      if(!check_cross(y-1,x))
	ret += solve(tatami+1);
      room[y][x]=room[y+1][x]=0;
    }
  return(ret);
}
main()
{
  int ret,s;
  
  while(scanf("%d %d",&H,&W)  && (H||W))
    {
      if(((s=H*W) & 1)==0)
	{
	  T=s/2;
	  memset(room,0,sizeof(room));
	  ret=solve(0);
	}
      else
	ret=0;
      printf("%d\n",ret);
    }
  return(0);
}

Measured memory_bytes: 616
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

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

    static class DDivGame {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.readLong();

            if (n == 1)
                System.out.println(0);

            else {
                long tmp = n;
                long ans = 0;
                for (long i = 2; i * i <= n; i++) {
                    long pow = i;
                    while (tmp % pow == 0) {
                        tmp /= pow;
                        ans++;
                        pow *= i;
                    }
                    while (tmp % i == 0) {
                        tmp /= i;
                    }
                }

                System.out.println(tmp > 1 ? ++ans : ans);
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 32476
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <list>
#define pie 3.141592653589793
#define si(a) scanf("%d",&a)
#define ss(a) scanf("%s",a)
#define sl(a) scanf("%lld",&a)
#define pi(a) printf("%d",a)
#define pl(a) printf("%lld",a)
#define ps(a) printf("%s",a)
#define ll long long
using namespace std;
int main()
{
  ll n,k;
  cin >> n >> k;
  ll ans=1;
  while(true){
    if(n<=0)
      break;
    ll diff = ans*2-ans;
    if(diff>k)
      ans+=k;
    else
      ans*=2;
    n--;
  }
  pl(ans);
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define rep(i, n) for(int i = 0; i < n; i++)
#define repx(i, a, n) for(int i = a; i < n; i++)
#define loop while(1)
#define lli long long int
#define aryout(ary) rep(i, ary.size()) cout << ary[i] << (i < ary.size() - 1 ? " " : "\n");
#define arysort(v) sort(v.begin(), v.end()
#define aryreverse(v) reverse(v.begin(),v.end())
#define arysum(v) accumulate(v.begin(), v.end(), 0)

#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <utility>
#include <set>

using namespace std;

int main() {

  int x;
  cin >> x;

  int tmp1 = x / 100;
  int tmp2 = x % 100;

  int tmp = 5;
  int cnt = 0;

  while (tmp >= 1 && tmp2 > 0) {
    cnt += tmp2 / tmp;
    tmp2 = tmp2 - tmp2 / tmp * tmp;
    tmp -= 1;
  }

  cout << (tmp1 >= cnt ? 1 : 0) << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/////brack == 1, white == 0
int h, w, k;
int mt[6][6];
int rep = 0;


bool solve(int row, int line){
    int ans = false;
    int cnt = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if(row & (1<<i))continue;
            if(line & (1<<j))continue;
            else if(mt[i][j] == 1)cnt++;
        }
    }
    if(cnt == k)ans = true;
    
    return ans;
}

int main() {
    cin >> h >> w;
    cin >> k;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            char c;
            cin >> c;
            if(c == '#'){
                mt[i][j] = 1;
            }    
            else mt[i][j] = 0;
        } 
    }

    int hm = pow(2, h);
    int wm = pow(2, w);
    int ret = 0;

    for (int i = 0; i < hm; i++)
    {
        for (int j = 0; j < wm; j++)
        {
            if(solve(i, j))ret++;
        }
        
    }

    // for (int i = 0; i < h; i++)
    // {
    //     for (int j = 0; j < w; j++)
    //     {
    //         cout << mt[i][j] << " ";
    //     } 
    //     cout << endl;
    // }

    

    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 4092
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main(){
    int N;
    cin >> N;
    map<string, int> m;
    int M = 1;
    for(int i=0; i<N; i++){
        string s;
        cin >> s;
        if(!m.count(s)) m.insert({s, 1});
        else {
            m.at(s)++;
            M = max(M, m.at(s));
        }
    }
    auto itr = m.begin();
    while(itr != m.end()){
        if(itr->second == M) cout << itr -> first << endl;
        ++itr;
    }
    return 0;
}

Measured memory_bytes: 25216
#include <stdio.h>

int main(void)
{
	int W, H, x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if(x <= 0 || y <= 0 || x+r > W || r+y > H){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
}

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


#define INF 1000000000000


signed main()
 {
int s,w;
cin>>s>>w;
if(s>w){cout<<"safe";}
else cout<<"unsafe";
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    bool can = false;
    for (int i = 1; i <= b; i++) {
        if ((a * i) % b == c) can = true;
    }
    cout << ((can) ? "YES" : "NO") << '\n';
}


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

int ans,l[200];

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n*2;i++)
		cin>>l[i];
	sort(l,l+n*2);
	for(int i=0;i<n;i++)
		ans+=l[i+i];
	cout<<ans<<endl;
}


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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)
#define pii pair<int,int>
#define mp make_pair

const ll INF=1e9+7;
int n,m;
int main(){
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n>>m;
	for(int i=-10000;i<=10000;i++){
		if(abs(i-m)<n){
			cout<<i<<' ';
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> mlt(n, 0);
  for (int i = 0; i < 2 * m; i++) {
    int tmp;
    cin >> tmp;
    tmp--;
    mlt[tmp]++;
  }
  bool flag = false;
  for (int i = 0; i < n; i++) {
    if (mlt[i] & 1) {
      flag = true;
      break;
    }
  }
  if (!flag) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
  return 0;
}

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

char ope[4];
string a;
int flag=0;
void enz(int i,int sum){
    
    //printf("i=%d\n",i);
    //printf("sum=%d\n",sum);
    if(i==4){
        if(sum==7 && flag==0){
            cout<<a[0];
            for(int j=1;j<=3;j++){
                cout<<ope[j]<<a[j];
            }
            cout<<"=7"<<endl;
            flag=1;
            return;
        }
        else return;
    }
    ope[i]='+';
    enz(i+1,sum+a[i]-'0');
    //sum-=(a[i]-'0');
    //printf("sumback=%d,i=%d\n",sum,i);
    ope[i]='-';
    enz(i+1,sum-(a[i]-'0'));
}

    

int main() {
    cin>>a;
    //for(int i=0;i<4;i++)cout<<a[i];
    //cout<<a[0]<<endl;
    int sum=a[0]-'0';
    enz(1,sum);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  int64_t P = 2;
  int64_t cnt = vec[0]-1;
  for(int i=1; i<N; i++){
    if(vec[i] == P){
      P++;
    }
    cnt += (vec[i]-1)/P;
    //cout << cnt << endl;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            string s = Console.ReadLine();
            int A = (int)s[0]-48;
            int B = (int)s[1]-48;
            int C = (int)s[2]-48;
            int D = (int)s[3]-48;
            if(A+B+C+D==7)Console.WriteLine("{0}+{1}+{2}+{3}=7",A,B,C,D);
            else if(A-B+C+D==7)Console.WriteLine("{0}-{1}+{2}+{3}=7",A,B,C,D);
            else if(A+B-C+D==7)Console.WriteLine("{0}+{1}-{2}+{3}=7",A,B,C,D);
            else if(A+B+C-D==7)Console.WriteLine("{0}+{1}+{2}-{3}=7",A,B,C,D);
            else if(A-B-C+D==7)Console.WriteLine("{0}-{1}-{2}+{3}=7",A,B,C,D);
            else if(A-B+C-D==7)Console.WriteLine("{0}-{1}+{2}-{3}=7",A,B,C,D);
            else if(A+B-C-D==7)Console.WriteLine("{0}+{1}-{2}-{3}=7",A,B,C,D);
            else if(A-B-C-D==7)Console.WriteLine("{0}-{1}-{2}-{3}=7",A,B,C,D);
        }
    } 
}

Measured memory_bytes: 13268
#include"bits/stdc++.h"
using namespace std;

int main(){
    long long k, a, b;
    cin >> k >> a >> b;
    long long bisq = 1;
    long long coin = 0;
    if(a >= b-1 || k <= a){
        bisq += k;
    }
    else{
        /*
        long long times = (k+1) / (a+2);
        long long left = (k+1) % (a+2);
        bisq = (b-a) * times + left;
        cout << times << endl;
        cout << b-a << endl;
        */

        while(k > 0){
            if(coin > 0){
                bisq += b;
                coin--;
            }
            else if(bisq >= a && k > 1){
                bisq -= a;
                coin++;
            }
            else{
                bisq++;
            }
            k--;
        }

    }
    cout << bisq << endl;
}

Measured memory_bytes: 384
// ConsoleApplication95.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

// ConsoleApplication94.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<cmath>
using namespace std;
long long gcd(long long a, long long b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
long long exgcd(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1, y = 0;
		return a;
	}
	long long d = exgcd(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int main()
{
	double a;
	cin >> a;
	if (a / 2 - floor(a / 2) > 0.1)
	{
		a = floor(a / 2)+1;
	}
	else
	{
		a = a / 2;
	}
	cout << fixed << setprecision(0) << a << endl;

}


Measured memory_bytes: 256
n, m, l = map(int, input().split())
A, B = [], []
C = [[0 for _ in range(l)] for _ in range(n)]
for _ in range(n):
    A.append([int(x) for x in input().split()])
for _ in range(m):
    B.append([int(x) for x in input().split()])
for i in range(n):
    for j in range(l):
        C[i][j] = 0
        for x in range(m):
            C[i][j] += A[i][x] * B[x][j]
for i in C:
    print(*i)

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
#define MAX 2000000
#define INFTY (1<<30)

int A[MAX], H;

int parent(int i) { return i/2; }
int left(int i) { return i*2; }
int right(int i) { return i*2+1; }

void maxHeapify(int i) {
  int l = left(i);
  int r = right(i);
  int largest;

  if (l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if (r <= H && A[r] > A[largest]) largest = r;

  if (largest != i) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

// void buildMaxHeap(int A[], int n) {
//   for(int i = n/2; i > 0; i --) {
//     maxHeapify(A, i, n);
//   }
// }

void increaseKey(int i, int key) {
  // if (key < A[i]) return;
  A[i] = key;

  // 親の方が小さい間
  while (i > 1 && A[i/2] < A[i]) {
    swap(A[i], A[i/2]);
    i = i/2;
  }
}

void insert(int key) {
  H ++;
  // A[H] = -INFTY;
  increaseKey(H, key);
}

int extract() {
  int maxv;
  if (H < 1) return -INFTY;
  maxv = A[1];

  // 最後の値を根に移動
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}


int main() {
  int key;
  string cmd;
  while(true) {
    cin >> cmd;
    if (cmd == "end") break;
    else if (cmd == "insert") {
      cin >> key;
      insert(key);
    } else if (cmd == "extract") {
      cout << extract() << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 6932
n = int(input())
s = list(input())
ans = 0
for i in range(1, n):
    x = s[:i]
    y = s[i:]
    temp = 0
    for ch in range(26):
        if chr(ch + 97) in x and chr(ch + 97) in y:
            temp += 1
    ans = max(ans, temp)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100010; //check the limits, dummy

vector<vi> graph;
ll fact[MX];
ll K;
ll ans = 1;

void dfs(int v, int p) {
    int countAvail = K - 1; if (p != -1) countAvail--;
    F0R(i, sz(graph[v])) {
        int nxt = graph[v][i];
        if (nxt == p) continue;
        if (countAvail <= 0) {
            ans = 0;
            return;
        }
        ans = ans * countAvail;
        countAvail--;
        ans = ans % MOD;
        dfs(nxt, v);
    }
}

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

    fact[0] = 1;
    FOR(i, 1, MX) {
        fact[i] = fact[i-1] * i;
        fact[i] = fact[i] % MOD;
    }

    int N; cin >> N; F0R(i, N) {
        vi blank; graph.pb(blank);
    }

    cin >> K;

    F0R(i, N-1) {
        int A, B; cin >> A >> B; A--; B--;
        graph[A].pb(B); graph[B].pb(A);
    }

    ans = K;

    dfs(0, -1);

    cout << ans << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

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

int main(){
  string s;
  cin >> s;
  string ans = "Yes";
  if(s=="AAA" or s == "BBB") ans = "No";
  cout << ans;
  
  
  return 0;
}

Measured memory_bytes: 3604
class SkewHeapNode
  attr_accessor :element, :left, :right, :parent
  def initialize(element, left = nil, right = nil)
    @element = element
    @left = left
    @right = right  
    @parent = nil
  end
end

class SkewHeap
  attr_reader :size, :root
  def initialize
    @root = nil
    @size = 0
    @position = {}
    @id = 0
  end

  def add(element)
    @id += 1
    @size += 1
    node = SkewHeapNode.new(element)
    @position[@id] = node
    @root = merge(@root, node)
    @id
  end

  def top
    @root ? @root.element : nil
  end

  def pop
    return nil if @size==0
    @size -= 1
    element = @root.element
    @root = merge(@root.left, @root.right)
    @root.parent = nil if @root
    element
  end

  def change_key(target_id, new_element)
    node = @position[target_id]
    return nil unless node
    if heap_order_property_satisfied?(node, new_element)
      node.element = new_element
    else
      temp = merge(node.left, node.right)
      temp.parent = node.parent if temp
      if node.parent
        if node.parent.left == node
          node.parent.left = temp
        else
          node.parent.right = temp
        end
      else
        @root = temp
      end
      node.element = new_element
      node.left = nil
      node.right = nil
      node.parent = nil

      @root = merge(@root, node)
      @root.parent = nil if @root
    end
    self
  end

  def empty?
    @size == 0
  end

  alias :push :add
  alias :<< :add
  alias :length :size

private
  def merge(p, q)
    return p if q.nil?
    return q if p.nil?
    p, q = q, p if p.element > q.element
    q.parent = p
    p.right = merge(p.right, q)
    p.right, p.left = p.left, p.right
    p
  end

  def heap_order_property_satisfied?(node, new_element)
    if node.parent
      return false if node.parent.element > new_element
    end
    if node.left
      return false if node.left.element < new_element
    end
    if node.right
      return false if node.right.element < new_element
    end
    true
  end
end

class Sushi
  attr_accessor :t, :d
  def initialize(t,d)
    @t,@d=t,d
  end

  def <(other)
    @d<other.d
  end

  def >(other)
    @d>other.d
  end
end

n,k=gets.split.map(&:to_i)
sushi=n.times.map{gets.split.map(&:to_i)}.sort_by(&:last).
  reverse.map{|arg|Sushi.new(*arg)}
heap=SkewHeap.new
tops=[]

topping_num=0
topping_flag=Array.new(n+1)
total_deliciousness=0
k.times{|i|
  s=sushi[i]
  total_deliciousness+=s.d
  if topping_flag[s.t]
    heap << s
  else
    topping_flag[s.t]=true
    topping_num+=1
    tops << s
  end
}
ans=total_deliciousness+topping_num**2

k.upto(n-1){|i|
  break if heap.empty?
  s=sushi[i]
  next if topping_flag[s.t]
  topping_flag[s.t]=true
  topping_num+=1
  total_deliciousness+=s.d
  tops << s
  u=heap.pop
  total_deliciousness-=u.d
  satisfaction=total_deliciousness+topping_num**2
  ans=satisfaction if satisfaction>ans 
}

puts ans

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

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    i = 0
    while 1:
        if i == N:
            break
        # 単調非減少と単調非増加の列の長い方を採用Greedy
        a = i
        while a < N-1 and A[a] <= A[a+1]:
            a += 1
        b = i
        while b < N-1 and A[b] >= A[b+1]:
            b += 1
        i = max(a,b) + 1
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14224
#include<bits/stdc++.h>
typedef long long int lli;

using namespace std;

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
	int t=1;
	//cin>>t;
	while(t--){
		//logic_start
        int a,b,c;
        cin>>a>>b>>c;
        map<int,int> mp;
        mp[5]=2;
        mp[7]=1;
        if(mp[a])
            mp[a]--;
        if(mp[b])
            mp[b]--;
        if(mp[c])
            mp[c]--;
        if((!mp[5]) && (!mp[7]))
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
		//logic_end

	} 
}

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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

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;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.eb(x%10);x/=10;}reverse(all(res)); return res;}

void solve() {
  int x,y,z;
  cin>>x>>y>>z;
  cout<<z<<" "<<x<<" "<<y<<endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

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

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

int main(void) {
    string s;

    cin>>s;

    if(s=="SUN"){
        cout<<7<<endl;
    }
    if(s=="MON"){
        cout<<6<<endl;
    }
    if(s=="TUE"){
        cout<<5<<endl;
    }
    if(s=="WED"){
        cout<<4<<endl;
    }
    if(s=="THU"){
        cout<<3<<endl;
    }
    if(s=="FRI"){
        cout<<2<<endl;
    }
    if(s=="SAT"){
        cout<<1<<endl;
    }

}


Measured memory_bytes: 256
var cnt = 0;
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  let arr = lines.shift().split(' ').map(Number);
  mergeSort(arr, 0, n);
  console.log(cnt);
})();

function merge(arr, left, mid, right) {
  let L = arr.slice(left, mid);
  let R = arr.slice(mid, right);
  L.push(Infinity);
  R.push(Infinity);
  let i = 0;
  let j = 0;
  let t = 0;
  for (let k = left; k < right; k++) {
    if (L[i] < R[j]) {
      arr[k] = L[i++];
      cnt += t;
    } else {
      arr[k] = R[j++];
      t += 1;
    }
  }
}

function mergeSort(arr, left, right) {
  if (left + 1 < right) {
    let mid = Math.floor((left + right) / 2);
    mergeSort(arr, left, mid);
    mergeSort(arr, mid, right);
    merge(arr, left, mid, right);
  }
}



Measured memory_bytes: 45940
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#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 P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 1000010;
// cnt[i][0]->a_iの0の数
// cnt[i][1]->a_iの1の数
int cnt[60][2];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	rep(i, n) {
		rep(j, 60) {
			// bit演算
			// ビットa[i]にj番目のフラグが立っているかどうか
			cnt[j][(a[i] >> j) & 1]++;
		}
	}
	int ans = 0;
	for (int i = 59; i >= 0; i--) {
		ans = (ans * 2) % MOD;
		ans += cnt[i][0] * cnt[i][1] % MOD;
	}
	cout << ans % MOD << endl;
	return 0;
}


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

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    if(n == 1) {
        out(abs(a[0] - w));
        re0;
    }
    
    out(max(abs(a[n-2] - a[n-1]), abs(a[n-1] - w)));
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

bool fc(const vector<string> &a, const vector<string> &b, int si, int sj){
  rep(i, b.size()){
    rep(j, b.at(i).size()){
      if(a.at(i+si).at(j+sj) != b.at(i).at(j)) return false;
    }
  }
  return true;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  rep(i, n) cin >> a.at(i);
  vector<string> b(m);
  rep(i, m) cin >> b.at(i);
  rep(i, a.size()-b.size()+1){
    rep(j, a.at(i).size()-b.at(0).size()+1){
      if(fc(a, b, i, j) == true){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
      test_ans();
    }

    private static void test_mine(){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();

        int count = 0;
        if(s.charAt(1) == 'S'){
            if(s.charAt(0) == 'R' || s.charAt(2) == 'R')
                count = 1;
            else
                count = 0;
        }else{
            if(s.charAt(0) == 'R'){
                if(s.charAt(2) == 'R'){
                    count = 3;
                }else{
                    count = 2;
                }
            }else if(s.charAt(2) == 'R'){
                if(s.charAt(0) == 'R'){
                    count = 3;
                }else{
                    count = 2;
                }
            }else
                count = 1;
            }
        System.out.println(count);
    }

    private static void test_ans(){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        
        boolean p = s.charAt(0) == 'R';
        boolean q = s.charAt(1) == 'R';
        boolean r = s.charAt(2) == 'R';

        int count = 0;
        if(p && q && r)
            count = 3;
        else if((p && q) || (q && r))
            count = 2;
        else if(p || q || r)
            count = 1;
        else
            count = 0;

        System.out.println(count);
    }
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

ll solve(ll a, ll b) {
    if (a == b) return (a - 1) * 2; // １回目のa-1人, 2回目のa-1人がa*bよりスコアを小さくできる
    ll lim = a * b - 1;
    ll low = 1, high = 1LL << 31;
    while (low + 1 < high) {
        ll mid = (low + high) / 2;
        ll mul = (mid + 1) / 2 * (mid + 1 - (mid + 1) / 2);
        if (mul > lim) high = mid;
        else low = mid;
    }
    return low - 1;
}

int main() {
    int Q;
    cin >> Q;
    rep(i, Q) {
        ll a, b;
        cin >> a >> b;
        cout << solve(a, b) << endl;
    }
}


Measured memory_bytes: 256