akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <string>
#include <cmath>
#include <iomanip>
#include <cstdio>
using namespace std;

typedef long long ll;

const int maxn = 1e5+5;
int N,M;
int fa[maxn];
int size[maxn];
ll ans[maxn];
int l[maxn];
int r[maxn];

int find(int x)
{
    return fa[x] == x?x:fa[x]= find(fa[x]); //这里一开始写错了，写成了x = find。。
}

void join(int a, int b)
{
    a = find(a), b = find(b);
    if(a != b)
    {
        size[a] += size[b];
        size[b] = 0;
       fa[b] = a;
    }
}
int main(){
	cin>>N>>M;

	for(int i=0;i<maxn;i++)
		fa[i] = i,size[i]=1;
	 memset(ans, 0, sizeof(ans));
		
	for(int i=1;i<=M;i++)
		scanf("%d%d", &l[i], &r[i]);
	ll cnt = N;
	ans[M+1] = cnt*(cnt-1)/2;
	for(int i = M;i>=2;i--){
		int x = find(l[i]);
		int y = find(r[i]);
		if(x!=y){
			ans[i] = ans[i+1]-size[x]*size[y];
			join(l[i],r[i]);
		}
		else 
			ans[i] = ans[i+1];
	}
	
	for(int i=2;i<=M+1;i++)
		  printf("%lld\n", ans[i]);
	
	return 0;
}

Measured memory_bytes: 3712
#import time
#t1 = time.time()
h,n = map(int,input().split())
ab = [[int(i) for i in input().split()] for j in range(n)]

dp = [[10**18 for i in range(h+1)] for j in range(n)]

for i in range(n):
    dp[i][0] = 0
    
for i in range(1,h+1):
    dp[0][i] = ((i+ab[0][0]-1) // ab[0][0]) * ab[0][1]

for i in range(1,n):
    for j in range(1,h+1):
        dp[i][j] = min(dp[i-1][j],dp[i][max(0,j-ab[i][0])]+ab[i][1])

print(dp[n-1][h])

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

int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << min(a,b) + min(c,d) << endl;
	return 0;
}

Measured memory_bytes: 256
/*
DP(動的計画法) を使う.
DP[集合S] = Sを全て開けれる鍵の買い方の最小コスト
というDPを考える. これで状態を持つ.
Keyは集合
*/

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

const int INF = 1001001001;

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> key;  // 鍵. {状態Sを2進数で表したもの, Sを全て開けられる鍵の買い方の最小コスト}
    rep (i, m){
        int a, b;
        cin >> a >> b;
        int s = 0;  // 集合S
        rep(j, b) {  // 開けれる宝箱の集合
            int c;
            cin >> c;
            --c;
            s |= 1<<c;  // |= : 論理和(OR). 1<<c: 例 1<<3 は 1000 になる. つまりc個左にシフトさせている.
        }
        key.emplace_back(s, a);  // {集合S, 鍵のコスト}
    }

    // DPテーブル
    vector<int> dp(1<<n, INF);  // 2^n
    // 初期化
    dp[0] = 0;
    rep(s, 1<<n) {  // 遷移元の状態をsとする
        rep(i, m){  // 鍵を全部試す
            int t = s | key[i].first;  // 遷移先
            int cost = dp[s]+key[i].second;  // 遷移先のコスト
            dp[t] = min(dp[t], cost);  // DPテーブル更新
        }
    }

    int ans = dp.back();
    if (ans == INF) ans = -1;  // 全ての宝箱を開けられない場合
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	int a, b;

	scanf("%d %d", &a, &b);

	if (a > b)
		printf("a > b\n");
	else if (a < b)
		printf("a < b\n");
	else
		printf("a == b\n");

	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#define INF 100000000000
using namespace std;
int main(void){
  int N;
  std::cin >> N;
  int h[N];
  for(int i = 0; i < N; i++) std::cin >> h[i]; 
  int dp[N];
  for(int i = 0; i < N; i++) dp[i] = INF;
  dp[0] = 0;
  for(int i = 0; i < N; i++){
  for(int j = 1; j <= min(2, N-i-1); j++){
    dp[i+j] = min(dp[i+j], dp[i]+ abs(h[i]-h[i+j]));
  }
  }
  cout << dp[N-1] << endl;
}



Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc = new Scanner(System.in);
	public void run(){
		while(true){
			int m = sc.nextInt();
			int nmin = sc.nextInt();
			int nmax = sc.nextInt();
			if(m == 0 && nmin == 0 && nmax == 0) break;
			calc(m, nmin, nmax);
		}
	}
	public void calc(int m, int nmin, int nmax){
		int diff = 0;
		int ans = 0;
		int[] p = new int[200];
		for(int i = 0; i < m; i++){
			p[i] = sc.nextInt();
		}
		for(int i = nmax; i > nmin -1; i--){
			if(p[i-1] - p[i] > diff){
				diff = p[i-1] - p[i];
				ans = i;
			}
		}
		System.out.println(ans);
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
}

