akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void){
    int m,f,r;
    for(;;){
        scanf("%d %d %d\n",&m,&f,&r);
        if(m==-1&&f==-1&&r==-1) break;
        if(m==-1||f==-1){
            printf("F\n");
            continue;
        }
        if(m+f>=80) printf("A\n");
        if(m+f>=65&&m+f<80) printf("B\n");
        if(m+f>=50&&m+f<65) printf("C\n");
        if(m+f>=30&&m+f<50){
            if(r>=50) printf("C\n");
            else printf("D\n");
        }
        if(m+f<30) printf("F\n");
    }
    return 0;
}


Measured memory_bytes: 1804
fn main(){
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let n: usize = s.trim().parse().unwrap();
	let mut max = -1;
	let mut min = 10;
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let v: Vec<&str> = s.trim().split(' ').collect();
	for i in 0..n {
		let n = v[i].parse().unwrap();
		if i == 0 {
			max = n;
			min = n;
		} else {
			if n > max {
				max = n;
			}
			if n < min {
				min = n;
			}
		}
	}
	println!("{}", if max - min > 0 {
		max - min
	} else {
		(max - min) * - 1
	});
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n =  Integer.parseInt(sc.next());
		int d[] = new int[n];
				
				
		for (int i = 0 ; i < n ; i++) {
			d[i] = Integer.parseInt(sc.next());
		}
		
		
		int ans = 0;
		for(int i = 0 ; i < n - 1 ; i++) {
			for (int j = i + 1 ; j < n ; j++) {
				ans += d[i] * d[j];
				
			}
		}
		
		System.out.println(ans);
		
		
	}
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef pair<ll,P>  PP;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;
typedef priority_queue<PP, vector<PP>, greater<PP>> PPQueue;

#define fi          first
#define se          second
#define sfi         se.fi
#define sse         se.se
#define pb          push_back
#define INF         INT_MAX
#define MOD         1000000007
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     (upper_bound(all(x),y)-x.begin())
#define lb(x,y)     (lower_bound(all(x),y)-x.begin())
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)

int main(){
  cin.sync_with_stdio(false);
  ll n, a, b;
  cin >> n >> a >> b;
  Vector x(n);
  rep(i,n)cin >> x[i];
  ll sum = 0;
  rep(i,n-1){
    ll ta = (x[i+1] - x[i])*a;
    sum += ta >= b ? b : ta;
  }
  cout << sum << endl;
}


Measured memory_bytes: 1024
A, B, C, K = map(int, input().split())

if A >= K:
    print(K)
elif (A + B) >= K:
    if(A > K):
        print(K)
    else:
        print(A)
elif (A + B + C) >= K:
    if (A + B) > K:
        print(K)
    else:
        print(A - (K - (A + B)))
else:
    print(0)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int)x.size())
int n,a,b;
int BC(int x){
	int w=0;ref(i,0,n-1)w^=(x>>i&1);return w;
}
typedef vector<int> vint;
vint solve(int a,int b,int n){
	if(n==1){vint s;s.pb(a);s.pb(b);return s;}
	int p=0;
	ref(i,0,n-1)if((a>>i&1)!=(b>>i&1))p=i;
	int aa=a%(1<<p)+((a>>p+1)<<p);
	int bb=b%(1<<p)+((b>>p+1)<<p);
	vint A=solve(aa,aa^1,n-1);
	vint B=solve(aa^1,bb,n-1);
	vint C;
	ref(i,0,SZ(A)-1)C.pb(A[i]%(1<<p)+((A[i]>>p)<<p+1)+((a>>p&1)<<p));
	ref(i,0,SZ(B)-1)C.pb(B[i]%(1<<p)+((B[i]>>p)<<p+1)+((b>>p&1)<<p));
	return C;
}
int main(){
	cin>>n>>a>>b;
	if(BC(a)==BC(b)){puts("NO");return 0;}
	vint ans=solve(a,b,n);
	puts("YES");
	ref(i,0,SZ(ans)-1)cout<<ans[i]<<" ";cout<<endl;
}

