akhauriyash/Code-Regression huggingface dataset:
// Do you knOW what it feels like?

		// To be TorTured by your own MinD?
	
	// I don't wanna feel the PAIN.

// I BeG you to KILL me, pleASE...

#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Os")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=4e2+10, lg=22, mod=1e9+7, inf=1e18;

ll n,m,t,a[50],ans[100];

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n; n++;
	for(;n>1;n>>=1) m+=(a[++t]=n&1);
	ll l=m+1,r=m;
	for(int i=t,j=0;i;i--){
		ans[++r]=++j;
		if(a[i]) ans[--l]=++j;
	}
	cout<<r*2<<endl;
	for(int i=1;i<=r;i++) cout<<ans[i]<<' ';
	for(int i=1;i<=r;i++) cout<<i<<' ';

	return 0;
}


















Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <stdint.h>

unsigned long long int price[4];
unsigned long long int n;

int main() {
	for(int i = 0; i < 4; i++) {
		scanf("%llu", &price[i]);
	}
	scanf("%llu", &n);
	if(n == 1) {
		price[0] *= 4;
		price[1] *= 2;

		unsigned long long int min = 1844674407370955161;
		for (int i = 0; i < 3; i++) {
			if(min > price[i]) {
				min = price[i];
			}
		}
		printf("%llu\n", min);
	}
	else {
		price[0] *= 8;
		price[1] *= 4;
		price[2] *= 2;

		unsigned long long int min = 1844674407370955161;
		for(int i = 0; i < 4; i++) {
			if(min > price[i]) {
				min = price[i];
			}
		}

		if(n % 2 == 0) {
			//余り0
			printf("%llu\n", n / 2 * min);
		}
		else {
			unsigned long long int min_new = 1844674407370955161;
			for (int i = 0; i < 3; i++) {
				if(min_new > price[i]) {
					min_new = price[i];
				}
			}
			printf("%llu\n", n / 2 * min + min_new / 2);
		}
	}
	return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX_N 12
#define MAX_Q 16
#define MAX_K 101

using namespace std;

typedef pair<string,int> si;

typedef unsigned long long ull;

struct Edge{
  int to,dist;
  Edge(int to=IINF,int dist=IINF):to(to),dist(dist){}
};

struct Data{
  int cur,dist;
  ull bitmask;
  Data(int cur=IINF,int dist=IINF,ull bitmask=0):cur(cur),dist(dist),bitmask(bitmask){}
  bool operator < (const Data& data)const{ return dist > data.dist; }
};

const string N = "impossible";

int n,q,m,k[MAX_N];
si input_tmp[MAX_N][MAX_K];
int min_value[MAX_Q],min_cost,mindist[MAX_N][(1<<MAX_Q)];
vector<Edge> G[MAX_N];
ull supermarket_merchandise[MAX_N];
bool error;

inline void input(){

  rep(i,n){
    cin >> k[i];
    rep(j,k[i])cin >> input_tmp[i][j].first >> input_tmp[i][j].second;
  }

  map<string,int> getIndex;
  string line;
  int dex = 0;
  cin >> q;
  rep(i,q){
    cin >> line;
    if( getIndex.find(line) == getIndex.end() ) getIndex[line] = dex++;
    min_value[i] = IINF;
  }

  rep(i,n)rep(j,k[i]){
    if( getIndex.find(input_tmp[i][j].first) == getIndex.end() )continue;
    int index = getIndex[input_tmp[i][j].first];
    min_value[index] = min(min_value[index],input_tmp[i][j].second);
  }

  min_cost = 0;
  rep(i,dex){
    if( min_value[i] == IINF ) error = true;
    min_cost += min_value[i];
  }
  rep(i,n+1)G[i].clear(),supermarket_merchandise[i] = 0ULL;

  rep(i,n)rep(j,k[i]){
    if( getIndex.find(input_tmp[i][j].first) == getIndex.end() )continue;
    int index = getIndex[input_tmp[i][j].first];
    if( min_value[index] != input_tmp[i][j].second ) continue;
    supermarket_merchandise[i+1] |= (1<<index);
  }

  cin >> m;
  rep(i,m){
    int s,t,d;
    cin >> s >> t >> d;
    G[s].push_back(Edge(t,d));
    G[t].push_back(Edge(s,d));
  }

}

inline void dijkstra(){

  rep(i,n+1)rep(j,(1<<q))mindist[i][j] = IINF;
  mindist[0][0] = 0;
  priority_queue<Data> Q;
  Q.push(Data(0,0,0));
  while(!Q.empty()){

    Data data = Q.top(); Q.pop();
    int cur = data.cur;
    ull c_bitmask = data.bitmask;

    if( mindist[cur][c_bitmask] < data.dist ) continue;

    rep(i,G[cur].size()){
      int next = G[cur][i].to, next_dist = G[cur][i].dist + data.dist;
      ull next_bitmask = c_bitmask | supermarket_merchandise[next];
      if( mindist[next][next_bitmask] > next_dist ){
	mindist[next][next_bitmask] = next_dist;
	Q.push(Data(next,next_dist,next_bitmask));
      }
    }

  }

  if( mindist[0][(1<<q)-1] == IINF ) cout << N << endl;
  else                               cout << min_cost << ' ' << mindist[0][(1<<q)-1] << endl;

}

int main(){
  while(cin>>n,n){
    error = false;
    input();
    if( error ){
      cout << N << endl;
      continue;
    }
    dijkstra();
  }
  return 0;
}

Measured memory_bytes: 2480
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(void) {
  uint N;
  uint K;

  cin >> N;
  cin >> K;

  vector<uint> data(N,1);

  uint d;
  
  for(uint i=0; i<K; i++) {
    cin >> d;
    uint A;
    for(uint j=0; j<d; j++) {
      cin >> A;
      data[A-1] = 0;
    }
  }

  cout << accumulate(data.begin(),data.end(),0) << endl;
  
  return 0;
}


Measured memory_bytes: 3196
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include <numeric>

#define ll long long
#define int long long
#define ld long double
#define endl "\n"
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
const ll MOD = 1e9 + 7;
const int N = 2e12+5;
const int demo = 10;
using namespace std;
const ll cfmod=998244353;
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

signed main(){
    int q=1;
    //cin>>q;
    while(q--) {
        string a,b;
        cin>>a>>b;
        int ans=0;
        for(int i=0;i<(int)a.size();i++){
            if(a[i]!=b[i]){
                ans++;
            }
        }
        cout<<ans;
    }
}

Measured memory_bytes: 3480
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
char s[15];
int main(){
	scanf("%s",s+1);
	if(s[1]=='S')puts("Cloudy");
	else if(s[1]=='C')puts("Rainy");
	else puts("Sunny");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

   int n;
   long int ln = 0;
   long int l0 = 2;
   long int l1 = 1;

   cin >> n;

   if(n == 1){
      cout << l1 << endl;
   }else{
      for(int i = 2; i <= n; i++){
         ln = l1 + l0;
         l0 = l1;
         l1 = ln;
      }

      cout << ln << endl;
   }

   return 0;

}


Measured memory_bytes: 256
import string
S = input()
K = int(input())
LEN = len(S)
ans = ''
for pos, s in enumerate(S, 1):
    idx = string.ascii_lowercase.find(s)
    if pos < LEN:
        if idx > 0 and 26-idx <= K:
            ans += 'a'
            K -= (26 - idx)
        else:
            ans += s
    else:
        # 残りのKをすべて消費する
        ans += string.ascii_lowercase[(idx + K)%26]

print(ans)

Measured memory_bytes: 10356
#include <iostream>

using namespace std;

int main(){
  int x1, y1, x2, y2, x, y;
  cin >> x1 >> y1 >> x2 >> y2;

  x=x2-x1;
  y=y2-y1;

  printf("%d %d %d %d\n", x2-y, y2+x, x1-y, y1+x);
  return 0;
}

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

int top, N[1000];

void push(int);
int pop(void);

int main(){
  int x,y;
  char n[100];
  top = 0;

  while(scanf("%s", n) != EOF){
    if(n[0] == '+'){
      x = pop();
      y = pop();
      push(x + y);
    }
    else if(n[0] == '-'){
      y = pop();
      x = pop();
      push(x - y);
    }
    else if(n[0] == '*'){
      x = pop();
      y = pop();
      push(x * y);
    }
    else{
      push(atoi(n));
    }
  }

  printf("%d\n", pop());

  return 0;
}


void push(int x){
  N[++top] = x;
}

int pop(){
  top--;
  return N[top + 1];
}



Measured memory_bytes: 2716
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Double A = sc.nextDouble();
        Double B = sc.nextDouble();

        int ans = -1;

        for(int i =0;i<1100;i++){

            if(Math.floor(0.08*i) == A && Math.floor(0.1 *i) == B){
                ans = i;
                break;
            }

        }
        System.out.println(ans);



    }

}









