akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define clr(x) memset((x), 0, sizeof(x))
#define pb push_back
#define mp make_pair
#define sz size()
#define x first
#define y second
#define forn(i, n) for(int i=0; i<(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)

typedef long double ld;

// Constants
const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-11;

// Types
typedef signed   long long i64;
typedef unsigned long long u64;
typedef pair < int, int > PII;

int n;
int a[110];
int k[110];

int main()
{
	cin >>n;
	forn(i,n)
	{
		cin >>a[i];
		k[a[i]]++;
	}
	sort(a,a+n);
	reverse(a,a+n);

	int M=a[0]/2+a[0]%2;
	for(int i=a[0]; i>M; i--)
	{
		if(k[i]<2)
		{
			cout <<"Impossible\n";
			return 0;
		}
	}
	if(k[M]!=1+a[0]%2)
	{
		cout <<"Impossible\n";
		return 0;
	}
	for(int i=0; i<M; i++)
		if(k[i]>0)
		{
			cout <<"Impossible\n";
			return 0;
		}
	cout <<"Possible\n";

	return 0;
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

#逆元テーブル
mod = 10 ** 9 + 7
N = 1000002
inv_t = [0]+[1]
for i in range(2, N):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]

n = int(input())
a = list(map(int, input().split()))
d = [0 for i in range(1000001)]
for ai in a:
    arr = factorization(ai)
    for i, n in arr:
        d[i] = max(d[i], n)

base = 1
for i, n in enumerate(d):
    base = base * i ** n % mod
ans = 0
for ai in a:
    ans = (ans + base * inv_t[ai]) % mod
print(ans)


Measured memory_bytes: 117772
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int n, x;

int main(){
    vector<pair<int, int>> v;
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> x;
        v.push_back(make_pair(x, i + 1));
    }

    sort(v.begin(), v.end());

    for(int i = 0; i < n; i++){
        cout << v[i].second << " ";
    }

}

Measured memory_bytes: 1780
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n - 1); i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &i : x)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

