akhauriyash/Code-Regression huggingface dataset:
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 3e5 + 100, OO = 724249387, T = 4500 + 100, M = 1e9 + 7, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
int a[N], b[N], cnt, t[N], ans[N];

int32_t main() {
	int n, q;
	vector <int> v;
	cin >> n >> q;
	b[0] = n;
	for(int i = 0; i < q; i++) {
		cin >> a[i];
		while(~cnt && b[cnt] >= a[i])
			cnt--;
		b[++cnt] = a[i];
	}
	t[cnt] = 1;
	for(int i = cnt; i; i--) {
		int k = b[i];
		while(true) {
			int j = upper_bound(b, b + i, k) - b - 1;
			if(j < 0)
				break;
			t[j] += t[i] * (k / b[j]);
			k %= b[j];
		}
		ans[k] += t[i];
	}
	ans[b[0]] = t[0];
	for(int i = b[0] - 1; i; i--)
		ans[i] += ans[i + 1];
	for(int i = 1; i <= n; i++)
		cout << ans[i] << endl;
    return 0 ;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/



Measured memory_bytes: 6776
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

    int x, a, b;
    cin >> x >> a >> b;
    if( abs( x - a ) < abs( x - b ) ) cout << "A";
    else cout << "B";
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
n, m = gets.split.map &:to_i
a = n.times.map {gets.chomp}
b = m.times.map {gets.chomp}

(n-m+1).times do |y|
  (n-m+1).times do |x|
    if m.times.all? { |i| a[i+y][x, m] === b[i] }
      puts :Yes
      exit
    end
  end
end
puts :No

Measured memory_bytes: 14304
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int a =0;
		for(int i=0;i<S.length();i++) {
			if(S.charAt(i)=='A') {
				a++;
			}
		}
		if(a==0||a==3) {
			System.out.print("No");
		}else {
			System.out.print("Yes");
		}
	}
}


Measured memory_bytes: 24020
def main(X, N, p):
    for d in range(X + 2):
        if not((X - d) in p):
            print(X - d)
            return
        elif not((X + d) in p):
            print(X + d)
            return


if __name__ == "__main__":
    X, N = [int(s) for s in input().split(' ')]
    input_s = input()
    p = []
    if input_s != "":
        p = [int(s) for s in input_s.split(' ')]
    main(X, N, p)


Measured memory_bytes: 9048
package main

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

var white = "."
var isNotPath = -1

func main() {
	rdr := NewReader(10)
	height, width := ReadInt(), ReadInt()

	whiteCount := 0
	lines := make([]string, height)
	for i := range lines {
		lines[i] = ReadLine(rdr)
	}

	s := make([][]int, height)
	for i, line := range lines {
		l := make([]int, width)
		for j := 0; j < len(line); j++ {
			if line[j:j+1] == white {
				l[j] = whiteCount
				whiteCount++
			} else {
				l[j] = isNotPath
			}
		}
		s[i] = l
	}

	inRange := func(i, j int) bool {
		return 0 <= i && i < height && 0 <= j && j < width
	}

	var edges []EdgeB
	for i, line := range s {
		for j, cell := range line {
			if cell == isNotPath {
				continue
			}
			if inRange(i+1, j) && s[i+1][j] != isNotPath {
				edges = append(edges, EdgeB{From: cell, To: s[i+1][j], Distance: 1})
			}
			if inRange(i-1, j) && s[i-1][j] != isNotPath {
				edges = append(edges, EdgeB{From: cell, To: s[i-1][j], Distance: 1})
			}
			if inRange(i, j+1) && s[i][j+1] != isNotPath {
				edges = append(edges, EdgeB{From: cell, To: s[i][j+1], Distance: 1})
			}
			if inRange(i, j-1) && s[i][j-1] != isNotPath {
				edges = append(edges, EdgeB{From: cell, To: s[i][j-1], Distance: 1})
			}
		}
	}

	goal := s[height-1][width-1]
	connected, distance := BellmanFord(edges, 0, goal)

	if !connected {
		fmt.Println(isNotPath)
		return
	}
	fmt.Println(goal - distance)
	return
}

type Reader struct {
	rdr  *bufio.Reader
	size int
}

func NewReader(size int) *Reader {
	return &Reader{
		bufio.NewReaderSize(os.Stdin, size),
		size,
	}
}

func ReadInt() (i int) {
	fmt.Scan(&i)
	return
}

