akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	k := r.nextInt()

	s := make([]int, 0, 20)
	s = append(s, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)

	fmt.Fprintln(stdout, s[k-1])
}


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

class Program
{
    static void Main()
    {

        var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var a = A[0]; var b = A[1]; var c = A[2];
        var flag = false;

        foreach (var i in new int[] { 1, 2, 3 })
        {
            if (A[i % 3] == A[(i + 1) % 3] && A[(i + 1) % 3] != A[(i + 2) % 3])
            {
                flag = true;
            }
        }
        Console.WriteLine( flag ? "Yes":"No" );
    }
}



Measured memory_bytes: 13396
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int OFS = 8000, N = 2 * OFS;
int ab[N], ac[N], bc[N];
string a, b, c;

bool ok(char x, char y){
    return x == '?' || y == '?' || x == y;
}

bool checkab(int d){
    if (ab[d + OFS] == 1) return true;
    if (ab[d + OFS] == -1) return false;
    bool ret = true;
    REP(i,a.length()){
        int j = i - d;
        if (j < 0 || j >= b.length()) continue;
        if (!ok(a[i], b[j])) ret = false;
    }
    ab[d + OFS] = (ret ? 1 : -1);
    return ret;
}
bool checkac(int d){
    if (ac[d + OFS] == 1) return true;
    if (ac[d + OFS] == -1) return false;
    bool ret = true;
    REP(i,a.length()){
        int j = i - d;
        if (j < 0 || j >= c.length()) continue;
        if (!ok(a[i], c[j])) ret = false;
    }
    ac[d + OFS] = (ret ? 1 : -1);
    return ret;
}
bool checkbc(int d){
    if (bc[d + OFS] == 1) return true;
    if (bc[d + OFS] == -1) return false;
    bool ret = true;
    REP(i,b.length()){
        int j = i - d;
        if (j < 0 || j >= c.length()) continue;
        if (!ok(b[i], c[j])) ret = false;
    }
    bc[d + OFS] = (ret ? 1 : -1);
    return ret;
}

int main(void){
    cin >> a >> b >> c;
    int n = 2000;
    int ans = 3 * n;
    FOR(p,-2*n,2*n) FOR(q,-2*n,2*n){
        if (checkab(p) && checkac(q) && checkbc(q - p)){
            int l = min({0, p, q});
            int r = max({(int)a.length(), p + (int)b.length(), q + (int)c.length()});
            chmin(ans, r - l);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    Node[] nodes = new Node[N];
    for (int i = 0; i < N; i++) nodes[i] = new Node(i);
    for (int i = 0; i < N - 1; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      nodes[a].edges.add(nodes[b]);
      nodes[b].edges.add(nodes[a]);
    }

    List<Node> path = findPath(null, nodes[0], nodes[N - 1]);
    Collections.reverse(path);
    Node endBlack = path.get((path.size() - 1) / 2);
    Node endWhite = path.get((path.size() - 1) / 2 + 1);

    int countBlack = count(null, nodes[0], endWhite);
    int countWhite = count(null, nodes[N - 1], endBlack);

    if (countBlack > countWhite) {
      System.out.println("Fennec");
    } else {
      System.out.println("Snuke");
    }
  }

  private static List<Node> findPath(Node from, Node node, Node goal) {
    if (node == goal) {
      List<Node> path = new ArrayList<>();
      path.add(node);
      return path;
    }
    for (Node e : node.edges) {
      if (e != from) {
        List<Node> found = findPath(node, e, goal);
        if (found != null) {
          found.add(node);
          return found;
        }
      }
    }
    return null;
  }

  private static int count(Node from, Node node, Node end) {
    int count = 1;
    for (Node e : node.edges) if (e != from && e != end) count += count(node, e, end);
    return count;
  }

  static class Node {
    final int id;
    List<Node> edges = new ArrayList<>();

    Node(int id) {
      this.id = id;
    }
  }
}


Measured memory_bytes: 115752
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define SZ(x) ((int)((x).size()))

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

template<class TH>
void _dbg(const char* name, TH val){
    clog << name << ": " << val << endl;
}
template<class TH, class... TA>
void _dbg(const char* names, TH curr_val, TA... vals) {
    while(*names != ',') clog << *names++;
    clog << ": " << curr_val << ", ";
    _dbg(names+1, vals...);
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
    #define dbg_arr(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg(...)
    #define dbg_arr(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    int N;
    cin >> N;
    vector<LL> A(N+1);
    for (int i = 0; i <= N; i++) cin >> A[i];
    if (N == 0) {
        if (A[0] == 1) cout << 1 << "\n";
        else cout << -1 << "\n";
        return 0;
    }
    vector<LL> suff(N+1);
    suff[N] = A[N];
    for (int i = N-1; i >= 0; i--) suff[i] = A[i] + suff[i+1];
    LL res = 1;
    LL v = 1;
    for (int d = 1; d <= N; d++) {
        LL a = 2*(v-A[d-1]);
        LL b = suff[d];
        v = min(a, b);
        if (v <= 0 or (d == N and v < A[N])) {
            cout << -1 << "\n";
            return 0;
        }
        if (d == N) v = A[N];
        res += v;
    }
    cout << res << "\n";
}


Measured memory_bytes: 4760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
ll n,X;
cin >> n >> X;
ll x[n];
for (ll i = 0; i < n; i++) cin >> x[i];
ll y[n+1];
y[0] = 0;
for (ll i = 0; i < n; i++) y[i + 1] = x[i] % X;
ll ans = 0;
for (ll i = 1; i < n + 1; i++) ans = __gcd(ans, abs(X-x[i-1]));
cout << ans << endl;
}

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

