akhauriyash/Code-Regression huggingface dataset:
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func solve(io *Io) {
	const MX = 1e5 + 1

	dp := [MX]int{}
	for i := range(dp) {
		dp[i] = 1e9
	}

	dp[0] = 0
	for _, d := range []int{6, 9} {
		for cur := 1; cur < MX; cur *= d {
			for i := 0; i + cur < MX; i++ {
				if dp[i] + 1 < dp[i + cur] {
					dp[i + cur] = dp[i] + 1
				}
			}
		}
	}

	n := io.NextInt()
	io.PrintLn(dp[n])

}

func main() {
	io := NewIo()
	defer io.Flush()

	solve(io)
}

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

const int mod=1e9+7;
int dp[44][1<<18];


int main()
{
    int n,x,y,z; cin>>n>>x>>y>>z;
    int sum=x+y+z;
    int pre1=z;
    int pre2=z+y;
    int pre3=sum;
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=10;j++)
        {
            for(int pop_mask=0;pop_mask<(1<<(18));pop_mask++)
            {
                int akt_mask=(pop_mask<<j);
                akt_mask&=((1<<(18))-1);
                akt_mask|=(1<<j);
                if(akt_mask&(1<<pre1) && akt_mask&(1<<pre2) && akt_mask&(1<<pre3))
                {
                    continue;
                }
                else
                {
                    dp[i][akt_mask]+=dp[i-1][pop_mask];
                    if(dp[i][akt_mask]>=mod) dp[i][akt_mask]-=mod;
                }
            }
        }
    }
    ll ans=1;
    for(int i=1;i<=n;i++)
    {
        ans*=10;
        ans%=mod;
    }
    for(int i=0;i<(1<<(18));i++)
    {
        ans-=dp[n][i];
        if(ans<0) ans+=mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 42240
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D  = sc.nextInt();
	
		if(D == 25) {
			System.out.println("Christmas");
		}
		if(D == 24) {
			System.out.println("Christmas Eve");
		}
		if(D == 23) {
			System.out.println("Christmas Eve Eve");
		}
		if(D == 22) {
			System.out.println("Christmas Eve Eve Eve");
		}
	}
}


Measured memory_bytes: 21844
N=int(input())
t_before=0
x_before=0
y_before=0
import sys

for i in range (N):
    t, x, y =map(int,input().split())
    t_diff=t-t_before
    distance=abs(x-x_before)+abs(y-y_before)
    if (t_diff-distance)%2!=0 or distance>t_diff:
        print("No")
        sys.exit()
    else:
        t_before=t
        x_before=x
        y_before=y
    
        

print ("Yes")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  ll a,b,c;
  cin>>a>>b>>c;

  cout << min(c,b/a) << endl;

  return 0;

}


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

int main(void)
{
  int A, B;
  scanf("%d %d", &A, &B);
  if (A != 1 && B != 1) printf("1\n");
  if (A != 2 && B != 2) printf("2\n");
  if (A != 3 && B != 3) printf("3\n");
 
  return 0;
}

Measured memory_bytes: 128
n,m=map(int,input().split())
g=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
from heapq import *
pq=[]
heapify(pq)
heappush(pq,(0,0))# dist,node id
vis=[0]*n
inf=float('inf')
dist=[inf]*n
dist[0]=0
par=[-1]*n
while pq:
    cur=heappop(pq)
    u=cur[1]
    if vis[u]==1:continue
    vis[u]=1
    for v in g[u]:
        if vis[v]==1:continue
        dist[v]=min(dist[v],1+dist[u])
        if dist[u]+1==dist[v]:
            par[v]=u
        heappush(pq,(dist[v],v))
flag=True
for i in range(1,n):
    if par[i]==-1:
        print('No')
        exit()
print('Yes')
for i in range(1,n):
    print(1+par[i])


Measured memory_bytes: 107924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
struct data{
  bool isNull;
  ll mini;
  ll sum;
  data(){
    isNull=true;
  }
  data(ll x){
    isNull=false;
    mini=x;
    sum=x;
  }
};

data merge(const data &a,const data &b){
  if(a.isNull)return b;
  if(b.isNull)return a;
  data d;
  d.isNull=false;
  d.mini=min(a.mini,b.mini);
  d.sum=a.sum+b.sum;
  return d;
}

struct segtree{
  int size;
  vector< data > t;
   
  void init(int n=1){
    t.clear();
    size=1;
    while(size<n)size*=2;
    t.resize(size*2);
  }

