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

int dp[100000] = {};

int main() {
  int N; cin >> N;
  int h[N]; for (int i=0; i<N; i++) cin >> h[i];
  for (int i=1; i<N; i++) {
    if (i==1) dp[1] = abs(h[1]-h[0]);
    else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[N-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int sx,sy,tx,ty,pos = 0;
	char ans[50000];
	scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
	for(int i=0;i<ty-sy;i++){
		ans[pos] = 'U';
		pos++;
	}
	for(int i=0;i<tx-sx;i++){
		ans[pos] = 'R';
		pos++;
	}
	for(int i=0;i<ty-sy;i++){
		ans[pos] = 'D';
		pos++;
	}
	for(int i=0;i<tx-sx;i++){
		ans[pos] = 'L';
		pos++;
	}
	ans[pos] = 'L';
	pos++;
	for(int i=0;i<ty-sy+1;i++){
		ans[pos] = 'U';
		pos++;
	}
	for(int i=0;i<tx-sx+1;i++){
		ans[pos] = 'R';
		pos++;
	}
	ans[pos] = 'D';
	pos++;
	ans[pos] = 'R';
	pos++;
	for(int i=0;i<ty-sy+1;i++){
		ans[pos] = 'D';
		pos++;
	}
	for(int i=0;i<tx-sx+1;i++){
		ans[pos] = 'L';
		pos++;
	}
	ans[pos] = 'U';
	pos++;
	ans[pos] = '\0';
	printf("%s\n",ans);
}


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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi pair<int, int>
#define pl pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define MOD ll(1000000007)

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

	ll i, n, j, t, m, x, y, z, k;

	ll ans=0;

	string s;
	cin>>s;

	for(auto ch:s)
		ans = (ans + ch - '0')%9;

	if(ans)
		cout<<"No";
	else
		cout<<"Yes";

	cout<<"\n";

	return 0;
}


Measured memory_bytes: 3780
x, n = map(int, input().split())
p = list(map(int, input().split()))
diff = []
y = [i for i in range(-1, 102) if i not in p]
for i in y:
  z = abs(x - i)
  diff.append(z)

if x - min(diff) not in p:
  print(x - min(diff))
else:
  print(x + min(diff))

Measured memory_bytes: 9192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int N,K,Q;
  cin>>N>>K>>Q;
  
  // 各人のスコア
  vector<int> score(N,K);
  
  // 各人の正解数
  vector<int> ok(N);
  
  vector<int> A(Q);
  rep(i,Q){
    cin>>A[i];
    ++ok[A[i]-1];
  }
  
  rep(i,N){
    score[i]+=ok[i];
  }
  
  rep(i,N){
    if(score[i]-Q>0)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
}


Measured memory_bytes: 1792
using System;
using System.IO;
using System.Linq;
 
namespace D
{
	internal class Program
	{
		static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
 
		public static void Main(string[] args)
		{
			var line = Console.ReadLine().Split().Select(ulong.Parse).ToArray();
			var n = line[0];
			var k = line[1];
			var an = Console.ReadLine().Split().Select(ulong.Parse).ToArray();
 
			var aMax = an.Max();
			var max = Math.Max(k, aMax);
			var tmp = 1UL;
			var maxDigits = 1UL;
			while (true)
			{
				tmp <<= 1;
 
				if (tmp > max) { break; }
 
				maxDigits++;
			}
 
			var mask = 1UL << (int) (maxDigits - 1);
			var result = 0UL;
 
			var x = 0UL;
			for (var i = 0UL; i < maxDigits; i++, mask >>= 1)
			{
				var zeroNum = 0UL;
				var oneNum = 0UL;
				foreach (var a in an)
				{
					if ((mask & a) != 0) { oneNum++; }
					else { zeroNum++; }
				}
 
				if ((x | (1UL << (int) (maxDigits - i - 1))) > k)
				{
					result += oneNum * (1UL << (int) (maxDigits - i - 1));
					continue;
				}
 
				var maxNum = Math.Max(zeroNum, oneNum);
				result += maxNum * (1UL << (int) (maxDigits - i - 1));
				if (zeroNum > oneNum) { x += 1UL << (int) (maxDigits - i - 1); }
			}
 
			Console.WriteLine(result);
		}
	}
}

Measured memory_bytes: 31324
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

struct OP
{
    int x, y;
    OP(int _x, int _y) : x(_x), y(_y) {};
    OP() {};
};

int N;
int a[51];
OP ops[101];

int main()
{
    cin >> N;
    cin >> a[1];
    int maxA = a[1];
    int maxI = 1;
    int minA = a[1];
    int minI = 1;
    for (int i = 2; i <= N; ++i)
    {
        cin >> a[i];
        if (maxA < a[i])
        {
            maxA = a[i];
            maxI = i;
        }
        if (minA > a[i])
        {
            minA = a[i];
            minI = i;
        }
    }

    int opnum = 0;
    if (minA < 0 && abs(maxA) < abs(minA))
    {
        for (int i = 1; i <= N; ++i)
        {
            if (i == minI) continue;
            ops[opnum] = OP(minI, i);
            ++opnum;
            a[i] += a[minI];
        }
        for (int i = N; i >= 2; --i)
        {
            ops[opnum] = OP(i, i-1);
            ++opnum;
            a[i-1] += a[i];
        }
    }
    else
    {
        for (int i = 1; i <= N; ++i)
        {
            if (i == maxI) continue;
            ops[opnum] = OP(maxI, i);
            ++opnum;
            a[i] += a[maxI];
        }
        for (int i = 1; i <= N-1; ++i)
        {
            ops[opnum] = OP(i, i+1);
            ++opnum;
            a[i+1] += a[i];
        }
    }

    cout << opnum << endl;
    for (int i = 0; i < opnum; ++i)
    {
        printf("%d %d\n", ops[i].x, ops[i].y);
    }

    return 0;
}


Measured memory_bytes: 256
// URL: https://atcoder.jp/contests/abc131/tasks/abc131_f

import std.algorithm, std.container, std.math, std.range, std.typecons, std.string;

version(unittest) {} else
void main()
{
  int n; io.getV(n);
  int[] x, y; io.getC(n, x, y); --x[]; --y[];

  const m = 10^^5;
  auto g = Graph(m*2);
  foreach (xi, yi; lockstep(x, y))
    g.addEdgeB(xi, yi+m);

  auto b = new bool[](m*2), r = 0L;
  foreach (u; 0..m) {
    if (b[u]) continue;

    b[u] = true;
    auto v = new g.Node[](0); v ~= u;
    auto s = DList!(g.Node)(); s.insertBack(u);

    while (!s.empty) {
      auto i = s.front; s.removeFront();
      foreach (j; g[i]) {
	if (b[j]) continue;
	b[j] = true;
	v ~= j;
	s.insertBack(j);
      }
    }
    if (v.length == 1) continue;

    auto vx = v.filter!(vi => vi < m).array;
    auto vxe = vx.map!(vxi => g[vxi].length).sum;
    r += vx.length * (v.length - vx.length) - vxe;
  }

  io.put(r);
}

struct Graph
{
  alias Node = int;
  Node n;
  Node[][] g;
  alias g this;
  this(Node n) { this.n = n; g = new Node[][](n); }
  void addEdge(Node u, Node v) { g[u] ~= v; }
  void addEdgeB(Node u, Node v) { g[u] ~= v; g[v] ~= u; }
}

auto io = IO();

struct IO
{
  import std.algorithm, std.conv, std.format, std.range, std.stdio, std.traits;

  dchar[] buf;
  auto sp = (new dchar[](0)).splitter;
  int precision = 10;
  string delimiter = " ";

  void nextLine()
  {
    stdin.readln(buf);
    sp = buf.splitter;
  }

  auto get(T)(ref T v)
  {
    if (sp.empty) nextLine();
    v = sp.front.to!T;
    sp.popFront();
  }

  auto getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }

  auto getA(T)(size_t n, ref T v)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }

  auto getC(T...)(size_t n, ref T v)
  {
    foreach (ref w; v)
      w = new typeof(w)(n);
    foreach (i; 0..n)
      foreach (ref w; v) get(w[i]);
  }

  auto getM(T)(size_t r, size_t c, T v)
  {
    v = new T(r, c);
    foreach (ref w; v) getA(c, w);
  }

  auto putA(T)(T v)
  {
    static if (isInputRange!T && hasLength!T && !isSomeString!T) {
      foreach (i, w; v) {
	putA(w);
	if (i < v.length - 1) write(delimiter);
      }
    } else if (isFloatingPoint!T) {
      writef(format("%%.%df", precision), v);
    } else {
      write(v);
    }
  }

  auto put(T...)(T v)
  {
    foreach (i, w; v) {
      putA(w);
      if (i < v.length - 1) write(delimiter);
    }
    writeln;
  }

  auto putB(S, T)(bool c, S t, T f)
  {
    if (c)
      put(t);
    else
      put(f);
  }

  auto dbg(T...)(T v)
  {
    stderr.writeln(v);
  }
}


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

