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

public class Main {
    static Scanner scanner;

    public static void main(String[] args) {
        scanner = new Scanner(System.in);
        int k = nextInt();
        String s = scanner.next();
        if (s.length() > k) {
            System.out.println(s.substring(0,k) + "...");
        } else {
            System.out.println(s);
        }
    }

    public static boolean rikai(List<Integer> rikaido,int x) {

        System.out.println("c" + rikaido);

        boolean ret = true;
        for (Integer r :rikaido){
            if (r < x) {
                ret = false;
                break;
            }
        }
        return ret;
    }

    public static int nextInt() {
        return Integer.parseInt(scanner.next());
    }

    public static long nextLong() {
        return Long.parseLong(scanner.next());
    }

    public static double nextDouble() {
        return Double.parseDouble(scanner.next());
    }

    public static short nextShort() {
        return Short.parseShort(scanner.next());
    }

    public static float nextFloat() {
        return Float.parseFloat(scanner.next());
    }

    public static void printYes() {
        System.out.println("Yes");
    }

    public static void printYES() {
        System.out.println("YES");
    }

    public static void printNo() {
        System.out.println("No");
    }

    public static void printNO() {
        System.out.println("NO");
    }

    public static void nextLine() {
        scanner.nextLine();
    }
}

Measured memory_bytes: 26972
n,m,x=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(n)]
a=[]
ans=[]
for i in range(2**n):
    b=bin(i)[2:].zfill(n)
    a.append(b)
for bit in a:
    Skills=[]
    for i in range(1,1+m):
        skill=0
        for j in range(n):
            if bit[j]=="1":
               skill+=A[j][i]
        Skills.append(skill)
    cost=0
    if min(Skills)>=x:
        for j in range(n):
            if bit[j]=="1":
                cost+=A[j][0]
        ans.append(cost)
if len(ans)==0:
    ans.append(-1)
print(min(ans))

Measured memory_bytes: 9380
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void NGE(ll arr[], ll n,ll *arr1)
{
    stack<ll> s;

//	int arr1[n];


    // iterating from n-1 to 0
    for (ll i = 0; i < n; i++)
    {
        ll yav=0;


        /*We will pop till we get the
        greater element on top or stack gets empty*/
        while (!s.empty() && s.top() >= arr[i]) {
            s.pop();


        }

        /*if stack gots empty means there
        is no element on right which is greater
        than the current element.
        if not empty then the next greater
        element is on top of stack*/
        if (s.empty()) {
            arr1[i] = -1;

        }
        else {
            arr1[i] = s.top();
        }
        s.push(arr[i]);
    }
}
int main(){

   // ios_base::sync_with_stdio(false);
  ll a[5];
  for(int i=0;i<5;i++)
      cin>>a[i];
  ll k;
  cin>>k;
  ll flag=0,diff;
  for(int i=0;i<5;i++){
      for(int j=i;j<5;j++){
          diff=a[j]-a[i];
          if(diff>k){
              flag=1;
              goto lbl;
          }
      }
  }
  lbl:
    if(flag==1)
        cout<<":("<<endl;
    else cout<<"Yay!"<<endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
//#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n, i;
	cin >> n;
	vector<string>s(n);

	for (i = 0; i < n; i++)
	{
		cin >> s.at(i);
	}
	sort(s.begin(), s.end());
	int cnt = 1;
	for (i = 0; i < n - 1; i++)
	{
		if (s.at(i) != s.at(i + 1))
			cnt++;
	}
	cout << cnt << endl;
}
	
	

	
	
/**/
/*#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.141592653589793

int main(void) {
	return 0;
}
*/

Measured memory_bytes: 9560
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	for(int i=0;i<2;i++){
      for(int j=2;j>i;j--){
	  if(a[j]<a[j-1]){
	      int tmp=a[j];
	      a[j]=a[j-1];
	      a[j-1]=tmp;
	   }
       }
   }
	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
	return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[105];
ll B[105];

