akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  int s;
  vector<int> vec(M*2);
  for (int i=0; i<(M*2); i++) {
    cin >> s;
    vec.at(i)=s;
  }
  for (int i=1; i<=N; i++) {
    int counter=0;
    for (int j=0; j<M*2; j++) {
      if (vec.at(j)==i) {
        counter++;
      }
    }
    cout << counter << endl;
  }
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef struct {
  int no;
  double BMI,abs;
}P;
int main(){
  int n,a,b,c;
  while(1){
    cin >> n;
    if(n==0)break;
    P temp;
    P sets[n];
    for(int i=0;i<n;i++){
      cin >> sets[i].no >> b >> c;

      sets[i].BMI=double(c)/((double)(b)/100.0*(double)(b)/100.0);
      if(sets[i].BMI<=22){
	sets[i].abs=22-sets[i].BMI;
      }else{
	sets[i].abs=sets[i].BMI-22;
      }
    }
    for(int i=0;i<n-1;i++){
      for(int j=n-1;j>i;j--){
	if(sets[j].abs<sets[j-1].abs){
	  temp=sets[j];
	  sets[j]=sets[j-1];
	  sets[j-1]=temp;
	}
      }
    }
    for(int i=0;i<n-1;i++){
      for(int j=n-1;j>i;j--){
	if(sets[j].abs==sets[j-1].abs && sets[j].no<sets[j-1].no){
	  temp=sets[j];
	  sets[j]=sets[j-1];
	  sets[j-1]=temp;
	}
      }
    }
    cout << sets[0].no << endl;
  }
}

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

int main(){// a + b \geq a xor b より尺取法が使える。
  int N;
  cin >> N;

  vector<int64_t> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }

  int64_t ans= 0;
  int64_t right= 0;
  int64_t sum_LR= 0;
  int64_t xor_LR= 0;
  for(int64_t left=0; left<N; left++){  
    while(right < N && sum_LR+ data.at(right)==(xor_LR^ data.at(right))){/* ビット演算の優先順位が低いので()をつけないとバグる */
      sum_LR+= data.at(right);
      xor_LR^= data.at(right);
      right++;
    }
    ans+= right- left;

    if(right==left){ right++; }
    else{
      sum_LR-= data.at(left);
      xor_LR^= data.at(left);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <map>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    int n; cin >> n;
    map<string, int> count;
    REP(i, n) {
        string s; cin >> s;
        count[s]++;
    }

    int maxi = 0;
    for (auto i : count)
        maxi = max(maxi, i.second);

    for (auto i : count)
        if (i.second == maxi)
            cout << i.first << '\n';
    return 0;
}


Measured memory_bytes: 23808
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
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;}

int main(){
  ll x; cin >> x;
  ll p = 100, step = 0;
  while (p < x) {
    p += p / 100;
    step++;
  }
  cout << step << endl;
  return 0;
}


Measured memory_bytes: 3604
if __name__ == '__main__':
    N, T = map(int, input().split())
    C = []
    for i in range(N):
        c, t = map(int, input().split())
        if t <= T:
            C.append(c) 
    if len(C) == 0:
        print('TLE')
    else:
        C.sort()
        print(C[0])

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int n[5];
  for(int i=0;i<5;i++)
    cin >> n[i];
  sort(n,n+5,greater<int>());
  for(int i=0;i<5;i++){
    cout << n[i];
    if(i==4) break;
    cout << ' ';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1180
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>

class TaskC {
public:
	void solve(std::istream& in, std::ostream& out);
};

void TaskC::solve(std::istream& in, std::ostream& out){
    int n;
    in >> n;
    std::vector<int> a;
    for(int i = 0; i<n; ++i){
        int x;
        in >> x;
        a.insert(i%2 ? a.begin() : a.begin() + i, x);
    }
    if(n%2) std::reverse(a.begin(),a.end());
    for(int i = 0; i<n; ++i){
        out << a[i] <<" ";
    }
};

int main() {
	TaskC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Long, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            long key = sc.nextInt();
            if(map.containsKey(key)) {
                map.put(key, map.get(key) + 1);
            }else {
                map.put(key, 1);
            }
        }
        List<Entry<Long, Integer>> list = new ArrayList<Entry<Long, Integer>>(map.entrySet());
        Collections.sort(list, new Comparator<Entry<Long, Integer>>() {
            public int compare(Entry<Long, Integer> obj1, Entry<Long, Integer> obj2) {
                return obj2.getKey().compareTo(obj1.getKey());
            }
        });
        long tmp = 0l;
        for (int i = 0; i < list.size(); i++) {
            int value = list.get(i).getValue();
            long key = list.get(i).getKey();
            if(value >= 4) {
                if(tmp != 0l) {
                    System.out.println(tmp * key);
                } else {
                    System.out.println(key * key);
                }
                return;
            } else if(value >= 2) {
                if(tmp != 0l) {
                    System.out.println(tmp * key);
                    return;
                } else {
                    tmp = key;
                }
            }
        }
        System.out.println(0);
    }
}


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

