akhauriyash/Code-Regression huggingface dataset:
//#define LOCAL

#include <cstdio>
#include <cstring>
#include <algorithm>
#define SIZE 110

using namespace std;

char map[SIZE][SIZE];
int dir[][2] = {0, 1, 0, -1, 1, 0, -1, 0};

void dfs(int x, int y, int h, int w, char chars){
	map[x][y] = '0';
	
	for(int i = 0; i < 4; i++){
		int newx = x + dir[i][0];
		int newy = y + dir[i][1];

		if(0 <= newx && newx < h && 0 <= newy && newy < w
			&& map[newx][newy] == chars){
			dfs(newx, newy, h, w, chars);
		}
	}	
}

void printmap(int h, int w){
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++)
			printf("%c", map[i][j]);

		printf("\n");
	}
	printf("\n");
}

int main(void){
#ifdef LOCAL
	freopen("data.in", "r", stdin);
#endif
	int h, w;

	while(scanf("%d%d", &h, &w), h || w){
		int result = 0;

		for(int i = 0; i < h; i++)
			scanf("%s", map[i]);

		//printmap(h, w);

		for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++){
			if(map[i][j] != '0'){
				dfs(i, j, h, w, map[i][j]);
				result++;

				//printmap(h, w);
			}
		}

		printf("%d\n", result);
	}

	return 0;
}


Measured memory_bytes: 3456
package main

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