#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)

#ifdef _DEBUG
#define DEBUG(x) cout << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#define INFILE freopen("input.txt", "r", stdin)
#else
#define DEBUG(x)
#define INFILE
#endif

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

template <class T> static constexpr T LL9_MOD = static_cast<T>(1000000009);
template <class T> static constexpr T LL7_MOD = static_cast<T>(1000000007);
template <class T> static constexpr T INF = static_cast<T>(1LL << 60);
template <class T> static constexpr T EPS = numeric_limits<T>::epsilon();
template <class T> static constexpr T PI = static_cast<T>(3.14159265358979323846264338327950288);

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
static void scan(vector<string>& v, bool isWord = true);
template <class T> inline bool chmax(T& a, T b);
template <class T> inline bool chmin(T& a, T b);
template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val);

ll dp[3001][3001];

int main(int argc, char* argv[]) {
  INFILE;

  string s, t;
  cin >> s >> t;

  int sl = s.size(), tl = t.size();

  REP(i, 1, sl + 1) {
    REP(j, 1, tl + 1) {
      chmax(dp[i][j], dp[i][j - 1]);
      chmax(dp[i][j], dp[i - 1][j]);
      chmax(dp[i][j], dp[i - 1][j - 1] + ll(s[i - 1] == t[j - 1]));
    }
  }

  string result;
  while (dp[sl][tl] != 0) {
    if (s[sl - 1] == t[tl - 1] && dp[sl - 1][tl - 1] == dp[sl][tl] - 1) {
      result.push_back(s[sl - 1]);
      sl--;
      tl--;
      continue;
    }

    dp[sl - 1][tl] == dp[sl][tl] ? sl-- : tl--;
  }

  reverse(ALL(result));
  cout << result << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[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 A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define bp __builtin_popcountll
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
int main() 
{
    FAST;
    ll n,a,b;
    cin >>  n >> a >> b;
    ll ans = b-1;
    ll d = n - a;
    ans = min(ans,d);
    ll temp = b - a;
    if((temp)%2==0)
    {
        temp = temp/2;
        ans = min(ans,temp);
    }
    temp = a - 1;
    ll new_b = b - temp;
    if((new_b-1)%2==0)
    {
        temp = temp + (new_b-1)/2;
        ans = min(ans,temp);
    }
    else
    {
        new_b--;
        temp = temp + 1 + (new_b-1)/2;
        ans = min(ans,temp);
    }
    temp = n - b;
    ll new_a = a + temp;
    if((n-new_a)%2==0)
    {
        temp = temp + (n-new_a)/2;
        ans = min(ans,temp);
    }
    else
    {
        new_a++;
        temp = temp + 1 + (n-new_a)/2;
        ans = min(ans,temp);
    }
    cout<<ans;
}





Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[8] = { 0,0,-1,1 };
ll dy[8] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

bool graph[101][101];
bool visit[101];
vector<ll> to[101010];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	init(n);
	vector<ll>deg(n);
	rep(i, m) {
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		deg[a]++;
		deg[b]++;
		unite(a, b);
	}
	rep(i, k) {
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	vector<ll>s(n);
	rep(i, n) {
		s[find(i)]++;
	}
	rep(i, n) {
		ll ans = s[find(i)] - deg[i] - 1;
		for (ll u : to[i]) {
			if (find(i) == find(u))ans--;
		}
		if (i == n - 1) {
			cout << ans;
		}
		else {
			cout << ans << " ";
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 9984
import sys
sys.setrecursionlimit(10**7)

N = int(input())
ad = [[] for _ in range(N)]
edge = []
for _ in range(N-1):
    a, b = map(int,input().split())
    a -= 1; b -= 1
    ad[a].append(b)
    ad[b].append(a)
    edge.append((a, b))

K = max(len(S) for S in ad)
d = dict()

def dfs(v=0, pv=-1, memo=-1):
    color = 0
    for nv in ad[v]:
        if nv == pv:
            continue
        if color == memo:
            color += 1
        d[(v, nv)] = color
        d[(nv, v)] = color
        dfs(nv, v, color)
        color += 1

dfs()

print(K)
for e in edge:
    print(d[e]+1)

Measured memory_bytes: 94440
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b) {
	return *(int *)a - *(int *)b;
}
int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	int stick[N];
	int i, len = 0;
	for (i = 0; i < N; i++) {
		int tmp;
		scanf("%d", &tmp);
		stick[i] = tmp;
	}
	qsort(stick, sizeof(stick) / sizeof(int), sizeof(int), asc);
	for (i = N - 1; i >= N - K; i--) {
		len += stick[i];
	}
	printf("%d\n", len);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
long long k,a,b,ans;
int main(){
    cin>>k>>a>>b;
    if(a-1>k || b<=a){
        cout<<1+k<<endl;
        return 0;
    }
    long long now=k-a+1;
    
    cout<<max(1+k,(now/2*(b-a)+now%2+a))<<endl;
    return 0;
}

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

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   	int N;
   	cin>>N;
   	set<string> S;
   	for(int i=0;i<N;i++)
   	{
   		string x;
   		cin>>x;
   		S.insert(x);
   	}
   	cout<<S.size()<<endl;
}

Measured memory_bytes: 19212
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b;
  ci(a>>b);
  if(a==b) co(2*a)
    else co(2*M(a,b)-1)
    }

Measured memory_bytes: 256
#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#ifdef DEBUG
	#include "debug.hpp"
#endif

using namespace std;

#define all(c) (c).begin(), (c).end()
#define traverse(c, it) for(auto it = (c).begin(); it != (c).end(); it++)
#define rep(i, N) for(int i = 0; i < (N); i++)
#define rep1(i, N) for(int i = 1; i <= (N); i++)
#define rep2(i, s, e) for(int i = (s); i <= (e); i++)
#define rep3(i, s, e, d) for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back


#ifdef DEBUG
	#define debug(x...) { dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals); }
	#define light_debug(x) { dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << "  " << #x << " = " << x << endl; dbg::light = 0; }
#else
	#define debug(x...)
	#define light_debug(x) 
#endif

template<typename T>
inline T& ckmin(T& a, T b) { return a = a > b ? b : a; }

template<typename T>
inline T& ckmax(T& a, T b) { return a = a < b ? b : a; }

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;


int main() {

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

	#ifdef DEBUG
		freopen("debug", "w", stderr);
	#endif
	
	string s; cin >> s;
	if(s.back() == 's') cout << s << "es\n";
	else cout << s << "s\n";

	#ifdef DEBUG
		dbg::dout << "\nExecution time: " << clock() << "ms\n";
	#endif

	return 0;
}


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

int main(){
	string S;
	cin >> S;
	int loop;
	for(loop=0;loop<(int)S.size();loop++){
		if(S.substr(loop,1)=="?")cout << "D";
		else cout << S.substr(loop,1);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int[] x = new int[4];	
		
		for(int i = 0; i < N; i++) {
			String a = sc.next();
			char b = a.charAt(0);
			if(b == 'P') {
				x[0] = 1;
			} else if(b == 'W') {
				x[1] = 1;
			} else if(b == 'G') {
				x[2] = 1;
			} else if(b == 'Y') {
				x[3] = 1;
			}
		}
		
		int count = 0;
		
		for(int i = 0; i < 4; i++) {
			if(x[i] == 1) {
				count++;
			}
		}
		if(count == 3) {
			System.out.println("Three");
		} else {
			System.out.println("Four");
		}
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<list>
#include<iomanip>
#include<cstring>
#include<sstream>
#define h 100
#define ll  long long
#define pb push_back
using namespace std;
int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  if(n>=400 && n<600)cout<<8<<endl;
  else if(n>=600 && n<800)cout<<7<<endl;
  else if(n>=800 && n<1000)cout<<6<<endl;
  else if(n>=1000 && n<1200)cout<<5<<endl;
  else if(n>=1200 && n<1400)cout<<4<<endl;
  else if(n>=1400 && n<1600)cout<<3<<endl;
  else if(n>=1600 && n<1800)cout<<2<<endl;
  else cout<<1<<endl;
  return 0;
} 


Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	
	public static void main(String[] args) throws IOException {
		new Main().exec();
	}
	

	public void exec() throws IOException {
		int[] lcs = new int[1000000];
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		int q = Integer.parseInt(br.readLine());
		String x,y;
		int lenx,leny;
		char x0,y0;
		for(int i=0; i<q; i++) {
			x = br.readLine();
			y = br.readLine();
			lenx = x.length();
			leny = y.length();
			x0=x.charAt(0);
			y0=y.charAt(0);
			lcs[0] = (x0==y0) ? 1 : 0;
			for(int x2=1; x2<lenx; x2++){
				lcs[x2] = (lcs[x2-1]==1 || x.charAt(x2)==y.charAt(0)) ? 1 : 0;
			}
			for(int y2=1; y2<leny; y2++){
				lcs[y2*lenx] = (lcs[(y2-1)*lenx]==1 || x.charAt(0)==y.charAt(y2)) ? 1 : 0;
			}
			for(int x2=1; x2<lenx; x2++) {
				for(int y2=1; y2<leny; y2++) {
					if(x.charAt(x2)==y.charAt(y2)){
						lcs[x2+y2*lenx] = lcs[(x2-1)+(y2-1)*lenx]+1;
					}else{
						lcs[x2+y2*lenx] = Math.max(lcs[x2+(y2-1)*lenx],lcs[(x2-1)+y2*lenx]);
					}
				}
			}
			out.println(lcs[(lenx-1)+(leny-1)*lenx]);
		}
		out.flush();
	}
}

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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

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

	int n, m;
	cin >> n >> m;
	vector<ll> x(n), y(m);
	loop(n) cin >> x[i];
	loop(m) cin >> y[i];
	ll ans = 0, sum = 0;
	loop(n - 1) {
		ans += (x[i + 1] - x[i]) * (i + 1) * (n - i - 1);
		ans %= mod;
	}
	loop(m - 1) {
		sum += (y[i + 1] - y[i]) * (i + 1) * (m - i - 1);
		sum %= mod;
	}
	ans *= sum;
	ans %= mod;
	cout << ans << endl;
	return 0;
}
/*

*/


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <algorithm>
using namespace std;

int N;
int t[110], v[110];
double res;
int am[110];
int n2;
int idx[110];
queue<int> q;
int val[110];

bool cmp(int aa, int bb)
{
	if(am[aa] < am[bb])
		return true;
	else
		return false;
}

void solve()
{
	int i;
	n2 = N+1;
	//for(i=N; i>=1; i--){
	//	t[i] = t[i-1];
	//}
	//t[0] = 0;
	am[0] = 0;
	am[N] = 0;
	for(i=1; i<N; i++){
		if(v[i-1]<v[i])	
			am[i] = v[i-1];
		else
			am[i] = v[i];
	}
	for(i=0; i<n2; i++)
		idx[i] = i;
	sort(idx, idx+n2, cmp);
	for(i=0; i<n2; i++){
		q.push(idx[i]);
		val[idx[i]] = am[idx[i]];
	}
	int ii;
	int tmp;
	while(!q.empty() ){
		ii = q.front() ;
		q.pop() ;
		if(ii==0){
			tmp = v[0];
			if(v[0]>t[0])
				tmp = t[0];
			if(tmp < val[1]){
				val[1] = tmp;
				q.push(1) ;
			}
		}
		else if(ii==n2-1){
			tmp = v[ii-1];
			if(v[ii-1]>t[ii-1])
				tmp = t[ii-1];
			if(tmp < val[n2-2]){
				val[n2-2] = tmp;
				q.push(n2-2);
			}
		}
		else{
			if(val[ii-1]>val[ii]){
				if(val[ii]+t[ii-1] >= v[ii-1]){
					tmp = v[ii-1];
				}
				else{
					tmp = val[ii] + t[ii-1];
				}
				if(tmp < val[ii-1]){
					val[ii-1] = tmp;
					q.push(ii-1);
				}
			}
			if(val[ii+1]>val[ii]){
				if(val[ii]+t[ii] >= v[ii]){
					tmp = v[ii];
				}
				else{
					tmp = val[ii] + t[ii];
				}
				if(tmp < val[ii+1]){
					val[ii+1] = tmp;
					q.push(ii+1);
				}
			}
		}
	}
	res = 0;
	double v1, v2;
	double tt;//double
	double d, d2;
	for(i=0; i<N; i++){
		v1 = min(val[i], val[i+1]);
		v2 = max(val[i], val[i+1]);
		tt = t[i];
		d = v2 + (tt-(v2-v1))/2;
		if(d > v[i]){
			d2 = (v[i]+v2)*(v[i]-v2)/2 + (v[i]+v1)*(v[i]-v1)/2 
					+ (tt-(v[i]-v2)-(v[i]-v1) )*v[i];
		}
		else{
			d2 = (d+v2)*(d-v2)/2 + (d+v1)*(d-v1)/2;
		}
		res += d2;
	}
	printf("%.6f\n", res);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int i;
	scanf("%d", &N);
	for(i=0; i<N; i++)
		scanf("%d", &t[i]);
	for(i=0; i<N; i++)
		scanf("%d", &v[i]);
	solve();
	return 0;
}

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

int main()
{
    int s,h,a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
        s=a*b;
        h=c*d;
        if(s<=h)
            printf("%d\n",h);
        else
            printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 128
/*
 * kadai3_2
 * kamecha
 */
#include<stdio.h>

int main(void){
    int num;
    scanf("%d", &num);
    /*
     * 1の位だけ取り出して場合分けする
     */
    int n_1 = num%10;
    switch(n_1){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            puts("hon");
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            puts("pon");
            break;
        case 3:
            puts("bon");
            break;
        default:
            break;
    }
    return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>

int main(){
    int n,q;
    scanf("%d",&n);
    for(q=1;q<=n;q++){
        int h,i=0,j=0;
        int a[11],b[12],c[12];
        int w;
        for(w=0;w<=9;w++)scanf("%d",&a[w]);
        b[0]=0,c[0]=0;
        
        int mark=0;
        for(h=0;h<=9;h++){
            
            int max=b[i],min=c[j];
            if(b[i]<c[j]){
                max=c[j];
                min=b[i];
            }
            if(a[h]<min){
                mark=1;
            }else if(a[h]>max && max==b[i]){
                i++;
                b[i]=a[h];
            }else if(a[h]>max && max==c[j]){
                j++;
                c[j]=a[h];
            }else if(min==b[i]){
                i++;
                b[i]=a[h];
            }else{
                j++;
                c[j]=a[h];
            }
        }
        
        if(mark==0)printf("YES\n");
        else printf("NO\n");
    }
    return 0;
    
}

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

int main(){

  int S,h,m,s;

  cin >> S;
  h = S / 3600;
  m = (S - h * 3600) / 60;
  s = (S - h * 3600) - m * 60;

  cout << h << ":" << m << ":" << s << endl;

  return 0;
}

Measured memory_bytes: 1168
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> cnt(n+1);
    ll ans = 0;
    rep(i,1,n+1){
        for(int j = i; j <= n; j+=i){
            cnt[j]++;
        }
        ans += i * cnt[i];
    }

    cout << ans << endl;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int left = (a + b);
  int right = (c + d);
  if(left < right)
    cout << "Right" << endl;
  else if(left > right)
    cout << "Left" << endl;
  else
    cout << "Balanced" << endl;
}


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

const int INF=(int)1e9;

int main() {
	int n;
	cin >> n;
	vector<string> S(n);
	for(int i=0; i<n; i++) cin >> S[i];
	
	map<char,int> m,mm[55];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < S[i].length(); j++) {
			m[S[i][j]]++;
			mm[i][S[i][j]]++;
		}
	}
	vector<char> chs;
	for (auto itr = m.begin(); itr != m.end(); itr++) {
		if(itr->second!=1 || n==1) chs.push_back(itr->first);
	}
	map<char,int> ansm;
	for(int i=0; i<chs.size(); i++) ansm[chs[i]]=INF;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < chs.size(); j++) {
			ansm[chs[j]] = min(ansm[chs[j]],mm[i][chs[j]]);
		}
	}
	for (auto itr = ansm.begin(); itr != ansm.end(); itr++) {
		//cout << itr->first <<" "<< itr->second << endl;
		for (int i = 0; i < itr->second; i++) {
			cout << itr->first;
		}
	}
	cout << endl;
}

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

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  vector<set<int>> vec(n);
  rep(i, m){
    int a, b;
    cin >> a >> b; 
    a--;
    b--;
    vec[a].insert(b);
    vec[b].insert(a);
    uf.merge(a, b);
  }
  rep(i, k){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if(uf.issame(a, b)){
      vec[a].insert(b);
      vec[b].insert(a);
    }
  }
  rep(i, n){
    cout << uf.size(i)-vec[i].size()-1 << " ";
  }
  return 0;
}