Measured memory_bytes: 56260
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.InputStream;

import java.io.PrintWriter;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);

        final int N = nextInt();
        final int M = nextInt();

        boolean[] S = new boolean[N];
        boolean[] E = new boolean[N];

        for (int i = 0; i < M; i++) {
            int f = nextInt();
            int s = nextInt();

            if (f == 1) S[s] = true;
            else if (s == N) E[f] = true;
        }

        String ans = "IMPOSSIBLE";

        for (int i = 0; i < N; i++) {
            if (S[i] && E[i]) {
                ans = "POSSIBLE";
                break;
            }
        }

        out.println(ans);

        out.flush();
    }

    // FastScanner start
    static final InputStream in = System.in;
    static final byte[] buffer = new byte[1024];
    static int ptr = 0;
    static int buflen = 0;
    static 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;
    }
    static int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    static boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    static 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();
    }
    static 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();
        }
    }
    static int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    static double nextDouble() {
        return Double.parseDouble(next());
    }
    // FastScanner end
}


Measured memory_bytes: 23824
struct Read<R: std::io::BufRead> {
    stdin: R,
    v: Vec<String>,
    i: usize,
}
impl<R:std::io::BufRead> Read<R> {
    pub fn new(stdin: R) -> Self {
        Read{
            stdin: stdin,
            v: Vec::new(),
            i: 0,
        }
    }
    pub fn read_until<T: std::str::FromStr>(&mut self) -> T {
        if self.i == self.v.len() {
            self.read_line();
        }
        let elem = &self.v[self.i];
        self.i += 1;
        elem.parse().unwrap_or_else(|_| panic!())
    }
    #[allow(dead_code)]
    pub fn read_i32(&mut self) -> i32 {
        if self.i == self.v.len() {
            self.read_line();
        }
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_string(&mut self) -> String {
        if self.i == self.v.len() {
            self.read_line();
        }
        let elem = &self.v[self.i];
        self.i += 1;
        elem.to_owned()
    }
    pub fn read_line(&mut self) {
        self.i = 0; self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        let buf = buf.trim().to_owned();
        let mut ws = buf.split_whitespace();
        loop {
            let x = ws.next();
            if x.is_none() {
                break;
            }
            let x = x.unwrap().to_owned();
            self.v.push(x);
        }
    }
}
fn main() {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let read = Read::new(stdin);
    solve(read);
}

fn solve<R: std::io::BufRead>(mut r: Read<R>) {
    let mut n:i32 = r.read_until();
    for x in 1..n+1 {
        let t = x as f32 * 1.08;
        if t as i32 == n {
            println!("{}", x);
            return;
        }
    }
    println!(":(");
}

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

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

        private static object GetResult()
        {
            var abcd = ReadText().ToCharArray()
                .Select(x => int.Parse(x.ToString()))
                .ToArray();
            for (var i = 0; i < Math.Pow(2, 3); i++)
            {
                var ans = abcd[0];
                var output = abcd[0].ToString();
                for (var j = 1; j <= 3; j++)
                {
                    if (((i >> j - 1) & 1) == 1)
                    {
                        ans += abcd[j];
                        output += "+";
                    }
                    else
                    {
                        ans -= abcd[j];
                        output += "-";
                    }
                    output += abcd[j].ToString();
                }
                if (ans == 7)
                {
                    return output + "=7";
                }
            }
            return null;
        }

        #region Console.Read

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

        #endregion
    }
}


Measured memory_bytes: 28428
#include <stdio.h>

int main(void){
  char s[101],p[101];
  int i,j,sn=0,pn=0,t;

  scanf("%s %s",s,p);

//文字数カウント
  while(s[sn] != '\0') sn++;
  while(p[pn] != '\0') pn++;

  for(i=0;i<sn;i++){
    t=1;
    for(j=0;j<pn;j++)
      if(s[(i+j)%sn] != p[j]) t=0;
    if(t) break;
  }

  if( t )
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}


Measured memory_bytes: 2148
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>

typedef long long ll;
typedef unsigned long long ull;

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

inline int read() {
    int res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}