int a, b, c, d;
void solve() {
    cin >> a >> b >> c >> d;
    bool turn = true;
    while (a > 0 && c > 0) {
        if (turn) {
            c -= b;
        } else {
            a -= d;
        }
        turn = !turn;
    }
    if (a > 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 998244353, N = 3e3 + 211;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int n;
string s, t[] = {"AC", "WA", "TLE", "RE"};
map < string, int > cnt;

main () {
	cin >> n;
	while (n--) {
		cin >> s;
		++cnt[s];
	}
	
	for (int i = 0; i < 4; ++i) {
		cout << t[i] << " x " << cnt[t[i]] << endl;
	}
}
	
        	
//check for the constants

                                                                                   	



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

using namespace std;
signed main () {
    int n;
    cin >> n;
    vector <int> v;
    for (int i = 0; i < n; i++) {
        int x, y;cin >> x >> y;v.push_back(x); v.push_back(y);
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for (int i = 0; i < v.size(); i += 2) {
        ans += v[i];
    }
    cout << ans << '\n';
}


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

using namespace std;

int main()
{
    string a,b,s;
    int ca = 0;
    int cb = 0;
    cin >> s;

    for (size_t i = 0; i < s.length(); i++)
    {
        if(i % 2 == 0){
            a += '1';
            b += '0';
        }else{
            a += '0';
            b += '1';
        }
    }
    for (size_t i = 0; i < s.length(); i++)
    {
        if(s.substr(i,1) != a.substr(i,1)){
            ca++;
        }else{
            cb++;
        }
    }
    if(ca < cb){
        cout << ca << endl;
    }else{
        cout << cb << endl;
    }
    return 0;
}

Measured memory_bytes: 768
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    k,s = i_map()
    ans = 0
    for x in range(k+1):
        for y in range(k+1):
            z = s-x-y
            if 0<=z <=k:
                ans += 1
    print(ans)

if __name__=="__main__":
    main()


Measured memory_bytes: 9424
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define mrp(i,n) for(int i=n-1;i>=0;i--)
#define mrep(i,m,n) for(int i=m;i>=n;i--)
#define mlrp(i,n) for(long long i=n;i>=0;i--)
#define mlrep(i,m,n) for(long long i=m;i>=n;i--)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
ll abs(ll a,ll b){
    return(a>b?a-b:b-a);
}

int main(){
    int n;
    cin >> n;
    vi a(n);
    rp(i,n){
        cin >> a.at(i);
    }
    vi b(8);
    rp(i,8){
        b.at(i)=0;
    }
    int over=0,ans=0;
    rp(i,n){
        if(a.at(i)>=1&&a.at(i)<=399){
            b.at(0)++;
        }else if(a.at(i)>=400&&a.at(i)<=799){
            b.at(1)++;
        }else if(a.at(i)>=800&&a.at(i)<=1199){
            b.at(2)++;
        }else if(a.at(i)>=1200&&a.at(i)<=1599){
            b.at(3)++;
        }else if(a.at(i)>=1600&&a.at(i)<=1999){
            b.at(4)++;
        }else if(a.at(i)>=2000&&a.at(i)<=2399){
            b.at(5)++;
        }else if(a.at(i)>=2400&&a.at(i)<=2799){
            b.at(6)++;
        }else if(a.at(i)>=2800&&a.at(i)<=3199){
            b.at(7)++;
        }else if(a.at(i)>=3200&&a.at(i)<=4800){
            over++;
        }
    }
    rp(i,8){
        if(b.at(i)!=0){
        ans++;
        }
    }
    if(ans!=0){
        cout << ans << ' ' << ans + over << endl;
    }else{
        cout << 1 << ' ' << over << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] p = new int[n];
		for(i=0;i<n;i++) {
			p[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		Arrays.sort(p);
		p[n-1] /= 2;
		int ans;
		ans = Arrays.stream(p).sum();
		System.out.println(ans);
	}
}


Measured memory_bytes: 27092
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> > a[100005],adj;
int n,m;
int f[100005],con[100005];
bool vis[100005];
void dfs(int v){
	vis[v]=true;
	con[v]+=f[v];
	for(int i=0;i<a[v].size();i++){
		int q=a[v][i].first;
		if(!vis[q]){
			dfs(q);
			con[v]+=con[q];
			if(con[q]%2!=0)
				swap(adj[a[v][i].second].first,adj[a[v][i].second].second);
		}
	}
}
int main (){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
			f[u]++; 	
		a[u].push_back(make_pair(v,i));
		a[v].push_back(make_pair(u,i));	
		adj.push_back(make_pair(u,v));
	}
	if(m%2!=0){
		cout<<"-1";
		return 0;
	}
	dfs(1);
	for(int i=0;i<adj.size();i++){
		cout<<adj[i].first<<" "<<adj[i].second<<endl;
	}
}

Measured memory_bytes: 14836
<?php
$n = int();
echo $n * $n;


function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

// UnionFindを示す構造体
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
  int N, M, K; cin >> N >> M >> K;
  vector<int> ans(N + 1, 0);

  vector<int> A(M), B(M);
  REP(i, M) {
    cin >> A[i] >> B[i];
    ans[A[i]]++; ans[B[i]]++;
  }

  UnionFind uf(N + 1);
  REP(i, M) uf.merge(A[i], B[i]);

  vector<int> C(K), D(K);
  REP(i, K) {
    cin >> C[i] >> D[i];
    if(!uf.issame(C[i], D[i])) continue;
    ans[C[i]]++; ans[D[i]]++;
  }

  for(int i = 1; i <= N; ++i) {
    cout << uf.size(i) - ans[i] - 1 << " ";
  }
  cout << endl;
}

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

void printVector(vector<int> v) {
    for (auto x : v) {
        cout << x << ' ';
    }
    cout << '\n';
}

void printArray(ll A[], int size) {
    for (int i = 0; i <= size - 1; i++) cout << A[i] << ' ';
}

int main() {
    string s;
    cin >> s;
    int n;
    n = s.size();
    int tot = 0;
    for (int i = 0; i <= n - 1; i++) { 
        int now = 0;
        for (int j = i; j <= n - 1; j++) {
            if (s[j] == 'A' || s[j] == 'T' || s[j] == 'C' || s[j] == 'G') {
                now++;
            }
            else break;
        }
        tot = max(tot, now);
        now = 0;
    }
    cout << tot << '\n';
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
    static Set<Integer> getHigherSet(Set<Integer> set,int num) {
        Set higherSet = new TreeSet<>();

        for(int member: set) {
            if(member > num) {
                higherSet.add(member);
            }
        }
        return higherSet;

    }

    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char[] S = sc.next().toCharArray();
        long ans = 0;
        Set<Integer> Rlist = new TreeSet<>();
        Set<Integer> Glist = new TreeSet<>();
        Set<Integer> Blist = new TreeSet<>();

        for(int i=0;i<N;i++){
            if(S[i] == 'R'){
                Rlist.add(i);
            } else if(S[i] == 'G'){
                Glist.add(i);
            } else if(S[i] == 'B'){
                Blist.add(i);
            }
        }
        for(int Rnum: Rlist) {
            for(int Gnum: Glist) {
                ans += Blist.size();
                //R < G < B OK
                //B < G < R OK
                if(Blist.contains(2*Gnum - Rnum)){
                    ans--;
                }
                //R < B < G OK
                //G < B < R OK
                if((Gnum+Rnum) %2 == 0 && Blist.contains((Gnum + Rnum)/2)){
                    ans--;
                }
                //B < R < G OK
                //G < R < B OK
                if(Blist.contains(2*Rnum - Gnum)){
                    ans--;
                }
            }
        }

        System.out.println(ans);

    }

}









Measured memory_bytes: 55788
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    int t, n;
    cin >> t;

    while(cin >> n) {
        int result = n;
        int min1 = n * 6, min2 = n * 6;
        int max1 = 0, max2 = 0;
        bool has = false;

        for(int i = 1; i <= 4 * n; i++) {
            char c;
            cin >> c;
            if ( c == 'Y') {
                result += 1;
                if ( i <= 2 * n ) {
                    max1 = i;
                    if ( !has ) {
                        min1 = i;
                        has = true;
                    }
                } else {
                    max2 = i;
                    if ( !has ) {
                        min2 = i;
                        has = true;
                    }
                }
                if ( i % 2 == 0 && i != 2 * n && i != 4 * n) {
                    cin >> c;
                    i += 1;
                }
            }
            if ( i == 2 * n ) {
                has = false;
            }
        }

        if ( has )   result += 2;

        min2 -= 2 * n;
        if ( min1 % 2 == 1 && min1 != 1)    min1 -= 1;
        if ( min2 % 2 == 1 && min2 != 1)    min2 -= 1;
        if ( has && min1 <= min2 )  result -= 1;

        max2 -= 2 * n;
        if ( max1 % 2 == 1 && max1 != 1)    max1 -= 1;
        if ( max2 % 2 == 1 && max2 != 1)    max2 -= 1;
        if ( has && max1 >= max2 )  result -= 1;

        if ( has && max1 >= max2 && min1 <= min2 && max1 == min1 )  result += 1;


        cout << result << endl;
    }
     
    return 0;
}

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

