akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    map<int,int> mp;
    
    int n;
    cin>>n;
    
    rep(i,n){
        int a;
        cin>>a;
        mp[a]++;
    }
    
    int sum = 0;
    for(auto e:mp){
        if(e.second%2)sum++;
    }
    cout<<sum<<endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000000 + 7
#define PI 3.14159265359

const long long INF = 100000;
typedef pair<int,int> P;
typedef long long ll;

using Graph = vector<vector<int>>;
ll A, B;
ll func(ll x) {
	return A*x / B - A * (x/B);
}
int main() {
	ll N;
	cin >> A >> B >> N;
	cout << func(min(N, B - 1)) << endl;
}

Measured memory_bytes: 3552
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
inline int in(){ int x; scanf("%d",&x); return x;}
inline bool suji(char a){ if('0' <= a && a <= '9') return true; else return false; }
template<class T> inline T toA(string& s){T v; istringstream sin(s);sin>>v;return v;}

int main(){
  int i,j,k;
  int ans = 0;
  string s;
  vector<string> data, res;

  while(cin >> s) data.push_back(s);

  rep(i,data.size()){
    j = 0;
    while(j < data[i].size()){
      string t;
      while(j < data[i].size() && suji(data[i][j])){
        t += data[i][j];
        j++;
      }
      if(t != "") res.push_back(t);
      j++;
    }
  }

//  rep(i,res.size()) cout << res[i] << endl;
  rep(i,res.size()) ans += toA<int>(res[i]);
  printf("%d\n",ans);

  return 0;
}

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

using namespace std;

int main()
{
    vector<string> data;
    
    string S, T = "", W; int max_ = 0, c;
    
    while(cin >> S)
    {
        if(T.size() < S.size()) { T = S; }
        
        data.push_back(S);
    }
    
    sort(data.begin(), data.end());
    
    c = 1;
    
    if(data.size() != 1)
    {
        for(int i = 1; i < data.size(); i++)
        {
            if(data[i - 1] == data[i])
            {
                c++;
                
                if(max_  < c)
                {
                    max_ = c;
                    
                    W = data[i];
                }
            }
            else
            {
                c = 1;
            }
        }
    }
    else
    {
        W = S;
    }
    
    cout << W << ' ' << T << endl;
    
    return 0;
}

Measured memory_bytes: 3172
# import numpy as np
# import scipy as sp
# import sys
# input = sys.stdin.readline
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=list(map(int, input().split()))  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# a=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# a=[int(input()) for _ in range (n)]  #リスト入力  改行でa1 ... anのとき
# s=[list(map(str,list(input()))) for i in range(h)]  # 文字列の二次元配列入力
# s = [list(map(int, input().split())) for i in range(n)] # 数値の二次元配列入力
# a = b[:], a = [x[:] for x in b] # deepcopy
# chr(ord('a') + 1) # chrのインクリメント
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#　

s = input()
for i in range(1, 10):
    if s == 'hi'*i:
        print('Yes')
        exit()
print('No')


Measured memory_bytes: 38492
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int ans[100000];
void Calc(){
	string S = res();
	int N = S.length();
	int c = 0;
	for(int i=0;i<N;i++){
		if(S[i] == 'R'){
			c++;
		}
		else{
			ans[i-1] += (c+1)/2;
			ans[i] += c/2;
			c = 0;
		}
	}
	c = 0;
	for(int i=N-1;i>=0;i--){
		if(S[i] == 'L'){
			c++;
		}
		else{
			ans[i+1] += (c+1)/2;
			ans[i] += c/2;
			c = 0;
		}
	}
	for(int i=0;i<N;i++){
		cout << ans[i];
		if(i == N-1){
			cout << "\n";
		}
		else{
			cout << " ";
		}
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 1104
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace PaizaTest
{
    class Program
    {
        static void Main(string[] args)
        {

            var N = int.Parse(Console.ReadLine());
            // DP?
            var oneLine = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            var num = -1;
            var nextNum = 1;
            var brokenBlocks = 0;

            // 砕いたレンガの数を要素にしてDPする
            for (int i = 0; i < N; i++)
            {
                if (oneLine[i] == nextNum)
                {
                    num++;
                    nextNum++;
                    continue;
                }
                brokenBlocks++;
            }
            Console.WriteLine(num >= 0 ? brokenBlocks : -1);
        }
    }
}



Measured memory_bytes: 35676
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;



int main() {
	int n, z, w;
	cin >> n >> z >> w;

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

	if (n == 1) {
		cout << abs(a[0] - w) << endl;
	}
	else {
		cout << max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1])) << endl;
	}

}


