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

vector<complex<double>> fft(vector<complex<double>> a, bool inverse = false) {
    int n = a.size();
    int h = 0;
    for (int i = 0; 1 << i < n; i++) h++;
    for (int i = 0; i < n; i++) {
        int j = 0;
        for (int k = 0; k < h; k++) j |= (i >> k & 1) << (h - 1 - k);
        if (i < j) swap(a[i], a[j]);
    }
    for (int b = 1; b < n; b *= 2) {
        for (int j = 0; j < b; j++) {
            complex<double> w =
                polar(1.0, (2 * M_PI) / (2 * b) * j * (inverse ? 1 : -1));
            for (int k = 0; k < n; k += b * 2) {
                complex<double> s = a[j + k];
                complex<double> t = a[j + k + b] * w;
                a[j + k] = s + t;
                a[j + k + b] = s - t;
            }
        }
    }
    if (inverse)
        for (int i = 0; i < n; i++) a[i] /= n;
    return a;
}

vector<complex<double>> fft(vector<double> a, bool inverse = false) {
    vector<complex<double>> a_complex(a.size());
    for (int i = 0; i < a.size(); i++) a_complex[i] = complex<double>(a[i], 0);
    return fft(a_complex, inverse);
}

vector<double> convolve(vector<double> a, vector<double> b) {
    int s = a.size() + b.size() - 1;
    int t = 1;
    while (t < s) t *= 2;
    a.resize(t);
    b.resize(t);
    vector<complex<double>> A = fft(a);
    vector<complex<double>> B = fft(b);
    for (int i = 0; i < t; i++) {
        A[i] *= B[i];
    }
    A = fft(A, true);
    a.resize(s);
    for (int i = 0; i < s; i++) a[i] = A[i].real();
    return a;
}

int main(){
    
    string A, B;
    vector<double> a, b, c;
    vector<long> d, ans;
    int sgn = 1;
    cin >> A >> B;
    
    if(A[0] == '0' || B[0] == '0'){
        cout << 0 << endl;
        return 0;
    }
    
    for(int i = 0; i < A.length(); i++){
        if(A[i] == '-'){
            sgn *= -1;
            continue;
        }
        a.push_back((double)(A[i] - '0'));
    }
    
    for(int i = 0; i < B.length(); i++){
        if(B[i] == '-'){
            sgn *= -1;
            continue;
        }
        b.push_back((double)(B[i] - '0'));
    }
    
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    
    c = convolve(a, b);
    for(int i = 0; i < c.size(); i++)
        d.push_back((long)(c[i] + 0.5));
        
    long x;
        
    for(int i = 0; i < d.size(); i++){
        x = d[i];
        ans.push_back(x % 10);
        if(i < d.size() - 1) d[i + 1] += x / 10;
        else if(x / 10 > 0) ans.push_back(x / 10);
    }
    
    if(sgn == -1) cout << '-';
    for(int i = ans.size() - 1; i >= 0; i--)
        cout << ans[i];
    cout << endl;
    
    return 0;
}


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

int c;
int main(){
	string s;
	cin>>s;
	bool f=0;
	rep(i,s.size()){
		if(s[i]=='A')f=1;
		if(s[i]=='Z')if(f){c++;f=0;}
	}
	if(!c)cout<<"-1";
	rep(i,c)cout<<"AZ";cout<<endl;
	return 0;
}

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

#define N 100

int main(void){
	int n;
	char a[N],b[N];
	int ac=0,bc=0;

	scanf("%d",&n);

	for(int i=0;i<n;i++){
		scanf("%s %s",a,b);

		if(strcmp(a,b)>0){
			ac+=3;
		}else if(strcmp(a,b)<0){
			bc+=3;
		}else if(strcmp(a,b)==0){
			ac++;
			bc++;
		}
	}

	printf("%d %d\n",ac,bc);
}


Measured memory_bytes: 2084
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long