int main()
{
  long N, K;
  cin >> N >> K;

  long cnt = (K % 2 == 1 ? N/K : N/(K/2));

  if (K % 2 == 0) {
    long n1 = cnt/2;
    long n2 = cnt - n1;
    cout << n1*n1*n1 + n2*n2*n2 << endl;
  } else {
    cout << cnt*cnt*cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  if ((b-a)%2 == 0) cout << (b-a) / 2 << endl;
  else cout << (min(b-1, n-a) - (b-a)/2) << endl;
}

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

using namespace std;

#define FOR(i,l,r) for( int i = l; i < r; i++ )
#define li long long int

int mod = 1e9+7;

void addMod( int & a, int & b ) {
    a = (a+b)%mod;
}

int main() {
    int n; cin>>n;
    int hi = (1<<n);
    int dp[2][hi];
    int a[n][n];
    FOR(i,0,n) FOR(j,0,n) cin>>a[i][j];
    FOR(i,0,2) FOR(j,0,hi) dp[i][j] = 0;
    FOR(j,0,n) dp[0][(1<<j)] = a[0][j];
    FOR(i,1,n) {
        FOR(j,0,hi) {
            if( dp[(i-1)%2][j] ) {
                FOR(k,0,n) {
                    if( a[i][k] == 0 ) continue;
                    int u = j|(1<<k);
                    if( u != j ) {
                        addMod(dp[i%2][u],dp[(i-1)%2][j]);
                    }
                }
            }
        }
    }
    cout<<dp[(n-1)%2][hi-1]<<"\n";
    return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <unordered_map>
#include<cstring>
#include<cstdlib>
using namespace std;

const long long mod=1000000007;
const long long inf=mod*mod;

char g[1100][1100];
int a[1100][1100];

int main(){
int aa,b;
cin>>aa>>b;
for(int i=0;i<aa;i++){
    cin>>g[i];
}
a[0][0]=1;
for(int i=0;i<aa;i++)for(int j=0;j<b;j++){
    if(g[i][j]=='#') continue;
    if(i>0) a[i][j]=(a[i-1][j]+a[i][j])%mod;
    if(j>0) a[i][j]=(a[i][j-1]+a[i][j])%mod;
}
cout<<a[aa-1][b-1];

return 0;
}


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

int main(void) {
  int k, s;
  cin >> k >> s;
  int cnt = 0;

  for(int x = 0; x <= k; x++) {
    for(int y = x; y <= k; y++) {
      for(int z = y; z <= k; z++) {
        if(x+y+z == s) {
          if(x == y && y == z) cnt++;
          else if(x != y && y != z && z != x) cnt += 6;
          else cnt += 3;
        }
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
// constexpr long double EPS = 1e-15;
// const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    int n;
    cin >> n;
    pair<ll,ll> a[n];
    REP(i,n) {
       cin >> a[i].se >> a[i].fi; 
    }
    sort(a,a+n);
    ll sum = 0;
    REP(i,n) {
        sum += a[i].se;
        if (sum > a[i].fi) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, K; 
	cin >> N >> K; 
	if(K > (N-1) * (N-2) / 2) cout << "-1" << endl; 
	else{
		cout << N * (N-1) / 2 - K << endl; 
		for(int i = 1; i < N; i++){
			cout << i << " " << N << endl; 
		}
		int nokori = (N-1)*(N-2)/ 2 - K; 
		bool finished = false; 
 		for(int i = 1; i < N; i++){
			for(int j = i+1; j < N; j++){
				if(nokori == 0){
					finished = true; break; 
				}
				cout << i << " " << j << endl; 
				nokori --; 
			}
			if(finished) break; 
		}
	}
}

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

int main(){
  ll n;cin>>n;
  ll now=0;
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    now^=a;
  }
  if(now==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A, B;
    std::cin >> A >> B;
    if((A+B)%2==0){
        std::cout << (A+B)/2 << std::endl;
    }
    if((A+B)%2==1){
        std::cout << "IMPOSSIBLE" << std::endl;
    }
}


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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	vector<pair<int,int>> s,p;
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;++i){
		int x,y;
		cin>>x>>y;
		s.emplace_back(x,y);
	}
	for(int i=0;i<m;++i){
		int x,y;
		cin>>x>>y;
		p.emplace_back(x,y);
	}
	for(int i=0;i<n;++i){
		int best=1e9,id;
		for(int j=m-1;~j;--j)
			if(abs(s[i].first-p[j].first)+abs(s[i].second-p[j].second)<=best){
				best=abs(s[i].first-p[j].first)+abs(s[i].second-p[j].second);
				id=j;
			}
		cout<<id+1<<'\n';
	}
}




Measured memory_bytes: 3636
import std.stdio,
       std.string,
       std.conv,
       std.typecons,
       std.algorithm;

int abs(int n) {
  return n >= 0 ? n : -n;
}

void main() {
  int[] buf = readln.chomp.split.to!(int[]);
  int H = buf[0], W = buf[1], D = buf[2];
  alias Tuple!(int, "x", int, "y") Grid;
  Grid[int] A;

  for (int i = 1; i <= H; i++) {
    int[] m_line = readln.chomp.split.to!(int[]);
    for (int j = 0; j < m_line.length; j++) {
      A[m_line[j]] = Grid(i, j + 1);
    }
  }

  long[300 * 300 + 1] d;

  for (int i = D + 1; i <= H * W; i++) {
    d[i] += d[i - D] + abs(A[i].x - A[i - D].x) + abs(A[i].y - A[i - D].y);
  }

  int Q = readln.chomp.to!(int);
  
  for (int i = 0; i < Q; i++) {
    buf = readln.chomp.split.to!(int[]);
    int L = buf[0], R = buf[1];
    writeln(d[R] - d[L]);
  }
}


Measured memory_bytes: 13948
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

type Res struct {
	id   int
	city string
	val  int
}

type ByCity []Res

func (a ByCity) Len() int { return len(a) }
func (a ByCity) Less(i, j int) bool {
	if a[i].city < a[j].city {
		return true
	} else if a[i].city == a[j].city {
		return a[i].val > a[j].val
	} else {
		return false
	}
}
func (a ByCity) Swap(i, j int) { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	res := make([]Res, N)
	for i := 0; i < N; i++ {
		res[i] = Res{i, sc.nextStr(), sc.nextInt()}
	}
	sort.Sort(ByCity(res))
	for _, re := range res {
		fmt.Println(re.id + 1)
	}
}


Measured memory_bytes: 640
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

use std::collections::BTreeSet;
fn divisor(n: i64) -> BTreeSet<i64> {
  let mut i = 1;
  let mut div = BTreeSet::new();
  while i * i <= n {
    if n % i == 0 {
      div.insert(i);
      if n / i != i {
        div.insert(n / i);
      }
    }
    i += 1;
  }
  div
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: i64,
  }
  let dn = divisor(n);
  let mut ans = 0;
  for &d in &dn {
    if d == 1 {
      continue;
    }
    let mut x = n;
    while x % d == 0 {
      x /= d;
    }
    if x % d == 1 {
      ans += 1;
    }
  }
  let dm = divisor(n-1);
  for &d in &dm {
    if dn.contains(&d) {
      continue;
    }
    if n % d == 1 {
      ans += 1;
    }
  }

  puts!("{}\n", ans);
}


Measured memory_bytes: 4476
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define lli long long int
#define llu long long unsigned int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,s,e) for(i=s; i<e; i++)
#define mod 1000000007
#define F first
#define S second
#define plli pair<lli,lli>
#define pqlli priority_queue<lli>
#define test(t) cin>>t; while(t--)
using namespace std;

lli power(lli a, lli b, lli M = mod)
{
	lli result = 1;
    for (;;)
    {
        if (b & 1)
            result = (result*a)%M;
        b >>= 1;
        if (!b)
            break;
        a = (a*a)%M;
    }
    return result;
}
map<lli,lli> dis;

void bfs(vector<vector<lli> > &g, lli start, lli n)
{
	queue<plli> q;
	q.push(mp(start, 0));
	int mark[n+1];
	memset(mark, 0, sizeof(mark));
	mark[start] = 1;
	while(!q.empty())
	{
		lli temp = q.front().first;
		lli c = q.front().second;
		q.pop();
		for(auto i : g[temp])
		if(mark[i] == 0)
		q.push(mp(i, c+1)), dis[c+1]++, mark[i] = 1;
	}
}

int main()
{
	IOS;
	lli n;
	
	cin>>n;
	lli temp = (n/500)*1000;
	temp += ((n%500)/5)*5;
	cout<<temp<<endl;
}


Measured memory_bytes: 256
N, M=map(int, input().split())
AB=list(sorted([list(map(int, input().split())) for _ in range(N)]))

ans=0
honsuu=0
for i in range(N):
	if honsuu+AB[i][1]<=M:
		honsuu+=AB[i][1]
		ans+=AB[i][0]*AB[i][1]
	else:
		ans+=AB[i][0]*(M-honsuu)
		break
print(ans)



		


Measured memory_bytes: 28652
#include <stdio.h>
int table[150][150] = {0};
int sum_row[150] = {0};
int sum_col[150] = {0};
int main() {
int r,c;
int p=0,q=0;
int last_sum = 0;
scanf("%d %d",&r,&c);
for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
        scanf ("%d",&table[i][j]);
    }
}
for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
        sum_row[p] += table[i][j];
    }
    p++;
}


