akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#define N 52
using namespace std;
struct edge{
	int u,v;
}e[N];
int head[N],ver[N*N],nxt[N*N],l;
int head1[N],ver1[N*2],nxt1[N*2],l1;
int t,n,i,j,k,fa[N],fb[N],d[N],d1[N],cnt;
bool vis[N];
int read()
{
	char c=getchar();
	int w=0;
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0'){
		w=w*10+c-'0';
		c=getchar();
	}
	return w;
}
void insert(int x,int y)
{
	l++;
	ver[l]=y;
	nxt[l]=head[x];
	head[x]=l;
}
void insert1(int x,int y)
{
	l1++;
	ver1[l1]=y;
	nxt1[l1]=head1[x];
	head1[x]=l1;
}
void dfsa(int x,int pre)
{
	fa[x]=pre;
	for(int i=head[x];i;i=nxt[i]){
		int y=ver[i];
		if(y!=pre) dfsa(y,x);
	}
}
void dfsb(int x,int pre)
{
	fb[x]=pre;
	vis[x]=vis[pre]&(fa[x]==fb[x]);
	for(int i=head1[x];i;i=nxt1[i]){
		int y=ver1[i];
		if(y!=pre) dfsb(y,x);
	}
}
bool toposort()
{
	queue<int> q;
	for(int i=1;i<=n;i++){
		if(d1[i]==0){
			q.push(i);
		}
	}
	int cnt=0;
	while(!q.empty()){
		int x=q.front();
		q.pop();
		cnt++;
		for(int i=head[x];i;i=nxt[i]){
			int y=ver[i];
			d1[y]--;
			if(d1[y]==0) q.push(y);
		}
	}
	return (cnt==n);
}
bool check1()
{
	for(int i=1;i<=n;i++){
		if(fa[i]!=fb[i]) return 0;
	}
	return 1;
}
int check(int root)
{
	memset(vis,0,sizeof(vis));vis[0]=1;
	for(int i=1;i<n;i++){
		if(e[i].u!=root&&e[i].v!=root) insert(e[i].u,e[i].v),insert(e[i].v,e[i].u);
	}
	dfsa(root,0);dfsb(root,0);
	memset(head,0,sizeof(head));l=0;
	memset(d1,0,sizeof(d1));
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			if(!vis[fa[i]]) insert(i,fa[i]),d1[fa[i]]++;
			if(!vis[fb[i]]) insert(fb[i],i),d1[i]++;
			ans++;
		}
	}
	if(toposort()) return ans;
	else return 1<<30;
}
int main()
{
	t=read();
	while(t--){
		cnt++;
		int ans=1<<30;
		memset(d,0,sizeof(d));
		memset(head1,0,sizeof(head1));l1=0;
		memset(head,0,sizeof(head));l=0;
		n=read();
		for(i=1;i<n;i++){
			e[i].u=read();e[i].v=read();
			d[e[i].u]++;d[e[i].v]++;
			insert(e[i].u,e[i].v);insert(e[i].v,e[i].u);
		}
		for(i=1;i<n;i++){
			int u=read(),v=read();
			insert1(u,v);insert1(v,u);
		}
		dfsa(1,0);dfsb(1,0);
		if(check1()){
			puts("0");
			continue;
		}
		for(i=1;i<=n;i++){
			if(d[i]==1){
				for(j=1;j<=n;j++){
					if(i==j) continue;
					memset(head,0,sizeof(head));l=0;
					insert(i,j);insert(j,i);
					ans=min(ans,check(i));
				}
			}
		}
		if(ans!=1<<30) printf("%d\n",ans+1);
		else puts("-1");
	}
	return 0;
}


Measured memory_bytes: 3244
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
	x, y = map(int, readline().rstrip().split())
	print((max(0, 4 - x) + max(0, 4 - y) + max(0, 2 - x * y) * 4) * 100000)

if __name__ == '__main__':
    main()

    

Measured memory_bytes: 9472
#include <iostream>
#include <set>

using namespace std;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    set<int> s;
    int hoge,piyo;
    cin>>hoge;
    for(int i=0;i<hoge;++i)
    {
        cin >> piyo;
        s.insert(piyo);
    }
    cout << *s.rbegin() - *s.begin()<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;



class Solution{

    boolean found = false;

    int[] numbers = new int[10];

    int a = Integer.MAX_VALUE;
    
    void recurse(int index , int number){

        if(index < 0){
            a = Math.min(a,number); 
            return;
        }

        String numberString = String.valueOf(number);

        int currentStringLength = numberString.length();
 
        int current = Integer.parseInt(String.valueOf(numberString.charAt(index)));

        for(int i = 0 ; i<=9; i++){

            if(numbers[(current+i)%10] == 0){
                
                int newNumber = (int)(number+i*Math.pow(10,currentStringLength-index-1));
                
            

                if(String.valueOf(newNumber).length() > currentStringLength){
                    recurse(index, newNumber);
                }else{
                    recurse(index-1 , newNumber);                   
                }
            
            
            }
            
        }
        

    }