namespace ARC073D {
    class Program {
        static void Main(string[] args) {
            int[] NWinput = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int N = NWinput[0];
            int W = NWinput[1];
            List<int>[] values = new List<int>[4];
            for (int i = 0; i < 4; i++) {
                values[i] = new List<int>();
            }
            int[] firstinput = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int weight = firstinput[0];
            values[0].Add(firstinput[1]);
            for (int i = 0; i < N - 1; i++) {
                int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                values[input[0] - weight].Add(input[1]);
            }
            for (int i = 0; i < 4; i++) {
                values[i].Sort();
                values[i].Reverse();
            }
            List<long>[] valuesums = new List<long>[4];
            for (int i = 0; i < 4; i++) {
                valuesums[i] = new List<long>();
                valuesums[i].Add(0);
                for (int j = 0; j < values[i].Count; j++) {
                    valuesums[i].Add(valuesums[i][j] + values[i][j]);
                }
            }
            long max = 0;
            int div = W / weight;
            for (int i = 0; i < Math.Min(valuesums[0].Count, div + 1); i++) {
                for (int j = 0; j < Math.Min(valuesums[1].Count, div + 1); j++) {
                    for (int k = 0; k < Math.Min(valuesums[2].Count, div + 1); k++) {
                        int l = Math.Min(valuesums[3].Count - 1, div - i - j - k);
                        if (l >= 0 && i * weight + j * (weight + 1) + k * (weight + 2) + l * (weight + 3) <= W) {
                            max = Math.Max(max, valuesums[0][i] + valuesums[1][j] + valuesums[2][k] + valuesums[3][l]);
                        }
                    }
                }
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N, W;
    cin >> N >> W;

    int dp[10010];
    fill_n(dp, W+1, -1);
    dp[0] = 0;

    for (int i = 0; i < N; i++)
    {
        int v, w;
        cin >> v >> w;
        for (int j = w; j < W+1; j++)
        {
           if(dp[j-w] != -1) dp[j] = max(dp[j-w] + v, dp[j]);
        }
    }

    cout << *max_element(dp, dp + W + 1) << endl;
}


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

int main() {
  int K, S;
  cin >> K >> S;
  int kotae = 0;
  for (int X = 0; X <= K; X++){
    int Y_plus_Z = S - X;
    for (int Y = 0; Y <= K; Y++){
      int Z = Y_plus_Z - Y;
      if ((0 <= Z) && (Z <= K)){
        kotae += 1;
      }
    }
  }
  cout << kotae << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

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

	double ans=v[0];

	for(int i=1;i<n;i++)
	{
		ans+=v[i];
		ans/=2;
	}

	cout << ans << endl;



}


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

int main()
{
   int a, b, c;
   cin >> a >> b >> c;
   if(a+b <= b+c && a+b <= c+a) cout << a+b << endl;
   else if(b+c <= c+a && b+c <= a+b) cout << b+c << endl;
   else if(c+a <= a+b && c+a <= b+c) cout << c+a << endl;

   return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int D = 0;
        int count = 1;

        for (int i = 0; i < N; i++) {
            int L = sc.nextInt();
            D += L;
            if (D <= X) {
                count++;
            }
        }

        System.out.println(count);
    }

}

Measured memory_bytes: 21844
N = gets.to_i
a = [0]
gets.split.each { |s| a << s.to_i }

ans = {}
m = 0
N.step(1, -1) do |i|
  sum = 0
  ite = 2 * i
  while ite <= N do
    sum = (sum == 1) ? 0 : 1 if ans[ite]
    ite += i
  end
  (ans[i] = 1) && (m += 1) if sum + a[i] == 1
end
puts m
puts ans.keys.join ' '

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

signed main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) {
        cout << "Yes\n";
    }else {
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

string s;
int i;

bool cat(){
	if (s[i++] != 'm') return false;
	if (s[i] == 'm' && !cat()) return false;
	if (s[i++] != 'e') return false;
	if (s[i] == 'm' && !cat()) return false;
	return s[i++] == 'w';
}

int main(){
	while (cin >> s){
		int n = s.size();
		s += "$$$";
		i = 0;
		cout << (cat()&&i==n ? "Cat" : "Rabbit") << endl;
	}

	return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, x[114], y[114], h[114];
	cin>>n;
	REP(i, n){
		cin>>x[i]>>y[i]>>h[i];
	}
	REP(c1, 101){
		REP(c2, 101){
			bool f=false, ok=true;
			int H=1<<30;
			REP(i, n){
				// Hが確定したら等式、不等式が成立するか調べる
				if(f){
					if(h[i]==0){
						if(H>abs(x[i]-c1)+abs(y[i]-c2)){
							ok=false;
							break;
						}
					}
					else if(H!=h[i]+abs(x[i]-c1)+abs(y[i]-c2)){
						ok=false;
						break;
					}
				}
				// Hが確定するまで
				else{
					// Hの範囲を狭める
					if(h[i]==0){
						H=min(H, abs(x[i]-c1)+abs(y[i]-c2));
					}
					// Hが狭めた範囲にない場合は不適
					else if(H<h[i]+abs(x[i]-c1)+abs(y[i]-c2)){
						ok=false;
						break;
					}
					// Hが確定
					else{
						H=h[i]+abs(x[i]-c1)+abs(y[i]-c2);
						f=true;
					}
				}
			}
			if(ok && H>=1){
				cout<<c1<<' '<<c2<<' '<<H<<'\n';
				return 0;
			}
		}
	}
	return 0;
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		2505

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//


//
int main(){
	string S;cin>>S;
	int N = S.size();

	ll ans = N;
	string pre = S.substr(0,1);
	REPS(i,1,N){
//		printf("%d : [%c]\n",i,S[i]);
//		cout << pre << endl;
//		cout << "\t"<<S.substr(i,1)<<" " <<S.substr(i,2)<< endl;
		if(pre.size()==1){
			if(pre == S.substr(i,1)){
				ans--;
				pre = S.substr(i,2);
				i++;
			}
			else pre = S.substr(i,1);
		}
		else{
			pre = S.substr(i,1);
		}
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 640
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

const MOD: usize = 1000000007;

#[fastout]
fn main() {
   input! {
      n: usize,
      m: usize,
      s: [usize; n],
      t: [usize; m]
   }

   let mut dp = vec![vec![1; m + 1]; n + 1];
   for i in 0..n {
      for j in 0..m {
         dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1];
         if s[i] != t[j] {
            dp[i + 1][j + 1] += MOD - dp[i][j];
         }
         dp[i + 1][j + 1] %= MOD;
      }
   }
   println!("{}", dp[n][m]);
}


Measured memory_bytes: 33408
// C - Strawberry Cakes

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

char s[300][300];
bool has_s[300];
int a[300][300];

int main() {
	int H, W, K;
	cin >> H >> W >> K;

	int first_has_s = -1;
	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			cin >> s[i][j];
			if (s[i][j] == '#') {
				has_s[i] = true;
				if (first_has_s == -1) first_has_s = i;
			}
		}
	}

	int cnt = 0;
	int num = 1;
	for (int j=0; j<W; j++) {
		if (s[0][j] == '#') {
			cnt++;
			if (cnt >= 2) num++;
		}

		a[0][j] = num;

	}

	for (int i=1; i<H; i++) {
		if (has_s[i] == false) {
			for (int j=0; j<W; j++) {
				a[i][j] = a[i-1][j];
			}
			continue;
		}

		cnt = 0;
		num++;
		for (int j=0; j<W; j++) {
			if (s[i][j] == '#') {
				cnt++;
				if (cnt >= 2) num++;
			}

			a[i][j] = num;
		}
	}

	if (has_s[0] == false) {
		for (int i=0; i<H; i++) {
			for (int j=0; j<W; j++) {
				a[i][j]--;
			}
		}

		for (int i=0; i<first_has_s; i++) {
			for (int j=0; j<W; j++) {
				a[i][j] = a[first_has_s][j];
			}
		}
	}

	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			if (j != 0) cout << " ";
			cout << a[i][j];
		}
		cout << endl;
	}

