akhauriyash/Code-Regression huggingface dataset:
use std::io::{stdout, Write};
use std::thread;

fn run() {
    let input = read_input();
    let mut input = input.split_whitespace();
    let in_n: i64 = input.next().unwrap().parse().unwrap();
    let in_x: Vec<i64> = input.map(|s| s.parse().unwrap()).collect();

    let mut y = in_x.clone();
    y.sort();
    let x1 = y[in_n as usize / 2 - 1];
    let x2 = y[in_n as usize / 2];

    let mut out = stdout();
    for x in in_x {
        writeln!(out, "{}", if x <= x1 { x2 } else { x1 }).unwrap();
    }
}

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    use std::fs::File;
    use std::io::Read;
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => std::io::stdin().read_to_string(&mut s).unwrap(),
    };
    s
}


Measured memory_bytes: 17656
import sys
input = sys.stdin.readline  # NOQA
sys.setrecursionlimit(10 ** 7)  # NOQA


def dfs(G, v, p, counter):
    """G: graph, v: vertex, p: parent"""
    # Loop for each child
    counter_v = counter[v]
    for c in G[v]:
        if c == p:
            continue  # Avoid multiple access to parent
        counter[c] += counter_v
        dfs(G, c, v, counter)


def main():
    N, Q = map(int, input().split())
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)

    counter = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        counter[p] += x

    dfs(G, 0, -1, counter)
    print(*counter)


if __name__ == "__main__":
    main()


Measured memory_bytes: 230960
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

struct UnionFind
{
    vector<int> rank, parents;
    UnionFind() {}
    UnionFind(int n)
    {
        rank.resize(n, 0);
        parents.resize(n, 0);
        for (int i = 0; i < n; i++)
        {
            makeTree(i);
        }
    }
    void makeTree(int x)
    {
        parents[x] = x;
        rank[x] = 0;
    }
    bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
    void unite(int x, int y)
    {
        x = findRoot(x);
        y = findRoot(y);
        if (rank[x] > rank[y])
        {
            parents[y] = x;
        }
        else
        {
            parents[x] = y;
            if (rank[x] == rank[y])
            {
                rank[y]++;
            }
        }
    }
    int findRoot(int x)
    {
        if (x != parents[x])
            parents[x] = findRoot(parents[x]);
        return parents[x];
    }
};

struct Edge
{
    long long u;
    long long v;
    long long cost;
};

bool comp_e(const Edge &e1, const Edge &e2)
{
    return e1.cost < e2.cost;
}

bool comp_e_greater(const Edge &e1, const Edge &e2)
{
    return e1.cost > e2.cost;
}

struct Kruskal
{
    UnionFind uft;
    long long sum;
    vector<Edge> edges;
    vector<Edge> resEdges;
    int V;
    Kruskal(const vector<Edge> &edges_, int V_) : edges(edges_), V(V_) { init(); }
    void init()
    {
        sort(edges.begin(), edges.end(), comp_e);
        uft = UnionFind(V);
        sum = 0;
        for (auto e : edges)
        {
            if (!uft.isSame(e.u, e.v))
            {
                uft.unite(e.u, e.v);
                sum += e.cost;
                resEdges.push_back(e);
            }
        }
    }
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<pair<ll, ll>> x(N), y(N);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i].first >> y[i].first;
        x[i].second = i;
        y[i].second = i;
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    vector<Edge> edges;
    for (int i = 1; i < N; i++)
    {
        Edge e1 = {x[i - 1].second, x[i].second, x[i].first - x[i - 1].first};
        edges.push_back(e1);
        Edge e2 = {y[i - 1].second, y[i].second, y[i].first - y[i - 1].first};
        edges.push_back(e2);
    }
    Kruskal krs(edges, N);
    cout << krs.sum << endl;
    return 0;
}


Measured memory_bytes: 21840
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    string S;
    cin >> S;
    int min = 1000;
    for (int i = 0; i < S.length() - 2; i++){
        string tmp = S.substr(i,3);
        int tmp1;
        tmp1 = stoi(tmp);
        if (min > abs(tmp1 - 753)){
            min = abs(tmp1 - 753);
        }
    }
    cout << min << endl;
}

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