for(int i=0;i<c;i++){
    for(int j=0;j<r;j++){
        sum_col[q] += table[j][i];
    }
    q++;
}
for(int i=0;i<r;i++){
    table[i][c] = sum_row[i];
    last_sum += sum_row[i];
}
for(int i=0;i<=c;i++){
    table[r][i] = sum_col[i];
}
table[r][c] = last_sum;
for(int i=0;i<=r;i++){
    for(int j=0;j<=c;j++){
        if(j==0){
            printf ("%d",table[i][j]);
        }
        else {
        printf (" %d",table[i][j]);
        }
    }
    printf ("\n");
}

    return 0;
}



Measured memory_bytes: 2076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		long x = Long.parseLong(str[0]);
		long y = Long.parseLong(str[1]);

		long ans = Long.MAX_VALUE;
		if (x <= y)
			ans = Math.min(ans, y - x);
		if (-x <= y)
			ans = Math.min(ans, y + x + 1);
		if (x <= -y)
			ans = Math.min(ans, -y - x + 1);
		if (-x <= -y)
			ans = Math.min(ans, -y + x + 2);
		System.out.println(ans);
	}
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
 
  int x = 0;
  int answer = 0;
  
  for (int i = 0; i < N; i++) {
   if(S.at(i) == 'I')
     x ++;
   else
     x--;
   if (answer < x)
    answer = x;
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
import math
import copy

inputa = input().split()
# inputb = input().split()
# inputc = input().split()

a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

inputb = input().split()
inputbList = [int(x) for x in inputb]
# inputList = list(b)

# x = int(inputb[0])
# y = int(inputb[1])

# inputList=[]
# for i in range(a):
#     inputNum = input().split()
#     inputNum = [int(x) for x in inputNum]
#     inputList.append(inputNum)

# inputList = [int(n) for n in inputList]

# b = [int(n) for n in inputb]
# c = [int(n) for n in inputc]

sum = 0
for i in range(a):
    sum += inputbList[i]

ans = True
for i in range(a):
    tmp = 0
    tmp = sum - inputbList[i]
    if inputbList[i] >= tmp:
        ans = False

if ans == True:
    print("Yes")
else:
    print("No")










Measured memory_bytes: 3444
import java.util.*;

class Main{
  public static void main(String[] args) {
    Scanner reader=new Scanner(System.in);
    int n=reader.nextInt();
    int buka[]=new int[n+1];
    int number[]=new int[n+1];
    buka[0]=0;
    for(int i=0;i<n;i++)
    {
      number[i]=0;
    }
    for(int i=2;i<=n;i++)
    {
      buka[i]=reader.nextInt();

      number[buka[i]]++;

    }
    for(int i=1;i<=n;i++)
  System.out.println(number[i]);










  }
}

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

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

    static class E1Or2 {
        static E1Or2.Node[] graph;
        static boolean[] visited;

        static void dfs(int a) {
            visited[a] = true;
            for (int i : graph[a].edges) {
                if (!visited[i]) {
                    dfs(i);
                }
            }
        }

        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int[] x = new int[m];
            int[] y = new int[m];
            int[] z = new int[m];
            graph = new E1Or2.Node[n];
            for (int i = 0; i < n; i++) {
                graph[i] = new E1Or2.Node();
                graph[i].edges = new ArrayList<>();
            }
            visited = new boolean[n];
            for (int i = 0; i < m; i++) {
                x[i] = sc.nextInt() - 1;
                y[i] = sc.nextInt() - 1;
                z[i] = sc.nextInt();
                graph[x[i]].edges.add(y[i]);
                graph[y[i]].edges.add(x[i]);
            }
            int ans = 0;
            for (int i = 0; i < n; i++) {
                if (!visited[i]) {
                    dfs(i);
                    ans++;
                }
            }
            out.println(ans);
        }

        static class Node {
            ArrayList<Integer> edges;

        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll x, y, z, k; cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    for(ll i=0;i<x;i++) cin >> a[i];
    for(ll i=0;i<y;i++) cin >> b[i];
    for(ll i=0;i<z;i++) cin >> c[i];
    vector<ll> ab;
    for(ll i=0;i<x;i++){
        for(ll j=0;j<y;j++) ab.push_back(a[i] + b[j]);
    }
    sort(ab.begin(), ab.end(), greater<ll>());
    sort(c.begin(), c.end(), greater<ll>());
    vector<ll> ans;
    for(ll i=0;i<min(k, x*y);i++){
        for(ll j=0;j<min(k, z);j++){
            ans.push_back(ab[i] + c[j]);
        }
    }
    sort(ans.begin(), ans.end(), greater<ll>());
    for(ll i=0;i<k;i++) cout << ans[i] << endl;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	/*
	int a;
	cin >> a;
	//*/
	/*
	int a, b;
	cin >> a >> b;
	//*/

	string s;
	cin >> s;

	cout << (s ==  "ABC" ? "ARC" : "ABC") << endl;

}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e9;

int main(){
	int n;
	string s;
	cin >> n;
	cin >> s;
  	if(s.substr(0,n/2) == s.substr(n/2)){
    	cout << "Yes";
    }else{
    	cout << "No";
    }
	return 0;
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int n;
  i64 a, b;
  cin >> n >> a >> b;
  vector<i64> x(n);
  rep(i, 0, n) cin >> x[i];

  i64 ans = 0;
  rep(i, 1, n) {
    ans += min(a * (x[i] - x[i - 1]), b);
  }
  cout << ans << endl;
}


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

namespace ABC
{
    class ProgramD
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var a = double.Parse(inputs[0]);
            var b = double.Parse(inputs[1]);
            var n = double.Parse(inputs[2]);
            var x = Math.Min(b - 1, n);
            var result = Math.Floor(a * x / b) - (a * Math.Floor(x / b));
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27628
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}

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

    ll ans[k+1] = {0};
    for(ll i = k ; i >= 1 ; i--)
    {
        ans[i] = power(k/i , n);
        for(ll j = 2*i ; j <= k ; j += i)
        {
            ans[i] = (ans[i]%mod - ans[j]%mod + mod)%mod;
        }
    }

    ll sum = 0;
    for(ll i = 1;  i <= k ; i++)
    {
        // debug(ans[i]);
        sum = (sum + (ans[i] * i)%mod)%mod;
    }
    cout << sum << endl;
    return 0;
}

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

