akhauriyash/Code-Regression huggingface dataset:
n=int(input())

S=input().split()
s=list(S)

ans=[]
for i in range(n):
    
  ans.append(0)
  s[i]=int(s[i])


for i in range(n):
  #１番の生徒は８番目にやってきている　s[i]のiは生徒の番号、中身は何番目か
  
  s[i]#i=0,s[i]=8 
  ans[s[i]-1]=i+1

for i in range(n):
    print(ans[i],end=" ")


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;




int main() {
    li a, b;
    cin >> a >> b;
    if (max(a, b) > 8) {
        puts(":(");
    } else {
        puts("Yay!");
    }
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn
import scala.io.Source

object Main{
  def main(args: Array[String]){
    val lines =
    	for{
    		in <- Source.stdin.getLines.toList
    	}yield in.toString

    def reCatCard(s: String, h: List[Int]):String ={
      if(h.tail == Nil)
        s.dropRight(s.length - h.head).patch(0,s.drop(h.head),0)
      else
        reCatCard(s.dropRight(s.length - h.head).patch(0,s.drop(h.head),0), h.tail)
    }

    def reArrangeList(list: List[String]): List[List[String]] ={
      if(list == List("-"))
        List()
      else
        list.splitAt(list.tail.head.toInt + 2)._1 :: reArrangeList(list.splitAt(list.tail.head.toInt + 2)._2)
    }

    for(target <- reArrangeList(lines)){
      println(reCatCard(target.head, target.tail.tail.map(_.toInt)))
    }
  }
}

Measured memory_bytes: 44724
#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
const int N=1e5+5,mod=1e9+7;
typedef long long ll;
int n;
int solve(){
    if(n%2==0 || n%5==0)
        return -1;
    int cnt=1;
    int x=7;
    while(x%n){
        x=x*10 +7;
        x%=n;
        cnt++;
    }
    return cnt;

}
int main()
{
    Elhabashy
    input();
    cin>>n;
    cout<<solve()<<endl;

}


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

int main()
{
    int H, W, K;
    bool flg = false;
    cin >> H >> W >> K;
    for(int i = 0; i <= H; i++) {
        for(int j = 0; j <= W; j++) {
            if(H * W - i * j - (H - i) * (W - j) == K) {
                flg = true;
            }
        }
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;

    return (0);
}

Measured memory_bytes: 256
#include<stdio.h>

int main (void)

{

    int W,H,x,y,r;

    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

    if(x-r >= 0 && y-r >= 0 && x+r <= W && y+r <= H){

    printf("Yes\n");

    }

    else{

    printf("No\n");

    }

    return 0;

}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
constexpr int INF = (numeric_limits<int>::max() == INT_MAX ? (int)1e9 : (long long)1e18);
constexpr long double eps = 1e-6;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;using pii = pair<int,int>;using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void fast_io(){ios::sync_with_stdio(false); cin.tie(nullptr);}
signed main(){
    fast_io();
    int N,K,S; cin >> N >> K >> S;
    vector<int>ans(N,S);
    for(int i = K; i < N; ++i) ans[i] = (S < 1000000000 ? S + 1 : S -1);
    for(auto& e : ans ) cout << e << endl;
}


Measured memory_bytes: 2176
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);
	static int N;

	public static void main(String[] args){

		int n = scan.nextInt();
		int[] arr = new int[n];
		for(int i = 0; i < n; i++){
			arr[i] = scan.nextInt();
		}

		shellSort(arr, n);
	}

	static int insertSort(int[] a, int n, int g, int cnt){
		int v, j;
		for(int i = g; i < n; i++){
			v = a[i];
			j = i - g;
			while(j >= 0 && a[j] > v){
				a[j+g] = a[j];
				j = j - g;
				cnt++;
			}
			a[j+g] = v;
		}
		return cnt;
	}

	static void shellSort(int[] a, int n){
		int cnt, m, count, gCheck;
		cnt = 0;
		count = 0;
		gCheck = 1;

		while(n > gCheck){
			gCheck = gCheck * 2 + 1;
			count++;
		}
		if(count == 0)
			count = 1;
		m = count;
		int[] g = new int[m];
		g[m-1] = 1;

		for(int i = 1; i < m; i++){
			g[m-i-1] = g[m-i] * 2 + 1;
		}

		for(int i = 0; i < m; i++){
			cnt = insertSort(a, n, g[i], cnt);
		}

		System.out.println(m);
		for(int i = 0; i < m; i++){
			System.out.printf(i != m-1? "%d " : "%d\n", g[i]);
		}
		System.out.printf("%d\n", cnt);
		for(int i = 0; i < n; i++){
			System.out.printf("%d\n", a[i]);
		}
	}
}

Measured memory_bytes: 568936
#include <stdio.h>
#include <string.h>

#define N 2

int matrix(double **x);
 