Measured memory_bytes: 27016
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli t;
    cin >> t;
    vector<lli> v;
    lli x = 0;
    for1(i, 0, t)
    {
        lli a;
        cin >> a;
        v.pb(a);
        x ^= a;
    }
    for1(i, 0, t)
    {
        lli y = x ^ v[i];
        cout << y << " ";
    }
    cout << endl;
}

Measured memory_bytes: 5328
package main

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

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	input := bufio.NewReader(os.Stdin)

	var N, K int
	fmt.Fscanf(input, "%d%d\n", &N, &K)
	A := make([]int, N)
	for i := range A {
		fmt.Fscanf(input, "%d", &A[i])
	}

	var sum int
	for i := range A {
		sum += A[i]
	}

	candidates := make(map[int]bool)
	for i := 1; i*i <= sum; i++ {
		if sum%i == 0 {
			candidates[i] = true
			candidates[sum/i] = true
		}
	}
	// fmt.Println(candidates)

	var ans int
	for c := range candidates {
		r := make([]int, N)
		for i := range A {
			r[i] = A[i] % c
		}
		sort.Ints(r)
		// fmt.Println(r)

		s1 := make([]int, N+1)
		for i := 1; i <= len(r); i++ {
			s1[i] = s1[i-1] + r[i-1]
		}

		s2 := make([]int, N+1)
		for i := 1; i <= len(r); i++ {
			s2[i] = s2[i-1] + (c - r[i-1])
		}
		// fmt.Println(c, s1, s2)

		for i := 0; i < N; i++ {
			a := s1[i]
			b := s2[N] - s2[i]
			if a%c == b%c {
				if max(a, b) <= K {
					ans = max(ans, c)
				}
			}
		}
	}
	fmt.Println(ans)
}


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

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double h = 360 / 12 * H + 30.0 / 60 * M;
  double m = 360 / 60 * M;
  double r = (h - m) * M_PI / 180;
  double ans = sqrt(A * A + B * B - 2 * A * B * cos(r));
  cout << fixed << setprecision(9) << ans << "\n";
}