Measured memory_bytes: 25276
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int x;
  cin >> x;
  if(x == 3 || x == 5 || x == 7)
    cout << "YES" << ln;
    else cout << "NO" << ln;
}


Measured memory_bytes: 256
A = list(map(int, input().split()))
A.sort()
ans = 0
tmp = A[2] - A[1]
ans += tmp
A[0] += tmp

if (A[2] - A[0]) % 2 == 0:
    tmp = (A[2] - A[0]) / 2
    ans += tmp
else:
    tmp = (A[2] - A[0] + 1) / 2 + 1
    ans += tmp

print(int(ans))

Measured memory_bytes: 9120
class UnionFind:
  def __init__(self, n):
    self.parent = [-1] * n
    self.rank = [1] * n
    self.count = [1] * n

  def get_root(self, i):
    while self.parent[i] != -1:
      i = self.parent[i]
    return i

  def is_same_tree(self, i, j):
    return self.get_root(i) == self.get_root(j)

  def merge(self, i, j):
    i = self.get_root(i)
    j = self.get_root(j)
    if i == j:
      return

    if self.rank[i] > self.rank[j]:
      self.parent[j] = i
      self.rank[i] = max(self.rank[i], self.rank[j] + 1)
      self.count[i] += self.count[j]
    else:
      self.parent[i] = j
      self.rank[j] = max(self.rank[j], self.rank[i] + 1)
      self.count[j] += self.count[i]