struct UnionFind {
  vector<int> par;
  UnionFind(int N) : par(N) {
    for(int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }
};

int main() {
  int N, M;
  cin >> N >> M;

  vector< pair<int, int> > side(M);
  for (int i = 0; i < M; i++) {
    int s, e;
    cin >> s >> e;
    side[i] = make_pair(s, e);
  }

  int result = 0;
  for (int i = 0; i < M; i++) {
    UnionFind tree(N);
    for (int j = 0; j < M; j++) {
      if (i == j) continue;
      tree.unite(side[j].first - 1, side[j].second - 1);
    }
    if (!(tree.same(side[i].first - 1, side[i].second - 1))) result++;
  }

  cout << result << '\n';
}


Measured memory_bytes: 256
using System;


namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int a = int.Parse(str);

            Console.WriteLine(a/3600 + ":" + (a%3600)/60 + ":" + a%60);
        }
    }
}

Measured memory_bytes: 9104
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val list = readLine()!!.split(" ").map { it.toInt() }
    val minList = mutableListOf(list[0])
    var ans = 1
    for(i in (1..list.lastIndex)) {
        if(minList.last()!! >= list[i]) {
            ans++
            minList.add(list[i])
        } else {
            minList.add(minList.last()!!)
        }
    }
    println(ans)
}


Measured memory_bytes: 82456
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int64_t K, N;
  cin >> K >> N;
  
  vector<int64_t> dists;
  dists.reserve(N);
  int64_t pre, start;
  cin >> pre;
  start = pre;
  for (size_t n = 1; n < N; ++n) {
    int64_t A;
    cin >> A;
    dists.push_back(A - pre);
    pre = A;
  }
  dists.push_back((K - pre) + start);
  int64_t rem = *max_element(dists.begin(), dists.end());
  
  cout << (K - rem) << endl;
  
  return 0;
}


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

vector<int>to[100010],co[100010],ans;

void dfs(int v){
    rep(i,to[v].size()){
        int u=to[v][i];
        int w=co[v][i];
        if(ans[u]!=-1)continue;
        ans[u]=(ans[v]+w)%2;
        dfs(u);
    }
}

int main(){
    int n;
    cin>>n;
    rep(i,n-1){
        int u,v,w; cin>>u>>v>>w;
        u--; v--;
        to[u].push_back(v);
        to[v].push_back(u);
        co[u].push_back(w);
        co[v].push_back(w);
    }
    ans.resize(n,-1);
    ans[0]=0;
    dfs(0);
    rep(i,n)cout<<ans[i]<<endl;
    return 0;
}

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

namespace ConsoleApp1
{
    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var s = Read();
            Range(1, s.Length + 1).Where(x => x % 2 != 0).ToList().ForEach(x => Console.Write(s[x - 1]));
        }

        public static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        public static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        public static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        public static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static int ReadInt()
        {
            return int.Parse(Read());
        }

        public static long ReadLong()
        {
            return long.Parse(Read());
        }

        public static IList<string> ReadSplit()
        {
            return Read().Split().ToList();
        }

        public static IList<int> ReadSplitInt()
        {
            return Read().Split().Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 13396
N,K = [int(x) for x in input().split(' ')]

p = 0
v = 1.0/N
for i in range(1,N+1):
  #print(i)
  if i < K:
    s = i
    c = 0
    while s < K:
      s = s * 2
      #print('/',s)
      c += 1
    #print('c',c)
    p += v * pow(0.5,c)
  else:
    p += v
    
print(p)

Measured memory_bytes: 2940
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias Pair = Tuple!(long, "begin", long, "end");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto s = sread();
    if(s.remove_before || s.remove_bitween)
        writeln("YES");
    else
        writeln("NO");

}

bool remove_before(string s)
{
    auto test = s[$ - 7 .. $];
    // writeln(test);
    if (test == "keyence")
        return true;

    return false;
}

