akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(void){
    int n;
    string s,t1="",t2="";
    cin>>n>>s;
    if(n%2==1)cout<<"No"<<endl;
    else{
        for(int i=0;i<n/2;i++)t1+=s[i];
        for(int i=n/2;i<n;i++)t2+=s[i];
        if(s==t1+t1)cout<<"Yes"<<endl;
        else{
            if(s==t2+t2)cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }
    return 0;
}


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

from collections import Counter, defaultdict
MOD = 10**9 + 7

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
    
allcount = defaultdict(int)

for n in range(1,N+1):
    a = prime_factorize(n)
    c = Counter(a)
    for k,v in c.items():
        allcount[k] += v

ans = 1
for v in allcount.values():
    ans *= (v+1)
    ans %= MOD

print(ans)

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

using namespace std;

typedef long long ll;

int max(int a, int b) { return (a > b) ? a : b; }

const int MAXN = 2000 * 1000 + 1;


const int INF = 1e9;

bitset<MAXN> can = 0;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    string s1, s2, s3;cin >> n >> s1 >> s2 >> s3;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (s1[i] != s2[i] && s1[i] != s3[i] && s2[i] != s3[i])
        {
            ans += 2;
        } else {
            if (s1[i] == s2[i] && s2[i] == s3[i]) {
                ans += 0;
            } else {
                ans += 1;
            }
        }
    }
    cout << ans;
    return 0;
}

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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    
    vector<vector<bool> > Connection(N+1, vector<bool>(N+1, false));
    for(int m=0; m<M; m++) {
        int a, b;
        cin >> a >> b;
        Connection[a][b]=true;
        Connection[b][a]=true;
    }
    
    vector<int> per_vec(N-1);
    for(int n=0; n<N-1; n++) {
        per_vec[n] = n+2;
    }
    
    int counter=0;
    do {
        bool flag=true;
        if(!Connection[1][per_vec[0]]) continue;
        for(int n=0; n<N-2; n++) {
            if(!Connection[per_vec[n]][per_vec[n+1]]) {
                flag = false;
                break;
            }
        }
        
        if(flag) {
            counter++;
        }
    } while(next_permutation(per_vec.begin(), per_vec.end()));
    
    cout << counter << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;

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


int main(){
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  vector<int> l(q);
  vector<int> r(q);
  for(int i = 0; i < q; ++i){
    int a, b;
    cin >> a >> b;
    a--; b--;
    l[i] = a;
    r[i] = b;
  }

  vector<int> sum(n + 1, 0);

  for(int i = 1; i < n; ++i){
    if(s[i] == 'C' && s[i - 1] == 'A'){
      sum[i] = sum[i - 1] + 1;
    } else {
      sum[i] = sum[i - 1];
    }
  }

  vector<int> ans (q);
  for(int i = 0; i < q; ++i){
    ans[i] = sum[r[i]] - sum[l[i]];
  }


  rep(i, q){
    cout << ans[i] << endl;
  }


}


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

int main()
{
	int N;
	cin >> N;
	cout << N * (N + 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int N;
	double k;
	
	scanf("%d",&N);
	
	if(N%2==0){
		k=N/2;
		printf("%f\n",k/N);
	}else {
		k=(N-1)/2+1;
		printf("%f\n",k/N);
	}
	
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=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 input(...) __VA_ARGS__; in(__VA_ARGS__)

#if __has_include("debugger.cpp")
  #include "debugger.cpp"
#else
void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) > 0) cout << " ";
  print(std::forward<Tail>(tail)...);
}
# endif

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

ll toi(char x) {
  return x - '0';
}

vector<ll> d;
string s;
ll MOD = 1000000000 + 7;
vector<vector<ll>> table;

ll dp(ll i, ll v);
#define DP table[i][v]
ll dfs(ll i, ll v) {
  if (DP != -1) return DP;
  else return DP = dp(i, v);
}
ll dp(ll i, ll v) {
  if (i == s.size()) return v == 5;
  if (s[i] == '?') {
    ll ans = 0;
    REP(j, 10) {
      (ans += dfs(i + 1, (j * d[i] % 13 + v) % 13)) %= MOD;
    }
    return ans;
  } else {
    return dfs(i + 1, (toi(s[i]) * d[i] % 13 + v) % 13);
  }
}