#define ll long long

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll A[n];
    for(ll i=0;i<n;i++){
        ll x;
        cin>>x;
        A[i] = x;
    }
    ll S[n];
    S[0] = A[0];
    // ll R[n];
    // R[n-1] = A[n-1];
    for(ll i=1;i<n;i++){
        S[i] = S[i-1] + A[i];
        // R[n-1-i] = R[n-1-i+1] +A[n-1-i];
    }
    ll total = S[n-1];
    ll ans=INT_MAX;
    for(ll i=0;i<n-1;i++){
        ans = min(abs(S[i]-(total - S[i])),ans);
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
import sys

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

MOD = 10 ** 9 + 7
N, K = nm()


def solve():
    ans = 0
    tbl = [0] * (K + 1)
    for i in range(K, 0, -1):
        m = K // i
        p = pow(m, N, MOD)

        j = 2
        while j * i <= K:
            p += MOD - tbl[j * i] % MOD
            p %= MOD
            j += 1
        tbl[i] = p

        ans += i * p % MOD
        ans %= MOD
    return ans


print(solve())


Measured memory_bytes: 11148
def gcd(a, b):
  if a < b:
    a, b = b, a
  while a % b:
    a, b = b, a % b
  return b

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
if N == 1:
  print(x[1] - x[0])
elif N == 2:
  print(gcd(x[2] - x[1], x[1] - x[0]))
else:
  l = x[1] - x[0]
  for i in range(1, N - 1):
    d = x[i + 1] - x[i]
    l = gcd(l, d)
  print(l)

Measured memory_bytes: 14480
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s1 = scan.next().charAt(0) + "";
		String s2 = scan.next().charAt(0) + "";
		String s3 = scan.next().charAt(0) + "";
		String s = s1 + s2 + s3;
		s = s.toUpperCase();
		System.out.println(s);
	}
}