    public void solve() throws IOException{
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

        String[] inputLine1 = bufferedReader.readLine().split(" ");
        String[] inputLine2 = bufferedReader.readLine().split(" ");

        

        int N = Integer.parseInt(inputLine1[0]);
        int K = Integer.parseInt(inputLine1[1]);


        for(int i=0;i<inputLine2.length;i++){
            numbers[Integer.parseInt(inputLine2[i])]++;
        }

        recurse(String.valueOf(N).length()-1,N);

        System.out.println(a);
        
    }

}


class Main{


    public static void main(String[] args) throws IOException{
        new Solution().solve();
    }

}

Measured memory_bytes: 39300
from math import factorial

S = int(input())

mod = 10**9 + 7
ans = 0
for i in range(1, S+1):
    rest = S - 3 * i
    if rest >= 0:
        ans += factorial(i + rest - 1) // factorial(rest) // factorial(i - 1)
        
print(ans % mod)

Measured memory_bytes: 9100
'use strict'

function main(input) {


    input = input.split('\n').map(v => v.split(' ').map(v => ~~v))
        //[Log] [[5, 3, 3], [1, 2, 4]] (2) (094-b.html, line 19)
    let x = input[0][2] //currentpos

    let i = 0
    let a = 0
    let b = 0
    while (i < input[1].length && b <= a) {
        if (input[1][i] < x) {
            a++
        } else {

            b++
        }
        i++
    }
    let ans = Math.min(a, b)

    console.log(ans)


}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  string s;
  cin >> s;

  int ans = 1;
  char now = s[0];
  for ( int i = 1; i < N; i++ ) {
    if ( now != s[i] ) {
      ans++;
      now = s[i];
    }
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int main(void){
    
    
    string s;
    cin >> s;
    
    if(s[0] == '9' || s[1] == '9'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


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

void solve(long long A, long long B, long long N){
    long long a = N / B;
    long long n = floor((double)A * N / B) - (double)A * floor((double)N / B);
    if (a == 0) {
        cout << n << endl;
        return;
    }
    long long b = a * B - 1;
    long long n2 = floor((double)A * b / B) - (double)A * floor((double)b / B);
    cout << (n < n2 ? n2 : n) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    solve(A, B, N);
    return 0;
}


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

int main()
{
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll count=0;
	for(int i=0;i<n-2;i++)
	{
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
		count++;
	}
	cout<<count<<endl;
}

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

#define MAX 1000000
int prime[MAX];

int main()
{
	int number,count=0;
	prime[0] = prime[1] = 0;

	for(int i=2;i<MAX;i++)
	{
		prime[i] = 1;
	}
	for(int i=2;i<1001;i++)
	{
		if(prime[i])
		{
			for(int j=2*i;j<MAX;j += i)
			{
				prime[j] = 0;
			}
		}
	}

	while(cin >> number)
	{
		count = 0;
		for(int i=2;i<=number;i++)
		{
			count += prime[i];
		}
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 5064
from collections import Counter
n, k , q = map(int, input().split())
qlist = [int(input()) for _ in range(q)]
count = Counter(qlist)

for i in range(1, n+1):
    damage = q - count[i]
    if damage < k:
        print('Yes')
    elif damage >= k:
        print('No')

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

int n;
char s[10000];

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    if (n == 1) {
      scanf("%s", s);
      printf("%d\n", (int)s[0] - '0');
      continue;
    }
    int command[1000], stack[1000], stackNum = 0; // command == 1 : add
    for (int i = 0; i < n; i++) {
      scanf("%s", s);
      int counter = 0;
      while (s[counter] == '.') counter++;
      char input = s[counter];
      if (counter < stackNum) {
        while (stackNum > counter) {
          stackNum--;
          if (command[stackNum] == 1) stack[stackNum] += stack[stackNum + 1];
          else stack[stackNum] *= stack[stackNum + 1];
        }
      }
      if (input == '*') {
        command[++stackNum] = 2;
        stack[stackNum] = 1;
      } else if (input == '+') {
        command[++stackNum] = 1;
        stack[stackNum] = 0;
      } else {
        if (command[stackNum] == 1) stack[stackNum] += (int) input - '0';
        else stack[stackNum] *= (int) input - '0';
      }
    }
    while (stackNum > 0) {
      stackNum--;
      if (command[stackNum] == 1) stack[stackNum] += stack[stackNum + 1];
      else stack[stackNum] *= stack[stackNum + 1];
    }
    printf("%d\n", stack[1]);
  }
}



Measured memory_bytes: 2764
#include <stdio.h>

long sqrt(long p){
  int i,a=0;
  long m=0;
  for(i=62;i>=0;i-=2){
    a=(a<<2)|((p>>i)&3);
    m<<=1;
    if(a-m-1>=0){
      a-=m+1;
      m|=2;
    }
  }
  return(m>>1);
}

int main(){
  long n,i;
  scanf("%ld",&n);
  for(i=sqrt(n);i>=1;i--){
    if(n%i==0) break;
  }
  printf("%ld",n/i+i-2);
  return(0);
}

Measured memory_bytes: 128
def d_xxor(N, K, A):
    # 参考: http://drken1215.hatenablog.com/entry/2019/02/03/224200
    ans = 0
    # N, K <= 10**12 < 2**40 なので、上限を40とする

    # Aの各要素を2進表記したとき、b番目のビットが立っているものは何個か？
    bit_stand = [len([1 for a in A if a & (1 << b) != 0]) for b in range(41)]

    for d in range(40, -2, -1):
        # d=-1のケースはX=Kのケースを意味する
        if d != -1 and (K & (1 << d)) == 0:
            continue

        tmp = 0
        for e in range(40, -1, -1):
            bit_mask = 1 << e

            # Aの各要素を2進表記したとき、e番目のビットが立っているものは何個か？
            num = bit_stand[e]

            # このビットがfに貢献する値を決める。
            if e > d:
                if K & bit_mask != 0:
                    tmp += bit_mask * (N - num)  # X_e=1とする
                else:
                    tmp += bit_mask * num  # X_e=0とする
            elif e == d:
                tmp += bit_mask * num  # このビットは0とする(解説pdf参照)
            else:
                # これを満たすビットについては、独立に決めていい。
                # よって、貢献する値が大きな方を選べばいい
                tmp += bit_mask * max(num, N - num)
        ans = max(ans, tmp)
    return ans

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(d_xxor(N, K, A))

Measured memory_bytes: 14984
n = int(input())

ab = [list(input().split()) for _ in range(n)]
jpy =0
btc =0

for i in range(n):
    if ab[i][1] =="JPY":
        jpy += float(ab[i][0])
    
    elif ab[i][1] =="BTC":
        btc += float(ab[i][0])

print (jpy + btc *380000.0)

Measured memory_bytes: 9092
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll ans(0);
	rep(i, n) {
		rep(j, n) {
			rep(k, n) {
				bool ok = true;
				if (a[i] == a[j] || a[j] == a[k] || a[k] == a[i])ok=false;
				int p, q, r;
				p = a[i];
				q = a[j];
				r = a[k];
				if (p >= q + r || q >= p + r || r >= p + q) {
					ok=false;
				}
				if(ok)++ans;
			}
		}
	}
	cout << ans/6;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s[n];
    int a[n],k=0,mx=0;
    map<string, int>mp;
    map<string, int>::iterator it;
    //pair<string, int>p;
    for(int i=0;i<n;i++)
    {
        //string s;
        cin>>s[i];
        mp[s[i]]++;
    }
    for(it=mp.begin();it!=mp.end();it++){
        mx = max(mx,it->second);

    }
    //int cnt=1;
    //sort(a,a+n);

    //cout<<cnt<<endl;
    for(it=mp.begin();it!=mp.end();it++)
    {
        if(it->second == mx){
            cout<<it->first<<endl;
        }
    }
}


Measured memory_bytes: 26752
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto nkq = readln.split.to!(int[]);
    auto N = nkq[0];
    auto K = nkq[1];
    auto Q = nkq[2];
    auto AS = readln.split.to!(int[]);

    auto res = long.max;
    foreach (x; AS) {
        auto as = AS.dup;
        size_t i;
        long[] cs;
        foreach (j, a; as) {
            if (a < x) {
                if (j-i >= K) {
                    sort(as[i..j]);
                    foreach (k; i..j-K+1) cs ~= as[k];
                }
                i = j+1;
            }
        }
        if (N-i >= K) {
            sort(as[i..$]);
            foreach (k; i..N-K+1) cs ~= as[k];
        }
        if (cs.length >= Q) {
            sort(cs);
            res = min(res, cs[Q-1] - x);
        }
    }
    writeln(res);
}

Measured memory_bytes: 7936
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

int X;

// Is n a power of b?
bool is_pow_of(int n, int b)
{
  while(true) {
    if (n == 1) return true;

    if (n % b == 0) n /= b;
    else return false;
  }
}

bool is_pow_num(int n)
{
  if (n == 1) return true;
  //min(n,32)
  REP(b,2,n) {
    // n がある bのべき乗ならば，
    if (is_pow_of(n, b)) return true;
  }
  return false;
}

int main()
{
  cin >> X;

  // 大きい方から探す
  for(int n = X; n > 0; --n) {
    // nがべき乗数かどうか？
    if (is_pow_num(n)) {
      cout << n << endl;
      break;
    }
  }


  return 0;
}


Measured memory_bytes: 256
S = input()
ans = 0
for i in range(2**(len(S)-1)):
    l = 0
    indices = [0]
    for j in range(len(S)-1):
        if (i >> j) & 1:
            ans += int(S[l:j+1])
            l = j+1
    ans += int(S[l:])
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    if(n % 2 == 0)
    {
        cout << (int) n / 2;
    }
    else
    {
        cout << (int) n / 2 + 1;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  double ans = 0;
  REP(i, n){
    double x;
    string u;
    cin >> x >> u;
    if(u == "BTC") x *= 380000;
    ans += x;
  }
  printf("%.10f\n", ans);
  return 0;
}

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

int main(){
	string s;
  	cin>>s;
  	int a=0;
  
  	if(s[0]=='1')a++;
   	if(s[1]=='1')a++;
   	if(s[2]=='1')a++;
  
  	cout << a<<endl;
  
  return 0;

}

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

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

  if (n >= 30) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int m = scan.nextInt();

		int[] refrigerator = new int[a];
		int[] microwave = new int[b];
		int[] refriNum = new int[m];
		int[] microNum = new int[m];
		int[] discount = new int[m];

		int anser = 1000000;

		for (int i = 0; i < a; i++) {
			refrigerator[i] = scan.nextInt();
		}
		for (int i = 0; i < b; i++) {
			microwave[i] = scan.nextInt();
		}
		for (int i = 0; i < m; i++) {
			refriNum[i] = scan.nextInt();
			microNum[i] = scan.nextInt();
			discount[i] = scan.nextInt();
		}

		//割引後の価格を求める
		for (int i = 0; i < m; i++) {
			int price = refrigerator[refriNum[i] - 1] + microwave[microNum[i] - 1] - discount[i];
			if (anser > price) {
				anser = price;
			}
		}

		Arrays.sort(refrigerator);
		Arrays.sort(microwave);

		if (anser > refrigerator[0] + microwave[0]) {
			anser = refrigerator[0] + microwave[0];
		}

		System.out.println(anser);

	}

}


