akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <bitset>
#include <queue>
#include <deque>
#include <utility>
#include <algorithm>
#include <ctime>
using namespace std;

int const MAX_N = 128;
int const MX_CNT = 2200000;

double x[MAX_N], y[MAX_N];
int cnt[MAX_N];

int main() {
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    
    int n;
    cin>>n;
    for (int i=0; i<n; i++) cin>>x[i]>>y[i];
    double R = 1e11;
    double ang_part = R / MX_CNT;
    int sum = 0;
    for (int i=0; i<MX_CNT; i++) {
        double xx = R*cos(ang_part*i);
        double yy = R*sin(ang_part*i);
        double mn_val = 1e150;
        int mn_ind = -1;
        for (int j=0; j<n; j++) {
            double val = (xx - x[j])*(xx - x[j]) + (yy - y[j])*(yy - y[j]);
            if (val < mn_val) {
                mn_val = val;
                mn_ind = j;
            }
        }
        cnt[mn_ind]++;
        sum++;
    }
    for (int i=0; i<n; i++) printf("%.6lf\n",cnt[i]/((double) sum));
   	return 0;
}

Measured memory_bytes: 256
/*
h3110_fr13nd,
 
AUTHOR : @sam_jn
*/
 
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<pair<int, int>, null_type, less_equal<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define NN 1000002
#define in(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define ot(a, n) for(int i = 0; i < n; i++) cout << a[i] << " ";
#define ot2(a, n) for(int i = 0; i < n; i++) cout << a[i] << "\n";
ll pwr(ll a, ll b);
ll pwr(ll a, ll b, ll m);
int baap[200002];
int prime[NN];
int find(int i);  
bool Union(int x, int y);
ll inv(ll x) {return pwr(x, MOD - 2, MOD);}
void init();
int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[8] = {-1, 1, 0, 0, 1, -1, 1, -1};
//----------------------------------SOLUTION-BELOW-------------------------------------------// 

void solve(){
    int cnt = 0;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]) cnt++;
    }
    cout << cnt;
}
int main(){


                                                            // #ifndef ONLINE_JUDGE    
                                                            // freopen("/home/samyak/Desktop/CP/input.txt", "r", stdin);
                                                            // freopen("/home/samyak/Desktop/CP/output2.txt", "w", stdout);
                                                            // #else
                                                            // // online submission
                                                            // #endif
// 

    boost
    int _ = 1;
    // cout << 0 << endl;
    // cin >> _;
    while(_--){
        solve();
        cout << endl;
    }
}
 
 
//--------------------------------------DEFININTIONS---------------------------------------
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;    
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
int find(int i)  
{  
    if (baap[i] != i)  
        baap[i] = find(baap[i]);  
  
    return baap[i];  
}
 
bool Union(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return false;
    baap[x] = y;
    return true;
}
void init(){
  for(ll i = 2; i < NN; i++){
      if(prime[i]) continue;
      for(ll j = 2*i; j < NN; j += i)
          prime[j] = i;
  }
}

Measured memory_bytes: 3884
l={}
N=int(input())
for i in range(N):
    a=input()
    if a in l:
        l[a]+=1
    else:
        l[a]=1
M=int(input())
for j in range(M):
    b=input()
    if b in l:
        l[b]-=1

if max(l.values())<=0:
    print(0)
else:
    print(max(l.values()))


Measured memory_bytes: 9088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int[] N=cin.ArrayInt(2,0);
        Console.WriteLine(N[0]-N[1]+1);
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}



Measured memory_bytes: 11092
#include <stdio.h>
#define NUMBER 100
void print_array(int array[], int num)
{
	int i;
	for( i = 0; i< num-1; i++)
		printf("%d ", array[i]);
	
	printf("%d\n", array[i]);
}
	
void insertionSort(int array[], int num)
{
    int i, j, v;

    for (i=1; i <= num-1; i++) { 
	
	v = array[i];

        j = i - 1; 


        while (j >= 0 && array[j] > v) {
          
            array[j+1] = array[j];

          
            j--;
        }
		array[j+1] = v;
			print_array(array, num);
    }

}



int main(void)
{
	int array[NUMBER];
	int num, i;
	scanf("%d", &num);
	
	for (i = 0; i < num; i++){
		scanf("%d", &array[i]);

	}
		print_array(array, num);
	insertionSort(array, num);


	return 0;

}	