int main() {
  int n,x;
  cin>>n>>x;
   vector<int> v(n+1);
  rep(i,n) cin>>v[i];
  v[n]=x;
  ////////////
  sort(all(v));
  int ans;
  vector<int> s(n);
  rep(i,n){
    s[i]=v[i+1]-v[i];
  }
  ans=s[0];
  rep(i,n){
   ans=__gcd(s[i],ans) ;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string S,T; cin>>S>>T;
  int A,B; cin>>A>>B;
  string U; cin>>U;
  if(S==U) A--;
  else B--;
  cout<<A<<" "<<B<<endl;
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e5 + 7;
const int md = 1e9 + 7;
void sol() {
  int n, m, ans;
  int a, s = 0;
  cin >> n >> m;
  for(int i=0; i<m; i++) {
    cin >> a;
    s += a;
  }
  if(s <= n) {
    ans = n - s;
  }
  else ans = -1;
  cout << ans << "\n";
}

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;

  /*COMMENT BELOW WITHOUT FAIL*/
  //freopen("input.txt", "r", stdin);
  /*REMOVE ABOVE WITHOUT FAIL BEFORE SUBMITTING */

  //cin >> T;
  for(int i = 1; i <= T; i++) {
    //cout << "Case " << "#" << i << ": ";
    sol();
  }
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using namespace std;

int main(){
  int a, b, c; cin >> a >> b >> c;
  if (b-a==c-b) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef long long ll;  //ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<ll, ll> > PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    

template<typename T>
T lcm(T a, T b){
    return a/gcd(a,b)*b;
}    
// g++ -std=c++11 prac.cpp 

int main(){
    ll x=0,y=0,z=0,n,m=0,k,h,w,ans=0,sum=0,Max=-1e9-1,count=0,Min=1e9+1;
    string s,t,u;
    bool ok=false;
    cin >> n;
    if(n%2 != 0){
        cout << 0 << endl;
        return 0;
    }
    else{
        n /= 2;
        for (int i = 1; ll(pow(5, i)) <= n; i++) {
            ans += n / ll(pow(5, i));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import heapq
k = int(input())
q = [1, 2, 3, 4, 5, 6, 7, 8, 9]
count = 0
while q:
    cur = heapq.heappop(q)
    count += 1
    if (count == k):
        print(cur)
        sys.exit()
    else:
        if (cur % 10 != 0):
            heapq.heappush(q, (cur*10) + (cur%10) - 1)
        if (cur % 10 != 9):
            heapq.heappush(q, (cur * 10) + (cur % 10) + 1)
        heapq.heappush(q, (cur * 10) + (cur % 10))


Measured memory_bytes: 11732
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ary[], t, i;
		int w = sc.nextInt();
		ary = new int[w + 1];
		for(i = 0; i < w; i++)
			ary[i + 1] = i + 1;
		int n = sc.nextInt();
		for(i = 0; i < n; i++){
			String[] s = sc.next().split(",", 0);
			int a = Integer.parseInt(s[0]);
			int b = Integer.parseInt(s[1]);
			t = ary[a];
			ary[a] = ary[b];
			ary[b] = t;
		}
		for(i = 0; i < w; i++)
			System.out.println(ary[i + 1]);
	}
}

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

using namespace std;

int
main (
  int   argc,
  char *argv[ ]
  )
{
  for ( ; ; )
  {
    int x, y;

    cin >> x >> y;
    if ( x == 0 && y == 0 ) break ;

    cout << min ( x, y ) << " " << max ( x, y ) << endl;
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <iostream>
#include <string>

bool is_month(int vv) { return vv > 0 && vv < 13; }

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

  const auto vv1 = vvvv / 100;
  const auto vv2 = vvvv - 100 * vv1;

  if (is_month(vv1) && is_month(vv2)) {
    std::cout << "AMBIGUOUS" << std::endl;
  } else if (is_month(vv1) && !is_month(vv2)) {
    std::cout << "MMYY" << std::endl;
  } else if (!is_month(vv1) && is_month(vv2)) {
    std::cout << "YYMM" << std::endl;
  } else {
    std::cout << "NA" << std::endl;
  }
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int k;
    string s;
    cin >> k;
    cin >> s;
    vector<char> ans;
    int sl = (int)s.length();
    if(sl > k)
    {
        for (int i = 0; i < k; i++)
        {
            ans.push_back(s[i]);
        }
        for (int i = 0; i < 3; i++)
        {
            ans.push_back('.');
        }
    }else
    {
        cout << s << endl;
        return 0;
    }
    for (int i = 0; i <sz(ans); i++)
    {
        cout << ans[i];

    }
    cout << endl;
}

Measured memory_bytes: 3632
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map { it.toInt() }
    val (R, S, P) = readLine()!!.split(" ").map { it.toInt() }
    val T = readLine()!!

    val r = 'r'; val s = 's'; val p = 'p'

    var result = 0L
    f@ for (i in 0 until K) {
        var pre = 'n'
        var preP = 0
        s@ for (j in i until N step K) {
            val current = T[j]
            if (pre == current && preP != 0) {
                preP = 0
                continue@s
            }

            pre = current
            preP = when (current) {
                r -> P
                s -> R
                p -> S
                else -> 0
            }
            result += preP
        }
        pre = 'n'
        preP = 0
    }
    println(result)
}

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

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

	set<int64_t> as, bs, cs;
	for (int64_t i = 0; i < n; i++)
	{
		int64_t x = (s[i] - '0');

		for (auto &&b : bs)
		{
			cs.insert(10 * b + x);
		}

		for (auto &&a : as)
		{
			bs.insert(10 * a + x);
		}

		as.insert(x);
	}

	cout << cs.size() << endl;

	return 0;
}

Measured memory_bytes: 3712
// AOJ 0097: Sum of Integers II
// 2017.9.1 bal4u@uu
// 2017.11.1 retry

#include <stdio.h>
long long dp[11][1001];

int main()
{
	int n, s, k;

	dp[0][0] = 1;
	for (k = 0; k <= 100; k++)
		for (n = 9; n >= 0; n--)
			for (s = 0; s <= 1000-k; s++)
				dp[n+1][s+k] += dp[n][s];

	while (scanf("%d%d", &n, &s) && n > 0) printf("%lld\n", dp[n][s]);
	return 0;
}

Measured memory_bytes: 1928
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[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;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,l) = get!(usize, usize);
    let a = get!([usize]);
    for i in 0..n-1 {
        if a[i] + a[i+1] >= l {
            println!("Possible");
            for j in 0..n-1 {
                if i != j {
                    println!("{}", j+1);
                } else {
                    break;
                }
            }
            for j in (0..n-1).rev() {
                if i != j {
                    println!("{}", j+1);
                } else {
                    break;
                }
            }
            println!("{}", i+1);
            return;
        }
    }
    println!("Impossible");
}


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

using ll=long long;
using namespace std;

#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    string s; 
    getline(cin, s);
    string ans;

    for (int i = 0; i < s.length(); i++){
        if (s[i] >= 65 && s[i] <= 90){
            s[i] += 32;
            continue;
        }
        if (s[i] >= 97 && s[i] <= 122){
            s[i] -= 32;
            continue;
        }
    }

    cout << s << endl;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int a[101];
int main()
{
	int n,m;
	int x,y;
	memset(a,0,sizeof(a));
	cin>>n>>m;
	for(int i = 0; i < m; i++){
		cin>>x>>y;
		a[x]++;
		a[y]++;
	}
	for(int i = 1; i <= n; i++){
		cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    print(compute(min(n, m), max(n, m)))


def compute(n, m):
    if n == 1 and m == 1:
        return 1
    if n == 1:
        return max(0, m - 2)
    return (n - 2) * (m - 2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n;
    cin >> n;
    //unordered_map<ll, int> count;
    //count.reserve(1024);
    vector<pair<ll, int>> factors;
    ll ans = 0;
    for(ll i = 2; i *i <= n; i++){
        int cnt = 0;
        while(n % i == 0){
            cnt++;
            //ans = max(ans, count[i]);
            //ans -= count[i]/2;
            //ans += (count[i]+1)/2;
            n/=i;
            //factors.pb(i);
        }
        factors.pb(mp(i, cnt));
    }
    if(n != 1){
        factors.pb(mp(n,1));
        //count[n]++;
        //ans += 1; 
    }
    for(auto it : factors){
        int times = it.s;
        //int times = count[it];
        int curr = 1;
        while(times - curr >= 0){
            times -= curr;
            curr++;
            ans++;
        }
    }
    cout << ans << endl;

}



Measured memory_bytes: 19688
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint X=1000000000;
	llint S;cin>>S;S--;
	cout<<X<<" "<<0<<" "<<0<<" "<<1<<" "<<S%X+1<<" "<<S/X+1<<endl;
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1001001001
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int k;
char c[6][6];
bool select_h[6];
bool select_w[6];
int cnt_k=0;
int cnt_out=0;

bool check(int h,int w){
    cnt_k = 0;
    REP(i,h){
        if(select_h[i] == true) continue;
        REP(j,w){
            if(select_w[j] == true) continue;
            if(c[i][j] == '#') cnt_k++;
        }
    }
    if(cnt_k == k) return true;
    else return false;
}

void dfs_w(int i,int h,int w){
    i++;
    if(i==w){
        if(check(h,w)) cnt_out++;
        return;
    }
    select_w[i] = false;
    dfs_w(i,h,w);
    select_w[i] = true;
    dfs_w(i,h,w);
}

void dfs_h(int i,int h,int w){
    i++;
    if(i==h){
        dfs_w(-1,h,w);
        return;
    }
    select_h[i] = false;
    dfs_h(i,h,w);
    select_h[i] = true;
    dfs_h(i,h,w);
}

int main() {
    int h,w;cin >> h >> w >> k;
    REP(i,h){
        REP(j,w) cin >> c[i][j];
    }
    dfs_h(-1,h,w);
    cout << cnt_out << endl;
}

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

P f(int x){
	int a = x % 10;
  	int b = 0;
  	while(x){
    	b = x;
      	x /= 10;
    }
  	return P(a, b);
}

int main(){
	int n;
  	cin >> n;
  	map<P, int> freq;
  	for(int i = 1; i <= n; i++){
    	P p = f(i);
      	freq[p]++;
    }
        
    long long ans = 0;
  
    for(int i = 1; i <= n; i++){
    	P p = f(i);
      	P q(p.second, p.first);
      	ans += freq[q];
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [None]*n
for i in range(n):
    a[i] = int(input())
    
a.sort()
b = [None]*n
if n%2==0:
    b[0] = a[n//2-1]
    b[-1] = a[n//2]
    l1 = a[:n//2-1]
    l2 = a[n//2+1:][::-1]
    for i in range(len(l1)):
        b[2*i+1] = l2[i]
        b[2*i+2] = l1[i]
    ans = sum(abs(b[i]-b[i+1]) for i in range(n-1))
else:
    ind = n//2+1
    b[0] = a[ind]
    b[-1] = a[n//2]
    l1 = a[:n//2]
    l2 = a[ind:][::-1]
    b[1] = l1[0]
    for i in range(len(l1)-1):
        b[2*i+2] = l2[i]
        b[2*i+3] = l1[i+1]
    ans1 = sum(abs(b[i]-b[i+1]) for i in range(n-1))
    
    ind = n//2-1
    b[0] = a[n//2]
    b[-1] = a[ind]
    l1 = a[:ind]
    l2 = a[n//2+1:]
    b[1] = l2[0]
    for i in range(len(l2)-1):
        b[2*i+2] = l1[i]
        b[2*i+3] = l2[i+1]
    ans2 = sum(abs(b[i]-b[i+1]) for i in range(n-1))
    ans = max(ans1, ans2)
print(ans)

Measured memory_bytes: 82600
program CADDiB2018B
    implicit none
    integer(8)::N,H,W,A,B,i,ans=0
    read*,N,H,W
    do i=1,N
        read*,A,B
        if(A>=H.and.B>=W)ans=ans+1
    end do
    print'(i0)',ans
end program CADDiB2018B

Measured memory_bytes: 2812
#include<iostream>
#include<cstdio> 
#include<stdlib.h>
#include<cstring>
#include<algorithm>
#include<cmath>

#define MAXN 0x7fffffff
#define ll long long

using namespace std;

int m,n,i,j,k,p,q,l,flag=0;

int main(){
	ll lo[87];
	lo[0]=2;
	lo[1]=1;
	scanf("%d",&n);
	for(i=2;i<=n;i++){
		lo[i]=lo[i-1]+lo[i-2];
	}
	printf("%lld",lo[n]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

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

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define fi first 
#define se second

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;


void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

template<class T> class Union_Find {
public:
	vector<int> prnt;
	vector<int> rank;
	vector<T> dist;

	Union_Find(int N = 1):prnt(vector<int>(N)),rank(vector<int>(N,0)),dist(vector<int>(N, 0)) {
		for (int i = 0; i < N; ++i) prnt[i] = i;
	}

	int root(int x) {
		if (prnt[x] == x) {
			return x;
		}
		else {
			int r = root(prnt[x]);
			dist[x] += dist[prnt[x]];
			return prnt[x] = r;
		}
	}

	T weight(int x) {
		root(x);
		return dist[x];
	}

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

	bool merge(int x, int y, T w) {
		w += weight(x); w -= weight(y);
		x = root(x); y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y), w = -w;
		if (rank[x] == rank[y]) ++rank[x];
		prnt[y] = x;
		dist[y] = w;
		return true;
	}

	T diff(int x, int y) {
		return weight(y) - weight(x);
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	Union_Find<int> uf(N);
	for (int i = 0; i < M; ++i) {
		int l, r, d;
		cin >> l >> r >> d;
		--l, --r;
		if (uf.same(l, r)) {
			if (d != uf.diff(l, r)) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			uf.merge(l, r, d);
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1408
import itertools
N = int(input())
numslist = [0,0,0,0,0]
ans=0
for i in range(N):
    head=[j for j in input()][0]
    if head=="M":
        numslist[0]+=1
    elif head=="A":
        numslist[1]+=1
    elif head=="R":
        numslist[2]+=1
    elif head=="C":
        numslist[3]+=1
    elif head=="H":
        numslist[4]+=1
for v in itertools.combinations(numslist, 3):
    ans+=(v[0]*v[1]*v[2])
print(ans)

Measured memory_bytes: 3064
a,b,c=input().split()
a=int(a);b=int(b);c=int(c)

if a>c:
    d=a;a=c;c=d

if b>c:
    d=b;b=c;c=d

if a>b:
    d=a;a=b;b=d

print(a,b,c)

Measured memory_bytes: 7632
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

int n, m;
char a[60][60], b[60][60];
bool ans;

bool match(int x, int y) {
	FOE(i, 1, m) FOE(j, 1, m) if (b[i][j] != a[i + x][j + y]) return 0;
	return 1;
}

int main () {
	
	scanf("%d%d", &n, &m);
	
	FOE(i, 1, n) scanf("%s", a[i] + 1);
	FOE(i, 1, m) scanf("%s", b[i] + 1);
	
	FOE(i, 0, n - m + 1) FOE(j, 0, n - m + 1) if (match(i, j)) ans = 1;
	
	printf("%s\n", ans ? "Yes" : "No");
	
	return 0;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
const int64_t mod = 1e9 + 7;
int64_t dp[310][310][310]={};

int main(){
    int N,M;
    cin>>N>>M;
    dp[0][1][1]=1;
    if(false/*N>M*/){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<M;i++){//i日目の行動
        for(int j=1;j<=N;j++){//これまで行ったことのある頂点数
            for(int k=1;k<=j;k++){//1を含む強連結成分数   dp[i][j][k]から次の状態への遷移を求める。
                if(dp[i][j][k] != 0){
                    dp[i+1][j][k] = (dp[i+1][j][k] + dp[i][j][k]*(j-k))%mod;
                    dp[i+1][j][j] = (dp[i+1][j][j] + dp[i][j][k]*k)%mod;
                    dp[i+1][j+1][k] = (dp[i+1][j+1][k] + dp[i][j][k]*(N-j) )%mod;
                    //cout<<i<<' '<<j<<' '<<k<<endl;
                }
            }
        }
    }
    cout<<dp[M][N][N]<<endl;
    return 0;
}


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

using namespace std;

int main() {
  int m=999;
  string S;
  cin >> S;
  for (int j=0; j < S.size(); ++j) {
    string s = S.substr(j, 3);
    int si = stoi(s);
    m = min(m, abs(753-si));
  }
  cout << m << endl;
}

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

int main()
{
  double A,B,H,M;
  cin >> A >> B >> H >> M;
  double minute = 60 * H + M;
  double sa = (M_PI * 11 * minute) / 360;
  if(sa > 180) sa = 360 - sa;
  double answer = sqrt(A*A + B*B - 2*A*B*cos(sa));
  cout << fixed << setprecision(10);
  cout << answer << endl;
}


Measured memory_bytes: 4220
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,k,c;
  cin>>a>>b>>k;
  if(a>0 && k>0){
    c=a;
  	a-=k;
    k-=c;
  }
  if(b>0 && k>0){
    c=b;
    b-=k;
    k-=c;
  }
  if(a<0)
    a=0;
  if(b<0)
    b=0;
  cout<<a<<" "<<b<<endl;
  return(0);
}
  

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

vector<vector<int>> graph;
vector<int> p;
vector<int> ans;
void dfs(int pre, int cur, int cnt) {
  cnt += p[cur];
  ans[cur] = cnt;
  for(int x : graph[cur]) {
    if(x == pre) continue;
    dfs(cur, x, cnt);
  }
}

int main(){
  int n, q;
  cin >> n >> q;
  ans.resize(n);
  graph.resize(n);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  p.resize(n);
  rep(i, q) {
    int a, b;
    cin >> a >>b;
    --a;
    p[a] += b;
  }
  dfs(-1, 0, 0);

  rep(i, n) printf("%d%c", ans[i], i == n-1 ? '\n' : ' ');
}

Measured memory_bytes: 24320
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <set>
#include <vector>
using namespace std;
typedef vector<int> vi;

int V, E;
const int MAX_V = 100000;

vi G[MAX_V];

int parent[MAX_V];
int prenum[MAX_V];
int lowest[MAX_V];

int cnt;

int chi = 0;

void dfs(int v) {
    prenum[v] = lowest[v] = ++cnt;

    for (auto to : G[v]) {
        if (prenum[to] == 0) {
            parent[to] = v;
            dfs(to);
            lowest[v] = min(lowest[v], lowest[to]);
            chi += v == 0;
        } else if (v != 0 && parent[v] != to) {
            lowest[v] = min(lowest[v], prenum[to]); 
        }
    }

    return;
}

void solve() {
    set<int> s;
    for (int i = 0; i < V; i++) {
        if (i == 0) {
            if (chi >= 2) s.insert(i);
        } else {
            if (prenum[parent[i]] <= lowest[i] && parent[i] != 0) {
                s.insert(parent[i]);
            }
        }
    }

    for (auto i : s) {
        cout << i << endl;
    }
}

int main() {
    cin >> V >> E;

    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;

        G[s].push_back(t);
        G[t].push_back(s);
    }

    dfs(0);
    solve();
}

Measured memory_bytes: 4988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const float pi = 3.1415926535;
unsigned GetDigit(unsigned num){
    return to_string(num).length();
}

int main() {
  int n,k,q;
  cin >> n >> k >> q;

  vector<int>a(n);
  vector<int>table(q);
  for (int i = 0; i < q; i++) {
    cin >> table.at(i);
    a.at(table.at(i)-1)++;
  }
  for (int i = 0; i < n; i++) {
    int l  = q - a.at(i);
    if (k>l) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

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

int main() {
  double a,b,h,m;
  cin >>a >>b >>h >>m;
  h = h*30 + m*0.5; m*= 6;
  double pi = 3.141592653589732;
  double theta = abs(h-m)*pi/180;
  double c = sqrt(a*a+b*b-2*a*b*cos(theta));
  cout << fixed << setprecision(12) << c << endl;
  return 0;
}


Measured memory_bytes: 4192
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();

    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let s = buf.trim().chars().collect::<Vec<char>>();

    let mut s_n = Vec::new();
    let mut prev_c = s[0];
    let mut cnt_c = 1;
    for &c in s[1..].iter() {
        if c != prev_c {
            s_n.push(cnt_c);
            prev_c = c;
            cnt_c = 1;
        } else {
            cnt_c += 1;
        }
    }
    s_n.push(cnt_c);

    let nr_part = 2 * k + 1;

    let mut ans = 0;

    if nr_part >= s_n.len() {
        ans = n - 1;
    } else {
        /*
        let mut sum = s_n[..nr_part].iter().fold(0, |s, &x| s+x);
        ans = sum;
        for i in nr_part..s_n.len() {
            sum = sum + s_n[i] - s_n[i-nr_part];
            ans = std::cmp::max(ans, sum);
        }
        */
        let sum = s_n.iter().fold(0, |s, &x| s+x-1);
        ans = sum + 2 * k;
    }

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


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int solve();

#define ss second
#define ff first
#define y1 y111
typedef long long ll;

const int MAXN = (int)1e5 * 2 + 7, INFint = (int)1e9 + 7;
const ll INFll = (ll)1e18 + 7, MOD = (ll)1e9;
const double INFfl = (double)1e18 + 7, EPS = (double)1e-8, PI = atan2(0, -1);

int main(){
	ios_base::sync_with_stdio(0);
#ifdef home
	freopen ("input.txt", "r", stdin);
	freopen ("output.txt", "w", stdout);
#else
	cin.tie(0);
	cout.tie(0);
	#ifdef TASK
		freopen (TASK".in", "r", stdin);
		freopen (TASK".out", "w", stdout);
	#endif
#endif
	solve();
	return 0;
}

int n, a[MAXN];
unordered_map <int, ll> cnt;
ll ans;
unordered_set <ll> st;

int solve(){
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> a[i];
		cnt[a[i]]++;
		st.insert(a[i]);
	}
	for (auto x : st)
		if (cnt[x] > x) ans += cnt[x] - x;
		else if (cnt[x] != x) ans += cnt[x];
	cout << ans;
	return 0;
}

Measured memory_bytes: 8648
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	int w, n;
	int g[31];
	scanf("%d %d", &w, &n);
	for (int i = 1; i <= w; ++i)
		g[i] = i;
	for (int i = 0; i < n; ++i)
	{
		int a, b;
		scanf("%d,%d", &a, &b);
		swap(g[a], g[b]);
	}
	for (int i = 1; i <= w; ++i)
		printf("%d\n", g[i]);

	return 0;
}

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

#define inf 0x3f3f3f3f
#define pi acos(-1)
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()
template<class T> bool mmin(T &a,T b){return (a>b ?(a=b,true):false);};
template<class T> bool mmax(T &a,T b){return (a<b ?(a=b,true):false);};

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,m;
	cin >> n >> m;
	cout << (3*n+m)/2 << '\n';
#ifdef LOCAL_DEFINE
	cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}




















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int h,w;
vector<string> f;
int l[2100][2100],r[2100][2100],up[2100][2100],down[2100][2100];
int main() {
    cin >> h >> w;
    f.resize(h);
    for (int i = 0; i < h; ++i) {
        cin >> f[i];
    }
    for (int i = 0; i < h; ++i) {
        int cur = 0;
        for (int j = 0; j < w; ++j) {
            if(f[i][j] == '#') cur = 0;
            else cur++;
            l[i][j] = cur;
        }
    }

    for (int i = 0; i < h; ++i) {
        int cur = 0;
        for (int j = w-1; j >= 0; --j) {
            if(f[i][j] == '#') cur = 0;
            else cur++;
            r[i][j] = cur;
        }
    }

    for (int i = 0; i < w; ++i) {
        int cur = 0;
        for (int j = 0; j < h; ++j) {
            if(f[j][i] == '#') cur = 0;
            else cur++;
            up[j][i] = cur;
        }
    }

    for (int i = 0; i < w; ++i) {
        int cur = 0;
        for (int j = h-1; j >= 0; --j) {
            if(f[j][i] == '#') cur = 0;
            else cur++;
            down[j][i] = cur;
        }
    }
    int ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(f[i][j] == '#') continue;
            ans = max(ans,l[i][j]+r[i][j]+up[i][j]+down[i][j]-3);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
    input1 <- getLine
    input2 <- getLine
    let list2 = (map read (words input2)) :: [Int]
    putStrLn (show (countAll2 list2))

count2 :: Int -> Int
count2 n = if ( n `mod` 2) == 0
    then 1 + (count2 (n `div` 2))
    else 0

countAll2 :: [Int] -> Int
countAll2 list = foldr (+) 0 ( map count2 list)

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

using namespace std;

bool comp(const int& v1, const int& v2)
{
	return v1 > v2;
}

int main()
{
	int s, n, p, q, a[100001];
	
	while(cin>>n && n){
		while(n--){
			s = 0;
			cin >> p >> q;
			for(int i = 0; i < p; i++){
				cin >> a[i];
			}
			if(p <= q){
				cout << 0 << endl;
				continue;
			}
			for(int i = 0; i < p-1; i++){
				a[i] = a[i+1] - a[i];
				s += a[i];
			}
			sort(a, a+(p-1), comp);
			for(int i = 0; i < q-1; i++){
				s -= a[i];
			}
			cout << s << endl;
		}
	}
	
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
	char a;
	cin >> a;
	if (int(a)-int('a') < 0) {
		cout << 'A';
	}
	else {
		cout << 'a';
	}
}

Measured memory_bytes: 3644
M=1000000007
def findProductSum(A, n): 
    s = 0
    for i in range(n): 
        s+=A[i] 
    array_sum_square = s*s
    individual_square_sum = 0
    for i in range(n): 
        individual_square_sum += A[i]*A[i]
    return (array_sum_square -individual_square_sum) // 2
n=int(input())
a=list(map(int,input().split()))
print(findProductSum(a,n)%M)

Measured memory_bytes: 31336
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;

int N,M,K;


struct UnionFind {
    vector<int> root;
    
    UnionFind(int n) {
        root.assign(n,-1);
    }
    
    int find(int n){
        if(root[n] < 0) return n;
        else return root[n] = find(root[n]);
    }
    
    void connect(int a,int b){
        int ar = find(a);
        int br = find(b);
        if(ar == br) return;
        
        if(-root[ar] < -root[br]){
            root[br] += root[ar];
            root[ar] = br;
        }else{
            root[ar] += root[br];
            root[br] = ar;
        }
    }
    
};


int main()
{
    cin >> N >> M >> K;
    UnionFind U(N);
    vi fri(N);
    ve<vi> bro(N);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--,b--;
        fri[a]++,fri[b]++;
        U.connect(a,b);
        
    }
    
    rep(i,K){
        int a,b;
        cin >> a >> b;
        a--,b--;
        bro[a].pb(b);
        bro[b].pb(a);
    }
    ve<int> ans(N);
    rep(i,N){
        ans[i] = -U.root[U.find(i)]-1-fri[i];
        for (int p : bro[i]) {
            if(U.find(i) == U.find(p)) ans[i]--;
        }
    }

    outve(ans);
    //outve(U.root);
    
    
    
    

    return 0;
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    string S;cin>>S;
    map<string,int> MA;
    MA["SUN"]=7;
    MA["MON"]=6;
    MA["TUE"]=5;
    MA["WED"]=4;
    MA["THU"]=3;
    MA["FRI"]=2;
    MA["SAT"]=1;
    
    cout<<MA[S]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;

signed main(){
  int N; cin >> N;
  vector<int> L(N);
  REP(x, N) cin >> L.at(x);
  sort(L.begin(), L.end());

  int sum = 0;
  REPR(x, N) {
    for(int y = x-1; y > 0; --y) {
      auto itr = lower_bound(L.begin(), L.begin()+y-1, L.at(x)-L.at(y)+1);
      if (L.at(x)-L.at(y)+1 > *itr) continue;
      sum += y - (itr - L.begin());
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String a = sc.next();
            if (a.equals("-")) {
                break;
            }
            int b = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < b; i++) {
                sum = sc.nextInt();
                a = a.substring(sum,a.length()) + a.substring(0,sum);
            }
            System.out.println(a);
        }
    }
}



Measured memory_bytes: 26676
object Main {
  def main(args: Array[String]): Unit = {
    val _ = io.StdIn.readInt()
    val an: Seq[Int] = io.StdIn.readLine().split(" ").map(_.toInt)
    println(an.tail.foldLeft(an.head)((acc, ai) => lcm(acc, ai)))
  }
  def lcm(m: Int, n: Int): Int = (m * n) / gcd(m, n)
  def gcd(x: Int, y: Int): Int = {
    def loop(m: Int, n: Int): Int =
      if (n > 0) loop(n, m % n)
      else m
    if (x < y) loop(y, x) else loop(x, y)
  }
}

Measured memory_bytes: 43976
#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 k, a, b;
    cin >> k;
    cin >> a >> b;

    bool ans = false;
    for (int i=a; i<=b; ++i) {
        if (i%k==0) {
            ans = true;
            break;
        }
        
    }

    if(ans) {
        cout << "OK" << endl;
    }
    else {
        cout << "NG" << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  int N;
  cin >> N;
  ll ans = 0;
  for (int x = 1; x < N; x++) {
    for (int a = 1; a <= int(sqrt(x)); a++) {
      if (x % a != 0) {
        continue;
      }
      if (x / a == a) {
        ans++;
      } else {
        ans += 2;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3680
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scanf("%d", &n)
	fmt.Scanf("%s", &s)
	if n%2 != 0 {
		fmt.Println("No")
		return
	}
	if s[0:len(s)/2] == s[len(s)/2:] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
#include<stdio.h>
int main ()
{
    int a[2][110],n,i,j,y,p,max,s;
    scanf("%d",&y);
    for(i=0;i<2;i++)
        for(j=0;j<y;j++)
        scanf("%d",&a[i][j]);

    for(p=0;p<y;p++)
    {s=0;
        s+=a[0][p]+a[1][p];
        for(i=0;i<p;i++)
            s+=a[0][i];
        for(j=y-1;j>p;j--)
        s+=a[1][j];
        if(p)max=max>s?max:s;
        else max=s;
    }
    printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 128
from sys import stdin
data = stdin.read().splitlines()

a = int(data[0])
b = int(data[1])
c = int(data[2])
x = int(data[3])

count = 0

l = min(x//500, a)

while l >= 0:
    x = x - 500*l
    m = min(x//100, b)
    while m >= 0:
        x = x - 100*m
        if c >= x//50:
            count += 1
        x = x + 100*m
        m -= 1
    x = x + 500*l
    l -= 1
print(count)

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  int n;
  cin >> n;
  
  while(true){
    if(n <= 1000) break;
    n -= 1000;
  }
  
  cout << 1000-n << endl;
  return 0;
}

Measured memory_bytes: 3592
import sys
input = sys.stdin.readline
n = int(input())
if n == 1:
  print(1)
  exit()
  
chk = []
for i in range(n):
  a = int(input())
  chk.append(a)
  
from bisect import bisect_left,insort_left
from collections import deque
ans = 0

c = deque([])
for j in chk:
  if i == 0:
    c.append(j)
  else:
    ind = bisect_left(c,j)
    if ind == 0:
      ans += 1
      c.appendleft(j)
    else:
      c[ind-1] = (j)
      
print(ans)

Measured memory_bytes: 8092