func main() {
	sc := NewScanner()

	s := sc.ReadString()
	s = s[0:3]

	var ans int
	switch s {
	case "SSS":
		ans = 0
	case "RSS":
		ans = 1
	case "SRS":
		ans = 1
	case "SSR":
		ans = 1
	case "RSR":
		ans = 1
	case "RRS":
		ans = 2
	case "SRR":
		ans = 2
	case "RRR":
		ans = 3
	}

	fmt.Println(ans)
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

ll gcd(ll a, ll b){
    ll tmp;
    if(a < b){
        tmp = a;
        a = b;
        b = tmp;
    }

    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int main() {
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    ll gcd_ = gcd(n, m);
    int N = n / gcd_;
    int M = m / gcd_;

    REP(i, gcd_) {
        if(s[N*i] != t[M*i]) {
            cout << "-1" << endl;
            return 0;
        }
    }

    cout << n * m / gcd_ << endl;

    return 0;
}

Measured memory_bytes: 512
n = int(input())
P = list(map(int, input().split()))

cnt = 0
for i in range(1, n - 1):
    f = 0
    if P[i - 1] < P[i] and P[i] < P[i + 1]:
        f = 1
    elif P[i -1] > P[i] and P[i] > P[i + 1]:
        f = 1
    if f == 1:
        cnt += 1

print(cnt)

Measured memory_bytes: 38256
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, ret;
int main() {
    while(true) {
        scanf("%d", &n);
        if(n == 0) break;
        ret = 999999999;
        for(int a = 0; a <= 25; a++) {
            for(int b = 0; b <= 16; b++) {
                for(int c = 0; c <= 10; c++) {
                    int value = a * 200 + b * 300 + c * 500;
                    if(n == value) {
                        ret = min(ret, (a / 5) * 1520 + (a % 5) * 380 + (b / 4) * 1870 + (b % 4) * 550 + (c / 3) * 2244 + (c % 3) * 850);
                    }
                }
            }
        }
        printf("%d\n", ret);
    }
    return 0;
}

Measured memory_bytes: 2588
h,w = gets.split.map(&:to_i)
dp = Array.new(h+1).map{Array.new(w+1,0)}
dp[0][0] = 1
mod = 10**9+7
for i in 0..h-1
    a = gets.chomp
    for j in 0..w-1
        next if a[j] == "#"
        dp[i][j] %= mod
        dp[i+1][j] += dp[i][j]
        dp[i][j+1] += dp[i][j]
    end
end
puts dp[h-1][w-1]%mod

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

int main() {
  int N, K; string S; cin >> N >> K >> S;
  char firstLetter = S[0];
  int i = 1;
  for (int k = 0; k < K; k++) {
    for (; i < N && S[i] == firstLetter; i++) {}
    for (; i < N && S[i] != firstLetter; i++) S[i] = firstLetter;
  }
  char prevChar = firstLetter; int hCount = 0;
  for (i = 1; i < N; i++) {
    if (S[i] == prevChar) hCount++;
    prevChar = S[i];
  }
  cout << hCount << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int M[505][505];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, q; cin >> n >> m >> q;
    rep(i,m) {
        int l, r; cin >> l >> r;
        l--; r--;
        M[l][r]++;
    }
    rep(i,n) {
        REP(j,1,n) {
            M[i][j] = M[i][j-1]+M[i][j];
        }
    }
    rep(i,q) {
        int a, b; cin >> a >> b;
        a--; b--;
        int ans = 0;
        REP(i,a,b+1) {
            ans += M[i][b];
        }
        cout << ans << endl;
    }
    return 0;
}

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int a,b,c;cin>>a>>b>>c;
	if(c>=a and c<=b) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
typedef long long ll;
const ll INF = 1LL<<60;

typedef pair<long long,int> P;
struct edge {
    int to; long long cost;
};

struct Maze {
    int H, W;
    long long cost1=1, cost2=0, cost3=0, cost4=1;
    vector<string> maze;
    Maze(int H, int W, vector<string> maze) : H(H), W(W), maze(maze) {}
    vector<int> di={1,0,-1,0}, dj={0,1,0,-1};
    vector<vector<edge>> G;
    void Ginit() {
        G.resize(H*W);
        for(int i=0;i<H;++i) {
            for(int j=0;j<W;++j) {
                for (int k=0;k<4;k++) {
                    int ni = i + di[k];
                    int nj = j + dj[k];
                    if(0<=ni&&ni<H&&0<=nj&&nj<W) {
                        long long cost=0;
                        if(maze[i][j]=='.'&&maze[ni][nj]=='.') cost=cost1;
                        else if(maze[i][j]=='.'&&maze[ni][nj]=='#') cost=cost2;
                        else if(maze[i][j]=='#'&&maze[ni][nj]=='.') cost=cost3;
                        else if(maze[i][j]=='#'&&maze[ni][nj]=='#') cost=cost4;
                        if(cost!=INF) G[i*W+j].push_back((edge){ni*W+nj,cost});
                    }
                }
            }
        }
    }

};

struct UnionFind {
  vector<int> data;
  vector<int> white;
  UnionFind(int size) : data(size, -1), white(size, 0) {}
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
        if (data[y] < data[x]) swap(x, y);
        data[x] += data[y]; data[y] = x;
        white[x] += white[y];
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main() {
    int H, W; cin >> H >> W;
    vector<string> maze(H);
    REP(i,H) cin >> maze[i];
    Maze MZ(H,W,maze); MZ.Ginit();
    UnionFind UF(H*W);
    REP(i,H*W) if(maze[i/W][i%W]=='.') UF.white[i]++;
    for(int i=0; i<H*W; i++) for(auto e:MZ.G[i]) {
        if(e.cost==0) UF.unionSet(i,e.to);
    }
    ll ans = 0;
    REP(i,H*W) {
        if(i==UF.root(i)) ans += (ll) (UF.size(i) - UF.white[i]) * UF.white[i];
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin>>N;
  vector<int> d(N);
  for (int i = 0;i<N;i++){
    cin>>d.at(i);
  }
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  int count=1;
  for(int i =1;i<N;i++){
    if(d.at(i)<d.at(i-1)){
      count+=1;
    }
  }
  cout<<count<<endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> card_point(N);
  for(int i=0; i<N ; i++){
    cin >> card_point.at(i);
  }
  sort(card_point.begin(),card_point.end());
  reverse(card_point.begin(),card_point.end());
  int Alice_point = 0;
  int Bob_point = 0;
  for(int i=0; i<N ; i++){
    if(i%2 == 0){
      Alice_point += card_point.at(i);
    }
    else Bob_point += card_point.at(i);
  }
  cout << Alice_point - Bob_point << endl;
}


Measured memory_bytes: 256
// AOJ 2019

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

using namespace std;

int main(void)
{
	int n, m;
	while (cin >> n >> m, n || m){
		vector < pair <int, int> > data;
		int d, p;
		int ret = 0;
		for (int i = 0; i < n; i++){
			cin >> d >> p;
			data.push_back(make_pair(p, d));
			ret += (d * p);
		}
		sort(data.rbegin(), data.rend());
/*
		for (int i = 0; i < data.size(); i++){
			cout << data[i].first << " " << data[i].second << endl;
		}
*/
		for (int i = 0; i < (int)data.size(); i++){
			if (m < data[i].second){
				ret -= (m * data[i].first);
				m = 0;
			}
			else {
				ret -= (data[i].first * data[i].second);
				m -= data[i].second;
			}
		}

		cout << ret << endl;
	}
}

Measured memory_bytes: 1324
#include<bits/stdc++.h>
#define mod 1e+7
#define int long long
#define garou ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
signed main() {
	garou;
	int s,w;
	cin>>s>>w;
	if(s>w){
		cout<<"safe";
	}
	else{
		cout<<"unsafe";
	}
}

Measured memory_bytes: 3656
N,M,X=map(int,input().split())
A=[input().split() for _ in range(N)]
ans=[]

for i in range(2**N):
    score=[0]*M
    price=0
    for j in range(N):
        if ((i>>j) & 1):
            price+=int(A[j][0])
            for k in range(M):
                score[k]+=int(A[j][k+1])
    if sorted(score)[0] >= X:
        ans.append(price)

print(-1 if len(ans)==0 else min(ans))

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

int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int money=0;
  if(a+b>2*c){
    int ab=min(x,y);
    money+=2*c*ab;
    int rest=max(x,y)-ab;
    int price;
    if(x>y) price=a;
    else price=b;
    if(price>2*c) money+=rest*2*c;
    else money+=rest*price;
  }
  else{
    money+=a*x+b*y;
  }
  cout<<money<<endl;
}

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

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	ll h, w;
	cin >> h >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) cin >> a[i];

	vector<vector<ll>> dp(h, vector<ll>(w));
	for (int j = 1; j < w; j++)
	{
		if (a[0][j] == '#') break;
		else dp[0][j] = 1;
	}
	for (int i = 1; i < h; i++)
	{
		if (a[i][0] == '#') break;
		else dp[i][0] = 1;
	}

	for (int i = 1; i < h; i++)
	{
		for (int j = 1; j < w; j++)
		{
			if (a[i][j] != '#')
			{
				dp[i][j] += dp[i - 1][j];
				dp[i][j] += dp[i][j - 1];
				dp[i][j] %= mod;
			}
			else dp[i][j] = 0;
		}
	}

	cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 9216
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
    int h,w;
    cin >> h >>w;

    ll d[10][10] = {};
    rep(i,0,10)rep(j,0,10)cin >> d[i][j];

    rep(k,0,10)rep(i,0,10)rep(j,0,10)d[i][j] = min(d[i][j],d[i][k] + d[k][j]);


    ll ans = 0;
    rep(i,0,h)rep(j,0,w){
        int a;
        cin >> a;
        if(a != -1){
            ans += d[a][1];
        }
    }
    P(ans);
	return  0;
}

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

#define dd ch=getchar()
inline int read()
{
	int x=0;bool f=false;char dd;
	while(!isdigit(ch))f|=ch=='-',dd;
	while(isdigit(ch))x=(x<<1)+(x<<3)+ch-48,dd;
	return f?-x:x;
}
#undef dd
void write(int x)
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+48);
}
#define writeln(x) (write(x),putchar('\n'))