int main(void){
	double x[N][N+1];
	double *y[N];
	double su1=0,su2=0;
	int i,j,k,n;
	char str[100],*line;
    
	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		for(i=0;i<(N+1)*N;i++){
			if(i==0)
				line = strtok(str," ");
			else
				line = strtok(NULL," ");
			sscanf(line,"%d",&n);
			x[i/(N+1)][i%(N+1)]=n;
			
		}
		for(i=0;i<N;i++)
			y[i]=x[i];
		matrix(y);
		for(i=0;i<N;i++){
			if(i) printf(" ");
			printf("%3.3f",x[i][N]);
		}
		printf("\n");
	}
	return 0;
}

int matrix(double **x){
	int i,j,k;
	double su1=0,su2=0;

	for(k=0;k<=N-2;k++){
		for(j=k+1;j<=N-1;j++){
			su1=x[k][k];
			su2=x[j][k];
			for(i=0;i<=N;i++){
				x[j][i]=x[j][i]-x[k][i]*su2/su1;
			}
		}
	}	
	for(k=0;k<=N-2;k++){
		for(j=k+1;j<=N-1;j++){
			su1=x[N-1-k][N-1-k];
			su2=x[N-1-j][N-1-k];
			for(i=0;i<=N;i++){
				x[N-1-j][i]=x[N-1-j][i]-x[N-1-k][i]*su2/su1;
			}
		}
	}
	su1=0;
	for(j=0;j<=N-1;j++){
	su1=x[j][j];
		for(i=0;i<=N;i++){
		x[j][i]=x[j][i]/su1;
		}	
	}
	return 0;
}

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

void sort(int* begin, int length){
    for(int i=0;i<length-1;i++){
        for(int j=i+1;j<length;j++){
            if(*(begin+i) > *(begin+j)){
                int temp = *(begin+i);
                *(begin+i) = *(begin+j);
                *(begin+j) = temp;
            }
        }
    }
}

int main(){
    int N, K, p[1000];
    scanf("%d%d", &N, &K);
    for(int i=0;i<N;i++){
        scanf("%d", &p[i]);
    }
    // end input

    int ans = 0;
    sort(&p[0], N);
    for(int i=0;i<K;i++){
        ans += p[i];
    }
    printf("%d", ans);
    
    return 0;
}




Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

void solve(){
	ll a,v;
	cin>>a>>v;
	ll b,w;
	cin>>b>>w;
	ll t;
	cin>>t;
	v -= w;

	ll s = v*t;
	if(s >= abs(a-b)){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 3644
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

int n, m, k;

int ct_n[nax];
int ct_m[nax];

vector <pair <int, int>> a;
vector <int> b[nax];

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

    for (int i = 1 ; i <= k ; ++ i) {
        int h, w;
        scanf("%d %d", &h, &w);
        ++ ct_n[h];
        ++ ct_m[w];
        a.emplace_back(h, w);
        b[h].emplace_back(w);
    }

    int ans = 0;

    multiset <int> naive;

    for (auto [x, y] : a) {
        ans = max(ans, ct_n[x] + ct_m[y] - 1);
    }

    for (int i = 1 ; i <= m ; ++ i) {
        naive.insert(ct_m[i]);
    }

    for (int i = 1 ; i <= n ; ++ i) {
        for (int j : b[i]) {
            naive.erase(naive.find(ct_m[j]));
        }

        int res = naive.empty() ? 0 : *naive.rbegin();
        ans = max(ans, ct_n[i] + res);
        for (int j : b[i])
            naive.insert(ct_m[j]);
    }
    printf("%d\n", ans);
}



Measured memory_bytes: 38340
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int x1, x2, x3, x4, y1, y2, y3, y4;
	cin >> x1 >> y1 >> x2 >> y2;

	x3 = x2 - (y2 - y1);
	y3 = y2 + (x2 - x1);
	x4 = x3 - (y3 - y2);
	y4 = y3 - (x2 - x3);

	cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;


	return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=[int(_) for _ in input().split()]
uf =UnionFind(n)

for i in range(m):
    a,b=[int(_) for _ in input().split()]
    uf.union(a-1,b-1)

print(uf.group_count()-1)

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

int main(){
int W,X,Y,Z,w,x,y,z;
cin >> W >>X >> Y >> Z >> w >> x >>y >> z;

if( (W + X + Y + Z) > (w + x + y + z)){
    cout << W + X + Y + Z << endl;
}
else if(( W + X + Y + Z) < (w + x + y + z)){
    cout << w + x + y + z << endl;
}
else{ 
    cout << w + x + y + z << endl;
}

return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string x;
	cin >> x;
	if(x == s)a--;
	else b--;
	cout << a << " " << b << '\n';

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll c[10][10];
int main(){
	ll 	h, w; cin >> h >> w;
	for(int i = 0; i < 10; ++i)for(int j = 0; j < 10; ++j) cin >> c[i][j];
	ll a[h][w];
	for(int i = 0; i < h; ++i)for(int j = 0; j < w; ++j) cin >> a[i][j];
	ll count[10] = {};
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			if(a[i][j] >= 0) ++count[a[i][j]];
		}
	}
	count[1] = 0;
	ll ans = 0;
	for(ll k = 0; k < 10; ++k)for(ll i = 0; i < 10; ++i)for(ll j = 0; j < 10; ++j) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
	for(ll i = 0; i < 10; ++i) ans += count[i] * c[i][1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] c = new int[n-1];
        int[] s = new int[n-1];
        int[] f = new int[n-1];
        for(int i=0; i<n-1; i++) {
            c[i] = Integer.parseInt(sc.next());
            s[i] = Integer.parseInt(sc.next());
            f[i] = Integer.parseInt(sc.next());
        }
        int[] t = new int[n-1];
        for(int i=0; i<n-1; i++) {
            t[i] = s[i]+c[i];
            for(int j=i+1; j<n-1; j++) {
                if(t[i] < s[j]) t[i] = s[j] + c[j];
                else {
                    int k = 0;
                    while(true) {
                        if(t[i] <= s[j]+f[j]*k) {
                            t[i] = s[j]+f[j]*k+c[j];
                            break;
                        }
                        k++;
                    }
                }
            }
            System.out.println(t[i]);
        }
        System.out.println(0);
    }

}


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

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int n;
double t,a;
V<double> h;