	return 0;
}

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

typedef long long W;

const W INF = 1LL << 50;

struct edge {
	int to;
	W cost;
};
typedef pair<W, int> P;
typedef vector<vector <edge > > Graph;

void dijkstra(int s, const Graph& G, vector<W>& d) {
	priority_queue< P, vector<P>, greater<P> > que;
	fill(d.begin(), d.end(), INF);
	d[s] = 0;
	que.push(P(0, s));
	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int C[5000];
int R[5000];

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

	int N, K;
	cin >> N >> K;
	for(int i = 0; i < N; i++) {
		cin >> C[i] >> R[i];
	}

	Graph G1(N);
	for(int i = 0; i < K; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		G1[a].push_back({ b, 1 });
		G1[b].push_back({ a, 1 });
	}

	Graph G2(N);
	vector<W> d(N);
	for(int i = 0; i < N; i++) {
		dijkstra(i, G1, d);
		for(int j = 0; j < N; j++) {
			if(d[j] <= R[i]) {
				G2[i].push_back({ j, C[i] });
			}
		}
	}

	dijkstra(0, G2, d);
	cout << d[N - 1] << endl;
}

Measured memory_bytes: 236484
#include <iostream>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef unsigned long long ull;
typedef signed long long sll;

map<int, int> mp;