const int N=100005,mod=998244353;
int o[N],n,m;
ll k;
int tmp[N],a[N],b[N];

signed main()
{
//	freopen("qwq.in","r",stdin);
//	freopen("qwq.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)
		o[i]=read();
	for(int i=1;i<=n;i++)
		a[i]=o[i]-o[i-1];
	for(int i=1;i<=n;i++)
		b[i]=i;
	cin>>m>>k;
	for(int i=1,x;i<=m;i++)
	{
		x=read();
		swap(b[x],b[x+1]);
	}
	
	for(;k;k>>=1)
	{
		if(k&1)
		{
			memcpy(tmp,a,sizeof(a));
			for(int i=1;i<=n;i++)
				a[i]=tmp[b[i]];
		}
		memcpy(tmp,b,sizeof(b));
		for(int i=1;i<=n;i++)
			b[i]=tmp[tmp[i]];
	}
	
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		sum+=a[i];
		printf("%.1lf\n",(double)sum);
	}
	return 0;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
float temp(int t, int h);

int main(){
    int n, t, a, ans;
    float tmp, min = 10000000;
    cin >> n;
    cin >> t >> a;
    int h[n];

    for(int i=0; i<n; i++){
	cin >> h[i];	
    }

    for(int i=0; i<n; i++){
	tmp = abs(a - temp(t, h[i]));
	if(min > tmp){
	    ans = i;
	    min = tmp;	    
	}
    }
    cout << ans+1 << "\n";    
}

float temp(int t, int h){
    return t - h * 0.006;    
}


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

