akhauriyash/Code-Regression huggingface dataset:
import math

CON = 998244353

N, K = list(map(int,input().split()))
LR = [list(map(int,input().split())) for _ in range(K)]

dp = [0] * (N + 1)
cs = [0] * (N + 1)

def solve():
    dp[1] = 1
    cs[1] = 1

    for i in range(2, N + 1):
        for pts in LR:
            if i - pts[0] > 0: dp[i] += cs[i-pts[0]] 
            if i - pts[1] > 0: dp[i] -= cs[i-(pts[1] + 1)] 
        dp[i] = dp[i] % CON
        cs[i] = (cs[i-1] + dp[i]) % CON

    print(dp[N])

solve()

Measured memory_bytes: 71032
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;cin>>s;
	bool ok=true;

	if(s[0]!='A')ok=false;

	int n=s.size();
	bool s_ok=false;
	for(int i=2;i<n-1;++i){
		if(s[i]!='C')continue;
		
		if(s_ok){
			s_ok=false;
			break;
		}
		else{
			s_ok=true;
		}
	}
	if(!s_ok)ok=false;

	for(int i=1;i<n;++i){
		char a=s[i];

		if(isupper(a)){
			if((2<=i && i<=n-1) && a=='C')continue;
			ok=false;
		}
	}

	if(ok)cout<<"AC"<<endl;
	else cout<<"WA"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        String s = sc.nextLine();

        int sum = 0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == '1'){
                sum++;
            }
        }

        System.out.println(sum);

    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long INF = 1LL<<60;