int main()
{
    int N;
    cin >> N;
    
    for (int i = 0; i < N; i++)
    {
        int temp;
        cin >> temp;
        mp[temp]++;
    }
    
    int category = 0;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr)
    {
        category++;
    }
    
    printf("%d\n", (category % 2 == 0) ? category - 1 : category);
    
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;

int main(){
	double a,b,c,d,s,L,h;

	cin>>a>>b>>c;

	s=0.5*a*b*sin(c*M_PI/180);
	printf("%.10f\n",s);
	h=2*s/a;
	

	d=sqrt(a*a+b*b-2*a*b*cos(c*M_PI/180));

		L=a+b+d;
	printf("%.10f\n",L);		
	printf("%.10f\n",h);

}

Measured memory_bytes: 3364
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include <queue>
typedef long long int ll;
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EFOR(i,a,b) for (int i=(a);i<=(b);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);
    int ans=0;
    int W,a,b,c,d;

int main(){
    //sync_with_stdio(false);
    scanf("%d%d%d",&W,&a,&b);
    if( (a<=b&&b<=a+W) ||
        (b<=a&&a<=b+W) ||
        (b<=a+W&&a+W<=b+W)||
        (a<=b+W&&b+W<=a+W)){
            ans=0;
    }else{
            if(a>b+W){
                ans=a-(b+W);

            }
            if(a+W<b){
                ans=b-(a+W);
            }

            //ans=min(c,d);
        }

    cout<<ans<<endl;

    return 0;
}


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

using namespace std;

