akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main 
{
	public static void main(String arg[])
	{
		Scanner sc=new Scanner(System.in);
		boolean a[] =new boolean[10001];
		Arrays.fill(a, true);
		a[0]=a[1]=false;
		for(int i=2; i*i<=10000; i++)
		{
			if(!a[i])
				continue;
			for(int j=i*2; j<=10000; j+=i)
				a[j]=false;
		}


		while(sc.hasNext())
		{
			int n=sc.nextInt();
			if(n==0)
				return;
			int sum=0;
			int ans=0;

			for(int i=2; i<=n; i++)
			{
				sum =0;
				if(a[i])
					for(int j=i; j<=n; j++)
					{
						if(a[j])
						{
							sum+=j;
							if(n==sum)
								ans++;
						}
						if(sum>=n)
							break;
					}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;
void swap(int &a, int &b);

int main()
{
	int a[20000], b[20000];
	char op[20000];
	int count = 0;
	while (1)
	{
		cin >> a[count] >> op[count] >> b[count];
		if (op[count] == '?')
			break;
		count++;
	}
	for (int i = 0; i < count; ++i)
	{
		if (op[i] == '+')
		{
			cout << a[i] + b[i];
		}
		if (op[i] == '-')
		{
			cout << a[i] - b[i];
		}
		if (op[i] == '*')
		{
			cout << a[i] * b[i];
		}
		if (op[i] == '/')
		{
			cout << a[i] / b[i];
		}
		cout << endl;
	}

	return 0;
}

void swap(int &a, int &b)
{
	int temp = a;
	a = b;
	b = temp;
	return;
}




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

int n, a[51], b[51], c[51];
long long fp;
bool bo[51], brr;

void gnyb() {
	for(int i = 0; i <= 50; ++i) bo[i] = 0;
}

bool mgw(int a, int b) {
	bo[a] = 1;
	bool drr = 0;
	if(a == b) return 1;
	for(int i = 1; i <= a; ++i) {
		if(c[i] && !bo[a % i]) {
			drr |= mgw(a % i, b);
		}
	}
	return drr;
}

bool SMMBLK() {
	for(int i = 1; i <= n; ++i) {
		gnyb();
		if(!mgw(a[i], b[i])) {
			return 0;
		}
	}
	return 1;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	for(int i = 1; i <= n; ++i) cin >> b[i];
	for(int i = 1; i <= n; ++i) if(a[i] != b[i]) fp = 0;
	while(!SMMBLK()) {
		for(int i = 1; i <= 51; ++i) {
			if(i == 51) {
				cout << -1 << endl;
				return 0;
			}
			c[i] = 1;
			brr = 1;
			for(int j = 1; j <= n; ++j) {
				gnyb();
				if(!mgw(a[j], b[j])) {
					brr = 0;
					break;
				}
			}
			if(brr) {
				c[i] = 2;
				fp |= (1ll << i);
				for(int j = 0; j <= 50; ++j) if(c[j] == 1) c[j] = 0;
				break;
			}
		}
	}
	cout << fp << endl;
	return 0;
}

Measured memory_bytes: 256
// ref. http://code-festival-2016-quala.contest.atcoder.jp/data/other/code-festival-2016-qualb/editorial.pdf

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

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

  ll ans = 0;
  ans += a[0] - 1; // decrease a[0] to 1.
  ll now = 2; // try this value in greedy way.
  for (int i = 1; i < n; ++i) {
    // Here, check current value
    if (a[i] == now) {
      ++now; // increase now
      continue;
    }
    // Here, a[i] != now. We can decrease in greedy way.
    if (a[i] < now) { continue; }
    // Here, a[i] > now
    if (a[i] % now == 0) { // 2*a[i], 3*a[i], ...
      a[i] -= now + 1;
      ++ans;
    }
    ans += a[i]/now; // round down of a[i]/now.
  }

  cout << ans << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
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; }
template<class T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }

void _main() {
  int A, B, C;
  cin >> A >> B >> C;

  if (A==B && B==C && A%2==0) {
    cout << -1 << endl;
    return;
  }

  int ans = 0;
  while (A%2==0 && B%2==0 && C%2==0) {
    ans++;
    int a = B/2 + C/2;
    int b = A/2 + C/2;
    int c = A/2 + B/2;
    A = a;
    B = b;
    C = c;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e7+5;
int main(){
	ll n,cnt=0,m=0,x,y=0;
	cin>>n>>x;
	for(int i=1;i<n;i++){
		cin>>y;
		if(y<=x) cnt++;
		else{
			m=max(m,cnt);
			cnt=0;
		}
		x=y;
	}
	m=max(m,cnt);
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 384
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
    var n = parseInt(tmp[0], 10);
    var ans =0;
    if(n%2==0){console.log(n/2);}
      else if(n==1){console.log("1");}
               //  else{console.log(n%2+1);}
                   else{var ans=Math.ceil(n/2);
                      console.log(ans);}
                 
}
   
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner  yomi = new Scanner(System.in);
        int a = yomi.nextInt();
        int b = yomi.nextInt();
        int c = yomi.nextInt();
        int d = yomi.nextInt();
        while (true){
            c-=b;
            if (c<=0){
                System.out.println("Yes");
                return;
            }
            a-=d;
            if(a<=0){
                System.out.println("No");
                return;
            }
        }

    }
}

Measured memory_bytes: 35492
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t 
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define crap ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846264338327950288419716939937510
#define pb(a) push_back(a)
#define pf(a) push_front(a)
using namespace std;

int main()
{
	crap;
//	int t;
//	cin>>t;
//	while(t--)
//	{
		ll i,j,k,n;
		cin >> n;
		vector <ll> arr(n);
		f(i,0,n)
			cin >> arr[i];
		ll sum = 0;
		unordered_map <ll,ll> occur ;
		f(i,0,n)
		{
			sum += arr[i] ;
			occur[arr[i]]++;
		}
		ll q;
		cin >> q;
		while(q--)
		{
			ll x,y;
			cin >> x >> y;
			sum = sum - occur[x]*x ;
			sum += occur[x]*y;
			occur[y] += occur[x] ;
			occur[x] = 0;
			cout << sum endl ;
		}
//	}
	return 0;
}

Measured memory_bytes: 7884
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N = int(input())
A = [int(i) for i in input().split()]

A.sort()
if N == 2:
    print(A[1]-A[0])
    print(A[1],A[0])
    exit()

A.reverse()
max_num = A[0]
min_num = A[-1]
exchanges = [() for i in range(N-1)]
for i in range(1,N-1):
    if A[i] < 0:
        exchanges[i-1] = (max_num,A[i])
        max_num = max_num - A[i]
    else:
        exchanges[i-1] = (min_num,A[i])
        min_num = min_num - A[i]

exchanges[-1] = (max_num,min_num)
ans = max_num-min_num
print(ans)
for i in range(N-1):
    a,b = exchanges[i]
    print(a,b)


Measured memory_bytes: 23356
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b;
    cin>>a>>b;
    if(a.size()>b.size()) cout<<"GREATER";
    else if(a.size()<b.size()) cout<<"LESS";
    else{
        if(a>b) cout<<"GREATER";
        else if(a<b) cout<<"LESS";
        else cout<<"EQUAL";
    }
    cout<<endl;
}

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

TXY = [[0,0,0]]
for n in range(N):
  TXY.append([int(i) for i in input().split()])

ans = "Yes"
for i in range(N):
  sec = TXY[i+1][0] - TXY[i][0]
  length = abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2])

  if sec < length or (sec >= length and (length - sec)%2 == 1):
    ans = "No"
    break