func ReadLine(r *Reader) string {
	buf := make([]byte, 0, r.size)
	for {
		line, isPrefix, err := r.rdr.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

type EdgeB struct {
	From     int
	To       int
	Distance int
}

func BellmanFord(edges []EdgeB, start, goal int) (connected bool, cost int) {
	if len(edges) == 0 {
		return
	}

	// initialize
	max := math.MaxInt32
	distances := make(map[int]int)
	for _, e := range edges {
		distances[e.From] = max
		distances[e.To] = max
	}

	// solve
	distances[start] = 0
	updated := true

	for updated {
		updated = false
		for _, e := range edges {
			c := distances[e.From] + e.Distance
			if distances[e.From] != max && distances[e.To] > c {
				distances[e.To] = c
				updated = true
			}
		}
	}

	if distances[goal] != max {
		connected = true
	}
	cost = distances[goal]

	return
}


Measured memory_bytes: 2048
#include<stdio.h>

int main(){
	int a, b, c, dis;
	scanf("%d %d %d", &a, &b, &c);
	if(a > b){
		dis = a;
		a = b;
		b = dis;
	}
	if(b > c){
		dis = b;
		b = c;
		c = dis;
	}
	if(a > b){
		dis = a;
		a = b;
		b = dis;
	}
	printf("%d %d %d\n", a, b, c);
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

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

	int64 n;
	cin >> n;
	vector<int64> A(n);
	REP(i, n) cin >> A[i];
	int64 sum = 0;
	REP(i, n)  sum += A[i];
  int64 res = INF_LL;
  int64 now = 0;
  REP(i, n-1) {
    now += A[i];
    chmin(res, abs((sum-now)-now));
  }
  cout << res << endl;
}


Measured memory_bytes: 1792
#include <iostream>

int main()
{
    int n, limit;
    int ans = 10000;
    std::cin >> n >> limit;

    for (int i = 0; i < n; i++) {
        int c, t;
        std::cin >> c >> t;
        if (t <= limit && c < ans) ans = c;
    }

    if (ans < 10000) {
        std::cout << ans << std::endl;
    } else {
        std::cout << "TLE" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b; cin >> a >> b;
    out(max(a-b,0LL));

    return 0;
}

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

using namespace std;

map <int,int> m;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;

    m[a]++;
    m[b]++;
    m[c]++;

    if(m[5] == 2 && m[7] == 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	map<int, int> m;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		m[a]++;
	}
	vector<int> v;
	for (auto e : m) {
		v.push_back(e.second);
	}
	sort(begin(v), end(v));
	int t = 0;
	for (int i = 0; i < (int)v.size() - k; i++) {
		t += v[i];
	}
	cout << t << endl;
	return 0;
}


Measured memory_bytes: 10748
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

  int n, d, x; cin >> n >> d >> x;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int ans = x;
  rep(i, n) {
    int now = 1;
    int cnt = 1;
    while(now <= d) {
      now += a[i];
      ++cnt;
    }
    ans += --cnt;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

bool p[1000000];

void prime() {
  fill(p, p+1000000, true);
  p[0] = p[1] = false;
  
  FOR(i, 2, 1000000) {
    if(!p[i])continue;
    for(int j = 2; i*j < 1000000; j++) {
      p[i*j] = false;
    }
  }
}    


int main() {
  int n, count;

  prime();
  while(cin >> n) {
    count = 0;
    for(int i = 2; i <= n; i++) {
      if(p[i] == true)count++;
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 2136
import qualified Data.ByteString.Char8 as BS
import qualified Data.Maybe as MA

main = do
    [n, a, b] <- fmap (fst . MA.fromJust . BS.readInt) . BS.words <$> BS.getLine
    let m = n `div` (a + b) * a
    let m' = min (n `mod` (a + b)) a 
    putStrLn $ show (m + m')


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

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

    int a[M], b[M];
    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
    }
    
    int ans[N];
    for(int i = 0; i < N; i++){
        ans[i] = 0;
    }      

    for(int i = 0; i < M; i++){
        ++ans[a[i] - 1]; ++ans[b[i] - 1];
    }

    for(int i = 0; i < N; i++){
        cout << ans[i] << endl;
    }

}

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

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

    long long min = N-1;
  	int max=sqrt(N)+1;

    for(int i=max; i>0; i--){
        if(N%i==0){
            min = i + N/i -2;
            cout << min << endl;
            return 0;
        }
    }

    cout << min << endl;
  
    return 0;
}

Measured memory_bytes: 256
//%std
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int MAXN=1e5+10;
int n,m;
ll a[MAXN];
ll LCM(ll x,ll y)
{
	return x*y/__gcd(x,y);
}
int solve()
{
	ll lcm=a[1];
	for(int i=2;i<=n;++i)
	{
		lcm=LCM(lcm,a[i]);
		if(lcm>m)
			return 0;
	}
	for(int i=1;i<=n;++i)
		if((lcm/a[i])%2==0)
			return 0;
	return (m/lcm+1)/2;	
}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;++i)
		a[i]=read()>>1;
	cout<<solve()<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
 using namespace std;
 #define ll long long
 
int bfs(int n)
{
	
	queue<int> q;
	q.push(n);
	int dis[100006];
	for(int i=0;i<100005;i++)
	dis[i]=1000009;
	dis[n]=0;
	int final=0;
	while(!q.empty())
	{
		int tp=q.front();
		q.pop();
		int mx=0;
		for(int i=0;i<8;i++)
		{
			int po=pow(6,i);
			if(po<=tp)
			mx=po;
			else break;
		}
		
		if(tp-mx==0)
		{
			if(dis[tp-mx]>dis[tp]+1)
			dis[tp-mx]=dis[tp]+1;
			
			final=dis[tp-mx];
			break;
			
		}
		if(tp-mx>0)
		{
			if(dis[tp-mx]>dis[tp]+1){
			dis[tp-mx]=dis[tp]+1;
			}
						q.push(tp-mx);

			
		}

		mx=0;

		for(int i=0;i<8;i++)
		{
			int po=pow(9,i);
			if(po<=tp)
			mx=po;else break;
		}
		
		if(tp-mx==0)
		{
			if(dis[tp-mx]>dis[tp]+1)
			dis[tp-mx]=dis[tp]+1;
			
			final=dis[tp-mx];
			break;
		}

		if(tp-mx>0)
		{
			if(dis[tp-mx]>dis[tp]+1){
			dis[tp-mx]=dis[tp]+1;
			}
		q.push(tp-mx);

			
		}
		
		
		
	}
	return final;

}


int main()
{
int n;cin>>n;
int cc=bfs(n);
cout<<cc<<endl;
}

Measured memory_bytes: 768
package main

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

func main() {
	resolve(parseProblem(os.Stdin))
}

func parseProblem(r io.Reader) (string, chan query) {
	sc := bufio.NewScanner(r)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	const (
		initialBufSize = 100000
		maxBufSize     = 100000
	)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)

	sc.Scan()
	s := sc.Text()
	n := scanint(sc)

	ch := make(chan query)
	go func() {
		for i := 0; i < n; i++ {
			ch <- parseQuery(sc)
		}
		close(ch)
	}()
	return s, ch
}

const (
	Switch = 1 + iota
	Append
)

type query struct {
	cmd int
	sub int
	c   string
}

func parseQuery(sc *bufio.Scanner) query {
	cmd := scanint(sc)
	if cmd == Switch {
		return query{cmd, 0, ""}
	}
	sub := scanint(sc)
	sc.Scan()
	t := sc.Text()
	return query{Append, sub, t}
}

func scanint(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}

func resolve(base string, queries chan query) {
	state := 0
	fixies := [2][]string{}
	for q := range queries {
		if q.cmd == Switch {
			state += 1
		} else {
			// state 0; 1 -> 1(prefix), 2 -> 0 (suffix)
			fixies[(state+q.sub)%2] = append(fixies[(state+q.sub)%2], q.c)
		}
	}

	normal := state%2 == 0
	prefix := fixies[(state+1)%2]
	suffix := fixies[(state+2)%2]

	for i := len(prefix); i > 0; i-- {
		fmt.Printf("%s", prefix[i-1])
	}
	if normal {
		fmt.Printf("%s", base)
	} else {
		runes := []rune(base)
		for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
			runes[i], runes[j] = runes[j], runes[i]
		}
		fmt.Printf("%s", string(runes))
	}

	for i := 0; i < len(suffix); i++ {
		fmt.Printf("%s", suffix[i])
	}
}


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

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

  vector<int> A(N), B(N), C(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  rep(i, N) cin >> C[i];

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  ll ans = 0;

  rep(i, N) {
    ll n = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
    ll m = upper_bound(C.begin(), C.end(), B[i]) - C.begin();
    ans += n * (N - m);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1408
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define do(x) for(int i = 1; i <= x; i++){ solve(); }

using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e5+2;
const ll mod = 1e9+7;
vector<bool> used(SIZE,false);


void solve(){
	int r,d,x;
	cin >> r >> d >> x;
	for(int i = 1; i <= 10; i++){
		cout << x*r-d << endl;
		x = x*r-d;
	}
}

int main(){ 
	speedhack()
	// int it; cin >> it;
	int it = 1;
	do(it);
	return 0;
}


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

int order(int P[8], int index, int N)
{
  	int	i;
  	int	count;	
  
  	count = 1;
  	for (i=index+1; i<N; i++)
    {
      	if (P[index] > P[i])
          	count++;
    }
  	return (count);
}

int	main(void)
{
  	int	N;
  	int P[8];
  	int Q[8];
  	int R[] = {5040,720,120,24,6,2,1,0};
 	int num;
  	int i;
  	int PP;
  	int QQ;
  
  	num = scanf("%d", &N);
    if (num != 1)
    {
      	return (0);
    }
  
  	for (i=0; i<N; i++)
    {
      	num = scanf("%d", &P[i]);
     	if (num != 1)
          	return (0);
    }
  	for (i=0; i<N; i++)
    {
      	num = scanf("%d", &Q[i]);
      	if (num != 1)
          	return (0);
    }
  	for (i=N; i<8; i++)
    {
      	P[i] = 0;
      	Q[i] = 0;
    }
  	
  	PP = 0;
  	for (i=0; i<N; i++)
    {
      	PP += order(P, i, N) * R[i + 8 - N];
    }
  	QQ = 0;
  	for (i=0; i<N; i++)
    {
      	QQ += order(Q, i, N) * R[i + 8 - N];
    }
  	printf("%d", abs(QQ - PP));
  	return (0);
}

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

vector <int> v;

bool ok(int x)
{
    int flag[10] = {false};
    while (x)
    {
        flag[x % 10] = 1;
        x /= 10;
    }
    if (flag[3] == 0 || flag[5] == 0 || flag[7] == 0)
        return false;
    return true;
}
void DFS(int cur, int num)
{
    if (cur == 10)
    {
        if (ok(num))
            v.push_back(num);
        return;
    }
    DFS(cur + 1, num);
    DFS(cur + 1, num * 10 + 3);
    DFS(cur + 1, num * 10 + 5);
    DFS(cur + 1, num * 10 + 7);
}

int main()
{
    DFS(0, 0);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    int n;
    while (scanf("%d", &n) != EOF)
        printf("%d\n", (int)(upper_bound(v.begin(), v.end(), n) - v.begin()));
    return 0;
}

Measured memory_bytes: 6384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long start = 100;
        int answer = 0;
        while (x > start) {
            start += start / 100;
            answer++;
        }
        System.out.println(answer);
        sc.close();
    }

}


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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define loop(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
#define rfor(v,x) for(const auto& x : v) //xはn番目ではなく各値を指す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

#define downsort(v) vfsort(v,[](ll x,ll y) -> int{ return x>y; })

int x,y,z,k;
vector<ll> a,b,c,d,e;

int main(){
  cin >> x >> y >> z >> k; a.resize(x);b.resize(y);c.resize(z);
  vin(a);vin(b);vin(c);
  
  rfor(a,i)
    rfor(b,j) d.push_back(i+j);
  downsort(d);
  downsort(c);
  d.resize(k);
  rfor(c,i)
    rfor(d,j) e.push_back(i+j);
  downsort(e);

  rep(i,k) cout << e[i] << endl; 
  return 0;
}


Measured memory_bytes: 42984
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll r,g;
  cin >> r >> g;
  cout << g*2-r<<endl;
}


Measured memory_bytes: 256
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

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

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

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

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

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

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	a := make([]int, n+1)
	for i, _ := range a {
		a[i] = readInt()
	}
	b := make([]int, n)
	for i, _ := range b {
		b[i] = readInt()
	}

	count := 0
	prevb := 0
	for i, _ := range a {
		if a[i]-prevb >= 0 {
			a[i] -= prevb
			count += prevb

			if i == n {
				break
			}

			if a[i]-b[i] > 0 {
				count += b[i]
				prevb = 0
			} else {
				count += a[i]
				prevb = abs(a[i] - b[i])
			}
		} else {
			count += a[i]
			if i == n {
				break
			}
			prevb = b[i]
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define print(n) std::cout << n << std::endl
#define FOR(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
   char c;
   cin >> c;
   string str = "abcdefghijklmnopqrstuvwxyz";
    for (int i = 0; i < str.size(); ++i) {
        if(c == str[i])print(str[i+1]);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const int N=22;
const int mod=1000000007;


int dp[N][1<<N],n,a;
vector<int>v[N];

int dpf(int i,int mask){
	if(dp[i][mask]!=-1)return dp[i][mask];
	if(i==n)return 1;

	bool flag=1;
	dp[i][mask]=0;
	for(auto j:v[i]){
		if((mask&(1<<j))==0){
			flag=0;
			dp[i][mask]+=dpf(i+1,mask^(1<<j));
			dp[i][mask]%=mod;
		}
	}
	return dp[i][mask];


}

int main(){
	//fri("in.txt");
	//fro("out.txt");
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a;
			if(a)v[i].pb(j);
		}
	}
	memset(dp,-1,sizeof(dp));
	cout<<dpf(0,0);
return 0;
}

Measured memory_bytes: 360704
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
#define INF 100000000
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


    
void go();

main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);cout<<fixed<<setprecision(15);
    int tc=1;
    // tc=in();
    while(tc--){
        go();
    }
    return 0;
}