Measured memory_bytes: 4156
abc = sorted(list(map(int, input().split())))

ans = 0
ans += abc[2]-abc[1]
abc[0] += abc[2]-abc[1]
abc[1] += abc[2]-abc[1]

if (abc[2]-abc[0])%2 == 1:
  abc[1] += 1
  abc[2] += 1
  ans += 1

ans += (abc[2]-abc[0])//2
print(ans)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
int n,k;
int a=1;
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        if(a*2-a<k)
        {
            a=2*a;
        }
        else
        {
            a=a+k;
        }
    }
    printf("%d",a);
    
    
  
   
    
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#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(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, s; cin >> n >> s;

	int sq = ceil(sqrt(n));

	int ans = -1;

	if (n == s) {
		ans = n + 1;
	}

	if (ans == -1) {
		rep(b, 2, sq + 1) {
			int m = n;
			int res = 0;
			while (m) {
				res += m % b;
				m /= b;
			}
			if (res == s) {
				ans = b;
				break;
			}
		}
	}

	if (ans == -1) {
		for (int p = sq; p >= 1; p--) {
			int d = n / p;
			dump(p, d);
			if (p >= d)continue;
			int r = n % d;
			int A = p + p * d + r - s;
			int B = p;
			int b = A / B;
			int q = (d - b) * p + r;
			if (A % B == 0 && q < b && q >= 0) {
				dump(p, d, q, p + q, b);
				ans = b;
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    bool solve(vector<int>& A, vector<int>& B) {
        vector<pair<int,int>> P;
        int n = A.size();
        for (int i = 0; i < n; ++i) {
            P.emplace_back(B[i], A[i]);
        }
        sort(P.begin(), P.end());

        long long t = 0;
        for (auto& p : P) {
            // cout << t << " " << p.first << " " << p.second << endl;
            if (t + p.second > p.first) {
                return false;
            }
            t += p.second;
        }

        return true;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> A(n);
    vector<int> B(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i] >> B[i];
    }

    Solution sol;
    if (sol.solve(A, B)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }


    return 0;
}

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

void shiki(int,long long,long long);

long long ans;

string s;

int main(){
    cin >> s;
    shiki(0,0,0);
    cout << ans << endl;
}

void shiki(int i,long long sum,long long next){
    long long num = (s.at(i) - '0') + next;
    if(i == s.size()-1){
        ans += num + sum;
        return;
    }
    shiki(i+1,sum+num,0);
    shiki(i+1,sum,num*10);

    return;
}

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

using namespace std;

int main()
{
    int n,k;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;++i) {
        cin>>a[i]>>b[i]>>c[i];
    }
    int dp[n][3];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i=1;i<n;++i) {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }
    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){

    int a, b, h, m, hd;
    long double md, ans, x;
    scanf("%d%d%d%d",&a,&b,&h,&m);

    hd = 6 * m;
    md = 0.5 * m + 30.0 * h;
    x = (hd-md) * M_PI / 180.0;

    ans = a*a+b*b-2*a*b*cos(x);
    printf("%.10f",sqrt(ans));

    return 0;
}