Measured memory_bytes: 136904
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    private static final String REGIX_COMMA = ",";
    private static final int MAX_ANGLE = 180;
    private static final String EOF = "0,0";

    public static void main(String[] args) {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        try {
            String input = null;

            double x = 0;
            double y = 0;
            int angle = 90;

            while ((input = in.readLine()) != null && !EOF.equals(input)) {

                String[] data = input.split(REGIX_COMMA);
                int length = Integer.valueOf(data[0]);

                x += length * Math.cos(Math.toRadians(Integer.valueOf(angle)));
                y += length * Math.sin(Math.toRadians(Integer.valueOf(angle)));
                angle -= Integer.valueOf(data[1]);
            }

            System.out.println((int) x);
            System.out.println((int) y);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

Measured memory_bytes: 16932
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<String> s = nextCharArray();
		ArrayList<String> t = nextCharArray();
		int output = 0;
		for(int i = 0; i < s.size(); i++){
			if(s.get(i).equals(t.get(i))){
				output++;
			}
		}
		myout(output);
	}
	//Method addition frame start




	//Method addition frame end
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;

int n;
int a[100010];
vector<pii> vec;
int cur=-1000000;
int cnt;
int p,q,r,s,t;

int main() {
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n){
		if(cur==-1000000){
			cnt=1;
			cur=a[i];
		}else if(a[i]!=cur){
			vec.push_back(make_pair(cur,cnt));
			cur=a[i];
			cnt=1;
		}else ++cnt;
	}
	vec.push_back(make_pair(cur,cnt));
	
	for(int i=1;i+1<(int)vec.size();++i){
		if(vec[i].second>1){
			if(vec[i].first>vec[i-1].first&&vec[i].first>vec[i+1].first) ++p;
			else if(vec[i].first<vec[i-1].first&&vec[i].first<vec[i+1].first) ++q;
			else ++r;
		}else{
			if(vec[i].first>vec[i-1].first&&vec[i].first>vec[i+1].first) ++s;
			else if(vec[i].first<vec[i-1].first&&vec[i].first<vec[i+1].first) ++t;
		}
	}
	printf("%d %d %d %d %d\n",p,q,r,s,t);
}


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