bool remove_bitween(string s)
{
    auto lim = iota(1, 8);
    foreach (i; lim)
    {
        auto test = s[0 .. i] ~ s[$ - "keyence".length + i .. $];
        // test.writeln();
        if(test == "keyence")
            return true;
    }
    return false;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a,b,c;
		for(int i=0; i<n; i++){
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();	
			if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a) System.out.println("YES");
            else System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    ves s(N); rep(i,N) cin >> s[i];
    int cnta = 0;
    int cntb = 0;
    int cntab = 0;
    int cntAB = 0;
    rep(i,N) {
        rep(j,s[i].size()-1) if(s[i][j] == 'A' and s[i][j+1] == 'B') cntAB++;
        if(s[i][0] == 'B' and s[i][s[i].size()-1] == 'A') cntab++;
        else if(s[i][0] == 'B') cntb++;
        else if(s[i][s[i].size()-1] == 'A') cnta++;
    }
    int ans = cntAB;
    if(cntab == 0) { cout << ans + min(cnta, cntb) << endl; return 0; }
    if(cntab > 1) { ans += cntab - 1; cntab = 1; }

    if(cnta == 0 and cntb == 0) { cout << ans << endl; return 0; }
    if(cnta == 0) { cout << ans + 1 << endl; return 0; }
    if(cntb == 0) {cout << ans + 1 << endl; return 0; }

    if(cnta > 0 and cntb > 0 and cntab == 1) {
        ans += 2; cnta--; cntb--; cntab == 0; 
    }

    ans += min(cnta,cntb);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;


void ABC141E()
{
	int N;
	cin >> N;
	string S;
	cin >> S;

	vector<vector<int> > dp(N,vector<int>(N));
	for (int i = 0; i < N; ++i)
	{
		dp[i][N - 1] = S[i] == S[N - 1] ? 1 : 0;
	}
	for (int j = N - 2; j > 0; --j)
	{
		for (int i = 0; i <= j; ++i)
		{
			dp[i][j] = S[i] == S[j] ? dp[i + 1][j + 1] + 1 : 0;
		}
	}

	int ct = 0;
	for (int i = 0; i < N; ++i)
	{
		for (int j = i; j < N; ++j)
		{
			ct = max(ct, min(dp[i][j], j - i));
		}
	}
	cout << ct << endl;
}

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

Measured memory_bytes: 98176
#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb push_back
#define ii pair<int,int>
#define ppb pop_back
#define orta ((bas+son)>>1)
#define st first
#define nd second
#define ll long long
#define N 200005
#define inf 2000000005
#define MOD 1000000007
#define LOG 20
#define EPS 0.000000001
#define M 305
using namespace std;

int n;
int pre[N];
string s;

int main() {

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

	cin>>n;
	cin>>s;
	int mn=0;
	for(int i=1;i<=n;i++) {
		pre[i]=pre[i-1]+(s[i-1]=='(')-(s[i-1]==')');
		mn=min(mn,pre[i]);
	}
	for(int i=1;i<=-mn;i++) cout<<"(";
	pre[n]-=mn;
	cout<<s;
	for(int i=1;i<=pre[n];i++)
		cout<<")";

}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

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

	if(N%2==0){
		cout<<N<<endl;
	}else{
		cout<<2*N<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
for i in range(N - 1, 0, -1):
    if H[i] >= H[i - 1]:
        continue
    H[i - 1] -= 1
    if H[i] >= H[i - 1]:
        continue
    print('No')
    exit()
print('Yes')


Measured memory_bytes: 14224
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N = I()
xyh = []
for i in range(N):
    x, y, h = LI()
    xyh.append([x,y,h])


for i in range(100+1):
    for j in range(100+1):
        cx, cy = i, j
        H = []
        for item in xyh:
            #  print(item)
            if item[2] == 0:
                continue

            new_H = max(item[2] + abs(item[0] - cx) + abs(item[1] - cy), 0)
            H.append(new_H)
        else:
            if len(set(H)) == 1:
                center_H = H[0]
                H = []
                for item in xyh:
                    if item[2] == 0:
                        # 0の場合にも正しいか判定する
                        ch = abs(item[0] - cx) + abs(item[1] - cy)
                        if ch < center_H:
                            break
                else:
                    print(i, j, center_H)
                    exit()


Measured memory_bytes: 71276
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  };
  ($e:expr => $i:expr; $t:ty) => {
    (0..$i).map(|_| $e.get::<$t>()).collect::<Vec<$t>>()
  };
  ($e:expr => $row:expr, $col:expr; $t:ty) => {
    (0..$i).map(|_| scan!($e => $col; $t)).collect::<Vec<$t>>()
  }
}