Measured memory_bytes: 2596
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int A, B;
  int tans = 0;
  int ans = -10001;

  cin >> A >> B;

  tans  =  A + B;
  ans =  max(tans, ans);
  tans  = A - B;
  ans = max(tans, ans);
  tans  = A * B;
  ans = max(tans, ans);

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int w, h, x, y, r;
	scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);
	if (((x + r > w) || (y + r > h)) || ((x - r < 0) || (y - r < 0)))
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll n,f=0,cnt=2;
	cin>>n;
	set<ll> v;
	v.insert(n);
	while(1)
	{
		if(n%2==0)
		{
			n=n/2;
		}
		else
		{
			n=3*n+1;
		}
		if(v.count(n)==1)
		{
			f=1;
			break;
		}
		cnt++;
		v.insert(n);
	}
	//for (auto const& i: v) {
		//std::cout << i << " ";
	//}
	//cout<<endl<<"cnt "
	cout<<cnt;
}

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

const int maxn = 1e5+5;
int v[maxn],h[maxn];
int n,m,ans=0;
int main(){
	cin >> n >> m;
	for (int i=1;i<=n;i++){
		cin >> h[i];	
	}
	for (int i=1;i<=m;i++){
		int x,y;
		cin >> x >> y;
		if (h[x] >= h[y]) v[y] = 1;
		if (h[y] >= h[x]) v[x] = 1;
	}
	for (int i=1;i<=n;i++){
		if (!v[i]) ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 4424
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull  unsigned long long
#define vll  vector <long long>
#define pll pair <long long,long long>
#define f first
#define s second
#define up upper_bound
#define lp lower_bound
#define pq priority_queue
#define inf 1e10
#define minf -1e10
#define pi 3.14159265
#define mod 300000000000000000
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);
int main()
{
    ll n;
    cin>>n;
    vll a,b,c;
    ll dp[4];
    for(ll i=0;i<n;i++)
    {
        ll num,num3,num2;
        cin>>num>>num2>>num3;
        a.pb(num);
        b.pb(num2);
        c.pb(num3);
    }
    dp[1]=a[0],dp[2]=b[0],dp[3]=c[0];
    for(ll i=1;i<n;i++)
    {
        ll p=dp[1],q=dp[2],r=dp[3];
        dp[1]=max(q,r)+a[i];
        dp[2]=max(p,r)+b[i];
        dp[3]=max(p,q)+c[i];
    }
    cout<<max(dp[1],max(dp[2],dp[3]));

}


Measured memory_bytes: 2912
//hi
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long int LL;
int main(void){
    string a="CODEFESTIVAL2016";
    string b;
    cin>>b;
    int cnt=0;
    for(int i=0;i<a.length();i++)
		if(a[i]!=b[i]) cnt++;
	printf("%d\n",cnt);
    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(),m=sc.nextInt();
    int[] x=new int[m],d=new int[m-1];
    for(int i=0;i<m;i++)x[i]=sc.nextInt();
    Arrays.sort(x);
    for(int i=0;i<m-1;i++)d[i]=x[i+1]-x[i];
    Arrays.sort(d);
    if(n>=m) {
    	System.out.println(0);
    }else {
    	int j=m-2;
    	int res=x[m-1]-x[0];
    	for(int i=0;i<n-1;i++) {
    		//System.out.println(res);
    		res-=d[j];
    		j--;
    	}
    	System.out.println(res);
    }
  }
}