print(ans)


Measured memory_bytes: 21156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N = 0 , K = 0 , flag = 0 , OutArea = 0;
unsigned int MinData = 0;
cin>>N>>K;
int data[N];
 	 for(int i = 0 ; i < N ; i++){
   		 cin>>data[i];
  	 }
 	 for(int i = 0 ; i < K ; i++){
         MinData = -1;
   		 for(int i = 0 ; i < N ; i++){
			if(MinData > data[i] && data[i] > 0){
  				MinData = data[i];
              	flag = i;
  			}
   		}
//  cout << MinData<<endl;
    OutArea += MinData;
  	data[flag] = 0;  
  }
  cout << OutArea<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll K;
const ll lim = 10000000000000000LL + 1000LL;
int main() {
  cin >> K;
  for (ll i = 2; i <= 50; ++i) {
    ll k = K / i;
    if (k * i == K) {
      ll t = k * (i + 1) - K + i - 1;
      if (t > lim) continue;
      cout << i << endl;
      for (ll j = 0; j < i; ++j) {
        cout << t << ' ';
      }
      cout << endl;
      return 0;
    }

    ll r = K - k * i;
    ll tt = (k + 1) * (i + 1) - K + i - 1;
    if (tt <= lim) {
      cout << i << endl;
      for (ll j = 0; j < r; ++j) {
        cout << tt << ' ';
      }
      for (ll j = r; j < i; ++j) {
        cout << tt - i - 1 << ' ';
      }
      cout << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

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

	count := 0
	for i := 0; i < n; i++ {
		if list[list[i]-1] == i+1 {
			count++
		}
	}
	fmt.Println(count / 2)

}


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

void bar1(int w){
    for(int i=0; i<w; i++){
        if(i%2==0)
            cout << '#';
        else
            cout << '.';
    }
    cout << endl;
}

void bar2(int w){
        for(int i=0; i<w; i++){
        if(i%2==0)
            cout << '.';
        else
            cout << '#';
    }
    cout << endl;
}

int main(void){
    // Your code here!
    int H, W;
    while(true){
        cin >> H >> W;
        if(H==0 && W == 0)
            break;
        for(int i=0; i<H; i++){
            if(i%2==0)
                bar1(W);
            else
                bar2(W);
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3056
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;



int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    while (1) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3568
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

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

	if (a>b){t=a; a=b; b=t;}
	if (b>c){t=b; b=c; c=t;}
	if (a>b){t=a; a=b; b=t;}

	cout << a << " " << b << " " << c <<endl;
	return 0;
}

Measured memory_bytes: 3092
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val array = Array(n, {0.0})
    for(i in 0..n-1){
        array[i] = scanner.nextDouble()
    }
    var gcd = array[0]
    for(i in 1..n-1){
        gcd = gcd * array[i] / cal(gcd, array[i])
    }
    var sum = 0.0
    for(i in 0..n-1){
        sum += gcd / array[i]
    }
    println(gcd / sum)
}

fun cal(x:Double, y:Double): Double{
    var x2 = x;
    var y2 = y;
    if(x2 < y2) return cal(y2, x2);
    if(y2 === 0.0) return x2;
    return cal(y2, x2 % y2);
}

Measured memory_bytes: 31260
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

size_t N;
vector<int> a;

int main()
{
    cin >> N;
    a.resize(N);
    for (size_t i = 0; i < N; i++) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());
    cout << a.back() - a.front() << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> student;
    vector<pair<ll,ll>> check;
    vector<int> ans;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        student.push_back(make_pair(a,b));
    }
    rep(i,m){
        ll a,b;
        cin >>  a >> b;
        check.push_back(make_pair(a,b));
    }
    
    rep(i,n){
        ll  point=3000000000;
        int p;
        rep(j,m){
           ll manha = abs(student[i].first-check[j].first) + abs(student[i].second-check[j].second);
           if(manha<point){
               point = manha;
               p = j+1;
           }
        }
        ans.push_back(p);
    }
    rep(i,n){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define MAX 2000001
#define ll long long
using namespace std;
int main()
{
    ll n,c=0;
    cin>>n;
    c = n/11;
    n%=11;
    if(n>0&&n<7) cout<<1+c*2<<endl;
    else if(n>6&&n<11) cout<<2+c*2<<endl;
    else cout<<c*2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <time.h>
#include <algorithm>
#include <random>

using namespace std;
#define int long long

signed main() {
    ios_base::sync_with_stdio(false);
    cout.precision(20);

    int n, k;
    cin >> n >> k;

    int ans = 0;

    if (k == 0) {
        for (int i = 1; i <= n; ++i) {
            ans += n / i;
        }
        k = 1;
    }

    for (int i = k + 1; i <= n; ++i) {
        ans += (n / i) * (i - k);
        if (k <= n % i) ans += n % i - k + 1;
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define INF 1073741824
#define ll long long
#define PI (2*acos(0.0))
#define p1(n) printf("showing %d\n",n)
#define p2(m,n) printf("showing %d %d\n",m,n)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define on(val,pos) (val|(1<<pos))
#define off(val,pos) val&(~(1<<pos))
#define check(val,pos) (val&(1<<pos))
#define all(n) n.begin(),n.end()
//first four adjacent,second four corner
//int row[8]={0,-1,0,1,1,-1,-1,1};
//int col[8]={-1,0,1,0,-1,-1,1,1};
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
int k,n,m;
string s[7];
int sum(int row,int col){
    int cnt=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(check(row,i) or check(col,j))continue;
            else if(s[i][j]=='#')cnt++;
        }
    }
    return cnt;
}
int dp(int i,int j,int row,int col){
    if(i>=n and j>=m){
        return k==sum(row,col);
    }
    int total=0;
    for(int a=0;a<2;a++){
        for(int b=0;b<2;b++){
            total+=dp(i+1,j+1,(row | (a<<i)),(col | (b<<j)));
        }
    }
    return total;
}
int main(){
    int i,j,val,t=0,test;
    //freopen("000input.txt","r",stdin);
    cin>>n>>m>>k;
    for(i=0;i<n;i++)cin>>s[i];
    int x=abs(n-m);
    printf("%d\n",dp(0,0,0,0)/(1<<x));
    //free();   //if pointer array
    return 0;
}


Measured memory_bytes: 3756
import sys
from math import gcd

K = int(sys.stdin.readline().rstrip())
ans = 0

for a in range(1, K + 1):
    for b in range(a, K + 1):
        for c in range(b, K + 1):
            if a == b == c:
                ans += a
            elif a == b:
                ans += gcd(a, c) * 3
            elif a == c:
                ans += gcd(a, b) * 3
            elif b == c:
                ans += gcd(a, b) * 3
            else:
                ans += gcd(gcd(a, b), c) * 6

print(ans)

Measured memory_bytes: 9212
#include<iostream>
#define MAX_N 101
using namespace std;

int a[MAX_N];

int main() {
    int N, sum_a = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        sum_a += a[i];
    }
    int ans = 0, min_d = sum_a;
    for (int i = 0; i < N; i++) {
        if (abs(a[i] * N - sum_a) < min_d) {
            ans = i;
            min_d = abs(a[i] * N - sum_a);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn];
int main(){
  IOS();
  ll n,a,b;
  cin >> n >> a >> b;
  REP (i,n) cin >> d[i];

  ll ans = 0;
  REP (i,n-1) {
    if ((d[i+1]-d[i]) * a <= b) ans += (d[i+1]-d[i]) * a;
    else ans += b;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
#define rep(i, n) for (int i=0; i<(int) (n);i++)
using ll = long long;
using P = pair<int, int>;

void solve_1() {//14m
	int a, b;
	cin >> a >> b;
	int total;
	int n = 0;
	while (!((a-1)*n + 1 >= b)) {
		n++;
	}
	cout << n << endl;

}

void solve_2() {//30m
	int n;
	cin >> n;
	vector<int> x;
	int total = 0;
	rep(i, n) {
		int tmp;
		cin >> tmp;
		x.push_back(tmp);
		total += tmp;
	}
	int p1 = (double(total)/double(n)*2 - 1.0) / 2;
	int p2 = (double(total)/double(n)*2 - 1.0) / 2 + 1;
	int point_sum1 = 0, point_sum2= 0;
	rep(i, n) {
		point_sum1 += pow(x[i] - p1, 2);
		point_sum2 += pow(x[i] - p2, 2);
	}
	cout << min(point_sum1, point_sum2) << endl;

}

void solve_2re() {
	int n;
	cin >> n;
	vector<int> x(n);
	int total = 0;
	rep(i, n) {
		cin >> x[i];
		total += x[i];
	}
	int p1 = total / n;
	int p2 = total / n + 1;
	int point_sum1 = 0, point_sum2 = 0;
	rep(i, n) {
		point_sum1 += pow(x[i] - p1, 2);
		point_sum2 += pow(x[i] - p2, 2);
	}
	cout << min(point_sum1, point_sum2) << endl;
}

void solve_3() {//17m
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int sum = a + b;
	rep(i, n) {
		if (s[i] == 'a') {
			cout << (sum > 0 ? "Yes" : "No") << endl;
			if (sum>0) {
				sum--;
			}
		}
		else if (s[i] == 'b') {
			cout << (sum > 0 && b > 0 ? "Yes" : "No") << endl;
			if (sum > 0 && b > 0) {
				if (b>0) {
					sum--;
					b--;
				}
				else {
					sum--;
				}
			}
		}
		else if (s[i] == 'c') {
			cout << "No" << endl;
		}
	}
}

void solve_4() {//7m
	int n;
	cin >> n;
	rep(i, 50000) {
		if (int(i*1.08) == n) {
			cout << i;
			return;
		}
	}
	cout << ":(";
}

void solve_4re() {
	int n;
	cin >> n;
	int x = ceil(n/ 1.08);
	if (int(x*1.08)==n) {
		cout << x;
	}
	else
	{
		cout << ":(";
	}
}

void solve_5() {

}

void solve_6() {

}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//solve_1();
	//solve_2();
	//solve_2re();
	//solve_3();
	solve_4re();
	//solve_5();
	//solve_6();
	return 0;
}

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






int main() {
  string s;
  cin>>s;
  
  rep(i,3){
    if(s[i]==s[i+1]){
      cout<<"Bad"<<endl;
      return 0;
    }
  }
  cout<<"Good"<<endl;
}

Measured memory_bytes: 256
n, a, b, c, d = map(int, input().split())

s = input()

if s.find('##',a,max(c, d)) < 0:
    if c<d :
        print('Yes')
    else :
        if s.find('...',b-2,d+1)>=0:
            print('Yes')
        else :
            print('No')
else :
    print('No')

Measured memory_bytes: 3572
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string as = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string ab = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

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

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

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



int main() {

  int a, b;
  cin >> a >> b;

  if(a>9||b>9) cout << -1 << endl;
  else cout << a*b << endl;

  return 0;
}


Measured memory_bytes: 256
import math

n = int(input())
s = input()
s2 = list(s)

if s[0] == 'B':
    s2[0] = 'L'
else:
    s2[0] = 'R'

for i in range(1,2*n): 
    if s[i-1] == s[i]:
        if s2[i-1] == 'L':
            s2[i] = 'R'
        else:
            s2[i] = 'L'
    else:
        if s2[i-1] == 'L':
            s2[i] = 'L'
        else:
            s2[i] = 'R'
        
if s2[0] == 'R' or s2[2*n-1] == 'L' or s2.count('L') != s2.count('R'):
    print(0)
    exit()
            
ans = 1
count_l = 0
for s2_str in s2: 
    if s2_str == 'L':
        count_l += 1
    else:
        ans *= count_l
        ans %= 10**9 + 7
        count_l -= 1
    
print(ans * math.factorial(n) % (10**9 + 7))

Measured memory_bytes: 61680
n,m= map(int,input().split())
l = []
for i in range(m):
    a=(list(map(int,input().split())))
    l.append(a[1:])
b = list(map(int,input().split()))
ans = 0
for i in range(2**n):
    sw = [0 for i in range (m)]
    g = i+0
    for j in range(n):
        if g &1 == True:
            for k in range(m):
                if j+1 in l[k]:
                    sw[k]+=1
        g = g>>1
    cnt = 0
    for j in range(m):
        if sw[j]%2==b[j]:
            cnt+=1
    if cnt==m:
        ans+=1
print(ans)

Measured memory_bytes: 73872
'use strict';
function main(input) {
  const args =input.split('\n'),
        N = parseInt(args[0]),
        S = args.slice(1, N+1);
  let register = new Map();
  let cnt = 0;
  for (let s of S) {
    let sorted = s.split('').sort().join();
    if (!register.has(sorted)) {
      register.set(sorted, 1);
    } else {
      let tmp = register.get(sorted);
      cnt += tmp;
      register.set(sorted, tmp+1);
    }
  }
  console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 57648
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    HashSet<Integer> A = new HashSet<Integer>();
    for (int i = 0; i < N; i++) {
      A.add(sc.nextInt());
    }
    System.out.println(A.size());
  }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#include<unordered_map>
/*
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*    ▀▀       ▀▀▀▀▀▀    ▀     ▀▀▀▀▀▀      ▀    ▀
*   ▀  ▀      ▀         ▀     ▀            ▀  ▀
*  ▀    ▀     ▀ ▀ ▀     ▀     ▀ ▀ ▀         ▀
* ▀ ▀▀▀▀ ▀    ▀         ▀     ▀             ▀
*▀        ▀   ▀         ▀     ▀             ▀
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*/
using namespace std;
void afify()
{
	ios::sync_with_stdio(0);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
#define ll long long
#define ld long double
#define mk make_pair
#define loop(i,intial,n)  for(int i=int(intial);i<n;i++)
#define loopn(j,n) for(int j=int(n-1);j>=0;j--)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(v) v.begin(),v.end()
///////////////////////////////////////
#define SCD(a) scanf("%d",&a)
#define SCD2(a,b) scanf("%d %d",&a,&b)
#define SCLL(a) scanf("%lld",&a)
#define SCLL2(a,b) scanf("%lld %lld",&a,&b)
#define PRD(a) printf("%d\n",a)
#define PRLL(a) printf("%lld\n",a)
///////////////////////////////////////
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vi> vvi;
typedef vector <vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vpii> vvpii;
typedef stringstream ss;
const ll oo = (ll) 10e9 + 7;
const double EPS = 1e-4;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
//ifstream ifs("input.txt");
//ofstream ofs("output.txt");
int main()
{
	afify();
	int n;
	cin >> n;
	vi st(n);
	loop(i, 0, n) {
		int x;
		cin >> st[i];
	}
	sort(all(st));
	cout <<st[n-1]-st[0] << endl;


	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

signed main(){
    int N;
    cin>>N;
    vint x(2);rep(i,2)cin>>x[i];

    vint cnt(3);
    rep(i,N){
        int p;cin>>p;cnt[lower_bound(all(x),p)-x.begin()]++;
    }
    cout<<*min_element(all(cnt))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n, m, ans, a, b, h[100010], hm[100010];
int main()
{
	cin>>n>>m;
	for(int i = 1; i <= n; i++)
	cin>>h[i];
	for(int j = 1; j <= m; j++)	
	{
		cin>>a>>b;
		if(hm[a] < h[b]) hm[a] = h[b];//高度为h[a]的连接的最大高度为b 
		if(hm[b] < h[a]) hm[b] = h[a];
	}
	for(int i = 1; i <= n; i++)
	{
		//cout<<hm[i]<<endl;
		if(hm[i] < h[i] ) ans++;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

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

    vector<lint> a(n), b(n);
    for(lint i=0; i<n; i++)  cin >> a[i] >> b[i];
    reverse(begin(a), end(a));
    reverse(begin(b), end(b));

    lint sum = 0;
    for(lint i=0; i<n; i++) {
        a[i] += sum;
        lint r = a[i] % b[i];
        if(r == 0)  r = b[i];
        sum += b[i] - r;
    }

    cout << sum << endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int counter = 0;

  for (int i = 1; i <= N; i += 2) {
    int subcounter = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) {
        subcounter++;
      }
    }
    if (subcounter == 8) {
      counter++;
    }
    subcounter = 0;
  }
  cout << counter;
  return 0;
}

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

ll lcm(ll a, ll b){
	return a/__gcd(a,b)*b;	
}

int main(){
	ll n,ans=1,t;
	cin>>n;
	for(int i=1; i<=n; i++){
		cin>>t;
		ans=lcm(ans,t);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using P = pair<int, int>;
using LL = long long;

#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN_LL(v) LL v;cin>>v;
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl
const int MOD = 1000000007;
const int INF = 1000000000;

int main() {
  IN(N); IN(Q);
  string S;
  cin >> S;

  vector<int> count(N+1);
  count[0] = 0;
  // i文字目がCでi-1文字目がAなら1つ増えるカウンタ
  // i文字目までのカウント
  // 最短でcount[2] = 1
  FOR(i, 1, N) {
    count[i+1] = count[i];
    if (S[i] == 'C' && S[i-1] == 'A')
      ++count[i+1];
  }
  REP(i, Q) {
    IN(l); IN(r);
    OUT(count[r] - count[l]);
  }

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

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; }
typedef pair <ll,ll> P;

int main()
{
    string s;
    cin >> s;
    ll posA = s.find('A');
    ll posZ = s.rfind('Z');
    cout << posZ - posA+1 << endl;
    return 0;
}


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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define REPA( i, n )	FOR( i, 1, n )
#define FORR( i, m, n ) for( int (i) = (m); (i) >= 0; (i)-- )
#define ALL( a )        (a).begin(), (a).end()             
#define MP( a, b )		make_pair( (a), (b) )
#define fi				first
#define se				second

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main() {
	int h, w, s, t; cin >> h >> w >> s >> t;

	if( h % 2 == 0 || w % 2 == 0 ) {
		cout << "Yes" << endl;
	} else {
		if( ( s + t ) % 2 == 0 ) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int H,W,N;
    cin>>H>>W>>N;
    if(H<W) swap(H,W);
    cout<<(N+H-1)/H<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int a[107][100007];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    // multiset<long long int>s;
    long long int n,W;
    cin>>n>>W;
    long long int v[n+1],w[n+1];
    
    for(long long int i=1;i<=n;i++)
    {
        long long int x;
        cin>>w[i]>>v[i];
        // s.insert(x);
    }
    
    long long int k=1; 
    for(long long int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(w[i]>w[j])
            {
                long long int temp=w[i];
                w[i]=w[j];
                w[j]=temp;
                temp=v[i];
                v[i]=v[j];
                v[j]=temp;
            }
        }
    }
    
    // for(auto it =s.begin();it!=s.end();it++)
    // {
    //     w[k]= (*it);
    //     k++;
    // }
    // for(long long int i=0;i<=W;i++ )
    // a[0][i]=0;
    
    // for(long long int i=0;i<=n;i++ )
    // a[i][0]=0;
    
    for(long long int i=0;i<=n;i++)
    {
        for(long long int j=0;j<=W;j++)
        {
            if (i==0 || j==0)
            {
                a[i][j]=0;
                continue;
            }
            
            if((w[i])>j)
            a[i][j]=a[i-1][j];
            
            else
            {
                a[i][j]=max(a[i-1][j-w[i]] + v[i],a[i-1][j]);
            }
            
            
        }
    }
    cout<<(a[n][W]);
    
    
    

}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
int H, W, Q, xa, ya, xb, yb, s[1009][1009][3]; char c[1009][1009], d[] = "JOI";
int main() {
	scanf("%d%d%d", &H, &W, &Q);
	for(int i = 0; i < H; i++) scanf("%s", c[i]);
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			for(int k = 0; k < 3; k++) {
				s[i + 1][j + 1][k] = s[i + 1][j][k] + s[i][j + 1][k] - s[i][j][k] + (d[k] == c[i][j]);
			}
		}
	}
	while(Q--) {
		scanf("%d%d%d%d", &xa, &ya, &xb, &yb); xa--, ya--;
		for(int i = 0; i < 3; i++) {
			if(i) printf(" ");
			printf("%d", s[xb][yb][i] + s[xa][ya][i] - s[xb][ya][i]- s[xa][yb][i]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 15888
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
const int MAX=2e5+10;
const int MAX2=2e5+4;
const int MAAX=2e18;
const int MOD=1e9+7;
vector<int>adj[MAX];
int m,n;
int ans=0;
int dp[MAX];
int fun(int idx)
{
    int &ret=dp[idx];
    if(ret!=-1)
    {
        return ret;
    }
    ret=0;
    for(int i=0;i<adj[idx].size();i++)
    {
      ret=max(ret,1+fun(adj[idx][i]));
    }
    return ret;
}
in main()
{
    memset(dp,-1,sizeof dp);
cin>>n>>m;
int u,v;
for(int i=0;i<m;i++)
{
    cin>>u>>v;
    adj[u].pb(v);
}
int ans=1;
for(int i=1;i<=n;i++)
{
    if(dp[i]==-1)
    {
        ans=max(ans,fun(i));
    }
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11008
import sys
sys.setrecursionlimit(1000000)

a,b,c=map(int,input().split())
ans=0
def dfs(x,y,z):
    global ans
    if x==y==z:
        print(ans)
    elif x==y and x<z:
        ans+=1
        dfs(x+1,y+1,z)
    elif y==z and y<x:
        ans+=1
        dfs(x,y+1,z+1)
    elif x==z and x<y:
        ans+=1
        dfs(x+1,y,z+1)
    elif x<y<=z or x<z<=y:
        ans+=1
        dfs(x+2,y,z)
    elif y<x<=z or y<z<=x:
        ans+=1
        dfs(x,y+2,z)
    elif z<x<=y or z<y<=x:
        ans+=1
        dfs(x,y,z+2)
dfs(a,b,c)

Measured memory_bytes: 9124
s = input()
q = int(input())
r = False#ひっくり返されたか
f = ''#in front of#逆転しているので最後に戻しましょう
b = '' #behind
for i in range(q):
  t=list(input().split())
  if len(t) == 1:#一つしか入力されていない
    r = not(r)
  else:
    if (t[1] == '1' and r == False):
      f += t[2]
    elif (t[1] == '2' and r == True):
      f += t[2]
    else:
      b += t[2]
s = f[::-1] + s + b
if r:
  print(s[::-1])
else:
  print(s)

Measured memory_bytes: 4596
N,Q = map(int,input().split())
G = [[]for i in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
C = [0]*(N)
for i in range(Q):
    p,x = map(int,input().split())
    C[p-1] += x
from collections import deque
d=deque()
d.append(0)
t = [False]*(N)
t[0] = True
while d:
    a = d.popleft()
    for b in G[a]:
        if not t[b]:
            t[b] = True
            d.append(b)
            C[b] += C[a]
print(*C)

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

int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll r=0;
	for(ll i=0;i<n;i++) {
	    if(s[i]=='R')
	    r++;
	}
	ll moves=0;
	if(r==0 || r==n)
	{moves=0;}
	else {
	    for(ll i=0;i<r;i++) {
	        if(s[i]=='W')
	        moves++;
	    }
	}
	cout<<moves<<endl;
	return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N,R;
ll i, j, k;
int main(){
    scanf("%lld%lld", &N, &R);
    if(N<10){
        printf("%lld", R+100 * (10 - N) );
    }else{
        printf("%lld", R);
    }
    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
ans = 0
import itertools

ax = list(itertools.combinations([a,b,c,d,e],2))

for i in range(10):

    if abs(ax[i][0]-ax[i][1]) > k:

        ans += 1

if ans >= 1:

    print(':(')

else:

    print('Yay!')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a==1&&b==2)
        cout<<"3"<<endl;
    else if(a==1&&b==3)
        cout<<"2"<<endl;
        else if(a==2&&b==3)
        cout<<"1"<<endl;
       else  if(a==3&&b==2)
        cout<<"1"<<endl;
        else if(a==3&&b==1)
        cout<<"2"<<endl;
       else  if(a==2&&b==1)
        cout<<"3"<<endl;
        return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

X, A = get_ints

if X < A
  puts '0'
else
  puts '10'
end


Measured memory_bytes: 14448
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
int max(int a , int  b){
  if(a > b) return a;
  else return b;

}
int min(int a , int b){
  if(a < b) return a;
  else return b;
}
bool cmp(pair < int , string >   a , pair < int , string >   b){
  if(a.first < b.first ) return true;
  else return false;
}
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int32_t main(){  
  fast;
  int n,k;
  cin >> n >> k;
  vector < int > h(n);
  for(int i = 0 ; i < n ; i++) cin >> h[i];
  vector < int > dp(n,LLONG_MAX);
  dp[0] = 0;
  for(int i = 1; i < n; i++ ){
    for(int kk =  1 ; kk <=k ;kk++){
      if(i-kk >=0) dp[i]=min(dp[i] , dp[i-kk]+abs(h[i]-h[i-kk]));
    } 
  }
  //for(int i = 0 ; i < n ; i++) cout << dp[i] << "**\n";
  cout << dp[n-1] << "\n";
  return 0;
} 

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

int main(){
  long double a,b,x;
  cin >> a >> b >>x;
  long double height;
  long double ans;
  if (a*a*b/2.0>=x){
    height=2.0*x/b/a;
    ans=atan(b/height)/M_PI*180;
  }else {
    height=(a*a*b-x)*2.0/a/a;
    ans=atan(height/a)/M_PI*180;
  }
  cout << std::fixed << std::setprecision(15) << ans;
}


Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N,A,B = LI()
    ans = 0
    n_ab = int(N/(A+B))
    amari = N-n_ab*(A+B)
    ans = n_ab*A+A if amari >= A else n_ab*A+amari
    print(ans)

main()



Measured memory_bytes: 20508
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
from collections import deque


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
	
def count_str(m):
	tmp={}
	for i in range(10):
		if i in tmp:
			tmp[i]=1
		else:
			tmp[i]+=1
	return tmp

def is_prime(n):
	if n==1: return True

	for i in range(2,int(math.sqrt(n))+1):
		if n%i==0:
			return False
	return True

a,b,c,k=input2()

if k<a:
	print(k)
elif k>=a and k<=a+b:
	print(a)
else:
	print(2*a+b-k)



Measured memory_bytes: 27004
from operator import itemgetter
n = int(input())
restaurants = []
for i in range(n):
    a,b = input().split()
    restaurants.append([i,a,int(b)]) #{市名：得点}

for restaurant in sorted(sorted(restaurants,key = itemgetter(2),reverse=True),key = itemgetter(1)):
    print(restaurant[0]+1)
        

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for (i=0; i<=VMAX; i++) C[i] = 0;

  /* C[i] に i の出現数を記録する */
  for (j=1; j<=n; j++){
    scanf("%d",&A[j]);
    C[A[j]]++;
  }
  /* C[i] に i 以下の数の出現数を記録する*/
  for (i=1; i<=VMAX; i++) C[i] = C[i] + C[i-1];

  for (j=n; j>=1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  for(j=1; j<n; j++) printf("%d ",B[j]);
  printf("%d\n",B[j]);
  return 0;
}


Measured memory_bytes: 9592