int main(){
  std::string s;
  cin >> s;
  bool answer = true;
  int C_count = 0;
  int B_count = 0;
  for(int i = 0; i <= s.size(); i++){
    if(i == s.size()){
      if(C_count == 1 && B_count == 2){
        break;
      }
      else{
        answer = false;
        break;
      }
    }
    if(s.at(0) != 'A'){
      answer = false;
      break;
    }
    if(isupper(s.at(i))){
      B_count++;
    }
    if(s.at(i) == 'C'){
      C_count++;
    }
  }
  if(answer){
    for(int i = 2; i <= s.size() - 1; i++){
      if(i == s.size() - 1){
        answer = false;
        break;
      }
      if(s.at(i) == 'C'){
        break;
      }
    }
  }
  if(answer){
    cout << "AC" << endl;
  }
  else{
    cout << "WA" << endl;
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
const int maxn=1e6+10;
int n,a[maxn];
long long num[maxn],ans;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),num[a[i]]++;
	for (int i=1;i<=n;i++) ans+=num[i]*(num[i]-1)/2;
	for (int i=1;i<=n;i++)
	{
		printf("%lld\n",ans-num[a[i]]*(num[a[i]]-1)/2+(num[a[i]]-1)*(num[a[i]]-2)/2);
	}
return 0;
}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int a, b;
    string op;
    cin >> a >> op >> b;

    if(op == "+"){
        cout << a + b << endl;
    }else{
        cout << a - b << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long LL;
const int N = 2e5+100;

LL dp[N];
LL a[N],h[N];
int n;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    for(int i = 1; i<=n; i++) cin>>h[i];
    for(int i = 1; i<=n; i++) cin>>a[i];
    
    set<pair<LL,LL>> s;
    s.insert({0,0});
    for(int i = 1; i<=n; i++){
        auto p = prev(s.lower_bound({h[i],0}));
        dp[i] = p->second + a[i];
        while(1){
            auto q = s.lower_bound({h[i],0});
            if(q != s.end() && q->second <= dp[i])
                s.erase(q);
            else 
                break;
        }
        s.insert({h[i],dp[i]});
    }
    
    LL ans = 0;
    for(int i = 1; i<=n; i++) ans = max(ans,dp[i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 20232
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
 
n = ni()
 
ss = []
for i in range(n):
    ss.append(ns())
 
for i in range(n):
    for j in range(i):
        if ss[i] == ss[j]:
            print("No")
            sys.exit(0)
 
for i in range(n-1):
    if ss[i][-1] != ss[i+1][0]:
        print("No")
        sys.exit(0)
 
print("Yes")

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

int main() {
  string s;
  cin >> s;
  string out;
  string result="";
  
  for (int i=0; i<s.size(); i++) {
    if (s.at(i)=='A' || s.at(i)=='C' || s.at(i)=='G' || s.at(i)=='T') {
      out += s.at(i);
      for (int j=i+1; j<s.size(); j++) {
        if (s.at(j)=='A' || s.at(j)=='C' || s.at(j)=='G' || s.at(j)=='T') {
          out += s.at(j);
        }
        else break;
      }
    }
    if (out.size() > result.size()) result = out;
    out = "";
  }
  cout << result.size();
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())
loop = 0
result = 0

while(loop <= n):
    targetNum = list(str(loop))
    sum = 0
    for num in targetNum:
        sum += int(num)

    if a <= sum and sum <= b :
        result += loop

    loop += 1

print(result)

Measured memory_bytes: 3060
from sys import stdin, gettrace
if not gettrace():
    def input():
        return next(stdin)[:-1]
 
 
# def input():
#    return stdin.buffer.readline()
def main():
    n,w=map(int,input().split())
    li=[]
    for i in range(n):
        temp=[int(x) for x in input().split()]
        li.append(temp)
    dp=[[-1 for j in range(w+1)] for i in range(n+1)]
    for i in range(n,-1,-1):
        for j in range(0,w+1,1):
            if i==n or j==0:
                dp[i][j]=0        
            elif li[i][0]>j:
                dp[i][j]=dp[i+1][j]
            else:
                dp[i][j]=max(dp[i+1][j-li[i][0]]+li[i][1],dp[i+1][j])
    print(dp[i][w])
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 217772
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<int>> c(10, vector<int>(10));
  for (int i = 0; i < 10; i++){
    for (int j = 0; j < 10; j++){
      cin >> c[i][j];
    }
  }
  vector<vector<int>> A(H, vector<int>(W));
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> A[i][j];
    }
  }
  for (int k = 0; k < 10; k++){
    for (int i = 0; i < 10; i++){
      for (int j = 0; j < 10; j++){
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if (A[i][j] != -1){
        ans += c[A[i][j]][1];
      }
    }
  }
  cout << ans << endl;
}

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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll n,abc[3],ans = 0;
	cin>>n;
	ll dp[n+1][3];
	memset(dp,0,sizeof(dp));
	forni(i,n+1){
		forn(j,3) cin>>abc[j];
		forn(j,3){
			forn(k,3) if(k!=j)dp[i][j] = max(dp[i][j],dp[i-1][k] + abc[j]);
		}
	}
	forn(i,3) ans = max(dp[n][i],ans);
	cout<<ans<<'\n';
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
 


Measured memory_bytes: 5956
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> acum(n+1, 0);
    rep(i, n) acum[i+1] = acum[i] + a[i];

    ll ans = LLINF;
    rep(i, n) {
        chmin(ans, abs(acum[i] - (acum[n]-acum[i])));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
dic = [None, '.,!? ','abc','def','ghi','jkl','mno','pqrs','tuv','wxyz']

N = int(input())
for i in range(N):
    S = input()
    ans = ''
    btn = n = -1
    for c in S:
        if c == '0':
            if btn > 0:
                ans += dic[int(btn)][n % len(dic[int(btn)])]
                btn = n = -1
        else:
            btn = int(c)
            n += 1
    print(ans)

Measured memory_bytes: 5616
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
struct intv{int l,r;}s[300010];
int ans[100010],t[100010],n,m;
void update(int x,int d){while(x<=m)t[x]+=d,x+=x&-x;}
int query(int x){int r=0;while(x)r+=t[x],x-=x&-x;return r;}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	n=gi(),m=gi();
	for(int i=1;i<=n;++i)s[i].l=gi(),s[i].r=gi();
	std::sort(s+1,s+n+1,[](intv a,intv b){return a.r-a.l<b.r-b.l;});
	for(int i=1,p=1;i<=m;++i){
		while(p<=n&&s[p].r-s[p].l+1==i)update(s[p].l,1),update(s[p].r+1,-1),++p;
		int res=n-p+1;
		for(int j=i;j<=m;j+=i)res+=query(j);
		printf("%d\n",res);
	}
	return 0;
}


Measured memory_bytes: 3712
import sys
input=sys.stdin.readline
def main():
  n,k=map(int,input().split())
  a=list(map(int,input().split()))
  dp=[[-1]*(2) for i in range(51)]
  dp[0][0]=0
  maxdigit=50
  for i in range(maxdigit):
    mask=1<<(maxdigit-i-1)
    cnt=0
    for j in range(n):
      if mask&a[j]:
        cnt+=1
    cost0=mask*cnt
    cost1=mask*(n-cnt)
    if dp[i][1]!=-1:
      dp[i+1][1]=max(dp[i+1][1],dp[i][1]+max(cost0,cost1))
    if dp[i][0]!=-1:
      if k&mask:
        dp[i+1][0]=max(dp[i+1][0],dp[i][0]+cost1)
        dp[i+1][1]=max(dp[i+1][1],dp[i][0]+cost0)
      else:
        dp[i+1][0]=max(dp[i+1][0],dp[i][0]+cost0)
  return print(max(dp[maxdigit][0],dp[maxdigit][1]))
if __name__=='__main__':
  main()

Measured memory_bytes: 14356
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n;
    cin >> n;
    char s[n], t[n];
    cin >> s >> t;
    for(int i = 0; i < n; i++)
    {
        cout << s[i] << t[i];
    }
    return 0;
}