int main() {
  cin >> s;
  s = string(s.rbegin(), s.rend());
  d = vector<ll>(s.size());
  d[0] = 1;
  REP(i, s.size() - 1) {
    d[i + 1] = (d[i] * 10) % 13;
  }
  table = vector<vector<ll>>(s.size() + 1, vector<ll>(13, -1));

  print(dfs(0, 0));
}


Measured memory_bytes: 26668
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String word = in.next();
        int n = word.length();
        if (word.charAt(n-1) != 's')
            System.out.println(word + "s");
        else if (word.charAt(n-1) == 's')
            System.out.println(word + "es");
    }
}


Measured memory_bytes: 38540
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int N; cin >> N;
	ll L; cin >> L;
	vector<ll> a(N);
	rep(i,N) cin >> a[i];
	vector<ll> len(N-1);
	pair<ll,int> M{0,0};
	rep(i,N-1){
		len[i] = a[i]+a[i+1];
		if(M.first < len[i]){
			M.first = len[i];
			M.second = i;
		}
	}
	if(M.first < L){
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << endl;
	vector<int> ans;
	rep(i,M.second) ans.push_back(i+1);
	for(int i = N-2; i > M.second; i--) ans.push_back(i+1);
	ans.push_back(M.second+1);
	rep(i,N-1){
		cout << ans[i] << endl;
	}
	
	

}



