akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n,m = [int(i) for i in readline().split()]
MOD = 10**9+7

#dp[i][j][k]
# iまで見て j個未確定、k点
dp = [[[0 for k in range(n*n+1)] for j in range(n+1)] for i in range(n+1)]

dp[0][0][0] = 1

for i in range(n):
    for j in range(i+1):
        for k in range(n*n):
            if k + 2*j >= n*n: continue
            dp[i+1][j+1][k+2*j] += dp[i][j][k]
            dp[i+1][j+1][k+2*j] %= MOD
            dp[i+1][j  ][k+2*j] += (2*j+1)*dp[i][j][k]
            dp[i+1][j  ][k+2*j] %= MOD
            dp[i+1][j-1][k+2*j] += j*j*dp[i][j][k]
            dp[i+1][j-1][k+2*j] %= MOD
    

ans = dp[-1][0][m]
print(ans)




Measured memory_bytes: 97756
#include <stdio.h>
#include <iostream>
#include <vector>
#include <map>

int main() {
  int A[3][3];
  std::map<int, bool> Amap;
  bool IsSelect[3][3];
  int N = 0;
  
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      std::cin >> A[i][j];
      Amap[A[i][j]] = false;
    }
  }
  std::cin >> N;
  
  for (int n = 0; n < N; ++n) {
    int b = 0;
    std::cin >> b;
    if (Amap.count(b) > 0) {
      Amap[b] = true;
    }
  }
  
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; ++j) {
      IsSelect[i][j] = Amap[A[i][j]];
    }
  }

  for (int i = 0; i < 3; ++i) {
    bool is_select = true;
    for (int j = 0; j < 3; ++j) {
      is_select &=IsSelect[i][j];
    }
    if (is_select) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }
  
  for (int j = 0; j < 3; ++j) {
    bool is_select = true;
    for (int i = 0; i < 3; ++i) {
      is_select &=IsSelect[i][j];
    }
    if (is_select) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }
  
  bool is_select_a = true;
  bool is_select_b = true;
  for (int i = 0; i < 3; ++i) {
    is_select_a &= IsSelect[i][i];
    is_select_b &= IsSelect[i][2 - i];
  }
  if (is_select_a || is_select_b) {
    std::cout << "Yes" << std::endl;
    return 0;
  }
  
  std::cout << "No" << std::endl;
  return 0;
}

Measured memory_bytes: 256
A = input()
x = 0
lens = len(A)
C = list(A)

for i in range(1, lens):
  if C[i-1] == C[i]:
    x += 1
    
    if C[i] == '0':  
      C[i] = '1'
    else:
      C[i] = '0'
  else:
    continue

print(x)

Measured memory_bytes: 3956
N = int(input())
A = list(map(int,input().split()))
from bisect import bisect

# 区間の和を高速に求めたいので累積和
S = [0]*N
S[0] = A[0]
for i in range(1,N):
    S[i] = S[i-1]+A[i]

Ans = 10**15
# 真ん中の分割位置を全探索
for i in range(2,N-1):
    # 前半部分,後半部分をそれぞれできるだけ均等になるように分割
    ax = S[i-1]/2
    ai = bisect(S,ax)
    if abs(S[ai-1]-ax) < abs(S[ai]-ax):
        ai -= 1
    bx = (S[N-1]+S[i-1])/2
    bi = bisect(S,bx)
    if abs(S[bi-1]-bx) < abs(S[bi]-bx):
        bi -= 1
    x1,x2,x3,x4 = S[ai],S[i-1]-S[ai],S[bi]-S[i-1],S[N-1]-S[bi]
    # 考慮した組み合わせで最小のものを記録
    Ans = min(Ans,max(x1,x2,x3,x4)-min(x1,x2,x3,x4))

print(Ans)

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

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    deque<char> A;
    rep(i, s.size()) {
        if (!A.empty() && A.back() == '(' && s[i] == ')')
            A.pop_back();
        else
            A.push_back(s[i]);
    }

    string left = "", right = "";
    while (!A.empty() && A.front() == ')') {
        left += '(';
        A.pop_front();
    }

    while (!A.empty() && A.back() == '(') {
        right += ')';
        A.pop_back();
    }

    string res = left + s + right;
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <deque>
#include <vector>

using namespace std;


int main() {
  string inputs;
  cin >> inputs;

  deque<int> q;
  typedef pair<int, int> pair_t;
  vector<pair_t> v;
  int local = 0;
  for (int i = 0; i < inputs.size(); ++i) {
    if (inputs.at(i) == '\\') {
      q.push_back(i);
    } else if (inputs.at(i) == '/' && !q.empty()) {
      int left = q.back();
      q.pop_back();
      int local = i - left;
      while (!v.empty() && left < v.back().first) {
        local += v.back().second;
        v.pop_back();
      }
      v.push_back(pair_t(left, local));
    }
  }

  int sum = 0;
  for (auto elem : v) {
    sum += elem.second;
  }
  cout << sum << endl;
  cout << v.size();
  for (auto elem : v) {
    cout << " " << elem.second;
  }
  cout << endl;
}

Measured memory_bytes: 1312
// Why I am so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int mod = (int)1e9 + 7;

int dp[105][105];

int rl[105];

int h[105];

int ans;