Measured memory_bytes: 3632
s = input()

odd_s = list(s[0::2])
even_s = list(s[1::2])

to = ['R', 'U', 'D']
te = ['L', 'U', 'D']

if set(odd_s).issubset(to) and set(even_s).issubset(te):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 8992
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  int c=0;
  for(int i=0;i<n-2;i++)
  {
    if(s[i]=='A' and ( s[i+1] == 'B' and s[i+2]=='C'))
    {
      c++;
    }
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int main(void)
{
	int n;

	cin >> n;
	vector<int> a(n);

	for(int i = 0; i < n; i++ )
	{
		cin >> a[i];
	}

	int min = a[0];
	int max = a[0];
	long sum = a[0];

	for(int i = 1; i < n; i++)
	{
		if( min > a[i] )
		{
			min = a[i];
		}
		if( max < a[i] )
		{	
			max = a[i];
		}
		sum += a[i];
	}

	cout << min << " " << max << " " << sum << endl;
	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	if(K % 2 == 0) {
		cout << pow(K / 2, 2) << endl;
	} else {
		int ans = (K / 2) * (K / 2 + 1);
		cout << ans << endl;
	}

}


Measured memory_bytes: 256
#include<iostream>
#include <cmath>
#include<limits>
#include<queue>
#include <math.h>
#include <iomanip>
using namespace std;

typedef long long ll;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long double a, b, x;
    cin >> a >> b >> x;
    if(x<= a*a*b/2.0){
        cout << setprecision(8)<< 90 - atan(2.0*x/a/b/b) *180.0 / M_PI << endl;
    }else{
        cout << setprecision(8) << atan((2.0*a*a*b-2.0*x)/a/a/a) *180.0 /M_PI << endl;
    }
    return 0;
}

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

using namespace std;