Measured memory_bytes: 2936
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n,m;cin >>n>>m;
    vector<int> a(n);
    int sum=0;
    rep(i,n){
        cin >>a[i];
        sum+=a[i];
    }
    int cnt=0;
    rep(i,n){
        if(sum<=4*m*a[i])cnt++;
    }
    cout <<(cnt>=m?"Yes":"No")<<endl;
}

















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(X) X.begin(), X.end()
//for(int i = 0; i < n; i++)
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    int n; cin >> n;
    if(n >= 30)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main(){
  int k;
  int a;
  while( cin >> k,k ){
    int sum = 0;
    for(int i = 0 ; i < (k*(k - 1))/2 ;i++ ){
      cin >> a;
      sum+=a;
    }
    cout << sum/(k-1) << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9+5;

int main(){
	string s;
	cin >> s;
	int n = (int)s.size();
	vector<int> left, right;
	for(int i=0;i<s.size()-1;i++) {
		if(s[i]=='R' and s[i+1]=='L') {
			left.push_back(i);
			right.push_back(i+1);
		}
	}
	left.push_back(INF);
	right.push_back(INF);
	vector<int> ans(n,0);
	for(int i=0;i<n;i++) {
		if(s[i]=='R') {
			auto nearL = upper_bound(right.begin(),right.end(),i);
			int pos = *nearL;
			int dist = pos - i;
			if(dist%2 == 0) ans[pos]++;
			else ans[pos-1]++;
		} else {
			auto nearR = upper_bound(left.begin(),left.end(),i) - 1;
			int pos = *nearR;
			int dist = i - pos;
			if(dist%2 == 0) ans[pos]++;
			else ans[pos+1]++;
		}
	}
	for(int i=0;i<n;i++) {
		cout << ans[i] << ((i==n-1)?"\n":" ");
	}
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int N; cin >> N;
    vector<bool> equalIndex(N);
    rep(i, 0, N) {
        int in; cin >> in;
        equalIndex[i] = (in == i+1);
    }

    int res = 0;
    rep(i, 1, N) {
        if (equalIndex[i-1] and equalIndex[i]) {
            ++res;
            equalIndex[i-1] = equalIndex[i] = false;
        }
    }
    res += count(equalIndex.begin(), equalIndex.end(), true);

    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,i,j,tmp;
    cin>>n;
    vector<ll> r(n),m(n);
    for(i=0;i<n;i++){
        cin>>r[i];
    }
    m[0]=r[n-1];
   for(i=1;i<n;i++){
        m[i]=(m[i-1]>r[n-i-1]?m[i-1]:r[n-i-1]);
    }
    ll ans=m[n-2]-r[0];
    for(i=1;i<n-1;i++){
        tmp=m[n-i-2]-r[i];
        if(tmp>ans){
            ans=tmp;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5908
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	r := sc.nextInt()
	fmt.Println(3 * r * r)
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int X=2509,N=55,M=105,inf=1e18;
int n,m,s;
int a[M],b[M],c[N],d[N],t[N*X];
vector <pair <int,int> > g[N];
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> n >> m >> s;
    s=min(X-1,s);
    for(int i=0;i<m;i++){
        int u,v;
        cin >> u >> v >> a[i] >> b[i];
        g[u].push_back({v,i});
        g[v].push_back({u,i});
    }
    for(int i=1;i<=n;i++){
        cin >> c[i] >> d[i];
        c[i]=min(c[i],X-1);
    }
    fill(t,t+N*X,inf);
    t[1*X+s]=0;
    set <pair <int,int> > q;
    q.insert({0,1*X+s});
    while(!q.empty()){
        auto k=q.begin()->s;
        q.erase(q.begin());
        int v=k/X,cm=k%X;
        if(cm<X-1){
            int nm=cm+c[v];
            if(nm>=X)nm=X-1;
            int pos=v*X+nm;
            if(t[k]+d[v]<t[pos]){
                q.erase({t[pos],pos});
                t[pos]=t[k]+d[v];
                q.insert({t[pos],pos});
            }
        }
        for(auto ed:g[v]){
            int u=ed.f,i=ed.s,nm=cm-a[i];
            if(nm<0)continue;
            int pos=u*X+nm;
            if(t[k]+b[i]<t[pos]){
                q.erase({t[pos],pos});
                t[pos]=t[k]+b[i];
                q.insert({t[pos],pos});
            }
        }
    }
    for(int i=2;i<=n;i++){
        int ans=inf;
        for(int pos=i*X;pos<(i+1)*X;pos++)
            ans=min(ans,t[pos]);
        cout << ans << '\n';
    }
}

Measured memory_bytes: 8072
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f 
#define MEM(x,y) memset(x,y,sizeof(x))
#define Maxn 100005
#define P pair<int,int>
using namespace std;
int gcd(int x, int y)
{
	if (y == 0) return x;
	return gcd(y, x % y);
}
int main()
{
	ll a=1, b=1;
	int n;
	while(cin >> n)
	{
	
	while (n--)
	{
		ll q, w;
		cin >> q >> w;
		ll o,p;
		
		if(a%q==0)
		 o=a/q;
		else
		 o=a/q+1;
		if(b%w==0)
		 p=b/w;
		else
		 p=b/w+1;
		ll r=max(o,p);
		a = r*q;
		b = r*w;
	}
	cout << a + b;
}
}

Measured memory_bytes: 256
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())

def solve():
    N = INT()
    adj = [[] for _ in range(N)]
    for i in range(N-1):
        a, b, c = MAP()
        adj[a-1].append([b-1, c])
        adj[b-1].append([a-1, c])

    Q, K = MAP()
    K -= 1

    def dijkstra(K, adj):
        #K: 始点, adj[point, cost]:隣接リスト
        d = [inf]*N
        d[K] = 0
        que = []
        heappush(que, K)

        while que:
            v = heappop(que)
            for b, c in adj[v]:
                if d[b] > d[v] + c:
                    d[b] = d[v] + c
                    heappush(que, b)
        return d

    d = dijkstra(K, adj)
    for i in range(Q):
        x, y = MAP()
        print(d[x-1]+d[y-1])

if __name__ == '__main__':
    solve()

Measured memory_bytes: 51512
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int h[] = new int[n];
        int dp[] = new int[n];
        
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        
        for (int i = 1; i < n; i++) {
            if (i == 1) {
                dp[i] = Math.abs(h[i] - h[i-1]);
            } else {
                dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1] - h[i]), dp[i-2] + Math.abs(h[i-2] - h[i]));
            }
        }
        
        System.out.println(dp[n-1]);
    }
}


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

using namespace std;
using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int IINF = INT_MAX;
const static llong LINF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

/* --------------- template start --------------- */
template <typename T> 
struct BinaryIndexTree { // [1, n]
    vector<T> array;
    int n;

    BinaryIndexTree(int _n) {
        array.resize(_n + 1, 0);
        n = _n;
    }

    T cumsum(int i) {
        T s = 0;
        while(i > 0) {
            s += array[i];
            i -= i & -i;
        }

        return s;
    }

    T sum(int i, int j) {
        T ret_i = cumsum(i - 1);
        T ret_j = cumsum(j);

        return ret_j - ret_i;
    }

