akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>



using namespace std;
typedef long long ll;
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}

int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}





int main(){
  string S;
  cin>>S;
  if(S.size()==2){
    cout<<S<<endl;
  }else{
    printf("%c%c%c\n",S.at(2),S.at(1),S.at(0));
  }

  

}


  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    vector<bool> a(n, false);
    vector<int> b(n, 0);
    int p, cnta = 0, cntw = 0;
    string s;
    for(int i=0;i<m;i++){
        cin >> p >> s;
        if(a[p-1] == false){
            if(s == "AC"){
                cnta++;
                cntw += b[p-1];
                a[p-1] = true;
            }else {
                b[p-1]++;
            }
        }
    }
    cout << cnta << " " << cntw << endl;
}

Measured memory_bytes: 640
//Coded by Dy.
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define re register
int n, m;
int main() {
	scanf("%d%d", &n, &m);
	if(n > 9 || m > 9) {
		printf("-1\n");
		return 0;
	}
	printf("%d\n", n * m);
	return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
int n;
string s,t;
int main(){
    ____();
    cin >> n >> s >> t;
    string ans;
    for(int i = 0; i < n; i++) ans+=s[i], ans+=t[i];
    cout << ans << endl;
    return 0;
}

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

int main()
{
	long long int A,B;
	
	cin>>A>>B;
	
	//lcm*gcd=A*B ==> lc=A*B/gcd
	
	cout<<(A*B)/__gcd(A,B)<<endl;
	
	return 0;
}

Measured memory_bytes: 888
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int h, w, tmp, sum = 0;
    cin >> h >> w;
    
    int floyd[10][10];
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) cin >> floyd[i][j];
    }
    
    for (int tr = 0; tr < 10; ++tr) {
        for (int i = 0; i < 10; ++i) {
            for (int j = 0; j < 10; ++j) {
                floyd[i][j] = min(floyd[i][j], floyd[i][tr] + floyd[tr][j]);
            }
        }
    }
    
    for (int i = 0; i < h*w; ++i) {
        cin >> tmp, sum += (tmp == -1 ? 0 : floyd[tmp][1]);
    }
    
    cout << sum << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main () {

    string W;

    cin >> W;

    int cnt = 0;
    while (1) {
        string T; 
        cin >> T;

        if (T == "END_OF_TEXT") {
            break;
        }

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

            if (T[i] == 0) {
                break;
            }

            if ('A' <= T[i] && T[i] <= 'Z') {
                T[i] += 32;
            }
        }

        if (T == W) {
            cnt++;
            // cout << "count++" << endl;
        }
    }

    cout << cnt << endl;

    return 0;

}


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

int main(){
    int n, m; scanf("%d %d", &n, &m);
    int a[n][m];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            scanf("%d",&a[i][j]);
        }
        
    }

    int b[m];
    for (int j = 0; j < m; j++)
    {
        cin >> b[j];
    }
    
    int ans;

    for (int i = 0; i < n; i++)
    {
        ans = 0;
        for (int j = 0; j < m; j++)
        {
            ans += a[i][j]*b[j];
        }
        cout << ans << endl;
        
    }
    


    return 0;
}


Measured memory_bytes: 3252
import java.io.IOException
import java.lang.NumberFormatException
import java.lang.StringBuilder
import kotlin.math.max
import kotlin.math.pow

object AMain{
    fun solve(){
        val n = nextInt()
        val map = HashMap<Int, Long>()
        var sum = 0L
        for(i in 1..n){
            val a = nextInt()
            if(map.containsKey(a)){
                map[a] = map[a]!! + 1
            }else{
                map[a] = 1
            }
            sum += a
        }

        val q = nextInt()
        for(i in 1..q){
            val b = nextInt()
            val c = nextInt()
            if(map.containsKey(b)){
                sum += (c-b).toLong() * map[b]!!.toLong()
                if(map.containsKey(c)){
                    map[c] = map[c]!! + map[b]!!
                }else{
                    map[c] = map[b]!!
                }
                map[b] = 0
            }

            println(sum)
        }
    }





    // Scanner based on uwi-san's Java code
    val stream = System.`in`
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0

    fun hasNextByte(): Boolean{
        if(ptr < buflen){
            return true
        }else{
            ptr = 0
            try{
                buflen = stream.read(buffer)
            }catch (e: IOException){
                e.printStackTrace()
            }
            if(buflen <= 0){
                return false
            }
        }
        return true
    }

    fun readByte() =
        if(hasNextByte()) buffer[ptr++]
        else -1

    fun isPrintableChar(c: Byte) = c in 33..126

    fun hasNext(): Boolean{
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
        return hasNextByte()
    }

