akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll =long long;

int main() {
int N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  
  int M=vec[0];
  int counter=0;
  for(int i=0;i<N;i++){
  if(M>=vec[i]){
    M=min(M,vec[i]);
    counter++;
               }

    
  }
  cout<<counter<<endl;
    
  
}


Measured memory_bytes: 1024
import java.util.ArrayList

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val D = readLine()!!.split(" ").map { it.toInt() }

    val C = Array(13) {0}
    C[0] = 1

    for (p in D) {
        C[p]++
    }

    var res = 0
    for (s in 0..(1 shl 13)) {
        val list = ArrayList<Int>()
        list.addAll(Array(C[0]) {0})
        list.addAll(Array(C[12]) {12})

        for (i in 1..11) {
            if (C[i] == 0) {
                continue
            }

            when {
                C[i] > 1 -> {
                    list.add(i)
                    list.addAll(Array(C[i] - 1) {24 - i})
                }
                ((s shr i) and 1) == 1 -> {
                    list.add(i)
                }
                else -> {
                    list.add(24 - i)
                }
            }
        }

        var h = 24
        for (i in 0 until list.size) for (j in (i + 1) until list.size) {
            val d = Math.abs(list[i] - list[j])
            h = Math.min(h, Math.min(d, 24 - d))
        }
        res = Math.max(res, h)
    }

    println(res)
}


Measured memory_bytes: 42956
num_0 = int(input())
num_1 = input()
count = 0
count_i = 0

for i in range(0,num_0):
  if num_1[i] == "A":
    count_i = 1
  elif count_i == 1 and num_1[i] == "B":
    count_i = 2
  elif count_i == 2 and num_1[i] == "C":
    count = count + 1
    count_i = 0
  else:
    count_i = 0
    
print(count)

Measured memory_bytes: 3060
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <memory>
#include <algorithm>

typedef long long ll;

using namespace std;

class BMixJuice {
public:
    void solve(std::istream &in, std::ostream &out) {
        ll n, k;
        in >> n >> k;
        ll p[n];
        for (int i = 0; i < n; ++i) {
            in >> p[i];
        }
        sort(p, p + n);
        ll tot = 0;
        for (int i = 0; i < k; ++i) {
            tot += p[i];
        }
        out << tot << endl;
    }
};


int main() {
	BMixJuice solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3168
from queue import PriorityQueue

class State:
  def __init__(self,index,time):
    self.index=index
    self.time=time
  def __lt__(self,state):
    return self.time>state.time

while 1:
  try: n=int(input())
  except: break
  a=list(map(int,input().split()))
  
  ts=[float("inf")]*n
  vis=[False]*n
  pq=PriorityQueue()
  for i in range(n):
    if a[i]==0:
      pq.put(State(i,int(1e9)))
  
  while pq.qsize():
    cur=pq.get()
    if cur.index<0 or n<=cur.index or vis[cur.index] or cur.time<0: continue
    vis[cur.index]=True
    if a[cur.index]<0:
      cur.time=min(cur.time,-a[cur.index]-1)
    ts[cur.index]=cur.time
    pq.put(State(cur.index-1,cur.time-1))
    pq.put(State(cur.index+1,cur.time-1))
  
  res=0
  for i in range(n):
    if a[i]>0 and vis[i]:
      res+=min(a[i],ts[i]+1)
  print(res)

Measured memory_bytes: 88360
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    n = kwargs["n"]
    m = kwargs["m"]
    A = kwargs["A"]

    sumA = sum(A)
    count = 0
    res = "No"

    for i in range(n):
        if A[i] * 4 * m >= sumA:
            count += 1

        if count == m:
            res = "Yes"

    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    #kwargs["n"] = cin[0]
    #kwargs["n"], kwargs["k"] = cin
    #kwargs["n"] = [int(i) for i in cin][0]
    kwargs["n"], kwargs["m"] = [int(i) for i in cin]
    cin = input().split()
    kwargs["A"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Measured memory_bytes: 21820
#include <bits/stdc++.h>
#include<vector>
using namespace std;
int main()
{
    int N;
    cin>>N;
    int count1=0,count2=0,count3=0,count4=0;
    string s;
    vector<string>v;
    for(int i=0;i<N;i++){
        cin>>s;
        v.push_back(s);
    }
    count1=count(v.begin(),v.end(),"AC");
    count2=count(v.begin(),v.end(),"WA");
    count3=count(v.begin(),v.end(),"TLE");
    count4=count(v.begin(),v.end(),"RE");
    cout<<"AC"<<" "<<"x"<<" "<<count1<<endl;
    cout<<"WA"<<" "<<"x"<<" "<<count2<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<count3<<endl;
    cout<<"RE"<<" "<<"x"<<" "<<count4<<endl;



    return 0;
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int n;
    cin >> n;
    int c, prev = 0;
    vs32 pos(200000 + 1, -1);
    vs64 dp(n + 1);
    dp[0] = 1;
    rep (i, n)
    {
        cin >> c;
        if (c == prev || pos[c] == -1)
        {
            dp[i + 1] = dp[i];
        }
        else
        {
            dp[i + 1] = (dp[i] + dp[pos[c]]) % MOD;
        }
        pos[c] = i + 1;
        prev = c;
    }

    cout << dp[n] << "\n";
    return 0;
}



Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        int[] Top = new int[Consts.TOPNUM];
        int Elevation;
        for(int i = 0; i < Consts.MAX_MOUNTAINS; i++){
            Elevation = int.Parse(Console.ReadLine());
            for(int n = 0; n < Consts.TOPNUM; n++){
                if(Top[n] < Elevation){
                    for(int n2 = Consts.TOPNUM - 1; n2 > n; n2--){
                        Top[n2] = Top[n2 - 1];
                    }
                    Top[n] = Elevation;
                    break;
                }
            }
        }
        for(int i = 0; i < Consts.TOPNUM; i++)
            Console.WriteLine(Top[i]);
    }
}