long long f(long long b, long long n){
    if (n < b)
        return n;
    return f(b, n / b) + n % b;
}

int main(){
    long long n, s;
    scanf("%lld %lld", &n, &s);
    if (n == s){
        printf("%lld\n", n + 1);
        return 0;
    }
    for (long long i = 2; i * i <= n; i++){
        if (f(i, n) == s){
            printf("%lld\n", i);
            return 0;
        }
    }
    long long ans = -1;
    for (long long i = sqrt(n * 1.0); i >= 1; i--){
        long long b = (n - s) / i + 1;
        if (b >= 2 && f(b, n) == s){
            printf("%lld\n", b);
            return 0;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
parent = [i for i in range(n + 1)]
rank = [0] * (n + 1)
s = set()

def find(x):
    if parent[x] == x:
        return x
    else:
        parent[x] = find(parent[x])
        return parent[x]

def union(x, y):
    x = find(x)
    y = find(y)
    if rank[x] < rank[y]:
        parent[x] = y
    else:
        parent[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

for i in range(m):
    x, y, z = map(int, input().split())
    union(x, y)
for i in range(1, n + 1):
    s.add(find(i))
print(len(s))

Measured memory_bytes: 73248
def resolve():
    '''
    code here
    '''
    N, M = [int(item) for item in input().split()]
    tube_to_s = [[int(item) for item in input().split()] for _ in range(M)]
    mods = [int(item) for item in input().split()]

    to_list = [[] for _ in range(M)]

    for i in range(M):
        k, *arg = tube_to_s[i]
        to_list[i] += arg
    
    res = 0
    for i in range(2**N):
        temp_s = format(i, '0{}b'.format(N))
        for j in range(M):
            temp_on_num = 0
            for item in to_list[j]:
                temp_on_num += int(temp_s[item-1])
            
            if temp_on_num % 2 == mods[j]:
                pass
            else:
                break
        else:
            res += 1

    print(res)


if __name__ == "__main__":
    resolve()


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

int main() {
  string s; cin >> s;
  if(s[0] == '9' || s[1] == '9'){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int N, T, Q;
int a[1000010], d[1000010];
int x[1000010];
int memo[1000010];

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

	cin >> N >> T >> Q;
	rep(i, N) cin >> a[i] >> d[i];
	rep(i, Q) cin >> x[i];
	Fill(memo, INF);

	rep(i, N - 1) {
		if(d[i] == 1 && d[i + 1] == 2) {
			int t = (a[i] + a[i + 1]) / 2;

			memo[i] = t;

			for(int j = i - 1; ((d[j] == 1) && (j >= 0)); j--) {
				memo[j] = t;
			}

			for(int j = i + 1; ((d[j] == 2) && (j < N)); j++) {
				memo[j] = t;
			}
		}
	}

	rep(i, Q) {
		int now = x[i] - 1;
		if(abs(a[now] - memo[now]) <= T) cout << memo[now] << endl;
		else if(d[now] == 1) cout << a[now] + T << endl;
		else cout << a[now] - T << endl;
	}
	return 0;
}



Measured memory_bytes: 12544
def main():
    N = int(input())
    d = dict()
    for _ in range(N):
        s = input()
        d[s] = d.get(s, 0) + 1
    M = int(input())
    for _ in range(M):
        t = input()
        d[t] = d.get(t, 0) - 1

    max_v = 0
    for t in d:
        max_v = max(max_v, d[t])
    return max_v

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;


int n;
long long a[10005];
long long b[10005];

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

  long long ta=0;
  long long tb=0;

  for(int i=0;i<n;i++){
    if(b[i] > a[i]){
      ta += (b[i]-a[i])/2LL;
    } else {
      tb += (a[i]-b[i]);
    }
  }

  //cout<<ta<<" "<<tb<<endl;

  if(ta >= tb) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n;
      cin>>n;
      vector<int>arr;
      int prev=-INF;
      for(int i=0;i<n;i++){
            int x;
            cin>>x;
            if(prev!=x)arr.pb(x);
            prev=x;
      }
      n=arr.size();
      if(n==0){
            cout<<"WA\n";
            return 0;
      }
      vector<int>next(300000,INF);
      vector<int>data(300000,INF);

      for(int i=n-1;i>=0;i--){
            next[i]=data[arr[i]];
            data[arr[i]]=i;
      }
      vector<int>dp(300000,0);
      int pre=1;
      for(int i=0;i<n;i++){
            if(i>0){
                  dp[i]+=dp[i-1];
                  dp[i]%=modulo;
            }
            else dp[i]=1;
            if(next[i]<dp.size()){
                  dp[next[i]]+=dp[i];
                  dp[next[i]]%=modulo;
            }
      }
      cout<<dp[n-1];
}


Measured memory_bytes: 8944
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))

d = defaultdict(int)

for i in range(n):
    g = min(8,a[i]//400)
    d[g] +=1

cnt=0
joker=0
for i in d.keys():
    if i != 8:
        cnt+=1
    else:
        joker=d[8]

ans_min = max(cnt,1)
ans_max = cnt+joker


print(ans_min,ans_max)

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    swap(a,b);
    swap(a,c);
    cout << a << " " << b << " " << c << endl;
    return 0;
}

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

int main(){
  ll n;
  cin >> n;
  map<ll,ll> s;
  map<ll,ll> t;
  vector<ll> m;
  for(ll i=1;i<=n;++i){
    ll a;
    cin >> a;
    s[i+a]++;
    if( s[i+a] == 1 ) m.push_back(i+a);
    t[i-a]++;
  }
  ll ans = 0;
  for(ll i=0;i<m.size();++i){
    ans += s[m.at(i)]*t[m.at(i)];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 38920
import java.util.Scanner;

public class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    
    String s1 = s.substring(0, (int)(n/2));
    String s2 = s.substring((int)(n/2), n);
    System.out.println(s1.equals(s2) ? "Yes" : "No");
  }
}

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

using namespace std;

const int INF = 1 << 29;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  int find(int k)
  {
    return (data[k] < 0 ? k : data[k] = find(data[k]));
  }

  void unite(int x, int y)
  {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }
};

vector< pair< int, int > > g[100001];
vector< int > leftt[100001], rightt[100001], just[100001];
vector< int > gg[100001];
int deg[100001];


int rec(int idx, int back = -1)
{
  if(rightt[idx][0] == INF) {
    for(int i = 0; i < g[idx].size(); i++) {
      int to, rev;
      tie(to, rev) = g[idx][i];
      if(i == back) continue;
      just[idx][i] = rec(to, rev) + 1;
    }
    for(int i = 0; i < g[idx].size(); i++) {
      leftt[idx][i + 1] = max(leftt[idx][i], just[idx][i]);
    }
    for(int i = (int) g[idx].size() - 1; i >= 0; i--) {
      rightt[idx][i] = max(rightt[idx][i + 1], just[idx][i]);
    }
  }
  if(back == -1) return (rightt[idx][0]);
  return (max(leftt[idx][back], rightt[idx][back + 1]));
}


int main()
{
  int N, M;
  vector< pair< int, int > > edges, arcs;

  scanf("%d %d", &N, &M);

  UnionFind uf(N);

  for(int i = 0; i < M; i++) {
    int x, y, t;
    cin >> x >> y >> t;
    --x, --y;
    if(t == 1) {
      arcs.emplace_back(x, y);
      g[x].emplace_back(y, -1);
    } else {
      if(uf.find(x) == uf.find(y)) {
        cout << "Infinite" << endl;
        return (0);
      }
      uf.unite(x, y);
      edges.emplace_back(x, y);
      g[y].emplace_back(x, g[x].size());
      g[x].emplace_back(y, g[y].size() - 1);
    }
  }

  {
    for(auto &e : arcs) {
      gg[uf.find(e.first)].push_back(uf.find(e.second));
      ++deg[uf.find(e.second)];
    }
    vector< int > order;
    for(int i = 0; i < N; i++) {
      if(deg[i] == 0) order.push_back(i);
    }
    for(int i = 0; i < order.size(); i++) {
      for(auto &e : gg[order[i]]) {
        if(--deg[e] == 0) order.push_back(e);
      }
    }
    if(order.size() != N) {
      cout << "Infinite" << endl;
      return (0);
    }
  }


  int ret = 0;
  for(int i = 0; i < N; i++) {
    int sz = g[i].size();
    just[i].assign(sz, INF);
    leftt[i].assign(sz + 1, INF);
    rightt[i].assign(sz + 1, INF);
    leftt[i][0] = rightt[i][sz] = 0;
  }
  for(int i = 0; i < N; i++) ret = max(ret, rec(i));
  cout << ret << endl;
}

Measured memory_bytes: 35488
#include <stdio.h>

int main(){
    int val[5],i;
    
    for(i=0;i<5;i++){
        scanf("%d",&val[i]);
    }
    
    for(i=0;i<5;i++){
        if(val[i]==0){
            printf("%d\n",i+1);
            break;
        }
    }
    
    
    return 0;
}

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

int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	if (a <6)printf("0\n");
	else if (a>=6&&a<=12)printf("%d\n", b / 2);
	else printf("%d\n", b);

	return 0;
}