int main(){
  int a, b, c;
  
  cin >> a >> b;
  
  if(a > 9 || b > 9) cout << -1 << endl;
  else{
    c = a * b;
    cout << c << endl;
  }
  
  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
const ll MOD=1e9+7;

vector<long long> inv,finv;
void COMinit(long long siz) {
    long long buf=5;
    inv.resize(siz+buf);
    finv.resize(siz+buf);

    finv[0]=finv[1]=1;
    inv[1]=1;

    for (int i = 2; i < siz+buf; i++){
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    long long ans=1;
    for(long long i = n; i >= n-k+1; i--) {
        ans*=i;
        ans%=MOD;
    }
    ans*=finv[k];
    return ans%MOD;
}
//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin >> n >> k;
    COMinit(2000);
    ll ans;
    for(int i = 1; i <= k; i++) {
        ans=COM(k-1,i-1)*COM(n-k+1,i)%MOD;
        cout << ans << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int l[] = new int[n];
    int d = 0;
    int i = 1;
    for (int cnt = 0; cnt < n; cnt++) {
      l[cnt] = sc.nextInt();
      d += l[cnt];
      if (d <= x) {
        i++;
      }
    }
    System.out.println(i);
    sc.close();
  }
}

Measured memory_bytes: 35760
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int int32_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l=0,int r=INT_MAX)
{return uniform_int_distribution<int>(l,r)(rng);}