void go(){
    int k=in(),q=in();
    vecll d;
    rep(i,k)d.pb(in());
    while(q--){
        ll n=in()-1,x=in(),m=in();
        ll mov = 0;
        rep(i,k) mov+=(d[i]%m ? d[i]%m :m);
        mov *= n/k;
        mov += x%m;
        rep(i,n%k) mov+=(d[i]%m ? d[i]%m :m);
        cout << n-mov/m<<endl;
    }
}


Measured memory_bytes: 384
import sys
N, M = map(int, input().split())
A = []
B = []
for _ in range(N):
    A.append(input())
for _ in range(M):
    B.append(input())

for i in range(N-M+1):
    for j in range(N-M+1):
        for k in range(M):
            #print(A[i+k][j:j+M])
            #print(B[k])
            if A[i+k][j:j+M] != B[k]:
                break
        else:
            print("Yes")
            sys.exit()
print("No")



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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define tc ll t; cin >> t; while (t--)
#define yes cout << "APPROVED" << endl
#define no cout << "DENIED" << endl
#define sz(c) (ll) c.size()
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define trav(x,c) for(auto &x : c)
#define _for(i,a,n) for(ll i = a ; i < n ; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);

int main() {
    godspeed;
    ll n; cin >> n;
    vl v(n);
    bool f = 0;
    _for(i,0,n) {
        cin >> v[i];
        if(v[i]%2 == 0)
            if(v[i]%3 && v[i]%5)
                f = 1;
    }

    (f) ? no : yes;
}