    void add(int i, T x) {
        while (i <= n) {
            array[i] += x;
            i += i & -i;
        }
    }
};

template<typename T>
struct UnionFind {
    vector<int> par;
    vector<T> sz;

    UnionFind(int n) {
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find_root(int x) {
        return par[x] == x ? x : par[x] = find_root(par[x]);
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;
        
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }

    T size_of_tree(int x) {
        return sz[find_root(x)];
    }
};
/* --------------- template end --------------- */

/* --------------- function start --------------- */
llong my_gcd(llong a, llong b) {
    return (a ? my_gcd(b % a, a) : b);
}
llong my_lcm(llong a, llong b) {
    return a * b / my_gcd(a, b);    
}

llong facmod(llong n) {
    if (n == 0) return 1;

    llong res = n;
    for (int i = n - 1; i > 0; --i) {
        res = (res * i) % MOD;
    }

    return res;
}
llong powmod(llong a, llong n) {
    llong res = 1;
    while (n > 0) {
        if (n & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        n >>= 1;
    }

    return res;
}
llong modinv(llong n) {
    return powmod(n, MOD - 2);
}
llong combmod(llong n, llong k) {
    llong res = 1;
    for (int i = 0; i < k; ++i) {
        res = (res * (n - i)) % MOD;
    }
    res = (res * modinv(facmod(k))) % MOD;

    return res;
}
/* --------------- function start --------------- */

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong n, a, b;
    cin >> n >> a >> b;

    cout << (n / (a + b)) * a + min(n - (a + b) * (n / (a + b)), a) << endl;
    return 0;
}

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

using namespace std;
using Edge = int;
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void dfs(const Graph &g,int v,vector<int> &color,int c){
  color[v] = c;
  for(auto u:g[v]){
    if(color[u]==-1){
      dfs(g,u,color,c);
    }
  }
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> p(n);
  for(int i=0;i<n;++i){
    cin >> p[i];
    p[i]--;
  }
  Graph g(n);
  for(int i=0;i<m;++i){
    int s,t;
    cin >> s >> t;
    g[s-1].emplace_back(t-1);
    g[t-1].emplace_back(s-1);
  }
  vector<int> color(n,-1);
  for(int v=0,c=0;v<n;++v){
    if(color[v]==-1){
      dfs(g,v,color,c++);
    }
  }
  int max_match = 0;
  for(int i=0;i<n;++i){
    if(color[i] == color[p[i]]) max_match++;
  }
  cout << max_match << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

string K;
int D, n;
ll dp[2][100][10000];

ll solve(bool cap, int m, int i) {
    if (i == n)
        return m == 0;
    if (dp[cap][m][i] == -1) {
        dp[cap][m][i] = 0;
        if (cap) {
            for (int d = 0; d < K[i] - '0'; d++) {
                dp[cap][m][i] += solve(false, (m + d) % D, i + 1);
                dp[cap][m][i] %= MOD;
            }
            dp[cap][m][i] += solve(true, (m + K[i] - '0') % D, i + 1);
            dp[cap][m][i] %= MOD;
        } else {
            for (int d = 0; d <= 9; d++) {
                dp[cap][m][i] += solve(cap, (m + d) % D, i + 1);
                dp[cap][m][i] %= MOD;
            }
        }
    }
    return dp[cap][m][i];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> K >> D;
    n = K.size();
    memset(dp, -1, sizeof dp);
    ll result = solve(true, 0, 0) - 1;
    if (result < 0)
        result += MOD;
    cout << result << endl;
}


Measured memory_bytes: 16640
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n ;
  cin >> n ;
  vector<int> a(n) ;
  for(int i=0;i<n;i++)cin >> a.at(i) ;
 
  sort(a.begin(),a.end(),greater<int>()) ; //decreasing
  
  cout << a.at(0)-a.at(a.size()-1) << endl;
  
   return 0;
}


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

  const int MOD = 1000000007;
  const double PI = acos(-1); 

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }
int n;
ll k;
vector<int>a;
vector<int>f;


  //二分探索(最小値を出す問題は疑う)

bool C(ll x){
    ll res = 0;
    for(int i = 0; i < n; ++i){
        ll tx = a[i], ty = f[i];
        if(tx * ty > x) res += (ll)ceil((double)(tx * ty - x) / ty);
    }
    return res <= k;
}

  ll binary_search(ll ok, ll ng){
    while(abs(ok - ng) > 1){
      ll mid = (ok + ng) / 2;
      if(C(mid)) ok = mid;
      else ng = mid;
    }
    return ok;
  }