int n;

void addMod(int &a, int b, int m = mod) {
    a += b;

    if (m <= a) {
        a -= m;
    }
}

int binPow(int a, int b, int m = mod) {
    int ret = 1;

    for (; b; b >>= 1) {
        if (b & 1) {
            ret = (ret * 1ll * a) % mod;
        }

        a = (a * 1ll * a) % mod;
    }

    return ret;
}

void compress() {
    vector<int> vv;
    vv.pb(1);

    for (int i = 1; i <= n; ++i) {
        vv.pb(h[i]);
    }

    sort(all(vv));
    vv.resize(unique(all(vv)) - vv.begin());

    for (int i = 0; i < vv.size(); ++i) {
        rl[i + 1] = vv[i];
    }

    for (int i = 1; i <= n; ++i) {
        h[i] = upper_bound(all(vv), h[i]) - vv.begin();
    }
}

int f(int l, int r) {
    int ret = 0;

    addMod(ret, binPow(2, r + 1));
    addMod(ret, mod - binPow(2, l));

    return ret;
}
             
void solve() {                   
    scanf("%d", &n);

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

    compress();

    dp[1][0] = 2;

    for (int i = 1; i < h[1]; ++i) {
        int l = rl[h[1]] - rl[i + 1] + 1;
        int r = rl[h[1]] - rl[i];
        dp[1][i] = f(l, r);                                             
    }
    
    for (int i = 2; i <= n; ++i) {
        for (int j = h[i - 1]; j < h[i]; ++j) {
            int cur = dp[i - 1][0];

            int l = rl[h[i]] - rl[j + 1] + 1;
            int r = rl[h[i]] - rl[j];

            addMod(dp[i][j], cur * 1ll * f(l, r) % mod);
        }

        addMod(dp[i][0], dp[i - 1][0] * 2ll % mod);

        for (int j = 1; j < h[i - 1]; ++j) {
            if (j < h[i]) {
                int cur = dp[i - 1][j];

                if (h[i] > h[i - 1]) {
                    cur = (cur * 1ll * binPow(2, rl[h[i]] - rl[h[i - 1]])) % mod;
                }

                addMod(dp[i][j], cur);
            }
            else {
                addMod(dp[i][0], dp[i - 1][j] * 2ll % mod);
            }
        }
    }
    
    for (int i = 0; i < h[n]; ++i) {
        addMod(ans, dp[n][i]);    
    }

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

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

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

int main(){
    int N; cin >> N;
    int digit_0=N%10;
    int digit_1=N%100/10;
    int dogit_2=N/100;

    if(digit_0==7||digit_1==7||dogit_2==7){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3644
n=int(input())
s=input()
p1=["W","W"]
p2=["W","S"]
p3=["S","W"]
p4=["S","S"]
p=[p1,p2,p3,p4]
for i in range(4):
	for j in range(n-2):
		same=0
		if p[i][j+1]=="S" and s[j+1]=="o"\
		or p[i][j+1]=="W" and s[j+1]=="x":
			same=1
		if same and p[i][j]=="S" or not same and p[i][j]=="W":
			p[i].append("S")
		else:
			p[i].append("W")
	f=0
	same=0
	if p[i][-1]=="S" and s[-1]=="o"\
	or p[i][-1]=="W" and s[-1]=="x":
		same=1
	if same and p[i][-2]=="S" or not same and p[i][-2]=="W":
		if p[i][0]=="S":
			f=1
	else:
		if p[i][0]=="W":
			f=1
	if f==0:
		continue
	f=0
	same=0
	if p[i][0]=="S" and s[0]=="o"\
	or p[i][0]=="W" and s[0]=="x":
		same=1
	if same and p[i][-1]=="S" or not same and p[i][-1]=="W":
		if p[i][1]=="S":
			f=1
	else:
		if p[i][1]=="W":
			f=1
	if f:
		ans=""
		for x in p[i]:
			ans+=x
		print(ans)
		exit()
print(-1)

Measured memory_bytes: 6292
W, A, B = map(int, input().split())
if A <= B <= A + W or A <= B + W <= A + W or B <= A <= B + W or B <= A + W <= B + W:
    print('0')
    exit()
right_dis = max(0, abs(B - A + W))
left_dis = max(0, abs(A - B + W))
print(min(right_dis, left_dis))

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

#define long long ll
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
typedef pair<int,int>P;


int main(){
	
	int n,m;
	string s;
	
	cin>>s;
	for(int i=0;i<4;i++){
		cout<<s[i];
	}
	cout<<" ";
	for(int i=4;i<12;i++){
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
X, N = map(int, input().split())
if N == 0:
    print(X)

else:
    p = list(map(int, input().split()))
    abs_list = []
    re_list = []
    min = 1000
    min_index = 0

    for i in range(250):
        abs_list.append(-100+i)
    for j in p:
        abs_list.remove(j)
    for i in range(len(abs_list)):

        re_list.append(abs(abs_list[i] - X))
    for i in range(len(re_list)):
        if min > re_list[i]:
            min = re_list[i]
            min_index = i
    if re_list[min_index] > X:
        print(0)
    else:
        print(abs_list[min_index])


Measured memory_bytes: 9216
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

result = 0
0.upto a do |i|
  0.upto b do |j|
    0.upto c do |k|
      result += 1 if (500 * i + 100 * j + 50 * k) == x
    end
  end
end

puts result


Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  while(true){
    vector<string> s(1e5);
    int l;
    cin>>s[0]>>l;
    if(!l)break;
    for(int j=0;j<1e5;j++){
      bool f=false;
      vector<int> a(l,0);
      vector<int> b(l,0);
      for(int i=0;i<s[j].size();i++){
        a[i]=s[j][i]-'0';
      }
      b=a;
      sort(a.begin(),a.end(),greater<int>());
      sort(b.begin(),b.end());
      int na=0;
      int nb=0;
      for(int i=0;i<l;i++){
        na*=10;
        na+=a[i];
        nb*=10;
        nb+=b[i];
      }
      s[j+1]=to_string(na-nb);
      for(int i=0;i<=j;i++){
        if(s[i]==s[j+1]){
          cout<<i<<" "<<s[i]<<" "<<j-i+1<<endl;
          f=true;
          break;
        }
      }
      if(f)break;
    }
  }
}



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

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var r = int.Parse(line[0]);
            var t = int.Parse(line[1]);
            if (r % 100 ==0 && t % 30 ==0)
            {
                Console.WriteLine(GetPoint(r, t));
                goto nextloop;
            }
            if ( r % 100 ==0 && t% 30 != 0)
            {
                var ans1 = GetPoint(r, (t / 30 ) * 30);
                var ans2 = GetPoint(r, (t / 30 + 1) * 30);
                Console.WriteLine("{0} {1}", ans1, ans2);
                goto nextloop;
            }
            if (r % 100 != 0 && t % 30 == 0)
            {
                var ans1 = GetPoint(r / 100  * 100, t);
                var ans2 = GetPoint((r / 100 + 1) * 100, t);
        Console.WriteLine("{0} {1}", ans1, ans2);
                goto nextloop;
            }
            if (r % 100 != 0 && t % 30 != 0)
            {
                var anslist = new List<int>();
                anslist.Add(GetPoint((r / 100 + 1) * 100, (t / 30) * 30));
                anslist.Add(GetPoint(r / 100 * 100, (t / 30 + 1) * 30));
                anslist.Add(GetPoint(r / 100 * 100, (t / 30) * 30));
                anslist.Add(GetPoint((r / 100 + 1) * 100, (t / 30 + 1) * 30));
                anslist.Sort();
                for (int j = 0; j < 4; j++)
                {
                    Console.Write(anslist[j]);
                    if (j == 3) Console.WriteLine();
                    else Console.Write(" ");
                }
            }
                nextloop:;
        }
    }
    public static int GetPoint (int r, int  t)
    {
        return r / 100 + t / 6;
    }
}

Measured memory_bytes: 9308
#include<bits/stdc++.h>
#define maxn 100100
using namespace std;
int fa[maxn];
long long a[maxn];
int ff(int x)
{
    vector<long long>t,u;
    while(x!=fa[x])
    {
        t.push_back(x);
        u.push_back(a[x]);
        x=fa[x];
    }
    long long s=0;
    for(int i=(int)t.size()-1;i>=0;i--)
    {
        s+=u[i];
        a[t[i]]=s;
        fa[t[i]]=x;
    }
    return x;
}
int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    int n,m,l,r,d;
    cin>>n>>m;
    for(int i=1;i<=n;i++)fa[i]=i;
    while(m--)
    {
        cin>>l>>r>>d;
        ff(l);
        ff(r);
        if(fa[l]==fa[r])
        {
            if(a[r]-a[l]==d)continue;
            else {cout<<"No"<<endl;exit(0);}
        }
        a[fa[r]]=a[l]-a[r]+d;
        fa[fa[r]]=fa[l];
    }
    cout<<"Yes"<<endl;
return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD ((ll)1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)
template<class F,class S>void add(map<F,S>&mp,F f,S s){if(mp.find(f)==mp.end())mp[f]=F();mp[f]+=s;}
 
constexpr int gcd(int a,int b){return b?gcd(b,a%b):a;}
constexpr int lcm(int a,int b){return a*b/gcd(a,b);}


int main(){
    string s;
    cin>>s;
    int n;
    cin>>n;
    vi a;
    for(auto &c:s){
        if(c!='a' && n>='z'+1-c){
            n-='z'+1-c;
            c='a';
        }
    }
    s.back()=(s.back()-'a'+n)%26+'a';
    cout<<s<<endl;
}


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

using namespace std;

int main() {
    long long n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >>e;
    
    long long m;
    m = min(a, min(b, min(c, min(d, e))));

    long long ans;
    ans = (n + m - 1)/m + 4;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
m = [['#']*(w+2)] + [['#']+list(input())+['#'] for _ in range(h)] + [['#']*(w+2)]

d = [(1, 0), (0, 1), (-1, 0), (0, -1)]
q = deque([(1, 1, 1)])
m[1][1] = '@'
ans = -1
while q:
    x, y, c = q.popleft()
    if x == h and y == w:
        ans = c
        break
    for dx, dy in d:
        nx, ny = x+dx, y+dy
        if m[nx][ny] == '.':
            q.append((nx, ny, c+1))
            m[nx][ny] = '@'

if ans != -1:
    for i in range(1, h+1):
        for j in range(1, w+1):
            if m[i][j] == '#':
                ans += 1
    ans = h*w - ans

print(ans)


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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector <ll> vll;
typedef vector <int> vii;
typedef vector <pll> vpll;
typedef vector <pii> vpii;
const int N = 1e5 + 5;
const int inf = 1e9 + 7;

void solve() {
	ll n, p = 26, cnt = 1;
	cin >> n;
	if (n <= 26) {
		cout << char('a' + n - 1) << endl;
		return;
	}
	while (p < n) {
		n -= p;
		p *= 26;
		cnt ++;
	}
	string ans = "";
	for (ll i = 1; i <= cnt; i ++) {
		int mod = (n - 1) % 26 + 1;
		ans += char(mod - 1 + 'a');
		n = (n + 25) / 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

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









Measured memory_bytes: 3628
#include <cstdio>
using namespace std;

const long long zero = 0LL;
long long lcm, gcd;
long long GCD(long long,long long);

int main(){
	long long a,b;
	while( scanf(" %lld%lld",&a,&b)!=EOF ){
		gcd = GCD(a,b);
		lcm = a/gcd*b;
		printf("%lld %lld\n",gcd,lcm);
	}
}

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

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
 
int n,k,r;
int m[100],b[100][100];
bool d[100][100],s[100];
int p,q;
 
int main(){
  cin >> n >> k;
  for(int i=0;i<k;i++){
    cin >> m[i];
    for(int j=0;j<m[i];j++)cin >> b[i][j];
  }
  for(int i=1;i<=n;i++){
    s[i] = false;
    for(int j=1;j<=n;j++)d[i][j] = false;
  }
 
  cin >> r;
  for(int i=0;i<r;i++){
    cin >> p >> q;
    d[p][q] = true;
    d[q][p] = true;
  }
 
  for(int i=0;i<k;i++){
    for(int j=0;j<m[i];j++){
      for(int l=0;l<m[i];l++){
	if(d[b[i][j]][b[i][l]])s[b[i][j]] = true;
      }
    }
  }
 
  int ans = 0;
  for(int i=1;i<=n;i++)
    if(s[i])ans++;
  cout << ans << endl;
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
using namespace std;
int s[55][2];
int c[55][2];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%d%d",&s[i][0],&s[i][1]);
    }
    for(int i=0;i<m;i++){
        scanf("%d%d",&c[i][0],&c[i][1]);
    }
    for(int i=0;i<n;i++){
        int x=s[i][0];
        int y=s[i][1];
        int mind = 0x3f3f3f3f;
        int ans = 0;
        for(int j=0;j<m;j++){
            int v = abs(x-c[j][0])+abs(y-c[j][1]);
            if(v<mind){
                mind = v;
                ans = j;
            }
        }
        printf("%d\n",ans+1);
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll A[300100];
    rep(i,0,n) cin >> A[i];
    int cnt[65];
    Fill(cnt, 0);
    rep(i,0,n){
        ll tmp = A[i];
        int j = 0;
        while(tmp > 0){
            cnt[j] += (tmp % 2);
            tmp /= 2;
            j++;
        }
    }

    ll ans = 0;
    rep(i,0,60){
        ll tmp = modpow(2,i,MOD);
        ans += (tmp * (n-cnt[i]) % MOD) * cnt[i] % MOD;
    }

    ans %= MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5944
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<string>
#include<set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<n; i++)
#define per(i, n) for(int i=n-1; i>=0; i--)
#define reps(i, n) for(int i=1; i<n; i++)
#define pers(i, n)  for(int i=n-1; i>=1; i--)

const int INF = 1001001001;

void solve(){
  int n, m; cin >> n >> m;
  vector<int> pro(n);
  int vote = 0;
  rep(i, n){
    cin >> pro[i];
    vote += pro[i];
  }
  int able = 0;
  rep(i, n){
    if(pro[i]>=vote/4.0/m){
      able++;
    }
  }
  cout << (able>=m?"Yes":"No") << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

// sqrt(n) までの素数を求める。1000014129 (31623 * 31623) まで対応
void create_primes(int n, bitset<31624> & primes) {
	primes.flip();

	int u_b = sqrt(n + 1);
	assert(u_b < 31624);

	{
		for (int j = 4; j <= u_b; j += 2) {
			primes.reset(j);
		}
	}
	for (int i = 3; i <= u_b; i += 2) {
		if (!primes.test(i)) continue;

		for (int j = i * 2; j <= u_b; j += i) {
			primes.reset(j);
		}
	}
}

struct FactorInfo {
	int v;
	int c;
};

bitset<31624> primes;
// n の素因数分解を行う。 
vector<FactorInfo> make_factors(int n)
{
	create_primes(n, primes);

	int v = n;
	int limit = sqrt(n + 1);

	vector<FactorInfo> ans;
	FOR_LE(i, 2, limit) {
		if (!primes.test(i)) continue;

		int count = 0;
		while (v % i == 0) {
			v /= i;
			count++;
		}

		if (count != 0) {
			ans.push_back({ i, count });
		}
	}


	if (v != 1) {
		ans.push_back({ v , 1 });
	}

	return ans;
}

int temp[500];

int is_ok(vector<int>& as, int k, int v)
{
	//cout << "v : " << v << endl;
	FOR_LT(i, 0, as.size()) {
		temp[i] = as[i] % v;
		//cout << i << " : " << temp[i] << endl;
	}
	sort(temp, temp + as.size());
	
	int sum = 0;
	int i_s = 0;
	int i_l = as.size() - 1;
	while (temp[i_s] == 0) i_s++;

	int r = 0;
	while (i_s < i_l) {
		r += temp[i_s];
		i_s++;

		//cout << i_s << " " << temp[i_s] << "  : " << i_l << " " << temp[i_l] << endl;

		while (v - temp[i_l] <= r) {
			int n_r = v - temp[i_l];
			r -= n_r;
			sum += n_r;
			i_l--;
		}
	}

	//cout << "det : " << sum << " " << k << endl;

	return (sum <= k);
}

int evaluate(vector<int>& as, vector<FactorInfo> factors, int k, int i, int v) {
	if (i == factors.size()) {
		return is_ok(as, k, v) ? v : -1;
	}

	int ans = -1;

	int vc = 1;
	FOR_LE(n, 0, factors[i].c) {
		int c_ans = evaluate(as, factors, k, i + 1, v * vc);
		ans = max(ans, c_ans);
		vc *= factors[i].v;
	}

	return ans;
}


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

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

	vector<int> as(n);
	int sum = 0;
	for (auto &a : as) {
		cin >> a;
		sum += a;
	}

	vector<FactorInfo> factors = make_factors(sum);

	int max_value = evaluate(as, factors, k, 0, 1);
	cout << max_value << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        int A, B, C;
        cin >> A >> B >> C;

        int ma = max(A, max(B, C));
        int s = A + B + C;

        int ans = 0;
        while (s % 3 != 0 || s < ma * 3)
        {
                s += 2;
                ans++;
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
using namespace std;
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;

int main() { 
    int A, B; cin >> A >> B;

    if(B==1) {
        cout << 0 << endl;
        return 0;

    }


    int C = B-A;
    if (C <= 0) {
        cout << 1 << endl;
    } else {
        cout << (int)(ceil(1.0*C/(A-1))) + 1 << endl;
    }


    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<string> s(n);
    rep(i,n)cin>>s[i];
    sort(s.begin(),s.end());
    int M = 0;
    int c = 0;
    string cs = "0";
    rep(i,n){
        if(cs==s[i]){c++;M=max(M,c);}
        else{c=1;M=max(M,c);cs=s[i];}
    }
    cs="0";
    rep(i,n){
        if(cs==s[i]){c++;}
        else{c=1;cs=s[i];}
        if(c==M)cout<<s[i]<<endl;
    }


    return 0;
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=2010;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,Max[N],Min[N],a[N];
inline int abs(int x){return x>0?x:-x;}
int main()
{
	file();
	read(n);
	read(a[0]),read(a[0]);
	For(i,1,n)read(a[i]);
	rFor(i,n,0)
	{
		Min[i]=inf;
		Max[i]=0;
		//printf("%d %d %d\n",i,Min[i],Max[i]);
		For(j,i+1,n)
		{
			if(j==n)
			{
				chkmin(Min[i],abs(a[j]-a[i]));
				chkmax(Max[i],abs(a[j]-a[i]));
			}
			else
			{
				chkmin(Min[i],Max[j]);
				chkmax(Max[i],Min[j]);
			}
			//printf("%d %d %d %d\n",j,Max[j],Min[j],abs(a[j]-a[i]));
		}
		//printf("%d %d %d\n",i,Min[i],Max[i]);
	}
	printf("%d\n",Max[0]);
	return 0;
}


Measured memory_bytes: 256
n,m,x=map(int,input().split())
ca=[list(map(int,input().split())) for _ in range(n)]


ans = float("inf")

for bit in range(1 << n):
    count = 0
    sum = [0]*m
    for i in range(n):
        if bit & (1 << i):
          for j in range(1,m+1):
            sum[j-1] += ca[i][j]
          count+=ca[i][0]
    for i in range(m):
      if sum[i]<x:
        break
      if i+1==m:
        ans=min(count,ans)
if ans==float("inf"):
  print(-1)
  exit()
print(ans)

Measured memory_bytes: 68536
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char c[] = str.toCharArray();
        int type2count = c.length;
        int n = sc.nextInt();
        
        ArrayDeque<Integer> deq = new ArrayDeque<>();
        for (int i = 0; i < c.length; i++) {
            deq.offerLast(c[i] - '0');
        }
        
        int muki = 0;
        while (n-- > 0) {
            int type = sc.nextInt();
            
            if (type == 1) {
                muki = 1 - muki;
            } else {
                int type2 = sc.nextInt();
                type2count++;
                String s = sc.next();
                char cc = s.charAt(0);
                if (type2 == 1) {
                    if (muki == 0) {
                        deq.offerFirst(cc - '0');
                    } else {
                        deq.offerLast(cc - '0');
                    }
                } else {
                    if (muki == 1) {
                        deq.offerFirst(cc - '0');
                    } else {
                        deq.offerLast(cc - '0');
                    }
                }
            }
        }
        
        while (type2count-- > 0) {
            if (muki == 0) {
                int i = deq.pollFirst();
                char ccc = (char)(i + '0');
                System.out.print(ccc);
            } else {
                int i = deq.pollLast();
                char ccc = (char)(i + '0');
                System.out.print(ccc);
            }
        }
    }
}


Measured memory_bytes: 158516
#include <algorithm>
#include <iostream>
using namespace std;
int n;
int l[222];
int main(){
  cin >> n;
  for(int i = 0; i < 2*n; i++){
    cin >> l[i];
  }
  sort(l,l+2*n);
  int sum = 0;
  for(int i = 0; i < 2*n; i+=2){
    sum += l[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

#define LL long long

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

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

int main() {
	int a, b;
	cin >> a >> b;
	for (int c = 0; c <= 1000; ++c) {
		double ta = c * 0.08;
		double tb = c * 0.10;
		int ia = int(ta);
		int ib = int(tb);
		if (ia == a && ib == b) {
			cout << c << endl;
			return 0;
		}
	}
	cout << (-1) << endl;
	// return 0;
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define all(c) (c).begin(), (c).end()
const int INF = 1e9 + 1;
const ll LINF = 1e18 + 1;
const ll MOD = 1e9 + 7;

ll solve() {
  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

  ll at = a1 * t1 + a2 * t2;
  ll bt = b1 * t1 + b2 * t2;

  if (a1 < b1 && at < bt) return 0;
  if (a1 > b1 && at > bt) return 0;

  ll diff = at - bt;
  if (diff == 0) return -1;

  ll ans = 1;
  if (a1 > b1) {
    swap(a1, b1), swap(a2, b2), swap(at, bt);
    diff = -diff;
  }
  // cout << (b1 - a1) * t1 << endl;
  // cout << diff << endl;
  // cout << (b1 - a1) * t1 / diff << endl;
  ans += (b1 - a1) * t1 / diff * 2;
  if ((b1 - a1) * t1 % diff == 0) --ans;
  return ans;
}

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

  ll ans = solve();
  if (ans == -1) {
    cout << "infinity" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


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

int main()
{
    int a,b,c;
    char s[5];
    scanf("%s",s);
    a=s[0]-'0';
    scanf("%s",s);
    b=s[0]-'0';
    scanf("%s",s);
    c=s[0]-'0';
    int x=a*100+b*10+c;
    if (x%4==0)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, M = MAP()
s = [LIST()[1:] for _ in range(M)]
p = LIST()
 
ans = 0
for x in product([0, 1], repeat=N):
	for i in range(M):
		cnt = 0
		for n in s[i]:
			if x[n-1] == 1:
				cnt += 1
		if cnt%2 != p[i]:
			break
	else:
		ans += 1

print(ans)

Measured memory_bytes: 5400
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


i64 n, m;

int main(){
	cin >> n >> m;
	
	printf("%.10f\n", (n+n%2)*50.0/m);
	
	return 0;
}

Measured memory_bytes: 256
#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(x) (x).begin(),(x).end()


int main(){
    int n; cin >> n;
    vector<char> s(n);
    string ans="Three";
    rep(i,n){
        cin >> s[i];
        if(s[i] == 'Y'){
            ans = "Four";
            break;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	
	int n, m;
	int a = 0;
	double p = -99999999999;
	double d;
	cin >> n >> m>>d;
	for (int i = 0; i < n; i++) {
		double r;
		cin >> r;
		r = m - r*0.006;
	
		if (abs(d - r) < abs(p)) {
			p = abs(d - r);
			a = i + 1;
		}
	}
	cout << a << endl;

	return 0;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int a, b;
  cin >> a >> b;
  if(a*b % 2 == 0){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
  system("pause");
}


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

int main() {
    int n;
    cin >> n;
    while(n >= 0) {
        if(n%7 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
        n -= 4;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
	using namespace std;
	#define xxx ios::sync_with_stdio(),cin.tie(0),cout.tie(0)
	#define rep(i,n) for(int i=0;i<n;i++)
	#define repeq(i,j,n) for(int i=j;i<n;i++)
	#define int long long
	int bp(int a, int b, int m) {
   		a %= m;
   		int res = 1;
    	while (b > 0) {
        	if (b & 1)
            	res = res * a % m;
       		a = a * a % m;
       	 	b >>= 1;
 	    }
    return res;
	}
	int max(int a, int b){
		return (a>b)?a:b;	
	}
	int csb( int n) 
{ 
    int count = 0; 
    while (n) { 
        count += n & 1; 
        n >>= 1; 
    } 
    return count; 
} 
	int solve(int x){
		int r=0;
		while(x>0){
			int t=csb(x);
			x%=t;
			r++;
		}
		return r;
	}
	string mkstr(int n,char c){
		string s;
		s+=c;
		if(n==1 || n==0) return s;
		string s1,s2;
		s1=mkstr(n/2,c);
		s2=mkstr(n/2,c);
		return s1+s2;
	}
	int fun(string s,int n,char c){
		if(n==1){
			if(s[0]==c) return 0;
			else return 1;
		}
		else if(n==0) return 0;
		string s1=s.substr(0,n/2);
		string s2=s.substr(n/2,n);
		int ans1=0,ans2=0;
		for(int i=0;i<n/2;i++){
			if(s1[i]!=c) ans1++;
			if(s2[i]!=c) ans2++;
		}
		ans1+=fun(s2,n/2,c+1);
		ans2+=fun(s1,n/2,c+1);
		return min(ans1,ans2);

	}
	// void dfs(int v,vector<int> visited,vector<vector<int>> adjd,vector<vector<int>> adjud) {
    	
 //    	visited[v] = 1;
 //    	for (int u : adjd[v]){
 //        	if (color[u] == 0){
 //        	    dfs(u);
 //        	}
 //    	}
    	

 //   	 	visited[v] = 2;
    	
	// }
	signed main(){
		int test=1;
		//cin>>test;
		while(test--){
			string s;
			cin>>s;
			string a="Sunny",b="Cloudy",c="Rainy";
			if(s[0]=='S') cout<<b<<endl;
			if(s[0]=='C') cout<<c<<endl;	
			if(s[0]=='R') cout<<a<<endl;

		}
		return 0;
	}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define MOD 10000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ull B=100000007;
const int INF=1e9;
int main(){
      int n,a[3];
      cin>>n;
      REP(i,n)cin>>a[i];
      sort(a,a+n);
      REP(i,a[0]){
            bool f=true;
            REP(j,n)if(a[j]%(i+1)!=0)f=false;
            if(f)cout<<i+1<<endl;
      }
}

Measured memory_bytes: 1176
// ---------- begin snipet ----------
pub trait MoOperator {
    type Value;
    type Answer;
    fn insert(&mut self, x: &Self::Value);
    fn delete(&mut self, x: &Self::Value);
    fn answer(&self) -> Self::Answer;
}

pub struct MoSolver<S: MoOperator> {
    array: Vec<S::Value>,
    query: Vec<(usize, usize)>,
}

impl<S: MoOperator> MoSolver<S> {
    fn new(array: Vec<S::Value>) -> Self {
        MoSolver {
            array: array,
            query: vec![],
        }
    }
    fn add(&mut self, l: usize, r: usize) {
        self.query.push((l, r));
    }
    fn solve_with_size(&mut self, state: &mut S, answer: &mut [S::Answer], batch: usize) {
        let size = self.array.len();
        let mut q = vec![vec![]; size / batch + 1];
        for (k, &(l, r)) in self.query.iter().enumerate() {
            q[l / batch].push((r, l, k));
        }
        let array = &self.array;
        let mut x = 0;
        let mut y = 0;
        for (i, mut q) in q.into_iter().enumerate() {
            q.sort_unstable_by_key(|p| p.0);
            if i % 2 == 1 {
                q.reverse();
            }
            for (r, l, k) in q {
                let min = std::cmp::min;
                for v in array[min(l, x)..x].iter().rev() {
                    state.insert(v);
                    x = l;
                }
                for v in array[min(r, y)..r].iter() {
                    state.insert(v);
                    y = r;
                }
                for v in array[min(l, x)..l].iter() {
                    state.delete(v);
                    x = l;
                }
                for v in array[min(r, y)..y].iter().rev() {
                    state.delete(v);
                    y = r;
                }
                answer[k] = state.answer();
            }
        }
    }
}
// ---------- end Mo algorithm ----------

struct State {
    cnt: Vec<u32>,
    ans: u32,
}

impl MoOperator for State {
    type Value = usize;
    type Answer = u32;
    fn insert(&mut self, x: &Self::Value) {
        let c = &mut self.cnt[*x];
        if *c == 0 {
            self.ans += 1;
        }
        *c += 1;
    }
    fn delete(&mut self, x: &Self::Value) {
        let c = &mut self.cnt[*x];
        if *c == 1 {
            self.ans -= 1;
        }
        *c -= 1;
    }
    fn answer(&self) -> Self::Answer {
        self.ans
    }
}

fn solve(c: &[usize], ask: &[(usize, usize)]) -> Vec<u32> {
    let mut solver = MoSolver::<State>::new(c.iter().cloned().collect());
    for &(l, r) in ask {
        solver.add(l, r);
    }
    let mut state = State {
        cnt: vec![0; c.len()],
        ans: 0,
    };
    let mut ans = vec![0; ask.len()];
    solver.solve_with_size(&mut state, &mut ans, 1024);
    ans
}

use proconio::*;
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        q: usize,
        c: [Usize1; n],
        ask: [(Usize1, usize); q],
    }
    let ans = solve(&c, &ask);
    for a in ans {
        println!("{}", a);
    }
}


Measured memory_bytes: 55672
#include<bits/stdc++.h>
#define mx 100005
using namespace std;

int n, m, a[mx], b[mx];
long long ans[mx], p[mx];

int find(int x){return (p[x] < 0 ? x : p[x] = find(p[x]));}
long long uni(int x, int y){
  x = find(x), y = find(y);
  if(x != y){
    long long res = p[x] * p[y];
    p[x] += p[y];
    p[y] = x;
    return res;
  }else return 0;
}

int main(){
  scanf("%d%d", &n, &m);
  for(int i = 0; i < m; i++) scanf("%d%d", a+i, b+i);
  fill(p+1, p+n+1, -1);
  ans[m-1] = (long long)n*(n-1)/2;
  for(int i = m-1; i > 0; i--) ans[i-1] = ans[i] - uni(a[i], b[i]);
  for(int i = 0; i < m; i++) printf("%lld\n", ans[i]);
}

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

using ll = long long;

int main() {
  ll K; cin >> K;
  int N = 50;
  cout << N << '\n';
  for (int i = 0; i < N; i++) {
    cout << (N+1) * (K / N + (i < K % N)) + (N-1) - K << " \n"[i+1==N];
  }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define MOD 1000000007
long long int ppow(long long int i, long long int j) {
	long long int res = 1LL;
	while (j) {
		if ((j & 1LL)) {
			res *= i;
			if (res >= MOD) {
				res %= MOD;
			}
		}
		j >>= 1;
		i *= i;
		if (i >= MOD) {
			i %= MOD;
		}
	}
	return res;
}
long long int gcd(long long int a, long long int b) {
	if (a > b) {
		swap(a, b);
	}
	while (a) {
		swap(a, b);
		a %= b;
	}
	return b;
}
long long int lcm(long long int a, long long int b) {
	return a / gcd(a, b)*b;
}

int main() {
	int a, b,n;
	cin >> n>>a >> b;
	cout << min(a, b) << " " << max(0, a + b - n) << endl;
	return 0;
}

Measured memory_bytes: 256
(defun read-n-num (n)
               (let ((result)) (dotimes (x n (nreverse result)) (push (read) result))))

(format t "~d~%" (let* ((v-n (read))
                (v-ai (read-n-num v-n))
                (need-hight (first v-ai)))
           (reduce #'+ (reduce
            (lambda (result v-a)
              (when (< need-hight v-a)
                (setf need-hight v-a))
              (cons (- need-hight v-a) result))
            v-ai :initial-value nil))
          ))


Measured memory_bytes: 79860
//tanku short phrase
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
//		int phrase_counter = 0;
//		int temp=0;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true) {
		int word_num = Integer.parseInt(br.readLine());
		if(word_num == 0) {return;}
		int[] sec = new int[word_num];

//		int flag = 0;
//		int setlength;
//		int count = 0;
//		int loc = 0;

		for(int i=0;i<word_num;i++) {
			sec[i] = br.readLine().length();
		}

		int set=0;

		int rui =0;
		for(int j=0;j<word_num;j++) {
//		count = j;
			if(set != 5) {
				set = 0;
				rui=0;
			}else {
				break;
			}
		for(int i=j;i<word_num;i++) {
			rui += sec[i];
			if(rui < 5) {
				continue;
			}
			if(set==0&&rui > 5) {
				break;
			}
			if(rui == 5) { set++; }
			if(rui < 12) {
				continue;
			}
			if(set==1&&rui > 12) {
				break;
			}
			if(rui == 12) { set++; }
			if(rui < 17) {
				continue;
			}
			if(set==2&&rui > 17) {
				break;
			}
			if(rui == 17) { set++; }
			if(rui < 24) {
				continue;
			}
			if(set==3&&rui > 24) {
				break;
			}
			if(rui == 24) { set++; }
			if(rui < 31) {
				continue;
			}
			if(set==4&&rui > 31) {
				break;
			}
			if(rui == 31) {
				set++;
			System.out.println(j+1);
			break;
			}
		}





		}

		}

	}

}



Measured memory_bytes: 24528
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
map < int, set < int > > f; 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, k;
	long long ans = 0, cur = 0; 
	cin >> n >> k;
	f[0].insert(0);
	for(int i = 1, a; i <= n; i++){
		cin >> a; 
		cur = (cur + a - 1) % k; 
		int er = i - k; 
		while(f[cur].size() && *f[cur].begin() <= er){
			f[cur].erase(f[cur].begin());
		}
		ans += f[cur].size();
		f[cur].insert(i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 28416
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define u64 uint64_t
#define ll long long
#define endl "\n"
#define PI acos(-1)
#define pi pair<ll,ll>
#define fi first
#define si second
#define mkp make_pair
#define pb push_back
#define clr(arr) memset(arr,0,sizeof(arr))
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
deque<ll>dq;
map<ll,ll>mp;
set<ll>st;
vector<ll>vt;
ll mod=1e9+7;
const int N=1e6+5;
ll arr[N];

int main()
{
    IOS;
    ll n,m,x,y,z,i,j,k,p,f=0,tc,cnt=0,sum=0,mul=1,mi=1e18,ma=-1e18,a,b,c,d,sz;
    string str;
    char ch;
    double db;
    //code
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(i=0;i<n-1;i++)
    {
        if(i==0)
        {
            if(arr[i+1]==arr[i])
            {
                vt.pb(arr[i]);
            }
        }
        else
        {
            if(arr[i]==arr[i+1]||arr[i]==arr[i-1])
                vt.pb(arr[i]);
        }
    }
    if(arr[n-1]==arr[n-2]&&n>1)
    {
        vt.pb(arr[n-1]);
    }
    sz=vt.size();
    if(sz<4||n<4)
    {
        cout<<0<<endl;
        return 0;
    }
    if(vt[sz-1]==vt[sz-4])
    cout<<vt[sz-1]*vt[sz-1]<<endl;
    else
    {
        cout<<vt[sz-1]*vt[sz-4]<<endl;
    }



    //code
    return 0;
}


Measured memory_bytes: 5032