Measured memory_bytes: 256
use std::fs::File;
use std::io::{stdout, BufWriter, Read, Write};
use std::thread;

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

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    let stdin = std::io::stdin();
    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 => stdin.lock().read_to_string(&mut s).unwrap(),
    };
    s
}

fn run() {
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let input = read_input();
    let mut input = input.split_whitespace();

    let in_n: i64 = input.next().unwrap().parse().unwrap();
    let in_s: Vec<String> = (0..in_n)
        .map(|_| input.next().unwrap().parse().unwrap())
        .collect();

    let mut count: i64 = in_s
        .iter()
        .map(|s| s.match_indices("AB").count() as i64)
        .sum();
    // B..A
    let mut ba = 0;
    // B..A以外
    let mut bz = 0;
    // B以外..A
    let mut za = 0;
    // B以外..A以外
    let mut zz = 0;
    for s in &in_s {
        if s.starts_with("B") {
            if s.ends_with("A") {
                ba += 1;
            } else {
                bz += 1;
            }
        } else if s.ends_with("A") {
            za += 1;
        } else {
            zz += 1;
        }
    }
    while za > 0 {
        za -= 1;
        while ba > 0 {
            ba -= 1;
            count += 1;
        }
        if bz > 0 {
            bz -= 1;
            count += 1;
        }
    }
    while zz > 0 {
        zz -= 1;
    }
    if ba > 0 {
        ba -= 1;
        while ba > 0 {
            ba -= 1;
            count += 1
        }
        if bz > 0 {
            bz -= 1;
            count += 1
        }
    }
    writeln!(out, "{}", count).ok();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

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

int main()
{
	fastIO
	//inp_out();
	ll n,m;
	cin>>n>>m;
	ll ans=0;
	ans+=((n*(n-1)))/2;
	ans+=((m*(m-1)))/2;
	cout<<ans;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int n,k;
int ans = 0;
vector<int> e[MAXn];
int dfs(int x){
    debug(x);
    int ret = 0;
    for (auto i:e[x]) {
        int tmp = dfs(i);
        if (x != 0 && tmp == k-1) {
            ans++;
        }
        else if (x == 0 && tmp == k) {
            ans++;
        }
        else {
            ret = max(ret,tmp + 1);
        }
    }
    return ret;
}
int main(){
    IOS();
    cin >> n >> k;
    for (int i=0;i<n;++i) {
        int x;
        cin >> x;
        x--;
        if (i == 0) {
            if (x != 0) ans++;
            continue;
        }
        e[x].eb(i);
    }

    dfs(0);
    cout << ans << endl;
}


Measured memory_bytes: 13776
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
int main()
{
	int m,n;
	int c = 0;
	cin >>m>> n;
	int a[200][200];
	int b[200];
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	for (int j = 0; j < n; j++) {
		cin >> b[j];
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			c += a[i][j] * b[j];
		}
		cout << c << endl;
		c = 0;
	}
}




Measured memory_bytes: 3148
def is_kaibun(str):
    for i in range(len(str) // 2):
        if str[i] != str[~i]:
            return False
    return True


s = input()
n = len(s)
if is_kaibun(s) and is_kaibun(s[:n // 2]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
function main(input) {
  var args = input.split("");
  var arr = [];
  for (var i = 0; i < args.length - 2; i++) {
    arr[i] = args[i] + args[i + 1] + args[i + 2];
  }
  for (var i = 0; i < arr.length; i++) {
    arr[i] = parseInt(arr[i], 10);
  }

  var num = arr[0];
  for (var i = 0; i < arr.length; i++) {
    var res = Math.abs(num - 753);
    var res2 = Math.abs(arr[i] - 753);
    if (res > res2) {
      num = arr[i];
    }
  }
  console.log(Math.abs(num - 753));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

int main(void) {
    map<string, int> cnt;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        cnt[s]++;
    }
    string str[] = {"AC", "WA", "TLE", "RE"};
    for (int i = 0; i < 4; ++i) {
        cout << str[i] << " x " << cnt[str[i]] << endl;
    }
}

Measured memory_bytes: 3632
#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};
namespace _DSU {
	constexpr int BUF = 212345 * 2;
	int ptr = 0;
	int mem[BUF];
	int* get(int size) {
		ptr += size;
		return mem + ptr - size;
	}
	void reset() {
		ptr = 0;
	}
}
class UF {
private:
	int *par, *rank;
public:
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	UF(int n) :par(_DSU::get(n + 10)), rank(_DSU::get(n + 10)) {
		for (int i = 0; i<n; i++) {
			par[i] = i, rank[i] = 0;
		}
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return false;
		if (rank[x] < rank[y])swap(x, y);
		par[y] = x;
		if (rank[x] == rank[y])rank[x]++;
		return true;
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};
int N, M;
LL X;
int a[112345];
int b[112345];
LL c[112345];
LL d[112345];
pair<LL, int> edge[112345];
LL kruskal(UF& uf) {
	LL ret = 0;
	for (int i : range(M)) {
		const int u = a[edge[i].second];
		const int v = b[edge[i].second];
		const LL cost = c[edge[i].second];
		if (uf.unite(u, v)) {
			ret += cost;
		}
	}
	return ret;
}
constexpr int mod = 1e9 + 7;
LL f(int size) {
	LL ret = 1;
	for (int i : range(size)) {
		ret *= 2;
		ret %= mod;
	}
	return ret;
}
int main() {
	while (cin >> N >> M >> X) {
		for (int i : range(M)) {
			cin >> a[i] >> b[i] >> c[i];
			a[i]--; b[i]--;
			edge[i] = { c[i],i };
		}
		sort(edge, edge + M);
		for (int i : range(M)) {
			UF uf(N);
			uf.unite(a[i], b[i]);
			d[i] = c[i] + kruskal(uf);
			_DSU::reset();
		}
		sort(d, d + M);
		int c1 = distance(d, upper_bound(d, d + M, X - 1));
		int c2 = distance(d, upper_bound(d, d + M, X));
		c1 = min(M, M - c1 + 1);
		c2 = min(M, M - c2 + 1);
		const LL ret = (mod + f(c1) -f(c2)) % mod;
		cout << ret << endl;
	}
	return 0;
}


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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*🍈( '-'  🍈*/

int main(){
	ll W,H,x,y;
	cin >> W >> H >> x >> y;
	if (x==W-x and y==H-y){
		cout << setprecision(12) << (double)W*(double)H/2 << " 1" << endl;
	}else {
		cout << setprecision(12) << (double)W*(double)H/2 << " 0" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>a>>b;
  if(a==0 || b==0){
    cout<<"Zero"<<endl;
    return 0;
  }
  if(a<0 && b>0){
    cout<<"Zero"<<endl;
  }else if(a<0 && b<0){
    if((abs(a-b)+1)%2==0)cout<<"Positive"<<endl;
    else cout<<"Negative"<<endl;
  }else{
    cout<<"Positive"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
lis_a=[list(map(int, input().split())) for i in range(n)]
lis_b=[int(input()) for j in range(m)]
s=0
for i in range(n):
    for j in range(m):
        s+=lis_a[i][j]*lis_b[j]
    print(s)
    s=0


Measured memory_bytes: 6012
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>
 
using namespace std;
 
/* template */
 
using ll = long long;
 
void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
 
#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};
 
struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};
 
 
using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;
 
template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}
 
template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
 
template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}
 
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
 
constexpr ll LNF = 1LL<<50;
 
constexpr int INF = 1e9+7;
 
const long double PI=3.14159265358979323846;
 
 
vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};
 
/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.size();
    ll ans = 0;
    rep(i,0,n){
        ans += ctoi(s[i]);
    }
    if(ans%9==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

int main() {
  int n;
  cin >> n;
  if(n > 999){
    cout << "ABD";
    //cout << setfill('0') << right << setw(3) << n-1000; 
  }else{
    cout << "ABC";
   // cout << setfill('0') << right << setw(3) << n; 
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<ll>
#define vll vector<ll> 
#define inf 100000000000
#define mod 1000000007

ll fun(ll n)
{
    ll a = 5;
    ll sum = 0;
    while(true)
    {
        ll num = n/a;
        if(num == 0)break;
        sum += num;
        a = a*5;
    }
    return sum;
}
int main()
{
    ll n;
    cin >> n;
    
    if(n%2 == 1)
    {
        cout << 0;
    }
    else
    {
        n /= 2;
        cout << fun(n);
    }
    
    return 0;
}

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

using namespace std;

int main(void) {
  string n;
  cin >> n;

  string cn = n;
  reverse(cn.begin(), cn.end());

  if (n == cn) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

  return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a;
  int ans = 0;
  rep(i, n) {
    cin >> a;
    if (i % 2 == 0) {
      if (a % 2 == 1) {
        ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3588
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long double 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll pi=3.141;
int main(){
	//mahakal(),fast;
	
	ll n ;
	cin>> n ;
	ll ans = 2*pi * n ;
	cout<<ans<<endl;

	return 0;
}

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

int main() {

	int n, m;
	scanf("%d %d", &n, &m);
	map<int, int> ma;
 	for(int i = 0; i < n; i++) {
		int k;
		scanf("%d", &k);
		for(int j = 0; j < k; j++) {
			int a;
			scanf("%d", &a);
			ma[a] += 1;
		}
	}
	int ans = 0;
	for(int i = 0; i < (int)ma.size(); i++) {
		if(ma[i] == n) {
			ans++;
		}
	}
	printf("%d\n", ans);
}

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

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 10010;
static const ll INFTY = 1e12;
static const ll NUMMAX = 1000000007;
static const ll MOD = 1000000007;
#define LOOP 10000000


int main() {

  string str, X;
  int num, N;
  int sum = 0;

  cin >> N;
  vector<pair<string, int>> music(N);
  REP(i, N){
    cin >> str >> num;
    music[i] = make_pair( str, num );
  }
  cin >> X;

  REP(i, N){
    if( X == music[i].first ){
      for(int j = i+1; j < N; j++){
        sum += music[j].second;
      } 
    }
  }

  cout << sum << endl;

  return 0;



}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 256
def readinput():
    n = int(input())
    txy = []
    for i in range(n):
        t,x,y = list(map(int,input().split()))
        txy.append((t,x,y))
    return n, txy

def canmove(current, next):
    (t0,x0,y0) = current
    (t1,x1,y1) = next
    dist = abs(x1-x0) + abs(y1-y0)
    tdiff = t1-t0
    if(dist > tdiff):
        return False
    if( tdiff%2 != dist%2 ):
        return False
    return True

def main(n,txy):
    current = (0,0,0)
    for i in range(n):
        next = txy[i]
        ans = canmove(current, next )
        if (ans == False):
            return False
        current = next
    return True

if __name__=='__main__':
    n,txy = readinput()
    ans = main(n,txy)
    if (ans == True):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 17328
import java.util.Scanner;

class Sea {
	private int w;
	private int h;
	private int atlas[][];
	public Sea(int w, int h, int[][] atlas) {
		this.w = w;
		this.h = h;
		this.atlas = atlas;
	}
	// atlasに破壊的操作を及ぼす. もしそうでありたくないのであれば, 
	// clone()でshallow copyを作るとかの実装にしなければいけない. 
	// その場合は, メモリ消費に気をつける. 
	private void dfs(int x, int y) {
		atlas[x][y] = 0;
		for (int dx = -1; dx <= 1; ++dx) {
			for (int dy = -1; dy <= 1; ++dy) {
				int nx = x + dx; int ny = y + dy;
				if (out(nx, ny)) continue;
				if (atlas[nx][ny] == 1) dfs(nx, ny);
			}
		}
	}
	public boolean in(int x, int y) {
		return (0 <= x && x < h) && (0 <= y && y < w);
	}
	public boolean out(int x, int y) {
		return !in(x, y);
	}
	public int countIsland() {
		int cnt = 0;
		for (int x = 0; x < h; ++x)
			for (int y = 0; y < w; ++y)
				if (atlas[x][y] == 1) {
					dfs(x, y);
					++cnt;
				}
		return cnt;
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder out = new StringBuilder();
		while (true) {
			int w = sc.nextInt();
			int h = sc.nextInt();
			if (w == 0 && h == 0) break;
			int atlas[][] = new int[h][w];
			for (int i = 0; i < h; ++i)
				for (int j = 0; j < w; ++j)
					atlas[i][j] = sc.nextInt();
			Sea sea = new Sea(w, h, atlas);
			out.append(sea.countIsland() + "\n");
		}
		System.out.print(out);
	}
}


Measured memory_bytes: 44032
#include<stdio.h>
#define N 50
int num[N];
main(){

  int i;
  scanf("%d",&i);
  //for(i = 0;i < k;i++)
    printf("%d\n",fibonacci(i));
    return 0;
    }
  fibonacci(int n){
    int i,sum = 0;
    int num[N];
    num[0]= 1;
    num[1] = 1;
    if(n==0)return 1;
   else if(n==1)return 1;
   else if(n > 1){
     for(i = 2;i<=n; i++)
     num[i] = num[i-1]+num[i-2];
    return num[n];
    }
    else return 0;
}

Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        String s = reader.readLine();

        Integer a = Integer.valueOf(s);

        if (a % 2 == 0) {
            System.out.println("0.5");
        } else {
            System.out.println(((a / 2) + 1) / (double) a);
        }
    }

}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n,m;
  cin >> n >> m;
  vector<int>vec(m);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    vec[i]=n-a;
  }
  sort(vec.begin(),vec.end());
  int cnt=0;
  int ans=0;
  rep(i,m){
    if(vec[i]<=0)cnt++;
    else{
      cnt++;
      ans+=vec[i];
    }
    if(cnt==m-1)break;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3156
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort()
    mt = 0
    mn = 0
    for i in range(n):
        if mt < max(mt, min(a[i], a[-1] - a[i])):
            mt = max(mt, min(a[i], a[-1] - a[i]))
            mn = a[i]
    print(a[-1], mn)


if __name__ == '__main__':
    solve()


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

using namespace std;

string reverse(string word) {
	string ans = "";
	for (int i = word.length() - 1; i >= 0; i--) {
		ans += word[i];
	}
	return ans;
}

int main(){
	string s;
	cin >> s;
	if (s.length() == 2)
	{
		cout << s << endl;
	}
	else {
		cout << reverse(s) << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#define pr(x) printf("%s %lld\n", #x , x)
int main()
{
    //freopen("in.txt", "w", stdout);
     long long int n , move , cnt = 0;
     scanf("%lld",&n);
     while(n >= 1){
         n /= 2;
         cnt++;
     }
     move = pow(2 , cnt) - 1;
     printf("%lld\n",move);
     
}   

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
using namespace std;

int prime(int m)
{
    int i;
    if(m==0)
        return 0;
    if(m==1)
        return 0;
    for(i=2; i<=sqrt(m); i++)
        if (m%i==0)
            break;
    if(i<=sqrt(m))
        return 0;
    else
        return 1;
}
int main(int argc,char *argv[])
{
    int x;
    cin>>x;
    for(int i=x;; i++)
        if(prime(i)==1)
        {
            cout<<i;
            break;
        }
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = sorted(map(int, input().split()), reverse=False)
m = max(A)+1
c = Counter(A)
s = list(set(A))
dp = [True] * m
for x in s:
    t = x * 2
    while t < m:
        dp[t] = False
        t += x
ans = 0
for a in A:
    if c[a] == 1 and dp[a]:
        ans += 1
print(ans)



Measured memory_bytes: 154644
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  ll T1, T2, A1, A2, B1, B2;
  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
  ll x = T1 * (B1 - A1);
  ll y = T2 * (B2 - A2);

  if ((x < 0 and y < 0) or (x > 0 and y > 0)) {
    cout << 0 << endl;
    return 0;
  }

  if (x + y == 0) {
    cout << "infinity" << endl;
    return 0;
  }

  // assume x > 0, y < 0 without loss of generality
  if (x < 0) {
    x *= -1;
    y *= -1;
  }
  
  if (x + y > 0) {
    cout << 0 << endl;
    return 0;
  }    
  
  ll d = abs(x + y);

  // 2, -3 -> 4 (1+2+1)
  // 2, -4 -> 2 (1+1)
  // 2, -5 -> 1 (1)
  // 2, -6 -> 1 (1)
  // 3, -4 -> 6 (1+2+2+1)
  // 3, -5 -> 3 (1+2)
  // 3, -6 -> 2 (1+1)
  // 3, -7 -> 1 (1)
  
  if (x % d == 0) {
    cout << 1 + (x / d - 1) * 2 + 1 << endl;
  } else {
    cout << 1 + x / d * 2 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
//abc143_a.cpp
//Sun Oct 20 15:15:17 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int a,b;
	cin >> a >> b;

	if (b*2>=a){
		cout << 0 << endl;
	}else {
		cout << a-2*b << endl;
	}
}

Measured memory_bytes: 256
def resolve():
    N = input().strip()
    carry = 0
    a = 0 # 99 -> 099
    b = 1 # 99 -> 100
    for ch in N:
        n = ord(ch) - ord('0')
        a2 = min(a+n, b+10-n)
        b = min(a+n+1, b+10-n-1)
        a=a2
    print(a)

resolve()

Measured memory_bytes: 53100
#include <iostream>
#include <algorithm>
#define MAX 200001
using namespace std;
typedef long long ll;

int main()
{
	int a[3];
	for (int i = 0; i < 3; i++) {
		 cin >> a[i];
	}
	sort(a, a + 3);
	cout << a[2] - a[0];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string S;
    cin >> S;
    int a[26] = {};
    for(int i=0;i<S.size();i++){
        a[int(S[i]-'a')] += 1;
        if(a[int(S[i]-'a')] > 1){
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        if (i % 3 == 0)
            cout << ' ' << i;
        else
        {
            int x = i;
            while (x)
            {
                if (x % 10 == 3)
                {
                    cout << ' ' << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
}



Measured memory_bytes: 3100
#include <iostream>

int main(void){
	int a,b;
	std::cin >> a >> b;

	if(a == b){
			std::cout << "a == b" << std::endl;
	}else if(a<b){
			std::cout << "a < b" << std::endl;
	}else {
			std::cout << "a > b" << std::endl;
	}
		
	
	return 0;
}

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

using namespace std;

#define y1 dfljk
#define fi first
#define se second

const double C = 5.0 * acos(-1.0);

int n, x1, y1, x2, y2;
pair<int, int> a[200000];
map<pair<int, int>, int> pos;
int dp[200000];
int opt;

int t[2 * 200000];

void upd(int v, int x) {
	t[v += n] = x;
	for(v >>= 1; v; v >>= 1) t[v] = max(t[v * 2], t[v * 2 + 1]);
}

int get(int l, int r) {
	int ret = 0;
	for(l += n, r += n; l <= r; l = (l + 1) >> 1, r = (r - 1) >> 1) {
		if(l & 1) ret = max(ret, t[l]);
		if(!(r & 1)) ret = max(ret, t[r]);
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout.precision(15);
	cin >> x1 >> y1 >> x2 >> y2 >> n;
	if(x1 > x2) swap(x1, x2), swap(y1, y2);
	for(int i = 0; i < n; i++) {
		cin >> a[i].fi >> a[i].se;
		if(a[i].fi < x1 || a[i].fi > x2 || a[i].se < min(y1, y2) || a[i].se > max(y1, y2)) n--, i--;
	}
	if(n != 0) {
		sort(a, a + n);
		for(int i = 0; i < n; i++) pos[a[i]] = i;
		sort(a, a + n, [](pair<int, int> a, pair<int, int> b){ if(y1 < y2) return a.se < b.se; else return a.se > b.se; });
		for(int i = 0; i < n; i++) {
			int j = pos[a[i]];
			dp[j] = 1 + get(0, j);
			upd(j, dp[j]);
			opt = max(opt, dp[j]);
		}
	}
	cout << fixed << 100LL * (x2 - x1 + abs(y1 - y2)) + opt * (C - 20) + (opt == min(abs(x1 - x2), abs(y1 - y2)) + 1 ? C : 0);
}

Measured memory_bytes: 16640
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> A >> B;
  if (A == 1 && B == 2) cout <<3 << endl;
  if (A == 1 && B == 3) cout <<2<< endl;
  if (A == 2 && B == 1) cout <<3<< endl;
  if (A == 2 && B == 3) cout <<1<< endl;
  if (A == 3 && B == 1) cout <<2<< endl;
  if (A == 3 && B == 2) cout <<1<< endl;

}


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

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

	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			int dist = 0;
			for (int dim = 0; dim < d; dim++) {
				dist += (x[i][dim] - x[j][dim]) * (x[i][dim] - x[j][dim]);
			}
			for (int c = 1; c <= 160; c++) {
				if (dist == c * c) ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(void) {
    int N, M, K;
    cin >> N >> M >> K;
    UnionFind uf(N);
    vector<int> friends(N), block(N);
    while(M--) {
        int A, B;
        cin >> A >> B;
        --A; --B;
        uf.unite(A, B);
        friends[A]++;
        friends[B]++;
    }
    while(K--) {
        int C, D;
        cin >> C >> D;
        --C; --D;
        if(uf.find(C) == uf.find(D)) {
            block[C]++;
            block[D]++;
        }
    }

    for(int i=0; i<N; i++) {
        cout << uf.size(i) - 1 - friends[i] - block[i] << ' ';
    }
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int b[n-1],a[100000]={},i,sum=0;
    for(i=1;i<n;i++)
    {
        cin>>b[i];
    }
    a[1]=b[1];
    a[2]=b[1];
    for(i=3;i<=n;i++)
    {
        if(b[i-1]>a[i-1])
            a[i]=b[i-1];
        else
        {
            a[i]=b[i-1];
            a[i-1]=b[i-1];
        }
    }
    for(i=1;i<=n;i++)
        sum+=a[i];
    cout<<sum;
}

Measured memory_bytes: 640
n=int(input())
li=list(map(int,input().split()))

mao=sorted(li)
z=0
for i in range (0,len(li)):
  if (li[i]!=mao[i]):
    z=z+1

if (z==0 or z==2):
  print ("YES")

else:
  print("NO")

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        static void Main(string[] args)
        {
            //string data1 = Console.ReadLine();
            string[] data = Console.ReadLine().Split(' ');
            int h = int.Parse(data[0]);
            int a = int.Parse(data[1]);
            int ans = 0;

            while (h > 0)
            {
                h -= a;
                ans++;
            }

            Console.WriteLine(ans);
            
        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc144_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] N = Console.ReadLine().Split(' ');
            int A = int.Parse(N[0]);
            int B = int.Parse(N[1]);

            if(A <= 9 && B <= 9)
            {
                Console.WriteLine(A * B);
            }
            else
            {
                Console.WriteLine(-1);
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 11092
#code
N,K=map(int,input().split())
A=list(map(int,input().split()))
visited=[0 for i in range(N+1)]
p=1
path=[p]
visited[p]=1
p=A[p-1]
while visited[p]==0:
    path.append(p)
    visited[p]=1
    p=A[p-1]
i=path.index(p)
if(K<i):
    print(path[K])
else:
    K-=i
    print(path[i+K%(len(path)-i)])

Measured memory_bytes: 107404
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

vector <vector <int> > g;
vector <int> parent;
vector <int> depth;
vector <bool> visited;
int dfs(int root);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),u=nxt(),v=nxt();
    vector <int> row;
    g.resize(n+1,row);
    for(int i=0;i<n-1;i++)
    {
        int x=nxt(),y=nxt();
        g[x].push_back(y);
        g[y].push_back(x);

    }
    parent.resize(n+1);
    depth.resize(n+1,0);
    visited.resize(n+1,0);
    parent[v]=-1;

    dfs(v);
    //for(int i=1;i<=n;i++)
        //cout<<parent[i]<<" "<<depth[i]<<endl;

    vector <int> path;
    int cur=u;
    while(cur!=v)
    {
        path.push_back(cur);
        cur=parent[cur];
    }
    ///for(int i=0;i<path.size();i++)
        //cout<<path[i]<<" ";
        //cout<<endl; 
    int test=0;
    for(int i=0;i<(path.size()+1)/2;i++)
    {
        int temp=0;
        temp+=i;
        int dist=path.size()-2*i;
        temp+=depth[path[i]];
        temp+=(dist-1);
        if(temp>test)
            test=temp;
        //cout<<path[i]<<" "<<temp<<endl;

    }
    cout<<test<<endl;
    
    

    return 0;   
}

int dfs(int root)
{
    visited[root]=1;
    int d=0;
    for(int i=0;i<g[root].size();i++)
    {
        if(!visited[g[root][i]])
        {
            d=max(d,dfs(g[root][i])+1);
            parent[g[root][i]]=root;
        }
    }
    depth[root]=d;
    return d;

}


 
 


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

use proconio::{input, fastout};
use proconio::marker::*;


#[fastout]
fn main() {
    input! {
    mut a: usize,
    mut b: usize,
    k: usize
    }
    if a <= k {
        if b + a <= k {
            b = 0;
        } else {
            b -= k - a;
        }
        a = 0;
    } else {
        a -= k;
    }
    println!("{} {}", a, b);
}



Measured memory_bytes: 2148