template <typename T,typename G>
ostream& operator << (ostream& out, const pair<T,G> &a) 
{return out<<"( "<<a.x<<", "<<a.y<<")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out<<"[ ";for(const auto &i:a)out<<i<<", ";return out<<"]"<<endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out<<"{ ";for(const auto &i:a)out<<i<<", ";return out<<"}"<<endl;}

template <typename T,typename G>
ostream& operator << (ostream& out, const map<T,G> &a) 
{out<<"< ";for(const auto &i:a)out<<i<<", ";return out<<">"<<endl;}

template<typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
ostream&>::type operator<<(ostream& out, T(&a)[N])
{out<<"[ ";for(size_t i=0;i<N;++i)out<<a[i]<<", ";out <<"]"<<endl;return out;}

void debug_out(){cerr<<endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr<<(H)<<" ";debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr<<"#"<<#__VA_ARGS__<<":\n",debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	char c;
	cin>>c;
	c++;
	cout<<c;
	return 0;
}


Measured memory_bytes: 256
use std::io;
use std::io::{BufRead, Write};

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let n: usize = buf.trim_right().parse().unwrap();
    let s: Vec<_> = (0..n)
        .map(|_| {
            buf.clear();
            input.read_line(&mut buf).unwrap();
            buf.trim_right().as_bytes().to_owned()
        })
        .collect();
    let x_sum: usize = (0..n)
        .filter(|x_off| {
            (0..n).all(|x| (0..n).all(|y| s[(x + x_off) % n][y] == s[(y + x_off) % n][x]))
        })
        .map(|i| n - i)
        .sum();
    let y_sum: usize = (1..n)
        .filter(|y_off| {
            (0..n).all(|y| (0..n).all(|x| s[x][(y + y_off) % n] == s[y][(x + y_off) % n]))
        })
        .map(|i| n - i)
        .sum();
    writeln!(output, "{}", x_sum + y_sum).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "2
ab
ca
", "2\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "4
aaaa
aaaa
aaaa
aaaa
",
            "16\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "5
abcde
fghij
klmno
pqrst
uvwxy
",
            "0\n",
        );
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n,m;
    cin>>n>>m;
    set<int> rest;
    rep(i,1,m+1)rest.insert(i);
    vpii payday;
    rep(i,0,n){
        int a,b;
        cin>>a>>b;
        pii e;
        e.first=b;
        e.second=a;
        payday.push_back(e);
    }
    sort(payday.rbegin(),payday.rend());
    ll ans=0;
    rep(i,0,n){
        int pay=payday[i].first;
        int day=payday[i].second;
        auto pos=rest.lower_bound(day);
        if(pos!=rest.end()){
            rest.erase(pos);
            ans+=pay;
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 6136
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

typedef struct {
	int I;
	int from;
	int cost;
	vector<pair<int,int>> to;
} _node;

bool operator > (const _node& a,const _node& b) {
	return a.cost > b.cost;
}
class Dijkstra {
public:
	int start,fin;
	vector<_node> node;
	vector<int> path;
	priority_queue<_node,vector<_node>,greater<_node>> pque;
	void ds_init(int n) {
		node = vector<_node>(n);
		for (int i = 0;i < n;i++) {
			node[i].I = i;
			node[i].from = i;
			node[i].cost = INF;
		}
	}
	void dijkstra(int s,int ficost = 0) {
		node[s].cost = ficost;
		for (int i = 0;i < node[s].to.size();i++) {
			node[node[s].to[i].first].cost = node[s].to[i].second + node[s].cost;
			node[node[s].to[i].first].from = s;
			pque.push(node[node[s].to[i].first]);
		}
		while (!pque.empty()) {
			_node next = pque.top();
			pque.pop();
			if (next.cost > node[next.I].cost) continue;
			for (int i = 0;i < next.to.size();i++) {
				if (node[next.to[i].first].cost > next.cost + next.to[i].second) {
					node[next.to[i].first].cost = next.cost + next.to[i].second;
					node[next.to[i].first].from = next.I;
					pque.push(node[next.to[i].first]);
				}
			}
		}
	}
	void searchpath(int now) {
		if (node[now].from != now) {
			path.push_back(node[now].from);
			searchpath(node[now].from);
		} else {
			reverse(ALL(path));
			return;
		}
	}
};

bool solve() {
	int n,k; cin >> n >> k;
	if (k == 1) cout << 0 << endl;
	else cout << (n-(k-1)-1) << endl;
}

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

Measured memory_bytes: 256
N = int(input())

ans = 'Yes'
pos = {'x': 0, 'y': 0}
elapsed_t = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    t -= elapsed_t
    d = abs(x - pos['x']) + abs(y - pos['y'])
    if not (t % 2 == d % 2 and d <= t):
        ans = 'No'
        break
    pos['x'], pos['y'] = x, y
    elapsed_t += t

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
int r[N],c[N];
int mk[N];
vector<int>ed[N];
void solve(){
	int h,w;
	cin>>h>>w;
	int m;
	cin>>m;
	map<int,map<int,int> >mp;
	int maxr=0,maxc=0;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		mp[x][y]=1;
		r[x]++;
		c[y]++;
		maxr=max(maxr,r[x]);
		maxc=max(maxc,c[y]);
	}
	vector<int>rs;
	for(int i=1;i<=h;i++)if(r[i]==maxr)rs.pb(i);
	int ans=0;
	for(int i=1;i<=w;i++){
		if(c[i]==maxc)for(int j:rs){
			if(mp[j].find(i)==mp[j].end()){cout<<maxr+maxc<<"\n";return;}
		}
	}
	cout<<maxc+maxr-1<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 73288
#include<bits/stdc++.h>
using namespace std;
using lint = long int;

int N;
lint res = 0;
vector<int> A(200010);
priority_queue<int> pq;

int main(){
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    pq.push(A[0]);
    for(int i = 1; i < N; i++){
        int val = pq.top(); pq.pop();
        res += val;
        pq.push(A[i]); pq.push(A[i]); //間隔をA[i]の両端に
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5068
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(int argc, const char * argv[]) {
    
    int i=0;
    
    int x[100] = {0};
    int y[100] = {0};
    int n=0;
    double p1=0;    //p=1のときの距離
    double p2=0;    //p=2のときの距離
    double p3=0;    //p=3のときの距離
    double p4=0;    //p=♾のときの距離
    
    float inf = INFINITY;
    
    scanf("%d", &n);
    
    for (i=0; i<n; i++) {
        scanf("%d", &x[i]);
    }
    for (i=0; i<n; i++) {
        scanf("%d", &y[i]);
    }
    
    //p1
    for (i=0; i<n; i++) {
        p1 += pow(abs(x[i]-y[i]), 1);
    }
    p1 = pow(p1, 1);

    
    //p2
    for (i=0; i<n; i++) {
        p2 += pow(abs(x[i]-y[i]), 2);
    }
    p2 = pow(p2, 0.5);

    
    //p3
    for (i=0; i<n; i++) {
        p3 += pow(abs(x[i]-y[i]), 3);
    }
    p3 = pow(p3, 1.0/3);
    
    //p4
    for (i=0; i<n; i++) {
        if (p4 < abs(x[i]-y[i])) {
            p4 = abs(x[i]-y[i]);
        }
    }
    
    printf("%lf\n", p1);
    printf("%lf\n", p2);
    printf("%lf\n", p3);
    printf("%lf\n", p4);

    return 0;
}


Measured memory_bytes: 2104
#include<stdio.h>

int main(int argc, char const *argv[]) {
  int A, B;

  scanf("%d %d", &A, &B);

  if (A % 2 == 1 && B % 2 == 1){
    puts("Yes");
  }
  else{
    puts("No");
  }



  return 0;
}


Measured memory_bytes: 128
#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; ll k;
  cin >> s >> k;
  int n = s.size();
  
  if(n==1){
    cout << k/2 << endl;
    return 0;
  }
  bool same = true;
  for(int i=1; i<n; i++){
    if(s[i-1] != s[i]) same = false;
  }
  if(same){
    cout << (n*k)/2 << endl;
    return 0;
  }
  
  ll tmp=0, cnt=0;
  char pre = ' ';
  rep(i,n){
    if(s[i]==pre){
      tmp++;
      if(tmp%2==1) cnt++;
    }
    else tmp=0;
    pre = s[i];
  }
  string ss = s+s;
  ll cnt2=0;
  tmp = 0; pre = ' ';
  rep(i,2*n){
    if(ss[i]==pre){
     tmp++;
     if(tmp%2==1) cnt2++;
    }
    else tmp=0;
    pre = ss[i];
  }
  ll ans=0;
  if((cnt*2)==cnt2){
    ans = cnt*k;
  }
  else{
    ll d = (cnt*2)-cnt2;
    ans = cnt*k + (k-1);
  }
  cout << ans << endl;
  return 0;
}

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

ll gcd(ll m, ll n) {//最大公約数
    if (n == 0)return m;
    return gcd(n, m % n);
}//gcd

ll lcm(ll m, ll n) {//最小公倍数
    return m / gcd(m, n) * n;
}

int main(){
  int n;
  cin>>n;
  ll ans=1;
  rep(i,n){
    ll t; cin>>t;
    ans=lcm(t,ans);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3640
#include<stdio.h>
 
int main()
{
	char s[3][3],a;
	int i,j;
	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
		scanf("%c",&s[i][j]);
		}
		scanf("%c",&a);	
	}
		
			printf("%c%c%c\n",s[0][0],s[1][1],s[2][2]);
	
 
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#define nmax 100001

using namespace std;
ifstream fin("p.in");
ofstream fout("p.out");

int n,k;
vector<vector<int>>vec;

int main()
{
    cin>>n;
    for(int i=0; i<n; i++)
        {
            vector<int>v;
            for(int j=1; j<=3; j++)
                {
                    int x;
                    cin>>x;
                    v.push_back(x);
                }
            vec.push_back(v);
        }

    vector<long long>mem(2*n,-1);

    vector<vector<int>> dp(n + 1, vector<int> (3, 0));

    for(int i=1; i<=n; i++)
        {
            for(int j=0; j<3; j++)
                {
                    if(j==0)
                        dp[i][j]=vec[i-1][j]+max(dp[i-1][1],dp[i-1][2]);
                    if(j==1)
                        dp[i][j]=vec[i-1][j]+max(dp[i-1][0],dp[i-1][2]);
                    if(j==2)
                        dp[i][j]=vec[i-1][j]+max(dp[i-1][0],dp[i-1][1]);
                }
        }

    /*for(int i=1; i<=n; i++)
        {   for(int j=0; j<3; j++)
                fout<<dp[i][j]<<" ";
            fout<<endl;
        }*/
    int mx=0;
    for(int i=0; i<3; i++)
        mx=max(mx,dp[n][i]);

    cout<<mx;
    return 0;
}


Measured memory_bytes: 13104
from collections import *
from heapq import *
import sys

sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]
dij = [(1, 0), (-1, 0), (0, 1), (0, -1)]

class mint:
    def __init__(self, x):
        self.__x = x % md

    def __str__(self):
        return str(self.__x)

    def __neg__(self):
        return mint(-self.__x)

    def __add__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x + other)

    def __sub__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x - other)

    def __rsub__(self, other):
        return mint(other - self.__x)

    def __mul__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * other)

    __radd__ = __add__
    __rmul__ = __mul__

    def __truediv__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * pow(other, md - 2, md))

    def __rtruediv__(self, other):
        return mint(other * pow(self.__x, md - 2, md))

    def __pow__(self, power, modulo=None):
        return mint(pow(self.__x, power, md))