public static class Consts{
    public static int MAX_MOUNTAINS = 10;
    public static int TOPNUM = 3;
}

Measured memory_bytes: 9040
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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


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

    if(su >= h){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }



    return 0;
}


Measured memory_bytes: 1024
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll N,W;cin>>N>>W;
    ll v[N],w[N];REP(i,N)cin>>v[i]>>w[i];
    ll dp[N+1][W+1]={};
    REP(i,N){
        REPS(j,W){
            if(w[i]<=j){
                dp[i+1][j]=max(dp[i+1][j],dp[i][j-w[i]]+v[i]);
            }
            dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
        }
    }
    cout<<dp[N][W]<<"\n";
}


Measured memory_bytes: 10964
n = int(input())
A = list(map(int, input().split()))
ans = 0
for i in A:
  if i % 4 == 0:
    ans += 1
  elif i % 2 != 0:
    ans -= 1
if n % 2 != 0:
  ans += 1

print("Yes" if ans >= 0 else "No")

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    cin>>n;
    set<char> s;
    char c;
    for (i=0;i<n;i++)
    {
        cin>>c;
        s.insert(c);
    }
    if (s.size()==3)
        cout<<"Three\n";
    else
        cout<<"Four\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n, t;
    scanf("%d%d", &n, &t);
    lint a[n];
    rep(i, n) scanf("%lld", &a[i]);

    lint p[n], mp = 0;
    multiset<int> S;
    rep(i, n) S.insert(a[i]);
    rrep(i, n){
        p[i] = a[i] - *S.begin();
        chmax(mp, p[i]);
        S.erase(S.find(a[i]));
    }
    int ans = 0;
    rep(i, n) ans += (p[i] == mp);
    printf("%d\n", ans);
}

Measured memory_bytes: 6528
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int N, M;

int solve(string tar, map<string, int> &item, map<string, vector<string> > &recipe){
  if(recipe.find(tar) == recipe.end()) return item[tar];
  int res = item[tar], sum = 0;
  REP(i, recipe[tar].size()) sum += solve(recipe[tar][i], item, recipe);
  return min(res, sum);
}

int main() {
  while(cin >>N && N){
    map<string, vector<string> > recipe;
    map<string, int> item;
    REP(i, N){
      string s; int n; cin >>s >>n;
      item[s] = n;
    }
    cin >>M;
    REP(i, M){
      string s; cin >>s;
      int n; cin >>n;
      recipe[s] = vector<string>(n);
      REP(j, n){
        string t; cin >>t;
        recipe[s][j] = t;
      }
    }
    string tar; cin >>tar;
    cout <<solve(tar, item, recipe) <<endl;
  }
  return 0;
}

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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

vector<int> G[100000+5];
int visited[100000+5];

