akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
	int n,temp,top,low;

	cin >> n;
	cin >>temp;
	if(temp<0)temp=0-temp;
	top=temp;
	low=temp;
	for(int i=1;i<n;i++){
		cin >>temp;
		if(temp<0)temp=0-temp;
		if(top<temp)top=temp;
		if(low>temp)low=temp;
	}
	cout<<top-low<<endl;
	return 0;
}

Measured memory_bytes: 256
require 'pp'

s = gets.chomp!
x = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']

if 7 - x.find_index(s) == 0
    puts 7
else
    puts 7 - x.find_index(s)
end


Measured memory_bytes: 4092
#include<bits/stdc++.h>
using namespace std;
long long e[100001],d[100001],a[100001],b[100001],c[100001],n,m;
int main()
{
	ios_base::sync_with_stdio(0);
	cin>>n>>m;
	cin>>d[1];
	for(int i=2;i<=m;i++)
	{
		cin>>d[i];
		if(d[i]>=d[i-1])
		for(int j=d[i-1];j<d[i];j++)
		e[j]++;
		else for(int j=d[i];j<d[i-1];j++)
		e[j]++;
	}
	for(int i=1;i<=n-1;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	long long res=0;
	for(int i=1;i<=n-1;i++)
	if (a[i]*e[i]>b[i]+c[i]+b[i]*(e[i]-1))
	res+=b[i]+c[i]+b[i]*(e[i]-1);
	else res+=a[i]*e[i];
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 7036
#include <iostream>
#include <set>
#include <cassert>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <map>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int64_t> a;
	int mc = 0;
	for (int i = 0; i < n; ++i) {
		int64_t ai;
		cin >> ai;
		a.push_back(ai);
		if (ai < 0) {
			mc++;
		}
	}
	sort(a.begin(), a.end());
	if (n == 2) {
		cout << a[1] - a[0] << endl;
		cout << a[1] << " " << a[0] << endl;
		return 0;
	}
	else {
		int p = n-mc;
		int q = mc;
		if (p == 0) {
			p = 1;
			q = n - 1;
		}
		if (q == 0) {
			q = 1;
			p = n - 1;
		}
		vector<pair<int, int>> v;
		int64_t a0 = a[0];
		for (int i = q; i < n - 1; ++i) {
			v.push_back(make_pair(a0, a[i]));
			a0 = a0 - a[i];
		}
		int64_t an = a[n - 1];
		v.push_back(make_pair(an, a0));
		an = an - a0;
		for (int i = 1; i < q; ++i) {
			v.push_back(make_pair(an, a[i]));
			an = an - a[i];
		}
		cout << an << endl;
		for (int i = 0; i < v.size(); ++i) {
			cout << v[i].first << " " << v[i].second << endl;
		}
		return 0;
	}
}

Measured memory_bytes: 3572
#include <stdio.h>
#include <string.h>
int h,w,K,len,len2;
char s[10][10];
int a[10],b[10],r[10],c[10],tot;
void dfs2(int step){
	int i,j,k,cnt;
	if(step==len2+1){
		for(j=1;j<=w;j++)c[j]=0;
		for(j=1;j<step;j++)c[b[j]]=1;
		cnt=0;
		for(j=1;j<=h;j++)
			for(k=1;k<=w;k++)
				if(!r[j]&&!c[k]&&s[j][k]=='#')cnt++;
		if(cnt==K)tot++;
		return ;
	}
	for(i=b[step-1]+1;i<=w;i++){
		b[step]=i;
		dfs2(step+1);
	}
}
void dfs1(int step){
	int i,j;
	if(step==len+1){
		for(j=1;j<=h;j++)r[j]=0;
		for(j=1;j<step;j++)r[a[j]]=1;
		for(len2=0;len2<=w;len2++)
			dfs2(1);
		return;
	}
	for(i=a[step-1]+1;i<=h;i++){
		a[step]=i;
		dfs1(step+1);
	}
}
int main(){
	int i;
	scanf("%d%d%d",&h,&w,&K);
	for(i=1;i<=h;i++)scanf("%s",s[i]+1);
	a[0]=0;
	for(len=0;len<=h;len++)
		dfs1(1);
	printf("%d\n",tot);
	return 0;
}

Measured memory_bytes: 1728
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	aa := make([]int, n)
	bb := make([]int, n)
	ma := make([]int, n)
	mb := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	for i := 0; i < n; i++ {
		bb[i] = getNextInt(scanner)
	}

	ans := 0

	ms := MergeSort{}
	ms.init(n)

	for i := 0; i < 30; i++ {
		t := 1 << uint(i)
		for ii := 0; ii < n; ii++ {
			ma[ii] = aa[ii] % (t << 1)
			mb[ii] = bb[ii] % (t << 1)
		}
		ms.sort(0, n, mb)

		c := 0
		for ii := 0; ii < n; ii++ {
			c += n
			for iii := 1; iii <= 3; iii++ {
				l := 0
				r := n
				v := t*iii - ma[ii]
				for l < r {
					m := (l + r) >> 1
					if mb[m] >= v {
						r = m
						continue
					}
					l = m + 1
				}
				if iii%2 == 1 {
					c -= l
					continue
				}
				c += l
			}
		}
		c %= 2
		ans |= c << uint(i)
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}

func bsearch(a, n, t int, mb []int) int {
	l := 0
	r := n
	for l < r {
		m := (l + r) >> 1
		if a+mb[m] >= t {
			r = m
			continue
		}
		l = m + 1
	}
	return l
}

type MergeSort struct {
	n      int
	ll, rr []int
}

func (ms *MergeSort) init(n int) {
	ms.n = n
	ms.ll = make([]int, n/2+2)
	ms.rr = make([]int, n/2+2)
}

func (ms *MergeSort) sort(l, r int, aa []int) {
	if l+1 < r {
		m := (l + r) >> 1
		ms.sort(l, m, aa)
		ms.sort(m, r, aa)
	}
	ms.merge(l, r, aa)
}

func (ms *MergeSort) merge(l, r int, aa []int) {
	ll := ms.ll
	rr := ms.rr
	m := (l + r) >> 1
	for i := l; i < m; i++ {
		ll[i-l] = aa[i]
	}
	for i := m; i < r; i++ {
		rr[i-m] = aa[i]
	}

	ll[m-l] = 1 << 30
	rr[r-m] = 1 << 30
	lpos := 0
	rpos := 0
	for i := l; i < r; i++ {
		if ll[lpos] <= rr[rpos] {
			aa[i] = ll[lpos]
			lpos++
			continue
		}
		aa[i] = rr[rpos]
		rpos++
	}
}


Measured memory_bytes: 12800
#include<stdio.h>

int main(void){
    int a,b,c=0,i;
    scanf("%d %d",&a,&b);
    if(a>b){
        for(i=0;i<a;i++){
            c *= 10;
            c += b;
        }
    }else{
    for(i=0;i<b;i++){
            c *= 10;
            c += a;
        }
    }
    printf("%d\n", c);
    return 0;
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;



int main() {
	int H, W;
	cin >> H >> W;
	vector<string> grid(H);
	for (int i = 0; i < H; i++) {
		cin >> grid[i];
	}
	//横
	set<int> yN;
	for (int y = 0; y < H; y++) {
		bool allEmpty = true;
		for (int x = 0; x < W; x++) {
			if (grid[y][x] == '#')allEmpty = false;
		}
		if (allEmpty)yN.insert(y);
	}
	//縦
	set<int> xN;
	for (int x = 0; x < W; x++) {
		bool allEmpty = true;
		for (int y = 0; y < H; y++) {
			if (grid[y][x] == '#')allEmpty = false;
		}
		if (allEmpty)xN.insert(x);
	}

	for (int y = 0; y < H; y++) {
		if (yN.count(y))continue;
		for (int x = 0; x < W; x++) {
			if (xN.count(x))continue;
			cout << grid[y][x];
		}
		cout << endl;
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }




int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int now = 0;
    int sum = 0;
    rep(i, n) {
        sum += abs(now - a[i]);
        now = a[i];
    }
    sum += abs(a[a.size()-1]);

    rep(i, n) {
        int ans = sum;
        if(i == n-1) {
            int prev = a[i-1];
            ans -= abs(prev-a[i]);
            ans -= abs(a[i]);
            ans += abs(a[i-1]);
        } else {
            int prev = 0;
            if(i > 0) prev = a[i-1];
            ans -= abs(prev-a[i]);
            ans -= abs(a[i]-a[i+1]);
            ans += abs(prev-a[i+1]);
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <limits>
#include <set>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

using Z = long long;
constexpr Z INF = numeric_limits<Z>::max();

#ifdef DEBUG
# define dump(x) cerr << #x << " = " << (x) << endl
# define mesg(m) cerr << m << endl
# define debug if (true)
#else
# define NDEBUG
# define dump(x)
# define mesg(m)
# define debug if (false)
#endif
#define rep(i, n) for (auto i = 0; i < n; i++)
#define rrep(i, n) for (auto i = n; i >= 0; i--)
#define all(c) begin(c), end(c)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  Z n;
  cin >> n;
  vector<Z> as(3 * n);
  for (auto& a : as) cin >> a;
  multiset<Z> lkeep, rremove, rkeep;
  rep (i, n) lkeep.insert(as[i]);
  for (int i = n; i < 3 * n; i++)
    rremove.insert(as[i]);
  rep (i, n) {
    rkeep.insert(*begin(rremove));
    rremove.erase(begin(rremove));
  }
  Z lsum = accumulate(all(lkeep), 0ll),
    rsum = accumulate(all(rkeep), 0ll);
  Z best = lsum - rsum;
  for (int i = n; i < 2 * n; i++) {
    debug {
      mesg("lkeep");
      for (auto v : lkeep)
        cerr << v << ' ';
      cerr << endl;
      mesg("rremove");
      for (auto v : rremove)
        cerr << v << ' ';
      cerr << endl;
    }
    Z a = as[i];
    lkeep.insert(a);
    lsum += a - *begin(lkeep);
    lkeep.erase(begin(lkeep));
    if (rremove.count(a)) {
      auto it = rremove.find(a);
      rremove.erase(it);
    }
    else {
      rkeep.erase(a);
      auto replaced = *begin(rremove);
      rkeep.insert(replaced);
      rremove.erase(begin(rremove));
      rsum += replaced - a;
    }
    best = max(best, lsum - rsum);
  }
  cout << best << endl;
}


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

int p[100];
char s[100][11];

int cmp(const int *a,const int *b){
  int tmp;
  tmp = strcmp(s[*a],s[*b]);
  if(tmp) return tmp;
  else return p[*b] - p[*a];
}

int main(void){
  int n,i;
  scanf("%d",&n);
  int num[n];
  for(i=0;i<n;i++){
    scanf("%s %d",s[i],&p[i]);
    num[i]=i;
  }

  qsort(num,n,sizeof(int),cmp);
  
  for(i=0;i<n;i++)printf("%d\n",num[i]+1);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int A;
    int B;
    int C;
    
    int AB;
    int BC;
    int CA;

    cin >> A >> B >> C;

    AB = A + B;
    BC = B + C;
    CA = C + A;

    if(AB <= BC)
    {
        if(AB <= CA)
        {
            cout << AB;
        }
        else
        {
            cout << CA;
        }
    }
    else
    {
        if(BC <= CA)
        {
            cout << BC;
        }
        else
        {
            cout << CA;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);

        int numberCount = sc.nextInt();
        Set<Integer> numbers = new HashSet<Integer>();
        for (int i = 0; i < numberCount; i++) {
            numbers.add(sc.nextInt());
        }

        System.out.println(numbers.size());
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
   ll limit;
   cin >> limit;
    ll nowprice = 100;
    int count = 0;
    while(nowprice < limit) {
        nowprice *= 1.01;
        count++;
    }
    cout << count << endl;

}


Measured memory_bytes: 3624
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	var bar_r, bar_l int = 0, 0
	var l, r int = 0, n - 1
	for l <= r {
		if bar_l <= bar_r {
			bar_l += a[l]
			l++
		} else {
			bar_r += a[r]
			r--
		}
	}

	ans := abs(bar_r - bar_l)
	fmt.Println(ans)
}

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


Measured memory_bytes: 6968
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)];rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo

show_flg=False
show_flg=True

ans=0


a=I()


ans=2*a*math.pi
print(ans)






Measured memory_bytes: 76500
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int a[5];
    for (auto &e: a) cin >> e;

    int d = 0;
    for (auto &e: a) {
        int n = e - e % 10;
        if (e % 10 > 0) n += 10;
        d = max(n - e, d);
        e = n;
    }

    int ans = accumulate(a, a + 5, 0) - d;

    cout << ans << endl;

    return 0;
}


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

struct edge {int u, v, cost;};

int n;
vector<edge> G;

bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

class UnionFind {
 public:
    int g_num;
    vector<int> rank, par;

    UnionFind() {}
    UnionFind(int size) {
        rank.resize(size, 0);
        par.resize(size, 0);
        for (int i = 0; i < size; i++) {
            par[i] = i;
            rank[i] = 0;
        }
        g_num = size;
    }

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

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

        g_num--;
        if (rank[x] > rank[y]) {
            par[y] = x;
        } else {
            par[x] = y;
            if (rank[x] == rank[y]) rank[y]++;
        }
    }

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

    int group_num() {
        return g_num;
    }
};