  void Update(int i,ll value){
    i+=(size-1);
    t[i]=data(value);
    while(i){
      i=(i-1)/2;
      t[i]=merge(t[i*2+1],t[i*2+2]);
    }
  }
  
  
  data Dfs(int a,int b,int k,int l,int r){
    if(b<=l || r<=a)return data();
    if(a<=l && r<=b)return t[k];
    int m=(l+r)/2;
    data lc=Dfs(a,b,k*2+1,l,m);
    data rc=Dfs(a,b,k*2+2,m,r);
    return merge(lc,rc);
  }
  
  ll getMin(int a,int b){
    return Dfs(a,b,0,0,size).mini;
  }
  ll getSum(int a,int b){
    return Dfs(a,b,0,0,size).sum;
  }
};

segtree T;
 
int main(){

   
  int n,q;
  scanf("%d %d",&n,&q);
  T.init(n);
  for(int i=0;i<n;i++){
    T.Update(i,0);
  }
  
  while(q--){
    int type,a,b;
    scanf("%d %d %d",&type,&a,&b);
    if(type==0){
      a--;
      ll x=T.getSum(a,a+1) + b;
      T.Update(a,x);
    }else{
      a--;
      b--;
      printf("%lld\n", T.getSum(a,b+1) );
    }
  }
  return 0;
}