Measured memory_bytes: 128
n = int(input())
x = list(map(int, input().split()))
a=0
b=0
x.sort(reverse=True)
for i in range(int(n/2)):
    a += x[i*2]
    b += x[i*2+1]
if n%2==1:
    a+=x[n-1]
print(a-b)

Measured memory_bytes: 3064
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(input())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

x = 1
ans = 0
for i in range(60):
    ones = 0
    zeros = 0
    for a in A:
        if a & (1 << i) > 0:
            ones += 1
        else:
            zeros += 1
    ans += (ones * zeros * x) % MOD
    x *= 2

print(ans % MOD)



Measured memory_bytes: 125620
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int a,b,c,d;
int x,y,z;
int main(void){
  bool f = false;
  while(cin >> x >> y >> z){
    if(x < y) swap(x,y);
    if(x < z) swap(x,z);
    if(f || x >= y+z){
      f = true;
      continue;
    }
    a++;
    if(x*x < y*y+z*z) b++;
    else if(x*x == y*y+z*z) c++;
    else d++;
  }
  printf("%d %d %d %d\n",a,c,b,d);
}

Measured memory_bytes: 1144
#![allow(unused_mut, unused_macros, unused_variables, unused_assignments, non_snake_case, unused_imports)]

use std::cmp::*;
use std::collections::*;