int main()
{
    ll N;
    cin >> N;
    REP(i, N - 1)
    {
        cin >> B[i];
    }
    memset(A, 0, sizeof(A));
    A[0] = B[0];
    A[N - 1] = B[N - 2];
    FOR(i, N - 1, 1)
    {
        A[i] = std::min(B[i - 1], B[i]);
    }
    ll sum = 0;
    REP(i, N)
    {
        sum += A[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
const val MOD: Long = (1e9+7).toLong()

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map{it.toInt()}
    val x = Array(n, {
        val (a, b) = readLine()!!.split(" ").map{it.toLong()}
        Pair(a, b)
    })
    x.sortBy{ it.first }

    var cnt: Long = 0
    var sum: Long = 0
    for (i in 0 until n) {
        if (cnt + x[i].second < m) {
            cnt += x[i].second
            sum += x[i].first * x[i].second
        } else {
            sum += x[i].first * (m - cnt)
            break
        }
    }
    println(sum)
}


Measured memory_bytes: 83464
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
 
 bool p(string s,ll i,ll j){
     ll k;
     while(i<=j){
         if(s[i]==s[j]){
             i++;
             j--;
         }else{
             return false;
         }
     }
     return true;
 }
int main(){
    string s;
    cin>>s;
    ll n=s.length();
    bool fi,se,th;
    fi=p(s,0,n-1);
    if(fi){
        se=p(s,0,(n-1)/2-1);
        if(se){

            th=p(s,(n+3)/2-1,n-1);
            if(th){
                if(n%2!=0){
                    cout<<"Yes"<<endl;
                }else{
                    cout<<"No"<<endl;
                }
            }
        }else{
            cout<<"No"<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,h,c,x,y,z=1;
  cin>>w>>h>>c;
  x=w;y=h;
  while(1){
    int co=0;
    for(int i=2;i<=w && i<=h;i++){
      if(w%i==0 && h%i==0){
	z*=i;
	w/=i;
	h/=i;
	co=1;
	break;
	
      }
    }
    if(co==0) break;
  }
  cout<<x/z*y/z*c<<endl;
  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define INF 1e9
typedef pair<int,int> edge;

vector<vector<edge>> g;
vector<int> p;

bool solve(int v){
    if(abs(p[v]) > INF) return false;
    for(edge e : g[v]){
        int to = e.first;
        int d = e.second;
        if(p[to] == INF){
            p[to] = p[v] + d;
            if(!solve(to)) return false;
        }else if(p[v] + d != p[to]){
            return false;
        }
    }
    return true;
}

int main(void){
    int n,m;
    cin>>n>>m;
    g.resize(n);
    p.resize(n,INF);
    rep(_,m){
        int l,r,d;
        cin>>l>>r>>d;
        l--,r--;
        g[l].push_back({r,d});
        g[r].push_back({l,-d});
    }

    rep(i,n){
        if(p[i] != INF)continue;
        p[i] = 0;
        if(!solve(i)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 12032
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

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

    for(int i=0;i<3;i++){
        if(N[i]=='1'){
            N[i]='9';
        }
        else if(N[i]=='9'){
            N[i]='1';
        }

    }

    cout<<N<<endl;


}


Measured memory_bytes: 256
def dij(n,x,y,i,j):
#    d=min((j-i),(abs(x-i)+1+abs(j-y)),(abs(x-j)+1+abs(i-y)))
    d=min((j-i),(abs(x-i)+1+abs(j-y)))
    return d

n,x,y=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき

c=[0]*(n+1)

for i in range(1,n):
    for j in range(i+1,n+1):
        d=dij(n,x,y,i,j)
        c[d]=c[d]+1
        
for i in range(1,n):
    print(c[i])

Measured memory_bytes: 3444
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<climits>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<string.h>
#include<algorithm>
#include<unordered_map>
#pragma GCC optimize "trapv"
using namespace std;

#define ld long double
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(int i=a;i<b;i++)
#define pp pair<int,pair<int,int>>
#define ppp pair<pair<int,int>,pair<int,int>>

const ll M=1e9,N=2e5+2;

struct hash_pair{
	template <class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const{
		auto hash1 = hash<T1>{}(p.first);
		auto hash2 = hash<T2>{}(p.second);
		return hash1 ^ hash2;
	}
};

void sieve(){
	bool prime[N+1];
	memset(prime,true,sizeof(prime));
	for(ll p=2;p*p<=N;p++){
		if(prime[p] == true){
			for(ll i=p*p;i<=N;i+=p)
				prime[i] = false;
		}
	}
}

ll power(ll x,ll y,ll p){
	ll res = 1;
	x = x%p;
	while(y > 0){
		if(y&1)
			res = (res*x)%p;
		y = y>>1;
		x = (x*x)%p;
	}
	return res;
}

int root(int i,int A[]){
	while(A[i] != i){
		A[i] = A[A[i]];
		i = A[i];
	}
	return i;
}

void unite(int a,int b,int A[],int B[]){
	int c = root(a,A);
	int d = root(b,A);
	if(c == d)
		return;
	if(B[c] < B[d]){
		A[c] = d;
		B[d] += B[c];
	}
	else{
		A[d] = c;
		B[c] += B[d];
	}
}

inline ll in()
{
	ll n=0;
	bool check=0;
	register char c=getchar();
	while(c<'0' || c>'9')
	{
		if(c=='-')
			check=1;
		c=getchar();
	}
	while(c>='0' && c<='9')
	{
		n = (n<<1)+(n<<3)+c-'0';
		c=getchar();
	}
	return n-2*n*check;
}

string ip()
{
    string i="";
    int temp=getchar();
    while(temp<'a'||temp>'z')
        temp=getchar();
    while(temp>='a'&&temp<='z')
    {
        i+=(char)temp;
        temp=getchar();
    }
    return i;
}

vector<int> V[N];
int P[N],H[N];
unordered_map<int,bool> U;
vector<pair<int,int>> B;

bool compare(pair<int,int> a,pair<int,int> b){
	return a.first > b.first;
}

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


	ll x,val;
	cin>>x;
	val = 1000*(x/500)+5*((x%500)/5);
	cout<<val<<"\n";

	return 0;
}

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

int main()
{
  int n;
  int a[100];
  
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = n-1; i > 0; i--) cout << a[i] << " ";
  cout << a[0] << endl;
  
  return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>0&&b>0) cout<<"Positive"<<endl;
    else if(a<0&&b<0) {
        if((abs(a-b)+1)%2==0) cout<<"Positive"<<endl;
        else cout<<"Negative"<<endl;
    }
    else cout<<"Zero"<<endl;
}


Measured memory_bytes: 3552
package main

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

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

type rec struct {
	key, value int
}
type recs []rec

func (r recs) Len() int {
	return len(r)
}
func (r recs) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}
func (r recs) Less(i, j int) bool {
	return r[i].key < r[j].key
}

func main() {
	var N int
	fmt.Scan(&N)
	m := make(map[int]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for i := 0; i < N; i++ {
		m[nextInt(sc)]++
	}
	ans := "No"
	if len(m) <= 3 {
		rs := make([]rec, 0)
		for k, v := range m {
			var r rec
			r.key = k
			r.value = v
			rs = append(rs, r)
		}
		sort.Sort(recs(rs))
		if len(rs) == 1 && rs[0].key == 0 {
			ans = "Yes"
		} else if N%3 == 0 {
			if rs[0].key == 0 && rs[0].value == N/3 && rs[1].value == N*2/3 {
				ans = "Yes"
			} else if len(rs) == 3 && rs[0].value == N/3 && rs[1].value == N/3 && rs[2].value == N/3 &&
				rs[0].key^rs[1].key^rs[2].key == 0 {
				ans = "Yes"
			}
		}
	}
	fmt.Println(ans)
}


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

int main() {

    int N;
    cin >> N;

    string S;
    map<string, int> m;
    for (int i = 0; i < N; i++) {
        cin >> S;
        m[S]++;
    }

    int maxv = 0;
    for (const auto& x : m) {
        int v = x.second;
        if (v > maxv) {
            maxv = v;
        }
    }

    // std::mapではデフォルトでキーが昇順になるように要素がソートされる
    // 先頭から順になめるだけで辞書順に取得できる
    for (auto it = m.begin(); it != m.end(); it++) {
        if (it->second == maxv) {
            cout << it->first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 25216
import java.util.Arrays;
import java.util.Scanner;

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

		int n = sc.nextInt();
		sc.nextLine();
		char[] s = sc.nextLine().toCharArray();
		char[] a = new char[n];

		for (int i = 0; i < 4; i++) {
			Arrays.fill(a, 'X');
			if (i % 2 == 1) {
				a[0] = 'S';
			} else {
				a[0] = 'W';
			}

			if ((i >> 1) % 2 == 1) {
				a[1] = 'S';
			} else {
				a[1] = 'W';
			}

			for (int j = 1; j < n - 1; j++) {
				if (s[j] == 'o') {
					if (a[j] == 'S') {
						a[(j + 1) % n] = a[j - 1];
					} else {
						a[(j + 1) % n] = a[j - 1] == 'S' ? 'W' : 'S';
					}
				} else {
					if (a[j] == 'S') {
						a[(j + 1) % n] = a[j - 1] == 'S' ? 'W' : 'S';
					} else {
						a[(j + 1) % n] = a[j - 1];
					}
				}
			}

			boolean valid = true;
			if (s[n - 1] == 'o') {
				if (a[n - 1] == 'S') {
					valid = a[n - 2] == a[0];
				} else {
					valid = a[n - 2] != a[0];
				}
			} else {
				if (a[n - 1] == 'S') {
					valid = a[n - 2] != a[0];
				} else {
					valid = a[n - 2] == a[0];
				}
			}
			if (!valid) continue;

			if (s[0] == 'o') {
				if (a[0] == 'S') {
					valid = a[n - 1] == a[1];
				} else {
					valid = a[n - 1] != a[1];
				}
			} else {
				if (a[0] == 'S') {
					valid = a[n - 1] != a[1];
				} else {
					valid = a[n - 1] == a[1];
				}
			}

			if (valid) {
				System.out.println(a);
				return;
			}
		}

		System.out.println(-1);
	}
}


Measured memory_bytes: 26196
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>

using namespace std;


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

	cin >> n;
	n %= 10;
	if ((n == 2) || (n == 4) || (n == 5) || (n == 7) || (n == 9)) cout << "hon\n";
	else if (n == 3) cout << "bon\n";
	else cout << "pon\n";


	return 0;
}




Measured memory_bytes: 3172
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define int long long
using namespace std;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MAXIN(x) max_element(ALL(x)) - x.begin();
#define MIN(x) *min_element(ALL(x))
#define MININ(x) min_element(ALL(x)) - x.begin();
#define INF 1000000000000
#define MOD 100000070

#define MAXR 100000
#define PI 3.14159265358979323846

using namespace std;

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

    int a = n % 10;
  //  cout << a <<endl ;

    string ans;
    switch (a)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        ans = "hon";
        /* code */
        break;

        case 0:
        case 1:
        case 6:
        case 8:
            ans = "pon";
            break;

    default:
        ans = "bon";
        break;
    }

    cout << ans <<endl ;

    return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int MOD = 1000000007;
const long long INF = LLONG_MAX;

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

ll H, W, K;
ll sx, sy, gx, gy;
vector<ll> c[4][1010101];
ll DX[] = {0, 1, 0, -1};
ll DY[] = {1, 0, -1, 0};

using sstate = tuple<ll, ll, ll, ll>;
struct state {
  ll cost, dir, x, y;
};

int main() {
  cin >> H >> W >> K;
  cin >> sx >> sy >> gx >> gy;
  repe(i, 1, H) {
    string s;
    cin >> s;
    rep(j, 0, 4) {
      c[j][i].push_back(-1);
      for (auto e : s) {
        if (e == '@') {
          c[j][i].push_back(-1);
        } else {
          c[j][i].push_back(INF);
        }
      }
      c[j][i].push_back(-1);
    }
  }
  repe(i, 0, W + 1) {
    rep(j, 0, 4) {
      c[j][0].push_back(-1);
      c[j][H + 1].push_back(-1);
    }
  }

  priority_queue<sstate, vector<sstate>, greater<sstate>> que;
  que.push(sstate{0, 0, sx, sy});
  c[0][sx][sy] = 0;

  while (!que.empty()) {
    auto cst = que.top();
    que.pop();

    state cs = state{get<0>(cst), get<1>(cst), get<2>(cst), get<3>(cst)};

    ll dx = DX[cs.dir];
    ll dy = DY[cs.dir];
    ll nx = cs.x + dx;
    ll ny = cs.y + dy;
    ll nc = cs.cost + 1;
    if (nc < c[cs.dir][nx][ny]) {
      c[cs.dir][nx][ny] = nc;
      que.push(sstate{nc, cs.dir, nx, ny});
    }

    rep(i, 0, 4) {
      if (i == cs.dir) continue;

      ll nnc = (cs.cost + K - 1) / K * K;
      if (nnc < c[i][cs.x][cs.y]) {
        c[i][cs.x][cs.y] = nnc;
        que.push(sstate{nnc, i, cs.x, cs.y});
      }
    }
  }

  ll ans = INF;
  rep(i, 0, 4) { chmin(ans, c[i][gx][gy]); }

  /*
    repe(i, 0, H + 1) {
      repe(j, 0, W + 1) {
        ll m = INF;
        rep(k, 0, 4) { chmin(m, c[k][i][j]); }
        cout << m << " ";
      }
      cout << endl;
    }
    */
  if (ans == INF) {
    cout << -1;
    return 0;
  }

  cout << (ans + K - 1) / K;
}


Measured memory_bytes: 201168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
int main(){
  ll n;
  cin>>n;
  string ans="Yes";
  vll t(n+1),x(n+1),y(n+1);
  for (ll i=1;i<n+1;i++) cin>>t[i]>>x[i]>>y[i];
  for (ll i=0;i<n;i++) {
    ll d=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]),T=abs(t[i+1]-t[i]);
    if (d>T || (T-d)%2==1) {
      ans="No";
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
 
using namespace std;
 
signed main(){
    
    int n,K;
    cin >> n >> K;
 
    vector<pair<int,int>> p;
 
    REP(i,n){
        int a,b;
        cin >> a >> b;
        p.pb(MP(a,b));
    }
    //SORT(p);
    ll ans = 4000000000000000010;

    
 
    REP(i,n) REP(j,n) REP(k,n) REP(l,n){
        int x_min = min({p[i].fi,p[j].fi,p[k].fi,p[l].fi});
        int x_max = max({p[i].fi,p[j].fi,p[k].fi,p[l].fi});
        int y_min = min({p[i].se,p[j].se,p[k].se,p[l].se});
        int y_max = max({p[i].se,p[j].se,p[k].se,p[l].se});
        int cnt = 0;
        
        REP(c,n){
            int x = p[c].fi;
            int y = p[c].se;
            if(x_min <= x && x <= x_max && y_min <= y && y <= y_max){
                cnt++;
            }
        }
        if(cnt >= K) ans = min(ans,(x_max - x_min)*(y_max - y_min));
        
    }

    cout << ans << endl;  
 
    return 0;
}
//g++ -std=c++14 code1.cpp

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

int main() {
  ll n;
  string s="",alf = "abcdefghijklmnopqrstuvwxyz";
  cin>>n;
  while(1){
    n--;
    s=alf[n%26] + s;
    if (!(n / 26)) break;
    n/=26;
  }
  cout <<s<<endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
int main()
{
    int n, i, j, k, l, count;

    while(scanf("%d", &n)!=EOF)
    {
        count = 0;
        for(i=0; i<=9; i++)
        {
            for(j=0; j<=9; j++)
            {
                for(k=0; k<=9; k++)
                {
                    for(l=0; l<=9; l++)
                    {
                        if(i+j+k+l==n)
                            count++;
                    }
                }
            }
        }
        printf("%d\n", count);
    }
    return 0;
}

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

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

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

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

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


int main(){
  int n, a[12], w[12], p[12];

  scanf("%d", &n);

  for(int i=0;i<n;i++)
    scanf("%d", a+i);

  for(int i=0;i<n;i++)
    scanf("%d", w+i);

  int ans = INF;
  iota(p, p+n, 0);

  do{
    int sum = 0;
    
    for(int i=0;i<n;i++){
      if(a[p[i]] == 0)
        sum += w[p[i]] * (a[p[i]] != a[p[(i+1)%n]]);
      if(a[p[i]] == 1)
        sum += w[p[i]] * (a[p[i]] != a[p[(i+n-1)%n]]);
    }

    ans = min(ans, sum);

  }while(next_permutation(p, p+n));

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




Measured memory_bytes: 3228
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String op = sc.next();
        int b = sc.nextInt();
        if(op.equals("+")){
            System.out.println(a + b);
        
        }else{
            System.out.println(a - b);
        }
        }        
    }



Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;

ll pow(ll x, int n){
    ll ret = 1;
    while(n > 0){
        if (n & 1) ret *= x;
        x *= x;
        n >>= 1;
    }

    return ret;
}

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

    int cnt = 1;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (x % 2 == 0) cnt *= 2;
    }

    cout << pow(3, n) - cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            sum=sum+a[i]*a[j];
        }
    }
    cout<<sum<<"\n";
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
    ll n;cin>>n;
    if(n%2==1)cout<<0<<endl;
    else{
        n/=2;
        ll res = 0;
        ll d = 5;
        while(n>=d){
            res += n/d;
            d*=5;
        }
        cout<<res<<endl;
    }
}


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