int main() {
  
  cin >> n >> k;
  a = vector<int>(n);
  f = vector<int>(n);
  REP(i,n) cin >> a[i];
  REP(i,n) cin >> f[i];
  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());
  ll l = -1, r = 1e12;
  cout << binary_search(r, l) << endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

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

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int n; cin >> n, n;) {
		vector<int> v(n);
		rep(i,n) cin >> v[i];
		cout << (accumulate(all(v), 0) - *max_element(all(v)) - *min_element(all(v))) / (n - 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> pref(n+1);
    vector<ll> p(m), y(m);
    for (ll i = 0; i < m; i++) {
        cin >> p[i] >> y[i];
        pref[p[i]].push_back(y[i]);
    }
    for (ll i = 1; i < n + 1; i++) sort(pref[i].begin(), pref[i].end());
    for (ll i = 0; i < m;i++){
        cout << setfill('0') << right << setw(6) << p[i];
        cout << setfill('0') << right << setw(6) << (long long)(lower_bound(pref[p[i]].begin(), pref[p[i]].end(), y[i]) - pref[p[i]].begin() + 1) << endl;
        }
}

Measured memory_bytes: 10304
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

import random


def main():
    n = int(input())
    S = input().strip()
    SS=""
    SX="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    #eprint((ord("A")))
    #eprint((ord("Z")))
    for i in range(len(S)):
        # S[i] -> 
        # SX[i] -> SX[i+n]
        # ii = (i+n) % 25 
        # SS+=SX[ii]
        chrcode =  (ord(S[i]) + n) if (ord(S[i]) + n)<=90  else (ord(S[i]) + n)%91 + 65
        #eprint( chrcode )
        SS+= chr(chrcode)
    print(SS)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 69992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  string s;
  cin>>s;
  if(s=="a"||s=="i"||s=="u"||s=="o"||s=="e"){
    cout<<"vowel"<<endl;
  }
  
  else{
    cout<<"consonant"<<endl;
  }
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
    cin>>n;
    int a[n],memo1=0, memo2=0,index=-1;
    for(int i=0;i<n;i++){
            cin>>a[i];
            if(a[i]>memo1){memo1=a[i];index=i;}
    }
  	sort(a,a+n,greater<int>());
    for(int i=0;i<n;i++){cout<<(i==index?a[1]:memo1)<<endl;}
}


Measured memory_bytes: 2432
from collections import deque
t,*g=open(0)
h,w=map(int,t.split())
vis=[[1e9]*w for _ in range(h)]
vis[0][0]=int(g[0][0]=="#")
q=deque([(0,0)])
while q:
	cy,cx=q.popleft()
	for ny,nx in ((cy+1,cx),(cy,cx+1)):
		if not not (0<=ny<h and 0<=nx<w) and vis[cy][cx]+(g[cy][cx]!=g[ny][nx]=="#")<vis[ny][nx]:
			vis[ny][nx]=vis[cy][cx]+(g[cy][cx]!=g[ny][nx]=="#")
			q.append((ny,nx))
print(vis[-1][-1])

Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    double R;
    cin >> R;
    cout << 3.1415*2*R << endl;
}

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