Int dfs(int K, int now, int from) {
    int color_num;
    if(from == -1)
        color_num = K - 1;
    else
        color_num = K-2;
    if(K < G[now].size())
        return 0;

    Int case_num = 1;
    for(auto e: G[now])
    {
        if(e == from)
            continue;
        case_num *= color_num;
        color_num--;
        case_num %= MOD;
    }
    for(auto e: G[now]) {
        if(e == from)
            continue;
        case_num *= dfs(K,e,now);
        case_num %= MOD;
    }

    return case_num;
}

int main(void) {
    int N,K;

    cin>>N>>K;

    for(int i = 1;i < N;i++) {
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    cout<<(K*dfs(K,1,-1))%MOD<<endl;

    return 0;
}


Measured memory_bytes: 11520
#include <stdio.h>

//Istiyak Hossain

int main()
{
    int a, b, i, j;

    scanf("%d %d", &a, &b);

    while(a | b)
    {
        for(i = 0; i < a; i++)
        {
            for(j = 0; j < b; j++)
            {
                if((j % 2 == 0) ^ (i % 2 == 0) ){
                    printf(".");
                }
                else {
                    printf("#");
                }

            }
            printf("\n");
        }
        printf("\n");
        scanf("%d %d", &a, &b);
    }

    return 0;
}



Measured memory_bytes: 1996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];
    int pos = -1;
    ll now = 0, ans = 0;
    rep(i, N){
        if(i > 0) now ^= A[i-1];
        while(pos+1 < N && (now^A[pos+1]) == now+A[pos+1]){
            pos++;
            now ^= A[pos];
        }
        ans += pos+1-i;
    }
    cout << ans << endl;
}

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

bool isPrime(int n){
	if(n==2) return true;
	else if(n==1 or n%2==0) return false;
	else{
		for(int i=3; i<=sqrt(n); i+=2){
			if(n%i==0) return false;
		}
	}
	return true;
}

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

	int n;
	cin >> n;
	if(isPrime(n)){
		cout << n;
		return 0;
	}
	else{
		while(true){
			n++;
			if(isPrime(n)){
				cout << n;
				return 0;
			}
		}

	}
	return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;

int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);

  int n, u, v;
  cin >> n >> u >> v;
  --u; --v;
  swap(u,v);

  vvi g(n);
  rep(i,0,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].pb(b);
    g[b].pb(a);
  }

  if(u==v) return cout << 0 << endl, 0;

  vi d(n, -1), ok(n);
  queue<tuple<int,int,int>> q;
  q.push(make_tuple(0,0,u));
  while (not q.empty()) {
    int dist, good, k;
    tie(dist, good, k) = q.front(); q.pop();
    if (d[k] != -1) continue;
    if (k==v) good=1;
    d[k] = dist;
    ok[k] = good;
    trav(l, g[k]) {
      tuple<int,int,int> nxt = make_tuple(dist+1, good, l);
      q.push(nxt);
    }
  }

  vi d1(n,-1);
  queue<pii> qu;
  qu.push({0,v});
  while (not qu.empty()) {
    int dist, k;
    tie(dist, k) = qu.front(); qu.pop();
    if (d1[k] != -1) continue;
    d1[k] = dist;
    trav(l,g[k]) qu.push({dist+1, l});
  }

  int ans = 0;
  rep(i,0,n) {
    if (d1[i] < d[i]) ans = max(ans, d[i]-1);
  }
  cout << ans << endl;
}

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