struct Scanner<R: Read> {
  reader: R
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader: reader }
  }
  fn safe_get<T: FromStr>(&mut self) -> Option<T> {
    let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
      .skip_while(|c| c.is_whitespace())
      .take_while(|c| !c.is_whitespace())
      .collect::<String>();
    if token.is_empty() { None } else { token.parse().ok() }
  }
  fn get<T: FromStr>(&mut self) -> T {
    if let Some(v) = self.safe_get() { v } else {
      writeln!(stderr(), "Terminated with EOF").unwrap();
      std::process::exit(0);
    }
  }
}

trait Writable {
  fn write(&self, sep: &'static str) -> String;
}

impl<T: ToString> Writable for Vec<T> {
  fn write(&self, sep: &'static str) -> String {
    self.iter().map(|e| e.to_string()).collect::<Vec<String>>().join(sep)
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  let mut s = scan!(sc; String)
    .as_bytes()
    .to_vec();
  let l = s.len();
  s.sort();
  s.dedup();
  println!("{}", if l == s.len() { "yes" } else { "no" });
}


Measured memory_bytes: 4352
// input macro
// ref: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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 mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

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

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

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

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

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

fn gcd(a: usize, b: usize) -> usize {
    if a%b == 0 {
        return b;
    }
    else {
        return gcd(b, a%b);
    }
}

fn rec(a: usize, b: usize) -> usize {
    if gcd(a,b) == b {
        return (2 * (a/b) - 1) * b;
    }
    else {
        return 2 * (a/b) * b + rec(b, a - (a/b)*b); 
    }
}

#[allow(unused_mut)]
fn main() {
    input!(
        n: usize,
        x: usize,
    );
    let a = std::cmp::max(x, n-x);
    let b = std::cmp::min(x, n-x);

    println!("{}", a+b+rec(a,b));
}


Measured memory_bytes: 4352
N = int(input())
A = list(map(int, input().split()))
a0 = 0
for i, a in enumerate(A):
    if i%2==0:
        a0 += a
    else:
        a0 -= a
a0 //= 2
Ans = [a0*2]
for a in A[:-1]:
    a_ = a - a0
    Ans.append(a_*2)
    a0 = a_
print(*Ans)


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

using namespace std;

typedef long long llint;

int main() {
  int n;
  cin >> n;
  vector<llint> a(n);
  bool ng = false;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) ng = true;
  }
  if (ng) {
    cout << 0 << endl;
    return 0;
  }
  llint ans = 1;
  llint p = 1e18;
  for (int i = 0; i < n; i++) {
    if (ans <= p / a[i]) {
      ans *= a[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4044
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(x => long.Parse(x) - 1).ToArray();
        var counts = new long[n];
        for (int i = 0; i < a.Length; i++)
        {
            counts[a[i]]++;
        }
        long res = 0;
        for (int i = 0; i < a.Length; i++)
        {
            res += counts[i] * (counts[i] - 1) / 2;
        }
        for (int i = 0; i < a.Length; i++)
        {
            res -= counts[a[i]] * (counts[a[i]] - 1) / 2;
            counts[a[i]]--;
            res += counts[a[i]] * (counts[a[i]] - 1) / 2;
            Console.WriteLine(res);
            res -= counts[a[i]] * (counts[a[i]] - 1) / 2;
            counts[a[i]]++;
            res += counts[a[i]] * (counts[a[i]] - 1) / 2;
        }
    }
}


Measured memory_bytes: 37184
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
///#define int long long int

using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using li = pair<ll, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod =  1000000007;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
// const double pi = 3.14159265359;
const double eps = 0.00000001;

int arr[MAXN];
ii op[MAXN];

int32_t main() {
    $
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> op[i].S >> op[i].F;
    }
    sort(op, op + m, greater<ii>());
    sort(arr, arr + n);
    ll sum = 0;
    int p = 0;
    for (int i = 0; i < n; ++i) {
        if (p < m && !op[p].S) ++p;
        if (p < m && op[p].F > arr[i]) {
            sum += op[p].F;
            --op[p].S;
        } else{
            sum += arr[i];
        }
    }
    cout << sum << '\n';
}   



Measured memory_bytes: 1408
N = int(input())
dam_arr = list(map(int,input().split()))
mount_arr = []

# calculate 1st mount's rain
rain = 0
for i in range(N):
  if i%2==0:
    rain += dam_arr[i]
  else:
    rain -= dam_arr[i]
    
mount_arr.append(rain)

# caluculate others
for i in range(N-1):
  mount_arr.append(2*dam_arr[i]-mount_arr[-1])

mount_arr=[str(a) for a in mount_arr]
mount_arr=" ".join(mount_arr)
print(mount_arr)

Measured memory_bytes: 18116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const ll INFTY = 1L << 62L;
static const ll MAX = 1000000007;
ll solver(ll *a, ll n)
{
    ll sum[n + 1] = {};
    rep(i, 0, n)
    {
        sum[i + 1] = sum[i] + a[i];
    }
    ll ans = 0;
    rep(i, 0, n)
    {
        ll tmp = (sum[n] - sum[i + 1]) % MAX;
        ans += a[i] * tmp;
        ans %= MAX;
    }
    return ans;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll a[n];
    rep(i, 0, n) cin >> a[i];
    cout << solver(a, n) << endl;
}

Measured memory_bytes: 6768
# coding: utf-8
from math import ceil
from bisect import bisect_left
N = int(input())
A = list(map(int, input().split()))
A.sort()
a = A[-1]
ans = ceil(a / 2)
b = float("inf")
for i in range(N):
    if abs(b - ans) > abs(A[i] - ans):
        b = A[i]
print(a, b)


Measured memory_bytes: 14432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

double dp[3030][3030];
int main() {
  int N; cin >> N;
  vector<double> p(N);
  rep(i, 0, N) cin >> p[i];
  dp[0][0] = 1;
  rep(i, 0, N) rep(j, 0, N) {
    dp[i + 1][j + 1] += dp[i][j] * p[i];
    dp[i + 1][j] += dp[i][j] * (1 - p[i]);
  }
  double ans = 0.0;
  rep(i, N / 2 + 1, N + 1) ans += dp[N][i];
  printf("%.12lf\n", ans);
  return 0;
}


Measured memory_bytes: 71936
import math
import collections

Max = 210000
Mod = 1000000007
fac = [0] * Max
finv = [0] * Max
inv = [0] * Max
def COMinit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, Max):
        fac[i] = fac[i-1] * i % Mod 
        inv[i] = Mod - inv[Mod%i] * (Mod//i) % Mod
        finv[i] = finv[i-1] * inv[i] % Mod 

def COM(n, k):
    if n < 0 or k < 0 or n < k:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % Mod) % Mod