using namespace std;
typedef long long ll;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<pair<ll,ll> > x(N);

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

  sort(x.begin(), x.end());

  ll f = 0;
  for (int i = 0; i < N; i++) {
    f+= x[i].second;
    if (f >= K) {
      cout << x[i].first << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

static const int LEN=100000;
static const int NIL=-1;

int n;
vector<int > G[LEN];
int color[LEN];

void dfs(int r,int c)
{
    stack<int> S;
    S.push(r);
    color[r]=c;
    while(!S.empty()){
        int u=S.top(); S.pop();
        for(unsigned int i=0;i<G[u].size();i++){
            int v=G[u][i];
            if(color[v]==NIL){
                color[v]=c;
                S.push(v);
            }
        }
    }
}

void assignColor()
{
    int id=1;
    for(int i=0;i<n;i++) color[i]=NIL;
    for(int u=0;u<n;u++){
        if(color[u]==NIL) dfs(u,id++);
    }
}

int main()
{
    int s,t,m,q;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>s>>t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    assignColor();
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>s>>t;
        if(color[s]==color[t]) cout<< "yes" <<endl;
        else cout<< "no" <<endl;
    }
    return 0;
}



Measured memory_bytes: 9012
S = input()
if 13 <= int(S[:2]) and int(S[2:]) == 0:
    print('NA')
elif 0 == int(S[:2]) and int(S[2:]) >= 13:
    print('NA')
elif int(S[:2]) >= 13 and int(S[2:]) >= 13:
    print('NA')
elif int(S[:2]) == 0 and int(S[2:]) == 0:
    print('NA')
elif 13 <= int(S[:2]) or 0 == int(S[:2]) and int(S[2:]) <= 12:
    print('YYMM')
elif 12 >= int(S[:2]) and int(S[2:]) >= 13 or int(S[2:]) == 0:
    print('MMYY')
else:
    print('AMBIGUOUS')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/

ll get(ll n,ll d){//未満
	if(d==0)return (n+1)/2;
	ll ret=0;
	if(n%2==0)ret+=(!!(n--&(1ll<<d)));
	return ret+2ll*get(n/2,d-1);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;
	cin>>a>>b;
	if(a==b){
		puta(a);
		return 0;
	}
	ll ans=0;
	rep(i,40){
		if((get(b,i)-get(a-1,i))%2==1)ans|=(1ll<<i);
	}
	puta(ans);
	return 0;
}


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

using namespace std;

const long long INF = 1e18;

struct interval {
    int l, r, val;

    bool operator < (const interval& T) const {
        return l < T.l;
    }
}a[200005];

struct dat {
    long long val, lazy;
}tree[800005];

long long dp[200005][2];

int lx, ly;
long long lval;

void push(int ind) {
    if (tree[ind].lazy == 0) return;
    tree[ind * 2].val += tree[ind].lazy;
    tree[ind * 2].lazy += tree[ind].lazy;
    tree[ind * 2 + 1].val += tree[ind].lazy;
    tree[ind * 2 + 1].lazy += tree[ind].lazy;
    tree[ind].lazy = 0;
}

void update(int l, int r, int ind) {
    if (lx <= l && r <= ly) {
        tree[ind].val += lval;
        tree[ind].lazy += lval;
        return;
    }
    push(ind);
    int mid = (l + r) / 2;
   if (lx <= mid) update(l, mid, ind * 2);
   if (ly > mid) update(mid + 1, r, ind * 2 + 1);
   tree[ind].val = max(tree[ind * 2].val, tree[ind * 2 + 1].val);
}

void query(int l, int r, int ind) {
    if (lx <= l && r <= ly) {
        lval = max(lval, tree[ind].val);
        return;
    }
    push(ind);
    int mid = (l + r) / 2;
    if (lx <= mid) query(l, mid, ind * 2);
    if (ly > mid) query(mid + 1, r, ind * 2 + 1);
    tree[ind].val = max(tree[ind * 2].val, tree[ind * 2 + 1].val);
}

void pupdate(int l, int r, int ind) {
    if (l == r) {
        tree[ind].val += lval;
        return;
    }
    push(ind);
    int mid = (l + r) / 2;
    if (lx <= mid) pupdate(l, mid, ind * 2);
    else pupdate(mid + 1, r, ind * 2 + 1);
    tree[ind].val = max(tree[ind * 2].val, tree[ind * 2 + 1].val);
}

int main() {
    int n, m;
    scanf("%d%d", &n, &m);

    for (int i = 0; i < m; i++) {
        scanf("%d%d%d", &a[i].l, &a[i].r, &a[i].val);
    }

    sort(a, a + m);

    int p = 0;

    priority_queue <pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >, greater<pair<int, pair<int, int> > > > pq;

    dp[0][0] = dp[0][1] = 0;
    long long cost = 0;

    for (int i = 1; i <= n; i++) {
        while (p < m && a[p].l <= i) {
            cost += a[p].val;
            pq.push(make_pair(a[p].r, make_pair(a[p].l,  a[p].val)));
            lx = a[p].l;
            ly = a[p].r;
            lval = -a[p].val;
            update(0, n, 1);
            p++;
        }

        while (pq.size() && pq.top().first < i) {
            cost -= pq.top().second.second;
            lx = pq.top().second.first;
            ly = pq.top().first;
            lval = pq.top().second.second;
            update(0, n, 1);
            pq.pop();
        }

        dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]);

        lx = 0;
        ly = i - 1;
        lval = -INF;
        query(0, n, 1);

        dp[i][1] = lval + cost;

        lx = i;
        lval = dp[i][1];
        pupdate(0, n, 1);

    }

    printf("%lld\n", max(dp[n][0], dp[n][1]));
}


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