int main(){
    int N,M; cin>>N>>M;
    int k[11],s[11][11],p[11];
    for(int i=0;i<M;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            cin>>s[i][j];
            s[i][j]--;
        }
    }
    for(int i=0;i<M;i++){
        cin>>p[i];
    }
    int ans=0;
    for(int bit;bit<(1<<N);bit++){  //bit全探索
        int on=0;
        for(int i=0;i<M;i++){   //電球毎
            int cnt=0;
            for(int j=0;j<k[i];j++){    //スイッチカウント
                if(bit>>s[i][j]&1){ //onのスイッチ
                    cnt++;
                }
            }
            if(cnt%2==p[i]){    //電球piがつく
                on++;   //ついた電球の数
            }
        }
        if(on==M){
            ans++;  //ついた電球の数が全電球と同じ
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stack>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

string S;
stack<int> stk; 
int x, y, cnt = 0;

void solve(){
    stk.push(S[0]);
    
    int N = S.size();

    for(int i = 1; i < N; i++){
        if(stk.empty() || S[i]==stk.top())
            stk.push(S[i]);
        else{
            if(!stk.empty()){
                stk.pop();
                cnt += 2;
            }
        }
    }
    cout << cnt << endl;
}

int main(){
    cin >> S;

    solve();
}


Measured memory_bytes: 768
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
const static ll MOD = 1e9 + 7;
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;

int main() {
	ll N, K; cin >> N >> K;
	ll a = N % K;
	ll b = abs(K - a);
	cout << min(a, b) << endl;
}


Measured memory_bytes: 256
import numpy as np

n = int(input())
S = [list(input()) for i in range(n)]

alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
aa = [[0]*len(alpha) for i in range(n)]

for i in range(n):
    for j in S[i]:
        a = alpha.index(j)
        aa[i][a] += 1

ans = []

aa = np.array(aa)

for i in range(len(alpha)):
    x = min(aa[:,i])
    ans.append(x)

ans2 =[]
for i in range(len(alpha)):
    ans2.append(alpha[i]*ans[i])

print("".join(ans2))


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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

int n,m;
vector<int> ans;
int sum;
int ma;
int ki=-1;

int gcd(int a,int b) { return b ? gcd(b,a%b) : a; }

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

	//FOR(N,3,20001){
	//sum=0;
	//ans.clear();
	//ki=-1;
	//ma=0;
	cin>>n;

	//n=N;

	ans.pb(3);ans.pb(5);
	sum=8;

	int m=n-3;
	for(int i=2;i<=30000;i++) {
		if(m==0) break;
		if(i%2==0) {
			ans.pb(i);
			sum+=i;
			ma=i;
			m--;
		}
		else if(i%3==0||i%5==0) {
			if(i==3||i==5) continue;
			if(ki==-1) {
				ki=i;
			}
			else {
				if(m==1) {
					sum-=ans.back();
					ans.pop_back();
					m++;
				}
				ans.pb(ki);ans.pb(i);
				sum+=ki+i;
				ki=-1;
				ma=i;
				m-=2;
			}
		}
	}
	int lst=(30-sum%30);
	while(lst<=ma) lst+=30;
	ans.pb(lst);
	sum+=lst;

	//set<int> st;

	//for(auto x:ans) {
		//if(gcd(sum,sum-x)==1) cout<<N<<endl;
		//st.insert(x);
	//}

	//if((int)st.size()!=N) cout<<"st "<<N<<endl;

	for(auto x:ans) cout<<x<<' ';
	cout<<endl;
	//if(N%1000==0) cout<<"N="<<N<<endl;
	//}
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  int N;
  int K;
  cin >> N >> K;
  bool Flags[N];
  int result;
  for (int i = 0; i < N; i++) Flags[i]=false;
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int A;
      cin >> A;
      if (!Flags[A-1]) {
        Flags[A-1]= true;
      }
    }
  }
  result = std::count(Flags, Flags+(sizeof(Flags)), false);
  cout << result << endl;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b ;
  int c;
  c = a % 100;
  if( a%2 == 1 && b%2 == 1){
    cout << "Odd" << endl; 
  }
  else{
    cout << "Even" << endl;     
  }
}

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


using namespace std;


#ifdef zxc

#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = long double;
const ld EPS = 1e-8;
const ll MOD = 1e9 + 7;
const ld PI = 3.141592653589793;
const int maxn = 10001;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