N, M = map(int, input().split())
prime_count = collections.Counter()
for i in range(2, math.ceil(math.sqrt(M))+1):
    while M % i == 0:
        M /= i
        prime_count[i] += 1
if M > 1:
    prime_count[M] += 1

ans = 1
COMinit()
for i, b in prime_count.items():
    tmp = COM(b+N-1, N-1)
    ans = (ans * tmp) % Mod 
print(ans)


Measured memory_bytes: 44272
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if (a%3==0 || b%3==0 || (a+b)%3==0) {
        cout << "Possible" << endl;
    }
    else cout << "Impossible" << endl;
    return 0;
    
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char inp[12];
	char out[12]={};
	int ctr=0;
	scanf("%s", &inp);
	for(int i=0;inp[i]!='\0';i++){
		if(inp[i]=='0'){
			out[ctr]='0';
			ctr++;
		}else if (inp[i]=='1'){
			out[ctr]='1';
			ctr++;
		}else if(ctr!=0){
			if(inp[i]=='B'){
				out[ctr-1]='\0';
				ctr-=2;
			}
			ctr++;
		}
	}
	printf("%s",out);
	return 0;
}

Measured memory_bytes: 1700
// Why I am so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

int a, b, c;

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

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		printf("0\n");
		return;
	}

	if (a > b) {
		swap(a, b);
	}

	if (a > c) {
		swap(a, c);
	}    

	printf("%lld", a * 1ll * min(b, c));    
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
/**計算幾何学の問題を解く際に利用するクラス******/
//http://skyblueryu.blog54.fc2.com/blog-entry-27.html
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
#include <cstdio>
#include <iostream>
#define EPS (pow(M_E,(double)-10))
//マクロの書式については 
//http://www7b.biglobe.ne.jp/~robe/cpphtml/html01/cpp01030.html
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;

class Point{
public:
	double x,y;