Measured memory_bytes: 3620
import math
def func():
    a=int(input())
    b = list(map(int,input().split()))
    f = [[[0 for i3 in range(100)] for i2 in range(100)] for i1 in range(100)]
    #print(a)
    #for i in range(a):
    #    print(b[i])
    z=0
    for i in range(a-2):
        ii=i
        p=b[ii]
        for j in range(a-1-ii):
            jj=ii+j+1
            q=b[jj]
            for k in range(a-1-jj):
                kk=jj+k+1
                r=b[kk]
                if p+q>r and q+r>p and r+p>q:
                    if p!=q and q!=r and r!=p:
                        z=z+1
    print(z)

func()

Measured memory_bytes: 83016
N = int(input())
C=list(input())
type=set(C)
L=0
R=0
RR=0
X=0
if 'R' in type and 'W' in type:
    for i in range(N):
      L=i
      R=RR
      if L>=N-1-R:
        break
      if C[i]=='W':
          for ii in range(N-L-R):
            if C[N-1-R-ii]=='R':
              C[L]='R'
              C[N-1-R-ii]='W'
              X+=1
              break
            RR+=1
            if L>=N-1-R:
              break
print(X)

Measured memory_bytes: 10752
#include <stdio.h>
int main() {char T[9999];int i=0;while (1) {T[i]=getchar();if (T[i]=='\n') {
	if (T[0]=='E' && T[1]=='N' && T[2]=='D' && T[3]==' ' && T[4]=='O' && T[5]=='F' && T[6]==' ' && T[7]=='I' && T[8]=='N' && T[9]=='P' && T[10]=='U' && T[11]=='T') return 0;
	T[i]=' ';for (int j=0,cnt=0;j<=i;j++) if (T[j]!=' ') cnt++;else printf("%d",cnt),cnt=0;puts("");i=0;} else i++;}}

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