int main() {
    ll n, a, b;
    std::cin >> n >> a >> b;
    ll upperBound = b * (n - 1) + a;
    ll lowerBound = a * (n - 1) + b;
    if (lowerBound > upperBound) {
        puts("0");
    } else {
        std::cout << upperBound - lowerBound + 1 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i = a; i<n; i++)
#define per(i,a,n) for (int i = n-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define all(now) (now).begin(),(now).end()
#define fi first
#define se second
#define SZ(now) ((int)(now).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod = 1000000007;
inline int read(int &n){char c=getchar();int x=0,f=1;while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+(c-'0');c=getchar();}return n = x*f;}
ll powmod(ll a,ll b,ll mod) {ll res = 1; a%=mod; assert(b>=0); for(;b; b>>=1){if(b&1)res = res*a%mod; a = a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int N = 2e5+7;
int T,n,m;
ll a[N];
int main()
{
    //ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    while(~scanf("%d",&n))
    {
        rep(i,1,n+1){
            ll x;
            scanf("%lld", &x);
            a[i] = x-i;
        }
        sort(a + 1, a + 1 + n);
        ll b = a[n / 2+1];
        if(n&1==0) {
            b = (b + a[n / 2]) / 2;
        }

        // printf("b:%d\n", b);
        ll ans = 0;
        rep(i,1,n+1){
            ans += abs(a[i] - b);
        }
        printf("%lld\n", ans);
    }
    return 0;
}

/*

2 2 3 5 5
1 0 0 1 0

6 5 4  3  2  1
5 3 1 -1 -3 -5
5 3 1 1 3 5 = 18

1  1  1  1  2  3  4
0 -1 -2 -3 -3 -3 -3
3 2  1 0 0 0 0

*/

Measured memory_bytes: 1792
// And in the end, the love you take is equal to the love you make.
//                      Paul McCartney (the Beatles). The End. Abbey Road.

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ii = pair<int, int>;
#define fi first
#define se second
#define mp make_pair

const size_t N = 2000 + 5;

int n, mn[N];
char a[N], b[N];
bitset<N> bs[N];
vector<ii> ne[N];

void prep() {
    scanf("%s%s", a, b);
    n = strlen(a);
    assert(n == strlen(b));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            bs[i][j] = b[(i + j) % n] == '1';
        }
    }
    for (int i = 0; i < n; ++i) {
        mn[i] = 1e9;
        for (int j = 0; j < n; ++j) {
            if (bs[j][i]) {
                mn[i] = j;
                break;
            }
        }
    }
    bitset<N> cur;
    for (int j = 0; j < n; ++j) {
        if (bs[0][j]) {
            ne[0].emplace_back(mn[j], j);
            cur[j] = 1;
        }
    }
    for (int i = n - 1; i > 0; --i) {
        for (int j = 0; j < n; ++j) {
            if (!cur[j] && bs[i][j]) {
                ne[i].emplace_back(mn[j], j);
                cur[j] = 1;
            }
        }
    }
}

int get(int a, int b) {
    return min((b + n - a) % n, (a + n - b) % n);
}

void solve() {
    int ans = 1e9;
    for (int i = 0; i < n; ++i) {
        bitset<N> need;
        set<ii> s;
        int diff = 0, j, l, r;
        for (j = 0; j < n; ++j) {
            need[j] = a[j] == '1' && b[(i + j) % n] == '0';
            if (need[j]) {
                s.emplace(mn[j], j);
            }
            diff += a[j] != b[(i + j) % n];
        }
        for (r = 0; r < n; ++r) {
            for (auto &pr: ne[(n - r) % n]) {
                auto it = s.find(pr);
                if (it != s.end()) {
                    s.erase(it);
                }
            }
            l = s.empty() ? 0 : s.rbegin()->fi;
            if (l < 1e9) {
                ans = min(ans, r + r + l + diff + get(i, l));
                ans = min(ans, l + l + r + diff + get(i, (n - r) % n));
            }
        }
    }
    if (ans == 1e9) {
        puts("-1");
    } else {
        printf("%d\n", ans);
    }
}

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


Measured memory_bytes: 896
#include<iostream>
#include<vector>

using namespace std;

typedef vector<int>  v;

int main(){
  int n,c;
  vector<v> stc;
  cin >> n >> c;
  for(int i = 0; i < n; i++){
    int x,y,z;
    cin >> x >> y >> z;
    v a;
    a.push_back(x); a.push_back(y); a.push_back(z);
    stc.push_back(a);
  }
  int p[200002] = {};
  for(int i = 0; i < c ; i++){
    int tt[200002] = {};
    for(int j = 0; j < n; j++) if(stc[j][2] == i+1) tt[stc[j][0]*2-1]++, tt[stc[j][1]*2]--;
    for(int j = 1; j < 200002 ; j++) tt[j] += tt[j-1];
    for(int j = 0; j < 200002 ; j++) if(tt[j] > 0) p[j]++;
  }
  int max = 0;
  for(int now = 1 ; now < 200002 ; now++){
    if(max < p[now]) max = p[now];
  }
  cout << max << endl;
}


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