	//以下の記法に関しては
	//http://ameblo.jp/nana-2007-july/entry-10037680575.html
	Point(double x = 0,double y = 0): x(x), y(y) {};

	/***演算子のオーバーロード***********/
	Point operator + (Point p) { return Point(x + p.x,y + p.y);}
	Point operator - (Point p) { return Point(x - p.x,y - p.y);}
	Point operator * (double a) { return Point(a*x,a*y);}//スカラー倍
	Point operator / (double a) { return Point(x/a,y/a);}//スカラー倍
	/***********************************/

	double norm() { return x*x+y*y;}//ベクトルのノルムを返す
	double abs() { return sqrt(norm());}//ベクトルの長さを返す

	/***演算子のオーバーロード2***********/
	//Pointはクラスオブジェクトなのでサイズが大きく値渡しは適さない
	//Point &pという記法は参照渡しでポインタでない変数
	//に対してアドレスを引数にとりたい場合に使う．
	//参照渡しとポインタ渡しについては以下
	//http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1320144958
	//http://homepage2.nifty.com/well/Reference.html#PASS_BY_REFERENCE
	//
	//Point &pの前のconst修飾子は関数内で引数のオブジェクトの内容を
	//勝手に書き換えないようにするために付けている．(const Point &p)
	//の後のconstはこの関数がconstメンバ関数であることを意味する．
	//constメンバ関数に関して詳しくは以下
	//http://www.s-cradle.com/developer/sophiaframework/tutorial/Cpp/const.html

	bool operator < (const Point &p) const{
		//(条件)?(処理1):(処理2)
		//条件が真なら処理1，偽なら処理2が実行される
		return x != p.x ? x < p.x :y < p.y;
	}

	bool operator == (const Point &p) const{
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}
	/*************************************/

};

typedef Point Vector;

//ベクトルaとbの内積を計算する関数
//これは参照渡しじゃなくていいんかいという疑問は正直ある
double dot(Vector a,Vector b){
	//double dot(const Vector& a,const Vector& b){
	return a.x*b.x + a.y*b.y;
}

//ベクトルaとbの外積を計算する関数
double cross(Vector a,Vector b){
	//double cross(const Vector& a,const Vector& b){
	return a.x*b.y - a.y*b.x;
}



//線分を表す構造体
struct Segment{
	Point p1, p2;
};
typedef Segment Line;

//円を表すクラス
class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(),double r = 0.0):c(c), r(r) {}
};

//多角形の表現(多角形は点の列で表現できる)
typedef vector<Point> Polygon;


int main(){
	Point p1,p2;
	int Q;
	scanf("%lf %lf",&p1.x,&p1.y);
	scanf("%lf %lf",&p2.x,&p2.y);
	scanf("%d",&Q);//クエリ数

	Vector d((p2.x-p1.x),(p2.y-p1.y));//方向ベクトル
	double abs = d.abs();
	d.x = d.x/abs;
	d.y = d.y/abs;

	Point p;
	Vector v;//p1→p
	Vector proj;
	for(int q = 0;q < Q;q++){
		scanf("%lf %lf",&p.x,&p.y);

		v.x = p.x - p1.x;
		v.y = p.y - p1.y;
		proj.x = d.x * dot(v,d);
		proj.y = d.y * dot(v,d);
		
		printf("%.10f %.10f\n",proj.x + p1.x,proj.y + p1.y);
	}
	return 0;
}

Measured memory_bytes: 1252
from collections import deque
import sys

n, q = map(int, input().split())

# Q = [[] for _ in range(n)]
Q = [deque() for _ in range(n)]
ans = []
for query in (line.split() for line in sys.stdin):
    s = int(query[1])
    if query[0] == '0':
        t = int(query[2])
        Q[s].append(t)
    elif query[0] == '1':
        # ans.append(Q[s])
        print(*Q[s])
    elif query[0] == '2':
        t = int(query[2])
        if Q[t]:
            if len(Q[s]) == 1:
                Q[t].append(Q[s][0])
            elif len(Q[t]) == 1:
                Q[s].appendleft(Q[t][0])
                Q[t] = Q[s]
            else:
                Q[t].extend(Q[s])
                
        else:
            Q[t] = Q[s]
        Q[s] = deque()

# for i in ans:
#     print(i)



Measured memory_bytes: 30684
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <iostream>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
using namespace std;

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



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    long long int t,n,m,k,q,x,a,b,c,d;
    cin>>n;
    cout<<(n/500)*1000+((n%500)/5)*5<<"\n";
    return 0;
    
}
    


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