signed main() {
#ifdef zxc
    mt19937 mt(228);
//    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
//            freopen("", "r", stdin);
//        freopen("hack.out", "w", stdout);
#endif
    fast_io();
    cout.precision(10);
    cout << fixed;
    auto start = chrono::steady_clock::now();

    string s;
    cin >> s;
    bool ok = s[2] == s[3] && s[4] == s[5];
    cout << (ok ? "Yes" : "No");
    auto end = chrono::steady_clock::now();
    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int W,H, f[100][100];
bool memo[100][100];
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

void dfs(int x, int y, int c)
{
	memo[x][y]=1;
	
	for(int i=0; i<4; i++)
	{
		int tx=x+dx[i], ty=y+dy[i];
		if(tx<0||ty<0||tx>=W||ty>=H) continue;
		if(f[tx][ty]!=c) continue;
		if(memo[tx][ty]) continue;
		dfs(tx,ty,c);
	}
}

int main()
{
	while(scanf("%d%d", &W,&H), (W||H))
	{
		int xs,ys,xg,yg,N;
		scanf("%d%d%d%d%d", &xs,&ys,&xg,&yg,&N);
		xs--;ys--;xg--;yg--;
		while(N--)
		{
			int c,d,x,y;
			scanf("%d%d%d%d", &c,&d,&x,&y);
			x--; y--;
			
			int w=2, h=4;
			if(d==0) swap(w,h);
			for(int i=y; i<y+h; i++)
			for(int j=x; j<x+w; j++)
				f[j][i]=c;
		}
		
		memset(memo,0,sizeof(memo));
		dfs(xs,ys,f[xs][ys]);
		
		puts(memo[xg][yg]?"OK":"NG");
	}
}

Measured memory_bytes: 0
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/*Used path compression technique*/
/*-------------------------------------*/
//ll finds(ll a)
//{
//    vector<ll>vec;
//    while(parent[a]>0){
//        vec.pb(a);
//        a=parent[a];
//    }
//    for(int i=0;i<vec.size();i++)parent[vec[i]]=a;
//    return a;
//}
//void unions(ll a,ll b)
//{
//    parent[a]+=parent[b];
//    parent[b]=a;
//}
/*------------------------------*/
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    ll x;
    cin>>x;
    if(x)cout<<"0"<<endl;
    else cout<<"1"<<endl;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int cntr = n / r + 1, cntg = n / g + 1;
    int ans = 0;
    rep(i, cntr) {
        rep(j, cntg) {
            int value = n - r * i - g * j;
            if(value >= 0 && value % b == 0) ans++; 
        }
    } 
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func chatInACircle(a []int) int {
	sort.Slice(a, func(i, j int) bool {
		return a[i] > a[j]
	})
	if len(a) == 2 {
		return a[0]
	}

	m := a[0]
	a = a[1:]

	for i := 0; i < len(a) - 1; i++ {
		m += a[i/2]
	}

	return m
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	
	ans := chatInACircle(a)
	fmt.Println(ans)
}

Measured memory_bytes: 6512
# https://atcoder.jp/contests/abc104/tasks/abc104_d
# in
# ????C?????B??????A???????
# out
# 979596887
# in
# ABCBC
# 3

MOD = (10**9) + 7
dp_a = 0
dp_ab = 0
dp_abc = 0

dp_none = 1

a = 'A'
b = 'B'
c = 'C'
gets.chomp.chars do |s|
  if s == a
    dp_a = (dp_a + dp_none)%MOD
  elsif s == b
    dp_ab = (dp_ab + dp_a)%MOD
  elsif s == c
    dp_abc = (dp_abc + dp_ab)%MOD
  else
    dp_abc = (dp_abc * 3 + dp_ab)%MOD
    dp_ab = (dp_ab * 3 + dp_a)%MOD
    dp_a = (dp_a * 3 + dp_none)%MOD
    dp_none = (dp_none * 3)%MOD
  end
end

p dp_abc

Measured memory_bytes: 2044
def generate (n)
    $P = Array.new(n, false)
    i = 3
    until i > n
        $P[i] = true
        i += 2
    end
    i = 3
    $P[2] = true
    until i > n
        if ! $P[i]
            i += 2
            next
        end
        j = i + i
        until j > n do
            $P[j] = false
            j += i
        end
        i += 2
    end
end

def is_prime (n)
    return $P[n] ? 1 : 0
end

def solve (n)
    return (1..n).inject(0) { |sum, i| sum + is_prime(i) }
end

generate 1000000 
while s = gets do
    n = s.to_i
    p solve n
end

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S.at(i).at(j);
    }
  }
  vector<vector<int>> DP(H, vector<int>(W, 1e9));
  DP.at(0).at(0) = (S.at(0).at(0) == '#') ? 1 : 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (i) {
        int flip = (S.at(i - 1).at(j) == '.' && S.at(i).at(j) == '#');
        DP.at(i).at(j) = min(DP.at(i).at(j), DP.at(i - 1).at(j) + flip);
      }
      if (j) {
        int flip = (S.at(i).at(j - 1) == '.' && S.at(i).at(j) == '#');
        DP.at(i).at(j) = min(DP.at(i).at(j), DP.at(i).at(j - 1) + flip);
      }
    }
  }
  cout << DP.at(H - 1).at(W - 1) << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 2e5 + 10;
const int M = 4005;
const int mod = 1e9 + 7;

int n, m, a[N], b[N];
LL inv[M << 1], fac[M << 1], fav[M << 1], dp[M][M];