n, m = map(int, input().split())
uf = UnionFind(n)
for _ in range(m):
  a, b = [int(i) - 1 for i in input().split()]
  uf.merge(a, b)
print(max(uf.count))


Measured memory_bytes: 16356
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int dp[101][4][4][4];
const int MOD = 1e9 + 7;

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

	int n;
	cin >> n;

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				dp[3][i][j][k] = 1;
			}
		}
	}

	const int A = 0, G = 1, C = 2, T = 3;
	dp[3][A][G][C] = 0;
	dp[3][A][C][G] = 0;
	dp[3][G][A][C] = 0;

	for (int i = 4; i <= n; i++) {
		for (int c1 = 0; c1 < 4; c1++) {
			for (int c2 = 0; c2 < 4; c2++) {
				for (int c3 = 0; c3 < 4; c3++) {
					for (int c4 = 0; c4 < 4; c4++) {
						// ?AGC
						if (c2 == A && c3 == G && c4 == C) continue;
						// ?ACG
						if (c2 == A && c3 == C && c4 == G) continue;
						// ?GAC
						if (c2 == G && c3 == A && c4 == C) continue;
						// A?GC
						if (c1 == A && c3 == G && c4 == C) continue;
						// AG?C
						if (c1 == A && c2 == G && c4 == C) continue;
						dp[i][c2][c3][c4] += dp[i - 1][c1][c2][c3];
						dp[i][c2][c3][c4] %= MOD;
					}
				}
			}
		}
	}

	int ans = 0;
	for (int c1 = 0; c1 < 4; c1++) {
		for (int c2 = 0; c2 < 4; c2++) {
			for (int c3 = 0; c3 < 4; c3++) {
				ans += dp[n][c1][c2][c3];
				ans %= MOD;
			}
		}
	}

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


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  ll N = S.size();
  REP(i, N) S[i] = 'x';
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    int i,len=0,c=0;
    cin>>s;
    cin>>t;
    len=s.length();
    for(i=0;i<len;i++)
    {
        if(s.at(i)==t.at(i))
        {
            c=c+0;
        }
        else if(s.at(i)!=t.at(i))
        {
            c=c+1;
        }
    }
    cout<<c;
}

Measured memory_bytes: 3848
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt(), b = s.nextInt();
		if (a<b) {
			String r = "";
			for(int i=0;i<b;i++) {
				r += a;
			}
			System.out.println(r);
		}else {
			String r = "";
			for(int i=0;i<a;i++) {
				r += b;
			}
			System.out.println(r);
		}

	}
}


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

int main(){
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> bi(m);
  for(int i = 0; i < m; i++){
    cin >> bi.at(i);
  }
  
  int count = 0;
  for(int i = 0; i < n; i++){
    int answer = c;
    for(int j = 0; j < m; j++){
      int a;
      cin >> a;
      answer += a * bi.at(j);
    }
    if(answer > 0){
      count++;
    }
  }
  cout << count << endl;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int n;
  scanf("%d", &n);
  ll prev = 2, cur = 1;
  for (int i = 2; i <= n; ++i) {
    prev += cur;
    swap(prev, cur);
  }

  ll ans = (n == 1) ? 1 : cur;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
S = input()
Q = int(input())
x = 0
p = ''
q = ''
for i in range(Q):
    A = list(input().split())
    if A[0] == '1':
        x += 1
    elif x%2 ==0:
        if A[1] == '1':
            p = A[2] + p
        else:
            q = q + A[2]
    else:
        if A[1] == '1':
            q = q + A[2] 
        else:
            p = A[2] + p
S = p + S + q
if x%2 == 1:
    S = ''.join(reversed(list(S)))
print(S)

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	int ans = 0;
	ans += 1000*(n / 500);
	n %= 500;
	ans += 5 * (n / 5);
	
	cout << ans << endl;
}


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