using namespace std;

int main(){
int n, m;
cin >> n >> m;
int a[n], b[n];
int i, j;
for(i=1; i<=n; i++){
    cin >> a[i] >> b[i];}
int c[m], d[m];
for(j=1; j<=m; j++){
    cin >> c[j] >> d[j];}

int min[n], number[n], k, l;
for(l=1; l<=n; l++){
    min[l] = abs(a[l]-c[1])+abs(b[l]-d[1]);
    number[l] = 1;
    for(k=2; k<=m; k++){
        if(min[l] > abs(a[l]-c[k])+abs(b[l]-d[k])){
            min[l] = abs(a[l]-c[k])+abs(b[l]-d[k]);
            number[l] = k;
        }
    }
}

int p;
for(p=1; p<=n; p++){
cout << number[p] << endl;
}
return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		List<int[]> Npoint = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			int[] n = new int[2];
			n[0] = sc.nextInt();
			n[1] = sc.nextInt();
			Npoint.add(n);
		}
		List<int[]> Mpoint = new ArrayList<>();
		for (int i = 0; i < M; i++) {
			int[] m = new int[2];
			m[0] = sc.nextInt();
			m[1] = sc.nextInt();
			Mpoint.add(m);
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < N; i++) {
			int[] n = Npoint.get(i);
			int minDis = Integer.MAX_VALUE;
			int point = 0;
			for (int j = 0; j < M; j++) {
				int[] m = Mpoint.get(j);
				int dis = Math.abs(n[0] - m[0]) + Math.abs(n[1] - m[1]);
				if (dis < minDis) {
					minDis = dis;
					point = j+1;
				}
			}
			sb.append(point).append("\n");
		}
		System.out.println(sb);
	}
}

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

int main(){
  long long x;
  cin >> x;
  long long a=0;
  long long b=0;
  for (long long i = -1000; i < 1000; i++)
  {
    for (long long j = -1000; j < 1000; j++)
    {
      long long ai = i*i*i*i*i;
      long long bj = j*j*j*j*j;
      if(ai-bj==x){
        a = i;
        b = j;
        break;
      }
    }
  }
  cout << a << " " << b << endl;  
}

Measured memory_bytes: 3648
numbers = list(map(int, input().split()))
n = numbers[0]

l = []
l = l + list(range(1, 2*n+1))

print("?", " ".join(map(str, l[:n])))

culoare_initiala = input()

st = 0
dr = n

while st < dr - 1:
    mij = (st + dr) // 2
    
    
    print("?", " ".join(map(str, l[mij: mij+n])))
    
    culoare = input()
    if culoare == culoare_initiala:
        st = mij
    else:
        dr = mij
        
rezultat = ["_"] * (2*n)

rezultat[st] = culoare_initiala[0]
if culoare_initiala == "Blue":
    rezultat[st+n] = "R"
else:
    rezultat[st+n] = "B"

v = []
v = v + list(range(st+1, st+n)) 
w = []
for i in range(2*n):
    if i not in v and i != st and i != st + n:
        w.append(i)
        
assert len(v) == len(w)

for i in range(2 * n):
    if rezultat[i] != "_":
        continue
    if i not in v:
        z = v
    else:
        z = w
    print("?", str(i+1), " ".join([str(i+1) for i in z]))
    rezultat[i] = input()[0]
    
print("!", "".join(rezultat))


Measured memory_bytes: 3532
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        List<int> i = new List<int>();
        foreach (var item in a)
        {
            if (!i.Contains(item)) i.Add(item);
        }
        Console.WriteLine(i.Count);
    }
}

Measured memory_bytes: 11232
#include<bits/stdc++.h>  
using namespace std;  
  
#define fast ios::sync_with_stdio(false);cin.tie(NULL)  
#define fi first  
#define se second  
#define all(v) (v).begin(),(v).end()  
#define pb push_back  
#define eb emplace_back
#define em emplace
#define mp make_pair
  