void init() {
	fac[0] = fav[0] = 1;
	inv[1] = fac[1] = fav[1] = 1;
	for (int i = 2; i < M << 1; ++i) {
		inv[i] = -mod / i * inv[mod % i] % mod + mod;
		fac[i] = fac[i - 1] * i % mod;
		fav[i] = fav[i - 1] * inv[i] % mod;
	}
}

inline void Add(LL &x, LL y) {
	x += y;
	if (x >= mod) x -= mod;
}

inline LL C(int x, int y) {
	if (x < 0 || x < y) return 0;
	return fac[x] * fav[y] % mod * fav[x - y] % mod;
}

int main() {
	init();
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d", &a[i], &b[i]);
		dp[-a[i] + 2001][-b[i] + 2001]++;
	}
	for (int i = 1; i < M - 1; ++i) {
		for (int j = 1; j < M - 1; ++j) {
			Add(dp[i][j + 1], dp[i][j]);
			Add(dp[i + 1][j], dp[i][j]);
		}
	}
	LL ans = 0;
	for (int i = 1; i <= n; ++i) {
		Add(ans, dp[a[i] + 2001][b[i] + 2001]);
		ans -= C(a[i] * 2 + b[i] * 2, a[i] * 2);
		if (ans < 0) ans += mod;
	}
	cout << ans * (mod + 1) / 2 % mod << endl;
	return 0;
}


Measured memory_bytes: 127232
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
        int w = 0;
      if(b > a){
        w = a;
        a = b;
        b = w;
      }
      if(c > a){
        w = a;
        a = c;
        c = w;
      }
      if(c > b){
        w = b;
        b = c;
        c = w;
      }
      if(a >=b && c >= b){
        w = Integer.parseInt(String.valueOf(a)+String.valueOf(c));
		System.out.println(w+b);
        System.exit(0);
      }
      if(a >=c && b >= c){
        w = Integer.parseInt(String.valueOf(a)+String.valueOf(b));
		System.out.println(w+c);
        System.exit(0);
      }
      if(b >=a && c >= b){
        w = Integer.parseInt(String.valueOf(b)+String.valueOf(c));
		System.out.println(w+a);
        System.exit(0);
      }
	}
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll dp[105][301010];

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

    const ll INF = (1ll<<60);
    REP(i, 105)REP(j, 301010) dp[i][j] = INF;
    dp[0][0] = 0;

    ll N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];

    REP(i, N){
    	REP(j, 101010){
    		if(dp[i][j] == INF) continue;
    		dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
    		dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j]+w[i]);
    	}
    }

    ll res = -1;
    REP(i, 101010){
    	if(dp[N][i]<=W) res= max(res, (ll)i);
    } 
    cout << res << endl;
    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int X; cin >> X;
	if (X >= 30) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		String[] array = str.split(" ");
		char X = array[0].charAt(0);
		char Y = array[1].charAt(0);

		char ans = '=';
		if(X < Y)
			ans = '<';
		if(X > Y)
			ans = '>';
		System.out.println(ans);
	}


}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-9;
const ll MOD=1e9+7;
struct Graph{
    struct edge{int to;ll cost;};
    int siz;
    bool dir;
    vector<vector<edge>> G;
    Graph(){}
    Graph(int siz,bool dir):siz(siz),dir(dir){
        G.resize(siz+1);
    }
    void resize(int nsiz,bool ndir){
        dir=ndir;
        siz=nsiz;
        G.resize(siz+1);
    }
    void add_edge(int u,int v){
        assert(0<=u&&u<siz);assert(0<=v&&v<siz);
        G[u].push_back({v,0});
        if(!dir)G[v].push_back({u,0});
    }
    void add_edge(int u,int v,ll cost){
        assert(0<=u&&u<siz);assert(0<=v&&v<siz);
        G[u].push_back({v,cost});
        if(!dir)G[v].push_back({u,cost});
    }
    vector<edge>& operator[](const int& idx){
        assert(0<=idx&&idx<siz);
        return G[idx];
    } 
};
struct SCComponents{
    int n;
    Graph G,rG; 
    vector<int> order,vis,cmp;
    SCComponents(int n):n(n),vis(n),cmp(n,-1){
        G.resize(n,true);
        rG.resize(n,true);
    }
    void add_edge(int u,int v){
        G.add_edge(u,v);
        rG.add_edge(v,u);
    }
    void dfs(int i){
        if(vis[i])return;
        vis[i]=1;
        for(auto e:G[i])dfs(e.to);
        order.push_back(i);
    }
    void rdfs(int i,int k){
        if(cmp[i]!=-1)return;
        cmp[i]=k;
        for(auto e:rG[i])rdfs(e.to,k);
    }
    void build(){
        for(int i=0;i<n;i++)dfs(i);
        reverse(order.begin(),order.end());
        int idx=0;
        for(auto i:order)if(cmp[i]==-1)rdfs(i,idx++);
    }
};
int main(){
    int n,m;cin>>n>>m;
    SCComponents scc(n);
    while(m--){
        int u,v;cin>>u>>v;
        scc.add_edge(u,v);
    }
    scc.build();
    int q;cin>>q;
    while(q--){
        int u,v;cin>>u>>v;
        cout<<(scc.cmp[u]==scc.cmp[v]?1:0)<<endl;
    }
}



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

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i=0;i<n;i++) cin >> a[i];
  for (int i=0;i<n;i++) cin >> b[i];
  vector<int> acount(n+1,0);
  vector<int> bcount(n+1,0);
  for (int i=0;i<n;i++) {
    acount[a[i]]++;
    bcount[b[i]]++;
  }
  bool ok = true;
  for (int i=1;i<=n;i++) {
    if (acount[i]+bcount[i] > n) {
      ok = false;
    }
  }
  if(!ok) cout << "No" << endl;
  else {
    vector<int> asum(n+1,0);
    vector<int> bsum(n+1,0);
    for (int i=1;i<=n;i++) {
      asum[i] = asum[i-1]+acount[i];
      bsum[i] = bsum[i-1]+bcount[i];
    }
    int rot = 0;
    for (int i=1;i<=n;i++) {
      rot = max(rot,asum[i]-bsum[i-1]);
    }
    cout << "Yes" << endl;
    for(int i=0;i<n;i++) {
      if (i != 0) cout << ' ';
      cout << b[(i-rot+n)%n];
    }
    cout << endl;
  }
}