int n;
int k;
vector<int> arr(100004, 0);
vector<int> memo(100004, -1);

int cost(int i) {
	if(i>=n-1) return 0;
	if(i==n-2) return abs(arr[n-2]-arr[n-1]);

	if(memo[i]==-1) 
	{
		for(int j=1; j<=k; ++j)
		{
			if(i+j>n-1) break;
			int temp = abs(arr[i+j]-arr[i]) + cost(i+j);
			memo[i] = (memo[i]==-1) ? temp : min(memo[i], temp);
		}
	}
	return memo[i]; 
}


int main() {

	cin >> n >> k;
	for(int i=0; i<n; ++i) cin >> arr[i];

	cout << cost(0) << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



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

  int a = 4;
  int b = 7;

  int ans  = 0;
  bool ok = false;

  REP(i, 26){
    REP(j,16){
      ans = a*i + b*j;
      if(ans == n) ok = true;
      if(n > ans) continue;
    }
  }

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

ll solve() {
    string S;
    ll K;
    cin >> S >> K;
    vector<ll> ns;
    ll f = -1, nn = -1;
    for ( int i = 0; i < S.size(); i++ ) {
        ll n = S[i] - '0';
        ns.push_back(n);
        if ( f < 0 && n > 1 ) {
            f = i;
            nn = n;
        }
    }
    if ( f < 0 || K < f+1 ) {
        return 1;
    } else {
        return nn;
    }
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
K = int(input())
se = set()
x = 7 % K
cnt = 1
while True:
    if x == 0:
        print(cnt)
        exit()
    if x in se:
        print(-1)
        exit()
    se.add(x)
    x = (10 * x + 7) % K
    cnt += 1


Measured memory_bytes: 77944
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            var ans = (a + b) % 24;
            WriteLine(ans);
        }


        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 11220
import sys

input = sys.stdin.readline

m, d = map(int, input().split())

count = 0

for i in range(1, m + 1):
    for j in range(22, d + 1):
        op = j % 10
        tp = j // 10
        if op >= 2 and tp >= 2 and i == op * tp:
            # print("M{}, {} {}".format(i, op, tp))
            count += 1

print(count)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define MAX_N (101)
const ll MOD = (ll)1e9+7;

int main() {
	vector<int> a(5), A(5);
    for(int i=0; i<5; i++) {
        cin >> a[i];
        if(a[i]%10==0) A[i] = a[i];
        else A[i] = (10-(a[i]%10)) + a[i];
    }
    
    int b[5];
    b[0] = A[1]+A[2]+A[3]+A[4];
    b[1] = A[0]+A[2]+A[3]+A[4];
    b[2] = A[0]+A[1]+A[3]+A[4];
    b[3] = A[0]+A[1]+A[2]+A[4];
    b[4] = A[0]+A[1]+A[2]+A[3];

    int mn=1e9;
    for(int i=0; i<5; i++){
        mn = min(mn, b[i]+a[i]);
    }

    cout << mn << endl;

}

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


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Data.List
import Data.Functor
import Control.Monad
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import qualified Data.ByteString.Char8 as B

main :: IO()
main = do
  n <- readLn :: IO Int
  ss <- B.getContents :: IO B.ByteString
  mapM_ putStrLn $ solve'' ss

insertB = B.pack "insert"
findB = B.pack "find"

solve'' :: B.ByteString -> [String]
solve'' = reverse . snd . foldl' f (Set.empty, []) . B.lines
  where
    f :: (Set.Set B.ByteString, [String]) -> B.ByteString -> (Set.Set B.ByteString, [String])
    f !(dic, ss) !c
      | command == insertB = {-# SCC insert #-} let newDic = Set.insert key dic
                             in key `seq` newDic `seq` (newDic, ss)
      | command == findB = {-# SCC find #-} let val = if Set.member key dic then "yes" else "no"
                            in val `seq` (dic, val:ss)
      where (command:key:_) = B.words c
  


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

typedef long long ll;

int main(){
  int N;
  cin >> N;
  int mod = 1'000'000'007;
  vector<int> s(1000);
  for (int i = 2; i <= N; i++) {
    int x = i;
    for (int j = 2; j <= x; j++) {
      while(x%j==0){
        x /= j;
        s.at(j)++;
      }
    }
  }

  ll ans = 1;
  for (int i = 0; i < s.size(); i++) {
    ans = ((ans%mod)*((s.at(i)+1)%mod))%mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        char[][] c = new char[3][3];
        for(int i = 0; i < 3; i++){
            String s = scan.next();
            for(int j = 0; j < 3; j++){
                c[i][j] = s.charAt(j);
            }
        }
        System.out.println(c[0][0] +""+ c[1][1] +""+ c[2][2]);
        scan.close();
    }

    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 39108
import sys
input = sys.stdin.readline

s = input().rstrip()
l = [0]*len(s)
k=0
for i in range(1,len(s)-1):
    if s[i] == s[i-1] and l[i-1] == 0:
        l[i]=1
        l[i+1]=1
        
if len(s) >1 and s[-1] == s[-2] and l[-2] == 0:
    l[-2] = 1
    l[-1]=1
print(len(s)-sum(l)//2)


Measured memory_bytes: 10460
#include<stdio.h>
int main(void)
{
    int n;
    int b,f,r,v;
    int i,j,k;
    static int count[4][3][10];
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        count[b-1][f-1][r-1] += v;
    }
    
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",count[i][j][k]);
            }
            printf("\n");
        }
        if(i<3) printf("####################\n");
    }
    return 0;
}


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

int main() {
  int A, B, count;
  cin >> A >> B;
  for (int i = 0; i < 2; i++) {
    if (A < B) {
      count += B;
      B -= 1;
    }
    else {
      count += A;
      A -= 1;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int N, C, K;
int Array[100005];
void Read()
{
    cin >> N >> C >> K;
    for(int i = 1; i <= N; i++)
        cin >> Array[i];
    sort(Array + 1, Array + N + 1);
}

void Solve()
{
    int cnt = 0, nb = 0, last = 0;
    for(int i = 1; i <= N; i++)
    {
        if(Array[i] > last || cnt == C)
        {
            ++nb;
            cnt = 1;
            last = Array[i] + K;
        }
        else
            ++cnt;
    }
    cout << nb << "\n";
}
int main()
{
    Read();
    Solve();
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
const int INF = 1e9+1;

int main(){
  int N, W, M = 1e5;
  cin >> N >> W;
  vector<int> dp(M+1,INF);
  dp[0] = 0;
  for(int i = 0; i < N; ++i){
    vector<int> dp_ = dp;
    int w, v;
    cin >> w >> v;
    for(int j = 0; j <= M-v; ++j)
      dp_[j+v] = min(dp_[j+v],dp[j]+w);
    dp = dp_;
  }
  for(int i = M; i >= 0; --i){
    if(dp[i] > W) continue;
    cout << i << endl;
    return 0;
  }
}


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

int main() {
    int n, ans;
    cin >> n;
    vector<int> c(n - 1), s(n), f(n - 1);
    rep(i, n - 1) cin >> c.at(i) >> s.at(i) >> f.at(i);
    s.at(n - 1) = 0;
    rep(i, n) {
        ans = s.at(i);
        for(int j = i; j < n - 1; j++) {
            if(ans < s.at(j)) ans = s.at(j);
            ans = (ans + f.at(j) - 1) / f.at(j) * f.at(j) + c.at(j);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, k;
int a[101];
int g[101010];
int main(){
    INIT;
    cin >> n >> k;
    REP(i, n){
        cin >> a[i];
    }
    for(int i = 0;i <= k;i++){
        set<int> st;
        REP(j, n){
            if(i - a[j] >= 0)st.insert(g[i - a[j]]);
        }
        int num = 0;
        while(st.count(num))num++;
        g[i] = num;
    }
    cout << (g[k] > 0 ? "First" : "Second") << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
    #define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
    #define endl printf("\n")
    typedef pair<ll,ll> pii;
    #define pb push_back
    #define ms(a,b) memset(a, b, sizeof(a))
    #define in(x) scanf("%lld",&x)
    #define out(x) printf("%lld",x)
    #define X first
    #define Y second
    #define sps printf(" ")
    #define dou(x) cout<<fixed<<setprecision(6)<<x
    #define all(v) v.begin(),v.end()
    int main()
    {
        ll i,j,k,l,n,m;
        string s;
        cin>>s;
        auto it=find(all(s),'7');
        if(it==s.end())puts("No");
        else puts("Yes");
    }

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

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var an = new List<int>();
        var pre1 = false; var count = 1;
        if (a[0] == 1) pre1 = true;
        for (int i = 1; i < n; i++)
        {
            if (pre1 && a[i] == 0) { count++; pre1 = false; }
            else if (!pre1 && a[i] == 1) { count++; pre1 = true; }
            else { an.Add(count); count = 1; }
        }
        an.Add(count);
        Console.WriteLine(getMax(an));
    }
    public static int getMax(List<int> an)
    {
        if (an.Count() == 1) return an[0];
        if (an.Count() == 2) return an[0] + an[1];
        var n = an.Count();
        var s3 = an[0] + an[1] + an[2];
        var smax = s3;
        for (int i = 3; i < n; i++)
        {
            s3 = s3 + an[i] - an[i - 3];
            smax = Math.Max(smax, s3);
        }
        return smax;
    }
}

Measured memory_bytes: 14860
import sys
from math import sqrt
from collections import Counter

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    c1 = LI()
    c2 = LI()
    c3 = LI()

    if c1[0] - c1[1] == c2[0] - c2[1] == c3[0] - c3[1]:
        if c2[1] - c2[2] == c2[1] - c2[2] == c3[1] - c3[2]:
            print("Yes")
            exit()

    print("No")

    pass


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

vector<vector<int> > v;
vector<int> memo;

int dp(int i){
  if(memo[i]!=-1)return memo[i];
  memo[i]=0;
  for(auto e:v[i])memo[i]=max(memo[i],dp(e)+1);
  return memo[i];
}

int main(){
  int N,M;
  cin>>N>>M;
  v.resize(N);
  REP(i,N)memo.push_back(-1);
  REP(i,M){
    int x,y;
    cin>>x>>y;
    x--;y--;
    v[x].push_back(y);
  }
  int ans=0;
  REP(i,N)ans=max(ans,dp(i));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 8184
package main

import (
	"fmt"
	"math/big"
)

type key struct {
	k1, k2 int64
}

var memo = make(map[key]int64)

func gcd(n, m int64) int64 {
	if v, ok := memo[key{n, m}]; ok {
		return v
	}

	x := new(big.Int)
	y := new(big.Int)
	res := new(big.Int)

	res.GCD(x, y, big.NewInt(n), big.NewInt(m))
	memo[key{n, m}] = res.Int64()
	return res.Int64()
}

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

	var res int64
	for i := 1; i < k+1; i++ {
		for j := 1; j < k+1; j++ {
			for l := 1; l < k+1; l++ {
				res += gcd(gcd(int64(i), int64(j)), int64(l))
			}
		}
	}
	fmt.Println(res)
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

int main(){
  int N;
  cin >> N;
  cout << 180 * (N-2) << endl;
  return 0;
}


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

struct LIS{
    const int INF = 1e9 + 1;
    vector<int> dp;
    int last = 0;
    vector<vector<int>> hist;

    LIS(int N){
        dp.assign(N+1, INF);
    }
    void add(int a){
        int pos = lower_bound(dp.begin(), dp.end(), a) - dp.begin();
        hist.push_back({pos, dp[pos], last});
        dp[pos] = a;
        last = max(last, pos);
    }

    int ans(){ return last+1; }
    
    void rollback(){
        auto v = hist.back();
        hist.pop_back();
        dp[v[0]] = v[1];
        last = v[2];
    }
};

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    vector<int> edges[200000];
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<int> ans(N);
    LIS lis(N);
    auto dfs = [&](auto&& dfs, int i, int p)->void{
        lis.add(A[i]);
        ans[i] = lis.ans();
        for(int j : edges[i]) if(j != p) dfs(dfs, j, i);
        lis.rollback();
    };
    dfs(dfs, 0, -1);

    for(int a : ans) cout << a << endl;
    return 0;
}


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

int n, a[2],num[2];
bool ok[1000][1000];

int main() {
	scanf("%d%d%d",&n,&a[0],&a[1]);
	for (int i=0;i<1000;++i) for(int j=0;j<1000;++j)ok[i][j]=true;
	{
		num[0] = 0;
		while (a[0] % 2 == 0) {
			++num[0];
			a[0] /= 2;
		}
		num[1] = 0;
		while (a[1] % 2 == 0) {
			++num[1];
			a[1] /= 2;
		}
	}
	{
		int p = num[0];
		if (p & 1) {
			int two = 1 << (p / 2);
			for (int x = 0; x < n * 2; ++x) {
				for (int y = 0; y < n * 2; ++y) {
					if (y % (two * 2) >= two) ok[x][y] = false;
				}
			}
		}
		else {
			int two = 1 << (p / 2);
			for (int x = 0; x < n * 2; ++x) {
				for (int y = 0; y < n * 2; ++y) {
					int px = (x % (two * 2) >= two ? 1 : 0);
					int py = (y % (two * 2) >= two ? 1 : 0);
					if (px != py) ok[x][y] = false;
				}
			}
		}
		p = num[1];
		if (p & 1) {
			int two = 1 << (p / 2);
			for (int x = 0; x < n * 2; ++x) {
				for (int y = 0; y < n * 2; ++y) {
					if (y % (two * 2) >= two) ok[x][y] = false;
				}
			}
		}
		else {
			int two = 1 << (p / 2);
			for (int x = 0; x < n * 2; ++x) {
				for (int y = 0; y < n * 2; ++y) {
					int px = (x % (two * 2) >= two ? 1 : 0);
					int py = (y % (two * 2) >= two ? 1 : 0);
					if (px != py) ok[x][y] = false;
				}
			}
		}
	}
	int con = 0;
	for (int x = 0; x < n * 2; ++x) {
		for (int y = 0; y < n * 2; ++y) {
			if (con == n*n) break;
			if (ok[x][y]) {
//				cout << x << " " << y << endl;
				printf("%d %d\n",x,y);
				++con;
			}
		}
	}
}

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

typedef struct _data {
	int x;
	int y;
} data;

int  main()
{
	char s[3];
	cin >> s;
	int ans = 0;
	rep(i, 2)
	{
		if (s[i] != s[i+1])
			ans = 1;
	}
	if (ans == 1) 
		cout << "Yes\n";
	else
		cout << "No\n";
	return (0);
}


Measured memory_bytes: 256
/*
    In the name of Allah

    MohammadErfan Gooneh

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define endl                        '\n'
#define all(a, n)                   for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define IOS                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
int main() {
    IOS ;
    ll n , a ;
    cin >> n >> a ;
    if((n%500)<=a)cout << "Yes";
    else cout << "No" ;




















return 0 ;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int a, b; cin >> a >> b;
	if (a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) cout << "Possible";
	else cout << "Impossible";
	
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

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

int main(void){
	int N, K;
	map<int, int> d;
	int dp[101][3][3] = {0};
	cin >> N >> K;
	REP(i, K){
		int a, b;
		cin >> a >> b;
		d[a-1] = b;
	}
	REP(i, 3){
		REP(j, 3){
			dp[2][i][j] = 1;
		}
	}
	if(d.find(0) != d.end()){
		REP(i, 3){
			if(i != d[0]-1){
				REP(j, 3){
					dp[2][j][i] = 0;
				}
			}
		}
	}
	if(d.find(1) != d.end()){
		REP(i, 3){
			if(i != d[1]-1){
				REP(j, 3){
					dp[2][i][j] = 0;
				}
			}
		}
	}
	if(d.find(2) != d.end()){
		dp[2][d[2]-1][d[2]-1] = 0;
	}

	for(int i = 2;i < N;i++){
		REP(j, 3){ // 2??????
			REP(k, 3){ // 1?????? 
				if(d.find(i) != d.end()){
					if(!(j == k && k == d[i]-1)){
						dp[i+1][d[i]-1][k] += dp[i][k][j];
						dp[i+1][d[i]-1][k] %= 10000;
					}
				}else{
					REP(s, 3){
						if(!(j == k && k == s)){
							dp[i+1][s][k] += dp[i][k][j] ;
							dp[i+1][s][k] %= 10000;
						}
					}
				}
			}
		}
	}
	int res = 0;
	REP(i, 3){
		REP(j, 3){
			res = (res + dp[N][i][j]) % 10000;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3104
# -*- coding: utf-8 -*-

input()
ingredients = list(map(float, input().split()))

ingredients.sort()
# print(ingredients)

while True:
    first = ingredients.pop(0)
    second = ingredients.pop(0)
    # print("{}, {}".format(first, second))
    new_ingredient = (first + second) / 2
    ingredients.insert(0, new_ingredient)
    if len(ingredients) == 1:
        break

print(ingredients[0])

Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#define llong long long
#define For(i,a,n) for(register int i=a;i<=n;i++)
#define RF(i,a,n) for(register int i=a;i>=n;i--)
#pragma GCC optimize(2)
using namespace std;

const int maxn = 100005;
struct node{
	int idx, v;
	bool operator < (const node &b) const{
		return v < b.v;
	}
}a[maxn];

int n;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    For(i,1,n){
    	cin>>a[i].v;
    	a[i].idx = i;
    }
    sort(a+1, a+n+1);
    For(i,1,n-1){
    	cout<<a[i].idx<<" ";
    }
    cout<<a[n].idx<<endl;
    return 0;
}

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

int main(){
    int n;
    int i, j;
    int absolute;
    int s1, s2;
    scanf("%d", &n);
    int w[n];
    for(i=0; i<n; ++i){
        scanf("%d", &w[i]);
    }
    
    for(i=0; i<n; i++){
        s1=0;
        s2=0;
        for(j=0; j<n; j++){
            if(i >=j) s1 += w[j];
            
            if(i < j) s2 += w[j];
           
        }
        if(i==0) absolute=abs(s1-s2);
        
        if(absolute> abs(s1-s2))
            absolute = abs(s1-s2);
    }
    
    printf("%d", absolute);
    
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main(){
    int N, D, X; cin >> N >> D >> X;
    vector<int> A(N); REP(i, N) cin >> A[i];

    int cnt = 0;
    for(int i = 0; i < N; ++i) {
        for(int k = 0; k < D; k = k + A[i]) {
            cnt++;
        }
    }

    cout << X + cnt << endl;
}

Measured memory_bytes: 256
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
--
local N = read.n()
local L = read.N(N)

local ans = 0
for i=1,N-2 do
    for j=i+1,N-1 do
        for k=j+1,N do
            if L[i] ~= L[j] and L[i] ~= L[k] and L[j] ~= L[k] then
                local t = {L[i], L[j], L[k]}
                table.sort(t)
                local a,b,c = table.unpack(t)
                if a < b + c and b < c + a and c < a + b then
                    ans = ans + 1
                end
            end
        end
    end
end
print(ans)

Measured memory_bytes: 2884
#define rep(i,n) for(i=0;i<(n);++i)
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<utility>
#include<string>
#include<algorithm>
#include<bitset>
#include<queue>
using ll = unsigned long long int;
using namespace std;



int src(){
    int N;
    string str;
    cin>>N;
    cin>> str;
    if(N%2==1){
        cout<<"No"; return 0;
    }
    int hN=N/2;
    for(int i=0;i<hN;++i){
        if(str[i]!=str[i+hN]){cout<<"No"; return 0;}
    }
    cout<<"Yes";
    return 0;
}

int main(int argc,char* argv[]){
    //ifstream in( argv[1] );
    //cin.rdbuf(in.rdbuf());
    src();    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contest
{
    class ABC
    {
        static void Main()
        {
            Solve();
        }

        private static void Solve()
        {
            int n = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = new int[n];
            for(int i = 0; i < n; i++)
            {
                a[input[i] - 1] = i + 1;
            }
            StringBuilder sb = new StringBuilder();
            foreach(var x in a)
            {
                sb.Append(" " + x);
            }
            string res = sb.ToString().Trim();
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 28884
p=2019
s,a,d,z=input()[::-1],0,0,[0]*p
for i,j in enumerate(s):
	d=(d+int(j)*pow(10,i,p))%p
	z[d]+=1
r=z[0]
for i in range(p):
	r+=z[i]*(z[i]-1)//2
print(r)

Measured memory_bytes: 9348
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		//String t = sc.next();
		//String g = sc.next();
		long n = sc.nextLong();
		long m = sc.nextLong();
		//long k = sc.nextLong();
		//long l = sc.nextLong();
		long count=0;
		long[] array=new long[3];

		/*for(int i=0;i<=3;i++) {
			if(s.substring(i,i+1).equals("+")) {
				count++;
			}else {
				count--;
			}
		}*/
		//Arrays.sort(array);
		if(n%m==0) {
			System.out.println(0);
		}else {
			System.out.println(1);
		}
		//System.out.println((int)Math.ceil((n+m)/2.0));
		//System.out.println(Math.abs(array[2]-array[1])+Math.abs(array[1]-array[0]));
	}
}




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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct Bill
{
	int b, x, y;
};

#define SQR(x) ((x) * (x))
const int INF = 1 << 30;

int prv[1024];
bool dijkstra(vector<Bill>& bill, vint& ntoi, int s, int t)
{
	int V = bill.size();
	
	vint used(V, false);
	vint d(V, INF);
	d[s] = 0;
	
	while(true)
	{
		int v = -1;
		for(int u = 0; u < V; u++)
		{
			if(!used[u] && (v == -1 || d[u] < d[v]))
			{
				v = u;
			}
		}
		
		if(v == -1) break;
		
		used[v] = true;
		
		rep(u, V)
		{
			double drc = sqrt(SQR(bill[v].x - bill[u].x) + SQR(bill[v].y - bill[u].y));
			if(drc <= 50 && d[v] + drc < d[u])
			{
				d[u] = d[v] + drc;
				prv[u] = v;
			}
		}
	}
	
	return d[t] == INF;
}

int main()
{
    int n;
	
	while(cin >> n && n)
	{
		vector<Bill> bill(n);
		vint ntoi(1001, -1);
		rep(i, n)
		{
			cin >> bill[i].b >> bill[i].x >> bill[i].y;
			ntoi[bill[i].b] = i;
		}
		
		int m;
		cin >> m;
		rep(i, m)
		{
			int s, b;
			cin >> s >> b;
			
			memset(prv, -1, sizeof prv);
			
			if(dijkstra(bill, ntoi, ntoi[s], ntoi[b]))
			{
				cout << "NA" << endl;
			}
			else
			{
				vint path;
				for(int t = ntoi[b]; t != -1; t = prv[t]) path.push_back(bill[t].b);
				
				reverse(ALL(path));
				
				rep(i, path.size()) cout << path[i] << (i + 1 == path.size() ? "\n" : " ");
			}
		}
	}
}

Measured memory_bytes: 0