akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int[] total = new int[3];

		total[0] = sc.nextInt();
		total[1] = sc.nextInt();
		total[2] = sc.nextInt();

		sc.close();

		Arrays.sort(total);

		System.out.println(total[0] + total[1]);
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>

using namespace std;

void dump(const vector<int>& v)
{
    cout << v[0];
    for (int i = 1; i < v.size(); ++i) cout << " " << v[i];
    cout << endl;
}

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    vector<int> b(N);
    int unit = 30000;
    for (int i = 0; i < N; ++i) {
        a[i] = (i + 1)*unit;
        b[i] = (N - i)*unit;
    }

    for (int i = 0; i < N; ++i) {
        int p;
        cin >> p;
        a[p-1] += i;
        b[p-1] += i;
    }

    dump(a);
    dump(b);
    
    return 0;
}

Measured memory_bytes: 768
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import bisect
 
def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

def f(*xs):
  return sum(x // 2 * 2 for x in xs)

def solve(I, J, L):
  ans = f(I, J, L)
  if min(I, J, L) >= 1:
    ans = max(ans, 3 + f(I-1, J-1, L-1))
  return ans

I, O, _, J, L, _, _ = reads()
ans = O + solve(I, J, L)
print(ans)

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

using namespace std;

int main() {
	string S, T;
	cin >> S >> T;
	int ans = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] != T[i]) {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 3912
N = int(input())
dp = [[0 for _ in range(3)] for _ in range(N + 1)]  # dp[何日目に][何をした] = その時の幸福度

for i in range(1, N + 1):
    a, b, c = map(int, input().split())
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a
    dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + b
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c

print(max(dp[N]))


Measured memory_bytes: 24308
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	int ans = 0;
	while (true) {
		if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
			cout << ans << endl;
			return 0;
		}
		if (A == B && A == C) {
			cout << -1 << endl;
			return 0;
		}
		int tmpA = A, tmpB = B, tmpC = C;
		A = tmpB / 2 + tmpC / 2;
		B = tmpA / 2 + tmpC / 2;
		C = tmpA / 2 + tmpB / 2;
		ans++;
	}
}


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

int main(){
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++){
        double tmp = 1.0;
        int cp = i;
        while(cp < k){
            cp *= 2;
            tmp /= 2.0;
        }
        ans += tmp/n;
    }
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}

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


int main(){
  int n; cin >> n;
  unsigned long long ans = 0;
  for (int i = 0; i <= n; i++)
  {
    if(i%5 && i%3)
    {
      ans += i;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 3648
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next();
  var dp = xArray(-1e9,n+1,n+1), add = 0;
  var a = nexts(2).sort((a,b)=>a-b), q;
  dp[0][0] = dp[0][a[0]] = dp[0][a[1]] = dp[a[0]][a[1]] = 0;
  for(var i = 1; i < n; i++){
    a = nexts(3).sort((a,b)=>a-b);
    solve(...a);
  }
  a = next();
  return Math.max(dp[0][0],dp[a][a]+1) + add;
  function solve(u,v,w){
    if(u === w)return add++;
    q = [];
    solve1(u);
    if(u<v)solve1(v);
    if(v<w)solve1(w);
    solve2(u,v);
    if(v<w)solve2(u,w);
    if(u<v)solve2(v,w);
    solve3(u,v,w);
    while(q.length){
      var x = q.pop(), y = q.pop(), z = q.pop();
      if(dp[x][y] < z)dp[x][y] = z;
    }
  }
  function solve1(u){
    f1(0,0,u,u);
    for(var i = 0; i < u; i++){
      f0(i,u,0,i);
    }
    for(var i = u; i <= n; i++){
      f0(u,i,0,i);
    }
  }
  function solve2(u,v){
    f0(u,v,0,0);
    f1(0,v,u,u);
    if(u < v){
      f1(0,u,v,v);
    }else{//u=v
      for(var i = 0; i < u; i++){
        f1(0,i,i,u);
      }
      for(var i = u; i <= n; i++){
        f1(0,i,u,i);
      }
    }
  }
  function solve3(u,v,w){
    f1(v,w,u,u);
    if(u < v){
      f1(u,w,v,v);
      if(v < w){
        f1(u,v,w,w);
      }else{//v=w
        for(var i = 0; i < u; i++){
          f1(i,u,i,w);
        }
        for(var i = u; i < w; i++){
          f1(u,i,i,w);
        }
        for(var i = w; i <= n; i++){
          f1(u,i,w,i);
        }
      }
    }else{//u=v
      f1(u,u,w,w);
      for(var i = 0; i < u; i++){
        f1(i,w,i,u);
      }
      for(var i = u; i < w; i++){
        f1(i,w,u,i);
      }
      for(var i = w; i <= n; i++){
        f1(w,i,u,i);
      }
    }
  }
  function f0(a,b,c,d){
    if(dp[a][b] < dp[c][d])q.push(dp[c][d],b,a);
  }
  function f1(a,b,c,d){
    if(dp[a][b] < dp[c][d]+1)q.push(dp[c][d]+1,b,a);
  }
}

Measured memory_bytes: 104232
<?php 
  $n = trim(fgets(STDIN));
  $list = [];
  if($n == 1){
    echo "1\n";
    exit;
  }
  for($i=0; $i<$n; $i++){
    $ans = $i*$i;
    if($n < $ans){
      break;
    }else{
      $list[] = $ans;
    }
  }
  echo max($list)."\n";

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

namespace _0033
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Ball ball = new Ball();
            for (int i = 0;i < n; ++i)
            {
                List<int> ballList = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
                if (ball.IsOrder(ballList) == true)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }

        }
    }
    class Ball
    {
       
        public bool IsOrder(List<int> list)
        {
            int endB = list[0];
            int endC = 0; 
            for (int i = 1; i < list.Count; ++i)
            {
                if (list[i] > endB)
                {
                    endB = list[i];
                }
                else if (list[i] < endB && list[i] > endC)
                {
                    endC = list[i];
                }
                else
                {
                    return false;
                }
            }
            return true;
        }
    }
}