#define forn for (ll i = 0; i < n; i++)
#define form for (ll j = 0; j < m; j++)
#define NO cout << "NO\n";
#define YES cout << "YES\n";
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i = a; i < b; i++)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

ll gcd(ll a, ll b){
    ll r;
    while (b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}


ll *calc_z(string s){
    ll n = s.size();
    ll *z = new ll[n] {0};
    ll l = 0, r = 0;
    for (ll i = 1; i < n; i++){
        if (r >= i) z[i] = min(z[i-l], r-i+1);
        while (z[i]+i < n && s[z[i]] == s[z[i]+i]) z[i]++;
        if (i + z[i] - 1 > r){
            l = i;
            r = i+z[i]-1;
        }
    }
    return z;
}

ll find_lower(ll *a, ll n, ll v){
    ll l = -1, r = n;

    while (r>l+1){
        ll m = (l+r)/2;

        if (a[m] >= v) r = m;
        else l = m;
    }
    if (r == n) return n-1;
    if (a[r] == v) return r;
    return r == 0 ? 0 : r-1;
}

void solve(){
    ll x;
    cin >> x;
    if (x >= 30) cout << "Yes\n";
    else cout << "No\n";
}

int main(){
    //init();

    ios::sync_with_stdio(0);
    cin.tie(0);

    //ll t; cin >> t; while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <cstring>

using namespace std;

const int MOD = 1e9+7;

int bino[2001][2001];

int main() {
    memset(bino, 0, sizeof bino);
    bino[0][0] = 1;
    for (int i = 1; i <= 2000; ++i) {
        bino[i][0] = bino[i][i] = 1;
        for (int j = 1; j < i; ++j) {
            bino[i][j] = (bino[i-1][j-1] + bino[i-1][j]) % MOD;
        }
    }

    int S;
    cin >> S;

    long long ret = 0;
    for (int k = 1; S-2*k-1 >= 0; ++k) {
        ret = (ret + bino[S-2*k-1][k-1]) % MOD;
    } 
    cout << ret << endl;
}

Measured memory_bytes: 19240
#include <iostream>
#include<algorithm>
using namespace std;
 
int main() {
    for(;;){
        int e;
        int ans=1000000;
        cin >> e;
        if (e==0) {
            break;
        }
        for (int z=0;e-z*z*z>=0 ; z++) {
            for (int y=0; e-z*z*z-y*y>=0; y++) {
                ans=min(ans,e-z*z*z-y*y +y+z);
            }
        }
        cout<<ans<<"\n";
    }
}

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

using ll=long long;
#define rng(i,l,r) for(int i=int(l);i<int(r);i++)
#define rep(i,r) rng(i,0,r)
#define rrng(i,l,r) for(int i=int(r)-1;i>=int(l);i--)
#define rrep(i,r) rrng(i,0,r)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#define inf INT_MAX/2-100
#define infl LLONG_MAX/3
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<' '<<#x<<' '<<x<<endl
#else
#define dmp(x) void(0)
#endif
 
template<class t,class u>bool chmax(t&a,u b){if(a<b)a=b;return a<b;}
template<class t,class u>bool chmin(t&a,u b){if(b<a)a=b;return b<a;}
 
template<class t>using vc=vector<t>;
template<class t>using vvc=vector<vector<t>>;
 
using pi=pair<int,int>;
using pl=pair<ll,ll>;
using vi=vc<int>;
using vl=vc<ll>;
 
 
ll readl(void){
	ll x;
	cin>>x;
	return x;
}
int readi(void){
	int x;
	cin>>x;
	return x;
}
 
string readstr(){
	string s;
	cin>>s;
	return s;
}
vi readvi(int n,int off=0){
	vi v(n);
	rep(i,n)v[i]=readi(),v[i]+=off;
	return v;
}
 
vl readvl(int n,int off=0){
	vl v(n);
	rep(i,n)v[i]=readl(),v[i]+=off;
	return v;
}
 
template<class t>
void print(t x,int suc=1){
	cout<<x;
	if(suc==1)cout<<"\n";
	if(suc==2)cout<<" ";
}
 
template<class t>
void print(const vc<t>&v,int suc=1){
	rep(i,si(v))print(v[i],i==int(si(v))-1?1:suc);
}
 
template<class t>
bool inc(t a,t b,t c){
	return !(c<b||b<a);
}
 
template<class t>
void compress(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}
 
template<class t>
int lwb(const vc<t>&v,const t&a){
	return lower_bound(all(v),a)-v.bg;
}
 
template<class t>
struct Compress{
	vc<t>v;
	Compress()=default;
	Compress(const vc<t>&x){
		add(x);
	}
	Compress(const initializer_list<vc<t> >&x){
		for(auto &p:x)add(p);
	}
	void add(const t&x){
		v.eb(x);
	}
	void add(const vc<t>&x){
		copy(all(x),back_inserter(v));
	}
	void build(){
		compress(v);
	}
	int get(const t&x)const{
		return lwb(v,x);
	}
	vc<t>get(const vc<t>&x)const{
		vc<t>res(x);
		for(auto &p:res)p=get(p);
		return res;
	}
	const t &operator[](int x)const{
		return v[x];
	}
	int size(){
		return v.size();
	}
};
void Yes(bool ex=true){
	cout<<"Yes\n";
	if(ex)exit(0);
}
void YES(bool ex=true){
	cout<<"YES\n";
	if(ex)exit(0);
}
void No(bool ex=true){
	cout<<"No\n";
	if(ex)exit(0);
}
void NO(bool ex=true){
	cout<<"NO\n";
	if(ex)exit(0);
}
void orYes(bool x,bool ex=true){
	if(x)Yes(ex);
	else No(ex);
}
void orYES(bool x,bool ex=true){
	if(x)YES(ex);
	else NO(ex);
}
void Possible(bool ex=true){
	cout<<"Possible\n";
	if(ex)exit(0);
}
void POSSIBLE(bool ex=true){
	cout<<"POSSIBLE\n";
	if(ex)exit(0);
}
void Impossible(bool ex=true){
	cout<<"Impossible\n";
	if(ex)exit(0);
}
void IMPOSSIBLE(bool ex=true){
	cout<<"IMPOSSIBLE\n";
	if(ex)exit(0);
}
void orPossible(bool x,bool ex=true){
	if(x)Possible(ex);
	else Impossible(ex);
}
void orPOSSIBLE(bool x,bool ex=true){
	if(x)POSSIBLE(ex);
	else IMPOSSIBLE(ex);
}


int main(void){
	cin.tie(0);
	ios::sync_with_stdio(0);
	string s="ABC",t="ARC",p;
	cin>>p;
	if(p==s)cout<<t<<endl;
	else cout<<s<<endl;
}

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

int main()
{
  	int m,f,r,mf;
  	char c;	
  
 	cin >> m >> f >> r;

  	while(m+f+r != -3){
      if(m < 0 || f < 0)c = 'F';
      else{
        mf = m + f;
        if(mf >= 80)c = 'A';
        else if(mf >= 65)c = 'B';
        else if(mf >= 50)c = 'C';
        else if(mf >= 30){
          if(r >= 50)c = 'C';
          else c = 'D';
        }
        else c = 'F';
      }
      cout << c << endl;
      
      cin >> m >> f >> r;
    }
  	
}


Measured memory_bytes: 3104
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//入力
		int n = sc.nextInt();
      	String str = sc.next();
      
      if(n>=3200){
      	System.out.println(str);
      }else{
        System.out.println("red");
     }
    }
}

