akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;


class UnionFindTree
{
private:
    vector<int> parent;
    vector<int> rank;
public:
    UnionFindTree(int n)
    {
        init(n);
    }

    void init(int n)
    {
        parent.resize(n);
        rank.resize(n, 0);

        for (int i = 0; i < n; i++)
        {
            parent[i] = i;
        }
    }

    // find root node
    int find(int x)
    {
        if (parent[x] == x)
        {
            return x;
        }
        else
        {
            return parent[x] = find(parent[x]);
        }
    }

    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);

        // already in the same tree.
        if (x == y)
            return;

        if (rank[x] < rank[y])
        {
            parent[x] = y;
        }
        else
        {
            parent[y] = x;
            if (rank[x] == rank[y])
            {
                rank[x]++;
            }
        }
    }

    bool same(int x, int y)
    {
        return (find(x) == find(y));
    }
};

int main(void)
{
    int N, M;
    cin >> N >> M;

    using pii = pair<int,int>;

    vector<pii> edge(M);

    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edge[i].first = a;
        edge[i].second = b;
    }

    int ans = 0;

    for (int i = 0; i < M; i++)
    {
        UnionFindTree uft(N);

        for (int j = 0; j < M; j++)
        {
            if(i != j && !uft.same(edge[j].first, edge[j].second)){
                uft.unite(edge[j].first, edge[j].second);
            }
        }

        set<int> s;

        for (int j = 0; j < N; j++)
        {
            if(uft.find(j) == j) s.insert(j);
        }

        if(s.size() > 1) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3576
use std::io;
use std::str::FromStr;
use std::collections::HashMap;

fn main(){
    let stdin = io::stdin();
    let mut buf = String::new();

    let design = ['S', 'H', 'C', 'D'];
    let mut trump = HashMap::new();

    for d in &design {
        trump.insert(d, [false; 13]);
    }

    let _ = stdin.read_line(&mut buf);
    let n = i64::from_str(buf.trim()).unwrap();

    for _ in 0..n {
        buf.clear();
        let _ = stdin.read_line(&mut buf);
        let vec: Vec<&str> = buf.split_whitespace().collect();
        let (d, r) = (vec[0].chars().nth(0).unwrap(), usize::from_str(vec[1]).unwrap());

        trump.get_mut(&d).unwrap()[r-1] = true;
    }

    for d in &design {
        for (i,r) in trump[d].iter().enumerate() {
            if !r {
                println!("{} {}", d, i+1);
            }
        }
    }
}



Measured memory_bytes: 5040
#include<stdio.h>

#include<stdlib.h>


int selectionsort (int * ,int);
int main(){
  int i, n,*a,q,f=0;
  scanf(" %d",&n);

  a=(int *)malloc(n *sizeof(int));
  for(i=0;i<n;i++){

    scanf(" %d",&a[i]);
   
  }
 f= selectionsort(a,n);
 //printf("%d",a[0]);
  for(i=0;i<n;i++){
    if(i>0) printf(" ");;
    printf("%d",a[i]);
  }
 printf("\n%d\n",f);

 return 0;
}

int selectionsort(int *A,int N){
  int i,j,k,m=0,l;
  int minj;
  for(i=0;i<=N-1;i++){
    minj=i;
    
   
    for (j=i;j<=N-1;j++){
      
      if(A[j]<A[minj])
	{
	  minj=j;}
    }
	  k=A[i];
      
	  l=A[minj];
	  A[i]=l;
	  A[minj]=k;
	  
  
  if(i!=minj) m++;
}
  
  return m;
}



Measured memory_bytes: 2104
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"sort"
	"strconv"
)