typedef long long ll;  
typedef pair<int,int> pii;  
typedef pair<ll,ll> pll;  
const long long INF = 1e18;  
const int inf = 1e9;

int main() {
	fast;

	string s;
	int k;
	cin >> k;

	for(int i=0; i<k; i++) s += "ACL";

	cout << s;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int A,B,T;
    cin>>A>>B>>T;
    int ans = 0;
    ans = (T)/A * B;
    cout<<ans<<endl;
    return 0;
}

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

const ll inf = 1e18;

pii p[5005];
ll dp[5005];

int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> p[i].first >> p[i].second;
  sort(p + 1, p + n + 1, [&] (pii a, pii b) {
    return a.first + a.second < b.first + b.second;
  });
  for (int i = 1; i <= n; ++i) dp[i] = inf;
  for (int i = 1; i <= n; ++i)
    for (int j = n; j >= 1; --j)
      if (dp[j - 1] <= p[i].first)
        dp[j] = min(dp[j], dp[j - 1] + p[i].second);
  int sol = 0;
  for (int i = 1; i <= n; ++i)
    if (dp[i] != inf)
      sol = i;
  cout << sol << '\n';
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a;
    for(ll i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        a.push_back(temp);
    }
    ll ans = 1;
    ll i = k;
    while(i <= n - 1) {
        i--;
        i += k;
        ans++;
    }

    cout << ans << endl;    
}

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

int main()
{
    long long n,k;
    cin >> n >> k;
    int c = 0;
    int a = n;
    while( a / k > 0 )
    {
        a = int(a / k);
        c++;
    }
    
    cout << c+1 << endl;
    return 0;
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    while (cin >> N >> K && (N || K)) {
        vector<int> S(K);
        for (int i=0; i<K; ++i) cin >> S[i];
        int t;
        bool ok = true;
        for (int i=0; i<N; ++i) {
            for (int j=0; j<K; ++j) {
                cin >> t;
                S[j] -= t;
                if (S[j] < 0) {
                    ok = false;
                }
            }
        }
        cout << (ok ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int S = b / d;
	if (b%d)S++;
	int K = c / e;
	if (c%e)K++;
	a -= max(S, K);
	cout << a << endl;
}

Measured memory_bytes: 3084
A,B,C,D,E,F=map(int,input().split())
maxim=-1
ans=[0,0]
for i in range(F//100//A+2):
  for j in range(F//100//B+2):
    if A*100*i+B*100*j >= F:
      break
    for k in range(F//C+2):
      if A*100*i+B*100*j+C*k >= F:
        break
      for l in range(F//D+2):
        s=D*l+C*k
        w=A*100*i+B*100*j
        if s+w<=F:
          if w//100*E>=s:
            if s+w!=0:
              if maxim<100*s/(s+w):
                maxim=100*s/(s+w)
                ans=[w+s,s]
print(*ans)

Measured memory_bytes: 43500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 1;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans %= mod;
        ans *= power(i + 1, mod - 2);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll n,a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> n;
    pf(a[n - 1]);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int a[100000], crt=1, i, n;
  rd(n);
  {
    int Nzj9Y0kE;
    for(Nzj9Y0kE=0;Nzj9Y0kE<n;Nzj9Y0kE++){
      rd(a[Nzj9Y0kE]);
    }
  }
  for(i=0;i<n;i++){
    crt = a[crt - 1];
    if (crt == 2){
      wt_L(i + 1);
      putchar_unlocked('\n');
      exit(0);
    }
  }
  wt_L(-1);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20180730-1

// --- original code ---
// {
//   int n, a[100000];
//   rd(n, a(n));
//   int crt = 1;
//   rep(i, n) {
//     crt = a[crt - 1];
//     if (crt == 2) {
//       wt(i + 1);
//       exit(0);
//     }
//   }
//   wt(-1);
// }

Measured memory_bytes: 640
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();

    if (a < b && b < c) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 26224
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < 3; i++) if (s[i] == '1') ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int a, b, c;
	int counter = 0;
	cin >> a >> b >> c;
	for (int i = a; i < b+1; i++){
		if (c%i == 0){
			counter += 1;
		}
	}
	cout << counter << endl;
}

Measured memory_bytes: 3084