akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	string s;
	cin >> s;
	sort(all(s));
	if(s == "abc") cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main(){
  int n, st = 0, sh = 0;
  string t, h;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> t >> h;
    if(t > h) st += 3;
    else if(t < h) sh += 3;
    else{
      st++; sh++;
    }
  }
  cout << st << " " << sh << endl;
  return 0;
}


Measured memory_bytes: 3180
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    if A >= 13:
        print(B)
    elif A >=6:
        print(B//2)
    else:
        print(0)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	int n;
	cin >> n;

	int ans = 0;
	for(int i=1 ; i<=n ; i+=2)
	{
		int count = 0;
		for(int j=1 ; j<=i ; j++)
		{
			if(i%j == 0)
				count++;
		}

		if(count >= 8 && i&1)
			ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
D = LIST()

mod = 998244353
c = Counter(D)
v = max(D)

if D[0] != 0 or c[0] != 1:
    print(0)
else:
    ans = 1
    for i in range(1, v + 1):
        ans *= pow(c[i-1], c[i], mod)
        ans %= mod
    print(ans)





Measured memory_bytes: 19024
from collections import deque
h, w = map(int, input().split())

maze = [list(input()) for _ in range(h)]
ans = 0

def bfs(sx, sy):
    INF = 1000000
    reached = [[INF for _ in range(w)] for _ in range(h)]
    reached[sx][sy] = 0
    d = deque()
    d.append([sx, sy])
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]
    while d:
        x, y = d.popleft()
        for i in range(4):
            next_y = y + dy[i]
            next_x = x + dx[i]
            if next_x < 0 or next_x > h - 1 or next_y < 0 or next_y > w - 1:
                continue
            if maze[next_x][next_y] == "#":
                continue
            if reached[next_x][next_y] != INF:
                continue
            d.append([next_x, next_y])
            reached[next_x][next_y] = reached[x][y] + 1
    gl = 0
    for i in range(h):
        for j in range(w):
            if maze[i][j] == ".":
                gl = max(gl, reached[i][j])    
    return gl

for i in range(h):
    for j in range(w):
        if maze[i][j] == ".":
            res = bfs(i, j)
            ans = max(ans, res)
print(ans)

Measured memory_bytes: 3316
class Osa_k
    # @parm {number} n - 素因数分解したい値の中での最大値
    def initialize(n)
        @min_factor = [*0..n]
        i = 2
        while i * i <= n do
            if @min_factor[i] == i then
                j = 2
                while i * j <= n do
                    @min_factor[i*j] = i if @min_factor[i*j] > i
                    j += 1
                end
            end
            i += 1
        end
    end

    # @parm {number} m - 素因数分解したい値
    # @return {array} res - mの素因数群
    def factor(m)
        res = []
        tmp = m
        while tmp > 1 do
            res << @min_factor[tmp]
            tmp /= @min_factor[tmp]
        end
        return res.uniq
    end
end

MAX = 10 ** 6 + 10
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
osa_k = Osa_k.new(MAX)
res = a[0]
h = Hash.new(0)
is_pairwise_coprime = true
n.times do |i|
    if is_pairwise_coprime then
        osa_k.factor(a[i]).each do |num, cnt|
            if h.has_key?(num) then
                is_pairwise_coprime = false
                break
            end
            h[num] += 1
        end
    end
    res = res.gcd(a[i])
end
 
if is_pairwise_coprime then
    puts "pairwise coprime"
elsif res == 1 then
    puts "setwise coprime"
else
    puts "not coprime"
end

Measured memory_bytes: 119188
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Int32;
using static System.Math;
 
class Program
{
    class Bngm : IComparable<Bngm>
    {
        public int Start;
        public int End;
        public int Channel;

        public int CompareTo(Bngm other)
        {
            if (Start != other.Start) return Start - other.Start;
            if (End != other.End) return End - other.End;
            return Channel - other.Channel;
        }
    }

    static void Main(string[] args)
    {
        label:
        var sp = ReadLine().Split();
        int n = Parse(sp[0]);
        var set = new SortedSet<Bngm>();
        var endChDic = new Dictionary<KeyValuePair<int, int>, Bngm>();
        for(int i = 0; i < n; ++i)
        {
            sp = ReadLine().Split();
            var bngm = new Bngm();
            bngm.Start = Parse(sp[0]);
            bngm.End = Parse(sp[1]);
            bngm.Channel = Parse(sp[2]);
            var pair = new KeyValuePair<int, int>(bngm.Start, bngm.Channel);
            if (endChDic.ContainsKey(pair))
            {
                var prev = endChDic[pair];
                prev.End = bngm.End;
                endChDic.Remove(pair);
                endChDic[new KeyValuePair<int, int>(prev.End, prev.Channel)] = prev;
            }
            else
            {
                set.Add(bngm);
                endChDic[new KeyValuePair<int, int>(bngm.End, bngm.Channel)] = bngm;
            }
        }
        var list = new List<Bngm>();
        foreach(var bngm in set)
        {
            int i = 0;
            for (; i < list.Count; ++i)
            {
                var last = list[i];
                if (last.End < bngm.Start)
                {
                    list[i] = bngm;
                    break;
                }
                else if (last.End == bngm.Start && last.Channel == bngm.Channel)
                {
                    list[i] = bngm;
                    break;
                }
            }
            if (i == list.Count) list.Add(bngm);
            //WriteLine($"{bngm.Start} {bngm.End} {bngm.Channel}");
        }
        WriteLine(list.Count);
    }
}


Measured memory_bytes: 33080
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int d,g;
int p[10],c[10];

int dfs(int s,int f,int n,int cnt){
    if(s >= g)ret cnt;
    if(n >= d){
	if(s >= g)ret cnt;
	else ret inf;
    }
    int r = inf;
    if(f == 0 ){
	rep(i,1,p[n])r = min(r,dfs(s+(100*(1+n)*(i)),1,n+1,cnt+i));
    }
    
    r = min(r,dfs(s+(100*(1+n)*p[n]+c[n]),f,n+1,cnt+p[n]));
    r = min(r,dfs(s,f,n+1,cnt));
    ret r;
}

int main(){
    cin >> d >> g;
    
    rep(i,0,d)cin >> p[i] >> c[i];

    P(dfs(0,0,0,0));
    
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define pb push_back
#define pii pair<int,int>
#define lo long long
#define modp(x) ((x)%modn)
using namespace std;
const int maxn=800005,maxm=200005;
struct node
{
	int l,r;
	lo w;
} tree[maxn];
lo ans;
void built(int k,int l,int r)
{
	tree[k].l=l;tree[k].r=r;
	if(l==r) return;
	int mid=(l+r)>>1;
	built(k<<1,l,mid);
	built(k<<1|1,mid+1,r);
}
void query(int ll,int rr,int k)
{
	int l=tree[k].l,r=tree[k].r;
	if(ll<=l && r<=rr)
	{
		ans=max(ans,tree[k].w);
		return;
	}
	int mid=(l+r)>>1;
	if(ll<=mid) query(ll,rr,k<<1);
	if(rr>mid) query(ll,rr,k<<1|1);
}
void change(int pos,int k,lo add)
{
	int l=tree[k].l,r=tree[k].r;
	if(l==pos && r==pos)
	{
		tree[k].w=add;
		return;
	}
	int mid=(l+r)>>1;
	if(pos<=mid) change(pos,k<<1,add);
	else change(pos,k<<1|1,add);
	tree[k].w=max(tree[k<<1].w,tree[k<<1|1].w);
}
lo a[maxm],b[maxm];
int n;
lo f[maxm];
int main()
{
	scanf("%d",&n);
	rep(i,1,n) scanf("%lld",a+i);
	rep(i,1,n) scanf("%lld",b+i);
	built(1,1,n);
	rep(i,1,n)
	{
		ans=0;
		query(1,a[i]-1,1);
		f[a[i]]=ans+b[i];
		change(a[i],1,f[a[i]]);
	}
	ans=0;
	query(1,n,1);
	printf("%lld",ans);
	return 0;
}

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

typedef long long ll;
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

void solve() {
    ll n, d;
    cin>>n>>d;
    d *= d;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        ll d1, a, b;
        cin>>a>>b;
        d1 = a*a + b*b;
        if(d1 <= d){
            cnt += 1;
        }
    }
    cout<<cnt<<"\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    // pre();
    while (t--)
        solve();

    return 0;
}

Measured memory_bytes: 3668
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/03/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,m,s,t; cin>>n>>m>>s>>t;
  s--; t--;
  struct Train {
    int t;
    ll a,b;
    Train(int t=0, ll a=0, ll b=0) : t(t),a(a),b(b){}
  };
  vector<Train> graph[n];
  for (int i = 0; i < m; i++) {
    int u,v,a,b; cin>>u>>v>>a>>b;
    u--; v--;
    graph[u].emplace_back(v,a,b);
    graph[v].emplace_back(u,a,b);
  }

  auto set_dist = [&](int s, bool yen, vector<ll>& arr) {
    arr.assign(n, 1e17);
    arr[s] = 0;
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<>> qs;
    qs.emplace(0, s);
    while (not qs.empty()) {
      auto q = qs.top(); qs.pop();
      auto c = q.first;
      auto p = q.second;
      if (arr[p] < c)
        continue;
      for (auto t : graph[p]) {
        auto cost = c+(yen?t.a:t.b);
        if (arr[t.t] <= cost)
          continue;
        arr[t.t] = cost;
        qs.emplace(cost, t.t);
      }
    }
  };

  vector<ll> yen(n), snook(n);
  set_dist(s, true, yen);
  set_dist(t, false, snook);

  vector<ll> ans(n);
  ll min_ans = 1e17;
  for (int i = n-1; i >= 0; i--) {
    ans[i] = min_ans = min(min_ans, yen[i]+snook[i]);
  }
  for (auto a : ans)
    cout << ll(1e15)-a << endl;

  return 0;
}


Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
const ll mod = 1e9 + 7;
const ll inf = 1e12;
const double pi = 3.141592;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int maxnum = (n - 1) * (n - 2) / 2;
    if(k > maxnum){
        cout << -1 << "\n";
        return 0;
    }
    vector<pair<int, int>> ans;
    rep(i, n-1){
        ans.emplace_back(1, i + 2);
    }
    int cnt = maxnum - k;
    for (int i = 2; i <= n; ++i)
    {
        for (int j = i+1; j <= n; j++)
        {
            if(cnt == 0)
                break;
            ans.emplace_back(i, j);
            --cnt;
        }
        if(cnt == 0)
            break;
    }
    int m = ans.size();
    cout << m << "\n";
    rep(i, m) cout << ans[i].first << " " << ans[i].second << "\n";
    return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef pair < int, int> P;