int main() {
  int64_t N,K; cin>>N>>K;
  vector<int64_t> A(N);
  rep(i,N) cin>>A.at(i);
  for(int i=K;i<N;i++){
    if(A.at(i)>A.at(i-K)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 4840
import Control.Monad
main=do
 c<-replicateM 3 (map read.words<$>getLine)
 putStrLn(f c)
  where f c = if((c!!0)!!0)-((c!!0)!!1)==((c!!1)!!0)-((c!!1)!!1)&&((c!!0)!!0)-((c!!0)!!1)==((c!!2)!!0)-((c!!2)!!1)then(g c)else"No"
        g c = if((c!!0)!!1)-((c!!0)!!2)==((c!!1)!!1)-((c!!1)!!2)&&((c!!0)!!1)-((c!!0)!!2)==((c!!2)!!1)-((c!!2)!!2)then(h c)else"No"
        h c = if((c!!0)!!0)-((c!!1)!!0)==((c!!0)!!1)-((c!!1)!!1)&&((c!!0)!!0)-((c!!1)!!0)==((c!!0)!!2)-((c!!1)!!2)then(i c)else"No"
        i c = if((c!!1)!!0)-((c!!2)!!0)==((c!!1)!!1)-((c!!2)!!1)&&((c!!1)!!0)-((c!!2)!!0)==((c!!1)!!2)-((c!!2)!!2)then"Yes"else"No"

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===

// const ll mod = static_cast<int>(1e9 + 7);


int main() {
	string s, t;
	cin >> s >> t;

	ll s_size = static_cast<ll>(s.size());

	vector<Vi> pos(26);
	for (int i = 0; i < s.size(); ++i) {
		pos[s[i] - 'a'].push_back(i);
	}
	unordered_set<char> chset;
	for (auto& si : s) chset.insert(si);
	for (auto& ti : t) {
		if (chset.find(ti) == chset.end()) {
			cout << -1 << endl;
			return 0;
		}
	}

	ll ans = 0;
	ll cursor = -1;

	for (auto& ti : t) {
		int ch = ti - 'a';
		auto it = upper_bound(pos[ch].begin(), pos[ch].end(), cursor);
		if (it == pos[ch].end()) {
			ans += s_size - cursor + pos[ch][0];
			cursor = pos[ch][0];
		}
		else {
			ans += *it - cursor;
			cursor = *it;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 1216
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N;
    string S;
    scan(N);
    scan(S);

    auto rh = RollingHash(S);

    int ans;

    foreach (i ; 0 .. N) {
        foreach (j ; i .. N) {
            while (ans < j - i && j + ans < N && 
                rh[i .. i + ans + 1] == rh[j .. j + ans + 1]) ans++;
        }
    }

    writeln(ans);
}


struct RollingHash {
    enum MAX_LENGTH = 500000;
    enum ulong MASK30 = (1UL << 30) - 1;
    enum ulong MASK31 = (1UL << 31) - 1;
    enum ulong MOD = (1UL << 61) - 1;
    enum ulong POSITIVIZER = MOD * ((1UL << 3) - 1);
    uint base;
    ulong[] basePow = new ulong[](MAX_LENGTH + 1);
    ulong[] hash;

    this(string s) {
        auto rnd = Random(unpredictableSeed);
        base = uniform(129, int.max, rnd).to!uint;
        basePow[0] = 1;
        foreach (i ; 1 .. MAX_LENGTH + 1) {
            basePow[i] = calcMod(mul(basePow[i - 1], base));
        }

        hash = new ulong[](s.length + 1);
        foreach (i ; 0 .. s.length) {
            hash[i + 1] = calcMod(mul(hash[i], base) + s[i]);
        }
    }

    // hash(s[begin .. end])
    ulong slice(int begin, int end) {
        return calcMod(hash[end] + POSITIVIZER - mul(hash[begin], basePow[end - begin]));
    }

    alias opSlice = slice;

    ulong mul(ulong l, ulong r) {
        auto lu = l >> 31;
        auto ld = l & MASK31;
        auto ru = r >> 31;
        auto rd = r & MASK31;
        auto middleBit = ld * ru + lu * rd;
        return ((lu * ru) << 1) + ld * rd + ((middleBit & MASK30) << 31) + (middleBit >> 30);
    }

    ulong mul(ulong l, uint r) {
        auto lu = l >> 31;
        auto rd = r & MASK31;
        auto middleBit = lu * rd;
        return (l & MASK31) * rd + ((middleBit & MASK30) << 31) + (middleBit >> 30);
    }

    ulong calcMod(ulong val) {
        val = (val & MOD) + (val >> 61);
        if (val >= MOD) val -= MOD;
        return val;
    }
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

int main() {
    rep (i, 3) {
        int a[6];
        rep (i, 6) cin >> a[i];
        int in  = a[0] * 3600 + a[1] * 60 + a[2],
        out = a[3] * 3600 + a[4] * 60 + a[5];
        int tmp = out - in;
        cout << tmp / 3600 << " ", tmp %= 3600;
        cout << tmp / 60 << " ", tmp %= 60;
        cout << tmp << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
def main():
    l = list(map(int,input().split()))
    l = sorted(l,reverse=True)
    ans = ''

    ans = 10* l[0] + l[1] + l[2]
    print(ans)


    '''
    for i in range(0,len(l)-1):
        ans = ans + str(l[i])
    ans_int = int(ans) + int(l[-1])

    print(ans_int)
    '''




if __name__ == '__main__' :
    main()

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


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

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
		int a,b,x[7],i,j;
		for(i=0;i<7;i++){
			scanf("%d %d",&a,&b);
				x[i]=a-b;	
			}
		for(j=0;j<7;j++){		
		printf("%d\n",x[j]);
		}
		return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    string s;
    cin>>s;
    int a=0;
    int d=10000;
    int c=0;
    REP(i,s.size()-2){
        c=abs(753-(100*(s[i]-'0')+10*(s[i+1]-'0')+(s[i+2]-'0')));
        d=min(c,d);
    }
    cout<<d;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc162/tasks/abc162_f

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  cin >> N;

  VL as(N);
  rep(i, N) cin >> as[i];

  V<map<ll, ll>> dp(N + 1, map<ll, ll>());

  dp[1][0] = 0;
  dp[1][1] = as[0];

  repf(i, 1, N) {
    for (ll j = (i - 1) / 2; j <= (i + 1) / 2; j++) {
      if (dp[i + 1].count(j) == 0) dp[i + 1][j] = -INF;
      if (dp[i + 1].count(j + 1) == 0) dp[i + 1][j + 1] = -INF;
      chmax(dp[i + 1][j], dp[i][j]);
      chmax(dp[i + 1][j + 1], dp[i - 1][j] + as[i]);
    }
  }

  ll res = dp[N][N / 2];

  cout << res << "\n";
}


Measured memory_bytes: 51788
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
//sort(all(x))とするとソートできるよ

int main(){
    int N;cin >> N;
    LL A,B;
    vector<pair<LL,LL>> work(N);
    rep(i,N){ // B,Aの順で保存
        cin >> work[i].second >> work[i].first ;
    }
    sort(all(work));

    bool OK = true;
    LL tmp;
    LL sum = 0;
    rep(j,N){ 
        tmp = work[j].first - work[j].second ;
        if(tmp - sum < 0){
            OK = false;
            break;
        }
        sum += work[j].second;
    }
    if(OK){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;
int main(){
  int n,a[200];
  int ans=-1;
  bool f=false;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>a[i];
  }
  while(!f){
    ++ans;
    for(int i=0;i<n;++i){
      if(a[i]%2!=0){
        f=true;
        break;
      }
      a[i]/=2;
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

        int N = sc.nextInt();
        String[] W = new String[N];
        String tmp;
        for (int i = 0; i < N; i++) {
            tmp = sc.next();
            //ダブっている単語があるかをチェック
            if (Arrays.asList(W).contains(tmp)) {
                System.out.println("No");
                return;
            }
            W[i] = tmp;
        }

        for (int i = 0; i < N - 1; i++) {
            if (W[i].charAt(W[i].length() - 1) != W[i + 1].charAt(0)) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");


    }
}


Measured memory_bytes: 35792
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define _GLIBCXX_DEBUG
#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++)

void printl(vector<int>);
void insertionSort(int, int);
void shellSort(int);

int cnt = 0;
vector<int> G;
vector<int> A;

int main()
{
    int n;
    cin >> n;
    rep(i, n)
    {
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    shellSort(n);
    cout << G.size() << endl;
    printl(G);
    cout << cnt << endl;
    rep(i, n)
    {
        cout << A.at(i) << endl;
    }
}

void printl(vector<int> A)
{
    for (int i = A.size() - 1; i >= 0; i--)
    {
        cout << A.at(i);
        if (i != 0)
        {
            cout << " ";
        }
        else
        {
            cout << endl;
        }
    }
}

void insertionSort(int n, int g)
{
    rep2(i, g, n)
    {
        int v = A.at(i);
        int j = i - g;
        while (j >= 0 && A.at(j) > v)
        {
            A.at(j + g) = A.at(j);
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int n)
{
    int m = 0;
    int h = 1;
    while (true)
    {
        if (h > n)
            break;
        G.push_back(h);
        h = 3 * h + 1;
    }
    for (int i = G.size() - 1; i >= 0; i--)
    {
        insertionSort(n, G.at(i));
    }
}



Measured memory_bytes: 6968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 998244353
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59


vector<ll> bi(5010101);


ll modinv(ll a) {
    ll m=Mod;
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll comb(ll s,ll t){
    ll q=bi[s]*modinv(bi[t]);
    q%=Mod;
    q*=modinv(bi[s-t]);
    q%=Mod;
    return q;
}

int main(){
    ll i,j;
    ll n,m;
    cin>>n>>m;

    bi[0]=1;

    for(i=1;i<5010101;i++){
        bi[i]=bi[i-1]*i;
        bi[i]%=Mod;
    }

    ll ans1=comb(3*m+n-1,n-1);
    ll ans2=n*comb(m+n-2,n-1);

    ans2%=Mod;
    
    ll hoge=(ans1-ans2+Mod)%Mod;

    if(n<=m) cout<<hoge<<endl;
    else{
        ll l;
        ll ans3=0;
        for(l=m+1;l<=min(3*m,n);l++){
            if((3*m-l)%2==0) {
                ans3+=comb(n,l)*comb((3*m-l)/2+n-1,n-1);
                ans3%=Mod;
            }
        }

         cout<<(hoge+Mod-ans3)%Mod<<endl;
    }







    return 0;
}

Measured memory_bytes: 39424
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll r;
cin>>r;
cout<<r*r<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
N,A,B = map(int, input().split())
ans = 0
S = A+B
T = N//S
U = N%S


if(A == 0):
    ans = 0
else :
    if(0< U < A):
        ans = A*T+U
    elif(U == 0):
        ans = A*T
    elif(U >= A):
        ans = A*T+A
    
print(ans)

Measured memory_bytes: 3064
// https://atcoder.jp/contests/abc128/tasks/abc128_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

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, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (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:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize, m: usize,
        bulbs: [[next / usize1]; m],
        p: [usize; m]
    };
    let mut switches = vec![0; n];
    for i in 0..m {
        for &si in &bulbs[i] {
            switches[si] |= 1<<i;
        }
    }
    let mut ans = 0;
    for i in 0..m {
        ans |= p[i]<<i;
    }

    let mut count = 0;
    for ptn in 0..1<<n {
        let mut parity = 0;
        for i in 0..n {
            if ptn & (1<<i) >= 1{
                parity ^= switches[i];
            }
        }
        if ans == parity {
            count += 1;
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    ll n, m;
    cin >> n >> m;
    vector<P> v;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        v.push_back({a, b});
    }
    sort(v.begin(), v.end());

    ll ans = 0;
    int i = 0;
    while(m > 0){
        int num = min(m, v[i].second);
        ans += v[i].first * num;
        m -= num;
        i++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5344
//16:36~
#include <iostream>
#include <vector>
#include <string>

bool isGood(const std::vector<std::string>& s, const long long int x) {
    const long long int n = s.size();
    for (long long int i = 0; i < n; i++) {
        for (long long int j = 0; j < i; j++) {
            if (s[(i + n - x) % n][j] != s[(j + n - x) % n][i]) return false;
        }
    }
    return true;
}

int main() {
    long long int n, ret = 0;
    std::cin >> n;
    std::vector<std::string> s(n);
    for (long long int i = 0; i < n; i++) {
        std::cin >> s[i];
    }

    for (long long int i = 0; i < n; i++) {
        if (isGood(s, i)) ret++;
    }

    std::cout << ret * n << std::endl;

    return 0;
}


Measured memory_bytes: 384
from sys import stdin, stdout
from math import gcd
def main():
    K = int(stdin.readline())
    sm = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                sm += gcd(i, gcd(j, k))
    stdout.write(str(sm)+"\n")
main()


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
const int maxn = 100050;
typedef long long ll;

int n, a[maxn], m, d[maxn];
long long ans, pre[maxn];

void add(int l,int r,int x,int y)
{
	if(l > r) return;
	d[l] += y; d[r+1] -= y;
	pre[l] += x; pre[r+1] -= x;
}

int main()
{
	scanf("%d%d",&n,&m);
	fo(i,1,n) scanf("%d",&a[i]);
    fo(i,1,n-1)
    {
    	if(a[i] < a[i+1])
    	{
    		add(a[i+1]+1,m,a[i+1]-a[i],0);
    		add(1,a[i],a[i+1]-a[i],0);
    		add(a[i]+1,a[i+1],1+a[i+1],1); 
    	}
    	else
    	{
    		add(1,a[i+1],1+a[i+1],1);
    		add(a[i+1]+1,a[i],m-a[i]+a[i+1],0);
    		add(a[i]+1,m,1+m+a[i+1],1);
    	}
    }
    ans = 1ll<<61;
    fo(i,1,m) d[i] += d[i-1], pre[i] += pre[i-1];
    fo(i,1,m) ans = min(ans, pre[i]-(ll)d[i]*i);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const Arr = (input.trim()).split("\n");
const N1 = Number(Arr[0]);
const arr1 = Arr[1].split(" ").map(Number);
const arr2 = Arr[3].split(" ").map(Number);
console.log(arr2.map(key => {   
  let mid;
  let left = 0;
  let right = N1;
  if (key < arr1[0] || arr1[N1-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key < arr1[mid]) right = mid;
    else if (key > arr1[mid]) left = mid + 1;
    else return 1;
  }
  return 0;
}).reduce((a, b) => a + b));



Measured memory_bytes: 34940
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    string s;
    cin >> s;
    int a = 0;
    if(s == "SUN") a = 7;
    if(s == "MON") a = 6;
    if(s == "TUE") a = 5;
    if(s == "WED") a = 4;
    if(s == "THU") a = 3;
    if(s == "FRI") a = 2;
    if(s == "SAT") a = 1;

    cout << a;
    return 0;
}

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

bool my_compare(tuple<string, int, int> a, tuple<string, int, int> b) {
    if (get<0>(a) != get<0>(b)) {
        return get<0>(a) < get<0>(b);
    }
    return get<1>(a) > get<1>(b);
}

int main() {
    int N;
    cin >> N;
    vector<tuple<string, int, int>> map;
    string city;
    int x;
    for (auto i = 0; i < N; i++) {
        cin >> city >> x;
        map.push_back(make_tuple(city, x, i+1));
    }
    sort(map.begin(), map.end(), my_compare);
    for (int i = 0; i < N; i++) {
        int y;
        tie(ignore, ignore, y) = map.at(i);
        cout << y << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		Console.WriteLine("{0}",s[0]*500>=s[1]?"Yes":"No");
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13140
a, b, c, d = map(int, input().split())
if c % b == 0:
    x = c // b
else:
    x = c // b + 1
if a % d == 0:
    y = a // d
else:
    y = a // d + 1
if x <= y:
    print("Yes")
else:
    print("No")
# print(x, y)


Measured memory_bytes: 9156
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int h,a;
    cin>>h>>a;
    cout<<(int)ceil(h/(double)a)<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, 0, N) { cin >> a[i]; a[i]--; }
	int cnt = 0;
	rep(i, 0, N) {
		if (i == a[a[i]])cnt++;
	}
	cout << cnt / 2 << endl;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;//for StringBuilder
class c
{
    static void Main()
    {
        var nk = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        long n = nk[0], k = nk[1];
        var a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        for (int i = 0; i < n-k; i++)
        {
            if (a[i] < a[i + k]) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 46336
def Knapsack(N, W, vs, ws):
    dp = [[0 for n in range(W+1)] for w in range(N+1)]

    for n in range(N):
        for w in range(W+1):
            if (w >= ws[n]):
                dp[n+1][w] = max(dp[n][w-ws[n]] + vs[n], dp[n][w])
            else:
                dp[n+1][w] = dp[n][w]

    return dp[N][W]

N, W = map(int, input().split(' '))
vs, ws = [0] * N, [0] * N
for n in range(N):
    vs[n], ws[n] = map(int, input().split(' '))

ans = Knapsack(N, W, vs, ws)
print(ans)


Measured memory_bytes: 42272
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
typedef pair<int64_t, int64_t> P;

int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, 0, N) cin >> X.at(i);
    int ans = INF;
    rep(i, 1, 101){
        int sum = 0;
        rep(j, 0, N){
            sum += pow(X.at(j) - i, 2);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)n; ++i)

int n, m, k, br, mh[51], h[51], an, md = 1e9 + 7, ch[300][300];
vector<int> g[51];
vector<pair<int, int> > cy;
char vis[51];

pair<int, int> go(int v, int p = 0){
	vis[v] = 1;
	h[v] = mh[v] = 1 + h[p];
	pair<int, int> ed = make_pair(0, 1);
	f(i, 0, g[v].size()){
		int u = g[v][i];
		if (u == p)continue;
		if (vis[u] == 1)mh[v] = min(mh[v], h[u]), ++ed.first;
		else if (!vis[u]){
			pair<int, int> t = go(u, v);
			mh[v] = min(mh[v], mh[u]);
			if (mh[u] < h[v])ed = make_pair(ed.first + t.first + 1, ed.second + t.second);
			else if (mh[u] == h[v])cy.push_back(make_pair(t.first + 1, t.second + 1));
			else ++br;
		}
	}
	vis[v] = 2;
	return ed;
}

int pw(int x, int p){
	if (!p)return 1;
	int t = pw(x, p >> 1);
	t = (ll)t * t % md;
	if (p & 1)t = (ll)t * x % md;
	return t;
}

int dan[51];
inline int div(int x){
	int an = 0;
	f(i, 1, x + 1)if (x % i == 0){
		dan[i] = pw(k, i);
		f(j, 1, i)if (i % j == 0 && (dan[i] -= dan[j]) < 0)dan[i] += md;
		if ((an += (ll)dan[i] * pw(i, md - 2) % md) >= md)an -= md;
	}
	return an;
}

int main() {
	f(i, 0, 300){
		ch[i][0] = 1;
		f(j, 1, i + 1)if((ch[i][j] = ch[i - 1][j - 1] + ch[i - 1][j]) >= md)ch[i][j] -= md;
	}
	scanf("%d%d%d", &n, &m, &k);
	f(i, 0, m){
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	f(i, 1, n + 1)if (!vis[i])go(i);
	an = pw(k, br);
	f(i, 0, cy.size()){
		if (cy[i].first == cy[i].second)an = (ll)an * div(cy[i].first) % md;
		else an = (ll) an * ch[k + cy[i].first - 1][cy[i].first] % md;
	}
	printf("%d\n", an);
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{

  int x, y, d, temp;


  scanf("%d%d", &x,&y);

    if(x>y){
    temp = x;
    x = y;
    y = temp;
  }

    d = x % y;
  while(d!=0){
    x = y;
    y = d;
    d = x % y;
  }

    printf("%d\n", y);

  return 0;
}




Measured memory_bytes: 2104
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int L;
	while(~scanf("%d", &L)) {
		int N;
		scanf("%d", &N);
		int sum = 0;
		rep(i, N) {
			int x; int w;
			scanf("%d%d", &x, &w);
			sum += x * w;
		}
		vpii ans;
		rep(i, sum)
			ans.emplace_back(-1, 1);
		rep(i, -sum)
			ans.emplace_back(1, 1);
		printf("%d\n", (int)ans.size());
		for(int i = 0; i < (int)ans.size(); ++ i)
			printf("%d %d\n", ans[i].first, ans[i].second);
	}
	return 0;
}

Measured memory_bytes: 3328
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}


int main(){
    string s;
    cin >> s;
    int len = s.length() - 1;
    SORT(s);

    bool same = 1;
    REP(i,len){
        if( s.at(i) == s.at( i+1 ) ){
            same = 1;
            break;
        }else{
            same = 0;
        }
    }
    cout << (( same == 1 ) ? "no" : "yes") << endl;
    return 0;
}


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

int main() {
    int n;
    long long int ans = 0;
    string s;
    cin >> n >> s;
    int r[n+1] = {0}, g[n+1] = {0}, b[n+1] = {0};
    for(int i = n-1; i >= 0; --i) {
        if(s[i] == 'R') {
            r[i] = r[i+1] + 1;
            g[i] = g[i+1];
            b[i] = b[i+1];
        } else if(s[i] == 'G') {
            r[i] = r[i+1];
            g[i] = g[i+1] + 1;
            b[i] = b[i+1];
        } else {
            r[i] = r[i+1];
            g[i] = g[i+1];
            b[i] = b[i+1] + 1;
        }
    }

    for(int i = 0; i < n-2; ++i) {
        for(int j = i+1; j < n-1; ++j) {
            if(s[i] != s[j]) {
                char c = 'R' + 'G' + 'B' - s[i] - s[j];
                if(c == 'R') {
                    ans += r[j+1];
                    if(s[2*j-i] == 'R') ans--;
                } else if(c == 'G') {
                    ans += g[j+1];
                    if(s[2*j-i] == 'G') ans--;
                } else {
                    ans += b[j+1];
                    if(s[2*j-i] == 'B') ans--;
                }
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    string s; cin >> s;

    bool a = true;
    char x = s[0];

    rep(i,4){
        if(s[i]!=x) a = false; 
    }
    
    if(!a && ((s[0]==s[1]  && s[2]==s[3]) || (s[0]==s[2]  && s[1]==s[3]) || (s[0]==s[3]  && s[2]==s[1]))){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
	input!(n: usize);
	input!(m: usize);
	input!(k: usize);
	input!(a: [usize; n]);
	input!(b: [usize; m]);

	// Aの山だけ上から読む
	let mut sum = 0;
	let mut acount = 0;
	let mut bcount = 0;
	for i in 0..n {
		if sum + a[i] > k {
			break;
		}
		sum += a[i];
		acount += 1;
	}
	// 残りがあればBの山から取る
	for i in 0..m {
		if sum + b[i] > k {
			break;
		}
		sum += b[i];
		bcount += 1;
	}

	let mut max = acount+bcount;

	while acount > 0 {
		sum -= a[acount - 1];
		acount -= 1;
		for i in bcount..m {
			if sum + b[i] > k {
				break;
			}
			sum += b[i];
			bcount += 1;
		}
		max = std::cmp::max(max, acount+bcount);
	}
	println!("{}", max);
}


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

#define int long long
int dp[223456][5],v[223456];

int f(int S,int J){
  if(S<=0&&J-S==1)return 0;
  if(S<=0||J<0)return -1e18;
  if(~dp[S][J])return dp[S][J];
  return dp[S][J]=max({f(S-2,J),f(S-3,J-1),f(S-4,J-2)})+v[S-1];
}

signed main(){
  int n;cin>>n;
  for(int i=0;i<n;i++)cin>>v[i];
  memset(dp,-1,sizeof(dp));
  if(n&1)cout<<max({f(n,2),f(n-1,1),f(n-2,0)})<<endl;
  else cout<<max(f(n,1),f(n-1,0))<<endl;
}


Measured memory_bytes: 20124
N = int(input())
A = [int(x) for x in input().split()]
ans = sum(A)
l = [0] * 100000
for i in A:
    l[i-1] += 1
Q = int(input())
for i in range(Q):
    B, C = map(int, input().split())
    ans += l[B-1] * (C - B)
    l[C-1] += l[B-1]
    l[B-1] = 0
    print(ans)

Measured memory_bytes: 20476
#include <iostream>

using namespace std;

int main()
{
	char x, y;
	cin >> x>> y;

	if (x == 'A')
		x = 10;
	else if (x == 'B')
		x = 11;
	else if (x == 'C')
		x = 12;
	else if (x == 'D')
		x = 13;
	else if (x == 'E')
		x = 14;
	else if (x == 'F')
		x = 15;

	if (y == 'A')
		y = 10;
	else if (y == 'B')
		y = 11;
	else if (y == 'C')
		y= 12;
	else if (y == 'D')
		y = 13;
	else if (y == 'E')
		y = 14;
	else if (y == 'F')
		y = 15;

	if (x < y)
		cout << "<" << endl;
	else if (x > y)
		cout << ">" << endl;
	else
		cout << "=" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

int w,a,b;

int main(){
	cin>>w>>a>>b;
	if(a+w>=b&&b+w>=a) cout<<0<<endl;
	else cout<<max(b-a-w,a-b-w)<<endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}


func main() {
	num := nextLine()
	array := []int{}
	min := math.MaxInt64
	ret := -math.MaxInt64
	for i := 0; i < num; i++ {
		array = append(array, nextLine())
		if ret < array[i] - min {
			ret = array[i] - min
		}
		if array[i] < min {
			min  = array[i]
		}
	}

	fmt.Println(ret)
}



Measured memory_bytes: 9504
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 100 * 1000 + 47;


int A[MAX];
int B[MAX];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    
    FOR(i, 0, n)
        A[i] = 1;
    
    B[0] = 1;
    
    FOR(i, 0, m)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        --x, --y;
        if (B[x])B[y] = 1;
        A[x]--, A[y]++;
        if (!A[x])B[x] = 0;
    }
    int cnt = 0;
    FOR(i, 0, n)
        cnt += B[i];
    cout << cnt << endl;
    

}


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=3.14159265359;

int main() {
    int N, M;
    cin>>N>>M;
    vector<vector<int> > edge(N);
    int A, B;
    for(int i=0;i<M;++i){
        cin>>A>>B;
        A--;
        B--;
        edge[A].push_back(B);
        edge[B].push_back(A);
    }
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
    int ans[N];
    for(int i=0;i<N;++i){
        ans[i] = -1;
    }
    ans[0] = 0;
    que.push(mp(0, 0));
    pair<int, int> state;
    int node, dist;
    map<int, int> amap;
    while(!que.empty()){
        state = que.top();que.pop();
        node = state.se;
        dist = state.fi;
        if(amap[node]>0) continue;
        amap[node]++;
        for(int i=0;i<edge[node].size();++i){
            if(ans[edge[node][i]]!=-1) continue;
            ans[edge[node][i]] = node;
            que.push(mp(dist+1, edge[node][i]));
        }
    }
    bool ok = true;
    for(int i=0;i<N;++i){
        if(ans[i]==-1) ok = false;
    }
    if(ok){
        cout<<"Yes"<<endl;
        for(int i=1;i<N;++i){
            cout<<ans[i]+1<<endl;
        }
    }
    else cout<<"No"<<endl;
}



Measured memory_bytes: 15296
var heyas: List<Heya> = listOf()
var sirubes: MutableList<Int> = listOf<Int>().toMutableList()

fun main(args: Array<String>) {
    val line = readLine()!!.trim()
    val (heyaCount: Int, pathCount: Int) = line.split(" ").map {it.toInt()}

    heyas = (0..heyaCount-1).map {Heya(it + 1)}
    sirubes = (1..heyaCount-1).map {-1}.toMutableList()

    for (i in (0..pathCount-1)) {
        val line2 = readLine()!!.trim()
        val (heya1: Int, heya2: Int) = line2.split(" ").map {it.toInt()}
        heyas[heya1 - 1].paths.add(heya2)
        heyas[heya2 - 1].paths.add(heya1)
    }

    wfs()

    println("Yes")
    for (sirube in sirubes) {
        println(sirube)
    }
}


class Heya(val heyaNo: Int) {
    val paths: MutableList<Int> = mutableListOf()

    fun sirubeIndex(): Int {
        return heyaNo - 2
    }
}

fun wfs() {
    var prevHeyas: MutableList<Heya> = listOf(heyas[0]).toMutableList()

    while (true) {
        if (prevHeyas.isEmpty()) {
            break
        }

        val targetHeyas: List<Heya> = prevHeyas
        prevHeyas = mutableListOf()

        for (targetHeya in targetHeyas) {
            for (nextHeyaNo in targetHeya.paths) {
                if (nextHeyaNo != 1 && sirubes[nextHeyaNo - 2] == -1) {
                    sirubes[nextHeyaNo - 2] = targetHeya.heyaNo
                    prevHeyas.add(heyas[nextHeyaNo - 1])
                }
            }
        }
    }
}


Measured memory_bytes: 87396
# ALDS1_12_V Single Source Shortest Path I
import sys

n = int(input())
G = [[float('inf')] * n for _ in range(n)]
for i in range(n):
    ukvc = list(map(int, sys.stdin.readline().strip().split()))
    u = ukvc[0]
    k = ukvc[1]

    for j in range(k):
        G[u][ukvc[2 + 2 * j]] = ukvc[3 + 2 * j]

p = [n] * n  # 親を保存するリスト　親ノードとしてあり得ない n を初期リストとする
c = ['white'] * n # 最小経路木への接続チェック　white 未接続　black 接続済
d = [float('inf')] * n  # ノード i までの最小経路を保存するリスト
d[0] = 0  # 根への距離は0とする
p[0] = -1  # 根の親は -1 とする
u = 0  # 次のループで最小経路木につなげるノード

while 'white' in c:
    c[u] = 'black'

    v = None
    minpath = float('inf')
    for i in range(n):
        d[i] = min(d[i], d[u] + G[u][i])
        if (d[i] < minpath) & (c[i] == 'white'):
            minpath = d[i]
            v = i
            p[i] = u

    if v is None:
        break

    u = v

for i in range(n):
    print('{} {}'.format(i, d[i]))






Measured memory_bytes: 5832