Measured memory_bytes: 20248
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll  long long
#define int long long
#define ld  long double
#define pb push_back
#define mod 1000000007
#define M_PI 3.141592653589
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
long long binpow(long long a, long long b, long long m=mod) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
main()
{
    char a;
    cin>>a;
    if('A'<=a && a<='Z')
       cout<<"A";
    else
        cout<<"a";

}


Measured memory_bytes: 3620
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020 Bjarni Dagur Thor Karason

#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1e18
#define PI 3.14159265359

int n, mxw;
ll memo[101][100001];
vii items;

ll dp(int at, int w)
{
    if (w > mxw) return -INF;
    if (at == n) return 0;
    if (memo[at][w] != -1) return memo[at][w];
    return memo[at][w] = max(dp(at + 1, w), dp(at + 1, w + items[at].first) + items[at].second);
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    memset(memo, -1, sizeof(memo));
    cin >> n >> mxw;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        items.PB(MP(a, b));
    }
    cout << dp(0, 0) << endl;

    return 0;
}


Measured memory_bytes: 79232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;

#define NUM 5

int main(void)
{
  LL N, a[NUM];
  cin >> N;
  for (int i = 0; i < NUM; i++) {
    cin >> a[i];
  }

  cout << (LL)(4 + ceil((double)N / (*min_element(a, a + NUM)))) << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	A := ReadInts(N)

	ans := 0
	max := -1
	for i := 0; i < N; i++ {
		if A[i] < max {
			ans += max - A[i]
		} else {
			max = A[i]
		}
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 5996
//In the name of ALLAH
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
const bool DEBUG = false;
#define cerr if(DEBUG)cerr
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long long maxn = 2e5 + 5;
const long long INF = 4e18 ;
//const long long M = 1e9 + 7;
const int lg = 21;

int n;
string s, V = "Vacant", F = "Female", M = "Male", zer;
bool flag;

int c(int x){
	if(x == n and flag)
		return 0;
	return x;		
}

inline void doo(int lo, int hi, string sl, string sh){
	string s;
	//cout << lo << " " << hi << " " << sl << " " << sh << endl;
	if(hi - lo == 2){
		cout << c((hi + lo) / 2) << endl;
		cin >> s;
		return;
	}
	int mid = hi + lo >> 1;
	cout << c(mid) << endl;
	cin >> s;
	if(s == V)
		return;
	if(((mid - lo + 1) % 2 == 0 and sl == s) or ((mid - lo + 1) % 2 == 1 and sl != s)){
		doo(lo, mid, sl, s);
	}
	else{
		doo(mid, hi, s, sh);		
	}
}

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	cout << 0 << endl;
	cin >> zer;
	if(zer == V)
		return 0;
	int mid = n >> 1;
	cout << mid << endl;
	cin >> s;
	if(s == V)
		return 0;
	if(((mid + 1) % 2 == 0 and zer == s) or ((mid + 1) % 2 == 1) and zer != s){
		doo(0, mid, zer, s);
		return 0;
	}
	else{
		doo(mid, n, s, zer);
		return 0;
	}		
	return 0;
}


Measured memory_bytes: 852
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
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; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
int main(){
  ll n,k,x,y;
  cin >> n >> k;
  vector<pair<ll,ll>> vec;
  vector<ll> dec;
  ll kind[n+1];
  ll variety=0;
  memset(kind,0,sizeof(kind));
  rep(i,n){
    cin >> x >> y;
    vec.push_back(make_pair(-y,x)); // -価値,種類、
  }
  sort(all(vec));
  ll max = 0,tmp=0;
  rep(i,k){
    max += -vec[i].first;
    if(kind[vec[i].second]){
      dec.push_back(-vec[i].first);
    }else{
      variety++;
    }
    kind[vec[i].second]++;
  }
  reverse(all(dec));
  max += variety*variety;
  tmp = max;
  for(int i=k;i<n;i++){
    if(kind[vec[i].second] == 0){
      if(variety == k || dec.size() == 0){
        break;
      }
      kind[vec[i].second]++;
      tmp += -vec[i].first;
      tmp -= dec[0];
      tmp += 2 * variety + 1;
      //cout << dec[0] << endl;
      dec.erase(dec.begin());
      chmax(max,tmp);
      variety++;
    }
  }
  cout << max;
}


Measured memory_bytes: 3312
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AtCoder_Beginner_Contest_134
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            var Ai = Sarray();

            var v = new long[N];
            var num = 0;
            for (var i = N; 0 < i; --i)
            {
                var sum = 0L;
                for (var j = N / i; 1 < j; --j)
                {
                    sum += v[j * i - 1];
                }
                if (sum % 2 != Ai[i - 1])
                {
                    v[i - 1] = 1;
                    ++num;
                }
                else
                {
                    v[i - 1] = 0;
                }
            }
            WriteLine(num);
            for (var i = 0; i < N; ++i)
            {
                if (1 == v[i])
                    Write($"{i+1} ");
            }
        }
    }
}