Measured memory_bytes: 8896
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC131().SolveA(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
  class ABC131
  {
  	public void SolveA(ConsoleInput cin)
        {
            var s = cin.Read;
            var c = s.ToCharArray();
            var f = false;
                for (int i = 0; i < s.Length - 1; i++)
            {
                if (c[i] == c[i + 1]) f = true;
            }
            if (f) WriteLine("Bad");
            else WriteLine("Good");
            ReadLine();
        }
  }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define PP(m) REP(i, m.size()) cout << m[i] << endl;

int main() {
  int N;

  while (cin >> N && N) {
    int c=0;
    vector<int> arr(N);
    REP(i, N) cin >> arr[i];
    REP(i, N-1) {
      REP(j, N-i-1) {
        if (arr[j] > arr[j+1] && arr[j] != arr[j+1]) {
          swap(arr[j], arr[j+1]);
          c++;
        }
      }
    }
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    auto AS = readln.split.to!(long[]);

    long S, M;
    foreach (a; AS) {
        M = max(M, a);
        S += a;
    }
    long[] rr;
    for (long r = 1; r^^2 <= S+1; ++r) if (S%r == 0) {
        rr ~= r;
        rr ~= S/r;
    }
    sort!"a > b"(rr);

    long[] as;
    as.length = N;

    foreach (x; rr) {
        long s;
        foreach (i, a; AS) {
            auto aa = a % x;
            s += aa;
            as[i] = aa;
        }
        if (s % x) continue;
        long d = s / x;
        sort!"a > b"(as);
        foreach (j; 0..d) s -= as[j];
        if (s <= K) {
            writeln(x);
            return;
        }
    }
}

Measured memory_bytes: 2300
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    double N;
    cin >> N;
    int n = sqrt(N);
    cout << n * n;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	int x,y;
	while(true){
		cin>>x>>y;
		if(x==0&&y==0)
			break;
		if(x>y)
			cout<<y<<" "<<x<<endl;
		else
			cout<<x<<" "<<y<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
MOD = 10 ** 9 + 7

n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
for i in range(n):
    cnt1 = 0
    cnt2 = 0
    for j in range(n):
        if i == j:
            continue
        if a[i] > a[j]:
            if i < j:
                cnt1 += 1
            else:
                cnt2 += 1
    ans += cnt1 * (k * (k + 1) // 2) + cnt2 * ((k - 1) * k // 2)
    ans %= MOD
print(ans)

Measured memory_bytes: 73020
import java.io.*;
import java.util.*;
public class Main {
    private static void solver(InputReader sc, PrintWriter out) throws Exception {
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        a +=b;
        long ans = ((n/a) * (a-b)) + Math.min(a-b,n%a);
        out.println(ans);
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}
class Pair {
   int x,y;
   Pair(int x, int y){
       this.x = x;this.y = y;
   }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, a[100001];

bool solve() {
	LL sum = 0;
	inc(i, n) { sum += a[i]; }
	
	if(sum % (n * (n + 1) / 2) != 0) { return false; }
	LL t = sum / (n * (n + 1) / 2);
	
	inc(i, n) {
		LL x = ((a[i] - a[i + 1]) + t);
		if(x % n == 0 && inII(x / n, 0, t)) { } else { return false; }
	}
	
	return true;
}

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	a[n] = a[0];
	
	cout << (solve() ? "YES" : "NO") << endl;
	
	return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>

int main() {
   char a,b,c;
   scanf("%c %c %c",&a,&b,&c);
    if(a=='A'&&b=='B'&&c=='C'){
    printf("ARC\n") ;
    }
    else if(a=='A'&&b=='R'&&c=='C')
    {
        printf("ABC\n") ;
    }
  return 0;
}

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

int f(int n,int k){
	if( n == 1 ) return 0;
	return ( f(n-1,k) + k) % n;
}

int main(){
	int n, k, m;
	while( cin >> n >> k >> m , n || k || m ){
		m = (m - k + 1 + n) % n;
		int ans = (f(n,k) + m-1 + n) % n + 1 ;
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
n = int(input())
x = [int(x) for x in input().split()]
center = sum(x)//len(x)
center2 = center+1
ans, ans2 =0, 0
for i in x:
    ans += (i-center)**2
    ans2 += (i-center2)**2

print(ans) if ans<ans2 else print(ans2)

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

typedef tuple<int,int,int> trinca;
typedef long long ll;

const int MAXW = 2*1e4 + 10;

vector<trinca> guloso;
ll dp[MAXW];
int N;

int main(){

	cin >> N;
	for(int i = 1;i<=N;i++){
		int w,s,v;
		cin >> w >> s >> v;
		guloso.push_back(make_tuple(s+w,w,v));
	}

	sort(guloso.begin(),guloso.end());

	for(trinca davez : guloso){
		int solid = get<0>(davez), w = get<1>(davez);
		ll v = get<2>(davez);
		for(int i = MAXW-1;i>=0;i--){
			if(i + w <= solid){
				dp[i+w] = max(dp[i+w],dp[i] + v);
			}
		}
	}

	ll best = 0;
	for(int i = 0;i<MAXW;i++) best = max(best,dp[i]);
	cout << best << endl;

	return 0;

}

Measured memory_bytes: 384
s = input()
t = input()
ls = len(s)
lt = len(t)
dp = [[0 for _ in range(ls + 1)] for _ in range(lt + 1)]
for i in range(1, lt+1):
    for j in range(1, ls+1):
        dp[i][j] = max(dp[i-1][j], dp[i][j-1])
        if s[j-1] == t[i-1]:
            dp[i][j] = max(dp[i-1][j-1] + 1, dp[i][j-1])
ans = ''
# print(*dp, sep='\n')
while ls > 0 and lt > 0:
    if dp[lt][ls] == dp[lt-1][ls]:
        lt -= 1
    elif dp[lt][ls] == dp[lt][ls-1]:
        ls -= 1
    else:
        ans += s[ls-1]
        lt -= 1
        ls -= 1

print(ans[::-1])

Measured memory_bytes: 119900
import qualified Data.ByteString.Char8 as C
import Data.Maybe (isJust, fromJust)
import Control.Monad (replicateM)
import Data.List (sort, drop, length, filter, take)
import qualified Data.Vector.Unboxed as U
import Control.Arrow (first) -- first :: Arrow a => a b c -> a (b, d) (c, d)

cReadLn :: IO Int
cReadLn = fst . fromJust . C.readInt <$> C.getLine

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,c,k] <- getParms -- passengers, maximum num in a bus, and limit time
--  ts <- (U.fromList . sort) <$> replicateM n cReadLn -- i-th passenger's arrival time
  ts <- sort <$> replicateM n cReadLn -- i-th passenger's arrival time
  print $ length $ solve ts c k

f :: Int -> Int -> U.Vector Int -> Int
f c k ts = solver c k ts 0
  where
    solver :: Int -> Int -> U.Vector Int -> Int -> Int
    solver _ _ ts n 
      | U.null ts = n
    solver c k ts n = solver c k qs (n+1)
      where p  = inABus c k ts
            qs = U.drop p ts

overWrap :: Int -> Int -> Int -> Int
overWrap k t0 t1 = (t0+k - t1)

inABus 
  :: Int -> Int -> U.Vector Int -> Int
inABus c k tt = U.length . U.filter (0<=) . U.map (overWrap k t) . U.take c $ tt
  where
    t = U.head tt

-- https://atcoder.jp/contests/agc011/submissions/3109211

solve :: [Int] -> Int -> Int -> [[Int]]
solve [] _ _ = []
solve xs c k = a : solve b c k
  where
    (a,b) = aux (head xs) xs 1
    aux :: Int -> [Int] -> Int -> ([Int],[Int])
    aux _  []        _  = ([],[])
    aux t0 xx@(x:xs) c0
      | c0 <= c && x <= t0+k = first (x:) (aux t0 xs (c0+1))
      | otherwise            = ([], xx)

-- first (1:) :: ([Int], [Int]) -> ([Int], [Int])

solve' :: Int -> Int -> [Int] -> [[Int]]
solve' _ _ [] = []
solve' c k xs@(x:_) = a : solve' c k ys
  where
    (a,ys) = aux x xs 1
    aux :: Int ->[Int] -> Int -> ([Int], [Int])
    aux _ [] _ = ([],[])
    aux t xx@(x:xs) c0
      | c0<=c && x<= t+k = (\(cs,ds) -> ((x:cs), ds)) (aux t xs (c0+1))
      | otherwise        = ([],xx)

Measured memory_bytes: 30972
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define eb emplace_back
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define state tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 998244353
#define B 300  //check the limits, man
#define N 5000003
const ll INF = 1e18;
ll inv[N];
ll pro(ll a,ll b)
{
    return (a*b)%M;
}
void buildfact()
{
    int i,q,r;
    fill(inv,inv+N,1);
    for(i=2;i<N;i++)
    {
        q=M/i,r=M%i;
        inv[i]=M-pro(q,inv[r]);
    }
    return ;
}
int main()
{
    buildfact();
    int i,n,m;
    ll ans,p2,p3,temp;
    in(n);
    ans=0,p2=1,p3=1;
    m=(n>>1),temp=1;
    rep(i,m)
    {
        ans+=pro(temp,p2);
        p2+=p2;
        if(p2>M)p2-=M;
        temp=pro(temp,pro(n-i,inv[i+1]));
    }
    rep(i,n)
        p3=pro(p3,3);
    ans+=ans;
    ans%=M;
    p3=(p3+M-ans)%M;
    llout(p3);
}


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

int main() {
  int N;
  string s;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> s;
      if(i == N -1 && s != "Y"){
        cout << "Three" << endl;
    	break;
      }
    
      if(s == "P" || s == "G" || s == "W" ){
        continue;
      }
      if( s == "Y" ){
        cout << "Four" << endl;
    	break;
      }
  }
}


Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>

#include <algorithm>

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const ll INF = 1ll << 60;

ll MOD = 1e9 + 7;

int main()
{

    int n;
    cin >> n;

    vector<double> v(n);

    REP(i, n)
    {
        cin >> v[i];
    }

    sort(v.begin(), v.end());

    REP(i, n - 1)
    {
        v[i + 1] = (v[i] + v[i + 1]) / 2;
    }

    double ans = 0.0;

    cout << v[n - 1];

    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        a: [[Usize1;n-1];n],
    }

    let mut table: Vec<Vec<usize>> = vec![vec![0; n]; n];
    let mut count = 1;

    for i in 0..n {
        for j in 0..n {
            table[i][j] = count;
            count += 1;
        }
    }

    let mut graph: Vec<Vec<usize>> = vec![vec![]; n * n + 1];

    for i in 0..n {
        let opponents = &a[i];
        let mut prev_match = 0;

        for &j in opponents {
            let match_no = if i < j { table[i][j] } else { table[j][i] };
            if prev_match > 0 {
                graph[prev_match].push(match_no);
            }
            prev_match = match_no;
        }
    }

    let mut seen: Vec<bool> = vec![false; n * n + 1];
    let mut dp: Vec<i64> = vec![0; n * n + 1];
    let mut calculated: Vec<bool> = vec![false; n * n + 1];

    let mut ans = 0;

    for i in 0..=n * n {
        if seen[i] {
            continue;
        }

        let score = dfs(i, &graph, &mut seen, &mut dp, &mut calculated);

        if score == -1 {
            println!("-1");
            return;
        }

        ans = max(ans, score + 1);
    }

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

fn dfs(
    current: usize,
    graph: &Vec<Vec<usize>>,
    seen: &mut Vec<bool>,
    dp: &mut Vec<i64>,
    calculated: &mut Vec<bool>,
) -> i64 {
    if seen[current] {
        if !calculated[current] {
            return -1;
        } else {
            return dp[current];
        }
    }

    seen[current] = true;

    for &next in &graph[current] {
        let score = dfs(next, graph, seen, dp, calculated);

        if score == -1 {
            return -1;
        }

        dp[current] = max(dp[current], score + 1);
    }

    calculated[current] = true;
    dp[current]
}


Measured memory_bytes: 69504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

int N, M;
Graph<int> G;
vector<ll> dp;

void dfs1(int v, int p = -1) {
    dp[v] = 1;
    for (auto nv : G[v]) {
        if (nv == p)
            continue;
        dfs1(nv, v);
        (dp[v] *= dp[nv] + 1) %= M;
    }
}

void dfs2(int v, int p = -1, ll d_par = 0) {
    (dp[v] *= (d_par + 1)) %= M;

    vector<ll> rmul;
    rmul.push_back(1);
    for (int i = G[v].size() - 1; i >= 0; --i) {
        int nv = G[v][i];
        if (nv == p)
            continue;
        rmul.push_back(rmul.back() * (dp[nv] + 1) % M);
    }
    reverse(rmul.begin(), rmul.end());

    int cnt = 0;
    ll lmul = 1;
    for (auto nv : G[v]) {
        if (nv == p)
            continue;
        ll tmp = lmul * (rmul[cnt + 1] * (d_par + 1) % M) % M;
        (lmul *= (dp[nv] + 1)) %= M;
        dfs2(nv, v, tmp);
        cnt++;
    }
}

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

    cin >> N >> M;
    G.resize(N);
    for (int i = 1; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    int s = 0;
    dp.resize(N);
    dfs1(s);
    dfs2(s);
    for (auto i : dp)
        cout << i << '\n';

    return 0;
}


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

int main() {
	int N,s=0, ans = 0;
	int a[100000];
	cin >> N;
	for (int i = 0; i < N; i++)cin >> a[i];
	bool b[100000] = {0};
	while (1) {
		if (s == 1)break;
		if (b[s] == 1) {
			ans = -1; break;
		}
		b[s] = 1;
		s = a[s]-1;
		ans++;
	}
	cout << ans << endl;

}


Measured memory_bytes: 768
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define endl "\n"
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n;
  cin>>n;
  ll a;
  if(n%2==1){
    a = n;
  }
  else{
    a = n+1;
  }
  vector<pair<ll,ll> > vp;
  rep(i,1,n+1){
    rep(j,i+1,n+1){
      if(i+j!=a){
        vp.pb(mp(i,j));
      }
    }
  }
  cout << vp.sz << endl;
  rep(i,0,vp.sz){
    cout << vp[i].fi << " " << vp[i].se << endl;
  }
  return 0;
}

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

using namespace std;

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

    int ans = 0;
    int highest = 0;
    for (int i = 0; i < n; ++i) {
        int h;
        cin >> h;
        highest = max(highest, h);
        if (h >= highest) ans++;
    }

    cout << ans << endl;
    return 0;
}


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

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N          = in.nextInt();
			double ans = 0;
			double x;
			String y;

			for(int i = 0; i < N; i++) {
				x = Double.parseDouble(in.next());
				y = in.next();

				if(y.equals("JPY")) {
					ans += x;
				} else {
					ans += x * 380000.0;
				}

			}
			out.println(ans);

		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

	}
}


Measured memory_bytes: 21588
s = gets.chomp

ym = s.scan(/\d{2}/).map(&:to_i)
if ym[0] == 0 && ym[1] == 0 then
  puts "NA"
elsif ym[0] == 0 && ym[1] >= 13 then
  puts "NA"
elsif ym[0] >= 13 && ym[1] == 0 then
  puts "NA"
elsif ym[0] >= 13 && ym[1] >= 13 then
  puts "NA"
elsif ym[0] == 0 && ym[1] <= 12 then
  puts "YYMM"
elsif ym[0] <= 12 && ym[1] == 0 then
  puts "MMYY"
elsif ym[0] <= 12 && ym[1] <= 12 then
  puts "AMBIGUOUS"
elsif ym[0] <= 12 || ym[1] >= 13 then
  puts "MMYY"
elsif ym[0] >= 13 || ym[1] <= 12 then
  puts "YYMM"
else
  puts "NA"
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
	int a, b;
	cin >> a >> b;
	if (a * b % 2 == 0) cout << "No" << endl;
	else cout << "Yes" << endl;

}

Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<ll, ll> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void File()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("pyramid.in", "r", stdin);*/
#endif
}
void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
	//File();
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 0, 1, -1, 1, -1, -1, 1 };