func main() {
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	v := nextInts(n)
	map0 := map[int]int{}
	map1 := map[int]int{}
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			map0[v[i]]++
		} else {
			map1[v[i]]++
		}
	}
	p1 := make([]Pair, 1)
	p2 := make([]Pair, 1)
	for k, v := range map0 {
		p1 = append(p1, Pair{k, v})
	}
	for k, v := range map1 {
		p2 = append(p2, Pair{k, v})
	}
	sort.Sort(Pairs(p1))
	sort.Sort(Pairs(p2))
	log.Println(p1)
	log.Println(p2)
	if p1[len(p1)-1].a != p2[len(p2)-1].a {
		fmt.Println(n - p1[len(p1)-1].b - p2[len(p2)-1].b)
	} else {
		c1 := n - p1[len(p1)-1].b - p2[len(p2)-2].b
		c2 := n - p1[len(p1)-2].b - p2[len(p2)-1].b
		fmt.Println(min(c1, c2))
	}
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define cin(a) scanf("%d",&a)
#define pii pair<int,int>
#define ll long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 201110;
const int M = 1e9+7;
int n,m,k,t;

int main()
{
    char c;
    cin>>c;
    cout<<char(c+1)<<endl;
    return 0;
}

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

int main() {
    int n;
    cin>>n;
    vector<int> vec(n);
    rep(i,n){
        cin>>vec.at(i);
    }
    int count=1;
    sort(vec.begin(),vec.end());
    if(n==1){
        cout<<count<<endl;
    }
    else{ 
        for(int i=0;i<n-1;i++){
            if(vec.at(i)!=vec.at(i+1)){
                count++;
            }
        }
    cout<<count<<endl;
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() { 
	int n; cin >> n;
	int h;
	int maxh = 0; int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> h;
		if (maxh <= h) {
			ans++;
			maxh = h;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 1e5+5;

int a[sz];

int main()
{
   string s;
   cin >> s;
   for(int i=0; i<s.size(); i++)
      if(s[i] == '?') s[i] = 'D';
   cout << s << endl;
}


Measured memory_bytes: 3704
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:String,
    }
    let a=a.chars().collect_vec();
    println!("{}",if a[0]=='9'||a[1]=='9'{"Yes"}else{"No"})
}

Measured memory_bytes: 2084
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
using namespace std;

int c[501][501];

string random(int n){
	string s;
	for(int i=0 ; i<n ; i++ ){
		s.push_back( rand() % 2 + '0' );
	}
	return s;
}

bool f(string s, int n, int k){
	int sum = 0;
	for(int i=0 ; i<k ; i++ ){
		sum = 0;
		for(int j=0 ; j<n/2 ; j++ ){
			sum += s[ c[i][j]-1 ] - '0';
		}
		if( n/8 <= sum && sum <= 3*n/8 ){
			;
		}else{
			return false;
		}
	}
	return true;
}

int main(){
	int n,k;
	srand((unsigned int)time(NULL));

	cin >> n >> k;
	for(int i=0 ; i<k ; i++ ){
		for(int j=0 ; j<n/2 ; j++ ){
			cin >> c[i][j];
		}
	}
	string s = random(n);
	while( f( s , n , k ) == false ){
		int i_ = rand()%s.size();
		s[i_] = (s[i_]=='0')? '1' : '0';
	}
	cout << s << endl;
}

Measured memory_bytes: 1808
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

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

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

int main() {
	IOS;
	int mod = 1e9 + 7;
	int n;
	cin >> n;
	vector<int> cnt(n,0);
	bool ok = true;
	ll ans = 1;
	REP(i, n) {
		int a;
		cin >> a;
		if ((n - 1 - a) % 2 != 0) {
			ok = false; break;
		}
		cnt[a]++;
	}
	for (int i = n - 1; i >= 0; i -= 2) {
		if (i != 0 && cnt[i] != 2)ok = false;
		if (i == 0 && cnt[i] != 1)ok = false;
	}
	if (ok) {
		REP(i, n / 2) {
			ans *= 2;
			ans %= mod;
		}
		cout << ans << endl;
	}
	else dump(0);
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(all(a));
  ll edge1 = 0;
  ll edge2 = 0;
  for(ll i=1;i<n;i++){
    if(a[i]==a[i-1]){
      edge2 = edge1;
      edge1 = a[i];
      i++;
    }
  }
  print(edge1 * edge2);
}


Measured memory_bytes: 3976
def main():
    N = int(input())
    a_lists = list(map(int, input().split()))
    cnt = 0
    for i in range(N):
        min_j = i
        for j in range(i, N):
            if a_lists[j] < a_lists[min_j]:
                min_j = j
        if min_j == i:
            continue
        a_lists[i], a_lists[min_j] = a_lists[min_j], a_lists[i]
        cnt += 1
    print(' '.join(map(str, a_lists)))
    print(cnt)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5600
#include<stdio.h>

int main(void){
  int x;
  scanf("%d",&x);

  if(x < 600){
    printf("8\n");
  }
  else if(x < 800){
    printf("7\n");
  }
  else if(x < 1000){
    printf("6\n");
  }
  else if(x < 1200){
    printf("5\n");
  }
  else if(x < 1400){
    printf("4\n");
  }
  else if(x < 1600){
    printf("3\n");
  }
  else if(x < 1800){
    printf("2\n");
  }
  else if(x < 2000){
    printf("1\n");
  }

  return  0;
}

Measured memory_bytes: 1620
import java.util.Scanner;
 

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt(), l[] = new int[m], r[] = new int[n];
        for (int i = 0; i < m; i++)
            l[i] = sc.nextInt();
        for (int i = 0; i < m; i++) {
            int s = 0;
            for (int j = 0; j < n; j++) {
                if (sc.nextInt() == l[i]) {
                    r[j]++;
                    s++;
                }
            }
            r[l[i] - 1] += n - s;
        }
        for (int i : r)
            System.out.println(i);
    }
}