Measured memory_bytes: 7868
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            String a = sc.next();
            if("abc".equals(a) || "acb".equals(a) || "bac".equals(a) || "bca".equals(a) || "cab".equals(a) || "cba".equals(a)){
              System.out.println("Yes");
            } else {
              System.out.println("No");
            }
            
            }
}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>
#include<string>

using namespace std;

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    int cnt = 0;
    int cnt2 = 0;
    int res = 0;
    if(x % (y+z) == z){
        cout << x / (y+z) << endl;
    }else{
        cout << x / (y+z)-1 << endl;
    }
}

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

using namespace std;

typedef long long ll;

int main(void) {
  ll H, N;
  cin >> H >> N;
  
  vector<int> A(N);
  vector<int> B(N);
  
  for(int i=0; i<N; ++i) {
    cin >> A[i] >> B[i];
  }
  
  vector<ll> dp(H+1);
  
  for(int i=1; i<=H; ++i) {
    ll mm = INT_MAX;
    bool found = false;
    for(int j=0; j<N; ++j) {
      //if(i - A[j] >= 0) {
        mm = min(mm, dp.at(max(i - A[j], 0)) + B[j]);
        found = true;
      //}
    }
    //if(found) {
      dp[i] = mm;
    //}
  }
  
  cout << dp.at(H) << endl;
  
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 10y - x = 10b

int solve(const std::vector<int>& x, const std::vector<int>& y, const std::vector<char>& z) {
	const int n = x.size();

	std::map<int, std::vector<int>> vec;
	for(int i = 0; i < n; i++) vec[y[i] - x[i]].push_back(i);

	int ans = 1 << 30;
	for(auto& e: vec) {
		auto& v = e.second;
		sort(begin(v), end(v), [&](int i, int j) { return x[i] < x[j]; });

		int right = -1;
		for(int idx: v) {
			if(z[idx] == 'R') right = idx;
			if(z[idx] == 'D' and ~right) ans = std::min(ans, std::abs(x[idx] - x[right]) * 10);
		}

		reverse(begin(v), end(v));
		int left = -1;
		for(int idx: v) {
			if(z[idx] == 'L') left = idx;
			if(z[idx] == 'U' and ~left) ans = std::min(ans, std::abs(x[idx] - x[left]) * 10);
		}
	}
	return ans;
}

int main() {
	int n; scanf("%d", &n);
	std::vector<int> x(n), y(n);
	std::vector<char> z(n);
	for(int i = 0; i < n; i++) scanf("%d%d %c", &x[i], &y[i], &z[i]);

	int ans = 1 << 30;
	for(int l = 0; l < 2; l++) {
		for(int i = 0; i < n; i++) {
			x[i] = -x[i];
			if(z[i] == 'R') z[i] = 'L';
			else if(z[i] == 'L') z[i] = 'R';
		}

		ans = std::min(ans, solve(x, y, z));
	}

	for(int l = 0; l < 2; l++) {
		std::map<int, std::vector<int>> vec;
		for(int i = 0; i < n; i++) vec[y[i]].push_back(i);

		for(auto& e: vec) {
			auto& v = e.second;
			sort(begin(v), end(v), [&](int i, int j) { return x[i] < x[j]; });

			int right = -1;
			for(int idx: v) {
				if(z[idx] == 'R') right = idx;
				if(z[idx] == 'L' and ~right) ans = std::min(ans, std::abs(x[idx] - x[right]) * 5);
			}
		}

		for(int i = 0; i < n; i++) {
			std::swap(x[i], y[i]);

			if(z[i] == 'U') z[i] = 'R';
			else if(z[i] == 'D') z[i] = 'L';
			else z[i] = '.';
		}
	}

	if(ans == 1 << 30) printf("SAFE\n");
	else printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 26728
n = int(input())
a = list(map(int,input().split()))
b = [abs(i) for i in a]
b.sort()
f = 0
for i in a:
     if i<0:
          f = (f+1)%2
if f == 0:
     print(sum(b))
else:
     print(sum(b)-2*b[0])

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];

  auto check = [&](const vector<string>& t) {
    rep(i, n) rep(j, n) {
      if(t[i][j] != t[j][i]) return false;
    }
    return true;
  };

  int ans = 0;
  rep(k, n) {
    vector<string> t;
    rep(i, n) t.push_back(s[(i+k)%n]);
    if(check(t)) ans += n;
  }

  vector<string> h(n);
  rep(i, n) rep(j, n) h[i] += s[j][i];

  rep(k, n) {
    vector<string> g;
    rep(i, n) g.push_back(h[(i+k)%n]);
    if(check(g)) ans += n;
  }

  cout << ans/2 << endl;

  return 0;
}