int main(){
    INIT;
    cin >> n; cin >> t >> a;
    h.resize(n);
    REP(i,n) {
        cin >> h[i];
        h[i] = t-h[i]*0.006;
    }
    int ans = 0;
    double d = std::fabs(a-h[0]);
    FOR(i,1,n) {
        double nd = std::fabs(a-h[i]);
        if(nd < d) ans = i, d = nd;
    }
    cout << ans+1 << "\n";
}

Measured memory_bytes: 256
package main
import (
  "fmt"
)

func min(a, b int) int {
  if a < b {
    return a
  }
  return b
}
func main() {
  var n, m, x int
  fmt.Scan(&n, &m, &x)
  as := make([]int, m)
  for i := 0; i < m; i++ {
    fmt.Scan(&as[i])
  }
 
  cost1 := 0
  cost2 := 0
  for _, a := range as {
    if a < x {
      cost1++
    } else {
      cost2++
    }
  }
  
  result := min(cost1, cost2)
  fmt.Println(result)
}

Measured memory_bytes: 512
#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>;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

const int INF = 1e9;

int main()
{
    int n;
    cin >> n;
    vector<int> m;
    m.push_back(1);
    int x = 6;
    while (n >= x)
    {
        if (n >= x)
            m.push_back(x);
        x *= 6;
    }
    x = 9;
    while (n >= x)
    {
        if (n >= x)
            m.push_back(x);
        x *= 9;
    }
    vector<int> dp(n + 1, INF);
    dp[0] = 0;
    rep(yen, n + 1)
    {
        rep(i, m.size())
        {
            if (yen - m[i] >= 0)
                chmin(dp[yen], dp[yen - m[i]] + 1);
        }
    }
    // rep(i, n + 1) cout << dp[i] << endl;
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x, y;
	x = (c - c % b) / b;
	y = (a - a % d) / d;
	if (c % b != 0) x++;
	if (a % d != 0) y++;


	if (x <= y) cout << "Yes" << "\n";
	else cout << "No" << "\n";


	return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(){
   int x,y,judg=0;
   int i,j;
   scanf("%d%d",&x,&y);
   for(i=0;i<=x;i++){
      for(j=0;j<=x-i;j++){
         if(i+j==x&&4*i+2*j==y){
            judg++;
            break;
         }
      }
      if(i==0&&j==0){
         judg=0;
      }
   }
   if(judg==0){
      printf("No\n");
   }else{
      printf("Yes\n");
   }
   return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

string S; ll K;
vector <pair<char, ll>> P;

int main(){
  cin >> S >> K;
  
  ll cnt = 1;
  for (int i = 1; i < S.length(); i++){
    if (S[i] == S[i-1]){
      cnt++;
    }else{
      P.push_back({S[i-1], cnt});
      cnt = 1;
    }
  }
  P.push_back({S[S.length()-1], cnt});

  int V = P.size();

  if (V == 1){
    ll ans = S.length();
    cout << ans * K / 2 << endl;
    return 0;
  }
  if (P[0].fi != P[V-1].fi){
    ll ans = 0;
    for (int i = 0; i < V; i++){
      ans += P[i].se / 2;
    }
    cout << ans * K << endl;
    return 0;
  }

  ll ans = 0;
  for (int i = 1; i < V-1; i++){
    ans += P[i].se/ 2;
  }
  ans *= K;
  ans += (P[0].se + P[V-1].se) / 2 * (K-1);
  ans += P[0].se / 2 + P[V-1].se / 2;

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3632
//
// Created on 2020/06/14.
//


#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 <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int x,y;
    cin>>x>>y;

    for (int i = 0; i <= x; ++i) {
        int turu = i;
        int kame = x - i;
        if(y == (2 * turu + 4 * kame)){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;

    return 0;
}


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

using namespace std;

int main()
{
    int n ;
    cin>>n;
    vector<int> a(n);
    int m=10000 , M=0;
    for(int i=0 ; i<n ; i++)
    {
        cin>>a[i];
        m=min( m , a[i] );
        M=max( M , a[i] );
    }
    int C=1e9 ;
    for(int j=m ; j<=M ; j++)
    {
        int sum=0;
        for( int i=0 ; i<n ; i++ )
        {
           sum+= (  ( a[i] - j ) * ( a[i]-j ) );
        }
        C=min( C , sum );
    }
    cout<<C<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define N 100010
ll n,m;
vector<ll> g[N];
bool vis[N];
void dfs(ll x){
    if(vis[x])return;
    vis[x]=1;
    for(auto y:g[x])dfs(y);
}
int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
      ll a,b,c;cin>>a>>b>>c;
      g[a].push_back(b);
      g[b].push_back(a);
  }
  ll ans=0;
  for(int i=1;i<=n;i++)vis[i]=0;
  for(int i=1;i<=n;i++){
      if(vis[i]==0){
	  dfs(i);
	  ans++;
      }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

bool search_edge(int a, int b, vector<pair<int, int>> edge) {
    bool ans = false;
    for (int i = 0; i < edge.size(); i++) {
        if (edge[i] == make_pair(a, b) || edge[i] == make_pair(b, a)) {
            ans = true;
            break;
        }
    }
    return ans;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> edge(M);
    for (int i = 0; i < M; i++) cin >> edge[i].first >> edge[i].second;

    vector<int> node(N);
    for (int i = 0; i < N; i++) {
        node[i] = i + 1;
    }

    int ans = 0;
    do {
        bool can = true;
        for (int i = 0; i < N - 1; i++) {
            if (!search_edge(node[i], node[i + 1], edge)) {
                can = false;
                break;
            }
        }
        if (can) ans++;
    } while (next_permutation(node.begin() + 1, node.end()));

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

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

Y = [0] * N
s = 0
for i in range(N):
    if i % 2 == 0:
        s += A[i]
    else:
        s -= A[i]

Y[0] = s
for i in range(1, N):
    Y[i] = 2 * A[i - 1] - Y[i - 1]

ans = ' '.join([str(n) for n in Y])
print(ans)

Measured memory_bytes: 19100
#include<bits/stdc++.h>
using namespace std;
int main(){
  int v,e;
  cin >> v >> e;
  int s,t;
  long d;
  int i,j,k,l;
  vector<vector<long> >distance(v,vector<long>(v,1LL<<40));
  for(i=0;i<v;i++){
    distance[i][i] = 0;
  }
  for(i=0;i<e;i++){
    cin >> s >> t >> d;
    distance[s][t] = d;
  }
  for(k=0;k<v;k++){
    for(i=0;i<v;i++){
      for(j=0;j<v;j++){
        distance[i][j] = min(distance[i][j],distance[i][k]+distance[k][j]);
      }
    }
  }
  bool chk = true;
  for(i=0;i<v;i++){
    if(distance[i][i]<0)chk=false;
  }
  if(!chk){
    cout << "NEGATIVE CYCLE" << endl;
  }else{
    for(i=0;i<v;i++){
    for(j=0;j<v;j++){
      if(distance[i][j]>(1LL<<38))cout << "INF";
      else cout << distance[i][j];
      if(j!=v-1)cout << " ";
    }
    cout << endl;
  }}
}



Measured memory_bytes: 3244
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<bits/stdc++.h>
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
#define ll long long int
const ll mod = 1000000007;
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  vector <int> a(n),r(n);
  for (int i = 0; i < n; ++i)
  {
    cin >> r[i];
  }
  for (int i = 0; i < n; ++i)
  {
    a[0] += r[i];
    if(i%2 == 1)
      a[0] -= 2*r[i];
  }
  a[0] /= 2;
  for (int i = 1; i < n; ++i)
  {
    a[i] = r[i-1] - a[i-1];
  }
  for (int i = 0; i < n; ++i)
  {
    cout << 2*a[i] << " ";
  }
  return 0;
}


Measured memory_bytes: 2176
// AOJ 1021
#include <iostream>
#include <vector>
#include <string>
using namespace std;


vector<string> text;
int line, chara;
string buffer;

bool on_tail() { return chara == text[line].size(); }
void goto_tail() { chara = text[line].size(); }
bool on_eof() { return line >= text.size() - 1; }
void delete_line(int n) { text.erase(text.begin() + n); }
void delete_chara(int line, int chara) {
  text[line].erase(text[line].begin() + chara);
}

void a() { chara = 0; }
void e() { goto_tail(); }
void p() { line = max(line - 1, 0); chara = 0; }
void n() { line = min(line + 1, (int)text.size() - 1); chara = 0; }
void f() {
  if (not on_tail()) { chara++; }
  else if (not on_eof()) {
    line++; chara = 0;
  }
}
void b() {
  if (chara > 0) { chara--; }
  else if (line > 0) { line--; goto_tail(); }
}
void d() {
  if (on_tail() and !on_eof()) {
    text[line] += text[line + 1];
    delete_line(line + 1);
  } else if (not on_tail()) {
    delete_chara(line, chara);
  }
}
void k() {
  if (on_tail() and !on_eof()) {
    d();
    buffer = "\n";
  } else if (not on_tail()) {
    buffer = text[line].substr(chara);
    text[line] = text[line].substr(0, chara);
  }
}
void y() {
  if (buffer == "\n") {
    string temp = text[line].substr(chara);
    text[line] = text[line].substr(0, chara);
    text.insert(text.begin() + line + 1, temp);
    line++; chara = 0;
  } else if (not buffer.empty()) {
    text[line].insert(text[line].begin()+chara, buffer.begin(), buffer.end());
    chara += buffer.size();
  }
}

int main() {
  string temp_line;
  buffer = "";
  while (getline(cin, temp_line) and temp_line != "END_OF_TEXT") {
    text.push_back(temp_line);
  }

  char operat;
  while (cin >> operat and operat != '-') {
    switch (operat) {
    case 'a':
      a(); break;
    case 'e':
      e(); break;
    case 'p':
      p(); break;
    case 'n':
      n(); break;
    case 'f':
      f(); break;
    case 'b':
      b(); break;
    case 'd':
      d(); break;
    case 'k':
      k(); break;
    case 'y':
      y(); break;
    default:
      break;
    }

  }

  for (int i = 0; i < text.size(); i++) {
    cout << text[i] << endl;
  }
}



Measured memory_bytes: 3160
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    abc = MII()
    k = II()
    maxv = max(abc)
    sumv = sum(abc) - maxv
    for i in range(k):
        maxv *= 2
    sumv += maxv
    print(sumv)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
ans = 0
h, w, k = map(int, input().split())
C = [input() for _ in range(h)]
for i in range(2**h):
    for j in range(2**w):
        c = 0
        for y in range(h):
            for x in range(w):
                if C[y][x] == ".":
                    continue
                if i>>y & 1:
                    continue
                if j>>x & 1:
                    continue
                c += 1
        if c == k:
            ans += 1
print(ans)

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

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

#define fi first
#define se second
#define all(A) A.begin(),A.end()

using namespace std;

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

ll N;
ll X,K,D;
char S[40];

ll i, j, k;

int main(){
    scanf("%lld%lld%lld", &X,&K,&D);
    ll inv = X < 0 ? -1 : 1;
    X = abs(X);
    
    if(K<X/D){
        printf("%lld\n", X - K * D);
        return 0;
    }
    
    K = K - X / D;
    ll x = X % D;
    if(x==0){
        printf("%lld\n", K % 2 == 1 ? D : 0);
        return 0;
    }
    ll ans = 0;
    if(K%2==0){
        ans = x * inv;
    }else{
        ans = (x - D) * inv;
    }
    printf("%lld\n", abs(ans));
    return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>]
#include <map>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

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

int main() {

	int R;
	cin >> R;

	float ans = R * 2 * 3.14;

	cout << ans << endl;

}


Measured memory_bytes: 3788
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int min(int a,int b){

    if(a>=b){return b;}
    return a;
}

int cmp(const void *a,const void *b){
    if(*(int*)a>*(int*)b){return -1;}
    else if(*(int*)a<*(int*)b){return 1;}
    else {return 0;}
}

int n,m,l[100005],r[100005];
int main(void){
scanf("%d %d",&n,&m);

for(int i=0;i<m;i++){
scanf("%d %d",&l[i],&r[i]);
}
qsort(l,m,sizeof(int),cmp);
qsort(r,m,sizeof(int),cmp);
if(r[m-1]-l[0]>=0){printf("%d\n",r[m-1]-l[0]+1);}
else{printf("0\n");}

}

Measured memory_bytes: 1396
#include <iostream>

using std::cin;
using std::cout;
using std::endl;


void TorT()
{
  int n, a, b;

  cin >> n >> a >> b;
  if (n * a > b) cout << b << endl;
  else           cout << n * a << endl;
}


void cross9_9()
{
  int a, b;

  cin >> a >> b;
  if (a > 0 && a < 10 && b > 0 && b < 10) cout << a * b << endl;
  else cout << -1 << endl;
}


void calculate_circle()
{
  int r;

  cin >> r;
  cout << r * r << endl;
}


void SvsM()
{
  int hp, a;
  int atk_cnt, rest;

  cin >> hp >> a;
  atk_cnt = hp / a;
  if (hp % a) atk_cnt++;
  cout << atk_cnt << endl;
}


void Poor3()
{
  int a, b, c;

  cin >> a >> b >> c;
  if (a == b && b != c) cout << "Yes" << endl;
  else if (b == c && c != a) cout << "Yes" << endl;
  else if (c == a && a != b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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


void cross81()
{
  int n;
  int flag = 0;

  cin >> n;
  for (int i = 1; i < 10; i++)
  {
    for (int j = 1; j < 10; j++)
    {
      if (n == i * j)
      {
        flag = 1;
        cout << "Yes" << endl;
        break;
      }
    }
    if (flag) break;
  }
  if(!flag) cout << "No" << endl;
}


void bite_eating()
{
  int n, l;
  int taste[200];
  int sum = 0;
  int diff = 100;

  cin >> n >> l;
  for (int i = 0; i < n; i++)
  {
    taste[i] = l + i;
    sum += taste[i];
  }
  for (int i = 0; i < n; i++)
  {
    if(std::abs(taste[i]) < std::abs(diff)) diff = taste[i];
  }
  cout << sum - diff << endl;
}


int main()
{
  //TorT();
  //cross9_9();
  //calculate_circle();
  //SvsM();
  //Poor3();
  //Algae();
  //cross81();
  bite_eating();
}

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

void solve(int n,int x)
{
	if(x==1||x==2*n-1){
		cout<<"No"<<endl;
		return;
	}
	if(n==2){
		cout<<"Yes"<<endl;
		for(int x:{1,2,3})
			cout<<x<<endl;
		return;
	}
	vector<int> res;
	if(x==2){
		for(int i=3;i<=n;i++)
			res.push_back(i);
		res.push_back(2*n-1);
		res.push_back(x);
		res.push_back(1);
		res.push_back(2*n-2);
		for(int i=n+1;i<=2*n-3;i++)
			res.push_back(i);
	}
	else{
		for(int i=3;i<=n;i++) if(i!=x)
			res.push_back(i);
		res.push_back(1);
		res.push_back(x);
		res.push_back(2*n-1);
		res.push_back(2);
		for(int i=n+1;i<=2*n-2;i++) if(i!=x)
			res.push_back(i);
	}
	cout<<"Yes"<<endl;
	for(int x:res)
		cout<<x<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	for(int n,x;cin>>n>>x&&n|x;)
		solve(n,x);
}


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

int main() {
  
  int N, K, S; cin >> N >> K >> S;
  
  int maxSum = int(pow(10, 9));
  
  if (S == maxSum) {
    
    if (N == K) {
      for (int i = 0; i < N; i++) {
        cout << S;
        if (i != N - 1) cout << " ";
      }
      cout << endl;
    }
    
    else {
      for (int i = 0; i < K; i++) {
        cout << S << " ";
      }
      for (int i = 0; i < N - K; i++) {
        cout << S - 1;
        if (i != N - K - 1) cout << " ";
      }
      cout << endl;
    }
    
  }
  
  else {
    
    if (N == K) {
      for (int i = 0; i < N; i++) {
        cout << S;
        if (i != N - 1) cout << " ";
      }
      cout << endl;
    }
    
    else {
      for (int i = 0; i < K; i++) {
        cout << S << " ";
      }
      for (int i = 0; i < N - K; i++) {
        cout << S + 1;
        if (i != N - K - 1) cout << " ";
      }
      cout << endl;
    }
    
  }
  
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 500;
const int LOG = 60;

int n, a[N], m, P[N][60];
ll k, x[N], dx[N];

int main(){
	scanf("%d", &n);
	for(int i = 0;i < n;i++)
		scanf("%lld", x + i);
	for(int i = 1;i < n;i++){
		dx[i] = x[i] - x[i - 1];
		P[i][0] = i;
	}	
	scanf("%d%lld", &m, &k);
	for(int i = 0;i < m;i++){
		scanf("%d", a + i), a[i]--;
		swap(P[a[i]][0], P[a[i] + 1][0]);
	}	
	for(int j = 1;j < 60;j++)
		for(int i = 1;i < n;i++){
			P[i][j] = P[P[i][j - 1]][j - 1];
	}
	ll cur = x[0];
	for(int i = 0;i < n;i++){
		int gdje = i;
		for(int j = 0;j < 60;j++)
			if((1LL << j) & k)
				gdje = P[gdje][j];
		cur += dx[gdje];
		printf("%lld\n", cur);
	}
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> p(N), d(N), revp(N), revd(N);
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        
        int len = s.size();
        for (int j = 0; j < len; j++) {
            if (s[j] == '(') {
                p[i] += 1;
            } else {
                p[i] -= 1;
                d[i] = min(d[i], p[i]);
            }
        }
        
        for (int j = len - 1; j >= 0; j--) {
            if (s[j] == ')') {
                revp[i] += 1;
            } else {
                revp[i] -= 1;
                revd[i] = min(revd[i], revp[i]);
            }
        }
    }

    vector<bool> used(N);
    
    int ld = 0;    
    bool update = 1;
    
    while (update) {
        update = 0;
        
        int pmax = -1, idx = -1;
        for (int i = 0; i < N; i++) {
            if (used[i]) continue;
            if (ld + d[i] >= 0 && p[i] > pmax) {
                pmax = p[i];
                idx = i;
            }
        }

        if (idx != -1) {
            ld += p[idx];
            used[idx] = 1;
            update = 1;
        }       
    }

    int rd = 0;
    update = 1;
    
    while (update) {
        update = 0;
        
        int revpmax = -1, idx = -1;
        for (int i = 0; i < N; i++) {
            if (used[i]) continue;
            if (rd + revd[i] >= 0 && revp[i] > revpmax) {
                revpmax = revp[i];
                idx = i;                
            }
        }

        if (idx != -1) {
            rd += revp[idx];
            used[idx] = 1;
            update = 1;
        }
    }

    bool poss = (ld - rd == 0);
    for (int i = 0; i < N; i++) {
        if (!used[i]) {
            poss = 0;
            break;
        }
    }
    
    cout << (poss ? "Yes" : "No") << endl;
    return 0;
}

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

int main() {
  
  string a,b;
  cin >> a >> b;
  
  if ( a.size() > b.size() ){
    cout << "GREATER" << endl;
    return 0;
  }else if ( a.size() < b.size() ){
    cout << "LESS" << endl;
    return 0;
  }else{
    for ( int i = 0; i < a.size(); i++){
      if ( a[i] > b[i] ){
        cout << "GREATER" << endl;
        return 0;
      }else if ( a[i] < b[i] ){
        cout << "LESS" << endl;
        return 0;
      }else{
        continue;
      }
    }
  }
  
  cout << "EQUAL" << endl;
  return 0;
  
}



Measured memory_bytes: 256
import java.util.*;

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

        int N = stdin.nextInt();
        int K = stdin.nextInt();

        Integer l[] = new Integer[N];

        for (int i = 0; i < N; i++) {
            l[i] = stdin.nextInt();
        }

        Arrays.sort(l, Comparator.reverseOrder());

        int max = 0;

        for (int i = 0; i < K; i++) {
            max += l[i];
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
map<string,bool> M;
int main()
{
  int T;
  cin>>T;
  int Ans=0;
  while(T--)
  {
    string S;
    cin>>S;
    if(!M[S])
      Ans++;
    M[S]=true;
  }
  cout<<Ans<<endl;
  return 0;
}

Measured memory_bytes: 19220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll inf = pow(10,9);
ll N,A,B,C;

ll dfs(ll cur, ll a, ll b, ll c, vector<ll> l){
	if(cur == N){
		if (a > 0 && b > 0 && c > 0){
			return abs(a-A)+abs(b-B)+abs(c-C)-30;
		}else{
			return inf;
		}
	}
	vector<ll> r(4);
	r[0] = dfs(cur + 1, a, b, c, l);
	r[1] = dfs(cur + 1, a + l[cur], b, c, l) + 10;
	r[2] = dfs(cur + 1, a, b + l[cur], c, l) + 10;
	r[3] = dfs(cur + 1, a, b, c + l[cur], l) + 10;
	sort(r.begin(), r.end());
	return r[0];
}

int main()
{
  cin >> N >> A >> B  >> C;
	vector<ll> l(N);
	for (ll i(0);i<N;++i){
		cin >> l[i];
	}
	cout << dfs(0,0,0,0,l) << endl;

	return 0;
}

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

long long mid(long long a, long long b, long long c){
	return a + b + c - max(max(a, b), c) - min(min(a, b), c);
}

int main(){
	string X;
	cin >> X;
	int N = X.length();
	stack<char> M;
	for(int i = 0; i < N; i++){
		if(X[i] == 'S'){
			M.push('S');
		}else{
			if(M.empty() || M.top() == 'T'){
				M.push('T');
			}else{
				M.pop();
			}
		}
	}
	cout << M.size() << endl;
}

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

int main() {
	int N;
	cin >> N;
	vector<long> A(N);
	for (long& i : A) cin >> i;
	long a = accumulate(A.begin(), A.end(), 0l);
	for (int i = 1; i < N; i += 2) a -= A[i] * 2;
	cout << a << ' ';
	for (int i = 1; i < N; i++) {
		a = A[i - 1] * 2 - a;
		cout << a << ' ';
	}
}

Measured memory_bytes: 2048
h,w=map(int,input().split())
c=[[0]*w for _ in range(h)]
for i in range(h):
    c[i]=list(map(str,input()))
#print(c)
for i in range(h):
    print("".join(map(str,c[i])))
    print("".join(map(str,c[i])))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{

	int n;
	cin>>n;
	set<long long int>a;
	for(int i=0;i<n;i++)
	{
		long long int b;
		cin>>b;
		a.insert(b);
		}
	int c=a.size();
	if(c==n)
	cout<<"YES";
	else if(c!=n)
	cout<<"NO";	
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1e9+7
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;


int main() {
    int a, b, c; cin >> a >> b >> c;
    if (a+b+c>=22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define invrep(i, n) for(int i = (n)-1; i >= 0; i--)        // n-1, n-2, ..., 0
#define invREP(i, x, n) for(int i = (n)-1; i >= (x; i--)    // n-1, n-2, ..., x
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define PB push_back

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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

class UnionFind{
    public:
        vector<int> uni;
        UnionFind(int s) : uni(s, -1) { }
 
       //頂点aが所属するグループを調べる
        int root(int a)
        {
            if (uni[a] < 0) return a;
            return uni[a] = root(uni[a]);
        }
    
        //頂点aと頂点bを繋ぐ。もともと同じグループの時falseを返す
        bool connect(int a,int b)
        {
            a = root(a);
            b = root(b);
            if (a == b) return false;
    
            if (uni[a] > uni[b])
            {
                a ^= b;
                b ^= a;
                a ^= b;
            }
    
            uni[a] = uni[a] + uni[b];
            uni[b] = a;
            return true;
        }
    
        //頂点a,bが同じグループであるかを調べる
        bool isConnect(int a,int b)
        {
            return root(a) == root(b);
        }
    
        //頂点aを含むグループの頂点数を調べる
        int size(int a)
        {
            return -uni[root(a)];
        }
    
    };

    


int N, K, L; 
int p[200000], q[200000], r[200000], s[200000];
int a[300000], b[300000];

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

    map<pi, int> mp;
    UnionFind ufk(N), ufl(N);
    rep(i, K){
        cin >> p[i] >> q[i];
        p[i]--; q[i]--;
        ufk.connect(p[i], q[i]);
    }
    rep(i, L){
        cin >> r[i] >> s[i];
        r[i]--; s[i]--;
        ufl.connect(r[i], s[i]);
    }
    rep(i, N){
        a[i] = ufk.root(i);
        b[i] = ufl.root(i);
        mp[make_pair(a[i], b[i])]++;
    }
    rep(i, N){
        cout << mp[make_pair(a[i], b[i])] << " \n"[i == N - 1];
    }
}

Measured memory_bytes: 17664
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto a=readln.split.to!(int[]);

  sort(a);
  writeln(a[$-1]-a[0]);

}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) {
    cin >> a[i];
    a[i] -= i + 1;
  }
  sort(a.begin(), a.end());
  long long ans = 0;
  long long mid = a[n / 2];
  for (int i = 0; i < n; ++i) {
    ans += abs(a[i] - mid);
  }
  cout << ans << endl;
}



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

#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MP make_pair
#define PB push_back
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<string,int> PSI;

string s;
int kth;
set<string> cnt;
set<PSI> nx;
string ToStr(char cc){ string cs=""; cs=cs+cc; return cs;}
int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	cin>>s>>kth;
	for (char i='a'; i<='z' ; i++){
		cnt.clear();nx.clear();
		#ifdef che
		debug("char %s\n",ToStr(i).c_str());
		#endif
		for (int j=0; j<s.size(); j++) 
			if ( s[j]==i){
				nx.insert(MP(ToStr(s[j]), j+1));
			}
		while ( nx.size() && cnt.size()<kth){
			PSI tp = *nx.begin(); nx.erase(tp);
			cnt.insert(tp.fi);
			if ( tp.se < s.size()){
				tp.fi = tp.fi+s[tp.se++];
				nx.insert(tp);
			}
		}
		kth -= cnt.size();
		
		if ( kth==0){
			cout<< *(--cnt.end());
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s;
    cin >> s;
    vector<int> cnt(26, 0);
    for(char c: s)
        cnt[c-'a'] += 1;
    for(int i = 0; i < 26; i++) {
        if (cnt[i] % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3672
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 100000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int n, q, a[N], ps[N];
map<int, int> mp;

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> q;
	for (int i = 1; i <= q; i++) cin >> a[i];
	set<int> st;
//	if (n == 4) assert(0);
	st.insert(a[q]);
	if (q == 0){
		for (int i = 1; i <= n; i++)cout << 1 << '\n';
		return 0;
	}
	mp[a[q]] = 1;
	for (int i = q - 1; i >= 1; i--){
		while ((*st.rbegin()) > a[i]){
			int fr = *st.rbegin();
			st.erase(fr);
			int x = fr / a[i];
			if (mp[fr] < 0) assert(0);
			mp[a[i]] += mp[fr] * x;
			st.insert(a[i]);
			if (fr % a[i] != 0){
				mp[fr % a[i]] += mp[fr];
				st.insert(fr % a[i]);
			}
			mp[fr] = 0;
		}
	}
	if (st.size() == 0) assert(0);
	for (auto u:st){
		int uu = u;
		int x = ((uu - 1) % n) + 1;
		int y = uu / n;
		if (mp[uu] < 0) assert(0);
		if (uu % n == 0){
			ps[1] += y * mp[uu];
		}
		else{
			ps[1] += (y + 1)* mp[uu];
			ps[x + 1] -= (y + 1) * mp[uu];
			ps[x + 1] += y * mp[uu];
		}
	}
	for (int i = 1; i <= n; i++) ps[i] += ps[i - 1];
	for (int i = 1; i <= n; i++) cout << ps[i] << '\n';










	return 0;
}


Measured memory_bytes: 31576
N, A, B, C, D = [int(_) for _ in input().split()]
A -= 1
B -= 1
C -= 1
D -= 1
S = input()
if C > D:
    C, D = D, C
    A, B = B, A
if '##' in S[B:D] or '##' in S[A:C]:
    print('No')
elif A < B or '...' in S[A - 1:C + 2]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3636
#include <stdio.h>

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

int main()
{
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  printf("%d\n", min(a, b) + min(c, d));
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int x,d,e;
    cin >> x;
    if(x<500)
    {
        d=x/5;
        cout << 5*d << endl;
    }
    else{
        d=x/500;
        e=(x%500)/5;
        cout << (1000*d) + (e*5) << endl;
    }

    return 0;
}


Measured memory_bytes: 256