// EK LOOP M BHI HO SKTA THA

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}

	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int tmp = A.at(i);
		if (A.at(tmp - 1) == i + 1) {
			cnt++;
		}
	}
	cout << cnt / 2 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 1000005

//Suffix_Array
//O(|T|log|S|) S??????????????????T????????????????????????????´¢
#define rank A
int n,Len;
int rank[MAX_N+1];
int tmp[MAX_N+1];

//(rank[i],rank[i+k])??¨(rank[j],rank[j+k])?????????
bool compare_sa(int i,int j){
  if(rank[i]!=rank[j])return rank[i]<rank[j];
  int ri=i+Len<=n?rank[i+Len]:-1;
  int rj=j+Len<=n?rank[j+Len]:-1;
  return ri<rj;
}

//?????????S?????\?°??????????????§????
void construct_sa(string S,int *sa){
  n=S.length();
  //?????????????????????????????????????????????????????????
  for(int i=0;i<=n;i++){
    sa[i]=i;
    rank[i]=i<n?S[i]:-1;
  }
  //k????????????????????????????????????????????¨???????????????2k????????§?????????
  for(Len=1;Len<=n;Len*=2){
    sort(sa,sa+n+1,compare_sa);
    //?????£??????tmp????¬?????????????????¨?????????????rank?????£??\
    tmp[sa[0]]=0;
    for(int i=1;i<=n;i++)
      tmp[sa[i]]=tmp[sa[i-1]]+(compare_sa(sa[i-1],sa[i])?1:0);
    for(int i=0;i<=n;i++)rank[i]=tmp[i];
  }
}

//S??????????????????T????????????????????????????´¢??????
bool contain(string S,int *sa,string T){
  int left=0,right=S.length();
  while(right-left>1){
    int mid=(left+right)/2;
    if(S.compare(sa[mid],T.length(),T)<0)left=mid;
    else right=mid;
  }
  return S.compare(sa[right],T.length(),T)==0;
}

char t[MAX_N],p[MAX_N];
int q,sa[MAX_N];
int main(){
  cin>>t;
  construct_sa(t,sa);
  cin>>q;
  while(q--){
    scanf("%s",p);
    if(contain(t,sa,p))printf("1\n");
    else printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 16884
S = input()
N = len(S)
SF_num = int((N-1)/2)
SF = S[:SF_num]
SF_rev = SF[::-1]
SB_num = int((N+3)/2)
SB = S[SB_num-1:]
SB_rev = SB[::-1]

if SF == SB_rev and SF == SF_rev and SB == SB_rev:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        // abc 129 C
        int n = sc.nextInt();
        int m = sc.nextInt();

        PriorityQueue<Integer> queue = new PriorityQueue<>();

        for (int i = 0; i < m; i++) {
            queue.add(sc.nextInt());
        }

        long[] dp = new long[n + 2];
        dp[1] = 1;
        for (int i = 2; i <= n + 1; i++) {
            if (!queue.isEmpty() && queue.peek() == i - 1) {
                queue.poll();
                continue;
            }
            dp[i] = dp[i - 1] + dp[i - 2];
            dp[i] %= 1000000007;
        }

        System.out.println(dp[n + 1]);
    }
}

Measured memory_bytes: 59300
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;
    int N = S.size();
    ll K; cin >> K;

    int cnt = 1;
    vector<pii> A;
    rep(i,N-1) {
        if (S[i] != S[i+1]) {
            A.emplace_back(S[i]-'a',cnt);
            cnt = 1;
        } else cnt++;
    }
    A.emplace_back(S.back()-'a',cnt);

    auto calc=[](ll x) {return x/2;};
    if (A.size()==1) {
        cout << calc(K*N) << ln;
        return 0;
    }
    if (S[0] != S.back()) {
        ll ans = 0;
        for (auto i : A) {
            ans += calc(i.second);
        }
        cout << ans*K << ln;
        return 0;
    }
    ll ans = 0;
    int M = A.size();
    for (int i = 1; i < M-1; i++) {
        ans += calc(A[i].second);
    }
    ans *= K;
    ans += calc(A[0].second+A.back().second)*(K-1);
    ans += calc(A[0].second) + calc(A.back().second);
    cout << ans << ln;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;