int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int N = 5;
	//注文してから届くまでの時間
	vector<int> Time{ a, b, c, d, e };
	//次に注文する時間
	vector<int> NextTime(N);

	//NextTimeを生成
	for (int i = 0; i < N; i++)
	{
		if (Time[i] % 10 == 0) {
			NextTime[i] = Time[i];
		}
		else {
			NextTime[i] = (Time[i] - (Time[i] % 10)) + 10;
		}
	}
	//10の9乗　doubleだからintに変換
	int BestTime = (int)1e9;

	for (int i = 0; i < N; i++)
	{
		//SumTimeを0で初期化　→　1パターン目のSumTime　→　BestTimeに代入　→　SumTimeを0で初期化
		int SumTime = 0;
		for (int j = 0; j < N; j++)
		{
			//最後の処理
			if (i == j)
			{
				SumTime += Time[j];
			}
			//最後以外の処理
			else {
				SumTime += NextTime[j];
			}
		}
		BestTime = min(BestTime, SumTime);
	}
	cout << BestTime << endl;
 }

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

int main()
{
string num;
cin >> num;
while(num!="0")
{
int ans=0;
for (int i=0;i<num.size();i++)
{
ans+=num.at(i)-'0';
}
cout << ans << endl;
cin >> num;
}
}





Measured memory_bytes: 3152
import java.util.*;

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

        int N = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();

        for (int i=0; i<N; i++) {
            String s = sc.next();
            map.put(s, map.getOrDefault(s, 0) + 1);
        }

        int M = sc.nextInt();
        for (int i=0; i<M; i++) {
            String s = sc.next();
            map.put(s, map.getOrDefault(s, 0) - 1);
        }

        int max = 0;
        for (String s : map.keySet()) {
            max = max > map.get(s) ? max : map.get(s);
        }
        System.out.println(max);
    }
}



Measured memory_bytes: 23892
n = int(input())
a = list(map(int, input().split()))

for i in range(n-1):
    a[i+1] += a[i]