Measured memory_bytes: 34140
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int c[1001],b[1001];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>c[i];
    int q,ti,xi,di;
    cin>>q;
    rep(i,q){
        cin>>ti>>xi>>di;
        if(ti==1){
            --xi;
            if(c[xi]<b[xi]+di){
                cout<<xi+1<<endl;
                return 0;
            }
            else{
                b[xi]+=di;
            }
        }
        else{
            --xi;
            if(b[xi]<di){
                cout<<xi+1<<endl;
                return 0;
            }
            else b[xi]-=di;
        }
    }
    cout<<0<<endl;
    return 0;
}


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

int main() {
  int n,m,x; cin>>n>>m>>x;
  int a,l=0,r=0;
  rep(i,m){
    cin>>a;
    if(a<x){l++;}
    else{r++;}
  }
  cout<<min(l,r);
}
      

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

const int MOD = 1e9+7;

string str1[600];
string str2[600];
vector<int> g1[600], g2[600];
bool goal1[600], goal2[600];
int A[600], B[600];
int n1, m1;
int n2, m2;

int memo[600][6][600];

int solve(int p1, int q1, int p2, int q2) {
  //cout << p1 << " " << q1 << " " << p2 << " " <<  q2 << endl;
  if (q2 == 0 && memo[p1][q1][p2] >= 0) return memo[p1][q1][p2];
  if (!goal1[p1] && q1 == str1[p1].size()) {
    ll res = 0;
    FOR(it, g1[p1])
      res = (res + solve(*it, 0, p2, q2)) % MOD;
    if (q2 == 0) memo[p1][q1][p2] = res;
    return res;
  }
  if (!goal2[p2] && q2 == str2[p2].size()) {
    ll res = 0;
    FOR(it, g2[p2])
      res = (res + solve(p1, q1, *it, 0)) % MOD;
    return res;
  }
  bool f1 = (goal1[p1] && q1 == str1[p1].size());
  bool f2 = (goal2[p2] && q2 == str2[p2].size());
  int res;
  if (f1 || f2) {
    res = f1 && f2;
  } else {
    if (str1[p1][q1] == str2[p2][q2]) {
      res = solve(p1, q1+1, p2, q2+1);
    } else {
      res = 0;
    }
  }
  if (q2 == 0) memo[p1][q1][p2] = res;
  return res;
}