// 戻り値がtrueなら負の閉路を含む

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
  LL n,m,p;
  cin>>n>>m>>p;
  LL lmmn=-1LL*mod*mod;
  vector<vector<LL>> g(n+1,vector<LL>(n+1,lmmn));
  vector<vector<LL>> rg(n+1,vector<LL>());
  vector<int> used(n+1,0);
  vector<LL> dp(n+1,lmmn);
  FOR(i,0,m){
    LL a,b,c;
    cin>>a>>b>>c;
    rg[a].PB(b);
    g[a][b]=max(c-p,g[a][b]);
  }
  dp[1] = 0;
  FOR(t,0,4*n+4){
    FOR(i,1,n+1){
      if(dp[i]==lmmn){
        continue;
      }
      for(const auto& to:rg[i]){
        LL cost=g[i][to];
        if(dp[i]==-lmmn){
          dp[to]=-lmmn;
        }else if (cost+dp[i]>dp[to]) {
          dp[to]=cost+dp[i];
          if (t>=2*n+1){
            cerr<<to<<" is inf"<<endl;
            dp[to]=-lmmn;
          }
        }
      }
    }
  }


  if(dp[n]==lmmn||dp[n]==-lmmn){
    cout<<-1<<endl;
  }else{
    cout<<max(0LL,dp[n])<<endl;
  }
	return 0;
}


Measured memory_bytes: 51456
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
const int maxn=100;
string s;
int n;
map<string,int> mp;
int c[10];
int main()
{

	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		cin>>s;
		mp[s]++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",mp["AC"],mp["WA"],mp["TLE"],mp["RE"]);
	return 0;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
int main(){
	double n;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(int(i*1.08)==n){
			cout<<i;
			return 0; 
		} 
	}
	cout<<":(";
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
-- templete



main = do
    [n, t] <- getInts
    ts <- maximum . map (apply2 (flip (/)) . map fromIntegral) <$> replicateM n getInts :: IO Double
    printf "%.8f\n" $ ts * fromIntegral t


Measured memory_bytes: 4912
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int k; string s; cin >> k >> s;
	if (s.size() <= k) cout << s;
	else {
		for (int i = 0; i < k; i++) putchar(s[i]);
		puts("...");
	}
	return 0;
}

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

#define MOD 1000000007

int main() {
  int k;
  string s;
  cin >> k >> s;


  string ans = s;
  if (s.length() > k) {
    ans = s.substr(0, k) + "...";
  }

  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; 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(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int par[100010],dep[100010];
void init(int N){
    for(int i = 0; i < N; i++){
        par[i] = i;
        dep[i] = 0;
    }
}

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

void merge(int a,int b){
    a = find(a);
    b = find(b);
    if (dep[a] > dep[b]){
        par[b] = a;
        dep[a] += b;
    } else {
        par[a] = b;
        dep[b] += a;
    }
}


int main(){
    vector<double> v;
    while(true){
        int n; cin >> n;
        if (n == 0) break;
        int a[n];
        double ave = 0.000;
        for(int i = 0; i < n; i++){
            cin >> a[i];
            ave += (double)a[i]*1.000;
        }
        ave /= (double)n*1.000;
        double dev = 0.000;
        for(int i = 0; i < n; i++){
            dev += (double)(ave-a[i])*(ave-a[i]);
        }
        dev /= (double)n;
        dev = sqrt(dev);
        v.push_back(dev);
    }
    for(int i = 0; i < v.size(); i++){
        cout << fixed << setprecision(10) << v[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3232
#include "bits/stdc++.h"
using namespace std;
int cnt=0,k,n;
vector<int> a[2000];
void dfs(int s,int e,int tmp)
{
	if(tmp>(k/2))
	cnt++;
	
	for(int i=0;i<a[s].size();i++)
	{
		if(a[s][i]==e)
		{
			continue;
		}
		dfs(a[s][i],s,tmp+1);	
	}	
}
int main()
{
	cin>>n>>k;
	pair<int,int> p[2000];
	for(int i=0;i<n-1;i++)
	{
		int u,v;
		cin>>u>>v;
		u--;
		v--;
		p[i].first=u;
		p[i].second=v;
		a[u].push_back(v);
		a[v].push_back(u);
	}
	int ans=100000;
	if(k%2==1)
	{
		for(int i=0;i<n-1;i++)
		{
			cnt=0;
			dfs(p[i].first,p[i].second,0);
			dfs(p[i].second,p[i].first,0);	
			ans=min(ans,cnt);
		}	
	}
	else
	{
		for(int i=0;i<n;i++)
		{
			cnt=0;
			dfs(i,-1,0);
			ans=min(ans,cnt);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 512