Measured memory_bytes: 35772
// Shinchan Loves Coding :)))
#include<bits/stdc++.h>

using namespace std;

#define night_rider ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define double long double
#define en "\n"
#define no 1e5
#define big 1e7+1
#define fi first
#define se second
#define modulo 1e9+7
#define MP make_pair
#define PB push_back
typedef vector<int> vi;
typedef pair<int,int> vii;

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

signed main()
{
    night_rider
  //  freopen("input.txt","r",stdin);
  //  freopen("output.txt","w",stdout);

    int n;
    cin>>n;
    int sum=0;
    for(int i=1 ; i<=n ; i++)
    {
        for(int j=1 ; j<=n ; j++)
        {
            for(int k=1 ; k<=n ; k++)
            {
                int res=gcd(j,k);
                int p=gcd(i,res);
                sum+=p;
            }
        }
    }
    cout<<sum;
}



Measured memory_bytes: 3612
import sys
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

for i in range(101):
    a1 = i
    b1 = c11 - a1
    b2 = c12 - a1
    b3 = c13 - a1
    a2 = c21 - b1
    a3 = c31 - b1
    #print(a1, a2, a3, b1, b2, b3)
    if a2+b2 == c22 and a2+b3 == c23 and a3+b2 == c32 and a3+b3 == c33:
        print('Yes')
        sys.exit(0)
print('No')


Measured memory_bytes: 3064
import sys
n=int(input())
s=input()
if n==1 or n/2!=n//2:
  print("No")
  sys.exit()