ans = float('inf')

for i in range(n-1):
    x = a[i]
    y = a[n-1] - a[i]
    ans = min(ans, abs(x - y))

print(ans)

Measured memory_bytes: 23800
#include<iostream>
#include<algorithm>
using namespace std;
int dp[1111][1111];
string s[1111];
main()
{
    int n;
    while(cin>>n,n)
    {
        for(int i=0;i<n;i++)cin>>s[i];
        for(int i=0;i<n;i++)
        {
            dp[i][0]=s[i][0]=='.';
            dp[0][i]=s[0][i]=='.';
        }
        for(int i=1;i<n;i++)for(int j=1;j<n;j++)
        {
            if(s[i][j]=='.')dp[i][j]=min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+1;
            else dp[i][j]=0;
        }
        int ans=0;
        for(int i=0;i<n;i++)for(int j=0;j<n;j++)ans=max(ans,dp[i][j]);
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 8408
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	
	static ArrayList<Integer> list=new ArrayList<>();
	static boolean[] prime=new boolean[104730];
	
	static void eratos() {
		for(int i=2; i<104730; i++) {
			prime[i]=true;
		}
		for(int i=2; i<104730; i++) {
			if(prime[i]) {
				list.add(i);
				for(int j=2; i*j<104730; j++) {
					prime[i*j]=false;
				}
			}
		}
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			eratos();
			while(sc.hasNext()) {
				int n=sc.nextInt();
				if(n==0) break;
				int sum=0;
				for(int i=0; i<n; i++) {
					sum+=list.get(i);
				}
				System.out.println(sum);
			}
			
			
		}
	}
}


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