int main() {
  int T;
  cin >> T;
  while(T--) {
    cin >> n1 >> m1;
    REP(i, m1) g1[i].clear();
    memset(goal1, 0, sizeof(goal1));
    vector<int> start1;
    REP(i, m1) {
      cin >> A[i] >> B[i] >> str1[i];
      if (A[i] == 0) start1.push_back(i);
      if (B[i] == n1-1) goal1[i] = 1;
      REP(j, i) {
        if (B[j] == A[i]) {
          g1[j].push_back(i);
        }
      }
    }
    cin >> n2 >> m2;
    REP(i, m2) g2[i].clear();
    memset(goal2, 0, sizeof(goal2));
    vector<int> start2;
    REP(i, m2) {
      cin >> A[i] >> B[i] >> str2[i];
      if (A[i] == 0) start2.push_back(i);
      if (B[i] == n2-1) goal2[i] = 1;
      REP(j, i) {
        if (B[j] == A[i]) {
          g2[j].push_back(i);
        }
      }
    }
    ll res = 0;
    memset(memo,-1,sizeof(memo));
    FOR(it, start1) {
      FOR(jt, start2) {
        res = (res + solve(*it,0,*jt,0)) % MOD;
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 9688
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int selection_sort(vector<int>& v, int length) {
    int count = 0;

    for (int i = 0; i < length; ++i) {
        int min_idx = i;
        for (int j = i; j < length; ++j) {
            if (v[min_idx] > v[j])
                min_idx = j;
        }
        if (i != min_idx) {
            swap(v[i], v[min_idx]);
            ++count;
        }
    }

    return count;
}

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

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

    int count = selection_sort(v, n);

    cout << v[0];
    for (int i = 1; i < n; ++i)
        cout << ' ' << v[i];
    cout << '\n';

    cout << count << '\n';
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

typedef long long ll;
struct unionfind{
	int par[100000];
	ll d[100000];
	void init(int n) { rep(i,n) par[i]=i,d[i]=0; }
	int find(int x){
		if(x==par[x]) return x;
		int r=find(par[x]);
		d[x]+=d[par[x]];
		return par[x]=r;
	}
	bool unite(int x,int y,int z){		//w[x]-w[y]=z	
		int rx=find(x),ry=find(y);
		if(rx==ry){
			return (d[x]-d[y]==z);
		}
		d[ry]=d[x]-d[y]-z;
		par[ry]=rx;
		return 1;
	}
	ll diff(int x,int y){		//w[x]-w[y]=?
		find(x),find(y);			//いる!!
		return d[x]-d[y];
	}
	bool same(int x,int y) { return find(x)==find(y); }
}UH,UW;
int H,W,N;
typedef pair<ll,ll> P;
const int MN=100000;
int rs[MN],cs[MN];
ll as[MN];
vector<P> rows[MN],cols[MN];
ll mnH[MN],mnW[MN];
ll inf=1e18;
bool solve(){
	cin>>H>>W>>N;
	UH.init(H);
	UW.init(W);
	rep(i,N){
		int r,c,a;
		scanf("%d%d%d",&r,&c,&a);
		r--,c--;
		rs[i]=r,cs[i]=c,as[i]=a;
		rows[r].pb(P(c,a));
		cols[c].pb(P(r,a));
	}
	rep(i,H){
		int K=rows[i].size();
		rep(j,K-1){
			P p=rows[i][j],q=rows[i][j+1];
			int a=p.fs,b=q.fs;
			ll dif=p.sc-q.sc;
			if(!UW.unite(a,b,dif)) return 0;
		}
	}
	rep(i,W){
		int K=cols[i].size();
		rep(j,K-1){
			P p=cols[i][j],q=cols[i][j+1];
			int a=p.fs,b=q.fs;
			ll dif=p.sc-q.sc;
			if(!UH.unite(a,b,dif)) return 0;
		}
	}
	rep(i,H) mnH[i]=inf;
	rep(i,W) mnW[i]=inf;
	rep(i,H){
		int r=UH.find(i);
		chmin(mnH[r],UH.diff(i,r));
	}
	rep(i,W){
		int r=UW.find(i);
		chmin(mnW[r],UW.diff(i,r));
	}
	rep(i,N){
		int r=rs[i],c=cs[i];
		ll a=as[i];
		ll inc=mnH[UH.find(r)]-UH.diff(r,UH.find(r)) + mnW[UW.find(c)]-UW.diff(c,UW.find(c));
		if(a+inc<0) return 0;
	}
	return 1;
}
int main(){
	if(solve()) puts("Yes");
	else puts("No");
}

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

int main() {
    int blue_num, red_num;
    vector<string> blue_cards, red_cards;
    cin >> blue_num;
    blue_cards = vector<string>(blue_num);
    for(int i = 0; i < blue_num; i++)
    {
        cin >> blue_cards.at(i);
    }
    cin >> red_num;
    red_cards = vector<string>(red_num);
    for(int i = 0; i < red_num; i++)
    {
        cin >> red_cards.at(i);
    }
    int max_score = 0;
    
    for(int i = 0; i < blue_num; i++)
    {
        int score = 0;
        for(int j = 0; j < blue_num; j++)
        {
            if(blue_cards.at(i) == blue_cards.at(j)){
                score += 1;
            }
        }
        for(int j = 0; j < red_num; j++)
        {
            if(blue_cards.at(i) == red_cards.at(j)){
                score -= 1;
            }
        }
        if(max_score < score){
            max_score = score;
        }
    
    }
    cout << max_score << endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int x[100000],a,i=0,j;

	while(1){
		scanf("%d",&a);
			if(a==0)
				break;
		x[i]=a;
		i++;
	}
	for(j=0;j<i;j++){
		printf("Case %d: %d\n",j+1,x[j]);
	}
	return 0;
}

Measured memory_bytes: 644
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t 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(int64_t 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) {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> frac, ifrac;
    combination(int n):frac(n+1), ifrac(n+1) {
        assert(n < mod);
        frac[0] = 1;
        for (int i = 1; i <= n; ++i) frac[i] = frac[i-1]*i;
        ifrac[n] = frac[n].inv();
        for (int i = n; i >= 1; --i) ifrac[i-1] = ifrac[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return frac[n]*ifrac[k]*ifrac[n-k];
    }
};

int main() {
    int n;
    cin >> n;
    vi aa, xxx(n);
    int kaburi = -1;
    rep(i, n+1) {
        int a;
        cin >> a;
        --a;
        aa.push_back(a);
        xxx[a]++;
        if(xxx[a] == 2) kaburi = a;
    }
  	combination c(n+1);

    int fi = -1, se;
    rep(i, n) {
        if(aa[i] == kaburi) {
            if(fi != -1) {
                se = n-i;
                break;
            } else fi = i;
        }
    }

    rep(i, n+1) {
      if(fi+se == 0) {
        cout << (!i?n:c(n+1, i+1).x) << endl;
    	continue;
    }
        cout << (!i?n:(c(n+1, i+1)-c(fi+se, i))) << endl;
    }
}

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

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

    string ans="";

    for(int i=0; i<str.size(); i++){
        if(str[i]=='0') ans+='0';
        if(str[i]=='1') ans+='1';
        if(str[i]=='B' and ans!="") ans.pop_back();
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, l, ans;
	bool neg = false, pos = false;
	scanf("%d %d", &n, &l);
	if (l > 0)
		pos = true;
	if (n + l - 1 < 0)
		neg = true;
	if (pos)
		ans = (n - 1) * ((2 * (l + 1)) + (n - 2)) / 2;
	else if (neg)
		ans = (n - 1) * ((2 * l) + (n - 2)) / 2;
	else
		ans = n * ((2 * l) + (n - 1)) / 2;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 1000000007
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }
ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128
ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}
ll inv(ll x){return power(x,MOD-2);}


void __sol(){
    
    int n,k; cin >> n >> k;
    int a[n+2]; memset(a,0,sizeof(a));
    forr(i,k){
        int d; cin >> d;
        forr(j,d){
            int p; cin >> p;
            a[p]++;
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(a[i]==0) ans++;
    }
    cout << ans;
}


int main(){
    fastio
    ll tc=1; //cin >> tc;
    while(tc--) __sol();
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric> // accumulate
#include <queue>
#include <string>
#include <cmath> // sqrt
#include <map>
#include <complex>
#include <set>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

vector<vector<int> > graph;

int memo[100010];

int rec(int v) {
    if (memo[v] != -1) return memo[v];
    int res = 0;
    for (auto nv: graph[v]) {
        res = max(res, rec(nv) + 1);
    }
    return memo[v] = res; 
}

int main() {
    int n, m;
    cin >> n >> m;
    graph.assign(n, vector<int>());
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        graph[x].push_back(y);
    }

    for (int v = 0; v < n; v++) memo[v] = -1;

    int res = 0;
    for (int v = 0; v < n; v++) {
        res = max(res, rec(v));
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,arr[105],kk=0,mn=INT_MAX;
     cin>>t;
     for(int i=0;i<t;i++)
     {
         cin>>arr[i];
     }
     for(int i=1;i<=100;i++)
     {
         for(int j=0;j<t;j++)
         {
             kk+=pow(arr[j]-i,2);
             //cout<<kk<<endl;
         }
         if(kk<mn)
            mn=kk;
         kk=0;
     }
     cout<<mn<<endl;
}


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

ll dp[101010], H[101010];

int main(){
  int N,K; cin>>N>>K;
  rep(i,N) cin>>H[i];
  fill(dp,dp+101010,1e15);
  dp[0]=0;
  rep(i,N) for(int j=1;j<=K;j++){
    dp[i+j]=min(dp[i+j],dp[i]+abs(H[i]-H[i+j]));
  }
  cout<<dp[N-1]<<endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] W = new int[N];
		for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		}
		
		int min = 20000;
		for(int i=0; i<N; i++) {
			int t =Math.abs(calcsum1(W,i) - calcsum2(W,i));
			if(t<min) {min = t;}
		}
		System.out.println(min);
		
		sc.close();
		
	}
	
	static int calcsum1(int[] W,int t) {
		int sum = 0;
		for(int i=0;i<=t; i++) {
			sum += W[i];
		}
		return sum;
	}
	
	static int calcsum2(int[] W,int t) {
		int sum = 0;
		for(int i=t+1;i<=W.length-1; i++) {
			sum += W[i];
		}
		return sum;
	}
	
	

}

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


void solve(long long N, std::vector<long long> A){
    double res = 0;
    for(int i=0;i<N;++i){
        res += 1.0/A[i];
    }
    cout<<setprecision(20)<<1.0 / res<<endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int r; cin >> r;
    
    cout << 3*r*r << endl;
}


Measured memory_bytes: 256
//int x=1;
//string yn[2] = { "Yes","No" };
//int x=1;
//string yn[2] = { "YES","NO" };
// string alp="abcdefghijklmnopqrstuvwxyz";
// string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//総和
/*
int t_sum(int x) {
int sum = 0;
while (x > 0) {
sum += x % 10;
x = x / 10;
}
return sum;
}
*/
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <regex>
#include <stack>
#include <queue>
#include <vector>
#include <iomanip>
#define MAX_N 100
#define INF 10000000

using namespace std;

string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int n,m,a,b;
int N[100];
string s,t;

void solve(){
	double e = INF;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int d;
		cin >> d;
		double c = m - d*0.006;
		if (e > abs(a - c)) {
			e = abs(a - c);
			ans = i;
		}
	}
	cout << ans+1 << endl;
}

int main() {
	cin >> n >> m>>a;
	solve();
	return 0;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    long long X;cin >> X;
    for(long long i = 1;i<=114514;i++){
        long long A = i;
        if((A*A+A)/2 >= X){
            cout << A << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d;
  cin>>d;
  if(d<=25)cout<<"Christmas";
  if(d<=24)cout<<" Eve";
  if(d<=23)cout<<" Eve";
  if(d<=22)cout<<" Eve";
  cout<<endl;
  return(0);
}


Measured memory_bytes: 256
h,w,k = map(int, input().split())
ptn = [1,1,2,3,5,8,13,21,34]
mod = 1000000007

dp = [[1]]
for ww in range(w-1):
  dp[0].append(0)

for hh in range(1,h+1):
  dp.append([])
  for ww in range(w):
    dp[hh].append(0)
#    print("[hh={}, ww={}]".format(hh,ww))
    if ww != 0:
      dp[hh][ww] += dp[hh-1][ww-1] * ptn[ww-1] * ptn[w-1-ww]
#      print("added from left {} {} {} ".format(dp[hh-1][ww-1], ptn[ww-1], ptn[w-1-ww]))
    dp[hh][ww] += dp[hh-1][ww] * ptn[ww] * ptn[w-1-ww]
#    print("added from above {} {} {} ".format(dp[hh-1][ww] , ptn[ww] , ptn[w-1-ww]))
    if ww != w-1:
      dp[hh][ww] += dp[hh-1][ww+1] * ptn[ww] * ptn[w-ww-2]
#      print("added from right {} {} {} ".format(dp[hh-1][ww+1] , ptn[ww],  ptn[w-ww-2]))
    dp[hh][ww] = dp[hh][ww] % mod
print(dp[-1][k-1])


Measured memory_bytes: 3064
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e6 + 10; 

int val[N];

inline int add(int a, int b, int mod = MOD) {
  a += b; return a >= mod ? a - mod : a;
}
inline int sub(int a, int b, int mod = MOD) {
  a -= b; return a < 0 ? a + mod : a;
}
inline int mul(int a, int b, int mod = MOD) {
  return int((long long) a * b % mod);
}
inline int power(int base, long long ex, int mod = MOD) {
  int res = 1;
  for (; ex > 0; ex >>= 1) {
    if (ex & 1) res = mul(res, base, mod);
    base = mul(base, base, mod);
  }
  return res;
}
inline int inv(int a, int mod = MOD) {
  return power(a, mod - 2, mod);
}
inline int mdiv(int a, int b, int mod = MOD) {
  return mul(a, power(b, mod - 2,  mod));
}
inline void adds(int &a, int b, int mod = MOD) {
  a += b; if (a >= mod) a -= mod;
}
inline void subs(int &a, int b, int mod = MOD) {
  a -= b; if (a < 0) a += mod;
}
inline void muls(int &a, int b, int mod = MOD) {
  a = int((long long) a * b % mod);
}
inline void mdivs(int &a, int b, int mod = MOD) {
  a = mdiv(a, b, mod);
}
vector<int> fact,ifact;
void prep_fact(int mx = 1e6 + 40) {
  fact.assign(mx,0);
  ifact.assign(mx,0);
  fact[0] = 1;
  for (int i = 1; i < mx; ++i) fact[i] = mul(i, fact[i - 1]);
  ifact[mx - 1] = inv(fact[mx - 1]);
  for (int i = mx - 1; i > 0; --i) ifact[i - 1] = mul(i, ifact[i]);
}
inline int ncr(int n, int r) {
  if (n < r || r < 0 || n < 0) return 0;
  return mul(fact[n], mul(ifact[n - r], ifact[r]));
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   val[0] = 1;
   f(i,1,N){
      int b = __builtin_popcount(i);
      val[i] = val[i%b]+1;
   }
   string s;
   cin >> s;
   int cnt = count(all(s),'1');
   debug(cnt);
   if(cnt == 0){
      int sm = 0;
      f(i,0,n){
         cout << "1\n";
      }
   }else if(cnt == 1){
      int sm = 0;
      f(i,0,n){
         if(s[i] == '1'){
            sm = power(2,n-i-1,2);
         }
      }
      f(i,0,n){
         if(s[i] == '0'){
            int v = power(2,n-i-1,2);
            adds(sm,v);
            cout << val[sm] << '\n';
            subs(sm,v);
         }else{
            cout << "0\n";
         }
      }
   }else{
      int ff = 0, ss = 0;
      f(i,0,n){
         if(s[i] == '1'){
            adds(ff,power(2,n-i-1,cnt+1),cnt+1);
            adds(ss,power(2,n-i-1,cnt-1),cnt-1);
         }
      }
      f(i,0,n){
         if(s[i] == '0'){
            int v = power(2,n-i-1,cnt+1);
            adds(ff,v,cnt+1);
            cout << val[ff] << '\n';
            subs(ff,v,cnt+1);
         }else{
            int v = power(2,n-i-1,cnt-1);
            subs(ss,v,cnt-1);
            cout << val[ss] << '\n';
            adds(ss,v,cnt-1);
         }
      }
   }
   return 0;
} 

Measured memory_bytes: 11580
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		WriteLine(Solve(I[0], I[1]).ToList()[I[2] - 1]);
	}
	IEnumerable<int> Solve(int A, int B)
	{
		for (var i = Max(A, B); i >= 1; i--) if (A % i == 0 && B % i == 0) yield return i;
	}
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int x;
    cin>>x;
    int r = lcm(360, x);
    cout<<r/x<<endl;
    return 0;
}

Measured memory_bytes: 3536
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val l = sc.nextInt()
  val r = sc.nextInt()
  val d = sc.nextInt()

  var count = 0
  for (i in l..r) {
    if (i % d == 0) count++
  }

  println(count)
}


Measured memory_bytes: 36364
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c,k=parseMap(split(readline()))
    if abs(a-b)>10^18
        println("Unfair")
    elseif k%2==0
        println(a-b)
    else
        println(b-a)
    end
end
main()

Measured memory_bytes: 168040
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        k: i64,
        x: i64,
        y: i64,
    }

    let mut a = x.abs();
    let mut b = y.abs();
    if a < b {
        std::mem::swap(&mut a, &mut b);
    }

    if (a+b)%2 == 1 && k%2 == 0 {
        println!("-1");
        return;
    }

    let mut res = vec![];
    if a+b == k {
        res.push((a,b));
    } else if (a+b)%2 == 1 && a+b < k {
        let t = (k+a-b)/2;
        res.push((a, -(k-a)));
        res.push((a+t, a-t));
        res.push((a, b));
    } else {
        let n;
        if a+b < k {
            n = 2;
        } else if ((k - (a+b)%k)%k)%2 == 0 {
            n = (a+b+k-1)/k;
        } else {
            n = (a+b+k-1)/k + 1;
        }

        let mut x = 0;
        let mut y = 0;
        while (y-k).abs() < (k*n-a-b).abs()/2 {
            y -= k;
            res.push((x,y));
        }
        x += k - ((k*n-a-b).abs()/2 - y.abs());
        y = -(k*n-a-b).abs()/2;
        res.push((x,y));
        while x + k < a {
            x += k;
            res.push((x,y));
        }
        y += k - (a-x);
        x = a;
        res.push((x,y));
        while y < b {
            y += k;
            res.push((x,y));
        }
    }

    println!("{}", res.len());
    for (mut a, mut b) in res {
        if x.abs() < y.abs() {
            std::mem::swap(&mut a, &mut b);
        }
        if x < 0 {
            a = -a;
        }
        if y < 0 {
            b = -b;
        }
        println!("{} {}", a, b);
    }
}


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