int calc(int x, int y) {
	return (x - y)*(x - y);
}

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

	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
	}

	int sum = 0;
	int ans = INF;
	for (int i = -100; i <= 100; i++)
	{
		sum = 0;
		for (int j = 0; j < N; j++)
		{
			sum += calc(a[j], i);
		}
		ans = min(ans, sum);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
"""
隣り合う2要素を掛けていく

ref. https://atcoder.jp/contests/abc169/submissions/13893064
"""
n = int(input())
A = list(map(int,input().split()))

MX = 1e18

while len(A)>1:
    if len(A)%2 == 1: # 要素数が奇数のときは[1]を加えて偶数にしておく
        A += [1]
    A = [A[2*i]*A[2*i+1] for i in range(len(A)//2)]

if A[0] > MX:
    print(-1)
else:
    print(A[0])


Measured memory_bytes: 21640
#[allow(unused_imports)]
use std::cmp::Ordering::{Equal, Greater, Less};
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;

// a.rs ---
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: i32,
        a: i32,
        b: i32,
    };

    println!("{} {}", min(a, b), max(0, a + b - n));
}


Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define mod 1000000007
#define inf 1<<30
#define mp(a,b) make_pair(a,b)
#define len(u,N) u.begin(),u.begin()+N


vector<ll> A;

int main() {
    rep(i,5) {
        ll temp;
        cin >>  temp;
        A.push_back(temp);
    }
    sort(all(A));
    ll res = inf;
    do{
        ll temp = 0;
        rep(i,4){
            temp += A[i];
            ll re = temp%10;
            if (re != 0) temp += 10-re;
            // cout << temp << endl;
            
        }
        temp += A[4];
        res = min(res,temp);
        
    }while(next_permutation(all(A)));
    
    cout << res << 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);

	int n = scan.nextInt();

	int[] l = new int[n];
	int max = 0;
	int sum = 0;
	for(int i = 0; i < n; i++){
	    l[i] = scan.nextInt();
	    if(max < l[i]){
		max = l[i];
	    }
	    sum += l[i];
	}

	if(sum - max > max){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
}
	


Measured memory_bytes: 23764
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut two = 0;
    let mut four = 0;
    let mut other = 0;

    for _ in 0..n {
        let a_i: i32 = read();
        if a_i % 4 == 0 {
            four += 1;
        } else if a_i % 2 == 0 {
            two += 1;
        } else {
            other += 1;
        }
    }

    println!(
        "{}",
        if (two == 0 && other <= four + 1) || (two != 0 && other <= four) {
            "Yes"
        } else {
            "No"
        }
    );
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
package main

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

func main() {
	S := getStdin()
	T := getStdin()

	ans := 0
	for i := 0; i < len(T); i++ {
		if S[i] != T[i] {
			ans++
		}
	}
	fmt.Printf("%d\n", ans)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func getStdin() string {
	return readLine()
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


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

int main() {
  int n, a, b;
  int ans = 0;

  cin >> n >> a >> b;
  for (int k = n; k > 0; k--) {
    int sum = 0, t = k;
    while (t > 0) {
      sum += t % 10;
      t /= 10;
    }
    if (sum >= a && sum <= b) ans += k;
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int n;
vector<int> a;

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

    int n;
    cin >> n;
    int N = 3 * n;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    vector<int> l(n + 1), r(n + 1);
    priority_queue<int, vector<int>, greater<int>> que1;
    int sum = 0;
    rep(i, n)
    {
        sum += a[i];
        que1.push(a[i]);
    }
    l[0] = sum;
    rep(i, n)
    {
        int x = a[i + n], y = que1.top();
        if (x > y)
        {
            sum = sum + x - y;
            que1.pop();
            que1.push(x);
        }
        l[i + 1] = sum;
    }

    sum = 0;
    priority_queue<int> que2;
    rep(i, n)
    {
        sum += a[N - i - 1];
        que2.push(a[N - i - 1]);
    }
    r[n] = sum;
    rep(i, n)
    {
        int x = a[2 * n - i - 1], y = que2.top();
        if (x < y)
        {
            sum = sum + x - y;
            que2.pop();
            que2.push(x);
        }
        r[n - i - 1] = sum;
    }

    int ans = -INF;
    rep(i, n + 1) ans = max(ans, l[i] - r[i]);
    cout << ans << endl;
}

Measured memory_bytes: 6516
#include<bits/stdc++.h>
#define N 100005
#define int long long
using namespace std;
int a[N],n,m;
bool b[N];
char c[N],c1[N];
signed main(){
//	scanf("%lld",&n);
//	scanf("%lld%lld",&n,&m);
	scanf("%s",c+1);scanf("%s",c1+1);
	int ans=0;
	if(c[1]==c1[1])ans++;
	if(c[2]==c1[2])ans++;
	if(c[3]==c1[3])ans++;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
const ll mod = 1e9 + 7;

int main()
{
    ll n, l;
    cin >> n >> l;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    int c = 0;
    rep(i, n)
    {
        if (a[i] + a[i + 1] >= l)
            c++;
    }
    if (c == 0)
    {
        cout << "Impossible" << endl;
        return 0;
    }
    rep(i, n - 1)
    {
        if (a[i] + a[i + 1] >= l)
        {
            cout << "Possible" << endl;
            rep(j, i)
                    cout
                << j + 1 << endl;
            for (int j = 1; j < n - i - 1; j++)
                cout << n - j << endl;
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
s = input()
l = len(s)
end1 = "0"
end2 = "1"
for i in range(l-1):
    if i%2==0:
        end1 = end1 + "1"
        end2 = end2 + "0"
    else:
        end1 = end1 + "0"
        end2 = end2 + "1"
start_bin = int("0b"+s,0)
end1_bin = int("0b"+end1,0)
end2_bin = int("0b"+end2,0)

a = start_bin^end1_bin
b = start_bin^end2_bin

a_1 = bin(a).count("1")
b_1 = bin(b).count("1")

if a_1<b_1:
    print(a_1)
else:
    print(b_1)

Measured memory_bytes: 3572
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()

using LL = long long;
int vis[100005];
vector <int> ans;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
	return getchar();
//    if (ib == ie) {
//        ib = ibuf;
//        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
//    }
//    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

using P = pair<int,int> ;
vector<pair<int,int> > g[100005];
int b[100005];
void dfs(int x)
{
	vis[x]=1;
	for(auto u:g[x])
	{
		if(vis[u.first]) continue;
		dfs(u.first);
		if(b[u.first])
		{
			ans.push_back(u.second);
			b[u.first]^=1;
			b[x]^=1;
		}
	}
}

int main() {
    ios_base::sync_with_stdio(false);
    int n,m;
	cin>>n>>m;
	vector <pair<int,int> > psort;
    vector <int> lsh;
    for (int i = 0; i < n; ++i) {
    	int a,b;
		cin>>a>>b;
		psort.push_back(make_pair(a,b));
		lsh.push_back(a);
    }
	sort(all(lsh));
    sort(all(psort));
    for(int i=0;i<n;i++)
    {
    	b[i]=psort[i].second;
	}
	for(int i=n;i>=0;i--)
	{
		b[i]^=(i?b[i-1]:0);
	}
    for (int i = 0; i < m; ++i) {
    	int l,r;
		cin>>l>>r;
		l=lower_bound(all(lsh),l)-lsh.begin();
		r=upper_bound(all(lsh),r)-lsh.begin();
		g[l].push_back(make_pair(r,i));
		g[r].push_back(make_pair(l,i));
    }
	for(int i=0;i<=n;i++)
	{
		if(vis[i]) continue;
		dfs(i);
		if(b[i])
		{
			cout<<-1<<endl;
			return 0;
		}
	}
	sort(all(ans));
	cout<<ans.size()<<endl;
	for(auto x:ans)
	{
		cout<<x+1<<' ';
	}
	cout<<endl;
    return 0;
}


Measured memory_bytes: 14964
N = gets.to_i;
a = gets.split(" ").map(&:to_i);
if N != a.count then exit; end
cost_sum = 0.0;
count = 0.0;

a.each{|value|
	cost_sum += value;
	count += 1;
}

ave = (cost_sum / count).round;
cost = 0;

a.each{|value|
	cost += (value - ave) ** 2;
}

puts cost;

Measured memory_bytes: 1788
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    let mut ans = 0;
    for i in a..b+1 {
        let s = i.to_string();
        let revs = s.chars().rev().collect::<String>();
        if s == revs { ans += 1; }
    }
    println!("{}", ans);
}

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

int main()
{
  int a,b,c,d,e,f;
 cin >>a;
  cin >>b;
  cin >>c;
  cin >>d;
  e=(a+b);
  f=(c+d);
  
  if (e>f)
  {
    cout << "Left"<< endl;
  }
  if (f>e)
  {
    cout << "Right"<< endl;
  }
  if (e==f)
  {
    cout << "Balanced"<< endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	int A,B;
	cin >> A >> B;
	cout << fixed << A*B-A-B+1 << endl;
	
	return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    ll n, ans = 0;
    cin >> n;
    ll t = 100;
    while(t < n){
        t += t / 100;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  string s;
  cin >> s;
  bool ok = true;
  rep(i, s.size()) {
    if (i % 2 == 0) {
      if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') ok = false; 
    } else {
      if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') ok = false; 
    }
    if (!ok) break;
  }
  if (!ok) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);
#define PI (3.14159265358979323846)

using ll = int64_t;
using ull = uint64_t;

using namespace std;

[[maybe_unused]] static auto __x = [](){ios_base::sync_with_stdio(0); cin.tie(0);};

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

    cout << (s[2] == s[3] and s[4] == s[5] ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/soundhound2018-summer-qual/tasks/soundhound2018_summer_qual_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, M, D;
  cin >> N >> M >> D;

  double pair_res = D == 0 ? 1.0 / N : 2 * (N - D) / pow(N, 2);
  double res = (M - 1) * pair_res;

  cout << fixed << setprecision(10) << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int main() {
  long long n, ans;
  cin >> n;
  ans = n;
  vector<string> vec(n);
  for(long long i = 0; i <n; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  long long i= 0;
  while(i < n-1){
    if(vec.at(i)==vec.at(i+1)){
      ans--;
    }
    i++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 9504
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
ll gcd(ll x,ll y){
    if (y == 0) return x;
    return gcd(y, x%y);
}
int main(void){
    ll a,b;cin>>a>>b;
    ll g=gcd(a,b);
    ll res=g*(a/g)*(b/g);
    cout<<res<<endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> s(N);
  for (int i = 0; i < N; ++i)
    cin >> s[i];

  int ans = 0;
  for (int i = 0; i < N; ++i)
    ans += s[i];

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

  if (ans % 10 != 0) {
    cout << ans << endl;
  } else {
    for (int i = 0; i < N; ++i) {
      if (s[i] % 10 != 0) {
        ans -= s[i];
        break;
      }
    }
    if (ans % 10 == 0)
      ans = 0;
    cout << ans << endl;
  }
}

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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int main() {
    int a, b;
    while (cin >> a >> b) {
        if (a == 0 && b == 0) {
            cout << "1" << endl;
            continue;
        }
        int s = a + b;
        int ans = log10(s);
        cout << ans + 1 << endl;
    }

    return 0;
}

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

int fact(ll N)
{
  if(N == 0 || N == 1) return 1;
  return (N*fact(N-1)) % 1000000007;
}

int main()
{
  ll N; cin >> N;
  cout << fact(N) << endl;
}

Measured memory_bytes: 1792
A=int(raw_input())
B=int(raw_input())
C=int(raw_input())
X=int(raw_input())
cnt = 0
for a in xrange(0,1+A):
  for b in xrange(0,1+B):
    for c in xrange(0,1+C):
      if 500*a + 100*b + 50*c == X:
        cnt += 1
print cnt


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, 0, N) cin >> A[i];

  map<ll, ll> mp;
  ll cnt = 0;
  vector<ll> ans;
  REP(i, 0, N) {
    ll k = i + 1;
    if(mp[A[i]] >= 0) {
      cnt++;
    } else {
      cnt--;
    }
    mp[A[i]]++;
    if(mp[A[N - i - 1]] <= 0) {
      cnt++;
    } else {
      cnt--;
    }
    mp[A[N - i - 1]]--;
    if(cnt == 0) ans.push_back(k);
  }
  REP(i, 0, ans.size()) cout << ans[i] << (i + 1 != ans.size() ? " " : "\n");
}



Measured memory_bytes: 6860
//
//  main.cpp
//  AutoAnswerSheets
//
//  Created by Niko@LOS on 2017/03/07.
//
//

#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
    // insert code here...
    int n;
    cin>>n;
    vector<int>vec(n);
    for(int i=0;i<n;i++)cin>>vec[i];
    for(int j=0;j<vec.size();j++)cout<<vec[j]<<(j==vec.size()-1?"":" ");
    cout<<endl;
    for(int i=1;i<n;i++){
        int j,cur=i;
        for(j=cur-1;j>=0;j--){
            if(vec[j]<vec[cur])break;
            swap(vec[cur--],vec[j]);
        }
        for(int j=0;j<vec.size();j++)cout<<vec[j]<<(j==vec.size()-1?"":" ");
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3084
#include <stdio.h>
#include <string.h>

struct dice {
    int face1;
    int face2;
    int face3;
    int face4;
    int face5;
    int face6;
};

struct dice move_W(struct dice d);
struct dice move_S(struct dice d);
struct dice move_E(struct dice d);
struct dice move_N(struct dice d);

int main() {
    struct dice d;
    scanf("%d %d %d %d %d %d",
            &d.face1, &d.face2, &d.face3, &d.face4, &d.face5, &d.face6);

    struct dice d_origin = {d.face1, d.face2, d.face3, d.face4, d.face5, d.face6};

    char command[24][7] = {"", "SEN", "SWN", "SSEE",
                           "N", "NSEN", "NSWN", "NSSEE",
                           "W", "WSEN", "WSWN", "WSSEE",
                           "E", "ESEN", "ESWN", "ESSEE",
                           "S", "SSEN", "SSWN", "SSSEE",
                           "SS", "SSSEN", "SSSWN", "SSSSEE"};

    int n;
    scanf("%d", &n);

    int face_u, face_f;

    int face_r[n];

    for(int i = 0; i < n; i++) {
        scanf("%d %d", &face_u, &face_f);

        for (int j = 0; j < 24; j++) {
            for (int k = 0; k < 7; k++) {
                switch (command[j][k]) {
                    case 'W':
                        d = move_W(d);
                        break;
                    case 'S':
                        d = move_S(d);
                        break;
                    case 'E':
                        d = move_E(d);
                        break;
                    case 'N':
                        d = move_N(d);
                        break;
                    default:
                        break;
                }
            }
            if ((face_u == d.face1)&&(face_f == d.face2)) {
                face_r[i] = d.face3;
                d = d_origin;
                break;
            } else {
                d = d_origin;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%d\n",face_r[i]);
    }

    return 0;
}

struct dice move_W(struct dice d) {
    struct dice d_tmp = {d.face3, d.face2, d.face6, d.face1, d.face5, d.face4};
    return d_tmp;
}

struct dice move_S(struct dice d) {
    struct dice d_tmp = {d.face5, d.face1, d.face3, d.face4, d.face6, d.face2};
    return d_tmp;
}

struct dice move_E(struct dice d) {
    struct dice d_tmp = {d.face4, d.face2, d.face1, d.face6, d.face5, d.face3};
    return d_tmp;
}

struct dice move_N(struct dice d) {
    struct dice d_tmp = {d.face2, d.face6, d.face3, d.face4, d.face1, d.face5};
    return d_tmp;
}



Measured memory_bytes: 2128
#include <cstdio>
#include <string>
#define NODE_MAX_SIZE 100000
#define NULL_INDEX -1

struct Node {
  int parent_index;
  int left_child_index;
  int right_sibling_index;
  int depth;
};

void init_tree(Node tree[], int size) {
  for(int i = 0; i < size; i++) {
    tree[i].parent_index = tree[i].left_child_index = tree[i].right_sibling_index = NULL_INDEX;
  }
}

int get_root_index(Node tree[], int size) {
  for(int i = 0; i < size; i++) {
    if(tree[i].parent_index == NULL_INDEX) {
      return i;
    }
  }

  return NULL_INDEX;
}

void set_depth(Node tree[], int root_node_index, int currentDepth) {
  tree[root_node_index].depth = currentDepth;

  if(tree[root_node_index].left_child_index != NULL_INDEX) {
    set_depth(tree, tree[root_node_index].left_child_index, currentDepth + 1);
  }
  if(tree[root_node_index].right_sibling_index != NULL_INDEX) {
    set_depth(tree, tree[root_node_index].right_sibling_index, currentDepth);
  }
}

void print_tree(Node tree[], int size) {
  for(int node_index = 0; node_index < size; node_index++) {
    Node node = tree[node_index];
    std::string node_type;

    if(node.parent_index == NULL_INDEX) {
      node_type = "root";
    } else if (node.left_child_index == NULL_INDEX) {
      node_type = "leaf";
    } else {
      node_type = "internal node";
    }

    printf("node %d: parent = %d, depth = %d, %s, ", node_index, node.parent_index, node.depth, node_type.c_str());

    printf("[");
    for(int child_node_index = node.left_child_index; child_node_index != NULL_INDEX; child_node_index = tree[child_node_index].right_sibling_index) {
      printf("%d", child_node_index);

      if(tree[child_node_index].right_sibling_index != NULL_INDEX) {
        printf(", ");
      }
    }
    printf("]");

    printf("\n");
  }
}
int main() {
  Node tree[NODE_MAX_SIZE];
  int node_size;

  scanf("%d%*c", &node_size);
  init_tree(tree, node_size);


  for(int i = 0; i < node_size; i++) {
    int node_index, child_num;
    scanf("%d %d", &node_index, &child_num);
    int previous_child_index;
    for(int j = 0; j < child_num; j++) {
      int child_index;
      scanf("%d", &child_index);

      tree[child_index].parent_index = node_index;
      if (j == 0) {
        tree[node_index].left_child_index = child_index;
      } else {
        tree[previous_child_index].right_sibling_index = child_index;
      }

      previous_child_index = child_index;
    }
  }

  int root_index = get_root_index(tree, node_size);
  set_depth(tree, root_index, 0);

  print_tree(tree, node_size);
}



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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    int32 mnr = INF;
    int32 mxl = 0;
    int32 mxrange = 0;
    vector<pii> lr(n);
    REP(i,n){
        int32 l, r;
        cin >> l >> r;
        r++;
        lr[i] = pii(l,r);
        mnr = min(mnr, r);
        mxl = max(mxl, l);
        mxrange = max(mxrange, r - l);
    }
    int32 ans = max<int32>(0, mnr - mxl) + mxrange;
    vector<pii> ab(n);
    REP(i,n){
        ab[i] = pii(max<int32>(0, mnr-lr[i].first), -max<int32>(0, lr[i].second - mxl));
    }
    sort(ALL(ab));
    int32 w = -ab[0].second;
    FOR(i,1,n){
        int32 a, b;
        tie(a, b) = ab[i];
        b *= -1;
        ans = max(ans, a + w);
        w = min(w, b);
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 3328
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

map <int, bool> mp;

int main(){
  int X, N; cin >> X >> N;
  for (int i = 0; i < N; i++){
    int P; cin >> P;
    mp[P] = true;
  }

  int now;
  for (int i = 0; i <= 1e5; i++){
    now = X - i;
    if (mp[now] == false){
      cout << now << endl;
      return 0;
    }
    now = X + i;
    if (mp[now] == false){
      cout << now << endl;
      return 0;
    }
  }

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n), h(n);
  rep(i, n) cin >> x[i] >> y[i] >> h[i];

  for (int cx = 0; cx <= 100; ++cx) {
    for (int cy = 0; cy <= 100; ++cy) {
      int H = 2e9;
      rep(i, n) H = min(H, h[i] + abs(x[i] - cx) + abs(y[i] - cy));
      if (H == 0) continue;
      bool ok = true;
      rep(i, n) if (h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), 0)) ok = false;
      if (ok) {
        printf("%d %d %d\n", cx, cy, H);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	int a[n];
	REP(i,n) cin >> a[i];
	int two = 0,four = 0,odd = 0;
	REP(i,n){
		if(a[i] % 4 == 0) four++;
		else if(a[i] % 2 == 0) two++;
		else odd++;
	}
	if(two % 2 == 0){
		if(odd == 1 && 0 < four) cout << "Yes" << endl;
		else if(odd <= four + 1) cout << "Yes" << endl;
		else cout << "No" << endl;
	}else{
		if(0 < four && odd <= four) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

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

int main( void ) {
    
    long long s, c;
    cin >> s >> c;
    
    long long ans;
    if( c >= s * 2 )
        ans = s + ( c - s * 2 ) / 4;
    else
        ans = c / 2;
    
    cout << ans << endl;
    return 0;
}

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

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b;
    }

int main() {
    long long n, m;
    cin >> n >> m;
    vector<long long> A(n);
    for (int i = 0; i < n; ++i) cin >> A[i];
    for (int i = 0; i < n; ++i) A[i] /= 2;
    long long b = 1;
    while (A[0] % 2 == 0) {
        A[0] /= 2;
        b *= 2;
    }
    for (int i = 1; i < n; ++i) {
        if (A[i] % b != 0) {
            cout << 0 << endl;
            return 0;
        }
        A[i] /= b;
        if (A[i] % 2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    long long l = 1;
    for (int i = 0; i < n; ++i) {
        l = lcm(l, A[i]);
        if (l > m) {
            cout << 0 << endl;
            return 0;
        }
    }

    m /= b;
    long long ans = (m/l+1) / 2;
    cout << ans << endl;
    
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    map<pair<int, int>, int> dct;
    int n;
    cin >> n;
    vector<pair<int, int>> pts(n);
    for (int i = n; i--;)
    {
        int x, y;
        cin >> x >> y;
        pts[i] = {x, y};
    }
    int ma = 0;
    for (int i = 0; i != n; ++i)
    {
        for (int j = 0; j != n; ++j)
        {
            if (j == i)
                continue;
            
            int dx = pts[j].first - pts[i].first;
            int dy = pts[j].second - pts[i].second;
            if (dct.find({dx, dy}) == dct.end())
            {
                dct[{dx, dy}] = 1;
                ma = max(ma, 1);
            }
            else
            {
                ++dct[{dx, dy}];
                ma = max(ma, dct[{dx, dy}]);
            }
        }
    }
    cout << n - ma << '\n';
    
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r,g,b,x;
  cin >> r >> g >> b;
  x = 10*g + b;
  if(x%4==0||(g==0&&b==0)){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N, K;
  string S; 
  cin >> N >> K >> S;
  
  if(S.at(K-1) == 'A')S.at(K-1) = 'a';
  if(S.at(K-1) == 'B')S.at(K-1) = 'b';
  if(S.at(K-1) == 'C')S.at(K-1) = 'c';

  cout << S << endl;
}

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M);
  for (int i = 0; i < M; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int tmp = 0;
      cin >> tmp;
      s[i] |= (1 << (tmp - 1));
    }
  }
  vector<int> p(M);
  copy_n(istream_iterator<int>(cin), M, p.begin());

  int result = 0;
  int pattern_num = 1 << N;
  for (int onoff = 0; onoff < pattern_num; ++onoff) {
    int shine = true;
    for (int i = 0; i < M; ++i) {
      int tmp = onoff & s[i];
      tmp = (tmp & 0x5555) + ((tmp >> 1) & 0x5555);
      tmp = (tmp & 0x3333) + ((tmp >> 2) & 0x3333);
      tmp = (tmp & 0x0F0F) + ((tmp >> 4) & 0x0F0F);
      tmp = (tmp & 0x00FF) + ((tmp >> 8) & 0x00FF);
      if ((tmp & 1) != p[i]) {
        shine = false;
      }
    }
    result += shine;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#define fst first
#define snd second
#define fore(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define bs binary_search
#define mm(a,b) memset(a,b,sizeof(a))
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int) (n).size())
#define MAXI ((ll)1e16)
#define MINI ((ll)-1e16)
#define EPS 1e-9
using namespace std;
typedef long long ll; 
typedef long double ld;
const long long M = 1e9+7; 
const long long INF = 1e9;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
string s;
int main(){FIN;
	cin >> s;
	ll c = 0;
	ll r = 0;
	ll n = SZ(s);
	fore(i,0,n){
		if(s[i]=='W')r+=i-c, c++;
	}
	cout << r;
	
}

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;
typedef double ld;
typedef pair<ld, ld> pdd;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pi = acos(-1);

ld angle(ld x0, ld y0, ld x1, ld y1, ld x2, ld y2){
  ld sol = atan2(x1-x2,y1-y2) - atan2(x1-x0,y1-y0);
  if(sol < 0) sol = -sol;
  if(sol > pi) sol = 2.0 * pi - sol;
  return sol;
}

ld crossp(ld x0, ld y0, ld x1, ld y1, ld x2, ld y2){
  ld sign = (y1 - y0) * (x2 - x1) - (y2 - y1) * (x1 - x0);
  if(sign < 0) return -1;
  else if(sign == 0) return 0;
  else return +1;
}

struct P{
  ld xi;
  ld yi;
  int id;
  bool operator<(const P &T) const {
    if(xi == T.xi) return yi < T.yi;
    return xi < T.xi;
  }
};

bool ccw(P A, P B, P C){
  return crossp(A.xi, A.yi, B.xi, B.yi, C.xi, C.yi) > 0;
}

bool cw(P A, P B, P C){
  return crossp(A.xi, A.yi, B.xi, B.yi, C.xi, C.yi) < 0;
}


const int N = 1005;
ld x[N], y[N];
ld res[N];

int main(){
  fastIO;
  int n;
  cin >> n;
  vector<P> si;
  for(int i = 0 ; i < n; i ++ ){
    cin >> x[i] >> y[i];
    si.push_back({x[i],y[i],i});
  }
  sort(si.begin(), si.end());
  vector<P> up, down;
  P pf, pl;
  pf = si[0];
  pl = si.back();
  up.push_back(pf);
  down.push_back(pf);
  for(int i = 1; i < (int)si.size(); i ++ ){
    if(i + 1 == si.size() || cw(pf, si[i], pl)){
      while(up.size() >= 2 && !cw(up[(int)up.size() - 2], up[(int)up.size() - 1], si[i])){
        up.pop_back();
      }
      up.push_back(si[i]);
    }
    if(i + 1 == si.size() || ccw(pf, si[i], pl)){
      while(down.size() >= 2 && !ccw(down[(int)down.size() - 2], down[(int)down.size() - 1], si[i])){
        down.pop_back();
      }
      down.push_back(si[i]);
    }
  }
  vector<P> hull = down;
  for(int i = (int)up.size() - 2; i > 0; i -- ){
    hull.push_back(up[i]);
  }
  int lf, rf;
  ld deg1, deg2;
  ld ang;
  ld sum = 0;
  for(int i = 0 ; i < hull.size(); i ++ ){
    lf = (i + (int)hull.size() - 1) % (int)hull.size();
    rf = (i + 1) % (int)hull.size();
    ang = angle(hull[lf].xi, hull[lf].yi, hull[i].xi, hull[i].yi, hull[rf].xi, hull[rf].yi);
    res[hull[i].id] = ((pi-ang)/(2.00*pi));
  }
  for(int i = 0 ; i < n; i ++ )
    cout << fixed << setprecision(10) << res[i] << "\n";
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

ll INF = (1LL << 30) - 1;

const ll MOD = 1000000007;

using namespace std;

ll D[205][205];
int t[9];
int N, M, R;
vector<vector<int> > indexTbl;

void minR(vector<int> index)
{
	if (index.size() == R)
	{
		indexTbl.push_back(index);
		return;
	}

	REP(i, R)
	{
		bool contain = false;
		REP(j, index.size())
		{
			if (i == index[j])
			{
				contain = true;
				break;
			}
		}
		if (contain)continue;

		index.push_back(i);
		minR(index);
		index.pop_back();
	}
	return;
}

int main()
{
	cin >> N >> M >> R;
	REP(i, R)
	{
		int r;
		cin >> r;
		r--;
		t[i] = r;
	}
	REP(i, N)
	{
		REP(j, N)
		{
			if (i == j)	D[i][j] = 0;
			else D[i][j] = INF;
		}

	}
	REP(i, M)
	{
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		if (D[a][b] > c)
		{
			D[a][b] = D[b][a] = c;
		}
	}


	REP(k, N)
	{
		REP(i, N)
		{
			REP(j, N)
			{
				D[i][j] = std::min(D[i][j], D[i][k] + D[k][j]);
			}
		}
	}

	vector<int> v;
	minR(v);

	ll ans = INF;
	REP(i, indexTbl.size())
	{
		vector<int> index = indexTbl[i];
		ll m = 0;
		FOR(k, index.size(), 1)
		{
			int to = index[k], from = index[k - 1];
			m += D[t[to]][t[from]];
		}
		ans = std::min(ans, m);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

static vector<double> solve_simultaneous(const vector<double> &set) {
	vector<double> result(2, 0);
	result.at(0) = ( (set.at(2) * set.at(4) - set.at(1) * set.at(5))
		/ (set.at(0) * set.at(4) - set.at(1) * set.at(3)) );
	result.at(1) = ( (set.at(2) * set.at(3) - set.at(0) * set.at(5))
		/ (set.at(1) * set.at(3) - set.at(0) * set.at(4)) );

	if (result.at(0) == 0) {
		result.at(0) = 0;
	}
	if (result.at(1) == 0) {
		result.at(1) = 0;
	}

	return result;
}

int main(void) {
	int dataset_counter = 0;
	double check_input = 0;
	vector<vector<double> > input;

	while (cin >> check_input) {
		input.push_back(vector<double>(6));
		input.at(dataset_counter).at(0) = check_input;
		for (int i = 1; i < 6; i ++) {
			double temp;
			cin >> input.at(dataset_counter).at(i);
		}

		dataset_counter ++;
	}

	for (vector<double> dataset : input) {
		vector<double> result(2, 0);
		result = solve_simultaneous(dataset);

		cout << fixed;
		cout << setprecision(3) << result.at(0) << " "
		<< setprecision(3) << result.at(1) << endl;
	}

	return 0;
}



Measured memory_bytes: 3184
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;

int main()
{
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	int ans = 0;
	if (A+B<=2*C)
	{
		ans = A * X + B * Y;
	}
	else
	{
		if (X>=Y)
		{
			ans += 2* C * Y;
			ans += min(A * (X - Y), 2 * C * (X - Y));
		}
		else
		{
			ans += 2 * C * X;
			ans += min(B * (Y - X), 2 * C * (Y - X));
		}
	}
	co(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

ll gcd(ll a, ll b) {
    if (a<b) swap(a, b);
    while(b!=0) {
        ll t = a;
        a = b;
        b = t%b;
    }
    return a;
}

ll lcm(ll a, ll b) { return a/gcd(a, b)*b; }

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

int const H = 81;
int const W = 81;
bool dp[H][W][(H+W)*H];

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

    int n, m; cin >> n >> m;
    vector<pair<int, int>> ab(n);
    rep(i, n) cin >> ab[i].first >> ab[i].second;
    sort(ab.begin(), ab.end());
    int ans = 0;

    priority_queue<int> pq;
    int cur = 0;
    reprev(i, m) {
        int lim = m-i;
        while(cur<n && ab[cur].first<=lim) { pq.push(ab[cur++].second); }
        if (pq.size()) { ans += pq.top(); pq.pop(); }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1660
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	string S; cin >> S;
	int left = 0;
	int right = 0;
	rep(i, N - 1) {
		if (S[i + 1] == 'W') left++;
		else right++;
	}
	int ans = INF;
	int tmp = right;
	rep(i, N) {
		ans = min(ans, tmp);
		if (i == N - 1) break;
		if (S[i] == 'W') tmp++;
		if (S[i + 1] == 'E') tmp--;
	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 720
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
ans=''
x,y=map(int,input().split(' '))
if x==y: ans='Yes'
else:
    for c in [a,b]:
        if (x in c)*(y in c):
            ans='Yes'
            break
if ans=='': ans='No'
print(ans)

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

#define int long long

const int N = 1e6 + 10;
int n, ans;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 1; i * i <= n; i++)
		if ((n - i) % i == 0 && (n - i) / i > i)
			ans += (n - i) / i;
	cout << ans;
}

Measured memory_bytes: 256