Measured memory_bytes: 40620
N, M = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
def func(M):
  res = []
  i = 2
  while i * i <= M:
    c=0
    while M % i == 0:
      M /= i
      c += 1
    if c > 0:
      res.append(c)
    i += 1
  if M > 1:
    res.append(1)
  return res

def conb(n, r):
  N, R = n, r
  for i in range(1, r):
    N *= n-i
    R *= r-i
  return N // R

res = func(M)
ans = 1
for i in res:
  ans = (ans * conb(i+N-1, i)) % mod
print(ans)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws Exception {
        int Q = Integer.parseInt(br.readLine().trim());
        int[][] lr = new int[Q][2];
        Boolean[] isPrime = new Boolean[100001];
        List<Integer> isPrimeList = new ArrayList<>();
        for (int i = 0; i < lr.length; i++) {
            lr[i] = inputval();
        }
        for (int i = 0; i < isPrime.length; i++) {
            isPrime[i] = true;
        }
        int x;
        for (int i = 2; i < (int) Math.sqrt(isPrime.length); i++) {
            x = 2;
            while (i * x < isPrime.length) {
                isPrime[i * x] = false;
                x++;
            }
        }
        isPrime[0] = false;
        isPrime[1] = false;
        for (int i = 0; i < isPrime.length; i++) {
            if (isPrime[i] == true) {
                isPrimeList.add(i);
            }
        }

        int[] isLike2017 = new int[100001];
        int count = 0;
        for (int i = 0; i < isLike2017.length; i++) {
            isLike2017[i] = 0;
        }
        for (int i = 0; i < isLike2017.length; i++) {
            if (isPrimeList.contains(i) && isPrimeList.contains((i + 1) / 2)){
                count++;
            }
            isLike2017[i] = count;

        }


        for (int i = 0; i < lr.length; i++) {
            System.out.println(isLike2017[lr[i][1]] - isLike2017[lr[i][0]-1]);
        }
    }


    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    static void array_sout(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }

    static void array_sout(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int func(int m,int a,int b,const int *h,int n){
  int cnt=0;
  int i;
  for(i=0;i<n;i++){
    if((int64)b*m>=h[i]) continue;
    cnt+=(h[i]-b*m+(a-b)-1)/(a-b);
    if(cnt>m) return 0;
  }
  return 1;
}

void run(void){
  int n,a,b;
  scanf("%d%d%d",&n,&a,&b);
  int *h=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",h+i);
  int max=h[0];
  for(i=1;i<n;i++) max=MAX(max,h[i]);
  int l=0;
  int r=(max+b-1)/b;
  while(l+1<r){
    int m=(l+r)/2;
    if(func(m,a,b,h,n)){
      r=m;
    } else {
      l=m;
    }
  }
  printf("%d\n",r);
  return;
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define max1 3005
#define siz 100000
#define mod 998244353
#define inf 1e18+5
#define ll long long int
#define debug(x) cout<<#x<<" "<<x<<endl
#define jam(x) cout<<"Case #"<<x<<": "
typedef pair<ll,ll> pr;
vector<vector<ll> > dp(max1,vector<ll>(max1,-1) );
string s,t;
ll fun(ll idx1,ll idx2)
{
  if(idx1>=s.length()||idx2>=t.length())
  {
    return 0;
  }
  if(dp[idx1][idx2]!=-1)
  {
    return dp[idx1][idx2];
  }
  if(s[idx1]==t[idx2])
  {
    return dp[idx1][idx2]=fun(idx1+1,idx2+1)+1;
  }
  return dp[idx1][idx2]=max({fun(idx1+1,idx2),fun(idx1,idx2+1),fun(idx1+1,idx2+1)});
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif*/
  cin>>s>>t;
  ll x=fun(0,0);
  string ans;
  ll l=0,r=0;
  while(l<s.length()&&r<t.length())
  {
    if(ans.length()==x)
    {
      break;
    }
    //cout<<l<<" "<<r<<" "<<dp[l][r]<<endl;
    if(dp[l][r]>dp[l+1][r+1]&&dp[l][r]>dp[l+1][r]&&dp[l][r]>dp[l][r+1])
    {
      ans.push_back(s[l]);
      l++;
      r++;
    }
    else if(dp[l][r]==dp[l+1][r+1])
    {
      l++;
      r++;
    }
    else if(dp[l][r]==dp[l+1][r])
    {
      l++;
    }
    else if(dp[l][r]==dp[l][r+1])
    {
      r++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 71168
n = int(input())
s = input()
res = 0
for i in range(1, n - 1):
    l = set(s[:i])
    r = set(s[i:])
    tmp = 0
    for j in range(26):
        if chr(ord("a") + j) in l and chr(ord("a") + j) in r:
            tmp += 1
    res = max(res, tmp)
print(res)


Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll s;
  R s;
  map<ll,ll> m;
  while(!m.count(s)) {
    ll k=m.size();
    m[s]=k;
    if(s%2) s=s*3+1;
    else s/=2;
  }
  pr(m.size()+1);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ll = unsigned long long;
using namespace std;

int main(void) {

    int k;
    cin >> k;

    if (k&1) {
        // odd
        cout << (k/2) * ((k/2)+1) << endl;
    } else {
        // even
        cout << pow(k/2,2) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int d[n];
    for(int i=0; i<n; i++) cin >> d[i];
    sort(d, d+n);
    cout << d[n/2]-d[n/2-1] << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int a,b,tasu,hiku,kakeru,ans;
    cin >> a >> b;
    tasu = a + b;
    ans = tasu;
    hiku = a - b;
    if(hiku > ans){
        ans = hiku;
    }
    kakeru = a * b;
    if(kakeru > ans){
        ans = kakeru;
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define out(ans) cout << ans << endl
typedef pair<int,int>P;
const ll mod=1e9+7;

ll n,a,b;
ll h[100010];

bool ok(ll mid){

  ll c=0;
  rep(i,0,n){
    ll H=h[i]-mid*b;
    if(H<=0)continue;
    c+=(H%a==0)?H/a:(H/a)+1;
  }
  return c<=mid;
}

int main(){

  cin>>n>>a>>b;
  a-=b;
  rep(i,0,n)cin>>h[i];

  ll l=0,r=1e10;
  while(r-l>1){
    ll mid=(l+r)/2;

    if(ok(mid))r=mid;
    else l=mid;
  }
  out(r);

  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long M = long.Parse(str[1]);
		string ans = "";
		if(N<M){
			for(var i=0;i<M;i++){
				ans += N;
			}
		} else {
			for(var i=0;i<N;i++){
				ans += M;
			}
		}
		Console.WriteLine(ans);
	}
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N,A,B;
    string S;
    cin >> N >>A>>B;

    ll ans = 0;

    REP(i,N+1){
        S = to_string(i);
        ll sum = 0;
        REP(j, S.size())
        {
            int a = S.at(j) - '0';
            sum += a;
        }
        if(sum>=A&&sum<=B){
            //cout << sum << endl;
            ans += i;
        }
    }
    cout << ans << endl;
}


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

set <long long> st;

int main() {
 int a, b, c;
  cin >> a >> b >> c;
  st.insert(a);
  st.insert(b);
  st.insert(c);
  if (st.size() == 2)
  	cout << "Yes" << '\n';
  else
    cout << "No" << '\n';
  
}

Measured memory_bytes: 256
import math
n = int(input())
e = [[int(i) for i in input().split()] for i in range(n)]
dissum=0.0
def get_distance(x1, y1, x2, y2):
    d = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
    return d
for i in range(0,n):
    for j in range(0,n):
        d = get_distance(e[i][0], e[i][1], e[j][0], e[j][1])
        dissum+=d
bai=(n-1)/math.factorial(n)
print(dissum/n)

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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

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

    int D;
    cin >> D;
    vector<int> c(D);
    rep(i, D) {
        cin >> c[i];
    }
    vector<vector<int>> s(D);
    rep(i, D) {
        s[i].resize(26);
        rep(j, 26) cin >> s[i][j];
    }

    rep(d, D) {
        int x = -1;
        int best = -1000000;
        rep(i, 26) {
            int tmp = s[d][i] - c[i];
            if (best < tmp) {
                x = i;
                best = tmp;
            }
        }
        cout << (x+1) << endl;
    }

    return 0;
}


Measured memory_bytes: 3692
import os

import math
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353
def mod_invs(max, mod):
    """
    逆元 0, 1/1, 1/2, 1/3, ..., 1/max
    :param int max:
    :param int mod:
    """
    invs = [1] * (max + 1)
    invs[0] = 0
    for x in range(2, max + 1):
        invs[x] = (-(mod // x) * invs[mod % x]) % mod
    return invs


def get_factors(n):
    """
    素因数分解
    :param int n:
    :rtype: list of int
    """
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret


S = sys.stdin.buffer.readline().decode().rstrip()
N = len(S)
MOD = 2019

hist = []
mod_counts = [0] * MOD
power = 1
n = 0
for i in reversed(range(N)):
    n += int(S[i]) * power
    n %= MOD
    mod_counts[n] += 1
    hist.append(n)
    power *= 10
    power %= MOD

ans = 0
m = 0
power = 1
for i in reversed(range(N)):
    # m = int(S[i + 1:] or 0) % MOD
    ans += mod_counts[m]
    mod_counts[hist[~i]] -= 1

    m += int(S[i]) * power
    m %= MOD
    power *= 10
    power %= MOD
print(ans)



def test(S, mod):
    ans = 0
    for l in range(len(S)):
        for r in range(l + 1, len(S) + 1):
            n = int(S[l:r])
            if n % mod == 0:
                print(n)
                ans += 1
    print(ans)


# test(S, 2019)
# print()
# test(S, 2019 // 3)


Measured memory_bytes: 77124
def popcount(n):
    return bin(n).count("1")


def f(n):
    tmp = n
    count = 0
    while tmp > 0:
        tmp %= popcount(tmp)
        count += 1
    return count


n = int(input())
# f(0)~f(n)までを計算しておく
F = [f(i) for i in range(n + 2)]
x = input()
pcx = x.count("1")
# xをpcx-1,pcx+1で割ったあまりをそれぞれ計算

a, b = 0, 0
if pcx == 1:
    for i in range(n):
        if x[i] == "1":
            b += pow(2, n - i - 1, pcx + 1)
            b %= (pcx + 1)
    for i in range(n):
        if x[i] == "1":
            print(0)
        else:
            print(1 + f((b + pow(2, n - i - 1, pcx + 1)) % (pcx + 1)))
    exit()

if pcx > 1:
    for i in range(n):
        if x[i] == "1":
            a += pow(2, n - i - 1, pcx - 1)
            a %= (pcx - 1)
            b += pow(2, n - i - 1, pcx + 1)
            b %= (pcx + 1)
else:
    for i in range(n):
        print(1)
    exit()
for i in range(n):
    if x[i] == "1":
        print(1 + f((a - pow(2, n - i - 1, pcx - 1)) % (pcx - 1)))
    else:
        print(1 + f((b + pow(2, n - i - 1, pcx + 1)) % (pcx + 1)))


Measured memory_bytes: 94144
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  int cnt = 0;
  for(int i=A;i<=B;i++){
    if(i/10000 == i%10){
      if((i/1000)%10 == (i%100)/10) cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    vector<int> x_sort = x;
    sort(x_sort.begin(), x_sort.end());
    int median = n/2;
    rep(i, n) {
        if (x[i] <= x_sort[median-1]) {
            cout << x_sort[median] << endl;
        }
        else {
            cout << x_sort[median-1] << endl;
        }
    }
}

Measured memory_bytes: 4828
import java.util.*;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int len = sc.nextInt();
		int[] a = new int[len];
		for(int i = 0; i < len; i++)
			a[i] = sc.nextInt();
		for(int i = len - 1; i >= 0; i--){
			System.out.print(a[i]);
			if(i > 0)
				System.out.print(" ");
		}
		System.out.println("");
	}
}

Measured memory_bytes: 19808
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
        string a,b,c;
        cin >> a >> b >> c;
        printf("%c%c%c\n",a[0] - 32,b[0] - 32,c[0] - 32);
        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

void chmax(pint& p,pint q){
    if(q.first>=p.first){
        p.second=max(p.first,q.second);
        p.first=q.first;
    }
    else p.second=max(p.second,q.first);
}
int main(){
   int m;
   cin>>m;
   int n=1<<m;
   pint a[n];
   rep(i,n)cin>>a[i].first;
   rep(i,n)a[i].second=0;
   rep(i,m)rep(j,n)if(j&(1<<i))chmax(a[j],a[j^(1<<i)]);
   int ans[n];
   rep(i,n)ans[i]=a[i].first+a[i].second; 
   rep(i,n-1)ans[i+1]=max(ans[i],ans[i+1]);
   rep(i,n-1)printf("%d\n",ans[i+1]);
   return 0;
}

Measured memory_bytes: 6144
S = list(input())
ans = int("".join([S[0],S[1],S[2]]))
for i in range(len(S)-2):
  n = int("".join([S[i],S[i+1],S[i+2]]))
  if abs(n-753) <= abs(ans-753):
    ans = n
  else:
    pass
  
print(abs(753-ans))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

int inf = std::numeric_limits<int>().max();

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define ll long long
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

int main() {
	int n;
	cin >> n;
	vector<int> v(n); 
	for(int i=0; i<n; i++) {
		cin >> v[i];
	}
	vector<int> ans(n); 
	ans[0] = 0;
	ans[1] = abs(v[1]-v[0]);
	for(int i=2; i<n; i++) {
		ans[i] = min(ans[i-1] + abs(v[i-1] - v[i]), ans[i-2] + abs(v[i-2]-v[i])); 
	}
	cout << ans[n-1] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)

typedef long long ll;
typedef pair<int, int> pii;

#define MAX 100000
bool prime[MAX];

void erat()
{
	fill(prime, prime+MAX, true);
	prime[0] = false;
	prime[1] = false;
	for (int i = 2; i < MAX; i++)
		for (int j = 2*i; j < MAX; j += i)
			prime[j] = false;
}

bool isprime(int n)
{
	if (n < MAX) return prime[n];
	if (n % 2 == 0) return false;
	for (int d = 3; d*d <= n; d += 2)
		if (n%d == 0)
			return false;
	return true;
}

int main(void)
{
	int a, d, n;
	erat();
	while (cin >> a >> d >> n, a|d|n) {
		int cnt = 0;
		for (int i = a;; i += d) {
			if (isprime(i) && ++cnt == n) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int A; int B; int C; int D;
    cin >> A >> B >> C >> D;
    if (A + B > C + D)
        cout << "Left" << endl;
    else if (A + B < C + D)
        cout << "Right" << endl;
    else
        cout << "Balanced" << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

        int n = scan.nextInt(), m = scan.nextInt();
        int a[] = new int[n];
        int sum, count;

        sum = 0;
        for(int i = 0; i < a.length; i++) {
            a[i] = scan.nextInt();
            sum += a[i];
        }
        
        count = 0;
        for(int i = 0; i < n; i++) {
            if(!(a[i] < sum / (double)(4 * m))) {
                count++;
            }

            if(count == m) {
                System.out.println("Yes");
                scan.close();
                return;
            }
        }
        System.out.println("No");

        scan.close();
        return;
    }
}

Measured memory_bytes: 36004
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

func main() {
	n := readString()
	b := []byte(n)

	for i := 0; i < 3; i++ {
		c := int(b[i] - '0')
		if c == 7 {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")
}

/*-------------------inputs-------------------*/

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func subL(list []int) []int {
	sl := make([]int, len(list)-1)
	for i := range list {
		if i == len(list)-1 {
			continue
		}
		sub := list[i+1] - list[i]
		sl[i] = sub
	}
	return sl
}


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

int main(){
  int a,b;
  cin>>a>>b;
  if (a == 0){
    cout<< "Zero"<<endl;
    return 0;
  }
  if (b == 0){
    cout<< "Zero"<<endl;
    return 0;
  }
  if (a>0 ){
    cout<< "Positive"<<endl;
    return 0;
  }
  if (b<0){
    int x = b - a +1;
    if (x%2 == 0){
      cout<< "Positive"<<endl; 
      return 0;
    }
    else{
      cout<< "Negative"<<endl;
      return 0;
    }
  }
  else{
    cout<< "Zero"<<endl;
    return 0;
  }  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args){
        
        Scanner scan=new Scanner(System.in);
        
        char[] text=new char[1200];
        String in="";
        String out="";
        
        in=scan.nextLine();
        text=in.toCharArray();
        
        for(int i=0;i<text.length;i++){
            if(Character.isUpperCase(text[i])){
                text[i]=Character.toLowerCase(text[i]);
            }else if(Character.isLowerCase(text[i])){
                text[i]=Character.toUpperCase(text[i]);
            }
        }
        
        out=String.valueOf(text);
        System.out.println(out);
        
    }   
     
}

Measured memory_bytes: 26096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
pair<ll,int> cost[101010];
ll ans;
int main(){
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%lld %d",&cost[i].first,&cost[i].second);
    sort(cost+1,cost+1+n);
    for(int i=1;i<=n;i++){
        int mn = min(cost[i].second,m);
        ans += cost[i].first*mn;
        m-=mn;
        if(!m) break;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 1792
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


A, B = list(map(int, sys.stdin.buffer.readline().split()))

ok = A <= 8 and B <= 8
if ok:
    print('Yay!')
else:
    print(':(')


Measured memory_bytes: 3060
def abc(a, b, c):
    ans = 0
    while a%2 + b%2 + c%2==0:
        if a==b and b==c:
            ans = -1
            break
        ans += 1
        x, y, z = a, b, c
        a = (y+z)//2
        b = (z+x)//2
        c = (x+y)//2
    return ans

def main():
    a, b, c = map(int, input().split())
    print(abc(a,b,c))
if __name__=='__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll m;
	cin>>m;
	set<ll>q[26];
	for(ll i=0;i<n;i++){
		ll now=s[i]-'a';
		q[now].insert(i);
	}
	for(ll i=0;i<m;i++){
		ll now;
		cin>>now;
		if(now==2){
			ll l,r;
			cin>>l>>r;
			l--;
			ll cnt=0;
			for(ll j=0;j<26;j++){
				auto itr1=q[j].lower_bound(l);
				auto itr2=q[j].lower_bound(r);
				if(itr1!=itr2){
					cnt++;
				}
			}
			cout <<cnt<<endl;
		}
		if(now==1){
			ll x;
			char z;
			cin>>x>>z;x--;
			char next=s[x];
			ll nextwo=next-'a';
			q[nextwo].erase(x);
			s[x]=z;
			nextwo=z-'a';
			q[nextwo].insert(x);
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 27264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll A, B;
  cin >> A >> B;
  cout << 6 - A - B << endl;
}

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

signed main() {
    int n;
    cin>>n;
    int c=0;
    vector<int> arr(n);
    for(int i=0;i<n;i++)
    cin>>arr[i];
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int z=j+1;z<n;z++)
            {
                if(arr[i]!=arr[j] && arr[j]!=arr[z] && arr[z]!=arr[i])
                {int maxi = max(arr[i],max(arr[z],arr[j]));
                int sum = arr[i]+arr[j]+arr[z];
                sum = sum - maxi;
                if(sum>maxi)
                c++;}
            }
        }
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 3628
N = int(input())
A = list(map(int,input().split()))

ans = [0] * N
for i,a in enumerate(A[::-1]):
    n = m = N-i
    s = 0
    while m <= N:
        s += ans[m-1]
        m += n
    ans[n-1] = (s%2)^a

ans = [i+1 for i,a in enumerate(ans) if a]
print(len(ans))
if ans:
    print(*ans, sep='\n')

Measured memory_bytes: 17636
#include <iostream>
#include <cmath>

int main()
{
        int x;
        std::cin >> x;

        int ans[2]={0};
        for(int i=-119;i<120;i++)
                for(int j=-119;j<120;j++)
                        if(static_cast<int>(std::pow(i,5)-std::pow(j,5))
                           == x)
                        {
                                ans[0] = i;
                                ans[1] = j;
                        }

        std::cout << ans[0] << " " << ans[1] << std::endl;
}

Measured memory_bytes: 4072
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<21)

bool cmp(const pair<int,char> &a,const pair<int,char> &b){
	return a.first > b.first;
}
int main(){
	int n;
	while(cin >> n,n){
		vector< pair<int,char> > data(n);
		rep(i,n){
			int sum = 0;
			cin >> data[i].second;
			rep(j,n-1){
				int t;
				cin >> t;
				sum += (t==0?10:t==2?1:0);
			}
			data[i].first = sum;
		}
		stable_sort(data.begin(),data.end(),cmp);
		rep(i,n){
			cout << data[i].second << endl;	
		}
	}
}

Measured memory_bytes: 0
from collections import deque
n, q = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
count = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    count[p-1] += x
q = deque([0])
d = [0]*n
while q:
    v = q.popleft()
    d[v] = 1
    for i in g[v]:
        if d[i]:
            continue
        count[i] += count[v]
        q.append(i)
print(*count)

Measured memory_bytes: 56084
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin>>n;
    long long a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int q;
    cin>>q;
    while(q--)
    {
        int com,b,e;
        cin>>com>>b>>e;
        long long c[e-b-1];
        for(int i=0;i<e-b;i++)
        {
            c[i]=a[i+b];
        }
        int d=e-b;
        sort(c,c+d);
        if(com==0)
        {
            cout<<c[0]<<endl;
        }
        else
        {
            cout<<c[e-b-1]<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3152
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
// in fenwick always use size as 1000010
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
ll a[10000010];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;cin >> n;
    for(int i=1;i<=10000000;i++)
    {
    	for(int j=i;j<=10000000;j+=i)
    	{
    		a[j]++;
    	}
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
    	ans+=(a[i]*i);
    }
    cout << ans;
    }

Measured memory_bytes: 81724
import numpy as np
MOD = 10**9 + 7
def solve(s):
    n = len(s)
    a = np.zeros(4, dtype=int)
    b = a.copy()
    a[0] = 1
    for c in s:
        t = 2 * int(c == "?") + 1
        b = t * a % MOD
        if c == "A":
            b[1] += a[0]
        elif c == "B":
            b[2] += a[1]
        elif c == "C":
            b[3] += a[2]
        else:
            b[1:] += a[:-1]
        a = b
    return a[3] % MOD

s = input()
print(solve(s))

Measured memory_bytes: 13048
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, K) = Slice2<long>();
            var xi = Sarray();
            var ans = long.MaxValue;
            //l～rの火を灯す
            for (long l = 0, r = K - 1; r < N; ++l, ++r)
            {
                var t = 0L;
                if (xi[l] * xi[r] < 0)//0をまたぐ場合左→右/右→左の順
                    t = Min(-2 * xi[l] + xi[r], -xi[l] + 2 * xi[r]);
                else if (xi[l] < 0)//左のみ
                    t = -xi[l];
                else//右のみ
                    t = xi[r];
                ans = Min(ans, t);
            }
            WriteLine(ans);
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 38312