for i in range(n//2):
  if s[i]==s[n//2+i]:
    pass
  else:
    print("No")
    sys.exit()
print("Yes")    

Measured memory_bytes: 2940
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<vector<int>>edge(N);
	vector<int>dir(N);
	for (int i = 0; i < N; i++) {
		cin >> L >> R;
		L--, R--;
		edge[L].push_back(R);
		edge[R].push_back(L);
		dir[L]++;
		dir[R]++;
	}
	vector<int>leg(N);
	queue<int>Q;
	for (int i = 0; i < N; i++) {
		if (dir[i] == 1)Q.push(i);
	}
	while (!Q.empty()) {
		int cn = Q.front();
		leg[cn] = 1;
		Q.pop();
		for (auto i : edge[cn]) {
			dir[i]--;
			if (dir[i] == 1) {
				Q.push(i);
			}
		}
	}
	cin >> K;
	for (int loop = 0; loop < K; loop++) {
		cin >> L >> R;
		L--, R--;
		if (leg[L] || leg[R])cout << 1 << endl;
		else cout << 2 << endl;
	}
}


Measured memory_bytes: 9132
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using pint = pair<int, int>;
using pll = pair<ll,ll>;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n,h;
    cin >> n >> h;
    vector<int> a(n),b(n+1);
    ll ans=0;
    REP(i,n){
        cin >> a[i] >> b[i];
    }
    b.push_back(0);
    sort(a.begin(),a.end(),greater<>());
    sort(b.begin(),b.end(),greater<>());
    int cut_max=a[0],index=0,count=0;
    while(h>0){
        if(cut_max<b[index]){
            h-=b[index];
            index++;
            count++;
        }
        else{
            h-=cut_max;
            count++;
        }
    }
    COUT(count);
    return 0;
}  

Measured memory_bytes: 1408
#include<deque>
#include<stdint.h>
#include<set>
#include<stack>
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
using namespace std;
int n,m,d,i,j,col[2010];
char ss[4]={'R','Y','B','G'};
int main()
{
	cin>>n>>m>>d;
	for (i=d;i<=2000;i++)
	{
		col[i]=1-col[i-d];
	}
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=m;j++)
		{
			cout<<ss[col[i+j]*2+col[i-j+1000]];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[MAX];
int head, tail, n;

void initailize(){
  head = 0; tail = 0;
}

void enqueue(P x){
  Q[tail]=x;
  tail = (tail+1)%MAX;
}

P dequeue(){
  P x = Q[head];
  head = (head+1)%MAX;
  return x;
}


int main(void){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for (i=1 ; i<=n ; i++){
    P u1;
    scanf("%s %d", u1.name, &u1.t);
    enqueue(u1);
  }

  while(head!=tail){
    u=dequeue();
    if(u.t > q){
      elaps += q;
      u.t -= q;
      enqueue(u);

    }
    else{
      elaps += u.t;
      printf("%s %d\n",u.name, elaps);
    }
  }
  return 0;
}


Measured memory_bytes: 11848
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  string a;
  int L;
  while(1){
    cin >>a>>L;
    if(a == "0" && L==0)break;
    map<string,int> mp;
    mp[a]=0;
    int i=1;
    int ans1,ans2;
    while(1){
      while((int)a.size() < L){
	a="0"+a;
      }
      string smax=a,smin=a;
      sort(smax.begin(),smax.end());
      reverse(smax.begin(),smax.end());
      sort(smin.begin(),smin.end());
      stringstream ss1,ss2;
      ss1 << smax;
      ss2 << smin;
      int max,min;
      ss1 >> max;
      ss2 >> min;
      stringstream ss3;
      ss3 << max-min;
      ss3 >>a;
      if(mp.count(a) != 0){
	ans1=mp[a];
	ans2=i-ans1;
	break;
      }
      mp[a]=i;
      i++;
    }
    cout <<ans1<<" "<<a<<" "<<ans2<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1260
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String lineN = br.readLine();
		String[] lineA = br.readLine().split(" ");
		int n = Integer.parseInt(lineN);
 		for(int i = n-1 ; i >= 0 ; i--){
                 	int a = Integer.parseInt(lineA[i]);
			sb.append(a);
			if(i != 0) sb.append(" ");
		}
		System.out.println(sb);
	} 
}

Measured memory_bytes: 24136
#include <stdio.h>
int d;
int f0(int p0,int p1) {
  if(p1==600/d)
    return p0;
  else
    return f0(p0+(600-d*p1)*(600-d*p1)*d,p1+1);
}
int main(void) {
  while(scanf("%d",&d)!=EOF)
    printf("%d\n",f0(0,1));
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
  int a,b,x;
  cin >> x >> a >> b;
  if ((b-a)<=0)
  {
    cout << "delicious" << endl;
  }else if ((b-a)>0&&(b-a)<=x)
  {
    cout << "safe" << endl;
  }else
  {
    cout << "dangerous" << endl;
  }
  
  
  
  
 
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256