const int INF = 1e8;

const int MAX_V = 105;
const int MAX_C = 10005;

struct Edge{
    int to, cost;
};

int M[MAX_V][MAX_V];

bool C(int n, int low, int high){
    bool used[MAX_V] = {0};
    queue<int> q; //?¨??????????????????\??????

    q.push(0);
    used[0] = true;

    int u, cnt = 1;
    while(!q.empty()){
        u = q.front(); q.pop();
        rep(v,n){
            if(M[u][v] >= low && M[u][v] <= high && used[v] == false){
                used[v] = true;
                cnt++;
                q.push(v);
            }
        }
    }
    return n == cnt;
}

int binarySearch(int n, int low, int &ans){
    int right = MAX_C, left = low;
    rep(i,20){
        int mid = (right + left) / 2;
        if(C(n,low,mid)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){
    int n, m;
    while(cin >> n >> m, n){
        memset(M, -1, sizeof(M));
        vector<int> v;
        rep(i,m){
            int a, b, w;
            cin >> a >> b >> w;
            a--; b--;
            M[a][b] = M[b][a] = w;
            v.emplace_back(w);
        }
        sort(all(v));

        int ans = INF;
        rep(i,v.size()){
            int high = binarySearch(n,v[i],ans);
            if(C(n,v[i],high)) ans = min(ans, high - v[i]);
            else break;
        }

        //int ans = INF;
        cout << (ans == INF ? -1 : ans) << endl;
    }
}

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


void solve(long long N, long long K){
    cout<<N-K+1<<endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	long double a, b;
	cin >> a >> b;
	cout << setprecision(10) << fixed << a / b << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main () {
    
    int f[4][4] = {{0}, {0}, {0}, {0}};
    int a, b, c;
    
    scanf("%d%d%d", &f[1][1] ,&f[1][2], &f[2][2]);
    
    a = f[2][2] * 3;
    
    f[1][3] = a - f[1][1] - f[1][2];
    f[3][1] = a - f[1][3] - f[2][2];
    f[3][3] = a - f[1][1] - f[2][2];
    f[2][1] = a - f[1][1] - f[3][1];
    f[2][3] = a - f[2][1] - f[2][2];
    f[3][2] = a - f[1][2] - f[2][2];
    
    for(int i = 1; i < 4; i ++ ) {
        for(int j = 1; j < 4; j ++ )
            printf("%d ",f[i][j]);
        printf("\n");
    }
    
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<double> x(n);
    vector<string> u(n);
    rep(i,n) cin >> x[i] >> u[i];
    int sum_jpy = 0;
    double sum_btc = 0;
    rep(i,n){
        if(u[i] == "JPY") sum_jpy += x[i];
        else sum_btc += x[i];
    }

    double ans = sum_jpy + 380000*sum_btc;

    cout << fixed << setprecision(10);
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
class aoj
{
    static void Main()
    {
        while (true)
        {
            string a = Console.ReadLine();
            if (String.IsNullOrEmpty(a)) break;
            int b = int.Parse(a);
            int c = 2;
            for(int i = 2; i<=b; i++)
            {
                c += i;
            }
            Console.WriteLine(c);
        }
    }
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<pair<int, int>> d(n);
  int cnt = 0;
  bool ok = false;
  rep(i,n){
    cin >> d[i].first >> d[i].second;
    if(d[i].first == d[i].second) cnt++;
    else cnt = 0;
    if(cnt == 3) ok = true;
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3652