akhauriyash/Code-Regression huggingface dataset:
def main():
    n,x,y = map(int,input().split(' '))
    cost = [0 for i in range(n - 1)]
    for i in range(n - 1):
        for l in range(i + 1, n):
            result = min(abs(i - l),abs(i - x + 1) + 1 + abs(l - y + 1),abs(i - y + 1) + 1 + abs(l - x + 1))
            cost[result - 1] += 1
    for per in cost:
        print(per)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
def divisor(n):
    if n % 2 == 0:
        return 2
    elif n % 3 == 0:
        return 3
    maxitr = intSqrt(n)
    i = 1
    while True:
        i += 4
        if i > maxitr:
            return n
        elif n % i == 0:
            return i
        i += 2
        if i > maxitr:
            return n
        elif n % i == 0:
            return i


def factorization(n, simple=True):
    result = []
    while n > 1:
        div = divisor(n)
        result.append(div)
        n //= div
    return result


def intSqrt(n):
    x = 1
    while True:
        x2 = (x + n // x) // 2
        if abs(x - x2) <= 1:
            break
        x = x2
    return x2


def ABC052C(n):
    factor = []
    for i in range(2, n+1):
        factor.extend(factorization(i))
    # index, counts = sp.unique(factor, return_counts=True)
    d = {}
    for c in factor:
        if c in d.keys():
            d[c] += 1
        else:
            d.setdefault(c, 1)
    ans = 1
    for key, value in d.items():
        ans = (ans * (value + 1)) % 1000000007
    print(ans)

ABC052C(int(input()))


Measured memory_bytes: 3064
package main

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

func main() {
	sc := NewScanner(os.Stdin)
	S := sc.Next()
	a := S[:2]
	b := S[2:]
	aMM := a >= "01" && a <= "12"
	bMM := b >= "01" && b <= "12"
	switch {
	case aMM && bMM:
		fmt.Println("AMBIGUOUS")
	case !aMM && bMM:
		fmt.Println("YYMM")
	case aMM && !bMM:
		fmt.Println("MMYY")
	default:
		fmt.Println("NA")
	}
}

func vmin(v []int) int {
	mn := math.MaxInt32
	for i := 0; i < len(v); i++ {
		mn = min(mn, v[i])
	}
	return mn
}

func gcd(x, y int) int {
	if y > 0 {
		return gcd(y, x%y)
	}
	return x
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

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

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

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt64() int64 {
	i, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#define INF 1000000
#define MAX_V 10

using namespace std;

int cost[MAX_V][MAX_V];
int d[MAX_V];
bool used[MAX_V];
int V=10;
int a[40010],c[10];

void dijkstra(int s){
	fill (d,d+V,INF);
	fill (used,used+V,false);
	d[s] = 0;
	
	while(true){
		int v = -1;
		for(int u=0;u<V;u++){
			if(used[u]!=true && (v==-1 || d[u]<d[v])){
				v = u;
			}
		}
		if(v==-1){
			break;
		}
			
		used[v] = true;
			
	
		for(int u = 0; u<V;u++){
			d[u] = min(d[u],d[v]+cost[v][u]);
		}
	}
}

int main(){
	int i,j,h,w,ans=0;
	cin >> h >> w;
	for(i=0;i<=9;i++){
		for(j=0;j<=9;j++){
			cin >> cost[i][j];
			if(i==j){
				cost[i][j] = INF;
			}
		}
	}
	
	for(i=0;i<h*w;i++){
		cin >> a[i];
	}
	
	for(i=0;i<=9;i++){
		dijkstra(i);
		c[i] = d[1];
	}
	
	for(i=0;i<h*w;i++){
		ans += c[a[i]];
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
 
int main () {
  char x;
  cin >> x;
  string n = "aeiou";
  for (int i = 0; i < n.length(); i ++){
    if (x == n[i]){
      cout << "vowel\n";
      return 0;
    }
  }
  cout << "consonant\n";
}

Measured memory_bytes: 3056
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false; cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

struct Point{ lli x, y; };

lli n;
vector<Point> p[2];
int main() {
  cin >> n;
  p[0] = p[1] = vector<Point>(n);
  for (int j=0; j<=1; ++j) {
    for (int i=0; i<n; ++i) cin >> p[j][i].x >> p[j][i].y;
    sort(begin(p[j]), end(p[j]), [](auto&& a, auto&& b) { 
      return a.x != b.x ? a.x < b.x : a.y < b.y; 
    });
  }
  vector<bool> t(n, false);
  for (int i=0; i<n; ++i) {
    auto& b = p[1][i];
    lli k = -1, ty = -1;
    for (int j=0; j<n; ++j) {
      if (t[j]) continue;
      auto& r = p[0][j];
      if (r.x < b.x && r.y < b.y && ty < r.y) {
	k = j; ty = r.y;
      }
    }
    if (k>=0) t[k] = true;
  }
  lli ans = count(begin(t), end(t), true);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

const bool IsACGT(const char ch)
{
    return ch == 'A' || ch == 'C'
        || ch == 'G' || ch == 'T';
}

int main()
{
    string S;
    cin >> S;
    int maxLen = 0;
    int len = 0;
    for (const char ch : S)
    {
        if (IsACGT(ch))
        {
            ++len;
        }
        else
        {
            len = 0;
        }
        if (len > maxLen) maxLen = len;
    }
    cout << maxLen;
}

Measured memory_bytes: 256
import random
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
t = [int(input()) for _ in range(d)]
ans = 0
last = [0]*26
for i in range(1,d+1):
    #x = 0
    x = t[i-1]-1
    #x = random.randrange(26)
    last[x] = i
    ans += s[i-1][x]
    for j in range(26):
        ans -= c[j]*(i-last[j])
    print(ans)
    

Measured memory_bytes: 9804
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()

class Heap(object):
    def __init__(self, A):
        self._heap = A[:]
        # heapify in linear time
        for i in range((len(A))//2-1,-1,-1): self._descend(i)

    def __len__(self):
        return len(self._heap)

    def __bool__(self):
        return bool(self._heap)

    def _descend(self, i):
        heap = self._heap
        now = i
        # i の子は 2i+1, 2i+2
        while(1):
            if now*2+1 >= len(self): break # 子が存在しない
            # 子がひとつだけのとき、必要なら入れ替えて終わり
            if now*2+1 == len(self)-1:
                if heap[now] > heap[now*2+1]:
                    heap[now], heap[now*2+1] = heap[now*2+1], heap[now]
                break
            # 子が複数のとき
            else:
                # 親、子1、子2のうち、親が最小であれば終わり
                if min(heap[now], heap[2*now+1], heap[2*now+2]) == heap[now]: break
                # そうでないとき、子のうち小さい方を親と入れ替える
                next = min((heap[2*now+1],2*now+1), (heap[2*now+2],2*now+2))[1]
                heap[now], heap[next] = heap[next], heap[now]
                now = next

    def front(self):
        assert self
        return self._heap[0]

    def append(self, x):
        self._heap.append(x)
        now = len(self)-1
        heap = self._heap
        # i の親は (i-1)//2
        while now!=0 and heap[now] < heap[(now-1)//2]:
            heap[now], heap[(now-1)//2] = heap[(now-1)//2], heap[now]
            now = (now-1)//2

    def pop(self):
        assert self
        if len(self)==1: return self._heap.pop()
        res, self._heap[0] = self._heap[0], self._heap.pop()
        self._descend(0)
        return res

def resolve():
    n, m = map(int,input().split())
    A = list(map(lambda x:-int(x),input().split()))
    heap = Heap(A)
    for _ in range(m):
        x = -heap.pop()
        x //= 2
        heap.append(-x)

    print(-sum(heap._heap))
resolve()

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

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

  for (int i = 0; i < s.length(); i++)
  {
    if (s[i] != t[i])
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3628
#include <iostream>
const int N=106;
using namespace std;
int a[N];
int main(){
	int n,k; cin>>n>>k;
	for(int i=0;i<k;i++){
		int num; cin>>num;
		while(num--){
			int temp;  cin>>temp;
			a[temp]++;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(a[i]==0) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3600
/**
 * n ????????´??°???????????°??? S ??¨???q ????????°????????´??°???????????°??? T ??????????????????T ?????????????????´??°????????§ S ?????????????????????????????° C ???????????????????????°????????????????????????????????????

??\???
???????????? n??????????????? S ?????¨??? n ????????´??°??????????????? q??????????????? T ?????¨??? q ????????´??°????????????????????????

??????
C ???????????????????????????????????????

??¶?´?
n???10,000
q???500
0???S???????´????10^9
0???T???????´????10^9
T ???????´???????????????°??????
??\?????? 1
5
1 2 3 4 5
3
3 4 1
????????? 1
3
??\?????? 2
3
3 1 2
1
5
????????? 2
0
 */

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>

int main(int argc, char const *argv[]) {
  std::vector<unsigned int> S;
  std::vector<unsigned int> T;
  std::string Param;
  std::istringstream iss;
  unsigned short n = 0;
  unsigned short q = 0;
  getline(std::cin, Param);
  iss.str(Param);
  iss >> n;
  iss.clear();
  getline(std::cin, Param);
  iss.str(Param);
  unsigned int Si;
  for (size_t i = 0; i < n; i++) {
    iss >> Si;
    S.push_back(Si);
  }
  iss.clear();
  getline(std::cin, Param);
  iss.str(Param);
  iss >> q;
  iss.clear();
  getline(std::cin, Param);
  iss.str(Param);
  unsigned int Ti;
  for (size_t i = 0; i < q; i++) {
    iss >> Ti;
    T.push_back(Ti);
  }
  unsigned short C = 0;
  for (const auto &e : T) {
    auto Result = find(S.begin(), S.end(), e);
    if (Result != S.end()) {
      C++;
    }
  }
  std::cout << C << std::endl;
  return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    int x; cin >> x;
    int i = 1;
    int ans =0;
    while (x > 0) {
        x -= i;
        i++;
        ans++;
    }

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

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

int main(){
  int a,b;
  char op;
  while(cin>>a>>op>>b){
    switch(op){
    case '+': cout<<a+b<<endl;
      break;
    case '-': cout<<a-b<<endl;
      break;
    case '*': cout<<a*b<<endl;
      break;
    case '/': cout<<a/b<<endl;
      break;
    case '?': break;
    }
  }
}

Measured memory_bytes: 3096
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    S = input()[:-1]

    n = len(S)
    if S == S[::-1] and S[:(n-1)//2] == S[:(n-1)//2][::-1] and S[(n+3)//2 - 1:] == S[(n+3)//2 - 1:][::-1]:
        print("Yes")
    else:
        print("No")
    

if __name__ == '__main__':
    main()

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

using ll = long long;

// 再帰関数による最大公約数
ll gcd(int x, int y) {
  if(y == 0) return x;
  return gcd(y, x % y);
}


// gcdを利用した最小公倍数
ll lcm(int x, int y) {
  return x / gcd(x, y) * y;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b;
  cin >> a >> b;
  
  cout << lcm(a, b) << "\n";
}

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

int main() {
	int n, m;
	string s[110];
	string t[110];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int cnt = 0;
		for (int j = 0; j < n; j++) {
			if (s[i] == s[j])cnt++;
		}
		for (int j = 0; j < m; j++) {
			if (s[i] == t[j])cnt--;
		}
		if (cnt > ans)ans = cnt;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,cnt=0;
    cin>>a;
    int arr[a];
    for(int i=0; i<a; i++)
        cin>>arr[i];
    sort(arr,arr+a);
    for(int i=0; i<a-1; i++)
        cnt+=abs(arr[i]-arr[i+1]);
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		D();
	}
	
	public static void A() {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = sc.next();
		if(s1.compareTo(s2) < 0) System.out.println("<");
		else if(s1.compareTo(s2) == 0) System.out.println("=");
		else System.out.println(">");
	}
	
	public static void B() {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		if(X<Y || X<Z) {
			System.out.println(0);
			return;
		}
		X -= Z;
		System.out.println(X/(Y+Z));
	}
	
	public static void C() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		sc.close();
		int ret = (int) ((M*1900+(N-M)*100)*Math.pow(2, M));
		System.out.println(ret);
	}
	
	//必ず、最後のカードはひく
	//X,yそれぞれがひく場合を考えうr
	public static void D() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Z = sc.nextInt();
		int W = sc.nextInt();
		if(N==1) {
			System.out.println(Math.abs(W-sc.nextInt()));
			return;
		}
		for(int i=0;i<N-2;i++) {
			sc.nextInt();
		}
		int lastm = sc.nextInt();
		int last = sc.nextInt();
		sc.close();
		int cand1 = Math.abs(lastm-last);
		int cand2 = Math.abs(last- W);
		System.out.println(cand1>cand2? cand1 : cand2);
	}
}

Measured memory_bytes: 25812
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] -= 1
li = [False] * N
f = True
now = 0
l = []
l2 = [0] * N
i = 0
while f:
    l.append(now)
    li[now] = True
    l2[now] = i
    if li[A[now]]:
        f = False
        num = len(l) - l2[A[now]]
        n = l2[A[now]]
    i += 1
    now = A[now]
k = (K-n) % num
print(l[min(K, n+k)]+1)

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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b;
  cin >> a >> b;
  if (a - b * 2 > 0) {
    cout << a - b * 2 << endl;
  } else {
    cout << 0 << endl;
  }
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

ll solve(ConnectNodeInfo& connect,int R){
	int N=connect.size();
	vector<pair<ll,ll>> mins(N,make_pair(1LL<<60,-1));
	REP(i,N){
		for(auto& x:connect[i]){
			mins[x.first] = min(mins[x.first],make_pair(x.second,(ll)i));
		}
	}
	mins[R] = make_pair(-1,-1);

	vector<ll> group(N,0),comp(N,0),used(N,0);
	ll cost = 0;

	REP(i,N){
		if(used[i]) continue;
		vector<int> chain;
		int cur = i;
		while(cur!=-1 && !used[cur]){
			chain.emplace_back(cur);
			used[cur] = 1;
			cur = mins[cur].second;
		}
		if(cur!=-1){
			int cycle = 0;
			for(auto& e:chain){
				group[e] = cost;
				if(e==cur){
					cycle = 1;
					comp[cost] = 1;
				}
				if(!cycle) cost++;
			}
			if(cycle) cost++;
		}
		else{
			for(auto& e:chain){
				group[e] = cost;
				cost++;
			}
		}
	}
	if(cost==N){
		ll sum = 0;
		for(auto& x:mins) sum += x.first;
		return sum+1;
	}

	ll res = 0;
	REP(i,N){
		if(i!=R && comp[group[i]]){
			res += mins[i].first;
		}
	}

	ConnectNodeInfo new_connect(cost);
	REP(i,N){
		for(auto& x:connect[i]){
			ll gs = group[i],gt = group[x.first];
			if(gs==gt) continue;
			if(comp[gt]){
				new_connect.AddDirectionalConnection(gs,gt,x.second-mins[x.first].first);
			}
			else{
				new_connect.AddDirectionalConnection(gs,gt,x.second);
			}
		}
	}
	return res + solve(new_connect,group[R]);
}

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

	int N=in(),E=in(),R=in();
	ConnectNodeInfo connect(N);
	REP(i,E){
		int u=in(),v=in(),w=in();
		connect.AddDirectionalConnection(u,v,w);
	}

	out(solve(connect,R));
	return 0;
}


Measured memory_bytes: 3764
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

A.sort()
temp = 0

if N % 2 == 1:
    w = -2*sum(A[:N//2]) +A[N//2] +A[N//2 + 1] + 2*sum(A[N//2 + 2:])
    m = -2*sum(A[:N//2-1]) - A[N//2 - 1] - A[N//2] + 2*sum(A[N//2+1:])
    print(max(w, m))
else:
    print(-2*sum(A[:N//2-1]) - A[N//2-1] + A[N//2] + 2*sum(A[N//2+1:]))

Measured memory_bytes: 7504
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int r, d, x;

  cin >> r >> d >> x;

  for (int i=0; i<10; i++) {
    x = r * x - d;
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}


double calc(double w,double s){return (s * 100.0) / (w + s);}

signed main(){
  int A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;
  
  int sw=A*100,s=0;
  for(int i=0;i<=(F/100);i++)
    for(int j=0;j<=(F/100);j++){
      int water = 100 * (A * i + B * j);
      for(int k = 0;k<= F ;k++){
        int l = min((F - water - k*C)/D,((water*E)/100 - k*C) / D);
        int sugar = k*C + l*D;
        if(l < 0 || water + sugar > F || (water*E/100) < sugar) continue;
        //if(water + sugar == 2634 || water+sugar == 2624)cout<<water<<" "<<sugar<<endl,
        //                         cout<<water*E/100 <<" "<< sugar<<endl,
        //                         cout<<calc(water,sugar)  - calc(sw,s)<<endl;
        
        if(calc(water,sugar)  > calc(sw,s)) sw = water ,s = sugar;
      }
    }
  
  
  if(sw+s == 0) cout<<A*100<<" "<<0<<endl;
  else cout<<sw+s<<" "<<s<<endl;
      
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  string s, t;
  cin >> s >> t;
  int x = s.size();
  int y = t.size();
  int dp[x + 1][y + 1] = {};

  rep(i, x) {
    rep(j, y) {
      if (s[i] == t[j])
        dp[i + 1][j + 1] = dp[i][j] + 1;
      else
        dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
    }
  }
  string ans = "";
  while (x > 0 && y > 0) {
    if (dp[x][y] == dp[x - 1][y])
      x--;
    else if (dp[x][y] == dp[x][y - 1])
      y--;
    else {
      x--;
      y--;
      ans += s[x];
    }
  }
  reverse(all(ans));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
        #define PI 3.14159265358979323846
        #define MAXINF (1e18L)
        #define INF (1e9L)
        #define EPS (1e-9)
        #define MOD ((ll)(1e9+7))
        #define REP(i, n) for(int i=0;i<int(n);++i)
        #define Rep(i,sta,n) for(int i=sta;i<n;i++)
        #define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
        #define ALL(v) v.begin(),v.end()
        #define FIND(v,x) (binary_search(ALL(v),(x)))
        #define SORT(v) sort(ALL(v))
        #define RSORT(v) sort(ALL(v));reverse(ALL(v))
        #define DEBUG(x) cerr<<#x<<": "<<x<<endl;
        #define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
        #define Yes(n) cout<<((n)?"Yes":"No")<<endl
        #define YES(n) cout<<((n)?"YES":"NO")<<endl
        #define pb push_back
        #define fi first
        #define se second
        using namespace std;
        template<class A>void pr(A a){cout << (a) << endl;}
        template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
        template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
        template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
        template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
        template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
        typedef long long ll;
        typedef pair<int, int> pii;
        typedef pair<ll,ll> pll;
        
        int main(void)
        {
            int N;
            cin >> N;
            int A,B,C,D;
            cin >> A >> B >> C >> D;
            string S;
            cin >> S;

            S = '#' + S + '#';

            if(C<D){
                Rep(i, A, D+1){
                    if(S[i] == '#' && S[i+1] == '#'){
                        Yes(false);
                        return 0;
                    }
                }
                Yes(true);
                return 0;
            }else{
                bool f=false;
                Rep(i, A, C+1){
                    if(S[i] == '#' && S[i+1] == '#'){
                        Yes(false);
                        return 0;
                    }
                }
                Rep(i, B, D+1){
                    if(S[i-1] == '.' && S[i] == '.' && S[i+1] == '.'){
                        f = true;
                    }  
                }
                Yes(f);
                return 0;
            }
        }

Measured memory_bytes: 772
#include<bits/stdc++.h>
#define lli unsigned long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

void solve(){
	lli n; cin>>n;
	string s; set<string> st; map<string,lli> mpp;
	vector<pair<lli,string> > vpp;
	vector<string> ss;
	NA(i,0,n){
		cin>>s; st.insert(s);
		mpp[s]++;
	}
	for(string t:st) vpp.pb({mpp[t], t});
	sort(vpp.begin(), vpp.end());
	// cout<<vpp[vpp.size()-1].second<<'\n';
	ss.pb(vpp[vpp.size()-1].second);
    for(lli i=vpp.size()-2; i>=0; --i){
		if(vpp[i].first!=vpp[i+1].first) break;
		// cout<<vpp[i].second<<'\n';
		ss.pb(vpp[i].second);
	}
	sort(ss.begin(), ss.end());
	NA(i,0,ss.size()) cout<<ss[i]<<'\n';
	return;
}
int main(){
    fastIO;
    solve();
    return 0;
}




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

int top, S[1000];

void push(int x){
  S[++top] = x;
}
int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top=0;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a + b);
    }
    else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a - b);
    }
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a * b);
    }
    else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int h[n+1][4];
    for(int i=1;i<=n;i++)
        cin >> h[i][1] >> h[i][2] >> h[i][3];
    int dp[n+1][4] ={0,};
    memset(dp,0,sizeof(dp));
    dp[1][1] = h[1][1];
    dp[1][2] = h[1][2];
    dp[1][3] = h[1][3];
    for(int i=2;i<=n;i++){
            dp[i][1] = max(dp[i-1][2] + h[i][1] , dp[i-1][3] + h[i][1]);
            dp[i][2] = max(dp[i-1][1] + h[i][2] , dp[i-1][3] + h[i][2]);
            dp[i][3] = max(dp[i-1][1] + h[i][3],dp[i-1][2]+ h[i][3]);
    }
    cout<< max(max(dp[n][1],dp[n][2]),dp[n][3]) <<endl;

}

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

char s[111];
int n,i;

int main(){
    scanf("%s%d",s,&n);
    while(n--){
        if (s[i] != '1'){
            printf("%c\n",s[i]);
            return 0;
        }
        i++;
    }
    puts("1");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
  
    int a; cin >> a;
    cout << a * a * 3 << endl;   
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,j,s=0,c=0,p=1,m;
	char a[200][200];
	for(i=0;i<=100;i++)
	for(j=0;j<=100;j++)
	a[i][j]='-';
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		scanf(" %c",&a[i][j]);
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(a[i][j]=='.')
			{
				int c=0;
				for(int k=-1;k<=1;k++)
				{
					for(int l=-1;l<=1;l++)
					{
						if(l==0 && k==0)
						continue;
						if(a[i+k][j+l]=='#')
						c++;
					}
				}
				a[i][j]=c+'0';
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			printf("%c",a[i][j]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> edges[100005];
void dfs(vector<int>& dp, int k){
	for(int i=0; i<edges[k].size(); i++){
		if(dp[edges[k][i]] == -1)
			dfs(dp, edges[k][i]);
		dp[k] = max(dp[edges[k][i]] + 1, dp[k] );
	}
}
int main()
{
	int n, m;
	cin>>n>>m;
	for(int i=0; i<m; i++){
		int a, b;
		cin>>a>>b;
		edges[a].push_back(b);
	}
	int ans = 0;
	vector<int> dp(n+1, -1);
	for(int i=1; i<=n; i++)
		edges[0].push_back(i);
	dfs(dp, 0);
	cout<<dp[0];
}


Measured memory_bytes: 8696
#include <stdio.h>

int main(void){
  int N;
  char S[100];
  int i, j, k;
  int flag;
  scanf("%d", &N);
  for(i = 0; i < N; i++){
    scanf("%c", &S[i]);
  }
  flag = 0;
  for(i = 0; i < N; i++){
    if(S[i] == 'Y'){
      flag = 1;
      break;
    }
  }
  if(flag == 0){
    printf("Three\n");
  }
  if(flag == 1){
    printf("Four\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
    ll pow2[63]={}; // 2^n
    pow2[0]=1;
    for(int i=1; i<63; i++){
        pow2[i]=2*pow2[i-1];
    }

    // keta <= 54
    ll num_keta[63];
    num_keta[0]=0;
    for(int i=1; i<63; i++){
        num_keta[i] = (pow2[i]-2)*36 + (pow2[i-1]-1)*9;
        //cout<<i<<" "<<num_keta[i]%9<<endl;
    }
    ll sum_keta[63];
    sum_keta[0]=0;
    for(int i=1; i<63; i++){
        sum_keta[i]=sum_keta[i-1]+num_keta[i];
        //cout<<i<<" "<<sum_keta[i]<<endl;
    }

    while(1){
        ll N;
        cin >> N;
        if(N==0){
            break;
        }

        int keta=0;
        while(sum_keta[keta]<N){
            keta++;
        }

        N-=sum_keta[keta-1];
        // その桁数の中でなんばんめか 1-indexed
        //cout<<N<<endl;
        int top_digit;
        top_digit = (N-1)/(num_keta[keta]/9)+1;
        cout<<top_digit;
        N-=(top_digit-1)*(num_keta[keta]/9);
    // 上からiけためを決定
        int first_digit=top_digit;
        int second_digit=-1;
        for(int i=2; i<=keta; i++){
            //cout<<"N " << N << endl;
            if(second_digit==-1){
                ll temp_sum=0;
                ll prev_sum=0;
                for(int x=0; x<=9; x++){
                    prev_sum=temp_sum;
                    if(x!=first_digit){
                        temp_sum+=pow2[keta-i];
                    }else{
                        temp_sum+=(pow2[keta-i]-1)*9;
                    }
                    //cout<<"temp_sum "<<temp_sum<<endl;
                    if(temp_sum>=N){
                        if(x!=first_digit){
                            second_digit=x;
                        }
                        cout<<x;
                        N-=prev_sum;
                        break;
                    }
                }
            }else{
                ll patterns=pow2[keta-i+1];
                if(N<=patterns/2){
                    cout<<min(first_digit, second_digit);
                }else{
                    cout<<max(first_digit, second_digit);
                    N-=patterns/2;
                }
            }


        }
        


        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 3084
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
readString = map BS.unpack . BS.words

getIntList = readIntList <$> BS.getLine
getNString n = map readString <$> replicateM n BS.getLine

compressRow :: [[Char]] -> [[Char]] -> [[Char]]
compressRow [] css' = reverse css'
compressRow (cs : css) css'
  | all (== '.') cs = compressRow css css'
  | otherwise = compressRow css (cs : css')

main = do
  [h, w] <- getIntList
  css <- getNString h
  let css' = map head css
  mapM_ putStrLn (transpose (compressRow (transpose (compressRow css' [])) []))


Measured memory_bytes: 5316
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) { new MainClass().solve(); }

        Scanner cin = new Scanner();

        string S;
        void solve() {
            S = cin.next();

            string[] haiku = S.Split(',');

            foreach (string str in haiku)
                Console.Write(str+" ");
            Console.WriteLine("");

        }
        class Scanner {
            string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
            public Scanner() { nextBuffer = new string[0]; BufferCnt = 0; }
            public string next() {
                if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                BufferCnt = 0;
                return nextBuffer[BufferCnt++];
            }
            public char nextChar() { return char.Parse(next()); }
            public int nextInt() { return int.Parse(next()); }
            public long nextLong() { return long.Parse(next()); }
            public double nextDouble() { return double.Parse(next()); }
            public string[] array() { return Console.ReadLine().Split(' '); }
            public char[] arrayChar() { return Array.ConvertAll(array(), char.Parse); }
            public int[] arrayInt() { return Array.ConvertAll(array(), int.Parse); }
            public long[] arrayLong() { return Array.ConvertAll(array(), long.Parse); }
            public double[] arrayDouble() { return Array.ConvertAll(array(), double.Parse); }
        }

        class Mathf {
            public int mod = 1000000007;//10^9+7
            public long Pow(long a, long b) {
                if (b == 0) return 1;
                if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
                else return Pow(a * a % mod, b / 2) % mod;
            }
            public long Fact(long n) { return n != 0 ? (n % mod * (Fact(n - 1) % mod) % mod) : 1; }
            public long C(long n, long r) {
                if (r == 0 || n == r) return 1;
                else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod;
            }
            public int GCD(int a, int b) { if (a < b) Swap(ref a, ref b); return b == 0 ? a : GCD(b, a % b); }
            public int GCD(int[] array) { return array.Aggregate((v, next) => GCD(v, next)); }
            public void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }
        }
    }
}

Measured memory_bytes: 13140
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC119_2 solver = new ABC119_2();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC119_2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            double total = 0;
            for (int i = 0; i < N; i++) {
                double x = in.nextDouble();
                String u = in.next();
                if (u.compareTo("BTC") == 0) {
                    total += x * 380000;
                } else {
                    total += x;
                }

            }
            out.println(total);
        }

    }
}



Measured memory_bytes: 25172
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort(key=lambda x:x[0])

cost = 0

for i in ab:
        if m > i[1]:
            m -= i[1]
            cost += i[0] * i[1]
            if m == 0:
                break
        else:
            cost += i[0] * m
            m = 0
            break

print(cost)

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

int main(){
    int n, x;
    
    cin >> n;
    
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0) {
            cout << ' ' << i;
        } else {
            x = i;
            do {
                if (x % 10 == 3) {
                    cout << ' ' << i;
                    break;
                } else {
                    x /= 10;
                }
            } while (x);
        }
    }
    
    cout << endl;

    return 0;
}


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

int main(){
    string s,t; cin >> s >> t;
    int a,b; cin >> a >> b;
    string u; cin >> u;
    s == u ? cout << a-1 << " " << b << endl : cout << a << " " << b-1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
  int X; cin >> X;
  int d = 400;
  for (int i = 8; i > 0; i--) {
    if (d <= X && X <= d + 199) {
        cout << i << endl;
        break;
    }
    else {
        d += 200;
    }
  }
}


Measured memory_bytes: 3632
N = int(input())

a = 0
for num1 in range(1,10) :
    for num2 in range(1,10) :
        if N == num1 * num2 :
            a = 1
            break
    if a == 1 :
        break


if a == 1:
    print ('Yes')
else :
    print ('No')

Measured memory_bytes: 3060
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] L = new int[N];
		for(int i = 0; i < N; i++) L[i] = sc.nextInt();
		Arrays.sort(L);
		int sum = 0;
		for(int i = 0; i < K; i++) sum += L[N-1-i];
		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
import copy
from sys import stdin
input = stdin.readline

n,m = map(int,input().split())
h = list(map(int,input().split()))
p = copy.copy(h)
# path = list(list(map(int,input().split())) for x in range(m))
for i in range(m):
    x,y = map(int,input().split())
    if h[x-1] > h[y-1]:
        p[y-1] = 0
    elif h[x-1] < h[y-1]:
        p[x -1] = 0
    elif  h[x-1] == h[y-1]:
        p[y-1] = 0
        p[x-1] = 0
cnt = 0
for k in p:
    if k != 0:
        cnt += 1
# print(h)
print(cnt)

Measured memory_bytes: 21336
#include <iostream>

using namespace std;

int main() {
    int n; cin >> n;
    long long y; cin >> y;
    for(int yu = 0; yu <= n; yu++){
        for(int h = 0; h <= n-yu; h++){
            if(yu*10000 + h*5000 + (n-yu-h)*1000 == y){
                cout << yu << " " << h << " " << n-yu-h << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int score1, score2, score3;
	char seiseki;

	while (1) {
		scanf("%d%d%d", &score1, &score2, &score3);

		if (score1 == -1 && score2 == -1 && score3 == -1){
			break;
		}
		else {

			if (score1 == -1||score2 == -1) {
				seiseki = 'F';
			}
			else if (score1 + score2 >= 80) {
				seiseki = 'A';
			}
			else if (score1 + score2 >= 65) {
				seiseki = 'B';
			}
			else if (score1 + score2 >= 50) {
				seiseki = 'C';
			}
			else if (score1 + score2 >= 30) {
				seiseki = (score3 >= 50) ? 'C' : 'D';
			}
			else {
				seiseki = 'F';
			}
		}

		printf("%c\n", seiseki);
	}

	return 0;
}


Measured memory_bytes: 2100
s = input()
k = int(input())
if len(s) == 1:
    print(k // 2)
    exit()

press = []
temp = s[0]
cnt = 0
for i in range(len(s)):
    if temp == s[i]:cnt += 1
    else:
        press.append((temp, cnt))
        cnt = 1
        temp = s[i]
press.append((temp, cnt))

if len(press) == 1:
    print(len(s) * k // 2)
    exit()

count = 0
for str, num in press:
    if num > 1:
        count += num // 2

count *= k
if s[0] == s[-1]:
    count -= (press[0][1] // 2 + press[-1][1] // 2 - (press[0][1] + press[-1][1]) // 2) * (k - 1)
print(count)

Measured memory_bytes: 61952
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c);
    CoutYn(!((a == b && b == c) || (a != b && b != c && c != a)));
}

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

const int maxn = 100005;

struct creature {
	int color, size;
};

int n;
creature a[maxn];
int ok[maxn];
LL sum[maxn];

int cmp(creature x, creature y) {
	return x.size < y.size;
}

void work() {
	memset(ok, 0, sizeof ok);
	memset(sum, 0, sizeof sum);
	sort(a+1, a+n+1, cmp);
	for(int i=1; i<=n; i++) sum[i] = sum[i-1] + a[i].size;
	ok[a[n].color] = 1;
	for(int i=n-1; i>=1; i--) {
		if(ok[a[i+1].color] && sum[i]*2 >= a[i+1].size) ok[a[i].color] = 1;
		else return;
	}
}

int main() {
	
	cin >> n;
	for(int i=1; i<=n; i++) {
		cin >> a[i].size;
		a[i].color = i;
	}
	work();
	int cnt = 0;
	for(int i=1; i<=n; i++)
		if(ok[i]) cnt++;
		
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,K; cin >> N >> K;
    int kk=1;
    for(int i=0;i<N-1;i++){
        kk *= (K-1);
    }
    cout << K*kk << endl;
    return 0;
}


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
template <typename T>
void dump_stack(std::stack<T>& stack) {
  std::stack<T> temp;
  while (!stack.empty()) {
    T top = stack.top(); stack.pop();
    std::cout << top << " ";
    temp.push(top);
  }
  std::cout << endl;
  while (!temp.empty()) {
    T top = temp.top(); temp.pop();
    stack.push(top);
  }
}
template <typename T>
void dump_queue(std::queue<T>& queue) {
  std::queue<T> temp;
  while (!queue.empty()) {
    T top = queue.front(); queue.pop();
    std::cout << top << " ";
    temp.push(top);
  }
  std::cout << endl;
  while (!temp.empty()) {
    T top = temp.front(); temp.pop();
    queue.push(top);
  }
}

typedef long long ll;



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

  ll ans=0;
  int num;
  for(ll i = 0; i < (ll)N.size(); ++i){
    char ch = N[i];
    if(ch=='0') num=0;
    if(ch=='1') num=1;
    if(ch=='2') num=2;
    if(ch=='3') num=3;
    if(ch=='4') num=4;
    if(ch=='5') num=5;
    if(ch=='6') num=6;
    if(ch=='7') num=7;
    if(ch=='8') num=8;
    if(ch=='9') num=9;
    ans += num;
  }
//  for (char c : N) {
//    int num = atoi(c);
//    ans += num;
//  }
//  while(N) {
//    ans += N%10;
//    N /= 10;
//  }
  if(ans%9==0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  for(int i=0; i<M; i++) cin >> L[i] >> R[i];
  sort(L.begin(), L.end());
  sort(R.begin(), R.end());
  cout << max(0, R[0]-L[M-1]+1) <<endl;
}

Measured memory_bytes: 1024