bool L[600][600][300];
int main()
{
	ll n;
	cin >> n;
	vector<string> s(n);
	for (ll i = 0; i < n; i++)
		cin >> s[i];

	for (ll i = 0; i < n*2; i++)
	{
		for (ll j = 0; j < n*2; j++)
		{
			for (ll k = 1; k < n; k++)
			{
				L[i][j][k] = L[i][j][k - 1] | (s[(i + k) % n][j%n] != s[i%n][(j + k) % n]);
			}
		}
	}

	ll ans = 0;
	for (ll i = 0; i < n; i++)
	{
		for (ll j = 0; j < n; j++)
		{
			ll sum = 0;

			for (ll k = n - 1; k >= 0; k--)
			{
				sum += L[i+n-k-1][j+n-k-1][k];
				// cout <<L[i][j][k]<<endl;
			}
			// cout << endl;
			if (sum == 0) ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 109260
#include<cstdio>
#include<vector>
#include<cmath>

using namespace std;

int main()
{
	int n, i;
	int sum = 0;
	vector<int> arr;
	int input;
	int min, idx = 0;

	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		scanf("%d", &input);

		arr.push_back(input);

		sum += input;
	}

	min = abs(sum - arr[0]*n);

	for (i = 1; i < n; i++)
	{
		if (abs(sum - arr[i] * n) < min)
		{
			min = abs(sum - arr[i] * n);

			idx = i;
		}
	}

	printf("%d\n", idx);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
long n,k,a,i,j,m=1e9+7,v[2<<20];main(){for(std::cin>>n>>k;i++<n;)for(j=0;j++<n;v[i]>v[j]?(a+=k*(k-1)/2+(i<j)*k)%=m:0)i-1||std::cin>>v[j];std::cout<<a;}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import collections

def solve(N: int):
    c = collections.defaultdict(int)
    if N == 1:
        print(1)
        return
    for i in range(1, N+1):
        target = str(i)
        c[target[0], target[-1]] += 1
    result = 0
    for i in range(0, 10):
        for j in range(0, 10):
            i = str(i)
            j = str(j)
            result += c[i, j] * c[j, i]
    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.util.*;
 
class Main{
    public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		int[] a = new int[6];
		int[] b = new int[6];
		for(int i=0; i<6; i++){
			a[i] = scan.nextInt();
		}
		for(int i=0; i<6; i++){
			b[i] = scan.nextInt();
		}
		Dice xai1 = new Dice(a);
		Dice xai2 = new Dice(b);
		System.out.println(xai2.cheakSameDice(xai1, xai2));
    }
}

class Dice{
	int[] dice;
	public Dice(int[] a){
		dice = new int[6];
		for(int i=0; i<6; i++){
			dice[i] = a[i];
		}
	}
	public void roll(char c){
		int tmp = 0;
		switch(c){
			case 'N':
				tmp = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = tmp;
				break;
			case 'W':
				tmp = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[3];
				dice[3] = tmp;
				break;
			case 'S':
				tmp = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[1];
				dice[1] = tmp;
				break;
			case 'E':
				tmp = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[2];
				dice[2] = tmp;
				break;
		}
	}
	public void rotation(){ //???????????????????¨???????????????????
		int tmp = dice[1];
		dice[1] = dice[2];
		dice[2] = dice[4];
		dice[4] = dice[3];
		dice[3] = tmp;
	}

	public String cheakSameDice(Dice xai1, Dice xai2){
		if(compareDices(xai1, xai2, 'N', 'W'))return "Yes";
		if(compareDices(xai1, xai2, 'N', 'E'))return "Yes";
		if(compareDices(xai1, xai2, 'S', 'W'))return "Yes";
		if(compareDices(xai1, xai2, 'S', 'E'))return "Yes";
		return "No";
	}

	public boolean checkSurface(Dice xai1, Dice xai2){
		if(xai1.dice[0]==xai2.dice[0] && xai1.dice[1]==xai2.dice[1] && xai1.dice[2]==xai2.dice[2] && xai1.dice[3]==xai2.dice[3] && xai1.dice[4]==xai2.dice[4] && xai1.dice[5]==xai2.dice[5]){
			return true;
		}
		return false;
	}

	public boolean compareDices(Dice xai1, Dice xai2, char c1, char c2){
		for(int i=0; i<6; i++){
			for(int j=0; j<6; j++){
				xai2.roll(c1);
				if(checkSurface(xai1, xai2))return true;
				xai2.roll(c2);
				if(checkSurface(xai1, xai2))return true;;
			}
			xai2.rotation();
			if(checkSurface(xai1, xai2))return true;
		}
		return false;
	}

	public int showTop(){
		return dice[0];
	}
}

Measured memory_bytes: 26300
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;


int main() {
	int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
	int ans = min(a + b, 2*c)*min(x, y);
	ans += (max(x, y) - min(x, y))*min(x > y ? a : b, 2*c);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
$N, $A, $B, $C = gets.chomp.split.map(&:to_i)
$l = []
$N.times { $l << gets.chomp.to_i }

# 三本の長さがa,b,cになったとき
# 合体後にabs(a - A) + abs(b - B) + abc(c - C) をたしたものコストになる

# a, b, cはそれぞれの長さ
def dfs (i, a, b, c)
  if i == $N
    # 1つでも0ならベースの木がないので大きな数字を返す
    return 10**10 if a * b * c == 0
    return ($A-a).abs + ($B-b).abs + ($C-c).abs
  end
  
  y_tmp = a == 0 ? 0 : 1
  z_tmp = b == 0 ? 0 : 1
  w_tmp = c == 0 ? 0 : 1

  x = dfs(i+1, a,b,c)
  y = dfs(i+1, a + $l[i], b, c) + 10*y_tmp
  z = dfs(i+1, a , b + $l[i], c) + 10*z_tmp
  w = dfs(i+1, a , b , c + $l[i]) + 10*w_tmp

  return [x, y, z, w].min
end

p dfs(0, 0, 0, 0)


Measured memory_bytes: 1788
#include<iomanip>
#include<iostream>
#include<cstring>
#include<cmath>
#include<time.h>
#include<stdlib.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a<=b)puts("unsafe");
	else puts("safe");
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
h_list = list(map(int, input().split()))

count_list = []
if len(h_list) == 1:
    count_list.append(0)
else:
    count = 0
    for i in range(N-1):
        if h_list[i] >= h_list[i+1]:
            count += 1
            count_list.append(count)
        else:
            count = 0
            count_list.append(0)
    
print(max(count_list))


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

int main()
{
    int a, b, c, d;
    pair<int, int> saki;
    pair<int, int>  ato;

    cin >> a >> b >> c >> d;

    if (a < c) {
        saki.first = a;
        saki.second = b;
        ato.first = c;
        ato.second = d;
    } else {
        saki.first = c;
        saki.second = d;
        ato.first = a;
        ato.second = b;
    }

    if (saki.second <= ato.first) {
        cout << 0 << endl;
    } else if (saki.second < ato.second) {
        cout << saki.second - ato.first << endl;
    } else {
        cout << ato.second - ato.first << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int h, w;
struct lamp{
    char c;
    short int up, down, left, right;
    int s(){return up + down + left + right - 3;}
};
lamp s[2000][2000] = {0};

int main()
{
    int ans = 0;
    char t[2000];
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        scanf("%s", t);
        for(int j = 0; j < w; j++){
            s[i][j].c = t[j];
        }
    }

    /* --- 左右を照らす数 --- */
    for(int i = 0; i < h; i++){
        short int kl = 0, kr = 0;
        for(int j = 0; j < w; j++){
            if(s[i][j].c == '#') kr  = 0;
            else                 kr += 1;
            if(s[i][w-1-j].c == '#') kl  = 0;
            else                     kl += 1;
            s[i][j].right = kr;
            s[i][w-1-j].left  = kl;
        }
    }
    /* --- 上下を照らす数 --- */
    for(int j = 0; j < w; j++){
        short int ku = 0, kd = 0;
        for(int i = 0; i < h; i++){
            if(s[i][j].c == '#') kd = 0;
            else                 kd += 1;
            if(s[h-1-i][j].c == '#') ku  = 0;
            else                     ku += 1;
            s[i][j].down = kd;
            s[h-1-i][j].up  = ku;
        }
    }

    /* --- スキャン --- */
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            ans = (ans < s[i][j].s() ? s[i][j].s() : ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 39296
#include <stdio.h>
#define N 45

int fibonacci(int);

int n;
int F[N];

int main()
{
  int i,fib;

  scanf("%d",&n);
  fib = fibonacci(n);
  printf("%d\n",fib);

  return 0;
}

int fibonacci(int n)
{
  if(n==0 || n==1){
    return F[n]=1; //F[n]にをメモしてそれを返す
  }
  if(F[n]!=NULL){
    return F[n];
  }
  return F[n] = fibonacci(n - 2) + fibonacci(n - 1);

}

Measured memory_bytes: 596
// B : Single Source Shortest Path
#include <stdio.h>
#include <stdlib.h>
#define N 100
#define INF 10000000
#define WHITE 0
#define BLACK 1

int main() {
  int i, j;
  int n;
  int u, k, l;
  int m[N][N];
  int d[N];
  int color[N];
  int mincost;

  // input
  scanf("%d", &n);  // the number of vertices in G
  
    // initialization
  for(i = 0; i < n; i++) {
    for(j = 0; j < n; j++) {
      m[i][j] = -1;
    }
  }
  
  for(i = 0; i < n; i++) {
    scanf("%d", &u);  // id
    // adjacency matrix with weight
    scanf("%d", &k);  // degree
    for(j = 0; j < k; j++) {
      scanf("%d", &l);  // vertice
      scanf("%d", &m[u][l]);  // the weight of l
    }
  }

  // SSSP
  // initialization
  for(i = 0; i < n; i++) {
    d[i] = INF;
    color[i] = WHITE;
  }
  // Dijkstra's Algorithm
  d[0] = 0;
  while(1) {
    mincost = INF;
    for(i = 0; i < n; i++) {
      if((color[i] != BLACK)&&(d[i] < mincost)) {
	mincost = d[i];
	u = i;
      }
    }
    if(mincost == INF) break;
    color[u] = BLACK;
    for(j = 0; j < n; j++) {
      if((color[j] != BLACK)&&(d[u] + m[u][j] < d[j]) && (m[u][j] != -1)) {
	d[j] = d[u] + m[u][j];
      }
    }
  }

  // output
  for(i = 0; i < n; i++) {
    printf("%d %d\n", i, d[i]);
  }

  return 0;
}



Measured memory_bytes: 2112
sa=str(input())
sb=str(input())
sc=str(input())
turn=len(sa)+len(sb)+len(sc)
st=sa[0]
sa=sa[1:]

for i in range(1,turn+1):
    if st=='a':
        if sa=='':
            print('A')
            exit()
        else:
            st=sa[0]
            sa=sa[1:]
        
    if st=='b':
        if sb=='':
            print('B')
            exit()
        else:
            st=sb[0]
            sb=sb[1:]

    if st=='c':
        if sc=='':
            print('C')
            exit()
        else:
            st=sc[0]
            sc=sc[1:]

Measured memory_bytes: 3064
using System;
using System.Linq;

namespace debug
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            var N = input[0];
            var K = input[1];
            var f = N / 2.0;
            if (Math.Ceiling(f) >= K)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 13268
N, M = map(int, input().split())
q = [[] for _ in range(N)]
for i in range(M):
    p, s = input().split()
    p = int(p) - 1
    q[p].append(s)

ac = 0
wa = 0
for i in range(N):
    clear = False
    tmpwa = 0
    for s in q[i]:
        if not clear and s == 'AC':
            clear = True
            ac += 1
            break
        else:
            tmpwa += 1
    if clear:
        wa += tmpwa

print(ac, wa)



Measured memory_bytes: 20272
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

s1, s2, s3 = 0, 0, 0
for p in P:
    if p <= A:
        s1 += 1
    elif A+1 <= p <= B:
        s2 += 1
    else:
        s3 += 1
print(min(s1, s2, s3))

Measured memory_bytes: 3064
ans :: Double -> String
ans x
  | x <= 48.0 = "light fly"
  | x <= 51.0 = "fly"
  | x <= 54.0 = "bantam"
  | x <= 57.0 = "feather"
  | x <= 60.0 = "light"
  | x <= 64.0 = "light welter"
  | x <= 69.0 = "welter"
  | x <= 75.0 = "light middle"
  | x <= 81.0 = "middle"
  | x <= 91.0 = "light heavy"
  | otherwise = "heavy"

main = do
  c <- getContents
  let i = map read $ lines c :: [Double]
      o = map ans i
  mapM_ putStrLn o

Measured memory_bytes: 3844