int n, k;
vector<pair<int, pair<int, int>>>v;
ll dp[nn][4];
ll solve(int idx, int last)
{
	if (idx >= n)
		return 0;
	ll &ret = dp[idx][last];
	if (~ret)
		return ret;
	ret = 0;
	if (last != 1)
		ret = max(ret, solve(idx + 1, 1) + v[idx].first);

	if (last != 2)
		ret = max(ret, solve(idx + 1, 2) + v[idx].second.first);

	if (last != 3)
		ret = max(ret, solve(idx + 1, 3) + v[idx].second.second);

	return ret;
}
int main()
{
	fast();
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int x, y, z;
		cin >> x >> y >> z;
		v.push_back(mk(x, mk(y, z)));
	}
	memset(dp, -1, sizeof(dp));
	cout << solve(0, 0) << endl;
	return 0;
}

Measured memory_bytes: 10868
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first+
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	string s;
	cin >> s;
	int n = s.size();
	int dp[n + 1][2];
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j < 2; j++)
		dp[i][j] = inf;
	}
	dp[0][0] = 0, dp[0][1] = 1;
	for(int i = 1; i <= n; i++) {
		int x = s[i - 1] - '0';
		dp[i][0] = min(dp[i - 1][0] + x, dp[i - 1][1] + 10 - x);
		dp[i][1] = min(dp[i - 1][0] + x + 1, dp[i - 1][1] + 10 - x - 1);
	}
	cout << dp[n][0];
}