int main() {
 vector<int> kazu(3);
  cin >> kazu[0] >> kazu[1] >> kazu[2];
  sort(kazu.begin(),kazu.end());
  int count = 0;
 for(int i = 0; i < 2; i++){
   if(kazu.at(i) == kazu.at(i+1)){
     count++;
   }
 }
 if(count == 1) cout << "Yes" << endl;
 else cout << "No" << endl;
}

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

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

    int n, d;
    cin >> n >> d;
    int ans = (n + d * 2) / (d * 2 + 1);
    cout << ans;
    return 0;
}


Measured memory_bytes: 3632
package main

import (
	"fmt"
)

func main() {
	var n, d, x int
	fmt.Scan(&n, &d, &x)

	c := 0
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		c += (d-1)/a + 1
	}

	fmt.Println(x + c)

}


Measured memory_bytes: 1772
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		long mod = (long)(1e9+7);
		Scanner input = new Scanner(System.in);
		String x = input.next();
		System.out.println(x.equals("ABC")?"ARC":"ABC");
	}
}

Measured memory_bytes: 26992
#include<stdio.h>
int main(void){
int W,H,x,y,r;

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

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

Measured memory_bytes: 584
using System;

namespace Csharp_ITP1 {
    class ITP1_1_C {
        static void Main() {
            string[] c = Console.ReadLine().Split();
            var a = double.Parse(c[0]);
            var b = double.Parse(c[1]);
            Console.Write(a * b + " ");
            Console.WriteLine(2 * (a + b));
        }
    }
}


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

long long po(long long a, long long b)
{
  if (a > b) swap(a, b);
  if (b % a == 0){
    return b * 2 - a;
  }

  return (2 * (b / a) * a + po(a, b % a));
}

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

  cout << n + po(x, n - x) << endl;
}



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