Measured memory_bytes: 512
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/abc145/tasks/abc145_e
# E - All-you-can-eat
"""
DP1[i][j] =the maximum sum of deliciousness of dishes, which are chosen from 1st- to i-th dishes,
such that he can finish them in j minutes

still WA!!!

"""


def gcd(a, b):
    if a < b:
        return gcd(b, a)
    elif a % b:
        return gcd(b, a % b)
    else:
        return b


N = gi()
A = [0] * N
ls = [0] * N
rs = [0] * N

for i in range(N):
    A[i] = gi()

ls[0] = A[0]
for i in range(1, N):
    ls[i] = gcd(ls[i - 1], A[i])
rs[N - 1] = A[N - 1]
for i in range(N - 2, -1, -1):
    rs[i] = gcd(rs[i + 1], A[i])

ans = max(ls[N - 2], rs[1])

for mid in range(1, N - 1):
    ans = max(ans, gcd(ls[mid - 1], rs[mid + 1]))

print(ans)


Measured memory_bytes: 27732
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;
 
using ll = long long;
 
//constant
const double EPS = 1e-10;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()
 
//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;
 
// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }
 
// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
 
// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
 
 
 
 
// ***************************************
 
int cnt = 0;
int K;
 
void rec(int keta, string S){
    if (keta == 1){
        cnt++;
        if (cnt == K) {
            cout << S << endl;
            exit(0);
        }
        return;
    }
 
    ll x = S[S.size() - 1] - '0';
    FOR(y, max<ll>(x - 1, 0), min<ll>(x + 2, 10)){
        rec(keta-1, S + to_string(y));
    }
}
 
 
int main(){
 
    cin >> K;
 
    FOR(keta, 1, 100){
        FOR(x, 1, 10) rec(keta, to_string(x));
    }
 
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
d = Array.new(n){gets.split.map(&:to_i)}

ans = 'No'

(n-2).times{|i|
  if d[i][0] == d[i][1]
      if d[i+1][0] == d[i+1][1]
        if d[i+2][0] == d[i+2][1]
          ans = 'Yes'
        end
      end
  end
  }
puts ans

Measured memory_bytes: 14360
#include <iostream>

using namespace std;

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    bool flg=true;
    if (x-r < 0 || x+r > W) {
        flg = false;
    }
    if (y-r < 0 || y+r > H) {
        flg = false;
    }
    
    if (flg) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3108