Measured memory_bytes: 48372
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int h, w;
char s[100][100];
int dp[100][100];

int rec(int i, int j) {
  if (dp[i][j] != -1) return dp[i][j];
  int res = 1e9;
  if (s[i][j] == '#') {
    if (i) {
      res = min(res, rec(i - 1, j) + (s[i - 1][j] != s[i][j]));
    }
    if (j) {
      res = min(res, rec(i, j - 1) + (s[i][j - 1] != s[i][j]));
    }
  } else {
    if (i) {
      res = min(res, rec(i - 1, j));
    }
    if (j) {
      res = min(res, rec(i, j - 1));
    }
  }
  return dp[i][j] = res;
}

int main() {
  cin >> h >> w;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      dp[i][j] = -1;
    }
  }
  dp[0][0] = (s[0][0] == '#');
  cout << rec(h - 1, w - 1) << endl;
  return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())

base=M//N
li=[]


for i in range(1,int(pow(M,1/2))+1):
    if i<=base and M%i==0:
        li.append(i)
    if M%i==0 and M//i<=base:
        li.append(M//i)

print(max(li))

Measured memory_bytes: 3060
package main

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

func solve() {
	n := getInt()
	as := getIntSlice(n)

	cSum := make([]int, n+1)
	m := make(map[int]int)
	m[0]++
	for i := 0; i < n; i++ {
		cSum[i+1] = cSum[i] + as[i]
		m[cSum[i+1]]++
	}

	ans := 0
	for _, v := range m {
		ans += v * (v - 1) / 2
	}
	puts(ans)
}

// -----------------------------------------

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// scanner.Buffer(make([]byte, buf), buf)
	scanner.Split(bufio.ScanWords)
	solve()
	writer.Flush()
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}

func puts(a ...interface{}) {
	if _, err := fmt.Fprintln(writer, a...); err != nil {
		panic(err)
	}
}


Measured memory_bytes: 14976