Measured memory_bytes: 12184
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
//#define int long long
const int INF = 1e9 + 228;
const int MAXN = 1e5 + 228;

signed main()
{
#ifdef LOCAL
    FILE;
#endif
    sh;
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n % 2 != 0) {
    	cout << "No" << endl;
    	return 0;
    }
    for (int i = 0; i < n / 2; i++) {
    	if (s[i] != s[i + (n / 2)]) {
    		cout << "No" << endl;
    		return 0;
    	}
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

int A[300][300];
int cur[300];
bool canceled[300];
int N, M;

pair<int, int> f() {
  pair<int, int> ret;

  int cnt[M];

  for(int i = 0; i < M; i++) {
    cnt[i] = 0;
  }

  for(int i = 0; i < N; i++) {
    cnt[A[i][cur[i]]] += 1;
  }

  ret.first = 0;
  ret.second = cnt[0];

  for(int i = 0; i < M; i++) {
    if(cnt[i] > ret.second) {
      ret.second = cnt[i];
      ret.first = i;
    }
  }

  return ret;
}

void g() {
  for(int i = 0; i < N; i++) {
    while(canceled[A[i][cur[i]]] == true) {
      cur[i] += 1;
    }
  }
}

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

  for(int i = 0; i < N; i++)
    for(int j = 0; j < M; j++) {
      cin >> A[i][j];
      A[i][j] -= 1;
    }

  int ans = 300;
  for(int i = 0; i < M; i++) {
    pair<int, int> p = f();
    ans = min(ans, p.second);
    canceled[p.first] = true;
    if(i == M - 1)
      break;
    g();
  }

  cout << ans << endl;


}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;