int N,K,A,B,cnt,ans,num[5];
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    for(int i=0; i<3; i++){
        cin >> A >> B;
        num[A]++;
        num[B]++;
    }
    for(int i=1; i<=4; i++){
        if(num[i]==0 || num[i]==3){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
}


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

#ifndef ONLINE_JUDGE
#define debarr(a,x,y)cerr<<#a<<":";for(int i=x;i<=y;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define deb(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S, class T>ostream &operator<<(ostream &os, const pair<S, T> &p) {return os << "(" << p.first << "," << p.second << ")";}
template<class T>ostream &operator<<(ostream &os, const vector<T> &p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>ostream &operator<<(ostream &os, const set<T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>ostream &operator<<(ostream &os, const multiset<T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class S, class T>ostream &operator<<(ostream &os, const map<S, T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>void dbs(string str, T t) {cerr << str << ":" << t << "\n";}
template<class T, class...S>void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << ":" << t << ","; dbs(str.substr(idx + 1), s...);}
#else
#define deb(...){}
#define debarr(a,x,y){}
#define debmat(mat,row,col){}
#endif
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define pr(x) {cout << x << "\n"; return;}

#define int              long long
#define ll               long long
#define ld               long double
#define fi               first
#define se               second
#define mp               make_pair
#define pb               push_back
#define sz(x)            (int)x.size()
#define all(x)           x.begin(),x.end()
#define ini(x,y)         memset(x,y,sizeof(x))
#define rep(i,n)         for(int i=0;i<n;i++)
#define re(i,n)          for(int i=1;i<=n;i++)
#define fr(i,a,b)        for(int i=a;i<=b;i++)
#define fb(i,a,b)        for(int i=a;i>=b;i--)
typedef pair<int, int>   pii;
typedef vector<int>      vi;
typedef vector<pii>      vii;
typedef map<int, int>    mii;
typedef set<int>         si;
const int N = 5e3 + 10;
const int mod = 1e9 + 7;

void add(int &a, int b) { a = (a + b) % mod;}
int mul(int a, int b) { return a % mod * b % mod % mod;}
void solve(int tc)
{
	int n; cin >> n;
	int ans = 0, sum = 0;
	rep(i, n)
	{
		int x; cin >> x;
		add(ans, mul(sum, x));
		sum += x;
	}
	cout << ans << endl;




}
signed main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) solve(i);
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(){
	int a,b,c,k,sum=0;
	scanf("%d%d%d%d",&a,&b,&c,&k);
	if(k<=a)return 0*printf("%d\n",k);
	if(k>a)sum+=a,k-=a;
	if(k<=b)return 0*printf("%d\n",sum);
	if(k>b)sum+=0,k-=b;
	return 0*printf("%d\n",sum-k);
	return 0;
}


Measured memory_bytes: 1728
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int max, min;
		long sum = 0;
		
		int n = in.nextInt();
		int[] ary = new int[n];
		for(int i=0; i<n; i++){
			ary[i] = in.nextInt();
		}
		
		//?????§?????¨????°????????¨????
		max = min = ary[0];
		for(int i=1; i<n; i++){
			if(max<ary[i]){
				max = ary[i];
			}
			if(min>ary[i]){
				min = ary[i];
			}
		}
		//????¨????????¨????
		for(int i=0; i<n; i++){
			sum += ary[i];
		}
		System.out.println(min+" "+max+" "+sum);
		in.close();
	}
}

Measured memory_bytes: 31732
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> p(n);
  for(int j=0;j<n;++j){
    cin>>p[j];
  }
  int ans;ans=0;
  for(int i=2;i<n;++i){
    if(((p[i-2]>p[i-1]) and (p[i-1]>p[i])) or ((p[i-2]<p[i-1]) and (p[i-1]<p[i]))){
      ans+=1;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;

int main() {
	int n;
	int x;
	cin >> n >> x;
	vl A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	ll pre = A[0];
	ll ans = 0;
	if (pre > x) {
		ans += pre - x;
		pre = x;
	}
	for (int i = 1; i < n; i++) {
		if (pre + A[i] <= x) {
			pre = A[i];
			continue;
		}
		else {
			if (pre>x) {
				ans += A[i];
				ans += pre - x;
				pre = 0;
			}
			else {
				ans += (A[i] + pre - x);
				pre = x - pre;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import collections
def main():
    n = int(input())
    a=[int(i) for i in input().split()]
    res = []
    mina = min(a)
    maxa = max(a)
    min_ind,max_ind=0,0
    for i in range(n):
        if(a[i]==mina):
            min_ind = i+1
        if(a[i]==maxa):
            max_ind = i+1

    if(mina>=0):
        print(n-1)
        for i in range(n-1):
            print(i+1,i+2)
    elif(maxa<=0):
        print(n-1)
        for i in range(n-1):
            print(n-i,n-i-1)
    else:
        if(abs(mina)<=abs(maxa)):
            print(2*n-1)
            for i in range(n):
                print(max_ind,i+1)
            for i in range(n-1):
                print(i+1,i+2)
        else:
            print(2*n - 1)
            for i in range(n):
                print(min_ind,i+1)
            for i in range(n-1):
                print(n-i,n-i-1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9384
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[110];

bool solve() {
    if (n == 2) {
        return a[0] == a[1] && a[0] == 1;
    }
    sort(a, a+n);
    int maxi = a[n-1];
    int mini = maxi / 2 + (maxi%2);
    if (a[0] != mini) return false;
    if (maxi % 2 == 0 && a[0] == a[1]) return false;
    if (maxi % 2 == 1 && !(a[0] == a[1] && a[1] != a[2])) return false;
    for (int i = mini+1; i <= maxi; i++) {
        int c = 0;
        for (int j = 0; j < n; j++)
            c += (a[j] == i);
        if (c < 2) return false;
    }
    return true;
}

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

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

    input();
    cout << (solve() ? "Possible" : "Impossible") << endl;
}


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

int main(){
  int a=0,b=0,c=0;
  string S;
  cin>>S;
  int n = S.length();
  for(int i=0;i<n;i++){
    int val = S[i] - 'a';
    if(val==0) a++;
    if(val==1) b++;
    if(val==2) c++;
  }
  int ab = abs(a-b);
  int bc = abs(b-c);
  int ca = abs(c-a);
  if(ab<2 && bc<2 && ca<2){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

	string s;
	cin >> s;
	map<char,int> mp;
	if(s[0] != 'A'){cout << "WA" << endl;return 0;}
	rep2(i,s.size()-1){
		mp[s[i]]++;
	}
	if(mp['C'] != 1){cout << "WA" << endl;return 0;}
	int cnt = 0;
	rep(i,s.size()){
		if('A'<=s[i] && s[i]<= 'Z') cnt++;
	}
	if(cnt!=2){cout << "WA" << endl; return 0;}
	cout << "AC" << endl;
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  C - 100 to 105
//
//  Created by Anson Thai on 11/4/20.
//  Copyright © 2020 Anson Thai. All rights reserved.
//

#include <iostream>

int function (int x);

int main(int argc, const char * argv[]) {
    // insert code here...
    //std::cout << "Hello, World!\n";
    
    int x;
    
    std::cin >> x;
    
    int h = x/100;
    int n = x-h*100;
    
    if (n>=5) {
        h += -(n/5);
        n = n%5;
        
    }
    
    if (n>=4) {
        h += -(n/4);
        n = n%4;
        
    }
    
    if (n>=3) {
        h += -(n/3);
        n = n%3;
        
    }
    
    if (n>=2) {
        h += -(n/2);
        n = n%2;
        
    }
    
    if (n>=1) {
        h += -(n);
        n = n%1;
        
    }
    
    if (h>=0) {
        std::cout << 1 << std::endl;
    } else {
        std::cout << 0 << std::endl;
    }
    
   
    
    
    
    return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

bool solve(vector<ll> v, ll k, ll a, ll b) {
    ll rem = 0;
    ll n = v.size();
    rep(i, n) {
        ll rem_num = v[i] - k * b;
        if (rem_num > 0) {
            rem += (rem_num + (a - b - 1)) / (a - b);
        }
    }
    return rem <= k;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    rep(i, n) { cin >> v[i]; }
    ll left = 0, right = mod;
    while (right - left > 1) {
        ll next = (right + left) / 2;
        if (solve(v, next, a, b)) {
            right = next;
        } else {
            left = next;
        }
    }
    cout << right << endl;
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

int to[100001];

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        to[a[i]] = i+1;
    }
    sort(a.begin(), a.end());
    rep(i, a.size()) {
        int ans = to[a[i]];
        if (i == a.size() - 1) {
            cout << ans << endl;
        }
        else {
            cout << ans << ' ';
        }
    }
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int64_t A, B, m, c, mod;
  cin >> A >> B;

  c = m = max(A, B);
  mod = min(A, B);
  while (mod != 0)
  {
    c = m;
    m = mod;
    mod = c % m;
  }
  cout << ((A * B) / m) << endl;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll c[100010],n,k;
vector<ll>a[100010];
void dep(ll now){
	ll co=k-1;
	if(now!=0){
		co--;
	}
	for(ll i=0;i<a[now].size();i++){
		ll nex=a[now][i];
		if(c[nex]!=-1){
			continue;
		}
		c[nex]=co;
		co--;
		if(nex==3){
		//	cout << c[3]<<now<<endl;
		}
		dep(nex);
	}
}
int main() {
	cin>>n>>k;
	for(ll i=0;i<100010;i++){
		c[i]=-1;
	}
	for(ll i=0;i<n-1;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for(ll i=0;i<a[2].size();i++){
	//	cout << a[2][i]<<endl;
	}
	c[0]=k;
	dep(0);
	ll ans=1;
	for(ll i=0;i<n;i++){
		ans*=c[i];
//		cout << c[i]<<endl;
		ans%=inf;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 9984
///////////////////////////////////
//            ___				 //
//      _..--"\  `|`""--.._		 //
//   .-'       \  |        `'-.  //
//  /           \_|___...----'`\ //
// |__,,..--""``(_)--..__      | //
// '\     _.--'`.I._     ''--..' //
//   `''"`,#JGS/_|_\###,---'`    //
//     ,#'  _.:`___`:-._ '#,     //
//    #'  ,~'-;(oIo);-'~, '#     //
//    #   `~-(  |    )=~`  #     //
//    #       | |_  |      #     //
//    #       ; ._. ;      #     //
//    #  _..-;|\ - /|;-._  #     //
//    #-'   /_ \\_// _\  '-#     //
//  /`#    ; /__\-'__\;    #`\   //
// ;  #\.--|  |O  O   |'-./#  ;  //
// |__#/   \ _;O__O___/   \#__|  //
//  | #\    [I_[_]__I]    /# |   //
//  \_(#   /  |O  O   \   #)_/   //
//        /   |        \         //
//       /    |         \        //
//      /    /\          \       //
//     /     | `\         ;      //
//    ;      \   '.       |      //
//     \-._.__\     \_..-'/      //
//      '.\  \-.._.-/  /'`       //
//         \_.\    /._/          //
//          \_.;  ;._/           //
//        .-'-./  \.-'-.         //
//       (___.'    '.___)        //
///////////////////////////////////
#include <bits/stdc++.h>
using namespace std;

#define all(x) begin(x), end(x)
#define cina(s, n, a) for(int quer = s; quer < n; quer++) cin >> a[quer]
#define mod(a, b) (abs(b) + (a % abs(b))) % abs(b)
#define setp(x) fixed << setprecision(x)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
ll MOD = 1e9 + 7;
void mul(ll &x, ll y){
	x *= y;
	if(x >= MOD) x %= MOD;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= MOD) x -= MOD;
	if(x < 0) x += MOD;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
/////////////////////////////////////////////////////////////////////////////////////
void solve(){
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << ' ' << x << ' ' << y;
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
		//cout << "Case #" << i << ": ";
        solve();
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  ll a, b, n, ans = 0;
  cin >> a >> b >> n;
  if (b - 1 <= n) {
    ans = (a * (b - 1)) / b;
  } else {
    ans = (a * n) / b;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}
char al[3] = {'R','B','G'};
int main(){

    int n;
    string s;
    cin>>n;
    cin>>s;


    vector<int> v[3];
    rep(i,n){
        if(s[i]=='R'){
            v[0].push_back(i);
        }
        if(s[i]=='B'){
            v[1].push_back(i);
        }
        if(s[i]=='G'){
            v[2].push_back(i);
        }
    }
    rep(i,3){
        sort(v[i].begin(),v[i].end());
    }


    ll ans = 0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){

            int t=j-i;
            int ki = 0;
            if(s[i]!=s[j]){
                if((s[i]=='R'||s[j]=='R')&&(s[i]=='B'||s[j]=='B')){
                   ki=2;

                }else if((s[i]=='R'||s[j]=='R')&&(s[i]=='G'||s[j]=='G')){
                  ki=1;
                }
                else if((s[i]=='B'||s[j]=='B')&&(s[i]=='G'||s[j]=='G')){
                   ki=0;
                }

                auto tt= upper_bound(v[ki].begin(),v[ki].end(),j);
                ans+=int(v[ki].end()-tt);
                
                if(binary_search(v[ki].begin(),v[ki].end(),j+t)==true){
                    ans--;
                }
                
            }
        }
    }

    cout<<ans<<endl;




return 0;
}


Measured memory_bytes: 3204
N,M=map(int,input().split())
road=[[] for _ in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)
ischecked=[0]*(N)
ans=0
for i in range(N):
    if ischecked[i]==1:
        continue
    ischecked[i]=1
    q=[i]
    while q:
        now=q.pop()
        nex=road[now]
        for j in nex:
            if ischecked[j]!=0:
                continue
            q.append(j)
            ischecked[j]=1
    ans+=1
print(ans-1)

Measured memory_bytes: 26344
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


string x;

bool input(){
  cin >>x;
  return x != "0";
}

void solve(){
  int res = 0;
  rep(i, x.size()){
    res += x[i] - '0';
  }
  cout <<res <<endl;
}

int main() {
  while (input()) solve();
}



Measured memory_bytes: 3164
#include<stdio.h>

int main(){
int s;
scanf("%d",&s);
int former,latter;
former=s/100;
latter=s-former*100;
if(latter<=12&&former<=12&&latter>0&&former>0)
printf("AMBIGUOUS");
else if(latter<=12&&latter>0)
printf("YYMM");
else if(former<=12&&former>0)
printf("MMYY");
else
printf("NA");
return 0;
}

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

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int r, c;
    cin >> r >> c;
    vector<string> grid(r);
    for(int i = 0; i < r; ++i) {
        cin >> grid[i];
    }
    const int mod = 1e9+7;
    vector<vector<int>> memo(r, vector<int>(c,0));
    memo[r-1][c-1] = 1;
    for(int i = r-1; i >= 0; --i) {
        for(int j = c-1; j >= 0; --j) {
            if(i == r-1 && j == c-1) continue;
            if(grid[i][j] == '#') continue;
            if(i+1 < r && grid[i+1][j] == '.') memo[i][j] += memo[i+1][j];
            if(j+1 < c && grid[i][j+1] == '.') memo[i][j] += memo[i][j+1];
            memo[i][j] %= mod;
        }
    }
    cout << memo[0][0] << '\n';
    return 0;
}


























Measured memory_bytes: 9216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
 
namespace a
{
    class Program
    {
        static void Main()
        {
			string line;
			while((line=Console.ReadLine())!=null){
				var ab = line.Split().Select(double.Parse).ToArray();
				double a = ab[0];
				double b = ab[1];
				
				if (a<35.50&&b<71.00)
				Console.WriteLine("AAA");
				else if (a<37.50&&b<77.00)
				Console.WriteLine("AA");
				else if (a<40.00&&b<83.00)
				Console.WriteLine("A");
				else if (a<43.00&&b<89.00)
				Console.WriteLine("B");
				else if (a<50.00&&b<105.00)
				Console.WriteLine("C");
				else if (a<55.00&&b<116.00)
				Console.WriteLine("D");
				else if (a<70.00&&b<148.00)
				Console.WriteLine("E");
				else
				Console.WriteLine("NA");
			}
        }
    }		
}

Measured memory_bytes: 9676
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<iomanip>
#include<tuple>
#include<bitset>


using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define printfloat(x) cout << fixed << setprecision(7) << (x) << endl;
#define printbit(x) cout << bitset<15>(x) << endl;
using ll = long long int;



long double pi = 3.14159265359;

int b[100];
int n;
int ans;

int main(){
    cin >> n;
    rep(i,n-1) cin >> b[i] ;
    ans += b[0] + b[n-2];
    rep(i,n-2){
        ans += min(b[i],b[i+1]);
    }
    cout << ans << endl;


return 0;
}

Measured memory_bytes: 3648