akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string(string(s)); }
string to_string(bool b) { return to_string(int(b)); }
string to_string(char b) { return "'" + string(1, b) + "'"; }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) {
	string res = "{";
	for (const auto& x : v) res += (res == "{" ? "" : ", ") + to_string(x);
	return res + "}";
}
void debug() { cerr << endl; }
template <typename Head, typename... Tail>
void debug(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug(T...);
}
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define db(...) 42
#endif
typedef long long ll;
typedef long double ld;
const int MOD = 998244353;
struct Mint {
	int val;
	Mint() { val = 0; }
	Mint(const ll& x) {
		val = (-MOD <= x && x < MOD) ? x : x % MOD;
		if (val < 0) val += MOD;
	}
	template <typename U>
	explicit operator U() const { return (U)val; }
	friend bool operator==(const Mint& a, const Mint& b) { return a.val == b.val; }
	friend bool operator!=(const Mint& a, const Mint& b) { return !(a == b); }
	friend bool operator<(const Mint& a, const Mint& b) { return a.val < b.val; }
	Mint& operator+=(const Mint& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	Mint& operator-=(const Mint& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	Mint& operator*=(const Mint& m) { val = (ll)val * m.val % MOD; return *this; }
	friend Mint modex(Mint a, ll p) {
		assert(p >= 0);
		Mint ans = 1;
		for (; p; p >>= 1, a *= a) if (p & 1) ans *= a;
		return ans;
	}
	Mint& operator/=(const Mint& m) { return *this *= modex(m, MOD - 2); }
	Mint& operator++() { return *this += 1; }
	Mint& operator--() { return *this -= 1; }
	Mint operator++(int) { Mint result(*this); *this += 1; return result; }
	Mint operator--(int) { Mint result(*this); *this -= 1; return result; }
	Mint operator-() const { return Mint(-val); }
	friend Mint operator+(Mint a, const Mint& b) { return a += b; }
	friend Mint operator-(Mint a, const Mint& b) { return a -= b; }
	friend Mint operator*(Mint a, const Mint& b) { return a *= b; }
	friend Mint operator/(Mint a, const Mint& b) { return a /= b; }
	friend ostream& operator<<(ostream& os, const Mint& x) { return os << x.val; }
};
int main() {
	int n, K;
	scanf("%d%d", &n, &K);
	vector<int> L(K), R(K);
	vector<Mint> add(n + 1);
	for (int i = 0; i < K; ++i) {
		scanf("%d%d", &L[i], &R[i]);
	}
	add[1] = 1;
	Mint f = 0;
	for (int i = 1; i <= n; ++i) {
		f += add[i];
		db(f.val);
		for (int j = 0; j < K; ++j) {
			if (i + L[j] <= n) add[i + L[j]] += f;
			if (i + R[j] + 1 <= n) add[i + R[j] + 1] -= f;
		}
	}
	printf("%d\n", add[n].val);
}


Measured memory_bytes: 4036
#include <iostream>
#include <map>

using namespace std;

int main(){
    map<long, long> cnt;
    long N, M;
    long sum = 0;
    long ans = 0;
    cin >> N >> M;
    cnt[0]++;
    for(long i = 0; i < N; i++){
        long A;
        cin >> A;
        sum = (sum+A)%M;
        cnt[sum]++;
    }
    for(auto itr = cnt.begin(); itr != cnt.end(); ++itr) {
        ans += ((itr->second)*(itr->second-1))/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ARGBCards {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string r, g, b;
	    in >> r >> g >> b;
	    string num = r;
	    num += g;
	    num += b;
	    int n = atoi(num.c_str());
	    ans2(n%4==0, out);
	}
};


int main() {
	ARGBCards solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
# coding:utf-8
import sys
while True:
    array = map(int, raw_input().split())
    if array[0] == 0 and array[1] == 0:
        break
    for i in range(array[0]):
        for j in range(array[1]):
            if i == 0 or i == array[0] - 1:
                sys.stdout.write('#')
            elif j == 0 or j == array[1] - 1:
                sys.stdout.write('#')
            else:
                sys.stdout.write('.')
        else:
            print
    else:
        print

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; i++){
    cin >> h[i];
  }
  int cnt = 0;
  for (int i = 0; i < N; i++){
    if ( h[i] >= K){
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

string divs[4] = {"dream", "dreamer", "erase", "eraser"};

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

  reverse(S.begin(), S.end());
  for (int i = 0; i < 4; ++i) reverse(divs[i].begin(), divs[i].end());

  bool flag = true;
  for (int i = 0; i < S.size();) {
    bool flag2 = false;
    for (int j = 0; j < 4; ++j) {
      string d = divs[j];
      if (S.substr(i, d.size()) == d) {
        flag2 = true;
        i += d.size();
      }
    }
    if (!flag2) {
      flag = false;
      break;
    }
  }
  if (flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n = int(input())
    aa = list(map(int, input().split()))
    inf = 10 ** 7
    max_a = -inf
    min_a = inf
    max_i = min_i = -1
    for i, a in enumerate(aa):
        if a > max_a:
            max_a = a
            max_i = i
        if a < min_a:
            min_a = a
            min_i = i
    print(2 * n - 1)
    if max_a + min_a >= 0:
        for i in range(n):
            print(max_i + 1, i + 1)
        for i in range(n - 1):
            print(i + 1, i + 2)
    else:
        for i in range(n):
            print(min_i + 1, i + 1)
        for i in range(n - 1, 0, -1):
            print(i + 1, i)

main()


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    ll ans = 1145141919;

    ll D, G;
    cin >> D >> G;
    vector<ll>s(D), p(D), c(D);
    for(ll i = 0; i < D; i++){
        cin >> p[i] >> c[i];
        s[i] = (i + 1) * 100;
    }
    for(ll i = 0; i < (1LL << D); i++){
        ll sum = 0;
        ll cnt = 0;
        for(ll j = 0; j < D && sum < G; j++){
            if((i & (1 << j)) == 0)continue;
            for(ll k = 1; k <= p[j] && sum < G; k++){
                cnt++;
                sum += s[j];
                if(k == p[j])sum += c[j];
            }
        }
        for(ll j = D - 1; j >= 0 && sum < G; j--){
            if((i & (1 << j)))continue;
            for(ll k = 1; k <= p[j] && sum < G; k++){
                cnt++;
                sum += s[j];
                if(k == p[j])sum += c[j];
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int t=(i^j);
            int ans=1;
            while(t%2==0){
                t>>=1;
                ans++;
            }
            cout<<ans<<" ";
        }
        cout<<endl;
    }
}

Measured memory_bytes: 512
let pn = 1000000007

let pow x n =
  let rec doit x n acc =
    if n = 0 then acc
    else doit (x * x) (n / 2) (if n mod 2 = 0 then acc else acc * x) in
  doit x n 1

let fold_left f init s n =
  let rec doit i acc =
    if i = n then acc
    else doit (i + 1) (f acc s.[i]) in
  doit 0 init

let () =
  let p = read_line () in
  let t = read_line () in
  let n = String.length p in
  let m = String.length t in
  let h = Array.make (n + 1) 0 in
  let hash x c = x * pn + Char.code c in
  String.iteri (fun i c -> h.(i+1) <- hash h.(i) c) p;
  let v = fold_left hash 0 t m in
  let x = pow pn m in
  for i = 0 to n - m do
    if h.(i+m) - h.(i)*x = v then Printf.printf "%d\n" i;
  done

Measured memory_bytes: 14380
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;


//?????????????????°???????????????
int toNum(string str){
    int num = 0, K = 1;
    for(int i = str.size() - 1; i >= 0; i--){
        num+=(str[i] - '0') * K;
        K*=10;
    }
    return num;
}

int main(){
    int n;
    map<int, int> m;
    string s;

    cin >> n;
    rep(i,n){
        char inp;
        cin >> inp;
        s+=inp;
    }
    rep(i,3){
        rep(j,n - i){
            m[toNum(s.substr(j,i + 1))] = 1;
        }
    }
    int c = 0;
    for(auto it:m){
        if(c != it.first) break;
        c++;
    }
    cout << c << endl;
}

Measured memory_bytes: 3272
#include<stdio.h>
int min(int a,int b){return(a<b)?a:b;}
int main(void)
{
  int a=0,b=1,c,i=0;char s[1000005];
  scanf("%s",s);
  while(i<strlen(s)){c=a;a=min(a+s[i]-48,b+58-s[i]);b=min(c+s[i]-47,b+57-s[i]);i++;}
  return printf("%d",a),0;
}

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

using namespace std;

int main() {
    int a,b,h,s;
    cin >> a >> b >> h;
    
    s=(a+b)*h/2;
    
    cout << s << endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int h = stdIn.nextInt();
		int w = stdIn.nextInt();
		
		int cnt = 0;
		
		for(int i = 0; i < n; i++) {
			int a = stdIn.nextInt();
			int b = stdIn.nextInt();
			
			if(a>=h && b >= w) {
				cnt++;
			}
			
		}
		System.out.println(cnt);
		
		
	}

}


Measured memory_bytes: 26836
#include <iostream>
using namespace std;
struct point
{
    int tan;
    int sum;
}ans1,ans2;
int main()
{
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    int tang=-1;
    int sum=1;
    //double C=(100*e)/(100+e);
    for(int a1=0;a1*a*100<=f;a1++)
        for(int b1=0;b1*b*100<=f-a1*a*100;b1++)
            for(int c1=0;c1*c<=f-a1*a*100-b1*b*100;c1++)
                for(int d1=0;d1*d<=f-a1*a*100-b1*b*100-c1*c;d1++)
                {
                    int suger=c1*c+d1*d;
					if(suger>(a1*a+b1*b)*e) continue;
					int all=suger+a1*100*a+b1*100*b;
					if(1.0*suger/all>1.0*tang/sum){
						tang=suger;
						sum=all;
					} 
                }
    cout<<sum<<" "<<tang<<endl;
    return 0;
}


Measured memory_bytes: 256
//222/03/2020
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
struct OverloadedNode{
    ll val,pos;
    bool operator < (const OverloadedNode &rhs) const {
        if(val==rhs.val) return pos<rhs.pos;
        else return val<rhs.val;
    }
};

//template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//typedef tree<OverloadedNode,null_type,less<OverloadedNode>,rb_tree_tag,tree_order_statistics_node_update>OverloadedPbds;
//template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
//template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
//template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
//template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
//template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
//template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

/*Containers*/
//vector<ll>v;
//deque<ll>dq;
//stack<ll>stk;
//map<ll,ll>mp;
//unordered_map<ll,ll>ump;
//set<ll>st;
//multiset<ll>mst;
//unordered_set<ll>ust;
//unordered_multiset<ll>umst;
//priority_queue<ll,deque<ll>,greater<ll>>pq;
//Pbds<ll>ost;
/*OverLoaded Containers*/
//vector<OverloadedNode>v;
//deque<OverloadedNode>dq;
//stack<OverloadedNode>stk;
//map<OverloadedNode,OverloadedNode>mp;
//set<OverloadedNode>st;
//multiset<OverloadedNode>mst;
//priority_queue<OverloadedNode>pq;
//OverloadedPbds oost;
/*Global Variables*/

int main(){
    _fastio
    double l;
    cin>>l;
    l=l/3.00;
    cout<<fixed<<setprecision(13)<<l*l*l<<en;



    return 0;
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, sum = 0, cnt1 = 0, cnt2 = 0;
	cin >> n;
	vector<ll> v(3 * n);
	for (ll i = 0; i < 3 * n; i++) {
		cin >> v.at(i);
	}
	sort(v.begin(), v.end(), greater<ll>());
	while (cnt1 < n) {
		cnt2++;
		sum += v[cnt2];
		cnt2++;
		cnt1++;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 2560
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n];
        int cnt =x;
        int day = 1;

        for(int i =0;i<n;i++){
            a[i] = sc.nextInt();
        }
        for(int i =0;i<n;i++){
            for(int j = 0;j<d;j++){
                if(day<=d){
                    cnt++;
                }
                day += a[i];
            }
            day = 1;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 21844
fn read_string() -> String {
    use std::io::Read;

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    return buf;
}

fn swap<T: Clone>(series: &mut Vec<T>, i: usize, j: usize) {
    let tmp = series[i].clone();
    series[i] = series[j].clone();
    series[j] = tmp;
}

fn partition<T: Ord + Clone>(series: &mut Vec<T>, p: usize, r: usize) -> usize {
    let x = series[r].clone();
    let mut i = p;
    for j in p..r {
        if series[j] <= x {
            swap(series, i, j);
            i += 1;
        }
    }
    swap(series, i, r);
    return i;
}

#[derive(Debug, Clone, Eq, PartialEq)]
struct Card {
    pub number: u32,
    pub design: String
}

impl Ord for Card {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        self.number.cmp(&other.number)
    }
}

impl PartialOrd for Card {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}

fn quick_sort<T: Ord + Clone>(series: &mut Vec<T>, p: usize, r: usize) {
    if p < r {
        let q = partition(series, p, r);
        quick_sort(series, p, q-1);
        quick_sort(series, q+1, r);
    }
}

fn main() {
    let input = read_string();
    let input = input.lines().collect::<Vec<_>>();
    let n: usize = input[0].parse().unwrap();
    let cards = input[1..n+1].iter().map(|line| {
        let es = line.split_whitespace().collect::<Vec<_>>();
        Card {
            number: es[1].parse().unwrap(),
            design: es[0].to_string()
        }
    }).collect::<Vec<_>>();
    let mut cards_quick = cards.clone();
    quick_sort(&mut cards_quick, 0, n-1);
    let mut cards_merge = cards.clone();
    merge_sort(&mut cards_merge, 0, n);

    if cards_quick == cards_merge {
        println!("Stable");
    } else {
        println!("Not stable");
    }

    for card in cards_quick {
        println!("{} {}", card.design, card.number);
    }
}

fn merge<T: Ord + Clone>(series: &mut Vec<T>, left: usize, mid: usize, right: usize) {
    let ls = series[left..mid].to_vec();
    let rs = series[mid..right].to_vec();

    let mut li = 0;
    let mut ri = 0;
    for i in left..right {
        if ls.len() <= li {
            series[i] = rs[ri].clone();
            ri += 1;            
        } else if rs.len() <= ri {
            series[i] = ls[li].clone();
            li += 1;
        } else if ls[li] > rs[ri] {
            series[i] = rs[ri].clone();
            ri += 1;
        } else {
            series[i] = ls[li].clone();
            li += 1;
        }
    }
}

fn merge_sort<T: Ord + Clone>(series: &mut Vec<T>, left: usize, right: usize) {
    if left + 1 < right {
        let mid = (left + right) / 2;
        merge_sort(series, left, mid);
        merge_sort(series, mid, right);
        merge(series, left, mid, right);
    }
}


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

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

int main()
{
    int n;
    cin >> n;
    int ans;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (i == 0) {
            ans = a;
        } else {
            ans = gcd(ans, a);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
const int N=100000;
int a[N+1],L,n;
inline void into(){
  scanf("%d%d",&n,&L);
  for (int i=1;i<=n;i++)
    scanf("%d",&a[i]);
}
inline void work(){
}
inline void outo(){
  for (int i=1;i<n;i++)
    if (a[i]+a[i+1]>=L) {
      printf("Possible\n");
      for (int j=1;j<i;j++)
        printf("%d\n",j);
      for (int j=n-1;j>i;j--)
        printf("%d\n",j);
      printf("%d\n",i);
      return;
    }
  printf("Impossible\n");
}
int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 1152
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():

    N, K = NMI()
    A = NLI()
    
    cnt = 0
    for i in range(len(A)-1):
        for j in range(i+1,len(A)):
            if A[i] > A[j]:
                cnt += 1
    
    repeat = 0
    ls = [0 for _ in range(len(A))]
    for k in range(len(A)):
        repeat += len([x for x in A if x < A[k]])

    
    print((cnt*K + repeat * (((K-1)*K)//2))%MOD)


if __name__ == '__main__':
    main()

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

int main(){

    vector<vector<int> > c(3, vector<int> (3));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }

    for(int a1 = 0; a1 <= 100; a1++){
        for(int a2 = 0; a2 <= 100; a2++){
            for(int a3 = 0; a3 <= 100; a3++){
                int b1 = c[0][0] - a1;
                int b2 = c[0][1] - a1;
                int b3 = c[0][2] - a1;
                if(a2 + b1 == c[1][0] && a2 + b2 == c[1][1] && a2 + b3 == c[1][2] && a3 + b1 == c[2][0] && a3 + b2 == c[2][1] && a3 + b3 == c[2][2]){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "No" << endl;
    return 0;

}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, l, max, sum int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&l)
		if l > max {
			max = l
		}
		sum += l
	}
	if max < sum-max {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const ll INF = 1e18;

void solve() {
  int n; cin >> n;
  vector <ll> a(n);
  for(auto &x : a) cin >> x;
  sort(a.begin(), a.end());
  ll cur = 1LL;
  for(int i = 0; i < n; i++) {
    if(a[i] == 0) {
      print(0);
      return;
    }
    ll x = a[i];
    if(cur >= (INF + x) / x) {
      print(-1);
      return;
    }
    if(x >= (INF + cur) / cur) {
      print(-1);
      return;
    }
    cur *= x;
  }
  print(cur);
}

int main() {
  int t; t = 1;
  while(t--) solve();
}

Measured memory_bytes: 4016
def calc_minkowski_distance(x1, x2, p):
    """calc L_p norm(finite dimension)

    Args:
        x1: vector1
        x2: vector2
        p: p in L_p

    Returns:
        L_p distance between x1 and x2 (float)
    """
    if p == "inf":
        return max([abs(x[0] - x[1]) for x in zip(x1, x2)])
    else:
        return sum([abs(x[0] - x[1]) ** (float(p)) for x in zip(x1, x2)]) ** float(1.0 / p)


target = [1, 2, 3, "inf"]
dimension = int(raw_input())
x1 = [float(x) for x in raw_input().split()]
x2 = [float(x) for x in raw_input().split()]
for p in target:
    print(calc_minkowski_distance(x1, x2, p))

Measured memory_bytes: 6632
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned long long u64;
const int N=50;
int n, k, s, t, a[N], cnt;
u64 set[2*N], com[N+1][N+1], ans;
void dfs(int x, int nmust, int nmay, u64 must, u64 may) {
	if(nmust>k) return;
	while(x<cnt && (set[x]&must)) ++x;
	if(x==cnt) {
		int tmp=std::min(k, nmay)-nmust;
		ans+=com[nmay-nmust][tmp];
		return;
	}
	u64 cur=set[x]&may;
	if(cur==0) return;
	for(; cur; cur&=cur-1) {
		int id=__builtin_ctzll(cur);
		dfs(x+1, nmust+1, nmay, must|1llu<<id, may);
		--nmay;
		may^=1llu<<id;
	}
}
void gg() {
	puts("0");
	exit(0);
}
int main() {
	std::random_device dev;
	std::mt19937 rng(dev());
	scanf("%d%d%d%d", &n, &k, &s, &t);
	for(int i=0; i<n; ++i) {
		scanf("%d", a+i);
		if((a[i]&s)!=s || (a[i]|t)!=t) {
			--i;
			--n;
		}
	}
	if(n==0) gg();
	for(int i=0; i<=n; ++i) {
		com[i][0]=com[i][i]=1;
		for(int j=1; j<i; ++j)
			com[i][j]=com[i-1][j-1]+com[i-1][j];
	}
	for(int i=0; i<=n; ++i) {
		for(int j=1; j<=i; ++j)
			com[i][j]+=com[i][j-1];
	}
	for(int i=0; i<18; ++i) {
		int ss=s>>i&1, tt=t>>i&1;
		if(ss!=tt) {
			u64 cur=0;
			for(int j=0; j<n; ++j) {
				if(~a[j]>>i&1) cur|=1llu<<j;
			}
			set[cnt++]=cur;
			if(!cur) gg();
			cur=0;
			for(int j=0; j<n; ++j) {
				if(a[j]>>i&1) cur|=1llu<<j;
			}
			set[cnt++]=cur;
			if(!cur) gg();
		}
	}
	if(cnt==0) {
		printf("%lld\n", com[n][k]-1);
		return 0;
	}
	dfs(0, 0, n, 0, (1llu<<n)-1);
	printf("%llu\n", ans);
	return 0;
}



Measured memory_bytes: 3788
<?php  
  $a = str_split(trim(fgets(STDIN)));
  $n = count($a);
  $b = array_fill(0,$n,1);
  $left = 0;
  $flag = 0;
  for($i=1;$i<$n;$i++){
    if($flag==1){
      break;
    }
    if($a[$i]=="L"){
      for($j=$i-2;$j>=$left;$j--){
        if(($i-$j)%2==0){
          $b[$i]++;
          $b[$j]=0;
        }else{
          $b[$i-1]++;
          $b[$j]=0;
        }
      }
      for($j=$i+1;$j<$n;$j++){
        if($a[$j]=="R"){
          $left = $j;
          $i=$left;
          break;
        }else{
          if(($j-$i)%2==0){
            $b[$i]++;
            $b[$j]=0;
          }else{
            $b[$i-1]++;
            $b[$j]=0;
          }
          if($j==$n-1){
            $flag=1;
          }
        }
      }
    }
  }
  for($i=0;$i<$n;$i++){
    echo($b[$i]." ");
  }

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

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

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


vector<int> occ[30];

int get(int in, char c) {
    if(occ[c-'a'].size()==0) return -1;
    int iin = lower_bound(occ[c-'a'].begin(), occ[c-'a'].end(), in+1 ) - occ[c-'a'].begin();
    int ans=  occ[c-'a'][iin]  - in;
    //cout<<in<<", "<<c<<": "<<ans<<"\n";
    return ans;
}
int main() {
	string s, t;
	cin>>s>>t;
	for(int i= 0;i<(int)s.size(); i++){
	    occ[s[i]-'a' ].push_back(i);
	}
	for(int i =0;i<26;i++){
	    if(occ[i].size()>0)
	         occ[i].push_back(*occ[i].begin() + (int)s.size());
	   //cout<<(char)('a' + i)<<": ";
	   //for(int c: occ[i]) cout << c<< " ";
	   //cout<<"\n";
	}
	long long ans= 0;
	long long ci = -1;
    bool ok  = true;
	for(char c: t) {
	    int d = get(ci, c);
	    if(d==-1) {
	        ok =false;
	        break;
	    }
	    ci+=d;
	    ci%=(int)s.size();
	    ans+=d;
	}
	if(ok)
	    cout<<ans <<"\n";
	else
	    cout<<-1<<"\n";
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>

using namespace std;

int sx, sy, tx, ty;
int x, y;

int main()
{
    scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
    x = tx - sx;
    y = ty - sy;
    for(int i = 0; i < y; i++)
    {
        printf("U");
    }
    for(int i = 0; i < x; i++)
    {
        printf("R");
    }
    for(int i = 0; i < y; i++)
    {
        printf("D");
    }
    for(int i = 0; i < x; i++)
    {
        printf("L");
    }
    printf("L");
    for(int i = 0; i <= y; i++)
    {
        printf("U");
    }
    for(int i = 0; i <= x; i++)
    {
        printf("R");
    }
    printf("DR");
    for(int i = 0; i <= y; i++)
    {
        printf("D");
    }
    for(int i = 0; i <= x; i++)
    {
        printf("L");
    }
    printf("U");
    return 0;
}


Measured memory_bytes: 256
require 'pp'
require 'set'

n = gets.chomp!
t = gets.chomp!

same = {}
same2 = {}

n.length.times do |i|
    same[n[i]] ||= SortedSet.new
    same[n[i]] << i

    same2[t[i]] ||= SortedSet.new
    same2[t[i]] << i
end

answer = {}

same.each do |_, s|
    i = s.first
    answer[t[i]] = s
end

puts same2 == answer ? "Yes": "No"


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

using ll = long long;
using ld = long double;

int main()
{
    int n,k,ans=0;
    cin >> n >> k;
    
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        ans += min(x, k-x);
    }
    

    cout << ans * 2 << endl;

    return 0;
}

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



int main(){
  string s;
  cin >> s;
  vector<long long> v;
  long long buff = 0;
  for(long long i = 0; i < s.length(); ++i){
    long long tmp = (s[i] == '<') ? 1 : -1;
    if(buff * tmp < 0){
      v.push_back(buff);
      buff = tmp;
    }else{
      buff += tmp;
    }
  }
  v.push_back(buff);

  long long ret = 0;
  long long i = 0;
  while(i < v.size()){
    if(i + 1 == v.size() || v[i] < 0){
      ret += (1 + abs(v[i])) * abs(v[i]) / 2;
      ++i;
    }else{
      long long v1 = abs(v[i]);
      long long v2 = abs(v[i+1]);
      if(v1 > v2) swap(v1, v2);
      ret += (v1 - 1) * v1 / 2;
      ret += (v2 + 1) * v2 / 2;
      ++i;
      ++i;
    }
  }

  cout << ret << endl;

  return 0;
}


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

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; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int N; cin>>N;
    vector<ll> A(N); rep(i,N)cin>>A.at(i);
    ll res = 0;
    rep1(i,N-1){
        if(A.at(i)>=A.at(i-1))continue;
        res += A.at(i-1)-A.at(i);
        A.at(i) = A.at(i-1);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define lpp(i, n) for (int i = 1; i <= (n) ; ++i)
#define sz(v) (int)(v).size()
#define int long long
#define mod 100000007

string x ;


int32_t main() {
    int n, k;
    cin >> n ;
    int arr[n][3];
    for (int i = 0; i < n; ++i) {
        cin >> arr[i][0] >>  arr[i][1] >> arr[i][2] ;
    }
    int dp[n][3];
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
    for (int j = 1; j < n; ++j) {
        dp[j][0]=max(dp[j-1][1]+arr[j][0],dp[j-1][2]+arr[j][0]);
        dp[j][1]=max(dp[j-1][0]+arr[j][1],dp[j-1][2]+arr[j][1]);
        dp[j][2]=max(dp[j-1][1]+arr[j][2],dp[j-1][0]+arr[j][2]);
    }
    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 4992
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
using namespace boost::multiprecision;  
using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
//#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

    int n;
    cin >> n;

    vector<string> s(n);

    int maxv = 0;
    map<string,int> mp;
    rep(i,n){
        cin >> s[i];
        mp[s[i]]++;
        chmax(maxv,mp[s[i]]);
    }

    sort(all(s));
    map<string,bool> flg;

    rep(i,n){
        if(mp[s[i]] == maxv && !flg[s[i]]){
            cout << s[i] << '\n';
            flg[s[i]] = true;
        }
    }


    return 0;
}


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

int cmpstr(const void * a, const void * b){
  //const char * x = a, *y = b;
  return strcmp(a, b);
}

int main(){

  int l, n;
  scanf("%d%d", &n, &l);
  char s[n][l+1];

  for (int i = 0; i < n; ++i)
    scanf("%s", s[i]);

  qsort(s, n, sizeof(s[0]), cmpstr);

  for (int i = 0; i < n; ++i)
    printf("%s", s[i]);

  printf("\n");

  return 0;
}


Measured memory_bytes: 128
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  for (;;) {
    auto s = readln.chomp;
    if (s == "-") break;

    auto m = readln.chomp.to!size_t;
    auto hi = m.iota.map!(_ => readln.chomp.to!int);

    foreach (h; hi)
      s = s[h..$] ~ s[0..h];

    writeln(s);
  }
}

Measured memory_bytes: 2420
l,r = map(int, input().split())

def baisuaru(l,r,m):
  if l//m < r//m:
    return True
  elif l%m==0:
    return True
  else:
    return False
    
if baisuaru(l,r,2019):
  print(0)
else:
  a=l%2019
  b=r%2019
  ans=99999999
  for i in range(a,b):
    for j in range(i+1,b+1):
      tmpans=(i*j)%2019
      if ans>tmpans:
        ans=tmpans
  print(ans)
    


Measured memory_bytes: 40684
use std::cmp;

fn main() {
    let mut sc = Scanner::new();
    let h: usize = sc.read();
    let w: usize = sc.read();
    let mut c: Vec<Vec<usize>> = (0..10).map(|_| (0..10).map(|_| sc.read()).collect()).collect();

    for k in 0..10 {
        for i in 0..10 {
            for j in 0..10 {
                c[i][j] = cmp::min(c[i][k] + c[k][j], c[i][j]);
            }
        }
    }

    let mut ans = 0;
    for _ in 0..h {
        for _ in 0..w {
            let a: i32 = sc.read();
            if a < 0 { continue; }
            let a = a as usize;
            ans += c[a][1];
        }
    }
    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 4352
def main():
    N = int(input())
    cnt = [float("inf")] * 26
    a = ord('a')
    for _ in range(N):
        S = input()
        tmp = [0] * 26
        for c in S:
            tmp[ord(c) - a] += 1
        for i in range(26):
            cnt[i] = min(cnt[i], tmp[i])
    ans = ""
    for i in range(26):
        ans += chr(a + i) * cnt[i]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38768
#include "bits/stdc++.h"
#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N,M;
ll P[100010];
ll A[100010], B[100010], C[100010];
ll imos[100010];
int main() {
    while(cin>>N>>M){
        REP(i,0,N+1) {
            imos[i]=0;
            A[i]=0;
            B[i]=0;
            C[i]=0;
        }
        REP(i,0,M){
            cin>>P[i];
            P[i]--;
        }
        REP(i,0,N-1){
            cin>>A[i]>>B[i]>>C[i];
        }
        REP(i,0,M-1){
            if(P[i]>P[i+1]) {
                imos[P[i+1]]++;
                imos[P[i]]--;
            }else{
                imos[P[i]]++;
                imos[P[i+1]]--;
            }

        }
        REP(i,0,N+1){
            imos[i+1] += imos[i];
        }
        ll ans=0;
        REP(i,0,N){
            ans += min(imos[i]*A[i], imos[i]*B[i]+C[i]);
        }
        p(ans);
        return 0;
    }
}


Measured memory_bytes: 6972
n,k = map(int,input().split())
D = list(map(int,input().split()))

def opab(left,right,m,D):
    jew = []
    for i in range(left):
        jew.append(D[i])
    for i in range(n-right,n):
        jew.append(D[i])
    jew.sort()
    count = 0
    while count < m:
        if not jew:
            break
        if jew[0] <0:
            jew.pop(0)
            count +=1
        else:
            break
    return sum(jew)
ans = 0
for k_i in range(k+1):
    for left in range(min(k_i,n)+1):
        for right in range(max(0,min(k_i,n)-left)+1):
            m = max(0,k - left -right)
            ans = max(ans,opab(left,right,m,D))
print(ans)

Measured memory_bytes: 3064
fact = [1]
p = 10**9 + 7

def fact1(n,m):
    for i in range(1,n+m+1):
        new_fact = fact[i-1]*i %p
        fact.append(new_fact)
#ax+by=1の解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2] != 1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]    
#aの逆元(mod m) a,mは互いに素
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return x%m

if __name__ == "__main__":
  n,k = (int(i) for i in input().split())
  a0 = [int(i) for i in input().split()]
  a = sorted(a0)
  fact1(n,0)
  minx = 0
  maxx = 0
  ck = mod_inv(fact[k-1],p)
  nck = [0]*k
  nck[k-1] = 1
  for i in range(k,n):
    tmp = mod_inv(fact[i-k+1],p)
    tmp2 = fact[i]*(ck*tmp%p)%p
    nck.append(tmp2)
  for i in range(1,n-k+2):
    minx = (minx + nck[n-i]*a[i-1])%p
    maxx = (maxx + nck[n-i]*a[n-i])%p
  ans = maxx - minx
  if ans < 0:
    ans += p
  print(ans)
   

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

int main() {
    double ans = 0.0;
    int n;
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        ans += 1.0 / a;
    }
    cout << 1.0 / ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;
int M;
bool used[114514];
vector<int> es[114514];

void dfs(int v) {
  used[v] = true;
  for (int u : es[v]) {
    if (used[u]) continue;
    dfs(u);
  }
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> N >> M;
  rep(i, M) {
    int u, v;
    int z;
    cin >> u >> v >> z;
    --u;
    --v;
    es[u].eb(v);
    es[v].eb(u);
  }

  int ans = 0;
  rep(v, N) {
    if (!used[v]) {
      ans++;
      dfs(v);
    }
  }
  cout << ans << endl;
}




Measured memory_bytes: 9344
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

int main() {
    int n;
    cin >> n;
    vector<string> vs(n);
    rep(i, n) {
        cin >> vs[i];
    }

    LL cnt = 0, cntba = 0, cntb = 0, cnta = 0;
    rep(i, n) {
        int len = vs[i].length();
        for (int j = 0; j < len - 1; j++) {
            if (vs[i][j] == 'A' and vs[i][j + 1] == 'B') cnt++;
        }


        char s_first = vs[i][0];
        char s_last = vs[i][len - 1];
        if (s_first == 'B' and s_last == 'A') {
            cntba++;
        } else if (s_first == 'B') {
            cntb++;
        } else if (s_last == 'A') {
            cnta++;
        }
    }
    LL ans = 0;
    if (cntba == 0) {
        ans = cnt + min(cnta, cntb);
    } else {
        if (cnta + cntb > 0) {
            ans = cnt + cntba + min(cnta, cntb);
        } else {
            ans = cnt + cntba - 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

from itertools import accumulate, permutations, combinations, takewhile, compress, cycle

# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint
import heapq

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)


# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

def dfs(n):
    if n in to:
        return
    else:
        to.add(n)
        for a, b, c in edges:
            if a == n:
                dfs(b)


def dfs2(n):
    if n in ot:
        return
    else:
        ot.add(n)
        for a, b, c in edges:
            if b == n:
                dfs2(a)


N, M, P = [int(x) for x in input().split()]
edges = []
# 1から行けるノード
to = set()
# N-1に到達できるノード
ot = set()
for _ in range(M):
    a, b, c = [int(x) for x in input().split()]
    a, b, c = a - 1, b - 1, c - P
    edges.append((a, b, -c))

dfs(0)
dfs2(N - 1)

W = [INF] * N
W[0] = 0
for cnt in range(N + 1):
    isShusoku = True
    for a, b, c in edges:
        if b in to and b in ot:
            if W[b] > W[a] + c:
                W[b] = W[a] + c
                isShusoku = False

if isShusoku == True:
    print(max(0,-W[N - 1]))
else:
    print(-1)
pass


Measured memory_bytes: 121688
#include <stdio.h>

int main(){
    int a;
    char c[10000];
    scanf("%d",&a);
    getchar();
    
    scanf("%[^\n]", c);
    
    for (int i=0; c[i]!='\0'; i++){
        if(c[i]>='A' && c[i]<='Z'){
            c[i]+=a;
            if(c[i]>90){
                c[i]-=26;
            }
            printf("%c",c[i]);
        }
    }
}

Measured memory_bytes: 1672
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        n:usize,
        mut ass:[i64;n]
    }

    ass.insert(0, -1);
    ass.push(-1);
    let mut ls = vec![-1; n + 2];
    for i in 1..n + 1 {
        ls[i] = max(ls[i - 1], ass[i]);
    }
    let mut rs = vec![-1; n + 2];
    for i in (0..n + 1).rev() {
        rs[i] = max(rs[i + 1], ass[i]);
    }

    for i in 1..n + 1 {
        let ans = max(ls[i - 1], rs[i + 1]);
        println!("{}", ans);
    }
}


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

int main(){
    int N, i;
    int a[120];
    int a_min = 1200;
    int a_max = 0;

    cin >> N ;

    for (i=0; i<N; i++){
        cin >> a[i];
        if (a[i] > a_max){
            a_max = a[i];
            }
        if (a[i] < a_min){
            a_min = a[i];
            }
    }

       cout << a_max - a_min << endl;
   }




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

int main() {
	int H,W;
	cin>>H>>W;
	string e="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	for(int i=0;i<H;i++) {
		for(int j=0;j<W;j++) {
			string s;
			cin>>s;
			if(s=="snuke") {
				cout<<e.at(j)<<i+1<<endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 256