md = 10**9+7

def main():
    ans=mint(0)
    n=II()
    aa=LI()
    for i in range(61):
        cnt1=0
        for a in aa:cnt1+=a>>i&1
        ans+=(1<<i)*cnt1*(n-cnt1)
    print(ans)

main()


Measured memory_bytes: 123084
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}




signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s == "abc"){
        cout << "Yes\n";
    }
    else cout << "No\n";
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>

using ll = long long;

int n;
ll h[200005];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%lld", h + i);
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        if (h[i] >= h[i - 1]) continue;
        ans += h[i - 1] - h[i];
        h[i] = h[i - 1];
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 4788
#include <iostream>
using namespace std;
 int main(){
	 int l,a,b,c,d;
	 cin>>l>>a>>b>>c>>d;
	 int k,s;
	 if(a%c==0)k=a/c;
	 else k=a/c+1;
	 if(b%d==0)s=b/d;
     else s=b/d+1;
     int ma;
     if(k<s)ma=s;
     else ma=k;
     cout<<l-ma<<endl;
 return 0;
 }


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;
vector<int> A,B;
int N,M;

void dfs(int v){
    reached[v] = true;
    for(int i=0;i<N;i++){
        if(graph[v][i] == false) continue;
        if(reached[i]) continue;
        dfs(i);
    }
}