int main() {
    cin >> n;
    Vl v(n);
    Mll m;
    REP(i, n) {
        cin >> v[i];
        m[v[i]]++;
    }

    ll sum = 0;
    for (auto x: m) {
        sum += x.second * (x.second-1) / 2;
    }

    for (auto x: v) {
        cout << sum - m[x] + 1 << '\n';
    }

    return 0;
}


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

int main()
{
	int n;
	cin >> n;
	int dp[50];
	dp[0] = 1;
	dp[1] = 1;
	for (int i = 2; i <= n; i++) {
		dp[i] = dp[i - 1] + dp[i - 2];
	}
	cout << dp[n] << endl;
	return 0;
}


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

using namespace std;
int v[111], N, X;

int main(){
    cin>>X>>N;
    int ans=X, d=0x3f3f3f3f;
    for (int i=0; i<N; i++){
        int a;
        cin>>a;
        v[a]++;
    }
    for (int i=0; i<=101; i++){
        if (!v[i]){
            if (abs(X-i)<d) d=abs(X-i), ans=i;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

class UnionFind
{
    // data[i] = i is root ? - size : i's parent
    std::vector<int> data;

  public:
    UnionFind(int n) : data(n, -1) {}

    int find(int x)
    {
        if (data[x] < 0) return x;
        return data[x] = find(data[x]);
    }

    bool unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y) return false;

        if (-data[x] < -data[y]) std::swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int size(int x) { return -data[find(x)]; }

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

int main()
{
    int n, k, l;
    cin >> n >> k >> l;
    UnionFind uf1(n), uf2(n);
    for (int i = 0; i < k; i++) {
        int p, q;
        cin >> p >> q;
        p--, q--;
        uf1.unite(p, q);
    }
    for (int i = 0; i < l; i++) {
        int r, s;
        cin >> r >> s;
        r--, s--;
        uf2.unite(r, s);
    }

    map<pair<int, int>, int> mp;

    for (int i = 0; i < n; i++) { mp[{uf1.find(i), uf2.find(i)}]++; }
    for (int i = 0; i < n; i++) {
        cout << mp[{uf1.find(i), uf2.find(i)}] << endl;
    }
}

Measured memory_bytes: 10752
#include<stdio.h>
int g[10][10];
int main(){
	int a;
	while(scanf("%d",&a),a){
		
		for(int i=0;i<10;i++)
			for(int j=0;j<10;j++)
				if(i==j)g[i][j]=0;
				else g[i][j]=999999999;
		int t=0;
		for(int i=0;i<a;i++){
			int c,d,e;
			scanf("%d%d%d",&c,&d,&e);
			if(t<c)t=c;
			if(t<d)t=d;
			g[c][d]=e;
			g[d][c]=e;
		}
		t++;
		for(int k=0;k<t;k++){
			for(int i=0;i<t;i++){
				for(int j=0;j<t;j++){
					if(g[i][k]+g[k][j]<g[i][j])g[i][j]=g[i][k]+g[k][j];
				}
			}
		}
		int n=0;
		long long int ans=999999999;
		for(int i=0;i<t;i++){
			long long int now=0;
			for(int j=0;j<t;j++)now+=g[i][j];
			if(ans>now){
				ans=now;
				n=i;
			}
		}
		printf("%d %lld\n",n,ans);
	}
}

Measured memory_bytes: 0
program rally
    implicit none
    integer n, i
    integer :: ansgt = 0, anslt = 0, ans = 0, sum = 0
    integer :: avelt = 0, avegt = 0, ave = 0, amari = 0
    integer,allocatable :: x(:)
    read *, n
    allocate(x(n))
    read *, x(:n)
    do i = 1, n
        sum = sum + x(i)
    end do
    amari = mod(sum, n)
    if(amari == 0)then
        ave = sum / n
        do i = 1, n
            ans = ans + (x(i) - ave)**2
        end do
        print *, ans
    else
        ave = sum / n
        avegt = ave + 1
        avelt = ave
        do i = 1, n
            ansgt = ansgt + (x(i) - avegt)**2
            anslt = anslt + (x(i) - avelt)**2
        end do
        if(ansgt < anslt)then
            print *, ansgt
        else
            print *, anslt
        end if
    end if
end program

Measured memory_bytes: 2836
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

template<typename value_type>
class fast_combination
{
public:
	value_type mod_value;

	vector<value_type> mod_inv;
	vector<value_type> fact;
	vector<value_type> fact_inv;

public:
	fast_combination(const value_type& limit, const value_type& m)
		: mod_value(m), mod_inv(), fact(), fact_inv()
	{
		mod_inv.assign(limit + 1, 0);
		fact.assign(limit + 1, 0);
		fact_inv.assign(limit + 1, 0);

		mod_inv[1] = 1;
		fact[0] = 1;
		fact[1] = 1;
		fact_inv[0] = 1;
		fact_inv[1] = 1;

		for (value_type i = 2; i <= limit; i++)
		{
			mod_inv[i] = (mod_value - ((mod_value / i) * mod_inv[mod_value % i] % mod_value)) % mod_value;
			fact[i] = (fact[i - 1] * i) % mod_value;
			fact_inv[i] = (fact_inv[i - 1] * mod_inv[i]) % mod_value;
		}
	}

public:
	value_type process(const value_type& n, const value_type& r)
	{
		if (n < 0 || r < 0) return 0;
		if (n < r) return 0;

		return (fact[n] * (fact_inv[r] * fact_inv[n - r] % mod_value)) % mod_value;
	}
};

//fast_combination<long long> fc(N, MOD);
//long long result = fc.process(n, r);

const int MOD = 1e9 + 7;

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

	fast_combination<long long> fc(3e6, MOD);

	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;

	long long result = fc.process(r2 + 1 + c2 + 1, r2 + 1);
	result = (result + (MOD - fc.process(r2 + 1 + c1, c1))) % MOD;
	result = (result + (MOD - fc.process(r1 + c2 + 1, c2 + 1))) % MOD;
	result = (result + fc.process(r1 + c1, c1)) % MOD;
	cout << result;

	return 0;
}

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
int pref[N+2]={0};

int32_t  main(){
	IOS;
  int n;cin>>n;
  int q;cin>>q;
  string s;cin>>s;
  int cnt=0;
  pref[0]=0;
  for(int i=1;i<n;++i){
    if(s[i]=='C' && s[i-1]=='A')cnt++;
    pref[i]=cnt;
  }
  while(q--){
    int l,r;cin>>l>>r;
    l--,r--;
    if(l==0){
      cout<<pref[r]<<endl;
    }else{
      int cnt=0;
      if(s[l-1]=='A' && s[l]=='C')cnt=1;
      cout<<pref[r]-pref[l-1]-cnt<<endl;
    }
  }
  return 0;
}



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

function Main(input) {
  input = myconv(input,3);
  var H = myconv(input[0],4)[0];
  var W = myconv(input[0],4)[1];
  input.shift();
  var uesita = "";
  for(var i = 0; i < W +2; i++){
    uesita += "#";
  }
  var output = [];
  output.push(uesita);
  for(var i = 0; i < H; i++){
    output.push("#" + input[i] + "#");
  }
  output.push(uesita);
  myout(output.join("\n"));
}

Main(myin());


Measured memory_bytes: 7372
// AOJ 1622 Go around the Labyrinth
// 2018.2.13 bal4u

#include <stdio.h>
#include <string.h>

typedef struct { char r, c; } Q;
Q q[10000]; int top, end;
int h, w;
char map[53][53];
int mv4[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
int mv9[9][2] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,0},{0,1},{-1,1},{-1,0},{1,1}};
char mk[53][53];

int check()
{
	int i, r, c, nr, nc, f;

	memset(mk, 0, sizeof(mk));
	q[0].r = 1, q[0].c = 1, top = 0; end = 1;
	f = 0;
	while (top != end) {
		r = q[top].r, c = q[top++].c;
		if (mk[r][c]) continue;
		mk[r][c] = 1;
		if (r == 1 && c == w) f++;
		if (r == h && c == 1) f++;
		if (r == h && c == w) f++;
		if (f == 3) return 0;
		for (i = 0; i < 4; i++) {
			nr = r + mv4[i][0], nc = c + mv4[i][1];
			if (!map[nr][nc]) continue;
			q[end].r = nr, q[end++].c = nc;
		}
	}
	return 1;
}

int main()
{
	int r, c, i, f, nr, nc;
	char buf[10], *p;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		sscanf(buf, "%d%d", &h, &w);
		memset(map, 0, sizeof(map));
		for (r = 1; r <= h; r++) {
			fgets(p = map[r]+1, 52, stdin);
			c = w; while (c--) *p = (*p == '.'), p++; *p = 0;
		}

		if (check()) goto no;
		for (r = 1; r <= h; r++) for (c = 1; c <= w; c++) {
			if (r == 1 && c == 1 || r == 1 && c == w ||
				r == h && c == 1 || r == h && c == w) continue;
			if (!map[r][c]) continue;
			f = 0;
			for (i = 0; i < 9; i++) {
				nr = r + mv9[i][0], nc = c + mv9[i][1];
				if (!map[nr][nc]) { f = 1; break; }
			}
			if (f) {
				map[r][c] = 0;
				if (check()) goto no;
				map[r][c] = 1;
			}
		}
		puts("YES"); continue;
no:		puts("NO");
	}
	return 0;
}



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

int main() {
  ll n; cin>>n;
  ll sum = 0, m = 0;
  vector<ll> v(n);
  rep(i,n){
    cin>> v[i];
    sum += v[i];
    if(i % 2 == 1){m+= v[i];}
  }
  sum /= 2;  
  ll x = sum - m;
  cout<< 2 * x << " ";
  rep(i, n - 1){
    x= v[i] - x;
    cout << 2 * x << " ";
  }
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
    ll a,b;
    cin>>n>>a>>b;
    if(a==0 && b==0)
    {
        cout<<"0";
        return;
    }
    ll x=n/(a+b);
    ll y=n%(a+b);
    ll ans=x*a +min(a,y);
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3652