Measured memory_bytes: 2112
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int main()
{
    int t;
    
    // scanf("%d",&t);
    
    t=1;
    
    while(t--)
    {
        int w,a,b;
        
        scanf("%d%d%d",&w,&a,&b);
        
        if(b>a+w)
            printf("%d",b-(a+w));
        else if(b+w<a)
            printf("%d",a-(b+w));
        else
            printf("0");
    }

    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int X[200010], Y[200010];
char U[200010];
vector<vector<pair<int, char>>> yoko(200010), tate(200010);
vector<vector<pair<int, char>>> waue(400010), wasi(400010);
vector<vector<pair<int, char>>> saue(400010), sasi(400010);

int main() {
	int N;
	cin >> N;
	for(int i=0; i<N; ++i){
		cin >> X[i] >> Y[i] >> U[i];
		if(U[i]=='L' || U[i]=='R') yoko[Y[i]].emplace_back(make_pair(X[i], U[i]));
		else tate[X[i]].emplace_back(make_pair(Y[i], U[i]));
		if(U[i]=='U' || U[i]=='R') waue[X[i]+Y[i]].emplace_back(make_pair(X[i], U[i]));
		else wasi[X[i]+Y[i]].emplace_back(make_pair(X[i], U[i]));
		if(U[i]=='L' || U[i]=='U') saue[Y[i]-X[i]+200000].emplace_back(make_pair(X[i], U[i]));
		else sasi[Y[i]-X[i]+200000].emplace_back(make_pair(X[i], U[i]));
	}
	int ans=1e9;
	for(int i=0; i<200010; ++i){
		sort(yoko[i].begin(), yoko[i].end());
		for(int j=0; j+1<yoko[i].size(); ++j){
			if(yoko[i][j].second=='R' && yoko[i][j+1].second=='L'){
				ans=min(ans, (yoko[i][j+1].first-yoko[i][j].first)*5);
			}
		}
		sort(tate[i].begin(), tate[i].end());
		for(int j=0; j+1<tate[i].size(); ++j){
			if(tate[i][j].second=='U' && tate[i][j+1].second=='D'){
				ans=min(ans, (tate[i][j+1].first-tate[i][j].first)*5);
			}
		}
	}
	for(int i=0; i<400010; ++i){
		sort(waue[i].begin(), waue[i].end());
		for(int j=0; j+1<waue[i].size(); ++j){
			if(waue[i][j].second=='R' && waue[i][j+1].second=='U'){
				ans=min(ans, (waue[i][j+1].first-waue[i][j].first)*10);
			}
		}
		sort(wasi[i].begin(), wasi[i].end());
		for(int j=0; j+1<wasi[i].size(); ++j){
			if(wasi[i][j].second=='D' && wasi[i][j+1].second=='L'){
				ans=min(ans, (wasi[i][j+1].first-wasi[i][j].first)*10);
			}
		}
		sort(saue[i].begin(), saue[i].end());
		for(int j=0; j+1<saue[i].size(); ++j){
			if(saue[i][j].second=='U' && saue[i][j+1].second=='L'){
				ans=min(ans, (saue[i][j+1].first-saue[i][j].first)*10);
			}
		}
		sort(sasi[i].begin(), sasi[i].end());
		for(int j=0; j+1<sasi[i].size(); ++j){
			if(sasi[i][j].second=='R' && sasi[i][j+1].second=='D'){
				ans=min(ans, (sasi[i][j+1].first-sasi[i][j].first)*10);
			}
		}
	}
	if(ans>1e8) cout << "SAFE" << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 70548
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  ll i,j,k,n,m;
  cin>>n>>m;
  ll a[n];
  ll sum=0;
  for(i=0;i<n;i++)
  {
      cin>>a[i];
  }
  sort(a,a+n);
  for(i=0;i<(n-m);i++)
  sum+=a[i];
  cout<<sum;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    ll n;
    cin>>n;
    ll sum=0;
    for(ll i=1;i<=n;i++){
        if(0==i%3||0==i%5){
            continue;
        }else{
            sum+=i;
        }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
int main(){
	int m,f,r;
	while(true){
		std::cin >> m >> f >> r;
		if(m == -1&&f == -1&&r == -1)break;
		if(m == -1 or f == -1){
			std::cout << "F"<<std::endl;
		} 
		if(m + f >=80){
			std::cout <<"A"<<std::endl;
		}
		if(m + f >= 65&&m + f < 80&&f > -1&&m > -1){
			std::cout <<"B"<<std::endl;
		}
		if(m + f >= 50&&m + f < 65&&m > -1&&f > -1){
			std::cout <<"C"<<std::endl;
		}
		if(m + f >= 30&&m + f < 50 && m > -1 && f > -1){
			if(r >= 50){
				std::cout <<"C"<<std::endl;
			}else{
				std::cout <<"D"<<std::endl;
			}
		}
		if(m + f < 30 && m > -1&&f > -1){
			std::cout <<"F"<<std::endl;
		}
	}
}

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
int INF = numeric_limits<int>::max();
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

/* if in function
template <class T>
bool contain(vector<T> &vec, T find_it) {
  auto it = find(vec.begin(), vec.end(), find_it);
  return it != vec.end();
}

bool contain(string &str, char c) {
  return str.find(c) != string::npos;
}
*/

int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}

int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  rep(i, m) cin >> b[i];
  int cnt = 0;
  rep(i, n) {
    int score = c;
    rep(j, m) {
      int a;
      cin >> a;
      score += a * b[j];
    }
    if (score > 0) ++cnt;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int func(int a,int b){
	return a*(100+b)/100.0;
}
int main(){
	int a,b,c;
	while(cin>>a>>b>>c,a+b+c){
		int ma=-1;
		loop(i,1,c)loop(j,1,c)if(func(i,a)+func(j,a)==c)ma=max(ma,func(i,b)+func(j,b));
		cout<<ma<<endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 10;
int n;
int a[maxn], F[maxn][maxn][2], G[maxn][maxn][2];
int f(int i, int j, bool k);
int g(int i, int j, bool k);
int f(int i, int j, bool k)
{
	if(~F[i][j][k]) return F[i][j][k];
	if(i == n || j == n) return F[i][j][k] = abs(a[i] - a[j]);
	if(k == 0) return F[i][j][k] = g(j + 1, j, k ^ 1);
	else return F[i][j][k] = g(i, i + 1, k ^ 1);
} 
int g(int i, int j, bool k)
{
	if(~G[i][j][k]) return G[i][j][k];
	if(i == n || j == n) return G[i][j][k] = f(i, j, k);
	if(k == 0) return G[i][j][k] = min(g(i, j + 1, k), f(i, j, k));
	else return G[i][j][k] = max(g(i + 1, j, k), f(i, j, k));
}
int main()
{
	memset(F, -1, sizeof F);
	memset(G, -1, sizeof G); 
	scanf("%d", &n);
	n += 2;
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	printf("%d\n", f(1, 2, 0));
	return 0;
}

Measured memory_bytes: 63616
import java.util.*;
import static java.lang.System.*;

import java.io.IOException;
import java.io.InputStream;

public class Main{
  public static void main(String[] args){
	  FastScanner sc = new FastScanner();
	  int N = sc.nextInt();
	  List<Double> v = new ArrayList<>();
	  for(int i=0; i<N; i++) {
		  double d = sc.nextDouble();
		  v.add(d);
	  }
	  while(v.size()> 1) {
		  Collections.sort(v);
		  double d1 = v.get(0);
		  double d2 = v.get(1);
		  v.remove(0);
		  v.remove(0);
		  double d3 = (d1 + d2) / 2;
		  v.add(d3);
	  }
	  out.println(v.get(0));
  }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte(){
        if(ptr < buflen){
            return true;
        }else{
            ptr = 0;
            try{
                buflen = in.read(buffer);
            }catch(IOException e){
                e.printStackTrace();
            }
            if(buflen <= 0){
                return false;
            }
        }
        return true;
    }
    private int readByte(){
        if(hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    private static boolean isPrintableChar(int c){
        return 33 <= c && c <= 126;
    }
    public boolean hasNext(){
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    public String next(){
        if(!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)){
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong(){
        if(!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if(b == '-'){
            minus = true;
            b = readByte();
        }
        if(b < '0' || '9' < b){
            throw new NumberFormatException();
        }
        while(true){
            if('0' <= b && b <= '9'){
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt(){
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble(){
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
 
 
int main ()
{
  prep();
  int n;
  cin >> n;
  int arr[n];
  for (int i=0; i<n; i++){
      cin >> arr[i];
  }
  long long minnest = 1000000000000000000LL;
  for (int i=-100; i<=100; i++){
      long long cost = 0;
      for (int j=0; j<n; j++){
          cost += pow(arr[j]-i, 2);
      }
      //cout << cost << " " << i << endl;
      minnest = min(minnest, cost);
  }
  cout << minnest;
  return 0; 
}

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

void str_toupper(char str[]){
	int i=0;

	
	while(str[i]){
			str[i]=toupper(str[i]);
		i++;
	}

}

int main(void) {
	char str[999];
	
	fgets(str, 999, stdin);
	
	str_toupper(str);
	
	printf("%s", str);
	return 0;
}

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

int		main(void)
{
	string s;

	cin >> s;
	int R = 0, B = 0;

	for (int i = 0; s[i]; i++)
	{
		if (s[i] == '0')
			R++;
		else
			B++;
	}
	cout << min(R, B) * 2 << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    long long n;
    cin>>n;
    long long a,b;
    vector<vector<int>> v(n);
    bool e[n][n]={};
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
        e[a][b]=1,e[b][a]=1;
    }
    long long c[n];
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
 
    pair<int,int> p[n];
    for(int i=0;i<n;i++){
        p[i]=make_pair(v[i].size(),i);
    }
    sort(p,p+n);
    sort(c,c+n);

    reverse(p,p+n);
    reverse(c,c+n);

    int cnt=0;
    int next=p[0].second;
    long long ans[n]={};
    ans[next]=c[cnt];
    cnt++;

    bool go[n]={};
    go[next]=1;

    queue<int> q;

    q.push(next);

    while(!q.empty()){
        q.pop();
        for(int j=1;j<n;j++){
            if(e[next][p[j].second] && !go[p[j].second]){
                q.push(p[j].second);
                ans[p[j].second]=c[cnt];
                cnt++;
                go[p[j].second]=1;
            }
        }
        next=q.front();
        
    }


    long long sum=0;
    bool used[n][n]={};
    for(int i=0;i<n;i++){
        for(auto j:v[i]){
            if(j!=i && !used[i][j]){
                sum+=min(ans[i],ans[j]);
                used[i][j]=true;
                used[j][i]=true;
            }
        }
    }
    cout<<sum<<endl;
    for(int i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
}

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

#define INF 1000000000000


signed main(){
  string s;cin>>s;
  int tmp=0,ans=0;
  char a[4]={'A','C','G','T'};
  rep(i,s.size()){
    bool b=0;
    rep(j,4){
      if(s[i]==a[j]){b=true;}
    }
    if(b){tmp++;}
    else {ans=max(ans,tmp);tmp=0;}
  }
  ans=max(ans,tmp);
  cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//万能头文件
using namespace std;
typedef long long ll;//注意要开long long
namespace doit
{
    inline ll read()//快读函数
    {
        ll x=0,p=1;
        char c;
        c=getchar();
        while(c<'0'||c>'9')
        {
            if(c=='-')
                p=-1;
            c=getchar();
        }
        while(c>='0'&&c<='9')
        {
            x=x*10+c-'0';
            c=getchar();
        }
        return x*p;
    }
    inline int f(ll n)//求数的位数
    {
        int len=0;
        while(n)
        {
            n/=10;
            len++;
        }
        return len;
    }
    inline void put()
    {
        ll n,ans;
        n=read();
        for(register int i=sqrt(n);i>=1;i--)//从sqrt(N)开始找
            if(n%i==0)//如果找到了
            {
                ans=n/i;//就为最优解
                break;
            }
        std::cout<<f(ans)<<"\n";//输出位数就OK了
    }
}
int main()
{
    ios::sync_with_stdio(false);
    doit::put();
}

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

int main(){
  int n;
  cin >> n;
  int h[3][n+1];
  rep(i,n) cin >> h[0][i+1] >> h[1][i+1] >> h[2][i+1];
  vvi dp(3, vector<int>(n));
  dp[0][0] = 0; dp[1][0] = 0; dp[2][0] = 0;
  for(int i=1; i<=n; i++){
    rep(j,3){
      rep(k,3){
        if(j==k) continue;
        dp[j][i] = max(dp[j][i], dp[k][i-1] + h[j][i]);
      }
    }
  }
  cout << max(dp[0][n], max(dp[1][n], dp[2][n])) << endl;;
}


Measured memory_bytes: 5900
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

constexpr int lim = 50;
ll s[lim+1], p[lim+1];

void init(){
  s[0] = 1; p[0] = 1;
  FOR(i, 1, lim+1){
    s[i] = 2 * s[i-1] + 3;
    p[i] = 2 * p[i-1] + 1;
  }
}

ll solve(ll n, ll x){
  if(x == 1){
    return (n == 0)? p[0]: 0;
  }
  else if(x < s[n-1] + 2){
    return solve(n-1, x-1);
  }
  else if(x == s[n-1] + 2){
    return p[n-1] + 1;
  }
  else if(x < 2 * s[n-1] + 3){
    return p[n-1] + 1 + solve(n-1, x-(s[n-1]+2));
  }
  else{
    return p[n];
  }
}

int main(){
  ll n, x; cin >> n >> x;

  init();

  cout << solve(n, x) << endl;

  return 0;
}


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

using namespace std;
int main ()
{
    int N,A,B;
    cin >> N;
    switch(N){
        case 1:
        cout << "Hello World" << endl;
        break;
        case 2:
        cin >> A >> B;
        cout << A+B <<endl;
        break;
        default:
        break;
    }
    return 0;
}












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

    ans = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            d = m[i][j]
            t = min(m[i][k] + m[k][j] if k != i and k != j else d + 1 for k in range(n))
            if t < d:
                print(-1)
                exit()
            if d < t:
                ans += d

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 69748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }




void solve() {
    int n, k;
    cin >> n >> k;
    
    int a = 1;
    rep(i, n) {
        if (a * 2 - a < k) a *= 2;
        else a += k;
    }
    cout << a << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}





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

int main() {
  int n,m,p = 0;
  cin >> n >> m;
  vector<int>data(n,1);
  vector<bool>red(n,false);
  red[0] = true;
  for(int i = 0;i < m;i++){
    int x,y;
    cin >> x >> y;
    x--;y--;
    data[x]--;
    data[y]++;
    if(red[x]) red[y] = true;
    if(data[x] == 0) red[x] = false;
  }
  int ans = 0;
  for(int i = 0;i < n;i++){
    if(data[i] > 0 && red[i]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
 
int main() {
    int n;cin>>n;
    int v;int ans = 1;
    int height;cin >> height;
  
    for(int i=1;i<n;i++){
        int l;cin >> l;
        v=l;
      
        if(v>=height){
            height = v;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

s = input()
if len(s) == 1:
    total = int(s)
else:
    bitlist = []
    # 文字列の長さ-1箇所にプラスを入れるかどうかbit演算によって考える
    for i in range(2 ** (len(s) - 1)):
        bitlist.append([int(x) for x in list(bin(i)[2::].zfill(len(s) - 1))])
    # print(bitlist)
    total = 0
    for bit in bitlist:
        befnum = int(s[0])
        # print(bit)
        for i, plus in enumerate(bit):
            if plus == 0:
                # プラスが入らない場合、前のケタの数を10倍して加える
                befnum = befnum * 10 + int(s[i + 1])
                # print(befnum)
            else:  # plus==1
                # プラスが入る場合、そこまでの数をtotalに加えてbefnumを初期化
                total += befnum
                befnum = int(s[i + 1])
                # print(befnum)
            if i == len(bit) - 1:
                total += befnum
            # print('total:' + str(total))
print(total)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

bool A[1000000];
vector<int>v;


void sieve()
{
        for(int i = 1; i < 1000000; i++)
         A[i] = true;

    for(int i = 2; i*i<=1000000; i++)
    {
        if (A[i] == true)
        {
            for (int j = i * i; j < 1000000; j+= i)
            {
                A[j] = false;
            }
        }
    }

    for(int i = 1; i <1000000; i++)
    {
        if (A[i] == true)
        {
            v.pb(i);
        }
    }
}

bool prime(int n)
{
    for(int i=2;i*i<n;i++)
    {
        if(n%i==0)
        {
            return false;
        }
    }
    return true;
}

int main()
{

 sieve();
 int n;
 cin>>n;
 if(prime(n)) cout<<n<<endl;
 else
 {
     auto pos=upper_bound(v.begin(),v.end(),n);
     cout<<v[pos-v.begin()]<<endl;
 }


}


Measured memory_bytes: 1916
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;
int ans;
string str;
int main(){
	cin>>str;
	for(int i=1;i<str.size();i++) if(str[i]!=str[i-1]) ans++;
	printf("%d",ans);
}


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

int main()
{
  string s, t;
  cin >> s >> t;

  int s_size = s.size();
  int t_size = t.size();

  vector<char> s_array(s_size);
  vector<char> t_array(t_size);
  for (int i = 0; i < s_size; i++)
    s_array[i] = s[i];
  for (int i = 0; i < t_size; i++)
    t_array[i] = t[i];
  sort(s_array.begin(), s_array.end());
  sort(t_array.begin(), t_array.end());
  reverse(t_array.begin(), t_array.end());

  int N = min(s_size, t_size);
  string a = "No";
  int i = 0;

  while (i < N)
  {
    if (s_array[i] < t_array[i])
    {
      a = "Yes";
      break;
    }
    else if(t_array[i] < s_array[i])
    {
      a = "No";
      break;
    }
    i++;
  }
  if (i == N && s_size < t_size)
    a = "Yes";
  cout << a << endl;
}

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

using namespace std;

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

int n=a+b;
int f=a+(a-1);
int f2=b+(b-1);
int m=max(n,f);int m2=max(m,f2);
cout<<m2;
return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3

MOD = None

def matunit(n):
    return [ [ int(y == x) for x in range(n) ] for y in range(n) ]

def matadd(a, b):
    assert len(a) == len(b)
    assert len(a[0]) == len(b[0])
    h = len(a)
    w = len(a[0])
    c = [ [ a[y][x] + b[y][x] for x in range(w) ] for y in range(h) ]
    return c

def matmul(a, b):
    assert len(a[0]) == len(b)
    h = len(a)
    k = len(b)
    w = len(b[0])
    c = [ [ 0 for _ in range(w) ] for _ in range(h) ]
    for y in range(h):
        for z in range(k):
            for x in range(w):
                c[y][x] += a[y][z] * b[z][x]
    for y in range(h):
        for x in range(w):
            c[y][x] %= MOD
    return c

def matpow(a, k):
    assert len(a) == len(a[0])
    n = len(a)
    b = matunit(n)
    while k:
        if k & 1:
            b = matmul(b, a)
        a = matmul(a, a)
        k >>= 1
    return b

def binsearch(l, r, pred): # [l, r)
    assert l < r
    l -= 1
    while r - l > 1:
        m = (l + r) // 2
        if pred(m):
            r = m
        else:
            l = m
    return r

def main():
    l, a, b, m = map(int, input().split())

    global MOD
    MOD = m

    x = [ [ 0 ], [ a ], [ 1 ] ]  # (answer, s_i, 1)
    DIGITS = 20
    d = [ binsearch(0, l, lambda i: len(str(a + b * i)) >= d) for d in range(DIGITS) ]
    for i in range(DIGITS - 1):
        l = d[i]
        r = d[i + 1]
        f = [ [ 10 ** i, 1, 0 ], [ 0, 1, b ], [ 0, 0, 1 ] ]
        x = matmul(matpow(f, r - l), x)
    print(x[0][0] % m)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3192
import java.util.Scanner;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;


public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        Node[] nodes = new Node[N];
        for(int i = 0; i < N; i++){
            nodes[i] = new Node(i);
        }

        int M = sc.nextInt();
        for(int i = 0; i < M; i++){
            int u = sc.nextInt() - 1;
            int v = sc.nextInt() - 1;
            nodes[u].adjacents.add(nodes[v]);
        }
        
        int S = sc.nextInt() - 1;
        int T = sc.nextInt() - 1;
        
        int shortest = bfs(N, nodes, S, T);
        System.out.println( (shortest >= 0 ) ? shortest / 3 : -1 );
    }
    
    private static int bfs(int N, Node[] nodes, int S, int T){
        int[][] dist = new int[N][3];
        boolean[][] visited = new boolean[N][3];
        
        for(int i = 0; i < N; i++){
            for(int j = 0; j < 3; j++){
                dist[i][j] = -1;
            }
        }
        
        Queue<Pair<Node, Integer>> queue = new LinkedList<>();
        queue.add(new Pair<>(nodes[S], 0));
        dist[S][0] = 0;
        visited[S][0] = true;
        
        while(!queue.isEmpty()){
            Pair<Node, Integer> p = queue.poll();
            Node n = p.first;
            int r = p.second;
            int rn = (r + 1) % 3;
            
            for(Node a : n.adjacents){
                if(!visited[a.id][rn]){
                    dist[a.id][rn] = dist[n.id][r] + 1;
                    visited[a.id][rn] = true;
                    queue.add(new Pair<>(a, rn));
                }
            }
        }
        
        return dist[T][0];
        
    }
    
    
    private static class Node {
        private final int id;
        List<Node> adjacents = new ArrayList<>();
        
        public Node(int id){
            this.id = id;
        }
    }
    
    private static class Pair<F,S>{
        private final F first;
        private final S second;
        
        public Pair(F first, S second){
            this.first = first;
            this.second = second;
        }
        
    }
}


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

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

  int A[110];
  int total = 0;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    total += A[i];
  }

  sort(A, A+N, greater<int>());

  int alice = 0;
  for (int i = 0; i < N; i += 2) {
    alice += A[i];
  }

  cout << 2 * alice - total << 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++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)

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

int main(void) {
    string s;
    int ans;
    ans=700;
    cin >> s;
    REP(i,s.size()){
        if(s[i]=='o'){
            ans+=100;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

int cnt[4]={0};
int g[4]={0};
int32_t  main(){
	IOS;
  vii v;
  for(int i=0;i<3;++i){
    int u_,v_;cin>>u_>>v_;
    v.pb({u_,v_});
  }

  //ohk now brute force 
  for(int i=0;i<3;++i){
    for(int j=0;j<3;++j){
      for(int k=0;k<3;++k){
        if(i==j || j==k || k==i)continue;
        //u can swap a edge order 
        if((v[i].ss==v[j].ff && v[j].ss==v[k].ff)
            
            || (v[i].ff==v[j].ff && v[j].ss==v[k].ff) 
            || (v[i].ss==v[j].ff && v[j].ss==v[k].ss)
            || (v[i].ff==v[j].ff && v[j].ss==v[k].ss)){
          puts("YES");
          return 0;
        }
      }
    }
  }
  puts("NO");

  return 0;
}



Measured memory_bytes: 256
import math

n,h = map(int, input().split())
al = []
bl = []
for _ in range(n):
    a,b = map(int, input().split())
    al.append((a,'swing'))
    bl.append((b,'throw'))

abl = al + bl
abl.sort(reverse=True)

remain_h = h
ans = 0
for v in abl:
    damage, command = v
    if command == 'swing':
        ans += math.ceil(remain_h/damage)
        break
    else:
        ans += 1
        remain_h -= damage
        if remain_h <= 0:
            break

print(ans)

Measured memory_bytes: 70104
N = int(input())
A = list(map(int,input().split()))
count = [0]*max(A)
for i in A:
    count[i-1] += 1
count = [i for i in count if i != 0]
count = sum(count) - len(count)
N = N - 2*(count // 2 + count % 2)
print(N)

Measured memory_bytes: 14108
import itertools

n, m = map(int, input().split())

path = [[False]*n for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

ans = 0

for i in itertools.permutations(range(n), n):
    if i[0]==0:
        for j in range(n-1):
            if not path[i[j]][i[j+1]]:
                break
        else:
            ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007

  int main()
  {
     ll t,i;
     cin>>t;
     ll c,b[1000000]={0};
     for(i=0;i<t-1;i++)
     { cin>>c;
      // a=a-1;
       b[c-1]++;
     }
     for(i=0;i<t;i++)
     cout<<b[i]<<"\n";
  }

Measured memory_bytes: 11448
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <climits>
using namespace std;

int main(){
    const double EPS = 1e-12;
    double x[5];
    double y[5];
    double s;
    double t;
    double u;
    double v;
    double m;
    int n;
    cin >> n;

    for(int i = 0;i < n;i++){
        cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];

        s = x[1] - x[0];
        t = y[1] - y[0];
        u = x[3] - x[2];
        v = y[3] - y[2];

        if(s * v - t * u > 0){
            m = s * v - t * u;
        }
        else{
            m = t * u - s * v;
        }

        if(m < EPS){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;

bool f(P a) {
    return a.fi==a.se;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<P> d(n);
    rep(i, n) cin >> d[i].fi >> d[i].se;
    string ans = "No";
    rep(i, n-2) {
        if (f(d[i]) && f(d[i+1]) && f(d[i+2])) ans = "Yes";
    }
    
    pr(ans);
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ulli unsigned long long int
#define lli long long int
#define d double
#define mod 1000000007
#define mx 200001
using namespace std;
void add_me(lli &a,lli b){
	a+=b;
	if(a>=mod) a-=mod;
}
void sub_me(lli &a,lli b){
	a-=b;
	if(a<0) a+=mod;
}
struct disjointset{
	int parent[mx];
	disjointset(){
		for(int i=1;i<mx;i++) parent[i]=i;
	}
	int find(int x){
		int par=parent[x];
		if(par==x) return x;
		return find(parent[x]);
	}
	void union_(int x,int y){
		int par1=find(x);
		int par2=find(y);
		if(par1==par2) return;
		parent[par2]=par1;
	}
};
int main() {
	FIO;
	lli n;
	cin>>n;
	vector<lli> vec(60,0);
	for(lli i=0;i<n;i++){
		lli x;
		cin>>x;
		for(int bit=0;bit<60;bit++){
			if(x&(1ll<<bit)) vec[bit]++;
		}
	}
	lli ans=0;
	for(int i=0;i<60;i++){
		ans=(ans+((vec[i]*(n-vec[i]))%mod)*((1ll<<i)%mod))%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

da = defaultdict(int)
while True:
    s = input()
    if len(s) == 0:
        break
    c, n = [int(x) for x in s.split(",")]
    da[c] += 1

db = defaultdict(int)
while True:
    try:
        s = input()
    except:
        break
    c, n = [int(x) for x in s.split(",")]
    db[c] += 1


sa = set([k for k in da.keys() if da[k] > 0])
sb = set([k for k in db.keys() if db[k] > 0])

for c in sorted(sa&sb):
    print(c,da[c]+db[c])



Measured memory_bytes: 6000
#include<iostream>
using namespace std;
int main()
{
 int x1,x2,x3,x4,x5;
  cin>>x1>>x2>>x3>>x4>>x5;
  if(x1==0)
  cout<<"1";
  else if(x2==0)
  cout<<"2";
  else if(x3==0)
  cout<<"3";
  else if(x4==0)
  cout<<"4";
  else
  cout<<"5";
}

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

const int maxn=100005;
int pre[maxn],f[maxn+5];

int Find(int x) {
  if(pre[x]==x)
    return x;
  int ret=Find(pre[x]);
  f[x]=f[x]+f[pre[x]];
  return pre[x]=ret;
}

int main() {
  int n, m;
  bool flag=true;

  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++)
    pre[i]=i;

  for(int i=1;i<=m;i++) {
    int l,r,d;
    scanf("%d%d%d",&l,&r,&d);
    if(flag) {
      if(Find(l)==Find(r)) {
        if(f[r]<=f[l]) {
          int p=f[l]-f[r];
          if(p!=d)
            flag=false;
        }
        else
          flag=false;
      }
      else {
        int k=Find(l);
        pre[k]=l;
        f[k]=-f[l];
        pre[l]=r;
        f[l]=d;
      }
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
    return 0;
  } else {
    cout<<"No"<<endl;
    return 0;
  }
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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 h, w;

int count(int i, int j, const vs &s, vii &cnt,int res) {
  if(j >= w) return res;
  if(s[i][j] == '#') return res;
  res++;
  cnt[i][j] = count(i,j+1,s,cnt,res);
  return cnt[i][j];
}

int count2(int i, int j, const vs &s, vii &cnt2,int res) {
  if(i >= h) return res;
  if(s[i][j] == '#') return res;
  res++;
  cnt2[i][j] = count2(i+1,j,s,cnt2,res);
  return cnt2[i][j];
}

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


  cin >> h >> w;
  vs s(h);
  rep(i,h) cin >> s[i];
  vii cnt(h,vi(w));
  vii cnt2(h,vi(w));
  rep(i,h)rep(j,w) {
    if(!cnt[i][j]) count(i,j,s,cnt,0);
  }
  rep(j,w)rep(i,h) {
    if(!cnt2[i][j]) count2(i,j,s,cnt2,0);
  }
  int ans = 0;
  rep(i,h)rep(j,w) {
    chmax(ans, cnt[i][j]+cnt2[i][j] - 1);
  }
  // rep(i,h)rep(j,w) cout << cnt[i][j] << ((j==w-1)?'\n':' ');
  // rep(i,h)rep(j,w) cout << cnt2[i][j] << ((j==w-1)?'\n':' ');
  cout << ans << endl;
}

Measured memory_bytes: 38016
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main(){
  long long N, K;
  cin >> N >> K;
  vector<vector<long long>> base(N, vector<long long>(N, 0));
  for (int i=0;i<N;i++){
    for (int j=0;j<N;j++){
      cin >> base[i][j];
    }
  }
  vector<vector<long long>> mat(N, vector<long long>(N, 0));
  for (int i=0;i<N;i++){
    mat[i][i] = 1;
  }
  vector<vector<long long>> Mat(N, vector<long long>(N, 0));
  vector<vector<long long>> Base(N, vector<long long>(N, 0));
  long long X, S;
  while (K != 0){
    for (int i=0;i<N;i++){
      for (int j=0;j<N;j++){
        Mat[i][j] = mat[i][j];
        Base[i][j] = base[i][j];
      }
    }
    if (K % 2 == 1){
      for (int i=0;i<N;i++){
        for (int j=0;j<N;j++){
          S = 0;
          for (int k=0;k<N;k++){
            S += Mat[i][k] * Base[k][j];
            S %= mod;
          }
          mat[i][j] = S;
        }
      }
    }
    for (int i=0;i<N;i++){
      for (int j=0;j<N;j++){
        S = 0;
        for (int k=0;k<N;k++){
          S += Base[i][k] * Base[k][j];
          S %= mod;
        }
        base[i][j] = S;
      }
    }
    K /= 2;
  }
  X = 0;
  for (int i=0;i<N;i++){
    for (int j=0;j<N;j++){
      X += mat[i][j];
      X %= mod;
    }
  }
  cout << X << endl;
  return 0;
}

Measured memory_bytes: 384
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
    a=list(map(int,input().split()))
    x=0
    for j in range(m):
       x+=a[j]*b[j]
    if x+c>0:ans+=1
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int total = 0;
		int[] input = new int[n];

		boolean[][] dp = new boolean[n][10001];

		for(int i = 0; i < n; i++){
			input[i] = sc.nextInt();
		}

		dp[0][0] = true;
		dp[0][input[0]] = true;

		for(int i = 1; i < n; i++){
			for(int j = 0; j <= 10000; j++){
				if(dp[i - 1][j]){
					dp[i][j] = true;
					dp[i][j + input[i]] = true;
				}
			}
		}

		for(int i = 9999; i >= 0; i--){
			if(i % 10 == 0 && i != 0){
				continue;
			}

			for(int j = 0; j < n; j++){
				if(dp[j][i]){
					System.out.println(i);
					return;
				}
			}
		}
	}

}


Measured memory_bytes: 23892