int main(){
    cin >> N >> M;
    graph = vector<vector<bool>>(50,vector<bool>(50,false));
    reached = vector<bool>(50);
    A = vector<int>(50);
    B = vector<int>(50);
    for(int i=0;i<M;i++){
        cin >> A[i] >> B[i];
        A[i]--;B[i]--;
        graph[A[i]][B[i]] = graph[B[i]][A[i]] = true;
    }

    int ans = 0;
    for(int i=0;i<M;i++){
        graph[A[i]][B[i]] = graph[B[i]][A[i]] = false;
        for(int j=0;j<N;j++) reached[j] = false;
        dfs(0);
        bool bridge = false;
        for(int j=0;j<N;j++){
            if(reached[j] == false){
                bridge = true;
                break;
            }
        }
        if(bridge) ans++;
        graph[A[i]][B[i]] = graph[B[i]][A[i]] = true;        
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
int main(){
	int h,w,hi,wi;
	while (1){
		scanf("%d %d",&h,&w);
		if (h == 0) break;
		for (hi=0; hi<h; hi++){
			for (wi=0; wi<w; wi++)
				printf("#");
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

ll const inf = 1e18;

struct MCMF{
	int sr, sn;
	vector<ll> d;
	vector<int> dr;
	vector<vector<int> > g;
	
	struct ED{
		int v, cp;
		ll cs, cc;
		ED(){}
		ED(int a, int b, ll c):v(a), cp(b), cs(c), cc(c) {}
	};
	
	vector<ED> ed;
	
	pair<int, ll> kl(int v, int cp = 1e9){
		if (v == sn)return make_pair(cp, 0);
		int fl = 0;
		ll cs = 0;
		for (int t: g[v])if (ed[t].cp){
			int u = ed[t].v;
			if (dr[v] + 1 != dr[u] || ed[t].cc)continue;
			pair<int, ll> an = kl(u, min(ed[t].cp, cp - fl));
			fl += an.first;
			cs += ed[t].cs * an.first + an.second;
			ed[t].cp -= an.first;
			ed[t ^ 1].cp += an.first;
			if (fl == cp)break;
		}
		if (fl < cp)dr[v] = 0;
		return make_pair(fl, cs);
	}
	
	void upd() { f(i, 0, g.size())for (int t: g[i])ed[t].cc += d[i] - d[ed[t].v]; }
	
	void di(){
		f(i, 0, d.size())d[i] = inf;
		d[sr] = 0;
		f(i, 0, dr.size())dr[i] = 0;
		priority_queue<pair<ll, int> > q;
		q.push(make_pair(0, sr));
		while (!q.empty()){
			ll c = -q.top().first;
			int v = q.top().second;
			q.pop();
			if (c > d[v])continue;
			for (int t: g[v])if (ed[t].cp){
				int u = ed[t].v;
				ll nc = c + ed[t].cc;
				if (nc < d[u])dr[u] = dr[v] + 1, q.push(make_pair(-(d[u] = nc), u));
			}
		}
		upd();
	}
	
	pair<int, ll> mcmf(int s, int t){
		sr = s, sn = t;
		d = vector<ll>(g.size(), inf);
		dr = vector<int>(g.size(), 1e9);
		d[sr] = dr[sr] = 0;
		f(it, 1, g.size())f(i, 0, g.size())if (d[i] != inf)for (int t: g[i])if (ed[t].cp){
			int u = ed[t].v;
			ll nc = d[i] + ed[t].cs;
			if (nc < d[u])d[u] = nc, dr[u] = dr[i] + 1;
		}
		upd();
		int fl = 0;
		ll cs = 0;
		while (d[sn] != inf){
			pair<int, ll> t = kl(sr);
			fl += t.first;
			cs += t.second;
			di();
		}
		return make_pair(fl, cs);
	}
	
	void aded(int a, int b, int w1 = 1, int cst = 0, int w2 = 0){
		g.resize(max((int)g.size(), max(a, b) + 1));
		g[a].push_back(ed.size());
		ed.emplace_back(b, w1, cst);
		g[b].push_back(ed.size());
		ed.emplace_back(a, w2, -cst);
	}
};

int const NN = 2000;
pair<int, int> p[NN];
int dp[NN], n, tp[4];
 
int main(){
	scanf("%d", &n);
	f(i, 0, n)scanf("%d%d%d", &p[i].first, &p[i].second, dp + i);
	f(i, 0, n)scanf("%d%d%d", &p[i + n].first, &p[i + n].second, dp + i + n);
	n <<= 1;
	int sr = n, sn = n | 1;
	f(i, 0, 4)tp[i] = n + 2 + i;
	n >>= 1;
	MCMF mf;
	f(i, 0, n)mf.aded(sr, i, dp[i]);
	f(i, n, n << 1)mf.aded(i, sn, dp[i]);
	f(i, 0, n)f(j, 0, 4)mf.aded(i, tp[j], 1e9, ((j & 1) ? p[i].first : -p[i].first) + ((j & 2) ? p[i].second : -p[i].second));
	f(i, n, n << 1)f(j, 0, 4)mf.aded(tp[j], i, 1e9, ((j & 1) ? -p[i].first : p[i].first) + ((j & 2) ? -p[i].second : p[i].second));
	printf("%lld\n", -mf.mcmf(sr, sn).second);
}

Measured memory_bytes: 1340
import sys
def input(): return sys.stdin.readline().strip()
N,M=map(int,input().split())
P=[list(map(int,input().split())) for i in range(M)]
inf=10**15
c=[[] for i in range(N)]
for i,j,w in P:
    c[i-1].append((j-1,w))
    c[j-1].append((i-1,-w))
d=[inf]*N
v=[0]*N
a=0
import sys
sys.setrecursionlimit(10**7)
def dfs(p,v,d):
    for n,w in c[p]:
        if v[n]==0:
            d[n]=d[p]+w
            v[n]=1
            if dfs(n,v,d)==-1:
                return -1
        elif d[p]+w!=d[n]:
            return -1
    return 0
s=0
while True:
    d[s]=0
    v[s]=1
    a=dfs(s,v,d)
    if a<0:
        break
    try:
        s=d.index(inf,s)
    except ValueError:
        break
print(['Yes','No'][a])

Measured memory_bytes: 162340
n, x, y = map(int, input().split())
ans = [0 for i in range(n)]
x -= 1
y -= 1
for i in range(n):
    for j in range(i+1, n):
        cand1 = j - i
        cand2 = abs(x - i) + 1 + abs(y-j)
        ans[min(cand1, cand2)] += 1

for item in ans[1:]:
    print(item)  

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int n;
  cin >> n;

  cout << n / 3 << endl;
}


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

int main(){
  int a, b; cin >> a >> b;
  if (a == b) cout << a+b;
  else{
    if (a > b) cout << 2*a - 1;
    else cout << 2*b - 1;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256