int prim() {
    sort(G.begin(), G.end(), comp);
    UnionFind uf(n);
    int res = 0;
    for (auto e: G) {
        if (!uf.same(e.u, e.v)) {
            uf.unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main(void) {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int cost;
            cin >> cost;
            if (cost == -1) continue;
            G.push_back(edge {i, j, cost});
        }
    }
    int ans = prim();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1344
#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <cassert>
#include <complex>
#include <time.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,val) memset(A,val,sizeof(A))
#define ITER(it,a) for(__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define DBG1(a) cerr<<#a<<"="<<(a)<<"\n"
#define DBG2(a,b) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"

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

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

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

const int MAX = 200200;
int A[MAX];
int P[MAX];

int main()
{

	//freopen("in.txt","r",stdin);
	//freopen("out.txt", "w", stdout);
	//ios::sync_with_stdio(0);cin.tie(0);
	
	int n;
	scanf("%d", &n);
	//n = 200000;
	FOR(i, 0, n)
	{
		scanf("%d", &A[i]);
		//A[i] = i + 1;
		A[i]--;
		P[A[i]] = i;
	}

	set<int> s;

	LL res = 0;

	FOR(i, 0, n)
	{
		int p = P[i];
		int L = -1, R = n;
		set<int>::iterator it = s.lower_bound(p);
		if (it != s.begin())
		{
			it--;
			L = *it;
		}

		it = s.upper_bound(p);
		if (it != s.end())
		{
			R = *it;
		}

		L = p - L;
		R = R - p;
		res += L * (LL)R * (LL)(i + 1);

		s.insert(p);
	}

	cout << res << endl;

	return 0;
}



Measured memory_bytes: 11136
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a;
	scanf("%d", &a);
	printf("%d\n", 180 * (a - 2));
	
	Please AC;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string in,res;
int main()
{
	cin>>in;
	res="";
	for(int i=0;i<in.length();++i)
	{
		if(in[i]=='B')
		{
			if(res!="")
				res.erase(res.begin()+res.length()-1);
		}
		else	res+=in[i];
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

 // 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする
    int score = 0; 

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー

        // 負荷さ優先探索中の処理



        dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
    }
    return score;
} 

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}
*/


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

  if(N.at(0)==N.at(1) && N.at(1)==N.at(2)){
    cout << "Yes" << endl;
    return 0; 
  }

  if(N.at(1)==N.at(2) && N.at(2)==N.at(3)){
    cout << "Yes" << endl;
    return 0; 
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  FOR(i, 1, n + 1) {
    ll a;
    cin >> a;
    if (i % 2 == 1 && a % 2 == 1) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define INF 100000000

const int MOD = 1e9+7;
typedef long long ll;
using namespace std;
const ll M = 998244353;

int main(void) {
    ll s, w;
    cin >> s >> w;
    if(s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll n, m, k, a;
	ll ans = 0;

	cin >> n >> m;

	vector<ll> v(m, 0);

	REP(i, n) {
		cin >> k;

		REP(j, k) {
			cin >> a;
			v[a - 1]++;
		}
	}

	REP(i, m) {
		if (v[i] == n) {
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s=scan.nextLine();
		int c=0;
		for(int i=0;i<s.length();i++)
		{
			if(s.charAt(2)==s.charAt(3) && s.charAt(4)==s.charAt(5))c=1; 
		
		}
		if(c==1) System.out.println("Yes");
		else System.out.println("No");

	}

}


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

int main()
{
    long long T1, T2;
    cin>>T1>>T2;
    long long A1, A2;
    cin>>A1>>A2;
    long long B1, B2;
    cin>>B1>>B2;

    long long X = T1*(A1-B1);
    long long Y = T2*(A2-B2);
    if (X<0)
        X *= -1,
        Y *= -1;
    if (X+Y>0)
        cout<<0<<endl;
    if (X+Y==0)
        cout<<"infinity"<<endl;
    if (X+Y<0)
    {
        long long t = -(X+Y);
        cout<<(X/t)*2+1-(X%t==0?1:0)<<endl;
    }
}


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

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	int n;
	while(scanf("%d", &n)==1)
	{
		vi a(n);
		for(auto&m:a) scanf("%d", &m);

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

		bool ans=true;
		for(int i=1;i<n;i++)
		{
			if(a[i]==a[i-1]) ans=false;
		}
		printf("%s\n", ans?"YES":"NO");
	}
	return 0;
}


Measured memory_bytes: 1024
h, w = map(int, input().split())

answer = ""
for i in range(h + 2):
  if i == 0:
    answer += ''.join(["#" for i in range(w + 2)]) + "\n"
  elif i == h +1:
    answer += ''.join(["#" for i in range(w + 2)]) + "\n"
  else:
    answer += "#" + str(input()) + "#" + "\n"

print(answer)

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

typedef long long ll;

int r,c;
ll d,px[90005],py[90005],dis[90005];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int x,y,q;
    while(cin >> r >> c >> d)
    {
        for(int i = 1; i <= r; i++)
            for(int j = 1; j <= c; j++)
            {
                cin >> x;
                px[x] = i; py[x] = j;
            }

        for(int i = r*c; i >= 1; i--)
            if(i + d > r*c)
                dis[i] = 0;
            else
                dis[i] = dis[i+d] + abs(px[i+d]-px[i]) + abs(py[i+d]-py[i]);

        cin >> q;
        while(q--)
        {
            cin >> x >> y;
            cout << dis[x] - dis[y] << '\n'; 
        }
    }    
    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

bool isK(ll a){
    string t = to_string(a);
    if(t[0]==t[4]&&t[1]==t[3]){
        return true;
    }else{
        return false;
    }
}

ll a[100005];

int main() {
    FOR(i,10000,100000){
        if(isK(i)){
            a[i] = 1;
        }
    }
    cin >> n >> m;
    FOR(i,n,m+1){
        if(a[i]==1){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 896
#include<stdio.h>
#define N 100

int main(){
  int a[N][N], b[N], n, m, sum, i, j;

  scanf("%d%d",&n,&m);

  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&a[i][j]);
    }
  }

  for(i=0;i<m;i++) scanf("%d",&b[i]);
  
  for(i=0;i<n;i++){
    sum=0;
    for(j=0;j<m;j++){
      sum+=a[i][j]*b[j];
    }
    printf("%d\n",sum);
  }
  
  return 0;
}



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

int main(){
  
  long int n,i;
  cin>>n;
  vector<long int>arr(n),lm(n),rm(n);
  
  for(i=0;i<n;i++)
    cin>>arr[i];
  
  lm[0]=arr[0];
  
  for(i=1;i<n;i++)
    lm[i] = max(lm[i-1],arr[i]);
  
  rm[n-1] = arr[n-1];
  for(i=n-2;i>=0;i--)
    rm[i] = max(rm[i+1],arr[i]);
  
  cout<<rm[1]<<endl;
  for(i=1;i<n-1;i++)
    cout<<max(lm[i-1],rm[i+1])<<endl;
  cout<<lm[n-2];
  return 0;
}
    

Measured memory_bytes: 6272
# 2020/05/04
# AtCoder Beginner Contest 102 - C

# Input
n = int(input())
a = list(map(int,input().split()))
ami = list()

for i in range(n):
    ami.append(a[i] - (i+1))

ami.sort()
medi = ami[n // 2]

wk_val = 0
for j in range(n):
    wk_val = wk_val + abs(a[j]-(medi+j+1))

ans = wk_val

# Output
print(ans)


Measured memory_bytes: 26832
/**
     *    author:  shashank_hire
    **/
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define ld long double
#define MOD 1000000007

int main()
{
    IOS;
    ll n, a, b, c, ma, mb, mc, tma, tmb, tmc;
    cin>>n>>ma>>mb>>mc;
    // cout<<ma<<" "<<mb<<" "<<mc<<"\t";
    // cout<<ma<<" "<<mb<<" "<<mc<<"\n";
    n--;
    while(n--)
    {
        cin>>a>>b>>c;
        tma = ma;
        tmb = mb;
        tmc = mc;
        ma = a + max(tmb, tmc);
        mb = b + max(tma, tmc);
        mc = c + max(tma, tmb);
        // cout<<a<<" "<<b<<" "<<c<<"\t";
        // cout<<ma<<" "<<mb<<" "<<mc<<"\n";
    }
    cout<<max({ma, mb, mc})<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int main() {
  int N;
  scanf("%d %*d", &N);

  int min=1e9+1;
  int maxprofit=0, res=0;
  for (int i=0; i<N; ++i) {
    int A;
    scanf("%d", &A);

    if (A < min)
      min = A;

    if (A - min == maxprofit) {
      ++res;
    } else if (A - min > maxprofit) {
      maxprofit = A - min;
      res = 1;
    }
  }

  printf("%d\n", res);
  return 0;
}


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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let mut hs = vec![0; n];
    for i in 0..n {
        hs[i] = read::<usize>();
    }
    hs.sort();
    let mut ans = 1 << 30;
    for i in 0..(n - k + 1) {
        let d = hs[i + k - 1] - hs[i];
        ans = std::cmp::min(ans, d);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
h, w, kkk = map(int, input().split())
choco = [0]*h
for i in range(h):
  choco[i] = input()
answer = h+w-2
for i in range(max([2**(h-1), 1])):
  flag = True
  board = [0]*(h-1)
  for j in range(h-1):
    if (i >> j)&1:
      board[j] = 1
  count = sum(board)
  key = [0]*(count+1)
  ans = count
  for p in range(w):
    max_board = [0]*(count+1)
    k = 0
    for q in range(h):
      if choco[q][p] == "1":
        max_board[k] += 1
      if q == h-1:
        if max(max_board) > kkk:
          flag = False
        break
      if board[q] == 1:
        k += 1
  if not flag:
    continue
  for p in range(w):
    k = 0
    for q in range(h):
      if choco[q][p] == "1":
        key[k] += 1
      if q == h-1:
        break
      if board[q] == 1:
        k += 1
    for u in range(count+1):
      if key[u] <= kkk:
        continue
      ans += 1
      key = [0]*(count+1)
      k = 0
      for q in range(h):
        if choco[q][p] == "1":
          key[k] += 1
        if q == h-1:
          break
        if board[q] == 1:
          k += 1
      break
  if ans < answer and flag:
    answer = ans
print(answer)

Measured memory_bytes: 52572
n,q=map(int,input().split())
s=input()
lr=[list(map(int,input().split())) for _ in range(q)]
c=[0]*n
for i in range(n-1):
    c[i+1]=c[i]
    if s[i]=="A" and s[i+1]=="C":
        c[i+1]+=1
for i in range(q):
    st=lr[i]
    l=st[0]
    r=st[1]
    print(c[r-1]-c[l-1])

Measured memory_bytes: 68952
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <stack>
#include <queue>
using namespace std;

int main(){

    int a[3],b[3];
    int c[3][3];

    for(int i = 0; i < 3; ++i){
        cin >> c[i][0] >> c[i][1] >> c[i][2];
    }

    b[0] = c[0][0];
    b[1] = c[0][1];
    b[2] = c[0][2];
    a[1] = c[1][0] - c[0][0];
    a[2] = c[2][0] - c[0][0];

    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j){
            if(c[i][j] != a[i] + b[j]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    string s;
    cin >> s;
    int n = s.size();
    vi v;
    v.push_back(-1);
    rep(i,n)if(s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T'){
        v.push_back(i);
    }
    v.push_back(n);
    int ans = 0;
    rep(i,v.size()-1){
        ans = max(ans, v[i+1]-v[i]-1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;
 
 
const long long INFLL = 1LL << 60;
const int INFI = 1000000000;
 
long long GCD(long long a, long long b){
    if(a<b){long long t=a; a=b; b=t;}
    if(b==0) return a;
    return(GCD(a%b, b));
}
 
int main(){
    long long  N,X; cin >> N >> X;
    long long ans;
    for(int i=0;i<N;i++){
        long long n; cin >> n;
        if(i==0) {ans = abs(n-X); continue;}
        ans = GCD(abs(n-X), ans);
    }
    cout << ans << endl;
 
}

Measured memory_bytes: 256
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

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

type UnWeightedGraph = ResizeArray<int> array

[<RequireQualifiedAccess>]
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module UnWeightedGraph =
    let inline init (n: int): UnWeightedGraph = Array.init n (fun _ -> ResizeArray<int>())

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

let main() =
    let [| n; q |] = reada int
    let tree = UnWeightedGraph.init n
    for i in 0 .. n - 2 do
        let [| a; b |] = reada int
        let a, b = a - 1, b - 1
        tree.[a].Add(b)
        tree.[b].Add(a)
    let sums = Array.zeroCreate n
    for _ in 1 .. q do
        let [| p; x |] = reada int
        let p, x = p - 1, int64 x
        sums.[p] <- sums.[p] + x

    let rec dfs p v =
        for nv in tree.[v] do
            if nv <> p then
                sums.[nv] <- sums.[nv] + sums.[v]
                dfs v nv
    dfs 0 0
    String.Join(" ", sums) |> puts
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()


Measured memory_bytes: 78328
#include <stdio.h>
long long min(long long a,long long b){
    return a<b?a:b;
    
}
int main()
{   int n,m,l;
    scanf("%d%d%d",&n,&m,&l);
    int a[m],b[m],c[m];
    long long pathmap[301][301];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            pathmap[i][j]=1145141919;
        }
    }
    for(int i=0;i<m;i++){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        pathmap[a[i]][b[i]]=c[i];
        pathmap[b[i]][a[i]]=c[i];
    }
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                pathmap[i][j]=min(pathmap[i][j],pathmap[i][k]+pathmap[k][j]);
            }
        }
    }
    long long fuelmap[301][301];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            fuelmap[i][j]=1145141919;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(pathmap[i][j]<=l){
                fuelmap[i][j]=1;
                fuelmap[j][i]=1;
            }
        }
    }
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                fuelmap[i][j]=min(fuelmap[i][j],fuelmap[i][k]+fuelmap[k][j]);
            }
        }
    }
    
    int q;
    scanf("%d",&q);
    int s[q],t[q];
    for(int i=0;i<q;i++){
        scanf("%d%d",&s[i],&t[i]);
        if(fuelmap[s[i]][t[i]]<1145141919){
        printf("%lld\n",fuelmap[s[i]][t[i]]-1);
        }else{
            printf("-1\n");
        }
    }

    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;cin>>n;

    set<ll> st;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            ll t=n;
            while(t%i==0) t/=i;
            if(t%i==1) st.insert(i);
        }
    }
    for(ll i=1;i*i<=n-1;i++){
        if((n-1)%i==0){
            st.insert(i);
            st.insert((n-1)/i);
        } 
    }
    st.erase(1);
    st.insert(n);

    cout<<st.size()<<"\n";
    
    return 0;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main()
{
	ll X;
	cin >> X;
	ll x = 100;
	ll i = 0;

	while(X != 1){
		x = x * 1.01;
		i++;
		if(x>=X){
			cout << i;
			break;
		}
	}

	cin >> x;
	
	return 0;	
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll dp[n+1];
  mem(dp);
  dp[0]=1;
  rep(i,n) {
    REP(j,3,n+1) {
      if(i+j<=n) {
        dp[i+j]+=dp[i];
        dp[i+j]%=MAX;
      }
    }
  }
  pr(dp[n]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  string S;
  cin >> S;
  for(int i=0; i<S.length()/2; ++i){
    if(S.at(i)!=S.at(S.length()-i-1)){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i=0; i<(S.length()-1)/2/2; ++i){
    if(S.at(i)!=S.at((S.length()-1)/2-1-i)){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i=(S.length()+3)/2-1; i<S.length(); ++i){
    if(S.at(i)!=S.at(S.length()-i-1)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
w = tx - sx
h = ty - sy
ans =""
ans += "U" * h
ans += "R" * w
ans += "D" * h
ans += "L" * (w+1)
ans += "U" * (h+1)
ans += "R" * (w+1)
ans += "D"
ans += "R"
ans += "D" * (h+1)
ans += "L" * (w+1)
ans += "U"
print(ans)

Measured memory_bytes: 3064
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
using namespace std;

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

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

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

  vector<int> s(N);
  for (int i = 0; i < N; ++i) {
    int t;
    cin >> t;
    s[i] = t;
  }
  int sum = accumulate(s.begin(), s.end(), 0);
  if (sum % 10 == 0) {
    sort(s.begin(), s.end());
    bool flag = false;
    for (int i = 0; i < N; ++i) {
      if (s[i] % 10 == 0) {
        continue;
      }
      cout << sum - s[i];
      flag = true;
      break;
    }

    if (!flag) {
      cout << 0;
    }
  } else {
    cout << sum;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long;
#define ld long double
#define pb push_back
const int mod=1e9+7;
const int mxN=2e6+3;

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

    long long sum=0;
    for(int i=0,maxnum=0;i<n;i++){
        maxnum=max(a.at(i),maxnum);
        sum+=maxnum-a.at(i);
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3952
def iskaibun(s):
    lens=len(s)
    #print(s)
    for i in range(lens // 2):
        #print("{} {}".format(s[i],s[lens-1-i]))
        if s[i] != s[lens-1 - i]:
            return False
    
    return True
    
s = input()
lens=len(s)
#print(s[0: (lens - 2) // 2+1])
#print(s[(lens + 2) // 2 : lens])
if iskaibun(s) and iskaibun(s[0: (lens - 1) // 2]) and iskaibun(s[(lens + 2) // 2 : lens]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>
#include <queue>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int N;
std::vector<int> a;
std::vector<int> b;
std::vector<int> c;

using Graph = std::vector<std::vector<int>>;
Graph G;

int current;
std::vector<int> score;

void dfs(const int v, const int p) {
  // score[v] = c[current++];
  // assert(current <= N);
  for (auto u : G[v]) {
    if (u == p)
      continue;
    score[u] = c[current++];
    dfs(u, v);
  }
}

int main() {
  // Input
  std::cin >> N;
  a.resize(N);
  b.resize(N);
  for (int i = 0; i < N - 1; ++i) {
    std::cin >> a[i] >> b[i];
    --a[i];
    --b[i];
  }
  c.resize(N);
  for (int i = 0; i < N; ++i)
    std::cin >> c[i];
  std::sort(c.begin(), c.end(), std::greater<int>());

  // Main
  G.resize(N);
  for (int i = 0; i < N; ++i) {
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }

  int current = 0;

  std::queue<int> que;
  std::vector<bool> visited(N);
  std::vector<int> score(N, -1);
  visited[0] = true;
  que.push(0);
  while (not que.empty()) {
    int v = que.front();
    que.pop();

    score[v] = c[current++];
    assert(current <= N);

    for (auto u : G[v]) {
      if (visited[u])
        continue;
      visited[u] = true;
      que.push(u);
    }
  }

  // Output
  int res = 0;
  for (int i = 1; i < N; ++i)
    res += c[i];
  std::cout << res << std::endl;
  for (int i = 0; i < N; ++i)
    std::cout << score[i] << " ";

  return 0;
}


Measured memory_bytes: 1024
n=int(input())
aa=list(map(int,input().split()))
q=int(input())
bc=[list(map(int,input().split())) for i in range(q)]
ans=sum(aa)
ind=[0]*(10**5)
for i in aa:
  ind[i-1]+=1
for b,c in bc:
  ans+=(c-b)*(ind[b-1])
  ind[c-1]+=ind[b-1]
  ind[b-1]=0  
  print(ans)
  
  

Measured memory_bytes: 32252
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,s[101],b,i,j;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%d",&s[i]);
	}
	for(i=1;i<=m;i++){
		for(j=1;j<n;j++){
			if(s[j]%i>s[j+1]%i){
				swap(s[j],s[j+1]);
			}
		}
	}
	for(i=1;i<=n;i++){
		printf("%d\n",s[i]);
	}
	return 0;
}


Measured memory_bytes: 2732
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0017
{
    public class Program

    {
        public static void Main(string[] args)
        {
            List<int> max = new List<int>();
            int n;

            while (!((n = int.Parse(Console.ReadLine()))== 0))
            {
                List<int> list = new List<int>();
                int sum = 0;
                for (int i = 0; i < n; i++)
                {
                    int num = int.Parse(Console.ReadLine());
                    sum = (sum + num > 0) ? sum + num : 0;
                    if (sum > 0)
                    {
                        list.Add(sum);
                    }
                    else
                    {
                        list.Add(num);
                    }
                }
                max.Add(list.Max());
            }

            foreach (int item in max)
                Console.WriteLine(item);     
        }
    }

}


Measured memory_bytes: 16232