akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std; // 575

long xors(long N) {
	switch(N % 4) {
		case 0: return N;
		case 1: return 1;
		case 2: return N ^ 1;
		case 3: return 0;
	}
}
int main() {
	long A, B;
	cin >> A >> B;
	cout << (xors(max(0L, A - 1)) ^ xors(B));
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

各bitについて、AからBまでの間に何回呼ばれるか考える
基本的に偶奇を考えれば良いことに着目すると、第n番目のbitに関してmod 2^nで考えていい
というかもっと端折ってmod 4で考えても実は良さそう
何故ならnとn+1、これのxorは1なので4回で戻るわ
A mod 4の結果が0ならA, 1なら1, 2ならA ^ 1, 3なら0で終わり
Bも同様にやって最後にxorで終了
*/

Measured memory_bytes: 256
a,b,h,m=list(map(int, input().split()))
import math
dm=math.pi*m/30
dh=math.pi*(60*h+m)/360
xa=a*math.cos(dh)
ya=a*math.sin(dh)
xb=b*math.cos(dm)
yb=b*math.sin(dm)
dist=((xa-xb)**2+(ya-yb)**2)**0.5
print(dist)



Measured memory_bytes: 9572
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
#from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    a = tuple(map(int, input().split()))

    s = [0] * (N+1)
    for i in range(N):
        s[i+1] = s[i] + a[i]
    c = Counter(s)

    ans = 0
    for key in c.keys():
        if c[key] > 1:
            ans += c[key]*(c[key]-1) / 2
    print(int(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 121932
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let K: usize = sc.get();
    let A: usize = sc.get();
    let B: usize = sc.get();
    for i in A..=B {
        if i % K == 0 {
            println!("OK");
            return;
        }
    }
    println!("NG");
}


Measured memory_bytes: 2108
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << ((n>=1000)?"ABD":"ABC") << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 6 + 5;
const int M = 5e5 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

int h,w,k,ans;
string c[N];

void init() {}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> h >> w >> k;

    for (int i = 0; i < h; ++i) {
        cin >> c[i];
    }

    for (int mask1 = 0; mask1 < (1<<h); ++mask1) {
        for (int mask2 = 0; mask2 < (1<<w); ++mask2) {
            int cnt = 0;
            for (int i = 0; i < h; ++i) {
                for (int j = 0; j < w; ++j) {
                    if(c[i][j]=='#' && !((1<<i)&mask1) && !((1<<j)&mask2)) ++cnt;
                }
            }
            if(cnt==k) ++ans;
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3636
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    W = list(map(int, input().split()))
    s1 = W[0]
    s2 = sum(W) - s1

    ans = abs(s2 - s1)
    for t in range(1, N):
        s1 += W[t]
        s2 -= W[t]
        ans = min(ans, abs(s1 - s2))
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;



int main(void) {
    ll n;
    cin >> n;
    ll a[n];
    rep (i, n) cin >> a[i];

    map<int, ll> mp;
    rep (i, n) mp[a[i]]++;

    ll sum = 0;
    for (auto x: mp) {
        sum += x.se * (x.se - 1) / 2;
    }

    ll t = sum;
    //cout << sum << " f" << endl;
    rep (i, n) {
        sum -= (ll)mp[a[i]] * (mp[a[i]] - 1) / 2;
        sum += (ll)(mp[a[i]] - 1) * (mp[a[i]] - 2) / 2;
        cout << sum << endl;
        sum = t;
    }

    return 0;
}


Measured memory_bytes: 11008
class Dice
    # constructor
    def initialize(line)
        @figures = line.chomp.split(" ").map(&:to_i)
    end
    
    # Rotate in any direction
    def rotate(direction)
        array = Array.new(6)
        
        case direction
        when "N"
            array[0] = @figures[1]
            array[1] = @figures[5]
            array[2] = @figures[2]
            array[3] = @figures[3]
            array[4] = @figures[0]
            array[5] = @figures[4]
        when "S"
            array[0] = @figures[4]
            array[1] = @figures[0]
            array[2] = @figures[2]
            array[3] = @figures[3]
            array[4] = @figures[5]
            array[5] = @figures[1]
        when "W"
            array[0] = @figures[2]
            array[1] = @figures[1]
            array[2] = @figures[5]
            array[3] = @figures[0]
            array[4] = @figures[4]
            array[5] = @figures[3]
        when "E"
            array[0] = @figures[3]
            array[1] = @figures[1]
            array[2] = @figures[0]
            array[3] = @figures[5]
            array[4] = @figures[4]
            array[5] = @figures[2]
        end
        @figures = Marshal.load(Marshal.dump(array))
    end
    
    # Rotate horizontally
    def turnClockwise()
        array = Array.new(6)
        array[0] = @figures[0]
        array[1] = @figures[2]
        array[2] = @figures[4]
        array[3] = @figures[1]
        array[4] = @figures[3]
        array[5] = @figures[5]
        @figures = Marshal.load(Marshal.dump(array))
    end
    
    def showTop()
        return @figures[0]
    end
    
    def showBottom
        return @figures[5]
    end
    
    def showFront()
        return @figures[1]
    end
    
    def showBack()
        return @figures[4]
    end
    
    def showRight()
        return @figures[2]
    end
    
    def showLeft()
        return @figures[3]
    end
    
    def showLabel()
        return @figures.join(" ")
    end
end

def isMatchTwoDices(label1, label2)
    dice1 = Dice.new(label1.chomp)
    dice2 = Dice.new(label2.chomp)

    for i in 1..4
        for j in 1..4
            if dice1.showTop() == dice2.showTop()
                for k in 1..4
                    if dice1.showLabel() == dice2.showLabel()
                        return true
                        exit
                    else
                        dice1.turnClockwise()
                    end
                end
            else
                dice1.rotate("N")
            end
        end
        dice1.rotate("W")
    end
    return false
end
##### Main Method #####
n = gets.to_i

input = []
(1..n).each {input << gets.chomp}

for i in 0..n - 2
    for j in i + 1..n - 1
        if isMatchTwoDices(input[i], input[j])
            puts "No"
            exit
        end
    end
end
puts "Yes"


Measured memory_bytes: 7772
#include<stdio.h>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
	int a, b, c, x, y, sum = 0;
	cin >> a >> b >> c >> x >> y;
	if (x > y) {
		swap(x, y);
		swap(a, b);
	}
	if (c * 2 > (a + b)) {
		sum += (a + b)*x;
	}
	else {
		sum += 2 * c*x;
	}
	y -= x;
	if (2*c > b) {
		sum += b*y;
	}
	else {
		sum += 2 * c*y;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define rg register
#define il inline
#define maxn 300005
#define ll long long
using namespace std;
int a[maxn] , b[maxn] , c[maxn] , sum[maxn] , d[maxn];
il int lowbit(int x){return x & (-x);}
void insert(int i,int x,int n){
	while (i <= n){
		c[i] += x;
		i += lowbit(i);	
	}
}
ll getsum(int i){
	rg ll ans = 0;
	while (i > 0){
		ans += c[i];
		i -= lowbit(i);
	}
	return ans;
}
bool check(int x , int n){
	memset(c,0,sizeof(c));
	ll sum0 = (((ll)n * (ll)(n + 1) >> 1) >> 1) + 1;
	ll cnt = 0;
	for (rg int i = 1;i <= n;++i) if (a[i] <= x) b[i] = 1;else b[i] = -1;
	for (rg int i = 1;i <= n;++i) sum[i] = sum[i - 1] + b[i] , d[i] = sum[i];
	sort(sum + 1 , sum + 1 + n);
	int e = unique(sum + 1,sum + 1 + n) - sum;
	for (rg int i = 1;i <= n;++i) 
		d[i] = lower_bound(sum + 1 , sum + e + 1 , d[i]) - sum;
	rg int tmp = lower_bound(sum + 1 , sum + 1 + e , 0) - sum;
	insert(tmp , 1 , n);
	for (rg int i = 1;i <= n;++i){
		cnt += getsum(d[i] - 1);
		insert(d[i], 1 , n);
	}
	//cout<<cnt<<endl;
	return cnt >= sum0;
}
int main(){
	rg int n;
	scanf("%d",&n);
	rg int l = 1000000002 , r = -1;
	for (rg int i = 1;i <= n;++i) {scanf("%d",&a[i]);l = (a[i] < l)?a[i]:l , r = (a[i] > r)?a[i]:r;}
	while (l < r){
		rg int mid = (l + r) >> 1;
		if (check(mid , n)) r = mid;
		else l = mid + 1;	
	}
	cout << r;
	return 0;	
}

Measured memory_bytes: 3456
#include<stdio.h>
#include<string.h>
int main(){
  int m[2][6]={
    {1,-1, 1,4,5,2},
    {2, 3,-1,5,2,1}
  };
  char s[101];
  int n,i,a;
  while(1){
    scanf("%s",s);
    if(s[0]=='#')break;
    n=0;
    a=1;
    for(i=0;i<strlen(s);i++){
      n=m[s[i]-'0'][n];
      if(n==-1){
	a=0;
	break;
      }
    }
    if(a&&n==5)printf("Yes\n");
    else       printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 524
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			long x = in.nextLong();
			long n = 0;
			while (n * (n + 1) / 2 < x) {
				++n;
			}
			out.println(n);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(in.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}



Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
using namespace std;
 
 int main(){
   int N;
   int a[110];
   cin >> N;
   for (int i =0; i < N; i++) {
     cin >> a[i];
   }
   
   sort(a, a + N, greater<int>());
   int Alice = 0;
   int Bob = 0;
   for (int i = 0; i < N; i++) {
     if (i % 2 == 0) {
       Alice += a[i];
     }
     else {
       Bob += a[i];
     }
   }
   cout << Alice - Bob << endl;
 }

Measured memory_bytes: 256
// 2012/10/28 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int obj;
		cin >> obj;

		if(cin.eof())
			break;

		bool spc = false;

		for(int i=0; i<10; i++){
			if(obj%2==1){
				if(spc){
					cout << ' ';
				}

				int wgt = 1;
				for(int j=0; j<i; j++){
					wgt *= 2;
				}
				cout << wgt;

				spc = true;
			}

			obj /= 2;
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
n, m = map(int, input().split())

A= list()
v = list()
for _ in range(n):
    A.append(list(map(int, input().split())))

for _ in range(m):
    v.append(int(input()))
result =[] 
for i in range(n):
    sum = 0
    for j in range(m):
        sum += A[i][j] * v[j]
    result.append(sum)

for i in result:
    print(i)


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

int main() {
  ll w,h; cin>>w>>h;
  ll x,y; cin>>x>>y;
  // 与えられたx,yがどこであろうと、(x,y)と長方形の中心を通る直線を引けば良い
  // この線が複数存在するのは、x,yが中心点であるときのみ
  ll area = w*h/2.0;
  int isMid = 0;
  if(x*2==w&&y*2==h) isMid = 1;
  if(w%2==1&&h%2==1) cout << area << ".5" << " " << isMid << endl;
  else cout << area << " " << isMid << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
ll gcd(ll A, ll B){
    if(B == 0){
        return A;
    }
    return gcd(B, A%B);
}
int main() {
    ll N;
    cin >> N;
    vector<pair<ll, ll>> tasks;

    for(int i=0; i<N; i++) {
        ll a, b;
        cin >> a >> b;
        tasks.emplace_back(b, a);
    }

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

        ll sum = 0;

        for(auto c : tasks){
            sum += c.second;
            if(sum > c.first){
                cout << "No" << endl;
                return 0;
            }
        }
    
    cout << "Yes" << endl;


}

Measured memory_bytes: 6128
#include <iostream>
#include <set>
#include <string>
using namespace std;
int main(){
  set<string> s;
  int n;
  string a;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a;
    s.insert(a);
  }
  cout << s.size();
  return 0;
}

Measured memory_bytes: 19256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=(s);i<(t);++i)
#define repb(i,s,t) for(int i=(s);i<=(t);++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
#define mst(a,b) memset(a,b,sizeof(a))
#define dd(x) cout<<#x<<'='<<x<<' '
#define de(x) cout<<#x<<'='<<x<<'\n'
#define fi first
#define se second
#define sq(x) ((x)*(x))
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

const int inf = 0x3f3f3f3f;
const ll infl = 4557430888798830399ll;
const ll mod = 1e9+7;


int main()
{
	int n,a;vector<pii> v;
	cin>>n;
	rep(i,0,n)
	{
		cin>>a;
		if(v.empty()||v.back().fi!=a)v.pb(mp(a,1));
		else v.back().se+=1;
	}
	a=0;
	rep(i,0,sz(v))a+=v[i].se/2;
	cout<<a<<endl;
}

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

int main(){
  int n; cin >> n;
  int maxn=0, minn=2000;

  int a;
  for(int i=0; i<n; i++){
    cin >> a;
    maxn = max(maxn, a);
    minn = min(minn, a);
  }

  cout << maxn-minn << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

string six_fix(int a) {
  string str = to_string(a);
  while ((int)str.size() != 6) {
    str = '0' + str;
  }
  return str;
}

int main() {
  int N,M;
  cin >> N >> M;
  int p[M],Y[M];
  vector<P> A[110000];
  string ans[M];
  for (int i = 0; i < M; i++) {
    cin >> p[i] >> Y[i];
    A[p[i]].emplace_back(Y[i],i);
  }
  for (int i = 0; i < 110000; i++) {
    sort(A[i].begin(),A[i].end());
  }
  for (int i = 0; i < 110000; i++) {
    for (int j = 0; j < (int)A[i].size(); j++) {
      ans[A[i][j].S] = six_fix(i) + six_fix(j+1);
    } 
  }
  for (int i = 0; i < M; i++) {
    cout << ans[i] << endl; 
  }
  return 0;
}

Measured memory_bytes: 13212
n = int(input())
lis = [list(map(int,input().split())) for x in range(n)]
lis = sorted(lis,key=lambda x:x[2])

bx,by,bh = -1,-1,-1
for cy in range(101):
    for cx in range(101):
        if bh >= 0:break
        #1点決めて基準の高さ(？)を決めておく
        h = abs(lis[-1][0] - cx) + abs(lis[-1][1] - cy) + lis[-1][2]	
        ok = True
        for li in lis:
            #もし高さがすべて確かに一致したときok
            if max(h - abs(li[0]-cx) - abs(li[1]-cy),0) != li[2]:
                ok = False
                break
        if ok :
            bx,by,bh = cx,cy,h
print(bx,by,bh)



Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
  int N;
  scanf("%d",&N);
  int p=N%10;
  if(p==3){
    printf("bon\n");
  }else if(p==0 || p==1 || p==6 || p==8){
    printf("pon\n");
  }else{
    printf("hon\n");
  }
  return 0;
}

Measured memory_bytes: 1616
#include <iostream>
#include <numeric>
#include <vector>
#include <set>

using std::pair;
using std::vector;

struct MaxFlow {
    struct Edge {
        int dst, cap, rev;
        Edge(int dst, int cap, int rev)
            : dst(dst), cap(cap), rev(rev) {}
    };
    using Graph = vector<vector<Edge>>;

    Graph graph;
    vector<bool> visited;

    MaxFlow(int n) : graph(n), visited(n) {}

    void span(int src, int dst, int cap) {
        graph[src].emplace_back(dst, cap, graph[dst].size());
        graph[dst].emplace_back(src, 0, graph[src].size() - 1);
    }

    int dfs(int v, int g, int f) {
        if (visited[v]) return -1;
        if (v == g) return f;

        visited[v] = true;
        for (auto& e : graph[v]) {
            if (e.cap == 0) continue;
            int ret = dfs(e.dst, g, std::min(f, e.cap));
            if (ret < 0) continue;
            e.cap -= ret;
            graph[e.dst][e.rev].cap += ret;
            return ret;
        }
        return -1;
    }

    int exec(int s, int g) {
        int ret = 0;
        while (true) {
            std::fill(visited.begin(), visited.end(), false);
            int res = dfs(s, g, 1e9);
            if (res < 0) break;
            ret += res;
        }
        return ret;
    }
};

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n) {
        std::iota(par.begin(), par.end(), 0);
    }

    int find(int v) {
        return par[v] == v ? par[v] : par[v] = find(par[v]);
    }

    void unite(int u, int v) {
        par[find(u)] = find(v);
    }
};

int main() {
    int n, m;
    std::cin >> n >> m;

    vector<pair<int, int>> edges(m);
    int unused;
    {
        std::set<int> xs, ys;
        for (auto& e : edges) {
            std::cin >> e.first >> e.second;
            --e.first, --e.second;
            xs.insert(e.first);
            ys.insert(e.second);
        }
        unused = n * 2 - xs.size() - ys.size();
    }

    // 最大マッチングが残る最大数
    MaxFlow mf(n * 2 + 2);
    int s = n * 2, g = n * 2 + 1;
    for (int v = 0; v < n; ++v) {
        mf.span(s, v, 1);
        mf.span(v + n, g, 1);
    }
    for (auto e : edges) {
        mf.span(e.first, e.second + n, 1);
    }
    int min = m - mf.exec(s, g);

    // 連結成分数が残る最小数
    UnionFind uf(n * 2);
    for (auto e : edges) {
        uf.unite(e.first, e.second + n);
    }
    std::set<int> pars;
    for (int v = 0; v < n * 2; ++v) {
        pars.insert(uf.find(v));
    }
    int max = m - (pars.size() - unused);

    std::cout << min << ' ' << max << std::endl;
    return 0;
}



Measured memory_bytes: 3312
#!/usr/bin/env python
# -*- coding: utf-8 -*-
S = input()
n = len(S) - 1
pattern = []
ans = 0

for i in range(2 ** n):
    tmp = [0] * n
    for j in range(n):
        if i >> j & 1:
            tmp[j] = "+"
    pattern.append(tmp)

for i in range(2 ** n):
    X = S[0]
    for j in range(n):
        if pattern[i][j] == "+":
            ans += int(X)
            X = S[j+1]
        else:
            X += S[j+1]
    ans += int(X)
print(ans)


Measured memory_bytes: 68108
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = scanner.nextInt();
        ArrayList<P> pts = new ArrayList<>();
        ArrayList<Integer> x = new ArrayList<>();
        ArrayList<Integer> y = new ArrayList<>();
        for(int i = 0; i < n; i++) {
            int xx = scanner.nextInt(), yy = scanner.nextInt();
            if (xx == 0 && yy == 0) continue;
            x.add(xx); y.add(yy);
            pts.add(new P(xx, yy));
        }
        n = pts.size();
        Collections.sort(pts);
        double ans = 0;
        for(int i = 0; i < n; i++) {
            double xx = 0.0; double yy = 0.0;
            for(int j = 0; j < n; j++) {
                int ind = (i + j) % n;
                P cur = pts.get(ind);
                xx += cur.x;
                yy += cur.y;
                ans = Math.max(ans, Math.hypot(xx,yy));
            }
        }
        out.printf("%.20f\n", ans);
        out.flush();
    }
    static class P implements Comparable<P>{
        double x, y;
        public P (double xx, double yy) {
            x = xx; y = yy;
        }
        public int compareTo(P o) {
            return Double.compare(Math.atan2(y,x), Math.atan2(o.y, o.x));
        }
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
int main(){
    int N;
    cin >> N;
    vector<long long> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    vector<long long> cnt(N + 1);
    map<long long, long long> m;
    int MAX = 0, ind = 0;
    vector<P> vec;
    vec.push_back(P(0, -1));
    for(int i = 0; i < N; i++){
        if(MAX < a[i]){
            MAX = a[i];
            ind = i;
            vec.push_back(P(a[i], i));
        }
    }
    reverse(vec.begin(), vec.end());
    int n = vec.size();
    int right = N;
    for(int i = 0; i < n - 1; i++){
        P v = vec[i];
        int now = v.second;
        for(int i = now; i < right; i++){
            m[a[i]]++;
        }
        long long nex = vec[i + 1].first;
        vector<P> temp;
        for(auto ite = m.rbegin(); ite != m.rend(); ite++){
            auto u = *ite;
            if(u.first <= nex) break;
            cnt[now] += (u.first - nex) * u.second;
            temp.push_back(u);
        }
        for(P u: temp){
            m[nex] += u.second;
            m.erase(u.first);
        }
        right = now;
    }
    for(int i = 0; i < N; i++){
        cout << cnt[i] << endl;
    }
}

Measured memory_bytes: 13168
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

#define mem(ar,a)       memset(ar,a,sizeof ar)
#define iOS           	ios_base::sync_with_stdio(false);cin.tie(NULL); 
#define pb(x)           push_back(x)
#define all(c)          c.begin(), c.end()
#define int             long long
#define ff              first
#define ss              second
#define nl              '\n'

int32_t main()
{
	iOS
	int a,b; cin>>a>>b;
	if(a>=13)
		cout<<b;
	else if(a<=5)
		cout<<0;
	else
		cout<<b/2;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

int main()
{
  int n, r;
  cin >> n >> r;
  if (n >= 10)
  {
    cout << r << endl;
  }
  else
  {
    cout << 100 * (10 - n) + r << endl;
  }
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (a, b, c, d) = readLine()!!.split(" ").map { it.toInt() }
    for (i in 0 until 1000){
        c -= b
        if (c <= 0){
            println("Yes")
            break
        }
        a -= d
        if (a <= 0){
            println("No")
            break
        }
    }
}


Measured memory_bytes: 36312
#include<iostream>
#include<cmath>
using namespace std;
const double PI= atan(1.0)*4;
const int maxn=2e5+5;
int main() 
{
    long long n,a[maxn]={0};
    cin>>n;
    for(int i=1;i<n;i++){
    	int ai;
    	cin>>ai;
    	a[ai]++;
	}
  for(int i=1;i<=n;i++){
    cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 5160
n, k = gets.split.map(&:to_i)
destinations = gets.split.map(&:to_i)

teleport = [1]
visited = Array.new(200001)
visited[1] = true

now = 1
while true
  nxt = destinations[now - 1]
  teleport << nxt
  break if visited[nxt]
  visited[nxt] = true
  now = nxt
end

idx = teleport.index(nxt)
ts = teleport.size
ans = if k < ts
        teleport[k]
      else
        loop_size = ts - idx - 1
        teleport[(k - idx) % loop_size + idx]
      end

puts ans

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

int main() {
  int64_t H, M;
  cin >> H >> M;
  if((H != 1) && (M != 1)){
    if((H * M) % 2 == 0) {
      cout << H * M / 2<< endl;
    }
    else {
      cout << (H * M + 1) / 2 << endl;
    }
  }
  else {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		long[] B = new long[N];
		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
		}
		
		long ans = 0;
		
		for(int i=N-1; i>=0; i--) {
			long push = B[i] - (A[i]+ans)%B[i];
			if(push==B[i])
				push = 0;
			ans += push;
		}
		
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 72272
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;


int main(){
	string S;
	cin >> S;
    int B_counter = 0;
    ll result = 0;
    for(int i = 0; i < S.length(); i++){
        if(S[i]=='W'){
            result += B_counter;
        }else{
            B_counter++;
        }
    }

    cout << result << endl;

	return 0;
}


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

string str;
unsigned int cur;

bool is_digit(char c)
{
	return c >= '0'&&c <= '9';
}

int solve()
{
	vector<int> vec;
	unsigned int str_size = str.size();

	while (cur < str_size) {
		if (is_digit(str[cur]) == true) {
			int num = 0;
			while (is_digit(str[cur]) == true) {
				num *= 10;
				num += str[cur] - '0';
				cur++;
			}
			vec.push_back((num + 1) / 2);
		}
		else if (str[cur] == '[') {
			cur++;

			vec.push_back(solve());
		}
		else if (str[cur] == ']') {
			cur++;

			int ans = 0;
			unsigned int size = vec.size();

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

			for (unsigned int i = 0; i <= size / 2; i++) {
				ans += vec[i];
			}

			return ans;
		}
	}
}

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

	for (int i = 0; i < n; i++) {
		cin >> str;

		cur = 1;

		cout << solve() << endl;
	}

	return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int H,W;
    cin >> H >> W;
    vector<string> S(H);
    rep(i,H)cin >> S[i];
    vector<vector<int>> wDP(H,vector<int>(W));
    rep(i,H){
        int l = 0;
        rep(j,W){
            if(S[i][j]=='#')l = 0;
            if(l == 0){
                repX(k, W, j)
                {
                    if (S[i][k] == '#')
                        break;
                    else
                        l++;
                }
            }
            wDP[i][j] = l;
        }
    }
    vector<vector<int>> hDP(H, vector<int>(W));
    rep(i, W)
    {
        int l = 0;
        rep(j, H)
        {
            if (S[j][i] == '#')
                l = 0;
            if (l == 0)
            {
                repX(k, H, j)
                {
                    if (S[k][i] == '#')
                        break;
                    else
                        l++;
                }
            }
            hDP[j][i] = l;
        }
    }
    int ans = 0;
    rep(i,H){
        rep(j,W){
            ans = max(ans,wDP[i][j]+hDP[i][j]);
        }
    }
    cout << ans-1 << endl;

    return 0;
}

Measured memory_bytes: 35712
N = list(map(int,input().split()))
Q = [list(map(int,input().split())) for i in range(N[2])]

# N = [4, 6, 10]
# Q = [[2, 4, 1, 86568], [1, 4, 0, 90629], [2, 3, 0, 90310], [3, 4, 1, 29211], [3, 4, 3, 78537], [3, 4, 2, 8580], [1, 2, 1, 96263], [1, 4, 2, 2156], [1, 2, 0, 94325], [1, 4, 3, 94328]]

from itertools import combinations_with_replacement as comb_rplc

C = 0
for seq in comb_rplc(range(1, N[1]+1), N[0]):
    S = 0
    for i in range(N[2]):
        if seq[Q[i][1]-1]-seq[Q[i][0]-1] == Q[i][2]:
            S += Q[i][3]
    if S > C:
        C = S
print(C)

Measured memory_bytes: 9092
n = int(input())
v = [0] * 4
for i in range(n):
    s = input()
    if s == 'AC': v[0] += 1
    elif s == 'WA': v[1] += 1
    elif s == 'TLE': v[2] += 1
    else: v[3] += 1
print('AC x ',v[0])
print('WA x ',v[1])
print('TLE x ',v[2])
print('RE x ',v[3])

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define gc getchar()
using namespace std;
int read()
{
	int x=1;
	char ch;
	while (ch=gc,ch<'0'||ch>'9') if (ch=='-') x=-1;
	int s=ch-'0';
	while (ch=gc,ch>='0'&&ch<='9') s=s*10+ch-'0';
	return s*x;
}
int main()
{
	int A=read(),B=read(),C=read();
	long long k;
	scanf("%lld",&k);
	if (k&1) printf("%d\n",B-A);
	else printf("%d\n",A-B);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;
int main(){
  ll s,k=1;
  cin >>s;
  vector <ll> v;
  v.push_back(s);
  while(1){
    if(s%2==0){
      s=s/2;
      for(ll i=0;i<k;i++){
        if(v[i]==s) {
          cout <<k+1<<endl;
          return 0;
        }
      }
      v.push_back(s);
      k++;
    }
    else{
      s=3*s+1;
      for(ll i=0;i<k;i++){
        if(v[i]==s) {
          cout <<k+1<<endl;
          return 0;
        }
      }
      v.push_back(s);
      k++;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

// M * (M-1)^(N-1-K) * N-1 C K
int main(int argc, const char * argv[]) {
    ll N; cin >> N;
    set<ll> A;
    for(ll i=0;i<N;i++){
        ll temp; cin >> temp;
        A.insert(temp);
    }
    if(A.size()!=N){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}



Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define MOD 1000000007;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int r {};
    cin >> r;

    cout<<r*r<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for A - Dividing a String
	var S string
	fmt.Scan(&S)

	if len(S) == 1 {
		fmt.Println("1")
	} else if len(S) == 2 {
		if S[0] != S[1] {
			fmt.Println("2")
		} else {
			fmt.Println("1")
		}
	} else {
		var ans int
		var T string
		for i := 0; i < len(S); i++ {
			if S[i:i+1] != T {
				T = S[i : i+1]
			} else {
				if i == len(S)-1 {
					break
				} else {
					i++
					T = ""
				}
			}
			ans++
		}
		fmt.Println(ans)
	}
}


Measured memory_bytes: 3248
Imports System

Module Program
    Sub Main(args As String())
        Dim Str As String = Console.ReadLine()

        Dim N As Integer = Integer.Parse(Str.Substring(0, Str.IndexOf(" ")))
        Dim M As Long = Long.Parse(Str.Substring(Str.IndexOf(" ") + 1, Str.Length - Str.IndexOf(" ") - 1))

        If N = M Then
            Console.WriteLine("Yes")
        Else
            Console.WriteLine("No")
        End If

    End Sub
End Module


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

// consider 24 min.40min gokai, reconsider46
int main(){
  int n;cin >> n;
  int m=0;
  vector<int> v;
  rep(i,n){
    int a; cin >> a;
    m=max(m,a);
    v.push_back(a);
  }
  int u=0;
  for(auto a: v){
    if(abs(u-m/2)>abs(a-m/2)){
      u=a;
    }
  }
  cout << m << ' ' << u << endl;
  return 0;
}


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

int main(){
	int n; cin>>n;
	vector<int> a(n),b(n),c(n),d(n);
	for(int i=0;i<n;i++) cin >> a[i] >> b[i];
	for(int i=0;i<n;i++) cin >> c[i] >> d[i];

	int ans=0;
	while(c.size()>0){
		int minxblue=0;
		for(int i=1;i<c.size();i++){
			minxblue=min(c[minxblue],c[i])==c[i]?i:minxblue;
		}
		int maxyred=0;
		bool flag=false;
		for(int i=0;i<a.size();i++){
			if(a[i]<c[minxblue] && b[i]<d[minxblue]){
				if(!flag) maxyred=i;
				maxyred=max(b[i],b[maxyred])==b[i]?i:maxyred;
				flag=true;
			}
		}
		if(flag){
			ans++;
			a.erase(a.begin()+maxyred);
			b.erase(b.begin()+maxyred);
		}
		c.erase(c.begin()+minxblue);
		d.erase(d.begin()+minxblue);
	}
	cout << ans << endl;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n, t;
  cin >> n >> t;
  vector<int> a(n);
  vector<int> min_a(n);
  vector<int> max_a(n);
  for (auto &e : a) {
    cin >> e;
  }
  min_a[0] = a[0];
  max_a[0] = a[0];
  int max_diff = 0;
  int count = 0;
  for (int i = 1; i < n; ++i) {
    min_a[i] = min(min_a[i-1], a[i]);
    max_a[i] = max(max_a[i-1], a[i]);
    int diff = a[i] - min_a[i-1];
    if (max_diff == diff) {
      count++;
    } else if (max_diff < diff) {
      max_diff = diff;
      count = 1;
    }
  }
  cout << count << "\n";
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> f(N, 0);
    for (int h = 0; h < N; h++)
    {
        for (int i = 1; i * i <= h; i++)
        {
            for (int j = 1; j*j<= h; j++)
            {
                for (int k = 1; k*k <= h; k++)
                {

                    if (i * (i + j + k) + j * (j + k) + k * k == h + 1)
                    {

                        //cout << h + 1 << " " << i << " " << j << " " << k << endl;
                        f.at(h)++;
                    }
                    else if (i * (i + j + k) + j * (j + k) + k * k > h + 1)
                    {
                        break;
                    }
                }
            }
        }

        cout << f.at(h) << endl;
    }
}


Measured memory_bytes: 3592
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        const string MINUSINF = "-";
        static long[] match = new long[] { 2, 5, 5, 4, 5, 6, 3, 7, 6 };
        static string[] dp = Enumerable.Repeat("-", 11000).ToArray();
        static void Main(string[] args)
        {
            // 写経
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = Console.ReadLine().Split().Select(int.Parse).ToList();

            dp[0] = "";

            for (var i = 0; i <= NM[0]; i++)
            {
                if (dp[i] == MINUSINF) continue;
                foreach (var a in A)
                    ChMax(ref dp[i + match[a - 1]], dp[i] + (char)('0' + a));
            }
            Console.WriteLine(dp[NM[0]]);
        }

        static void ChMax(ref string a, string b)
        {
            if (a == MINUSINF) a = b;
            else if (a.Length < b.Length) a = b;
            else if (a.Length == b.Length)
            {
                if (a.CompareTo(b) < 0) a = b;
            }
        }
    }
}


Measured memory_bytes: 96248
#include "bits/stdc++.h"
#define ed cout<<"\n";
//#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//#define ll longlongint
using namespace std;
int main(){
     //SPEED;
     int N,Y;
     cin>>N>>Y;
     int res10000 = -1, res5000 = -1, res1000 = -1;
     for (int a = 0; a <= N; ++a) { 
         for (int b = 0; b + a <= N; ++b) {
             int c=N-a-b;
             int total=10000*a+5000*b+1000*c;
             if(total==Y){
                 res10000=a;
                 res5000=b;
                 res1000=c;
             }
         }
     }
     cout << res10000 << " " << res5000 << " " << res1000 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n;
    cin >> n;
    cout << (n*(n-1))/2;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>	// vectorを使うにはこれが必要
using namespace std;

int main(){
	vector< vector<int> > arr;
    vector<int> coin;
    int n, m, tmp;
    std::cin >> n >> m;
	arr.resize(m);
	for(int i=0; i<m; i++){
		arr[i].resize(n+1);
	}
    coin.resize(m);
    for(int i=0; i<m; i++){
        std::cin >> tmp;
        coin[i] = tmp;
    }
    for (int i=0; i<m; i++){
        for (int j=0; j<=n; j++){
            // arr[i][j] -> a_1, a_2, ..., a_iのコインでj+1円両替する時の最小枚数
            if (i==0 || j==0){
                arr[i][j] = j;
            }
            else {
                if (j-coin[i] >= 0){
                    arr[i][j] = min(arr[i-1][j], arr[i][j-coin[i]] + 1);
                }
                else {
                    arr[i][j] = arr[i-1][j];
                }
            }
            //std::cout << arr[i][j] << "|";
        }
        //std::cout << endl;
    }
    std::cout << arr[m-1][n] << endl;
	return 0;
}


Measured memory_bytes: 6748
import java.util.Scanner;

//Equal Total Score
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m)==0)break;
			int[] t = new int[n];
			int[] h = new int[m];
			int st = 0;
			int sh = 0;
			for(int i=0;i<n;i++){
				t[i] = sc.nextInt();
				st += t[i];
			}
			for(int i=0;i<m;i++){
				h[i] = sc.nextInt();
				sh += h[i];
			}
			int ct = -1;
			int ch = -1;
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(st-t[i]+h[j] == sh-h[j]+t[i]){
						if(ct==-1){
							ct = t[i];
							ch = h[j];
						}
						else if(t[i]+h[j] < ct + ch){
							ct = t[i];
							ch = h[j];
						}
					}
				}
			}
			System.out.println(ct==-1?ct:ct+" "+ch);
		}
	}
}

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

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	if (s.back() == 's') cout << s + "es";
	else cout << s + "s";
    return 0;
}

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

unsigned euclidean_gcd(unsigned, unsigned);
int main()
{
    long K, sum=0;
    cin >> K;
    for (long i = 1; i <= K;i++){
        for (long j = 1; j <= K;j++){
            for (long k = 1; k <= K;k++){
                long tmp = euclidean_gcd(i, j);
                sum += euclidean_gcd(tmp, k);

            }
        }
    }
    cout << sum << endl;
}

unsigned euclidean_gcd(unsigned a, unsigned b)
{
    if (a < b)
        return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}


Measured memory_bytes: 3640