// [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 から拝借
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    let mut N = 0;
    let mut M = 0;
    {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        N = iter.next().unwrap().parse().unwrap();
        M = iter.next().unwrap().parse().unwrap();
    }
    let KS = {
        let mut temp : Vec<Vec<usize>> = Vec::new();
        for p in 0..M {
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            let mut iter = buf.split_whitespace();
            temp.push(iter.map(|x| x.parse().unwrap()).collect());
        }
        temp
    };
    input! {
        P : [usize; M],
    }
    let mut count = 0;
    'o: for f in 0..1 << N {
        for m in 0..M {
            let mut q = 0;
            for t in &KS[m][1..] {
                q += f >> (t - 1) & 1;
            }
            if q % 2 != P[m] {
                continue 'o;
            }
        }
        count += 1;
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main() {
	int n,cnt;
	while (fscanf(stdin, "%d", &n),n!=0) {
		cnt = 0;
		while (n != 1)
			if (n % 2 == 0) n /= 2, cnt++;
			else n *= 3, n += 1, cnt++;
		fprintf(stdout, "%d\n", cnt);
	}
	return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define forn(i , n) for(int i=0;i<n;i++)


int main(){
    int a;
    int b;
    int c;
    
    cin >> a >> b >> c;
    
    if(a > b) swap(a , b);
    if(a > c) swap(a , c);
    if(b > c) swap(b , c);
    
    cout << a << " " << b << " " << c << endl;
   
    return 0;
}

Measured memory_bytes: 3048
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] strArray = { scan.next(), scan.next(), scan.next() };
		Arrays.sort(strArray, Collections.reverseOrder());
		System.out.println(Integer.parseInt(strArray[0] + strArray[1]) + Integer.parseInt(strArray[2]));
	}
}


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

int main(){
int n;
int sum = 0;
int v[50],c[50];
  cin >> n;
  for(int i = 0;i<n;i++){
  cin >> v[i];
  }
  for(int i = 0;i<n;i++){
  cin >> c[i];
  }
  
  for(int i = 0;i<n;i++){
  if(v[i]>c[i]){
  sum+=v[i]-c[i];
  }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.E
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var A = ReadLongs();

            var L = new long[N];
            var R = new long[N];
            for (int i = 0; i < N; i++)
            {
                L[i] = i - A[i];
                R[i] = A[i] + i;
            }

            var dicXCount = new Dictionary<long, long>();
            foreach (var l in L)
            {
                if (dicXCount.ContainsKey(l))
                {
                    dicXCount[l]++;
                }
                else
                {
                    dicXCount.Add(l, 1);
                }
            }

            var count = 0L;
            foreach (var r in R)
            {
                if (dicXCount.ContainsKey(r))
                {
                    count += dicXCount[r];
                }
            }

            return count;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 60044