Measured memory_bytes: 1628
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

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

    vector <bool> check(10, false);
    int num;
    for(int i = 0; i < n; i ++)
    {
    	cin >> num;
    	check[num] = true;
    }

    for(int i = n; i <= 10*n; i ++)
    {
    	int curr = i;
    	while(curr > 0)
    	{
    		int dig = curr % 10;
    		if(check[dig] == true)
    			break;
    		curr = curr / 10;
    	}

    	if(curr == 0)
    	{
    		cout << i << endl;
    		break;
    	}
    }
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int k=1;
  int ans=0;
  bool t=false;
  for(int i=0;i<1e6;i++){
    k=a[k-1];
    ans++;
    if(k==2){
      t=true;
      break;
    }
  }
  cout << (t?ans:-1) << endl;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	n := len(s)
	ans := 0
	for i := 0; i < n/2; i++ {
		if s[i] != s[n-1-i] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
n, m=map(int, input().split())
lst=[None]*m
for i in range(m):
    lst[i]=tuple(map(int, input().split()))

left=max([el[0] for el in lst])
right=min([el[1] for el in lst])
if left<=right:
    print(right-left+1)
else:
    print(0)

Measured memory_bytes: 59736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int max_num = max({a, b, c});
    int ans = 0;
    while(1) {
        if ( max_num == a ) {
            if ( a == b || a == c ) break;
            ++ans, ++b, ++c;
        }
        else if ( max_num == b ) {
            if ( b == a || b == c ) break;
            ++ans, ++a, ++c;
        }
        else if ( max_num == c ) {
            if ( c == a || c == a ) break;
            ++ans, ++b, ++a;
        }
    }
    int min_num = min({a, b, c});
    if ( a == min_num ) {
        if ( ( b - min_num ) & 1 ) {
            ans += ( b - min_num + 1 ) / 2 + 1;
        }
        else {
            ans += ( b - min_num ) / 2;
        }
    }
    else if ( b == min_num ) {
        if ( ( a - min_num ) & 1 ) {
            ans += ( a - min_num + 1 ) / 2 + 1;
        }
        else {
            ans += ( a - min_num ) / 2;
        }
    }
    else if ( c == min_num ) {
        if ( ( b - min_num ) & 1 ) {
            ans += ( b - min_num + 1 ) / 2 + 1;
        }
        else {
            ans += ( b - min_num ) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}


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

struct Point { double x, y; };

struct Circle { Point center; double radius; };

double distance(const Point p, const Point q)
{
    const auto dx = p.x-q.x, dy = p.y-q.y;
    return sqrt(dx*dx + dy*dy);
}

double distance(const Circle a, const Circle b)
{
    const auto d = distance(a.center, b.center);
    return max(0.0, d - a.radius - b.radius);
}

int main()
{
    cout << setprecision(9) << fixed;

    Point start, finish;
    cin >> start.x >> start.y >> finish.x >> finish.y;

    int N; cin >> N;

    auto circles = vector<Circle>(N);
    for (auto& c : circles)
        cin >> c.center.x >> c.center.y >> c.radius;
    circles.push_back({start, 0});
    circles.push_back({finish, 0});

    const auto s = N, t = N+1;
    N += 2;

    auto distances = vector<double>(N, numeric_limits<double>::infinity());
    distances[s] = 0;

    auto candidates = vector<int>(N);
    iota(begin(candidates), end(candidates), 0);
    while (!candidates.empty())
    {
        const auto compare = [&](const int v, const int w) { return distances[v] < distances[w]; };
        const auto v = *min_element(begin(candidates), end(candidates), compare);
        candidates.erase(remove(begin(candidates), end(candidates), v), end(candidates));

        for (const auto w : candidates)
            distances[w] = min(distances[w], distances[v] + distance(circles[v], circles[w]));
    }

    cout << distances[t] << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  REP(i, n) cin >> v[i];
  vector<int> w;
  REP(i, n) {
    int ub = lower_bound(ALL(w), v[i]) - w.begin() - 1;
    if (ub < 0) {
      w.insert(w.begin(), v[i]);
    } else {
      w[ub] = v[i];
    }
  }
  int ans = w.size();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

template<i64 M>
struct modint {
  i64 a;
  constexpr modint(const i64 x = 0) noexcept: a((x % M + M) % M) {}
  constexpr i64 value() const noexcept { return a; }
  constexpr modint pow(i64 r) const noexcept {
    modint ans(1);
    modint aa = *this;
    while(r) {
      if(r & 1) {
        ans *= aa;
      }
      aa *= aa;
      r >>= 1;
    }
    return ans;
  }
  constexpr modint& operator+=(const modint r) noexcept {
    a += r.a;
    if(a >= M) a -= M;
    return *this;
  }
  constexpr modint& operator=(const i64 r) {
    a = (r % M + M) % M;
    return *this;
  }
  constexpr modint& operator-=(const modint r) noexcept {
    a -= r.a;
    if(a < 0) a += M;
    return *this;
  }
  constexpr modint& operator*=(const modint r) noexcept {
    a = a * r.a % M;
    return *this;
  }
  constexpr modint& operator/=(modint r) noexcept {
    i64 ex = M - 2;
    while(ex) {
      if(ex & 1) {
        *this *= r;
      }
      r *= r;
      ex >>= 1;
    }
    return *this;
  }

  constexpr modint operator+(const modint r) const {
    return modint(*this) += r;
  }
  constexpr modint operator-(const modint r) const {
    return modint(*this) -= r;
  }
  constexpr modint operator*(const modint r) const {
    return modint(*this) *= r;
  }
  constexpr modint operator/(const modint r) const {
    return modint(*this) /= r;
  }
};

using fp = modint<(i64)(1e9 + 7)>;

int main() {
  string L;
  cin >> L;
  i64 N = L.size();
  vector<fp> tri(101010);
  vector<fp> bit(101010);
  tri[0] = fp(1);
  bit[0] = fp(1);
  rep(i,1,101010) tri[i] = tri[i - 1] * fp(3);
  rep(i,1,101010) bit[i] = bit[i - 1] * fp(2);

  i64 cnt = 0;
  fp ans = fp(0);
  rep(i,0,N) {
    if(L[i] == '1') {
      ans += tri[N - 1 - i] * bit[cnt];
      cnt++;
    }
  }
  cout << (ans + bit[cnt]).value() << endl;
}


Measured memory_bytes: 2176
import math
n = int(input())
k = int(math.log10(n))
ans = 0
if k % 2 == 1:
    for i in range(k):
        if i % 2 == 0:
            ans += 10 ** (i+1) - 10 ** i
    print(ans)
else:
    for i in range(k-1):
        if i % 2 == 0:
            ans += 10 ** (i+1) - 10 ** i
    ans += n - 10 ** k + 1
    print(ans)


Measured memory_bytes: 3060
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,6);
  var output = [];
  var mae = "";
  var tmp = "";
  for(var i = 0; i < input.length; i++){
    tmp += input[i];
    if(mae === tmp){
       continue;
    }
    
      output.push(tmp);
      mae = tmp;
      tmp = "";
    
  }
  myerr(output);
  myout(output.length);
}
Main(myin());

Measured memory_bytes: 80684
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, m, a, b;
    cin >> n >> m;
    vector<int> ball(n, 1);
    vector<int> red(n, 0);
    red[0] = 1;
    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        if (red[a-1] == 1) {
            red[b-1] = 1;
            if (ball[a-1] == 1)
                red[a-1] = 0;
        }
        ball[a-1] -= 1;
        ball[b-1] += 1;
    }
    cout << accumulate(red.begin(), red.end(), 0) << endl; 
    return 0;
}