int main() {
  int n = 0, tmp0 = 0, tmp1 = 0;
  int tmp2 = 0, tmp3, out1 = 0, out2 = 0;
  int a[100];
  scanf("%d", &n);
  while (n) {
    for (tmp3=0;tmp3<100;tmp3++) a[tmp3] = 0;
    tmp0 = 0, out2 = 0;
    while (tmp0 < n) {
      tmp1 = 0, out1 = 0;
      while (tmp1 < n) {
        scanf("%d", &tmp2);
        a[tmp1] += tmp2;
        printf("%5d", tmp2);
        out1 += tmp2;
        tmp1++;
      }
      printf("%5d\n", out1);
      a[tmp1] += out1;
      tmp0++;
    }
    tmp0 = 0;
    while (tmp0 < n) {
      printf("%5d", a[tmp0]);
      tmp0++;
    }
    printf("%5d\n", a[tmp0]);
    scanf("%d", &n);
  }
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
using namespace std;
int n,banyak[100010],total,maks=0,a;
int main() {
cin>>n;
for(int i=1;i<=n;i++) {
	cin>>a;
	banyak[a]++;
}
for(int i=1;i<=100000;i++) {
	total=banyak[i]+banyak[i+1]+banyak[i-1];
	if(maks<total) {
		maks=total;
	}
}
cout<<maks<<endl;

}


Measured memory_bytes: 3952
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;


int main(){
   int N; cin >> N;
   vector<ll> x(N),y(N),h(N);
   rep(i,N){
      cin >> x[i] >> y[i] >> h[i];
   }
   ll ans1 = 0;
   ll ans2 = 0;
   ll ans3 = 0;
   rep(i,101){
      rep(j,101){
         ll H = 0;
         rep(k,N){
            if(h[k] != 0){
               H = h[k] + abs(x[k]-i) + abs(y[k]-j);
               break;
            }
         }
         bool ok = true;
         rep(k,N){
            if(h[k] != 0){
               if(h[k] + abs(x[k]-i) + abs(y[k]-j) != H) ok = false; 
            }
            else{
               if(abs(x[k]-i) + abs(y[k]-j) < H) ok = false;
            }
         }
         if(ok){
            ans1 = i;
            ans2 = j;
            ans3 = H;
         }
      }
   }
   cout << ans1 << " " << ans2 << " " << ans3 << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

#define PI 4*atan(1)

int main(){
  string s;
  int cnt = 0;
  while(cin >> s){
    string tmp;
    tmp = s;
    reverse(s.begin(), s.end());
    if(tmp == s){
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

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

    cout<<min(a*n,b)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 4000000000000000037
#define INF 1000000007
//#define MOD 1000000007
#define PI (acos(-1))
#define EPS 1e(-9);
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;

    ll A[N],B[N+1];

    B[0]=0;

    rep(i,N){
        cin>>A[i];
        B[i+1]=B[i]+A[i];
        B[i+1]%=M;
    }

    map<ll,ll> ct;
    rep(i,N+1){
       ++ct[B[i]]; 
    }

    ll ans=0;

    for(auto x:ct){
        ll now=x.second;
        ans+=(now*(now-1))/2;
    }

    cout<< ans<<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    int n, m;
    cin >> n >> m;
    vector<float> a(n);
    rep(i, n) cin >> a[i];

    sort(a.begin(), a.end(), greater<int>());
    
    float x = 0;
    rep(i, n) x += a[i];
    x /= (4*m);

    if(a[m-1] >= x) cout << "Yes" << endl; 
    else cout << "No" << endl;


    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 count = 0;
    		int ans = 0;
    		
    		for (int i = 105; i <= N; i++) {
    			
    			for (int j = 1; j <= i; j++) {
    			
    			if (i % 2 == 0) {
    				break;
    			}
    			
    			if (i % j == 0) {
    				count++;
    			}
    			
    		    }
    			
    			if (count == 8) {
    				ans++;
    			}
    			
    			count = 0;
    		}
    		
    		System.out.println(ans);
    		
    	}
    }

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  for(ll i = 0; i < n; i++) cin >> h[i];
  sort(all(h));

  ll ans = INF;
  for(ll i = k-1; i < n; i++){
    //cout << h[i]-h[i-k+1] << endl;
    ans = min(ans, h[i]-h[i-k+1]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#define mafuu signed
#define Chino main

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>

#define maxn 2005
#define inf 0x3f3f3f3f
#define px putchar
#define pn px('\n')
#define ps px(' ')
#define pd puts("======================")
#define pj puts("++++++++++++++++++++++")

const int mod = 924844033;

using namespace std;

inline int read(){
	int x=0,y=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')y=1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return y?-x:x;
}
template<typename T>
inline T read(){
	T x=0;
	int y=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')y=1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return y?-x:x;
}
int f[maxn],c[maxn][maxn],g[maxn][maxn][3],fac[maxn]={1},n,m,ans;
inline long long pow1(int x){return x&1?-1ll:1ll;}
mafuu Chino(){
	n=read(),m=read();
	for(register int i=1;i<=n;++i)fac[i]=1ll*fac[i-1]*i%mod;
	if(!m){
		c[0][0]=1;
		for(register int i=1;i<=n;++i){
			c[i][0]=1;
			for(register int j=1;j<=i;++j)
				c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
		}
		for(register int i=0;i<=n;++i)
			(ans+=pow1(i)*c[n][i]*fac[n-i]%mod)%=mod;
		printf("%d\n",(ans+mod)%mod);
		return 0;
	}
	for(register int i=1;i<=min(m<<1,n);++i){
		g[i][0][2]=1;
		if(i-m>0)g[i][1][0]=1;
		if(i+m<=n)g[i][1][1]=1;
	}
	for(register int i=(m<<1)+1;i<=n;++i){
		int x=i-(m<<1);
		for(register int j=0;j<=n;++j){
			if(j&&i-m>0)g[i][j][0]=(g[x][j-1][0]+g[x][j-1][2])%mod;
			if(j&&i+m<=n)g[i][j][1]=((g[x][j-1][0]+g[x][j-1][1])%mod+g[x][j-1][2])%mod;
			g[i][j][2]=((g[x][j][0]+g[x][j][1])%mod+g[x][j][2])%mod;
		}
	}
	f[0]=1;
	int sum=0,cnt;
	for(register int i=max(n-(m<<1)+1,1);i<=n;++i){
		cnt=(i-1)/(m<<1)+1,sum+=cnt;
		for(register int j=sum;j;--j)
			for(register int k=min(j,cnt);k;--k)
				(f[j]+=1ll*f[j-k]*((g[i][k][0]+g[i][k][1])%mod+g[i][k][2])%mod)%=mod;
	}
	for(register int i=0;i<=n;++i)
		(ans+=pow1(i)*f[i]*fac[n-i]%mod)%=mod;
	printf("%d\n",(ans+mod)%mod);
}


Measured memory_bytes: 47232
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  string s; cin >> s;
  lint n = s.size();
  vector<lint> a(n + 1, 0);
  vector<lint> b(n + 1, 0);
  for(int i = 0; i < n; i++) {
    if(s[i] == '<') {
      a[i + 1] = a[i] + 1;
    }
  }

  for(int i = n - 1; i >= 0; i--) {
    if(s[i] == '>') {
      b[i] = b[i + 1] + 1;
    }
  }

  lint ans = 0;
  for(int i = 0; i < n + 1; i++) ans += max(a[i], b[i]);
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define Loop(i, a, b) for(int i = a ; i < b ; ++i)
#define loop(i, n) Loop(i, 0, n)
#define ff first
#define ss second
#define mkp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define vvii vector<vii>
#define vl vector<ll>
#define vvl vector<vl>
#define pll pair<ll, ll>
#define vll vector<pll>
#define vvll vector<vll>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define nmbr(c) (int)(c-'0')
#define ltr(c) (int)(c-'a')
#define INF 1e18+5
#define inf 1e9+5
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

template <typename T> T max(T a, T b, T c){ return max(a, max(b, c));}
template <typename T> T min(T a, T b, T c){ return min(a, min(b, c));}

const int M = 1e9+7; //check

int main() {
	_69e27;
	int n, a[10], b[10];
	int cnt1 = 0, cnt2 = 0;
	cin >> n;
	loop(i, n) cin >> a[i];
	loop(i, n) cin >> b[i];
	int ref[10];
	loop(i, n) ref[i] = i+1;
	int cnt = 0;
	do{
		bool f1 = 1, f2 = 1;
		loop(i, n) if(ref[i] !=a[i]) f1 = 0;
		loop(i, n) if(ref[i] != b[i]) f2 = 0;
		if(f1) cnt1 = cnt;
		if(f2) cnt2 = cnt;
		cnt++;
	}
	while(next_permutation(ref, ref+n));
	cout << abs(cnt1-cnt2);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST

ll dfs(vector<long>& C, vector<vector<long>>& A, const long& X, vector<ll> total_A, ll depth, ll c)
{
    for(size_t i=0;i<total_A.size(); i++)
    {
        total_A[i] -= A[depth][i];
        if(total_A[i] < X) return c;
    }
    c -= C[depth];
    ll min_cost = c;
    for(size_t i=depth+1;i<A.size(); i++)
    {
        cerr << i << ":" << A.size() << endl;
        min_cost = min(min_cost, dfs(C, A, X, total_A, i, c));
    }
    return min_cost;
}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N, M, X;
    cin >> N >> M >> X;
    vector<long> C(N);
    vector<vector<long>> A(N, vector<long>(M,0));
    ll total_c = 0; vector<ll> total_A(M);
    for(size_t i=0;i<N; i++)
    {
        cin >> C[i];
        total_c += C[i];
        for(size_t m=0;m<M; m++)
        {
            cin >> A[i][m];
            total_A[m]+= A[i][m];
        }
    }
    bool skillup = true;
    for(size_t i=0;i<M; i++)
    {
        if(total_A[i] < X) skillup = false;
    }

    if(!skillup) cout << "-1" << endl;
    else
    {
        ll min_cost = total_c;
        for(size_t i=0;i<N; i++)
        {
            min_cost = min(min_cost, dfs(C, A, X, total_A, i, total_c));
        }
        cout << min_cost << endl;
    }

#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>

int main(void){
    
    int i,n,max,min,a;
    long long int sum=0;
    
    max=-1000000;
    min=1000000;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(a>max) max=a;
        if(a<min) min=a;
        sum+=a;
    }
    
    printf("%d %d %lld\n",min,max,sum);
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define MOD 1000
#define oo 1000000000000000007LL
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}
struct Edge {
    int u, v, w;
    bool inline operator < (const Edge &rhs) const {
        return w < rhs.w;
    }
};

struct DSU {
    vector<int> pset;
    DSU(int n) {
        pset.resize(n+1);
        fto(i, 1, n) pset[i] = i;
    }
    int findSet(int u) {
        return (pset[u] == u) ? u : pset[u] = findSet(pset[u]);
    }
    bool unionSet(int u, int v) {
        int p = findSet(u), q = findSet(v);
        if (p == q) return false;
        pset[p] = q;
        return true;
    }
};

int n, m, k, c[maxN], cnt;
Edge e[maxN];

int main () {
    scanf("%d%d%d", &n, &m, &k);
    fto(i, 1, n) scanf("%d", &c[i]);
    fto(i, 1, m) scanf("%d%d%d", &e[i].u, &e[i].v, &e[i].w);

    if (k == 1) {
        puts("0");
        return 0;
    }
    cnt = k;
    fto(i, 1, n)
        if (c[i] == 0) c[i] = ++cnt;

    sort(e+1, e+m+1);
    ll ans = 0;
    int cntEdge = 0;
    DSU s(cnt);
//    fto(u, 1, n) printf("%d ", c[u]);
//    puts("");
    fto(i, 1, m) {
        if (s.unionSet(c[e[i].u], c[e[i].v])) {
            ans += e[i].w;
            ++cntEdge;
            if (cntEdge == k-1) {
                printf("%lld", ans);
                return 0;
            }
        }
    }

    puts("-1");

    return 0;
}


Measured memory_bytes: 2560
b,r,g,c,s;
main(t){
  for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;)
    printf("%d\n",100-(t-s)*3+c*2+g*7+95*b+63*r);
return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>

void max_heapify(int *heap, int i)
{
  int heap_size,L,R,largest,tmp;

  heap_size=heap[0];
  L=2*i;
  R=2*i+1;
  if(L<=heap_size&&heap[L]>heap[i])
    {
      largest=L;
    }
  else largest=i;

if(R<=heap_size&&heap[R]>heap[largest])
  {
    largest=R;
  }
    if(largest!=i)
      {
	tmp=heap[i];
	heap[i]=heap[largest];
	heap[largest]=tmp;
	max_heapify(heap,largest);
      }
  }

int main()
{
  int *heap,key,index,half,tmp;
  char cmd[20];

  heap=malloc(sizeof(int)*2000000);
  heap[0]=1;
  while(1)
    {
      scanf("%s %d ",cmd,&key);
  if(cmd[0]=='i')
    {
      heap[0]++;
      index=heap[0];
      heap[index]=key;

      half=index/2;
      while(index>1&&heap[half]<heap[index])
	{
	  tmp=heap[index];
	  heap[index]=heap[half];
	  heap[half]=tmp;
	  index/=2;
	  half=index/2;
	}
    }
  else if(cmd[1]=='x')
    {
      printf("%d\n",heap[1]);
      heap[1]=heap[heap[0]];
      heap[0]--;
      max_heapify(heap,1);
    }
  else
    {
      return 0;
    }
    }
  return 0;
}

    

Measured memory_bytes: 6256
var n;
var g = [];
var p = [];
var r = [];

function init(){
	rep(g.length, function(i){
		p[i] = i;
		r[i] = 0;
	});
}

function find(i){
	return p[i] === i ? i : p[i] = find(p[i]);
}

function same(i, j){
	return find(i) === find(j);
}

function unite(i, j){
	var a = find(i);
	var b = find(j);
	
	if(a === b){
		return;
	}

	if(r[a] > r[b]){
		p[b] = a;
	}
	else{
		p[a] = b;
		if(r[a] === r[b]){
			++r[b];
		}
	}
}

function main(){
	n = scan();
	rep(n, function(i){
		rep(n, function(j){
			var c = scan();
			if(i < j && c !== -1){
				g[g.length] = [c, i, j];
			}
		});
	});
	g.sort(function(a, b){
		return a[0] - b[0];
	});
	init();
	var ans = 0;
	rep(g.length, function(i){
		var e = g[i];
		if(!same(e[1], e[2])){
			ans += e[0];
			unite(e[1], e[2]);
		}
	});
	print(ans);
}
 
function rep(a, b, c){
	if(c === undefined){
		c = b;
		b = a;
		a = 0;
	}
	for(var i = a; i < b; ++i){
		if(c(i) === false){
			break;
		}
	}
}
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var input = '';
var input_index = 0;
 
function scan(type){
	if(type === 'string'){
		return input[input_index++];
	}
	else{
		return +input[input_index++];
	}
}
 
function print(val){
	console.log(val);
}
 
process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.trim().split(/\s+/);
	main();
});

Measured memory_bytes: 18384
def main():
    N, K = input(), int(input())
    S = "0"*(100-len(N))+N
    DP = [[[0] * 2 for _ in range(K+2)] for _ in range(101)]
    DP[0][0][0] = 1
    for i in range(100):
        for j in range(K+1):
            DP[i+1][j][0] += DP[i][j][0] * (S[i] == "0")
            DP[i+1][j+1][0] += DP[i][j][0] * (S[i] != "0")
            DP[i+1][j][1] += DP[i][j][1] + DP[i][j][0] * (int(S[i]) > 0)
            DP[i+1][j+1][1] += DP[i][j][1] * 9 + DP[i][j][0] * max(0, int(S[i])-1)
    print(sum(DP[-1][K]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1e9+7;
int main(){
  ll N,ans=0,x=1;
  cin>>N;
  vector<ll> vec(61);
  for(ll i=0;i<N;++i){
    ll a,j=0;
    cin>>a;
    while(a>0){
      if(a&1){++vec.at(j);}
      a/=2;
      ++j;
    }
  }
  for(int i=0;i<61;++i){
    ans+=((((N-vec.at(i))*vec.at(i))%MOD)*(x%MOD))%MOD;
    x*=2;
    ans%=MOD;
  }
  cout<<ans<<endl;
}

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

using namespace std;

int main()
{
    int arr[]={0,0,0,0};
    int n;
    cin>>n;
    for(int i=0;i<=n;i++)
    {
        string str;
        getline(cin,str);
        if( str.compare("AC")==0)
        {
            arr[0]=arr[0]+1;
        }
        if( str.compare("WA")==0)
        {
            arr[1]=arr[1]+1;
        }
        if( str.compare("TLE")==0)
        {
            arr[2]=arr[2]+1;
        }
        if( str.compare("RE")==0)
        {
            arr[3]=arr[3]+1;
        }
    }
    cout<<"AC x "<<arr[0]<<"\n";
    cout<<"WA x "<<arr[1]<<"\n";
    cout<<"TLE x "<<arr[2]<<"\n";
    cout<<"RE x "<<arr[3]<<"\n";
}


Measured memory_bytes: 3604
// Solution by ** Abhishek Mittal **
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>

#define FIO ios_base::sync_with_stdio(0);  cin.tie(0);
#define PI 3.14159265358979323846
#define mod 1000000007
#define ll long long
#define vll vector<long long>  

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

// Used to traverse in any STL container with iterators
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

// Find whether element is present in given container or not
#define present(container, element) (container.find(element) != container.end())

// Finds whether element in present container is present in vector or not
#define cpresent(container, element) (find(all(container),element) != container.end())

using namespace std;



int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    FIO

    string s;
    cin>>s;
    int ans = 0, cnt = 0;
    for(int i=0;i<3;i++){
        if(s[i] == 'R')cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout<<ans;

    return 0;

}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    map<string, int> score;
   ll n,ans=0;
   cin>>n;
   string s;
   rep(i,n){
       cin>>s;
       sort(ALL(s));
       //cout<<s<<endl;
       if(score[s]!=0){
           //cout<<s<<endl;
           
           ans+=score[s];
           score[s]++;
       }
       else score[s]=1;
   }
    cout<<ans<<endl;
    
}
   



Measured memory_bytes: 11136
# ABC 140: B – Buffet
N = int(input())
A = [int(s) - 1 for s in input().split()]
B, C = [[int(s) for s in input().split()] for _ in range(2)]

s = B[A[0]]

for i in range(1, N):
    s += B[A[i]]
    if A[i] - A[i - 1] == 1:
        s += C[A[i] - 1]

print(s)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <fstream>
#define inputtxt() std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf())
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define foreach(e, v) for (auto e : v)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

int gcd(int x,int y){
    if(y==0) return x;
    return gcd(y, x%y);
}

int main(){
    int n; cin >> n;
    priority_queue<int> q;
    rep(i,n){
        int temp;
        cin >> temp;
        q.push(temp);
    }
    int prev = q.top();
    reps(i,1,n-1){
        q.pop();
        if(prev == q.top()){
            cout << "NO" << endl;
            return 0;
        }
        prev = q.top();
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], N;

    cin >> N;
    for(int i = 0; i < N; i++) cin >> R[i];

    int maxv = R[1] - R[0]; 
    int minv = R[0];
    for(int i = 1; i < N; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    cout << maxv << endl;
    return 0;
}


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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int xa = min(k, a);
    k -= xa;
    int xb = min(k, b);
    k -= xb;
    int xc = min(k, c);
    int ans = xa - xc;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3576
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

W, H, x, y = map(int, raw_input().split())
flag = 0
if x * 2 == W and y * 2 == H:
    flag = 1
print float(W) * H / 2, flag

Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//約数列挙(√N)
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
//素因数分解(√N)
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//素数テーブル(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
//二項係数(K)
template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
//二項係数テーブル(N^2)
template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
}
int main(){
  int c2=0,c4=0;
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
    if(!(a.at(i)%4))c4++;
    else if(!(a.at(i)%2))c2++;
  }
  if(c2==0){
    if(c4*2+1>=n)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else{
    if(c4*2+c2>=n)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

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

int main(){
  int n;
  string A,B;
  cin >> n;
  cin >> A >> B;
  rep(i,n)cout << A[i] << B[i];
  cout << endl;
  return 0;
}
    

Measured memory_bytes: 384