/****Union-Ford-Tree***/
int par[int(0x7ffffff)];//Parent
int Rank[int(0x7ffffff)];//Deep_of_the_Tree

//int a[100] = { 4,2,3,1,5 }, m[100] ={3,2,2};
//int n = 0;
//const ll mod = 1000000007;


//n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		Rank[i] = 0;
	}
}
//木の根探し
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (Rank[x] < Rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

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

/************************************************************************************
//*無向グラフのBELL_MAN_FORD;*//*
struct edge { int from, to, cost; };
edge es[10000];
int d[10000];
void shortest_path(int s) {
	for (int i = 0; i < V; i++)d[i] = INF;
	d[s] = 0;
	while (true) {
		bool update = false;
		for (int i = 0; i < E*2; i++) {
			edge e = es[i];
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if (!update)break;
	}

}
int main() {
	cin >> V >> E;
	for (int i = 0; i < E*2; i = i+2) {
		edge e;
		cin >> e.from >> e.to >> e.cost;
		es[i] = e;
		swap(e.to, e.from);
		es[i + 1] = e;

	}
	shortest_path(0);
	cout << d[6] << endl;
}
*////////////////////////////////////////*
int gcd(int a, int b) {//最大公約数を求める
	if (b == 0) return a;
	return gcd(b, a%b);
}
/*****************************************************************************/
//int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1};
//vector<int> G[10000];


//struct edge { int to, cost; };
//vector<edge>G[100000];


/**************/


/****
//priority_queue<int> //大きいものから順番に出てくる
//priority_queue<int,vector<int>,greater<int>>//小さいものから出てくる（順位キュー）
.top();
.pop();
.empty();
**/
//void solve();
int V, E;
//void shortest_path(int);
typedef long double ld;
typedef unsigned long long ull;
const int MX = 3007;


int A, B, T;
int main()
{
	cin >> A >> B >> T;
	int counter = 1;
	while (T >= counter * A) counter++;

	cout << B * --counter << endl;
	
}

Measured memory_bytes: 256
// D.

#include <iostream>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef pair<int, int> II;
typedef pair<int, II> III;

struct UnionFind {
	std::vector<int> _parent;
	std::vector<int> _size;
	UnionFind(int size) : _parent(size, -1), _size(size, 1) { }
	void unite(int a, int b) {
		int ra = root(a), rb = root(b); if (ra == rb) { return; }
		if (_size[ra] >= _size[rb]) { _parent[rb] = ra, _size[ra] += _size[rb]; } else { _parent[ra] = rb, _size[rb] += _size[ra]; }
	}
	int root(int a) {
		int p = _parent[a];
		if (p < 0) { return a; }
		while (_parent[p] >= 0) { p = _parent[p]; }
		return _parent[a] = p;
	}
	int size(int a) { return _size[root(a)]; }
};

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	vector<II> vx, vy;
	for (int i = 0; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		vx.push_back(II(x, i));
		vy.push_back(II(y, i));
	}
	sort(vx.begin(), vx.end());
	sort(vy.begin(), vy.end());
	vector<III> v;
	for (int i = 1; i < n; ++i) {
		v.push_back(III(vx[i].first - vx[i - 1].first, II(vx[i - 1].second, vx[i].second)));
		v.push_back(III(vy[i].first - vy[i - 1].first, II(vy[i - 1].second, vy[i].second)));
	}
	sort(v.begin(), v.end());
	UnionFind uf(n);
	int ans = 0;
	for (auto kv : v) {
		if (uf.root(kv.second.first) != uf.root(kv.second.second)) {
			uf.unite(kv.second.first, kv.second.second);
			ans += kv.first;
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
int main(){
    int n,i;
	long long x,y,k,ans;
    cin >> n >> k;
    pair<long long, long long> a[100010];
    for(i=0;i<n;i++){
        cin >> y >> x;
    	a[i] = make_pair(y,x);
    }
    sort(a,a+n);
    ans = 0;
	for(i=0;i<n;i++){
        ans += a[i].second;
		if(ans >= k){
        	cout << a[i].first << endl;
			return 0;
    	}
	}
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int i;
	ll num, ans = 0;
	string s;
	vector<ll> d(26, 0);
	cin >> s;
	num = s.size();
	rep(i, s.size())
		d[s[i] - 'a']++;
	rep(i, 26)
		ans += d[i] * (num - d[i]);
	ans >>= 1;
	cout << ans + 1 << "\n";
	return 0;
}

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

int main(){
    int a,b,k,ans;
    cin >> a >> b >> k;
    int li = min(a,b);
    vector<int> d;
    for(int i=1;i<li+1;i++){
        if(a%i==0 & b%i==0){
        d.push_back(i);
        }
    }
    // for(int i=0;i<d.size();i++){
    //     cout << d[i] << endl;
    // }
    reverse(d.begin(),d.end());
    cout << d[k-1] << endl;
}

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

#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
const int N=500+5;
char a[N][N];
bool b[N][N];

int main()
{
	//freopen("1.in","r",stdin);
	int n,m;
	cin>>n>>m;
	rep(i,1,n)scanf("%s",a[i]+1);
	rep(i,1,n)
	rep(j,1,m)b[i][j]=i==1||i==n||j==1||j==m;
	rep(i,2,n-1)
	{
		bool have_=0;
		rep(j,2,m-1)have_|=a[i][j]=='#';
		bool now=have_?(b[i-1][2]^1):0;
		rep(j,2,m-1)b[i][j]=now;
	}
	per(c,1,0)
	{
		rep(i,1,n)
		{
			rep(j,1,m)putchar((a[i][j]=='#'||b[i][j]==c)?'#':'.');
			puts("");
		}
		puts("");
	}
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <numeric>

int main(void) {
	int n;

	double avg = 0;

	std::cin >> n;

	std::vector<int> v(n);
	for (size_t i = 0; i < n; i++) {
		std::cin >> v[i];
	}

	avg = 1.0 * std::accumulate(v.begin(), v.end(), 0LL) / v.size();

	double pos, min = 100000;

	for (size_t i = 0; i < n; i++) {
		if (min > std::abs(avg - v[i])) {
			pos = i;
			min = std::abs(avg - v[i]);
		}
	}

	std::cout << pos << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define _GLIBCXX_DEBUG
int main()
{
    int n;
    cin>>n;
    vin p(n);
    rep(i,n)cin>>p[i];
    sort(p.begin(),p.end(),greater<int>());
    int sum=0;
    for(int i=1;i<n;i++)sum+=p[i];
    cout<<sum+p[0]/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#define ll long long
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int main()
{


    int n;
    int ans = 0;
    cin>>n;
    for(int i = 0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i = 0;i<n;i++)
    {
        for(int j = 0;j<n;j++)
        {
            if(i == j) continue;
            ans  = max(ans,abs(a[i] - a[j]));
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}


int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if(b % a == 0)cout << a + b << endl;
  else cout << b - a << endl;
	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++)
using LL = long long;
using P = pair<int,int>;


int main(){
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> A(M);
    rep(i,M) cin >> A[i];
	int tmp = 0;
	rep(i,M){
		if(A[i]	> X) break;
		tmp++;
		
	}
	int ans = M;
	ans = min(tmp, M - tmp);
	cout << ans << endl;
	return 0;

}












Measured memory_bytes: 3624
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))


N = int(input())


ht = {}
for i in range(1, 10):
    for j in range(1, 10):
        ht[(i, j)] = 0

for i in range(N + 1):
    a = str(i)
    h, t = map(int, [a[0], a[-1]])
    if (h,t) in ht.keys():
        ht[(h,t)] += 1

# print(ht)
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += ht[(i, j)] * ht[(j, i)]

print(ans)

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


int main()
{
    int64_t N;
    cin >> N;
    int64_t chk=1000000007;
    int64_t ans=1;
    while(N>0)
    {
        ans=ans*N;
        ans=ans%chk;
        N--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3568
#include <stdio.h>
#define NUL -1

typedef struct{
  int parent;
  int left;
  int right;
}Node;
Node N[100000];
int n,D[100000];


void depth(int u,int p)
{
  D[u]=p;

  if(N[u].right!=NUL){depth(N[u].right,p);}

  if(N[u].left!=NUL){depth(N[u].left,p+1);}
}

void print(int u){
  int i,c,k=0;
  printf("node %d: parent = %d, depth = %d,",u,N[u].parent,D[u]);
  if(N[u].parent==NUL)printf(" root, ");
  else if(N[u].left==NUL)printf(" leaf, ");
  else printf(" internal node, ");
  printf("[");

  c=N[u].left;
  while(c!=NUL)
    {
      if(k==0)
	{
	  printf("%d",c);
	  k++;
	}
      else
	{
	  printf(", %d",c);
	}
      c=N[c].right;
    }

  k=0;

printf("]\n");
}

int main(){
  int n,i,j,v,d,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      N[i].parent=NUL;
      N[i].left=NUL;
      N[i].right=NUL;
    }
  
   for(i=0;i<n;i++)
    {
      scanf("%d",&v);
      scanf("%d",&d);
      
      for(j=0;j<d;j++)
	{
	  scanf("%d",&c);
	  if(j==0)N[v].left=c;
	  else N[l].right=c;
	  l=c;
	  N[c].parent=v;
	}
    }
      
  for(i=0;i<n;i++)
    {
      if(N[i].parent==NUL)r=i;
    }

  depth(r,0);
  
  for(i=0;i<n;i++)
    {
      print(i);
    }
  return 0;
}
  



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


int main() {

	int n;
	cin >> n;
	string s;
	cin >> s;

	string abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

	for(char c1 : s){
		int index;
		for(int i=0; i<26; i++){
			if(c1 == abc.at(i)){
				index = i; 
			}
		}
		if(n+index<=25){
			cout << abc.at(n+index);
		}else{
			cout << abc.at(n+index-26);
		}
	}
	cout << endl;
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
int main()
{
    uint64_t n{}, k{};
    std::cin >> n >> k;
    std::vector<uint64_t> enemy(n);
    for (uint64_t i = 0; i < n; i++) {
        std::cin >> enemy[i];
    }
    // TODO
    if (enemy.size() <= k) {
        std::cout << 0;
        return 0;
    }
    std::partial_sort(enemy.begin(), enemy.end() - k, enemy.end());
    std::cout << std::accumulate(enemy.begin(), enemy.end() - k, uint64_t{});
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#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 SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K, S;
	cin >> N >> K >> S;
	VI ans;

	int n = N;
	while (K--) {
		ans.push_back(S);
		N--;
	}
	int a = S * 10;
	if (a > INF)a = 1;
	
	while (N--) {
		ans.push_back(a);
	}


	REP(i, n) {
		cout << ans[i];
		if (i != N - 1)cout << " ";
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 2292
#!/usr/bin/env python3

def main():
    n = int(input())
    n_prev = [[2 for j in range(n)] for i in range(n)]
    post_matches = [[[] for j in range(n)] for i in range(n)]
    q = []
    for i in range(n):
        ai = list(map(int, input().split()))
        for j in range(n - 1):
            x = min(i, ai[j] - 1)
            y = max(i, ai[j] - 1)
            if j == 0:
                n_prev[x][y] -= 1
                if n_prev[x][y] == 0:
                    q.append((x, y))
            else:
                xp = min(i, ai[j - 1] - 1)
                yp = max(i, ai[j - 1] - 1)
                post_matches[xp][yp].append((x, y))

    time = 0
    while q:
        time += 1
        qn = []
        while q:
            i, j = q.pop()
            for i2, j2 in post_matches[i][j]:
                n_prev[i2][j2] -= 1
                if n_prev[i2][j2] == 0:
                    qn.append((i2, j2))
        q = qn

    for i in range(n):
        for j in range(i + 1, n):
            if n_prev[i][j] > 0:
                print(-1)
                return
    print(time)

if __name__ == "__main__":
    main()


Measured memory_bytes: 129288
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <deque>
#include <queue>
#include <string>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>

#define pb push_back
#define pbk pop_back
#define sz(a) ((int) (a).size())
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
#define next hunext
#define prev huprev
#define rank hurank
#define hash huhash

#ifdef LOCAL42
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int inf = int(1e9);
const ll linf = ll(1e18);
const double eps = 1e-9;
const double pi = 4 * atan(1.0);

int main() {
#ifdef LOCAL42
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    string s;
    cin >> s;
    ll ans = 0;
    for (int i = 0; i < (1 << (sz(s) - 1)); ++i) {
        int last = -1;
        ll res = 0;
        for (int j = 0; j + 1 < sz(s); ++j) {
            if ((i & (1 << j)) != 0) {
                ll cur = 0;
                for (int z = last + 1; z <= j; ++z) {
                    cur = cur * 10 + s[z] - '0';
                }
                res += cur;
                last = j;
            }
        }
        ll cur = 0;
        for (int j = last + 1; j < sz(s); ++j) {
            cur = cur * 10 + s[j] - '0';
        }
        res += cur;
        ans += res;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
cur_x = 0
cur_y = 0 
cur_t = 0
for i in range(n):
    t, x, y = [int(i) for i in input().split()]
    d_x = abs(x - cur_x)
    d_y = abs(y - cur_y)
    d_t = t - cur_t
    if d_x + d_y > d_t or (d_t - (d_x + d_y)) % 2 == 1:
        print('No')
        break 
    cur_t = t
    cur_x = x
    cur_y = y
else:
    print('Yes')

Measured memory_bytes: 3064
// AOJ 2639: Yamanote Line
// 2017.11.26 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

char tm[3660];

int main()
{
	int a, b, c, i, t, ans;

	scanf("%d%d%d", &a, &b, &c);
	while (c < 3660) tm[c] = 1, c += 60;
	for (t = 0; t < 3660; t += a+b) {
		for (i = 0; i <= a; i++) {
			if (tm[t+i]) { printf("%d\n", t+i); return 0; }
		}
	}
	puts("-1");
	return 0;
}

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

int main() {
    int n; cin >> n;
    int a[n + 1];
    for (int i = 0; i < n; i++) cin >> a[i];
    int sum = accumulate(a, a + n, 0);
    int avg = sum / n - 2;
    int ans = 1e9;
    for (int i = 0; i < 3; i++) {
        int tot = 0;
        avg++;
        for (int j = 0; j < n; j++) {
            tot += (a[j] - avg) * (a[j] - avg);
        }
        ans = min(ans, tot);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<int> L(n);
    REP(i,n){
        cin >> L[i];
    }
    sort(L.begin(),L.end());
    ll sum = 0;
    REP(i,n-1){
        sum += L[i];
    }
    if(L[n-1]<sum){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#AC

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def culc(x):
    return x*(x-1)//2

n,m=map(int,input().split())
edge=[]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    edge.append((a,b))


ans=[culc(n)]

uf=UnionFind(n)
for i in range(m):
    a,b=edge[m-i-1]
    if uf.same(a,b):
        ans.append(ans[-1])
    else:
        member_a=uf.size(a)
        member_b=uf.size(b)
        uf.union(a,b)
        #不便さの減少幅(>=0)
        add=culc(uf.size(a))-culc(member_a)-culc(member_b)
        ans.append(ans[-1]-add)


for i in range(m):
    print(ans[m-i-1])





Measured memory_bytes: 27264
#include<iostream>
using namespace std;
int n,m,a[201][201];
int main(){
	cin>>n>>m;
	char c;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>c;
			if(c=='#')a[i][j]=-1;
			else a[i][j]=0;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(a[i][j]==-1)continue;
			if(a[i-1][j]==-1)a[i][j]++;
			if(a[i][j-1]==-1)a[i][j]++;
			if(a[i-1][j-1]==-1)a[i][j]++;
			if(a[i+1][j]==-1)a[i][j]++;
			if(a[i][j+1]==-1)a[i][j]++;
			if(a[i+1][j+1]==-1)a[i][j]++;
			if(a[i-1][j+1]==-1)a[i][j]++;
			if(a[i+1][j-1]==-1)a[i][j]++;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(a[i][j]==-1)cout<<'#';
			else cout<<a[i][j]; 
		}
		cout<<endl;
	}
} //lgP2670  ybt1970  扫雷 

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))

m=0
index=-1
for i in range(0,N):
    if abs(A[i])>m:
        m=abs(A[i])
        index=i

if index==-1:
    print(0)
else:
    if A[index]>0:
        operate=[]
        for i in range(0,N):
            if i!=index:
                operate.append((index+1,i+1))
                A[i]+=A[index]

        for i in range(0,N-1):
            if A[i]>A[i+1]:
                operate.append((i+1,i+2))
                A[i+1]+=A[i]

        print(len(operate))
        for x,y in operate:
            print(x,y)
    else:
        operate=[]
        for i in range(0,N):
            if i!=index:
                operate.append((index+1,i+1))
                A[i]+=A[index]

        for i in range(N-1,0,-1):
            if A[i]<A[i-1]:
                operate.append((i+1,i))
                A[i-1]+=A[i]

        print(len(operate))
        for x,y in operate:
            print(x,y)

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

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

const int MAX = 50;

int H, W;
int map[MAX][MAX];
int dp[MAX + 1][MAX + 1];

void solve()
{
  dp[0][0] = 0;
  REP(i, H){
    REP(j, W){
      if(i == 0 || j  == 0){
	if(i != 0)
	  dp[i][j] = map[i][j] + dp[i - 1][0];
	else if(j != 0)
	  dp[i][j] = map[i][j] + dp[0][j - 1];
      }else{
	dp[i][j] = map[i][j] + min(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }
}

int main()
{
  cin >> H >> W;
  char buf[W + 1];
  REP(j, H){
    cin >> buf;
    REP(i, W)
      map[j][i] = buf[i] - '0';
  }
  solve();
  cout << dp[H - 1][W - 1] << endl;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
	fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
	ll a, b;
	cin>>a>>b;
	cout<<max(a+b, max(a-b, a*b))<<endl;
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 60;
char s[maxn];
int main(){
	scanf("%s", s + 1); int n = strlen(s + 1);
	int l = 1, r = n, ans = 0;
	while (l < r){
		if (s[l] == s[r]){
			++ l; -- r; continue;
		} else if (s[l] == 'x'){
			++ ans;
			++ l;
			continue;
		} else if (s[r] == 'x'){
			++ ans;
			-- r;
			continue;
		} else {
			ans = -1;
			break;
		}		
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
string t;
int n,k,w[3],a[100001],dp[3][100001],ans;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n>>k>>w[1]>>w[2]>>w[0]>>t;
	for(int i=0;i<n;++i)
	{
		if(t[i]=='r')
		{
			a[i+1]=0;
		}
		if(t[i]=='s')
		{
			a[i+1]=1;
		}
		if(t[i]=='p')
		{
			a[i+1]=2;
		}
	}
	for(int i=1;i<=k;++i)
	{
		if(a[i]==0)
		{
			dp[0][i]=w[0];
			dp[1][i]=0;
			dp[2][i]=0;
		}
		if(a[i]==1)
		{
			dp[0][i]=0;
			dp[1][i]=w[1];
			dp[2][i]=0;
		}
		if(a[i]==2)
		{
			dp[0][i]=0;
			dp[1][i]=0;
			dp[2][i]=w[2];
		}
		for(int j=i+k;j<=n;j+=k)
		{
			if(a[j]==0)
			{
				dp[0][j]=max(dp[1][j-k],dp[2][j-k])+w[0];
				dp[1][j]=max(dp[0][j-k],dp[2][j-k]);
				dp[2][j]=max(dp[0][j-k],dp[1][j-k]);
			}
			if(a[j]==1)
			{
				dp[0][j]=max(dp[1][j-k],dp[2][j-k]);
				dp[1][j]=max(dp[0][j-k],dp[2][j-k])+w[1];
				dp[2][j]=max(dp[0][j-k],dp[1][j-k]);
			}
			if(a[j]==2)
			{
				dp[0][j]=max(dp[1][j-k],dp[2][j-k]);
				dp[1][j]=max(dp[0][j-k],dp[2][j-k]);
				dp[2][j]=max(dp[0][j-k],dp[1][j-k])+w[2];
			}
		}
	}
	for(int i=n;i+k>n;--i)
	{
		ans+=max(max(dp[0][i],dp[1][i]),dp[2][i]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	ll H;
	cin>>H;
	ll st = 1, en = 1, mv = 1;
	while(en < H)
	{
		st = (st<<1LL);
		en = ((en<<1LL) | 1LL);
		mv = ((mv<<1LL) | 1LL);
	}	
	cout<<mv<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
s = input()
s1 = int(s[:2])
s2 = int(s[2:])
isS1YYMM = 1 <= s1 <= 12
isS2MMYY = 1 <= s2 <= 12
if isS1YYMM:
    if isS2MMYY:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if isS2MMYY:
        print("YYMM")
    else:
        print('NA')

Measured memory_bytes: 3064
n = int(input())
A = list(map(int, input().split()))
ans = 0
abs_A = [abs(a) for a in A]
count = sum([1 if a < 0 else 0 for a in A])
if (count % 2 == 0):
    print(sum(abs_A))
else:
    print(sum(abs_A) - 2 * min(abs_A))

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

int main(){
    long long L,R;
    cin >> L >> R;
    long long ans;
    if(R >= L + 4037) ans =  0;
    else {
        long long c[R-L+1];
        for(long long i=0; i<R-L+1; i++){
            c[i] = (L+i) % 2019;
        }
        ans = 2019;
        for(int i=0; i<R-L+1; i++){
            for(int j=i+1; j<R-L+1; j++){
                long long t = c[i]*c[j]%2019;
                if(ans > t) ans = t;
            }
        }
    }
    cout <<  ans << endl;


    return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int>sunu(n);
    for (int i = 0; i < k; i++)
    {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            int a;
            cin >> a;
            sunu.at(a-1)++;
        }
        
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if(sunu.at(i)==0){
            ans++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3644