Measured memory_bytes: 3920
#include<iostream>
using namespace std;
int main(){
  char g;
  double len[11],total=0;
  double train1,train2;
  double a;
  while(1){
    total=0;
    for(int i=0;i<10;i++){
      cin >> len[i] >> g;
      total+=len[i];
    }
    cin >> train1 >> g >> train2;
    if(cin.eof()) break;
    a=total/(train1+train2);
    a*=train1;
    total=0;
    int i=0;
    while(a>total){
      total+=len[i];
      i++;
    }
    cout << i << endl;
  }
}

Measured memory_bytes: 1224
#include <cstdio>
#include <map>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long int64;
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())

map<int64, int> sum_cnt;
int n, x;

int main() {
	scanf("%d", &n);
	int64 sum = 0, ans = 0;
	sum_cnt[0]++;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &x);
		sum += x;
		ans += sum_cnt[sum];
		sum_cnt[sum]++;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 12800
/* atcoder */
#include "bits/stdc++.h"
using namespace std;

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* main */
void Main(void)
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    int U, D, R, L;
    U = y + r;
    D = y - r;
    R = x + r;
    L = x - r;
    if (U <= h && 0 <= D && R <= w && 0 <= L)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}



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

int main() {
  long long int a, b, c, k, ans = 0;

  cin >> a >> b >> c >> k;
  if (a <= k) {
    ans += a;
    k -= a;
  } else {
    ans += k;
    k = 0;
  }
  if (b <= k) {
    k -= b;
  }
  if (c <= k) {
    ans -= c;
  } else {
    ans -= k;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3564
N = int(input())
H = [int(i) for i in input().split()]

dp = [0]*N
dp[1] = abs(H[0]-H[1])
for i in range(2,N):
  dp[i] = min(dp[i-2]+abs(H[i]-H[i-2]),dp[i-1]+abs(H[i]-H[i-1]))
print(dp[-1])

Measured memory_bytes: 52208
# 2019-11-24 20:59:47(JST)
import sys

def main():
    n = int(sys.stdin.readline().rstrip())
    m = map(int, sys.stdin.read().split())
    ab = list(zip(m, m))

    graph = [[] for _ in range(n + 1)]
    for a, b in ab:
        graph[a].append(b)
        graph[b].append(a)

    root = 1
    parent = [0] * (n + 1)
    order = []
    stack = [root]

    while stack:
        x = stack.pop()
        order.append(x)
        for y in graph[x]:
            if y == parent[x]:
                continue
            parent[y] = x
            stack.append(y)

    color = [-1] * (n + 1)
    for x in order:
        ng = color[x]
        c = 1
        for y in graph[x]:
            if y == parent[x]:
                continue
            if c == ng:
                c += 1
            color[y] = c
            c += 1

    res = []
    for a, b in ab:
        if parent[a] == b:
            res.append(color[a])
        else:
            res.append(color[b])

    print(max(res))
    print('\n'.join(map(str, res)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38204
a1=3.times.map{gets.split.map(&:to_i)}
#puts a1.inspect
a2=a1.flatten
a3=a2.zip(a2.size.times.map{false}).to_h
n=gets.to_i
n.times do
  a3[gets.to_i]=true
end
=begin
a3[60]=true
a3[92]=true
a3[73]=true
puts a3

r1=[true,true,true,false,false,false,false,false,false]
r2=[true,false,false,true,false,false,true,false,false]
r3=[true,false,false,false,true,false,false,false,true]
r4=[false,true,false,false,true,false,false,true,false]
r5=[false,false,true,false,false,true,false,false,true]
r6=[false,false,false,true,true,true,false,false,false]
r7=[false,false,false,false,false,false,true,true,true]
r8=[false,false,true,false,true,false,true,false,false]
=end
#puts a3
res='No'
hv=a3.values
if hv[0]==true
  res='Yes' if (hv[1]==true && hv[2]==true) || (hv[3]==true && hv[6]==true) || (hv[4]==true && hv[8]==true)
end
if hv[1]==true
  res='Yes' if (hv[4]==true && hv[7]==true)
end
if hv[2]==true
  res='Yes' if (hv[5]==true && hv[8]==true) || (hv[4]==true && hv[6]==true)
end
if hv[3]==true
  res='Yes' if (hv[4]==true && hv[5]==true)
end
if hv[6]==true
  res='Yes' if (hv[7]==true && hv[8]==true)
end
puts res

Measured memory_bytes: 1788
import scala.io.StdIn.{readInt, readLine}

object Main extends App {
  val n = readInt
  val dllist = new DoublyLinkedList()
  for (i <- 1 to n) {
    val cmd = readLine().split(" ")
    cmd(0) match {
      case "insert" => dllist.insert(cmd(1).toInt)
      case "delete" => dllist.delete(cmd(1).toInt)
      case "deleteFirst" => dllist.deleteFirst
      case "deleteLast" => dllist.deleteLast
    }
  }
  dllist.printStr()

  class DoublyLinkedList {

    class Node(v: Int) {
      val value: Int = v
      var prev: Node = null
      var next: Node = null
    }

    var head: Node = null
    var tail: Node = null

    def insert(x: Int): Unit = {
      val newNode = new Node(x)
      if (head == null) {
        tail = newNode
      } else {
        head.prev = newNode
      }
      newNode.next = head
      head = newNode
    }

    def search(x: Int): (Node, Node) = {
      var current = head
      var prev: Node = null
      while (current != null) {
        if (current.value == x) {
          return (prev, current)
        }
        prev = current
        current = current.next
      }
      (null, null)
    }

    def delete(x: Int): Unit = {
      val (prev, found) = search(x)
      if (found == head) {
        deleteFirst
      } else if (found == tail) {
        deleteLast
      } else if (found != null) {
        prev.next = found.next
        if (found.next != null) {
          found.next.prev = prev
        }
      }
    }

    def deleteLast: Unit = {
      if (head == tail) {
        head = null
        tail = null
      } else {
        tail.prev.next = null
        tail = tail.prev
      }
    }

    def deleteFirst: Unit = {
      if (head == tail) {
        head = null
        tail = null
      } else {
        head.next.prev = null
        head = head.next
      }
    }

    def printStr(): Unit = {
      var current = head
      val sb = new StringBuilder().append(current.value)
      current = current.next
      while (current != null) {
        sb.append(" ").append(current.value)
        current = current.next
      }
      println(sb)
    }
  }

}



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

int euclid(int n, int m) {
  int q = min(n, m), p = max(n, m);
  if (q <= 0)
    return p;
  else
    euclid(q, p % q);
}
int main() {
  int i, j, k, a, b; cin >> a >> b;
  string s, t;
  ll g = euclid(a, b);
  ll ans = g * (a / g) * (b / g);
  cout << ans << endl;

  return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,s; cin >> n >> s;
    ll mod = 998244353;
    vvl dp(n+1,vl(s+1));
    dp[0][0] = 1;
    vl a(n);
    rep(i,n)cin>>a[i];

    rep(i,n){
        rep(j,s+1){ 
            dp[i+1][j] += dp[i][j]*2 % mod;
            if(j - a[i] >= 0)dp[i+1][j] += dp[i][j - a[i]];
            dp[i+1][j] %= mod;
        }
    }
    out(dp[n][s]);
}


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

using namespace std;
int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int cnt = 0;
    for(int i= 0;i<n-1;i++){
        if(s[i] == 'A' && s[i+1] == 'B'){
            if(s[i+2] == 'C'){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	int cur=0,ans=-1;
	rep(loop,4000){
		if(ans!=-1) break;
		int s=cur%60,t=(cur+a)%60;
		if(s<t&&s<=c&&c<=t) ans=cur+(c-s);
		if(t<s&&(s<=c||c<=t)) ans=cur+((s<=c)?(c-s):(60+c-s));
		cur+=a+b;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#include <bits/stdc++.h>
using namespace std;

int n,m,q;
vector<int>a,b,c,d;

int dfs(vector<int>& A) {
	if(A.size() == n) {
		int tmp = 0;
		rep(i,q) {
			if(A[b[i]]-A[a[i]] == c[i]) tmp += d[i];
		}
		return tmp;
	}
	int ans = 0;
	int prev_int = (A.empty() ? 1 : A.back());
	for(int i = prev_int;i<=m;i++) {
		A.push_back(i);
		ans = max(ans,dfs(A));
		A.pop_back();
	}
	return ans;
}

int main() {
	cin >> n >> m >> q;
	a.resize(q);
	b.resize(q);
	c.resize(q);
	d.resize(q);
	rep(i,q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--;b[i]--;
	}
	vector<int>A;
	cout << dfs(A) << endl;
}


Measured memory_bytes: 3604
import sys
sys.setrecursionlimit(10000)


class Node:

    def __init__(self, _id):
        self.id = _id
        self.children = []
        self.parent = None
        self.__depth = 0
    
    def add(self, node):
        node.parent = self
        self.children.append(node)

    def parent_id(self):
        if self.parent is None:
            return -1
        else:
            return self.parent.id

    def node_type(self):
        if self.parent is None:
            return 'root'
        elif len(self.children) == 0:
            return 'leaf'
        else:
            return 'internal node'

    def children_ids(self):
        return list(map(lambda n: n.id, self.children))

    def depth(self):
        if self.parent is None:
            return 0
        else:
            return self.parent.depth() + 1

    def __repr__(self):
        return 'node {}: parent = {}, depth = {}, {}, {}'.format(
            self.id, self.parent_id(), self.depth(), self.node_type(), self.children_ids())


def main():
    n = int(input())
    nodes = [Node(i) for i in range(n)]
    for _ in range(n):
        ID, _, *c_s = map(int, input().split(' '))
        for c in c_s:
            nodes[ID].add(nodes[c])
    for n in nodes:
        print(n)


if __name__ == '__main__':
    main()



Measured memory_bytes: 43168
#include<iostream>
#include<string>
#include <stdio.h>
#include <math.h>
#include <cctype>
#include<queue>
#include<stack>
#include<cstdio>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(){
	string s;
	getline(cin,s);
	for(int i=0;i<=s.size();i++){
			s[i]=toupper(s[i]);
		}
		cout<<s<<endl;
		return 0;
}

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

long long gcd(long long a,long long b)
    {long long t;if(a>b)t=a,a=b,b=t;while(a)t=a,a=b%a,b=t;return b;}
long long lcm(long long a,long long b){return a*b/gcd(a,b);}

int main()
{
	long long a,b;
	while(cin>>a>>b)
	{
		cout << gcd(a,b)<< " " <<lcm(a,b) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize ("-O3")
#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
ll NUM = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define zer ll(0)
 

int main()
{
    
    ll n, m;

    cin>>n>>m;

    ll pen=0,ac=0;
    v64 v(n,0);

    forn(i,m)
    {   
        ll a;
        string b;
        cin>>a>>b;
        a-=1;

        if(b=="WA")
        {
            v[a]+=1;
        }
        else if(b=="AC" && v[a]>=0)
        {
            pen += v[a];
            ac+=1;
            v[a]=-9999999;
        }

    }
    cout<<ac<<' '<<pen;
    
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int n,d[200000],i,j;
    while(~scanf("%d",&n))
    {
        int acm=0;
        for(i=1;i<=n;i++)
            scanf("%d",&d[i]);
        sort(d+1,d+n+1);
        if(n%2!=0||d[n/2]==d[n/2+1])
            acm=0;
        else
            acm+=d[n/2+1]-d[n/2];
        printf("%d\n",acm);
    }
    return 0;
}


Measured memory_bytes: 512
s = str(input())
t = str(input())

# pad a character to the first because i want to count index from 1
s = "." + s; t = "." + t;

a = len(s)
b = len(t)

dp = [['']*(b) for _ in range(2)]
# dp[i][j] is the length of lcs of s[0]s[1]...s[i] and t[0]t[1]...t[j]

for i in range(1, a):
    for j in range(1, b):
        if s[i] == t[j]:
            if len(dp[i&1][j]) < len(dp[(i+1)&1][j-1]) + 1:
                dp[i&1][j] = dp[(i+1)&1][j-1] + s[i]
        else:
            for adja in [[i-1, j-1], [i-1, j], [i, j-1]]:
                if len(dp[i&1][j]) < len(dp[adja[0]&1][adja[1]]):
                    dp[i&1][j] = dp[adja[0]&1][adja[1]]

print(dp[(a+1)&1][b-1])


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

typedef long long LL;

const int mod=1000000007;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}
int Power(int a,int k,int p=mod){int res=1;for (;k;k>>=1,smul(a,a,p)) if (k&1) smul(res,a,p);return res;}

int n,m,t;

void into(){
  scanf("%d%d%d",&n,&m,&t);
}

int ans;

void Get_ans(){
  int n0=n/gcd(n,t),m0=m/gcd(m,t);
  sadd(ans,add(Power(2,n0),Power(2,m0)));
  sadd(ans,Power(2,gcd(n0,m0)));
  ssub(ans,3);
  ans=Power(ans,n/n0);
  ans=Power(ans,m/m0);
}

void work(){
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 3828
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
ll k,now=0,del=1,tot=0;
double s(ll x){
	ll sum=0,d=x;
	while(d){sum+=(d%10);d/=10;}
	return (double)x/(double)sum;
}
int main(){
	scanf("%lld",&k);
	while(tot<k){
		if((now/del)%10==9){
			if(s(now+del)>s(now+10*del))  del*=10;
		}
		now+=del;printf("%lld\n",now);tot++;
	}
	return 0;
}

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

const int INF=1000000009;

int main() {
  int n,m,l; cin>>n>>m>>l;
  vector<vector<int>> d1(n, vector<int>(n, INF));
  rep(i, n) d1[i][i]=0;
  rep(i, m) {
    int a,b,c; cin>>a>>b>>c;
    a--; b--;
    d1[a][b]=d1[b][a]=c;
  }
  rep(k, n) {
    rep(i, n) {
      rep(j, n) {
        d1[i][j]=min(d1[i][j], d1[i][k]+d1[k][j]);
      }
    }
  }
  vector<vector<int>> d2(n, vector<int>(n, INF));
  rep(i, n) {
    rep(j, n) {
      if (d1[i][j]<=l) d2[i][j]=1;
    }
  }
  rep(k, n) {
    rep(i, n) {
      rep(j, n) {
        d2[i][j]=min(d2[i][j], d2[i][k]+d2[k][j]);
      }
    }
  }
  int q; cin>>q;
  vector<int> ans(q);
  rep(i, q) {
    int s,t; cin>>s>>t;
    s--; t--;
    int tmp=d2[s][t]-1;
    if (d2[s][t]==INF) tmp=-1;
    ans[i]=tmp;
  }
  rep(i, q) cout<<ans[i]<<endl;
  return 0;
}


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

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

    int d = a / b;
    int r = a % b;
    double f = (double)a / (double)b;

    cout << d << " " << r << " ";
    printf("%.8f\n", f);
    return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
typedef long long ll;
typedef long double ld;
#define rep(i,a)  for(ll i=0; i< a; i++)
#define pb push_back
#define vl vector<ll>
#define trace(x)  cerr << #x << ": " << x << endl;
const ll N=1e5+5;
ll mp[9*N]={0};
int main()
{
	fast;
	ll x,k,d;cin>>x>>k>>d;x=abs(x);
	ll p=x%d;ll p1=p-d;
	ll final=min(p,abs(p1));
	if(final==p)
	{
		ll mink=(x-final)/d;
		if(mink<=k)
		{
			k-=mink;
			if(k&1)
			{
				cout<<abs(p1);return 0;
			}
			else {cout<<p;return 0;}
		}
		else
		{
			ll zz=x/d;zz-=k;zz*=d;zz+=p;cout<<zz<<"\n";
		}
	}
	else
	{
		ll mink=(x+final)/d;
		if(mink<=k)
		{
			k-=mink;
			if(k&1)
			{
				cout<<p;return 0;
			}
			else {cout<<final;return 0;}
		}
		else
		{
			ll zz=x/d;zz-=k;zz*=d;zz+=p;cout<<zz<<"\n";
		}
	}


}

Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
int mod = 998244353;
long double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998626034825342117;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
int main() {
    int N, K; cin >> N >> K;
    string S; cin >> S;
    int count = 0;
    for (int i = 1; i < N; i++) {
        if (S.at(i) == S.at(i - 1))count++;
    }
    cout << min(N - 1, count + K * 2) << endl;
}

Measured memory_bytes: 3768
#include "stdio.h"
int main(int argc, char const *argv[])
{
	int n,i,j,k,count;
	int a,b;
	char input[1001];
	char tmp[1001];
	char output[1001];

	char cmd[100];
	char cmd1[] = "print";
	char cmd2[] = "reverse";
	char cmd3[] = "replace";

	scanf("%s",input);
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",cmd);
		if(strcmp(cmd,cmd1) == 0){
			scanf("%d",&a);
			scanf("%d",&b);
			for(j=a;j<b+1;j++){
				printf("%c",input[j]);
			}
			printf("\n");
		}
		else if(strcmp(cmd,cmd2) == 0){
			scanf("%d",&a);
			scanf("%d",&b);
			for(j=a;j<b+1;j++){
				tmp[j] = input[j];
			}
			for(j=a;j<b+1;j++){
				input[j] = tmp[b-j+a];
			}
		}		
		else if(strcmp(cmd,cmd3) == 0){
			scanf("%d",&a);
			scanf("%d",&b);
			scanf("%s",tmp);
			for(j=a;j<b+1;j++){
				input[j] = tmp[j-a];
			}
		}

	}

return 0;
}


Measured memory_bytes: 584
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,t;
	ll res;
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		scanf("%d",&t);
		while(t>0&&t%2==0)
		{
			res++;t/=2;
		}
	}
	printf("%lld\n",res);
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int a,b;
    cin >> a >> b;
    if(a+b==15) cout << "+" << endl;
    else if(a*b==15) cout << "*" << endl;
    else cout << "x" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 892
#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 drep(i,n) for (int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i=s; i<t; ++i)
#define pi (acos(-1))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int, int> P;
const int INF = 1001001001;
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;
}
ll gcd (ll a, ll b) {
  return b ? gcd(b, a%b) : a;
}
ll lcm (ll a, ll b) {
  return a/gcd(a,b)*b;
}
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int n, x ,t;
	cin >> n >> x >> t;
	if (n % x != 0){
		cout << (n / x + 1) * t << endl;
	}
	else if (n % x == 0) {
		cout << (n / x) * t << endl;
	}
  return 0;
}




Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;

void solve(){
  ll n, x, l = 0, r, ans = 0; cin >> n >> x;
  x--;
  vector<ll> y(n + 1), sum(n + 1);
  y[0] = 1;
  sum[0] = 1;
  for(int i = 1; i <= n; i++){
    y[i] = y[i - 1] * 2 + 3;
    sum[i] = sum[i - 1] * 2 + 1;
  }
  r = y[n] - 1;
  for(int i = n; i >= 0; i--){
    ll mid = (l + r) / 2;
    if(x == mid){
      ans += sum[i] / 2 + 1;
      break;
    }
    if(x < mid){
      l++;
      r = mid - 1;
    }
    else{
      ans += sum[i] / 2 + 1;
      l = mid + 1;
      r--;
    }
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


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

typedef long long ll;

const long double PI = (acos(-1));

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

  int a, b;
  cin >> a >> b;

  int ans = 0;
  b--;
  while (b > 0){
    b -= a - 1;
    ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))
l1 = min(x)
l2 = max(x)
ans = 100000000
for i in range(l1, l2+1):
    sum = 0
    for j in x:
        sum += (i-j)**2
    if sum < ans:
        ans = sum
print(ans)

Measured memory_bytes: 3060
X = int(input())
Y = [i**5 for i in range(0, 501)]
for i in range(0, 501):
    for j in range(0, 501):
        if (Y[i]-Y[j] == X):
            print('{0} {1}'.format(i, j))
            exit(0)
        if (Y[i]+Y[j] == X):
            print('{0} {1}'.format(i, -j))
            exit(0)


Measured memory_bytes: 9192
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int l,a,b,c,d;
  cin>>l>>a>>b>>c>>d;
  int res = max(1.0*a/c+0.9,1.0*b/d+0.9);
  cout<<l-res<<endl;
  
}

Measured memory_bytes: 1160
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;

int main(){

  int n,m;
  int a[256][256],b[256];
  int ans[256]={0};
  int i,j;

  cin >>n >>m;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin >>a[i][j];
    }
  }
  for(i=0;i<m;i++){
    cin >>b[i];
  }

  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      ans[i]+=a[i][j]*b[j];
    }
  }

  for(i=0;i<n;i++)
    cout <<ans[i] <<endl;

  return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <map>
#include <algorithm>
#define P pair<int,int>
using namespace std;
int main(){
  int n,m, b;
  int a[1000];

  while( cin >> m >> n &&n ){
    for( int i=0;i<n;i++ )
      a[i] = 0;

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


    P p[m];
    for( int i=0;i<n;i++ ){
      p[i] = P(a[i], -(i+1) );
      //      cout << (i+1) << "\t" << a[i] << endl;
    }
    sort( p, p+n, greater<P>() );
    for( int i=0;i<n-1;i++ )
      cout << -p[i].second << " ";
    cout << -p[n-1].second << endl;
  }
}

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

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

  ll N; cin >> N;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
  auto MAX_e = max_element(A.begin(), A.end());
  auto MIN_e = min_element(A.begin(), A.end());
  ll MAX = 0;
  ll MIN = 0;
  for (ll i = 0; i < N; i++) {
    MAX = max(MAX, A[i]);
    MIN = min(MIN, A[i]);
  }

  cout << (2 * N - 1) << '\n';
  if (abs(*MAX_e) >= abs(*MIN_e)) {
    for (ll i = 0; i < N; i++) {
      cout << (MAX_e - A.begin() + 1) << " " << (i + 1) << '\n';
    }
    for (ll i = 0; i < N - 1; i++) {
      cout << (i + 1) << " " << (i + 2) << '\n';
    }
  } else {
    for (ll i = 0; i < N; i++) {
      cout << (MIN_e - A.begin() + 1) << " " << (i + 1) << '\n';
    }
    for (ll i = N - 2; i >= 0; i--) {
      cout << (i + 2) << " " << (i + 1) << '\n';
    }
  }
  return 0;
}

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

using namespace std;

int main() {

    string arr[3] = {"Sunny","Cloudy","Rainy"};
    string s;
    cin>>s;
    int x = find(arr,arr+3,s)-arr;
    cout<<arr[(x+1)%3]<<endl;



    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll A, B, C;
ll t;
ll ret = 0;

void input() {
  IN(A);
  IN(B);
  IN(C);
}

void solve() {
    ll res = A + B + C;
    if(res >= 22) {
        PRINT("bust");
    } else {
        PRINT("win");
    }
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
a,*s,g=input()
c=s.count
if a==g:
  if(len(s)-c(a)*2)%2:
    print('Second')
  else:
    print('First')
else:
  if(len(s)-max(c(a),c(g))*2)%2:
    print('First')
  else:
    print('Second')

Measured memory_bytes: 4084
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    int n; string s;
	cin >> n >> s;
	vi a(n);
	
	// a の中に 1 があるかどうか
	bool odd = false;
	
    rep(i, n){
        a[i] = s[i] - '0' - 1;
        if(a[i] == 1) odd = true;
    }
    
    // nCk の偶奇判定
    // lucasの定理から (n&k) == k
    int ans = 0;
    if(odd){
        rep(i, n){
            if(((n-1)&i) == i) ans ^= (a[i]&1);
        }
    }
    else{
        rep(i, n){
            a[i] /= 2;
        }
        rep(i, n){
            if(((n-1)&i) == i) ans ^= (a[i]&1);
        }
        ans *= 2;
    }
    
    cout << ans << endl;
    return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 5276
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1e9+7;

void solve()
{
	ll x;
	cin>>x;
	if(x>=30)
		cout<<"Yes";
	else
		cout<<"No";
	
	return;
}
int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}

Measured memory_bytes: 3648
s = input().split()
K = int(s[0])
A = int(s[1])
B = int(s[2])
 
bis = 1
 
if B-A >  2:
  change = 1
else:
  change = 0
 
if change == 0:
  bis = bis + K
else:
  i = A - 1
  bis  = A
  k = K - i
  bis += (k//2)*(B-A)
  bis += k %2
print(bis)

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

int n;
string str;
int ans = 0;
int dp[5][12][30002];

int slv(int keta,int num,int id){
	if(n==id)return(0);
	if(str[id] == num+'0'){
		keta++;
		if(keta==3)ans++;
		else{
			for(int i=0;i<10;i++){
				slv(keta,i,id+1);
			}
		}
	}
	else{
		slv(keta,num,id+1);
	}
	return(0);
}

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

	for(int i=0;i<5;i++){for(int j=0;j<12;j++){for(int k=0;k<30002;k++){dp[i][j][k]=-1;}}}
	for(int i=0;i<10;i++)slv(0,i,0);

	cout<<ans<<endl;


}

Measured memory_bytes: 8704
#include <iostream>

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

using namespace std;

int prim(int n)
{
	int cost[101][101];
	int mincost[101];
	int used[101] = {};
	int res = 0;

	rep(i,n)
	{
		mincost[i] = 1000000;
		rep(j,n)
		{
			cost[i][j] = 1000000;
		}
	}
	
	int m;
	cin >> m;

	rep(i,m)
	{
		int a,b,d;
		char c1,c2;
		cin >> a >> c1 >> b >> c2 >> d;
		cost[b][a] = cost[a][b] = d/100 -1;
	}

	mincost[0] = 0;
	while(true)
	{
		int  v = -1;
		rep(u,n)
		{
			if(!used[u] && (v == -1 || mincost[u] < mincost[v]))
			{
				v = u;
			}
		}

		if(v == -1) break;

		used[v] = 1;
		res += mincost[v];
		rep(i,n)
		{
			mincost[i] = min(mincost[i],cost[v][i]);
		}
	}

	return res;
}

int main()
{
	int n;
	while(cin >> n && n)
	{
		cout << prim(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <cstdio>

int main(void) {
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);

    bool flag=false;
    for(int i=0; i<=n; i++)
        for(int j=0; j<=m; j++)
            flag |= k == i*m + j*n - 2*i*j;
    puts(flag ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 128