    fun next(): String{
        if(!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while(isPrintableChar(b)){
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun nextLong(): Long{
        if(!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if(b == '-'.toByte()){
            minus = true
            b = readByte()
        }
        if(b !in '0'.toByte()..'9'.toByte())
            throw NumberFormatException()
        while(true){
            if(b in '0'.toByte()..'9'.toByte()){
                n *= 10
                n += b - '0'.toByte()
            }else if(!isPrintableChar(b)){
                return if(minus) -n else n
            }else{
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextInt(): Int{
        val n1 = nextLong()
        if(n1 !in Int.MIN_VALUE..Int.MAX_VALUE)
            throw NumberFormatException()
        return n1.toInt()
    }

    fun NextDouble() = next().toDouble()
}

fun main(){
    AMain.solve()
}



Measured memory_bytes: 65272
def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    sum_ = sum(A)
    min_ = float('inf')
    x = y = 0
    for i in range(N - 1):
        x += A[i]
        y = sum_ - x
        if abs(x - y) < min_:
            min_ = abs(x - y)

    print(min_)

main()


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

using namespace std;

void reverse(vector<int>::iterator first, vector<int>::iterator last) {
  for (; first != last && first != --last; ++first) {
    iter_swap(first, last);
  }
}

int main() {
  ios::sync_with_stdio(false);

  int len_array;
  cin >> len_array;
  vector<int> v(len_array);

  for (int i = 0; i < len_array; i++) {
    cin >> v[i];
  }

  int num_query;
  cin >> num_query;

  int b, e;
  for (int i = 0; i < num_query; i++) {
    cin >> b >> e;
    reverse(v.begin() + b, v.begin() + e);
  }

  cout << *v.begin();
  for (auto it = v.begin() + 1, e = v.end(); it != e; ++it) {
    cout << " " << *it;
  }
  cout << endl;
}




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

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

  int n; cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  int ans = 1000000;
  for (int i = 1; i <= 100; i++) {
    int res = 0;
    for (int j = 0; j < n; j++) {
      res += (x[j] - i) * (x[j] - i);
    }
    ans = min(ans, res);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;++i)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
using namespace std;
int n,graph[101][101],visit[101];
int d[101],f[101],t;
const int WHITE=0;
const int GRAY=1;
void dfs(int u){
    visit[u]=GRAY;
    d[u]=++t;
    FOR(v,1,n+1){
        if(graph[u][v]==0) continue;
        if(visit[v]==WHITE) dfs(v);
    }
    f[u]=++t;
    //printf("%d %d %d\n",u,d[u],f[u]);
}
int main(){
    int u,k,v;
    scanf("%d",&n);
    REP(i,n){
        scanf("%d%d",&u,&k);
        REP(j,k){
            scanf("%d",&v);
            graph[u][v]=1;
        }
    }
    FOR(i,1,n+1){
        if(visit[i]==WHITE) dfs(i);
    }
    FOR(i,1,n+1){
        printf("%d",i);
        printf(" %d %d\n",d[i],f[i]);
    }
    return 0;
}




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

int main() {
    int N, K;
    cin >> N >> K;
    int R, S, P;
    cin >> R >> S >> P;
    string T;
    cin >> T;
    vector<bool> won(N, false);
    long long int ans = 0;
    for(int i = 0; i < N; i++) {
        if(0 <= i - K && T[i - K] == T[i] && won[i-K] == true) {
            continue;
        }
        char C;
        if(T[i] == 'r') {
            ans += P;
            C = 'p';
        }
        if(T[i] == 's') {
            ans += R;
            C = 'r';
        }
        if(T[i] == 'p') {
            ans += S;
            C = 's';
        }
        won[i] = true;
    }
    cout << ans << endl;
}

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

signed main() {
	int n;
	cin >> n;
	int N = sqrt(n) + 1;
	int a, b, ans = INT_MAX;
	for (int i = 1; i <= N; ++i) {
		a = i;
		b = n / i;
		if (a * b == n) {
			ans = min<int>(ans, max(to_string(a).size(), to_string(b).size()));
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long w,n,k,k1,t,cnt,p,p1[20000],kl[20000],l[20000],r[20000],zhi[20000];
int  main()
{  cin>>n;
   k=1;
   if (n==1)  {cout<<2<<' '<<1<<endl;  cout<<1<<' '<<2<<' '<<0<<endl;}
 else
 {  t=1;   
 while (t*2<=n)
    {l[++cnt]=k; r[cnt]=k+1; zhi[cnt]=0;
     l[++cnt]=k; r[cnt]=k+1; zhi[cnt]=t;
     k++;
     t=t*2;
    }
    k1=k; n=n-t; w=t;
  while (n>0)
    { t=1; k=1;  while (t*2<=n) t=t*2,k++; 
	   l[++cnt]=k; r[cnt]=k1; zhi[cnt]=w;
	   w=w+t; n=n-t; 
	}
     cout<<k1<<' '<<cnt<<endl;
    for (int i=1;i<=cnt;i++)
     cout<<l[i]<<' '<<r[i]<<' '<<zhi[i]<<endl;
 }  
   
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (x, y): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    const INF: i64 = 1_000_000_000_000_000;
    fn f(z: i64) -> i64 { if z >= 0 { z } else { INF } }
    let ans = *vec![f(y - x), f(x + y) + 1, f(-(x + y)) + 1, f(x - y) + 2].iter().min().unwrap();

    println!("{}", ans);
}

Measured memory_bytes: 4352
use std::io::{ stdin, stdout, BufRead, Write };
use std::ops::{ Add, Sub, Mul };

const SP   : u8 = b' ';
const LF   : u8 = b'\n';
const ZERO : u8 = b'0';

#[inline(always)]
fn uitoa(mut n: usize, buf: &mut Vec<u8>) {
  buf.clear();
  if n == 0 {
    buf.push(ZERO);
    return;
  }

  while n > 0 {
    buf.push((n % 10) as u8 + ZERO);
    n /= 10;
  }

  buf.reverse();
}

#[inline(always)]
fn atoui<T>(s: &[u8]) -> T
  where T: Add<Output=T> +
           Sub<Output=T> +
           Mul<Output=T> +
           Default +
           From<u8>
{
  let mut n = T::default();
  if s.len() == 0 {
    return n;
  }

  let mut i = 0;
  if s[i] == b'+' {
    i += 1;
  }

  for b in &s[i..] {
    n = (n * T::from(10)) + T::from(b - ZERO);
  }

  n
}

fn main() {
  let stdin = stdin();
  let mut stdin = stdin.lock();

  let mut buf = Vec::with_capacity(500 * 2);
  let len = stdin.read_until(SP, &mut buf).unwrap();
  buf.truncate(len - 1);
  let h = atoui::<usize>(&buf);

  buf.clear();
  let len = stdin.read_until(LF, &mut buf).unwrap();
  buf.truncate(len - 1);
  let w = atoui::<usize>(&buf);

  let mut num = Vec::with_capacity(3);
  let mut ans = Vec::new();
  let mut n   = 0;

  let mut odd = 0;
  let mut x   = 0;
  let mut y   = 0;

  for i in 0..h {
    buf.clear();
    stdin.read_until(LF, &mut buf).unwrap();

    if i % 2 == 0 {
      for j in 0..w {
        if odd != 0 {
          uitoa(y + 1, &mut num);
          num.push(SP);
          ans.write(&num).unwrap();

          uitoa(x + 1, &mut num);
          num.push(SP);
          ans.write(&num).unwrap();

          uitoa(i + 1, &mut num);
          num.push(SP);
          ans.write(&num).unwrap();

          uitoa(j + 1, &mut num);
          num.push(LF);
          ans.write(&num).unwrap();

          n += 1;
        }
        odd ^= buf[j * 2] & 1;
        y = i;
        x = j;
      }
    } else {
      for mut j in 0..w {
        j = w - 1 - j;

        if odd != 0 {
          uitoa(y + 1, &mut num);
          num.push(SP);
          ans.write(&num).unwrap();

          uitoa(x + 1, &mut num);
          num.push(SP);
          ans.write(&num).unwrap();

          uitoa(i + 1, &mut num);
          num.push(SP);
          ans.write(&num).unwrap();

          uitoa(j + 1, &mut num);
          num.push(LF);
          ans.write(&num).unwrap();

          n += 1;
        }
        odd ^= buf[j * 2] & 1;
        y = i;
        x = j;
      }
    }
  }

  let stdout = stdout();
  let mut stdout = stdout.lock();

  uitoa(n, &mut buf);
  buf.push(LF);
  stdout.write(&buf).unwrap();

  stdout.write(&ans).unwrap();
  stdout.flush().unwrap();
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N, K;
    double sum = 0;
    cin >> N >> K;
    for(ll i = 1;i <= N;i++) {
        ll count = 0;
        ll temp = i;
        while(temp < K) {
            temp *= 2;
            count++;
        }
        sum += 1.0 / N * pow(0.5, count);
    }
    cout << fixed << setprecision(9) << sum << endl;
    return 0;
}


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

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" " , n);
        int[] array = new int[n];
        
        for(int i = 0; i < n; i++){
            array[i] = Integer.parseInt(input[i]);
        }

        insertionSort(array);

    }

    static void insertionSort(int[] A){
        int N = A.length;

        //output
        StringBuilder sb = new StringBuilder();
        for(int k : A){
            sb.append(k + " ");
        }
        System.out.println(sb.toString().substring(0 , sb.length() - 1));

        for(int i = 1; i < N; i++){
            int v = A[i];
            int j = i-1;
            while(j>=0 && A[j] > v){
                A[j+1] = A[j];
                j--;

            }
            A[j+1] = v;

            //output
            StringBuilder sbs = new StringBuilder();
            for(int k : A){
                sbs.append(k + " ");
            }
            System.out.println(sbs.toString().substring(0 , sbs.length() - 1));

        }
    }

}

Measured memory_bytes: 28556
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int a, b;
  cin >> a >> b;
  cout << a*b/2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int *a, int *b);

int main(void) {
	int x, y, r;
	
	scanf("%d %d", &x, &y);
	
	if(x < y) {
		swap(&x, &y);
	}
	
	while(y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	
	printf("%d\n", x);
	
	return 0;
}

void swap(int *a, int *b) {
	int temp;
	
	temp = *a;
	*a = *b;
	*b = temp;
}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <string>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF=1<<29;
ll mod=1000000007;

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

	int N,L,sum=0,tmp=INF;
	cin>>N>>L;
	for(int i=L;i<L+N;i++){
		sum+=i;
		if(abs(i)<abs(tmp)) tmp=i;
	}
	sum-=tmp;
	cout<<sum<<endl;

	return 0;
}

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

#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pint;
typedef pair<long, long> plong;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T> void print(T &x) {
    cout << x << '\n';
    return;
}

template <class T> ll sized_subset(T &comb) {
    T x = comb & -comb, y = x + comb;
    return ((comb & ~y) / x) >> 1 | y;
}

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

int main() {
    int n = in();
    ll c[n - 1], s[n - 1], f[n - 1];
    REP(i, n - 1) {
        c[i] = in();
        s[i] = in();
        f[i] = in();
    }
    REP(i, n) {
        ll t = 0;
        for (int j = i; j < n - 1; j++) {
            t = max(t, s[j]);
            t = ((t - 1) / f[j] + 1) * f[j] + c[j];
        }
        print(t);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int n;

int main(){
	cin>>n;
	if(n%10==3){
		cout<<"bon";
		return 0;
	}
	int tmp=n%10;
	if(tmp==0||tmp==1||tmp==6||tmp==8)
		cout<<"pon";
	else
		cout<<"hon";
	
	
	return 0;
}

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

int main()
{
  ll n; cin>>n;
  int a[n];
  int alice=0, bob=0;
  rep(i, n) {
    cin >> a[i];
  }
  sort(a, a+n, greater<int>());

  rep(i, n) {
    if(i%2==0) alice += a[i];
    else bob += a[i];
  }
  cout << alice - bob << endl;
  return 0;
}

Measured memory_bytes: 256
def solve(a):
 
    colors = [0]*9
 
    for i in a:
        num = 0
        tmp = 400
        flag = True
        for j in range(9):
            if i < 0:
                flag = False
                break
            else:
                i -= 400
                num += 1
        if flag:
            colors[num-1] += 1
        else:
            colors[num-1] = 1
    if sum(colors[:8]) == 0:
        print(1,colors[-1])
    else:
        print(sum(colors[:8]),sum(colors[:8])+colors[-1])
 
def main():
    N = int(input())
    a = list(map(int,input().split()))
    solve(a)
 
if __name__ == "__main__":
    main()

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  rep(i,n) cin >> a[i];
  sort(all(a));
  auto it = unique(all(a));
  a.erase(it, a.end());
  int after = a.size();
  if((n-after)%2 == 0) cout << after << endl;
  else cout << after-1 << endl;
}



Measured memory_bytes: 640
#include<stdio.h>
#define MAX 100000

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main(){
  int h,i,A[MAX];

  scanf("%d",&h);
  
  for(i=1;i<=h;i++)scanf("%d",&A[i]);

  for(i=1;i<=h;i++){
    printf("node %d",i);
    printf(": key = %d, ",A[i]);
    if(parent(i)>=1)printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=h)printf("left key = %d, ",A[left(i)]);
    if(right(i)<=h)printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
using namespace std;


int main(){
    int n, m;
    cin >> n >> m;
    int x[m];
    for (int i = 0; i < m; i++){
        cin >> x[i];
    }
    sort(x, x + m);
    long long answer = 0;
    if (n < m) {
        long long intervals[m - 1];
        for (int i = 1; i < m; i++){
            intervals[i - 1] = x[i] - x[i - 1];
        }
        sort(intervals, intervals + m - 1);
        answer = accumulate(intervals, intervals + m - n, answer);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
  cin>>a>>b;
  cout<<(a+1)-b;
} 

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

int main()
{
	int Count = 0;
	int n;
	cin >> n;
	vector<int> S;
	for(int i = 0; i < n; i++){
		int s;
		cin >> s;
		S.push_back(s);
	}
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		int t;
		cin >> t;
		for(int j = 0; j < n; j++){
			if(t == S[j]){
				Count ++;
				break;
			}
		}
	}
	cout << Count << endl;
	return 0;
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int H, N, i;
  bool can = false;
  cin >> H >> N;
  vector<int> A(N);
  REP(i, N) {
    cin >> A[i];
  }
  sort(A.rbegin(), A.rend());
  REP(i, N) {
    H -= A[i];
    if (H <= 0) {
      can = true;
      break;
    }
  }
  if (can == true) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main(){
	int n;
	cin >> n;
	set<int> s;
	rep(i,n){
		int a;
		cin >> a;
		s.insert(a);
	}
	if(s.size()%2==0) cout << s.size()-1 << endl;
	else cout << s.size() << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define REP(i,n) for(int i = 1; i < (n); i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  vi ans(n);
  queue<int> q;
  rep(i,n){
    q.push(i);
    vi dist(n, -1);
    dist[i] = 0;
    auto push = [&](int v, int d){
      if(dist[v] != -1) return;
      dist[v] = d;
      q.push(v);
    };
    while(!q.empty()){
      int v = q.front(); q.pop();
      int d = dist[v];
      if(v-1 >= 0) push(v-1, d+1);
      if(v+1 < n) push(v+1, d+1);
      if(v == x) push(y, d+1);
      if(v == y) push(x, d+1);
    }
    rep(i,n) ans[dist[i]]++;
  }
  rep(i,n) ans[i] /= 2;
  REP(i,n){
    cout << ans[i] << endl;
  }
}

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

int main()
{
	int N, M, X, Y;
	scanf("%d%d%d%d", &N, &M, &X, &Y);
	int max_x{X}, min_y{Y};
	for (int i{}; i < N; i++)
	{
		int tmp;
		scanf("%d", &tmp);
		max_x = std::max(max_x, tmp);
	}
	for (int i{}; i < M; i++)
	{
		int tmp;
		scanf("%d", &tmp);
		min_y = std::min(min_y, tmp);
	}
	if (max_x < min_y) puts("No War");
	else puts("War");

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e5+4;
int n;
int head[N],etot;
struct Edge {
	int v,nxt,col;
	Edge () {col=0;}
}e[N<<1];
int deg[N],ans,root;
inline bool cmp(int x,int y) {
	return deg[x]>deg[y];
}
inline int read() {
	int x=0;char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x;
}
inline void adde(int u,int v) {
	e[++etot].nxt=head[u],e[etot].v=v,head[u]=etot;
}
void dfs(int p,int fa,int pre) {
	int cnt=0;
	for (int i=head[p];~i;i=e[i].nxt) {
		int v=e[i].v;
		if (!e[i].col) {
			++cnt;
			if (cnt==pre) ++cnt;
			e[i].col=cnt;
			if (i&1) e[i+1].col=cnt;
			else e[i-1].col=cnt;
			dfs(v,p,cnt);
		}
	}
}
int main() {
	memset(head,-1,sizeof(head));
	n=read();
	for (register int i=1;i<n;++i) {
		int u=read(),v=read();
		adde(u,v);
		adde(v,u);
		++deg[u],++deg[v];
	}
	for (register int i=1;i<=n;++i) {
		if (ans<deg[i]) {
			ans=deg[i];
			root=i;
		}
	}
	dfs(root,0,0);
	printf("%d\n",ans);
	for (register int i=1;i<=etot;i+=2)
		printf("%d\n",e[i].col);
	return 0;
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int n,k;
    cin >> n >> k;
    int i=0;
    vector<int> dp(n+1,0);
    dp[0] = 1;
    for(int i=1; i<=n; ++i) {
        dp[i] = min(dp[i-1]+k,dp[i-1]*2);
    }
    cout << dp[n] << "\n";
}


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

int main(){
    string s;
    cin >> s;
    int len = s.length();
    int count = 0;
    int max = 0;
    for(int i=0;i<len;i++){
        char c = s[i];
        if(c=='R'){
            count++;
            if(count>max){
                max++;
            }
        }else{
            count = 0;
        }
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
pair<int,int>p[N];
int n,m,a[N],vis[N];
vector<pair<int,int>>e[N];
vector<int>ans;
inline int dfs(int x)
{
	vis[x]=1;
	int rt=a[x];
	for(auto v:e[x])
	{
		int y=v.first;
		if(vis[y])
			continue;
		int t=dfs(y);
		if(t)
			ans.push_back(v.second);
		rt^=t;
	}
	return rt;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>p[i].first>>p[i].second;
	sort(p,p+n);
	a[0]=p[0].second;
	for(int i=1;i<n;++i)
		a[i]=p[i-1].second^p[i].second;
	a[n]=p[n-1].second;
	for(int i=0,l,r;i<m;i++)
	{
		cin>>l>>r;
		l=lower_bound(p,p+n,make_pair(l,0))-p;
		r=upper_bound(p,p+n,make_pair(r,1))-p;
		e[l].push_back({r,i+1});
		e[r].push_back({l,i+1});
	}
	for(int i=0;i<=n;i++)
	{
		if(!vis[i])
		{
			if(dfs(i))
			{
				cout<<"-1\n";
				return 0;
			}
		}
	}
	cout<<ans.size()<<endl;
	sort(ans.begin(),ans.end());
	for(int i:ans)
		cout<<i<<' ';
	return 0;
}

Measured memory_bytes: 13820
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
A, B, N = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)
x = 0
if N >= B:
    x = B - 1
else:
    x = N

print(int(A*x/B))

Measured memory_bytes: 9092
#include <stdio.h>
#include <algorithm>

int main(void) {
  int a[3];
  scanf("%d%d%d", &a[0], &a[1], &a[2]);
  std::sort(a, a + 3);
  printf("%d %d %d\n", a[0], a[1], a[2]);
  return 0;
}


Measured memory_bytes: 2752
n,c=map(int,input().split())
D=[]
r0=[]
r1=[]
r2=[]
for i in range(c):
    sub_list=list(map(int,input().split()))
    D.append(sub_list)
    r0.append(0)
    r1.append(0)
    r2.append(0)
c_list=[]
for i in range(n):
    sub_list=list(map(int,input().split()))
    c_list.append(sub_list)
for i in range(n):
    for j in range(n):
        if (i+j)%3==0:
            r0[c_list[i][j]-1]=r0[c_list[i][j]-1]+1
        elif (i+j)%3==1:
            r1[c_list[i][j]-1]=r1[c_list[i][j]-1]+1
        else:
            r2[c_list[i][j]-1]=r2[c_list[i][j]-1]+1
Min=10**10
for i in range(c):
    for j in range(i+1,c):
        for k in range(j+1,c):
            pat=[(i,j,k),(i,k,j),(j,i,k),(j,k,i),(k,i,j),(k,j,i)]
            for x in pat:
                Sum=0
                for y in range(c):
                    Sum=Sum+r0[y]*D[y][x[0]]+r1[y]*D[y][x[1]]+r2[y]*D[y][x[2]]
                Min=min(Min,Sum)
print(Min)


Measured memory_bytes: 45404
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b := intScanner(), intScanner()
	if b < a {
		fmt.Println(a - 1)
	} else {
		fmt.Println(a)
	}
}


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

#define pb push_back
const int maxn = 10000;

using ll = long long int;

ll l, r;

ll solve()
{
	ll al = l / 2019;
	ll ar = r / 2019;
	ll bl = l % 2019;
	ll br = r % 2019;
	if(bl >= br || al < ar) return 0; 
	int m = 2019;
	for(ll i = bl; i <= br; i++)
		for(ll j = i+1; j <= br; j++)
		{
			int ans = i * j % 2019;
			if(ans < m) m = ans;
		}
	return m;
}

int main()
{
	cin >> l >> r;
	printf("%lld\n", solve());	
}

Measured memory_bytes: 256
package main

import "fmt"

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

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	if abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d) {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


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

class BIT {
public:
  int num;
  vector<int> dat;

  BIT(int N, int val) : num(N) {
    dat.resize(N);
    fill(dat.begin(), dat.end(), val);
  }

  int query(int i) {
    int res = 0;
    while (i > 0) {
      res += dat[i];
      i -= i & -i;
    }
    return res;
  }

  void update(int i, int x) {
    while (i <= num) {
      dat[i] += x;
      i += i & -i;
    }
  }
};

int calc(string from, string to) {
  int N = from.size();

  queue<int> cidx[26];
  for (int i = 0; i < N; i++) {
    cidx[from[i] - 'a'].push(i);
  }

  vector<int> idx(N);
  for (int i = 0; i < N; i++) {
    idx[i] = cidx[to[i] - 'a'].front();
    cidx[to[i] - 'a'].pop();
  }

  BIT bit(N + 1, 0);

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += bit.query(N - idx[i]);
    bit.update(N - idx[i], 1);
  }

  return ans;
}

signed main() {
  string s;
  cin >> s;

  int cnt[26] = {};
  for (int i = 0; i < s.size(); i++) {
    cnt[s[i] - 'a']++;
  }

  int odd = 0;
  for (int i = 0; i < 26; i++) {
    if (cnt[i] % 2) {
      odd++;
    }
  }

  if (odd > 1) {
    cout << -1 << endl;
    return 0;
  }

  int app[30] = {};
  string A;
  for (auto c : s) {
    if (app[c - 'a'] < cnt[c - 'a'] / 2) {
      A.push_back(c);
      app[c - 'a']++;
    }
  }

  string B = A;

  for (int i = 0; i < 26; i++) {
    if (cnt[i] % 2) {
      B.push_back((char)('a' + i));
    }
  }

  reverse(B.begin(), B.end());
  A += B;

  cout << calc(s, A) << endl;
  return 0;
}


Measured memory_bytes: 6016
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define pb push_back

int Min(int a, int b)
{
  if (a < b) return a;
  return b;
}

int main(void)
{
  int n;
  cin >> n;
  vec<int> b(n);
  rep(i, n) cin >> b[i];
  vec<int> ans(0);

  while(!b.empty()) {
    int flag = 0;
    for (int j = Min(100, b.size()); j > 0; j--) {
      if (b[j - 1] == j) {
        flag = 1;
        ans.pb(j);
        b.erase(b.begin() + j - 1);
        break;
      }
    }
    if (!flag) {
      cout << -1 << endl;
      return 0;
    }
  }
  reverse(ans.begin(), ans.end());
  rep(i, ans.size()) cout << ans[i] << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>


using namespace std;


void security()
{
  string s;
  cin >> s;

  for (int i = 1; i < s.size(); ++i)
  {
    if (s[i - 1] == s[i])
    {
      cout << "Bad\n";
      return;
    }
  }
  cout << "Good\n";
}


void fifty_fify()
{
  string s;
  cin >> s;

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

  if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes\n";
  else cout << "No\n";
}


int main()
{
  //security();
  fifty_fify();
}

Measured memory_bytes: 256
using System;

namespace Ringo_sFavoriteNumbers
{
    class Program
    {
        public static string Solve()
        {
            string input = Console.ReadLine();
            int D = int.Parse(input.Split()[0]);
            int N = int.Parse(input.Split()[1]);

            double hentai = Math.Pow(100, D);

            if (N == 100)
            {
                N++;
            }
            return (hentai * N).ToString();
        }

        static void Main(string[] args)
        {
            Console.WriteLine(Solve());
        }
    }
}


Measured memory_bytes: 13140
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}

signed main(){
	int n;
	cin>>n;
	vector<int> a(n),s(n+1);
	s[0]=0;
	rep(i,n){
		cin>>a[i];
		s[i+1]=s[i]+a[i];
	}
	int ans=LLONG_MAX;
	rep(i,1,n) ans=min(ans,llabs(s[i]-(s[n]-s[i])));
	cout<<ans<<endl;
}


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

int main(){
    int N, count=0;;
    cin >> N;
    int a[N+1], k;
    for(int i=1; i<=N; i++){
        cin >> k;
        a[i]=k;
    }
    for(int i=1; i<=N; i+=2){
        int check=0;
        check = a[i];
        if(check%2==0){
            1+1;
        }
        else{
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3584
from math import factorial
n = int(input())
src = [''.join(sorted(input())) for _ in range(n)]
dic = {}
for s in src:
    # 辞書にキーが存在しなければキー追加
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
count = 0
# 辞書から値だけ取り出す
for d in dic.values():
    # dまでの値の組み合わせを合計する
    if d > 2:
        count += factorial(d) // 2 // factorial(d - 2)
    elif d == 2:
        count += 1
print(count)

Measured memory_bytes: 19392
import math

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

result = 0

if n >= 2:
    result += math.factorial(n)/math.factorial(n-2)/math.factorial(2)
if m > 2:
    result += math.factorial(m)/math.factorial(m-2)/math.factorial(2)

print(int(result))


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

signed main() {
    int N, K;
    string S;
    cin >> N >> K >> S;
    S += '-';

    vector<int> ac;
    ac.push_back(0);
    bool hand = (S[0] == '0');
    for (int cnt = 0, i = 0; i < N + 1; i++) {
        if (i && S[i] != S[i - 1]) {
            ac.push_back(ac.back() + cnt);
            cnt = 0;
        }
        cnt++;
    }

    int ans = 0;
    int l = 0, r = 0;
    for (int i = 1; i < ac.size(); i++) {
        r = i;
        l = max(l, r - K * 2 - (i + hand) % 2);
        int t = max(ans, ac[r] - ac[l]);
        ans = max(ans, t);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1528
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e6+3)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
	int n;
	cin>>n;
	vector<ll>a(n);
	ll x = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		x^=a[i];
	}
	for(int i=0;i<n;i++)cout<<(x^a[i])<<" ";
	
}

Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long double a,b,c,di,fi;
    cin>>a>>b>>c;
    di=(c-a-b)/2;
    fi=(long double)sqrt(a*b);

    if(fi<di)
    cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int t=0;
    long long res=1;
    for(int i=0;i<n;i++){
        long long tmp;
        cin>>tmp;
        long long r=res*tmp;
        if(tmp==0) t=-1;
        if(t==0&&(r<0||r>1000000000000000000||r<res)) t=1;
        res=r;
    }
    if(t==-1) cout<<0<<endl;
    else if(t==1) cout<<-1<<endl;
    else cout<<res<<endl;
}


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

#define db(x) cerr << #x ": " << (x) << '\n';

#define int long long

using namespace std;

typedef long long ll;

const int oo = 1e18;

int X, Y, Z;

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

    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << '\n';

    return 0;
}


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

std::bitset<4000400> b;

int main(){
	int N, a[2020], s, i; 
	for (scanf("%d", &N), b[0] = 1, s = i = 0; i != N; i++)
		scanf("%d", a+i), s += a[i], b |= b<<a[i];
    for(i = s>>1; !b[i]; i--) ;
    printf("%d\n", s-i);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

const int dx[2] = {1,0};
const int dy[2] = {0,1};
int main(){
    int h,w;
    cin >> h >> w;
    vector<string> m(h);
    rep(i,h) cin >> m[i];

    vector<vi> di(h,vi(w,INF));
    di[0][0] = 0;
    queue<P> q;
    q.push({0,0});
    while(q.size()){
        int x = q.front().first;
        int y = q.front().second;
        q.pop();

        rep(i,2){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx<0 || nx>=h || ny<0 || ny>=w) continue;
            int c = 0;
            if(m[x][y]!=m[nx][ny]) c = 1;
            if(di[nx][ny] <= di[x][y] + c) continue;
            di[nx][ny] = di[x][y] + c;
            q.push({nx,ny});
        }
    }
    /*rep(i,h){
        rep(j,w) cout << di[i][j] << " ";
        cout << endl;
    }*/
    if(m[0][0]=='#') di[h-1][w-1]++;
    if(m[h-1][w-1]=='#') di[h-1][w-1]++;
    cout << (di[h-1][w-1] + 1)/2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>

using namespace std;

int w;//縦本の総本数
int n;//横棒の数
int D[31];//あみだの並び順


queue<pair<int,int> > que;
int a,b;
int temp;

int main(){
  scanf("%d %d",&w,&n);
  for(int i = 1;i <= w;i++){
    D[i] = i;
  }//あみだを初期化
  for(int i = 0;i < n;i++){
    scanf("%d,%d",&a,&b);
    que.push(pair<int,int>(a,b));
  }
  for(int i = 0;i <n;i++){
    a =que.front().first;
    b =que.front().second;
    temp = D[b];
    D[b] = D[a];
    D[a] = temp;
    que.pop();
  }
  for(int i = 1;i <=w;i++){
    printf("%d\n",D[i]);
  }

}

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

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()

#pragma region 逆元
const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
#pragma endregion

int main()
{
	COMinit();
	ll MOD = 1e9 + 7;
	int n, m; cin >> n >> m;
	int tmp = m;
	map<int, int> mp;
	for (ll p = 2; p*p <= tmp; ++p)
	{
		if (tmp%p != 0)continue;

		int cnt = 0;
		while (tmp%p == 0)
		{
			tmp /= p;
			++cnt;
		}
		mp[p] = cnt;
	}
	if (tmp != 1)
	{
		mp[tmp] = 1;
	}
	ll res = 1;
	for (auto x : mp)
	{
		ll a = COM(n + x.second - 1, n - 1);
		res = (res * a) % MOD;
	}
	cout << res << endl;
}

Measured memory_bytes: 23680
//Gaurav Singh (saintpopo)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long int
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fbo find_by_order
#define ook order_of_key
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int N=1e5+5;
const int SZ=105;
const int MOD=1e9+7;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main(){
    IOS
    //io_set();
    
    char s;
    cin >> s;
    if(s =='A') {
        cout << 'T' << endl;
    }
    else if(s =='T') {
        cout << 'A' << endl;
    }
    else if(s =='C') {
        cout << 'G' << endl;
    }
    else if(s =='G') {
        cout << 'C' << endl;
    }
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  vector<string>b(n);
  for(int i=0;i<n;i++){
    cin >> b[i] >> a[i];
  }
  string key="";
  cin >> key;
  int sum=0;
  
  for(int i=0;i<n;i++){
    if(b.at(i)==key){
      for(int j=i+1;j<n;j++){
        sum+=a.at(j);
      }
      break;
    }
    else{
      continue;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256