Measured memory_bytes: 21844
N = int(input())
MOD = 10**9 + 7

memo = [{} for _ in range(N + 1)]

def isAGC(char4):
    for i in range(4):
        tmp = list(char4)
        if i != 3:
            tmp[i], tmp[i + 1] = tmp[i + 1], tmp[i]
        if ''.join(tmp).count('AGC') >= 1:
            return True
    return False

def dfs(cur, char3):
    if char3 in memo[cur]:
        return memo[cur][char3]
    if cur == N:
        return 1
    
    ret = 0
    for c in ['A', 'C', 'G', 'T']:
        if not isAGC(char3 + c):
            ret = (ret + dfs(cur + 1, char3[1:] + c)) % MOD

    memo[cur][char3] = ret
    return ret

print(dfs(0, 'XXX'))

Measured memory_bytes: 3852
#include <vector>
#include <iostream>
#include <string>
#include <set>
#include <map>

using namespace std;

int main() {
	long long n, m;
	cin >> n >> m;

	if (n > m) swap(n, m);

	if (n == 1 && m != 1) {
		cout << m - 2 << endl;
		return 0;
	}

	long long ans = n*m - 2*n - 2*m + 4;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using P = pair<long long, long long>;

struct Unionfind {
  // tree number
  vector<int> par;
  // tree rank
  vector<int> treerank;
  // constructor
  Unionfind(int n = 1) { stree(n + 1); }
  // make and initialization
  void stree(int n = 1) {
    par.assign(n, -1);
    treerank.assign(n, 0);
  }
  // search root
  int root(int x) {
    if(par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  // is same?
  bool issame(int x, int y) { return root(x) == root(y); }

  // add
  // already added, return 0
  bool uni(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return 0;
    if(treerank[x] > treerank[y]) swap(x, y);
    if(treerank[x] == treerank[y]) ++treerank[y];
    par[y] -= size(x);
    par[x] = y;
    return 1;
  }
  int size(int x) { return -par[root(x)]; }
};

struct data {
  long long a, b, n;
};
bool operator<(const data &l, const data &r) {
  if(l.b != r.b) return l.b < r.b;
  if(l.a != r.a) return l.a < r.a;
  return l.n < r.n;
}

long long n;
vector<long long> a, b;
vector<P> ap;
vector<data> bp;

bool solve();

int main() {
  cin >> n;
  a.resize(n);
  b.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i) cin >> b[i];
  if(solve())
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

bool solve() {
  bool ch = 1;
  Unionfind uf(n);
  for(int i = 0; i < n; ++i) {
    if(a[i] > b[i]) ch = 0;
    ap.push_back({a[i], i});
    bp.push_back({a[i], b[i], i});
  }
  if(ch) return 1;
  sort(ap.begin(), ap.end());
  sort(bp.begin(), bp.end());
  for(int i = 0; i < n; ++i) {
    if(ap[i].fi > bp[i].b) return 0;
    if(i != 0 && ap[i].fi <= bp[i - 1].b) ch = 1;
    uf.uni(ap[i].se, bp[i].n);
  }
  return ch || uf.size(0) != n;
}

Measured memory_bytes: 8072
#include<stdio.h>
int main(void){
int n,r,a,b,c;
int card[4][13];
char e;
for(a=0;a<4;a++)for(b=0;b<13;b++)card[a][b]=0;
scanf("%d",&n);
for(a=0;a<n;a++){
scanf("%*c%c",&e);
if(e=='S')c=0;
if(e=='H')c=1;
if(e=='C')c=2;
if(e=='D')c=3;
scanf("%d",&r);
card[c][r-1]=1;
}
for(a=0;a<4;a++){
for(b=0;b<13;b++){
if(card[a][b]==0){
if(a==0)e='S';
if(a==1)e='H';
if(a==2)e='C';
if(a==3)e='D';
r=b+1;
printf("%c %d\n",e,r);
}
}
}
return 0;
}


Measured memory_bytes: 1996
/*A - Fifty-Fifty*/
#include <bits/stdc++.h>
using namespace std;

using Long = long long;

int main(){

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

	set <char> letras;
	string cad;

	cin >> cad;

	for (int i = 0; i < cad.size(); ++i)
	{
		letras.insert(cad[i]);
	}

	if(letras.size() == 2){
		cout << "Yes";
	}
	else{
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

ll gcd(ll a,ll b){
	if( a < b) return gcd(b,a);
	if(b == 0) return a;
	if(b == 1) return 1;
	return gcd(b,a%b);
}

int main()
{
	int n;
	cin>>n;
	vector<ll> a(n);
	rep(i,n) cin>>a[i];
	vector<ll> left(n);
	vector<ll> right(n);
	left[0] = a[0];
	for(int i = 1; i < n; i++){
		left[i] = gcd(left[i-1],a[i]);
	}
	right[n-1] = a[n-1];
	for(int i = n-2; i >= 0; i--){
		right[i] = gcd(right[i+1],a[i]);
	}
	ll ans = 0;
	ans = max(left[n-2],right[1]);
	for(int i = 1; i < n-1; i++){
		ll temp = gcd(left[i-1],right[i+1]);
		ans = max(ans,temp);
	}
	cout<<ans<<endl;
	/*rep(i,n){
		cout<<left[i]<<" ";
	}
	cout<<endl;*/
	return 0;
}


Measured memory_bytes: 5140
package main

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

func main() {
	A, B, H, M := ReadFloat64(), ReadFloat64(), ReadFloat64(), ReadFloat64()
	a := (M / 30) * math.Pi
	b := (H + M/60) / 12 * 2 * math.Pi
	dx := B*math.Cos(b-a) - A
	dy := B * math.Sin(b-a)
	fmt.Println(math.Sqrt(dx*dx + dy*dy))
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadFloat64() (f float64) { Scan(&f); return }


Measured memory_bytes: 1840
import java.util.Scanner;
public class Main{
    public static int check(long dp[], long a){
        int start = 0;
        int end = dp.length-1;
        while(true){
            if(dp[start] >= a)
                return start;
            else if(dp[end] <= a)
                return end;
            else{
                if(start+1 == end)
                    return end;
                else{
                    int mid = (start+end)/2;
                    if(dp[mid] == a)
                        return mid;
                    else if(dp[mid] > a)
                        end = mid;
                    else
                        start = mid;
                }
            }
        }
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long a[] = new long[n];
        for(int i = 0 ; i < n ; i++)
            a[i] = sc.nextLong();
        long dp[] = new long[n];
        for(int i = 0 ; i < n ; i++){
            dp[i] = 1000000001;
        }
        dp[0] = a[0]; 
        for(int i = 1 ; i < n ; i++)
            dp[check(dp,a[i])] = a[i];
        for(int i = 0 ; i < n ; i++){
            if(dp[i] > 1000000000){
                System.out.println(i);
                break;
            }
            if(i == n-1)
                System.out.println(n);
        }
    }
}


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

int main(void){
	int n, p;
	while(1){
		cin >> n >> p;
		if(n == 0 && p == 0) break;

		int ma[100] = {};

		int cnt = 0;
		int wan = p;
		while(1){
			if(wan != 0){
				ma[cnt]++;
				wan--;
				if(wan == 0 && ma[cnt] == p){
					cout << cnt << endl;
					break;
				}
			}else{
				wan = ma[cnt];
				ma[cnt] = 0;
			}
			cnt = (cnt + 1) % n;
			//cout << wan << endl;
		}
		
	}

	return 0;
}

Measured memory_bytes: 1160
#include <stdlib.h>
#include <iostream>
using namespace std;

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

	long a_x = a/x;
	long b_x = b/x;
	if(a%x == 0) a_x--;


	cout << b_x - a_x << endl;

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
	int n;
	scanf("%d", &n);
	
	char str[n+1];
	scanf("%s", &str);
	
	if (n%2!=0){
		printf("No\n");
	}
	else {
		int index=1;
		for (int i=0; i<n/2; i++){
			if (str[i]!=str[i+n/2]){
				index=0;
			}
		}
			if(index){
				printf("Yes\n");
			}
			else{
				printf("No\n");
			}
	}

	return 0;
}

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


int main()
{
	ll X;
	cin>>X;
	ll ans=0;
	ans+=(X/500)*1000;
	X%=500;
	ans+=(X/5)*5;
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  int a,b,c,d;

  scanf("%d %d %d %d", &a, &b, &c, &d);

  if(a*b > c*d) printf("%d\n", a*b);
  else printf("%d\n", c*d);
  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
ll SZ = 262144;
ll* seg = new ll[2*SZ]; //segtree implementation by bqi343's Github


ll combine(ll a, ll b) { return max(a, b); }

void build() { F0Rd(i,SZ) seg[i] = combine(seg[2*i],seg[2*i+1]); }

void update(int p, ll value) {  
    for (seg[p += SZ] = value; p > 1; p >>= 1)
        seg[p>>1] = combine(seg[(p|1)^1], seg[p|1]);
}

ll query(int l, int r) {  // sum on interval [l, r]
    ll resL = 0, resR = 0; r++;
    for (l += SZ, r += SZ; l < r; l >>= 1, r >>= 1) {
        if (l&1) resL = combine(resL,seg[l++]);
        if (r&1) resR = combine(seg[--r],resR);
    }
    return combine(resL,resR);
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    vpl data(N);
    F0R(i, N) cin >> data[i].f >> data[i].s;

    sort(all(data));

    ll dp[N+1]; dp[N] = 1;

    map<ll, int> pos;
    F0R(i, N) pos.insert({data[i].f, i});
    F0R(i, 2*SZ) seg[i] = 0;

    F0Rd(i, N) {
        int last = (--(pos.lb(data[i].f+data[i].s)))->s;
        if (last > i) last = query(i+1, last);
        update(i, last);
        
        dp[i] = dp[i+1] + dp[last+1];
        dp[i] %= MOD;
    }

    cout << dp[0] << endl;
    
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 24608
import math

while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)

    if op == "?":
        break
    elif op == "+":
        print("{}".format(a + b))
    elif op == "-":
        print("{}".format(a - b))
    elif op == "*":
        print("{}".format(a * b))
    elif op == "/":
        print("{}".format(math.floor(a / b)))
    else:
        break



Measured memory_bytes: 5660
a, b, k = input().split(' ')
a = int(a)
b = int(b)
k = int(k)
 
if (k >= a + b): print('0 0')
else:
  if (k <= a):
    print(a-k, end = ' ')
    print(b)
  else:
    print('0',end = ' ')
    print(b - k + a)

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

int main() {
    int N, M;
    cin >> N >> M;
    int p; string s;
    vector<pair<int, int>> questions_and_results(N, make_pair(0, 0));
    for (int i = 0; i < M; i++) {
        cin >> p >> s;
        if (s == "AC") questions_and_results.at(p-1).first = 1;
        else if (questions_and_results.at(p-1).first == 0) questions_and_results.at(p-1).second += 1;
    }

    int n_ac = 0; int n_wa = 0;
    for (int i = 0; i < N; i++) {
        n_ac += questions_and_results.at(i).first;
        if (questions_and_results.at(i).first) n_wa += questions_and_results.at(i).second;
    }

    cout << n_ac << " " << n_wa << endl;
}

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

using namespace std;

int main(){
    int count = 0;
    string s,t;
    cin >> s;
    cin >> t;
    for(int i = 0; i < 3; i++){
        if(s[i] == t[i]) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
W = list(map(int,input().split()))
s = 0
i = 0
sw = sum(W)
while s < sw/2:
    s += W[i]
    i += 1
print(min( abs(sum(W[0:i])-sum(W[i:N])) , abs(sum(W[0:i-1])-sum(W[i-1:N])) ))

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
	int X;
	scanf("%d", &X);
	
	int i, x;
	for (x = X; x <= X * 2; x++) {
		for (i = 2; i * i <= x; i++) {
			if (x % i == 0) break;
		}
		if (i * i > x) break;
	}

	printf("%d\n", x);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int a[3];
int main() {
    for (int i = 0; i < 3; ++i) {
        cin >> a[i];
    }
    sort(a, a+3);
    cout << a[0] * a[1] / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int main(){
	

	int t = 1;
	//cin >> t;
	while(t--){
		int n;
		cin >> n;
		string s;
		cin >> s;
		int count = 0;
		int w = 0, r = 0;
		for(int i = 0; i < n; ++i){
			if(s[i] == 'R') r++;
			else w++;
		}
		for(int i = 0; i < r; ++i){
			if(s[i] == 'R') count++;
		}
		cout << r - count << '\n';
	}
	return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fo(i, n) for(int i=0; i<n ;i++)
#define Fo(i, k, n) for(int i=k; i<n ;i++)
#define deb(x) cout<< #x <<" "<< x <<"\n";
#define lli long long int
using namespace std;

int main(){
    fast
    int n;
    cin>>n;
    int a[n+1];
    fo(i, n)
        a[i] = 0;
    fo(i ,n-1){
        int temp;
        cin>>temp;
        a[temp-1]++;
    }
    fo(i , n){
        cout<<a[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 4432
# -*- coding: utf-8 -*-

s = input()
l =[]
l.append(s);

keepCheck = True
counter = 1
while keepCheck:
    counter += 1
    if s%2 == 0:
        s /= 2
    else:
        s = 3*s + 1

    # 重複チェック
    for val in l:
        if val == s:
            keepCheck = False

    l.append(s)

print counter


Measured memory_bytes: 2568
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n = int(input())

ans = [0]*10**5

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            ans[i**2 + j**2 + k**2 + i*j + j*k + k*i] += 1
print(*ans[1:n + 1], sep='\n')


Measured memory_bytes: 69196