akhauriyash/Code-Regression huggingface dataset:
#/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  #define add accumulate
  #define ll long long int
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  const ll mod=1e9+7;
  const ll MAX=1e5+1;
  ll lcm(ll x,ll y){return (x*y)/__gcd(x,y);}
  //
  //	
  	ll solve(){
  		ll n,cnt=0;
  		cin>>n;
  		rep(i,0,n){
  			ll k;
  			cin>>k;
  			while(k%2==0&&k>1){
  				++cnt;
  				k/=2;
  			}
  		}
  		cout<<cnt;
  	}
	int main(){ 
		hs;
		ll t;
		// cin>>t;
		t=1;
		while(t--)
			solve();
    return 0; 
} 

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	int x=c-a,y=d-b;
	printf("%d %d %d %d",c-y,d+x,a-y,b+x);
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 112345
int a[N];
int b[N];

int main(){
	int n; scanf("%d", &n);
	REP(i, n) scanf("%d", a+i);
	REP(i, n) b[i] = i;
	sort(b, b+n, [](auto x, auto y){
				return a[x] < a[y];
			});
	REP(i, n) printf("%d ", b[i] + 1);
}


Measured memory_bytes: 1664
v,e = map(int,input().split())
INF = float("INF")
D = [[INF]*v for _ in range(v)]
for i in range(v): D[i][i] = 0
for _ in range(e):
    s,t,d = map(int,input().split())
    D[s][t] = d

for k in range(v):
    for i in range(v):
        if D[i][k] == INF: continue 
        for j in range(v):
            if D[k][j] == INF: continue
            D[i][j] = min(D[i][j],D[i][k]+D[k][j])

neg = False
for i in range(v):
    if D[i][i] < 0:
        neg = True
        break

if neg:
    print("NEGATIVE CYCLE")
else:
    for i in range(v):
            print(" ".join(map(lambda x:"INF" if x == INF else str(x),D[i])))


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,ll> PP;

ll seg[1000005];
const ll INF = 1e17;
int nn;
ll dp[100005];
vector<PP> l;

void init (int _n) {
  nn = 1;

  while(nn < _n) nn *= 2;

  for(int i = 0; i < 2 * nn - 1; i++) seg[i] = INF;
}
  
void update(int k, ll a) {
  k += nn - 1;
  seg[k] = a;
  while(k > 0) {
    k = (k - 1) / 2;
    seg[k] = min(seg[2*k+1],seg[2*k+2]);
  }
}

ll query(int a, int b, int k, int l, int r) {
  if(b <= l || r <= a) return INF;

  if(a <= l && r <= b) return seg[k];
  else {
    ll vl = query(a,b,2*k+1,l,(l+r)/2);
    ll vr = query(a,b,2*k+2,(l+r)/2,r);

    return min(vl,vr);
  }
 
}


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

  init(n);

  for(int i = 0; i < m; i++) {
    int L,R,C;
    cin >> L >> R >> C;
    L--; R--;
    l.push_back(PP(P(L,R),C));
  }

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

  update(0,0);

  for(int i = 0; i < l.size(); i++) {
    P LR = l[i].first;
    ll tmp = query(LR.first,LR.second,0,0,nn);
    // cout << tmp << endl;
    if(tmp == INF) continue;
    update(LR.second,min(seg[LR.second+nn-1],tmp+l[i].second));
  }

  if(seg[nn+n-2] == INF) cout << -1 << endl;
  else cout << seg[nn+n-2] << endl;
    
}


Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
 
int main() {
 
  int long long t=0,i=0,j=0,N;
  int ans=0;
  
  cin >> N;

  ans=N/2+N%2;
  
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    string s;
    cin >> s;
    int ans = inf;
    rep(i, sz(s) - 2) {
        string t;
        t += s[i];
        t += s[i + 1];
        t += s[i + 2];
        if (abs(stoi(t) - 753) < ans) ans = abs(stoi(t) - 753);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//namespace problems {
//    vector<string> solve(string str) {
//        if (str.size() == 1) return {str};
//        int z = 0;
//        int e = 0;
//        for (auto &c: str) {
//            if (c == '1') e++;
//            else z++;
//        }
//        if (e != z) return {str};
//        return {str.substr(0,1), str.substr(1,str.size()-1)};
//    }
//}
//
//#include <iostream>
//#include <vector>
//#include <complex>
//
//using std::cin;
//using std::cout;
//using std::endl;
//using std::vector;
//using std::string;
#include <complex>
#include <iostream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>
#include <tuple>
#include <set>

using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    int sum = 0;
    char prev = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != prev) sum++;
        prev = s[i];
    }
    
    cout << sum << endl;
    
     return 0;
}

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

int main() {

	string A, B, C;
	cin >> A >> B >> C;

	if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
class Node:
    def __init__(self, data):
        self.data = data
        self.left = self.right = None

rt = None


def inorder(node):
    return inorder(node.left) + f' {node.data}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.data}' + preorder(node.left) + preorder(node.right) if node else ''

def find(node, k):
    while node:
        if node.data == k:
            return True
        if k < node.data:
            node = node.left
        else:
            node = node.right
    return False

def insert(data):
    global rt
    x, y = rt, None
    while x: x, y = x.left if data < x.data else x.right, x
    if y is None: rt = Node(data)
    elif data < y.data: y.left = Node(data)
    else: y.right = Node(data)

n = int(input())
b = [input() for i in range(n)]
for e in b:
    if e[0] == 'i': insert(int(e[7:]))
    elif e[0] =='f':
        if find(rt,int(e[5:])):
            print('yes')
        else:
            print('no')
    else:
        print(inorder(rt))
        print(preorder(rt))




Measured memory_bytes: 130304
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;

using namespace std;

int main()
{
  ull N;
  cin >> N;

  if (N == 1) {
    cout << "Hello World" << endl;
  } else {
    ull A, B;
    cin >> A >> B;
    cout << (A + B) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/* This code was submitted by
  "Anand Dubey" on 
   14th January 2019
*/


#include <bits/stdc++.h> // Include every standard library 
using namespace std; 
  
typedef long long LL; 
typedef pair<int, int> pii; 
typedef pair<LL, LL> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<LL> vl; 
typedef vector<vl> vvl; 
  
double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL; 
double PI = acos(-1); 
int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 }; 
int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 }; 
  
#ifdef TESTING 
#define DEBUG fprintf(stderr, "====TESTING====\n") 
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl 
#define debug(...) fprintf(stderr, __VA_ARGS__) 
#else 
#define DEBUG 
#define VALUE(x) 
#define debug(...) 
#endif 
  
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a)) 
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a)) 
#define FORSQ(a, b, c) for (int(a) = (b); (a) * (a) <= (c); ++(a)) 
#define FORC(a, b, c) for (char(a) = (b); (a) <= (c); ++(a)) 
#define FOREACH(a, b) for (auto&(a) : (b)) 
#define REP(i, n) FOR(i, 0, n) 
#define REPN(i, n) FORN(i, 1, n) 
#define MAX(a, b) a = max(a, b) 
#define MIN(a, b) a = min(a, b) 
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
#define TC(t) while (t--)  
#define g(str) getline(cin,str)  


inline string IntToString(LL a) 
{ 
    char x[100]; 
    sprintf(x, "%lld", a); 
    string s = x; 
    return s; 
} 
  
inline LL StringToInt(string a) 
{ 
    char x[100]; 
    LL res; 
    strcpy(x, a.c_str()); 
    sscanf(x, "%lld", &res); 
    return res; 
} 
  
inline string GetString(void) 
{ 
    char x[1000005]; 
    scanf("%s", x); 
    string s = x; 
    return s; 
} 
  
inline string uppercase(string s) 
{ 
    int n = SIZE(s); 
    REP(i, n) 
    if (s[i] >= 'a' && s[i] <= 'z') 
        s[i] = s[i] - 'a' + 'A'; 
    return s; 
} 
  
inline string lowercase(string s) 
{ 
    int n = SIZE(s); 
    REP(i, n) 
    if (s[i] >= 'A' && s[i] <= 'Z') 
        s[i] = s[i] - 'A' + 'a'; 
    return s; 
} 
  
inline void OPEN(string s) 
{ 

} 
  
int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
  string s;
    cin>>s;
    
  FOR(i,0,s.length())
  {
    int a=(int)s[i];
    if((n+a) > 90)
      a+=n-26;
    else
      a+=n;
    s[i]=(char)a;
  }
  cout<<s;
    return 0; 
} 


Measured memory_bytes: 256
#include<stdio.h>
 
void mergeSort(int S[], int temp[], int array_size);
void m_sort(int S[], int temp[], int left, int right);
void merge(int S[], int temp[], int left, int mid, int right);
 
int n,count=0;
int numbers[500001];
int temp[500001];
 
 
int main()
{
  int i;
  scanf("%d",&n);
   
  for (i = 0; i < n; i++){
   scanf("%d",&numbers[i]);
  }
  mergeSort(numbers, temp, n);
 
 
  for (i = 0; i < n-1; i++){
    printf("%d ", numbers[i]);
}
  printf("%d",numbers[n-1]);
  printf("\n");
 
  printf("%d\n",count);
  return 0;
}
 
 
void mergeSort(int numbers[], int temp[], int array_size)
{
  m_sort(numbers, temp, 0, array_size - 1);
}
 
 
 
void m_sort(int numbers[], int temp[], int left, int right)
{
  int mid;
 
  if (right > left)
  {
    mid = (right + left) / 2;
    m_sort(numbers, temp, left, mid);
    m_sort(numbers, temp, mid+1, right);
 
    merge(numbers, temp, left, mid+1, right);
  }
}
 
 
void merge(int numbers[], int temp[], int left, int mid, int right)
{
  int i, left_end, num_elements, tmp_pos;
 
  left_end = mid - 1;
  tmp_pos = left;
  num_elements = right - left + 1;
 
  while ((left <= left_end) && (mid <= right))
  {
    if (numbers[left] <= numbers[mid])
    {
      temp[tmp_pos] = numbers[left];
      tmp_pos = tmp_pos + 1;
      left = left +1;
      count++;
    }
    else
    {
      temp[tmp_pos] = numbers[mid];
      tmp_pos = tmp_pos + 1;
      mid = mid + 1;
      count++;
    }
  }
 
  while (left <= left_end)
  {
    temp[tmp_pos] = numbers[left];
    left = left + 1;
    tmp_pos = tmp_pos + 1;
    count++;
  }
  while (mid <= right)
  {
    temp[tmp_pos] = numbers[mid];
    mid = mid + 1;
    tmp_pos = tmp_pos + 1;
    count++; 
 }
 
  for (i=0; i <= num_elements; i++)
  {
    numbers[right] = temp[right];
    right = right - 1;
  }
}

Measured memory_bytes: 4508
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
using namespace std;
const int N=2*1e5+100;
int n,k,c,dp[N*2],a[N],w;
char s[N];
signed main()
{
	scanf("%d%d%d",&n,&k,&c);
	scanf("%s",s+1);
	dp[n+1]=0;
	if (s[n]=='o') dp[n]=1;
	else dp[n]=0;
	for (int i=n-1;i>=1;i--)
	{
		dp[i]=dp[i+1];
		if (s[i]=='o')
		  dp[i]=max(dp[i],dp[i+c+1]+1);
	}
	for (int i=1;i<=n;i++)
	{
		if (s[i]=='o')
		{
			w++;
			a[w]=i;
			if (w==k) break;
			i=i+c;
		}
	}
//	for (int i=1;i<=n;i++) printf("%d ",dp[i]);
//	printf("\n");
	for (int i=1;i<=n;i++)
	{
		if (s[i]=='o')
		{
			if (i>a[w]) continue;
			int pos=lower_bound(a+1,a+1+w,i)-a;
			if (a[pos]!=i) continue;
			if (pos-1+dp[i+1]<k) printf("%d\n",i);
		}
	}
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define for1(i,n) for(int i=1;i<=(int)(n);i++)
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N=202;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n;
      cin>>n;
      int a[n];
      for(int i=0;i<n;i++)
      {
            cin>>a[i];
      }
      sort(a,a+n);
      int ans=0;
      for(int k=0;k<=100000;k++)
      {
            int o=lower_bound(a,a+n,k)-a;
            if(o==n-(o))
            {
                  ans++;
            }
      }
      cout<<ans;
}  
// I never lose. I either win or I learn

Measured memory_bytes: 1024
#include<cstdio>
#define Z 100005
int N,M,p[Z],d[Z],i,u,v,w,r1,r2;
bool f;
int r(int x){
	if(p[x]==x)return x;
	int t=p[x];
	p[x]=r(p[x]);
	d[x]+=d[t];
	return p[x];
}
int main(){
	scanf("%d%d",&N,&M);
	for(i=1;i<=N;i++)p[i]=i;
	for(i=1;i<=M;i++){
		scanf("%d%d%d",&u,&v,&w);
		if(f)continue;
		r1=r(u);r2=r(v);
		if(r1!=r2){
			p[r2]=r1;
			d[r2]=d[r1]+w-d[v]+d[u];
		}
		else if(d[v]-d[u]!=w)f=true;
	}
	printf("%s\n",f?"No":"Yes");
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
bool ok = true;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n , i , k = 0;
    cin >> n;
    vector<int>v(n),c(n);
    int temp = 0 ;
    for(i = 0; i < n; i++){
        cin>> v[i];
        c[i] = v[i];
       
    }
    sort( c.begin(), c.end());
    for(int i = 0; i < n; i++){
        if(v[i]!= c[i]){
            temp++;
        }
    }
    if(temp <= 2){
        cout << "YES"<<endl;
    }
    else{
        cout << "NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int K; string S;
    cin >> K >> S;

    if(S.size()<=K){
        cout << S << endl;
        return 0;
    }else{
        REP(i,K) cout << S[i];
        cout << "..." << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  int next = 1;
  int cnt = 0;
  
  for(int i=0;i<N;i++){
    cin >> a.at(i);
    if(a.at(i)!=next){
      cnt ++;
    }else{
      next ++;
    }
  }
  if(next==1){
    cout << -1 << endl;
  }else{
    cout << cnt << endl;
  }  
}

Measured memory_bytes: 1024
import sys
import math
from fractions import gcd
# import queue
from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


N = int(sys.stdin.readline())
L = list(map(int, sys.stdin.readline().split()))
Ls = sorted(list(set(L[:])),reverse=True)
Lc = Counter(L)

A = 0

for l in Ls:
    if A == 0:
        if Lc[l] >= 4:
            print(l * l)
            exit()
        if Lc[l] >= 2:
            A = l
    else:
        if Lc[l] >= 2:
            print(A * l)
            exit()

print(0)

Measured memory_bytes: 91408
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def check(k,ans):
    if k<2:
        print(ans+k)
        exit()

def main():
    k,a,b=MI()
    d=b-a
    if d<3:
        print(k+1)
        exit()
    ans=1
    cnt=min(a-1,k)
    ans+=cnt
    k-=cnt
    check(k,ans)
    cnt=k//2
    ans+=cnt*d
    k-=cnt*2
    check(k,ans)

main()

Measured memory_bytes: 9108
#include<stdio.h>

int main(void)
{
	int a[5],k,q,r,hantei=0,i,j;
	scanf("%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4],&k);
	for(i=0;i<5;i++)
	{
		for(j=0;j<5;j++)
		{
			r = a[i] - a[j];
			if(r<=-1) r = r * -1;
			if(r > k) hantei = 1;
		}
		r = 0;
	}

	if(hantei==0) printf("Yay!\n");
	else printf(":(\n");
	return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader in = new MyReader();
        final int INF = Integer.MAX_VALUE;
        
        int N = in.i();
        int SIZE = 1 << N;
        
        int[] s = in.ii();
        Arrays.sort(s);
        
        ArrayList<Integer> pp = new ArrayList<>();
        pp.add(s[SIZE-1]);
        
        s[SIZE-1] = INF;
        
        for(int j = 0; j < N; j++){
            pp.sort(null);
            int i = 1;
            ArrayList<Integer> np = (ArrayList<Integer>)pp.clone();
            while(!pp.isEmpty()){
                int p = pp.remove(pp.size()-1);
                while(true){
                    if(s[SIZE-1-i] < p){
                        np.add(s[SIZE-1-i]);
                        s[SIZE-1-i] = INF;
                        break;
                    } else 
                        i++;                    
                    if(i == SIZE){
                        println("No");
                        return;
                    }
                }
            }
            pp = np;
        }
        println("Yes");
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}


Measured memory_bytes: 85976
#include <stdio.h>

int main(void){
    int n,k;
    scanf("%d %d",&k,&n);
    int a[n];
    int i;
    for(i=0;i<n;i++){
        scanf("%d", &a[i]);
    }

    int tokei,hantokei,min,tmp;

    tokei=a[1]-a[0];
    hantokei=k-(a[n-1]-a[0]);
    if(tokei>=hantokei){
        min=k-tokei;
    }else{
        min=k-hantokei;
    }
    /*長い方を引く*/

    for(i=1;i<n-1;i++){
        tokei=a[i+1]-a[i];
        hantokei=a[i]-a[i-1];

        if(tokei>=hantokei){
            tmp=k-tokei;
        }else{
            tmp=k-hantokei;
        }
        /*長い方を引く*/

        if(tmp<min){
            min=tmp;
        }
    }

    tokei=k-(a[n-1]-a[0]);
    hantokei=a[n-1]-a[n-2];
    if(tokei>=hantokei){
        tmp=k-tokei;
    }else{
        tmp=k-hantokei;
    }
    /*長い方を引く*/

    if(tmp<min){
        min=tmp;
    }

    printf("%d\n",min);
    return 0;
}


Measured memory_bytes: 896
N, K = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

if K > 40
    puts ([N]*N).join(' ')
    exit
end

[K, 40].min.times do |k|
    imosu = [0] * N
    0.upto(N-1) do |i|
        l = [i - a[i], 0].max
        r = i + a[i] + 1
        # l = i - a[i]
        # l = 0 if l < 0
        # r = i + a[i] + 1
        # r = N if r > N
        imosu[l] += 1
        imosu[r] += -1 if r < N
    end
    s = 0
    # all_n = true
    0.upto(N-1) do |i|
        s += imosu[i]
        a[i] = s
        # all_n = false if a[i] != N
    end
    # break if all_n
end

puts a.join(' ')

Measured memory_bytes: 80812
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;


int main() {
	#ifdef wws
		freopen ("in.txt", "r", stdin);
	#endif
	int n;
	cin >> n;
	int x = 600;
	per(i, 8, 1) {
		if (n < x) cout <<  i, ioi
		x += 200;
	}
	ioi
}


Measured memory_bytes: 3632
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
struct edge{int to,cost;};
vector<int> G[100005];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
std::vector<P> tree[100010];
ll i,j;

ll n;
ll ans=0;
char a[10],b[10],c[10]; 

int main(){
	cin>>a>>b>>c;
	cout<<a[0]<<b[1]<<c[2]<<endl;
	return 0;
}

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


ll N, K;



int main(){
	cin >> N >> K;
	string S;
	cin >> S;
	
	// 幸福の最大値はN-1
	// 不連続点1つごとに 幸福-1
	int happy = N-1;
	for ( int i = 1; i < N; i++ ){
		if ( S[i] != S[i-1] )
			happy--;
	}
	
	// 操作1回ごとに、不連続点が2点解消る
	happy += K*2;
	if ( happy > N-1 )
		happy = N-1;
	
	cout << happy << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int N,T;
	cin>>N>>T;
	vec(A)
	map<int,int> K;
	fx(N){
		vecp(A)
	}
	int mini=INT_MAX;
	int maxi=0;
	fx(N){
		if(A.at(x)<mini){
			mini=A.at(x);
		}
		maxi=max(A.at(x)-mini,maxi);
		K[A.at(x)]++;
	}

	int ans=0;
	fx(N){
		if(K[A.at(x)+maxi]>0){
			ans++;
		}
      K[A.at(x)]=0;
	}
	ce(ans)
	
}

Measured memory_bytes: 9976
def selectionsort(A, N):
	count = 0
	for i in range(N):
		minj = i
		for j in range(i, N):
			if A[j] < A[minj]:
				minj = j
		A[i], A[minj] = A[minj], A[i]
		if (A[i] != A[minj]):
			count += 1
	return count

def main():
	n = int(input())
	data = list(map(int, input().split()))

	c = selectionsort(data, n)
	print(*data)
	print(c)

if __name__ == "__main__":
	main()

Measured memory_bytes: 7740
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define re cin>>
#define pr cout<<
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)


const int N=2e6+5;
const int mod=1e9+7;

int n,x;

int main(){
      int xx;
      cin>>x>>n;
      set<int> st;
      for(int i=1;i<=n;i++) {
            cin>>xx;
            st.insert(xx);
      }

      int res=-100, mnDiff=INT_MAX;
      for(int i=0;i<=104;i++){
            if(st.find(i)!=st.end()) continue;
            int d= abs(i-x);
            if(d<mnDiff){
                  mnDiff=d;
                  res=i;
            }
      }
      
      cout<<res;
      return 0;
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
#define MAX 50
int H,W,n;
char t[MAX][MAX];
char u[MAX][MAX];
int flg[MAX][MAX];
bool drop(){
  bool res=false;
 
  for(int j=0;j<W;j++){
    int cnt=H-1;
    for(int i=H-1;i>=0;i--){
      if(t[i][j]=='.')continue;
      t[cnt][j]=t[i][j];
      cnt--;
    }
    for(int i=cnt;i>=0;i--){
      if(t[i][j]!='.')res=true;
      t[i][j]='.';
    }
  }
  return res;
}
 
bool check(){
  for(int i=0;i<MAX;i++)
    for(int j=0;j<MAX;j++)
      t[i][j]=u[i][j];
  drop();
  while(1){
    for(int i=0;i<MAX;i++)
      for(int j=0;j<MAX;j++)
	flg[i][j]=false;
 
    for(int i=0;i<H;i++){
      int cnt=0;
      int key='.';
      for(int j=0;j<=W;j++){
	if(t[i][j]==key)cnt++;
	else {
	  if(cnt>=n&&key!='.')
	    for(int k=0;k<cnt;k++)flg[i][j-1-k]=true;
	  key=t[i][j];cnt=1;
	}
      }
    }
 
    for(int j=0;j<W;j++){
      int cnt=0;
      int key='.';
      for(int i=0;i<=H;i++){
	if(t[i][j]==key)cnt++;
	else {
	  if(cnt>=n&&key!='.')
	    for(int k=0;k<cnt;k++)flg[i-1-k][j]=true;
	  key=t[i][j];cnt=1;
	}
      }
    }
    for(int i=0;i<H;i++)
      for(int j=0;j<W;j++)
	if(flg[i][j])t[i][j]='.';
 
    if(!drop())break;
  }
 
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      if(t[i][j]!='.')return false;
  return true;
}
 
bool solve(){
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(j+1<W){
	swap(u[i][j],u[i][j+1]);
	if(check())return true;
	swap(u[i][j],u[i][j+1]);
      }

    }
  }
  return false;
}
 
void init(){
  for(int i=0;i<MAX;i++)
    for(int j=0;j<MAX;j++)
      u[i][j]='.';
}
 
int main(){
  cin>>H>>W>>n;
  init();
   
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      cin>>u[i][j];
   
  cout<<(solve()?"YES":"NO")<<endl;
   
  return 0;
}

Measured memory_bytes: 1172
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; i++)
#define repi(i, n, iv) for (int i = iv; i < n; i++)
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

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

    int N;
    cin >> N;

    vector<int> A(N);
    int all = 0;
    rep(i, N)
    {
        cin >> A[i];
        all ^= A[i];
    }

    rep(i, N)
    {
        if (i != 0)
            cout << " ";
        cout << (all ^ A[i]);
    }
    cout << endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>

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

//最大公約数
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}

//最小公倍数
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}

typedef long long ll;

ll a[51];
ll b[51];
ll c[51];
ll d[51];

int main(){
	int n, m;
	
	cin >> n >> m;
	
	REP(i,n){
		scanf("%lld %lld", &a[i], &b[i]);
	}
	
	REP(i,m){
		scanf("%lld %lld", &c[i], &d[i]);
	}
	
	REP(i,n){
		int mi = -1;
		int s;
		REP(j,m){
			int l;
			
			l = abs(a[i]-c[j])+abs(b[i]-d[j]);
			
			if (mi == -1 || mi > l){
				mi = l;
				s = j;
			}
		}
		cout << s+1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  map<ll, ll> mp1, mp2;
  for (int i = 0; i < n; ++i) {
    mp1[a[i] + (i + 1)]++;
    mp2[(i + 1) - a[i]]++;
  }
  ll ans = 0;
  for (auto a : mp1) {
    ans += a.second * mp2[a.first];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 38128
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        n: usize, k: usize,
    }
    let mut dp = vec![false; n];

    for _ in 0..k {
        input! {
            d: usize,
            a: [usize; d],
        }
        for i in 0..d {
            dp[a[i] - 1] = true;
        }
    }

    println!("{}", dp.iter().filter(|&&x| x == false).count());
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    int n;
    cin >> n;
    pair<ld,ld> arr[n];
    for (int i=0;i<=n-1;i++)
    {
        cin >> arr[i].first >> arr[i].second;
    }

    ld ans=0;
    int count=0;
    for (int i=0;i<=n-1;i++)
    {
        for (int j=i+1;j<=n-1;j++)
        {
            ld a=pow((arr[i].first-arr[j].first),2);
            ld b=pow((arr[i].second-arr[j].second),2);
            ld local=(ld)pow(a+b,0.5);
            ans=ans+local;
            count++;
        }
    }
    
    cout << (ld)(ans*(n-1))/(ld)count << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	string s,t;
	cin>>s>>t;
	int x=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=t[i])x++;
	}
	cout<<x;
	return 0;
}

Measured memory_bytes: 3860
from decimal import Decimal, ROUND_FLOOR
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    A,B=map(str,input().split())

    val=Decimal(B)*Decimal(A)
    print(int(val))
    
resolve()

Measured memory_bytes: 71376
import java.util.*;

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

		Map<String,Integer> map = new TreeMap<>();

		int n = scan.nextInt();

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

			int query = scan.nextInt();
			String key = scan.next();

			switch(query) {

			case 0:
				int value = scan.nextInt();
				map.put(key, value);
				break;

			case 1:
				System.out.println(map.get(key));
				break;
			}
		}
	}
}



Measured memory_bytes: 192956
import java.util.Scanner;

public class Main {

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

		//定義
		final int mod = 1000000007;
		long sum = 0;
		long tmp = 0;

		//入力値の取得
		int N = sc.nextInt();
		long[] A = new long[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextLong();

			//2番目以降の合計値
			if(i > 0) {
				tmp = add(tmp, A[i], mod);
			}
		}

		//計算
		for(int i=0; i < N-1; i++) {
			sum = add(sum, multiple(A[i],tmp, mod), mod);
			tmp = subtract(tmp, A[i+1], mod);
		}

		System.out.print(sum);
	}

	private static long multiple(long A, long B, int mod) {
		long ans = 0;
		ans = (A*B)%mod;
		return ans;
	}

	private static long add(long A, long B, int mod) {
		long ans = 0;
		ans = (A+B)%mod;
		return ans;
	}

	private static long subtract(long A, long B, int mod) {
		long ans = 0;
		ans = (A-B)%mod;
		if(ans < 0) {
			ans += mod;
		}
		return ans;
	}
}


Measured memory_bytes: 61592
#include <stdio.h>

int main()
{
	int i, j, x;
	char str[100];

	while(gets(str)){
		int num[100] = {'\0'};

		i = 0;
		j = 0;

		while(str[i] != '\0'){
			switch(str[i]){
				case 'I':
					x = 1;
					break;
				case 'V':
					x = 5;
					break;
				case 'X':
					x = 10;
					break;
				case 'L':
					x = 50;
					break;
				case 'C':
					x = 100;
					break;
				case 'D':
					x = 500;
					break;
				case 'M':
					x = 1000;
					break;
				default:
					return 0;
			}

			if(i == 0) num[j] = x;
			else if(str[i] == str[i-1]) num[j] += x;
			else {j++; num[j] = x;}

			i++;
		}

		i = 0;
		x = 0;
		while(num[i] != '\0'){
			if(num[i] < num[i+1]) x -= num[i];
			else x += num[i];

			i++;
		}

		printf("%d\n", x);
	}

	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 100010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//************************************************************************//

//N以下の素数列挙

vector <int> enum_prime(int N){
	N = sqrt(N+1);
	bool prime[N];
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;

	for (int i = 2; i < N; i++)
	{
		if (!prime[i]) continue;
		for (int j = 2; i * j < N; j++)
		{
			prime[i*j] = false;
		}
	}

	vector <int> ps;
	rep(N, i)
	{
		if (prime[i]) ps.pb(i);
	}

	return ps;
}

bool isprime(int x)
{
	if (x == 1) return false;
	for (int i = 2; i * i <= x; i++)
	{
		if (x % i) continue;
		return false;
	}
	return true;
}

//************************************************************************//


void solve(void){
	int N;
	cin >> N;

	vec ps = enum_prime(N);

	cout << N << ":";

	if (isprime(N))
	{
		cout << ' ' << N << endl;
		return;
	}

	//cout << ps << endl;

	for (int p : ps)
	{
		if (N == 1)
		{
			break;
		}

		while(N % p == 0 && N != 1)
		{
			cout << ' ' << p;
			N /= p;
		}
	}

	if (isprime(N))
	{
		cout << ' ' << N;
	}

	cout << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3180
#include <stdio.h>
int main(){
    int N;
    scanf("%d", &N);
    int V[N], C[N];
    for(int i=0;i<N;i++){
        scanf("%d", &V[i]);
    }
    for(int i=0;i<N;i++){
        scanf("%d", &C[i]);
    }
    int ans = 0;
    for(int i=0; i<N; i++){
        if(V[i]>C[i]){
            ans += V[i]-C[i];
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int main() {
    int a,b;cin >> a >> b;
    if (a <= 9 && b <= 9) {
        cout << a * b << endl;
    }
    else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

void solve(){
    int n;
    string msg;
    while(cin>>n&&n!=0){
        cin>>msg;
        int aa[1000];int bb[1000];
        for(int i = 0; i < n; i++)
            cin>>aa[i]>>bb[i];
        for(int i = n-1; i >= 0; i--){
            int a,b;
            a=aa[i];
            b=bb[i];
            a--;b--;
            int diff=abs(a-b);
            swap(msg[a],msg[b]);
            int an=msg[a]-97;
            int bn=msg[b]-97;
            an=(an+diff)%26;
            bn=(bn+diff)%26;
            msg[a]=an+97;
            msg[b]=bn+97;
        }
        cout<<msg<<endl;
    }
}

int main(){

    solve();

    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const ll INF = 1 << 31;
int N;
struct zahyou {
    int x, y, num;
};

bool rx( const zahyou& left, const zahyou& right ) {
    return left.x == right.x ? left.num < right.num : left.x < right.x;
}
bool ry( const zahyou& left, const zahyou& right ) {
    return left.y == right.y ? left.num < right.num : left.y < right.y;
}
vector<zahyou> vec;
struct Edge {
    int to;
    ll cost;
};
vector<Edge> c[100001];
ll mincost[100001];

typedef pair<ll, int> pii; // (cst, to)
//vector<pii> G[100001];
bool used[100001];

int prim() {
    priority_queue<pii, vector<pii>, greater<pii> > que;
    for(int i = 0; i < N; ++i){
        //mincost[i] = INF;
        used[i] = false;
    }
    que.push(pii(0,0));
    int ret = 0;
    while(!que.empty()) {
        int cst = que.top().first, v = que.top().second;
        que.pop();
        if(used[v]) continue;
        used[v] = true;
        ret += cst;
        for(int i = 0; i < c[v].size(); i++)
            que.push(pii(c[v][i].cost, c[v][i].to));
    }
    return ret;
}
/*
int prim(){
    for(int i = 0; i < N; ++i){
        mincost[i] = INF;
        used[i] = false;
    }
    mincost[0] = 0;
    int res = 0;

    while
}*/

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

    cin >> N;
    for(int i = 0; i < N; ++i){
        int x, y;
        cin >> x >> y;
        vec.push_back((zahyou){x, y, i});
    }

    sort(vec.begin(), vec.end(), rx);

    zahyou px = vec[0];
    for(size_t i = 1; i < vec.size(); ++i){
        c[vec[i].num].push_back((Edge){px.num, vec[i].x - px.x});
        c[px.num].push_back((Edge){vec[i].num, vec[i].x - px.x});
        px = vec[i];
    }

    sort(vec.begin(), vec.end(), ry);

    zahyou py = vec[0];
    for(size_t i = 1; i < vec.size(); ++i){
        c[vec[i].num].push_back((Edge){py.num, vec[i].y - py.y});
        c[py.num].push_back((Edge){vec[i].num, vec[i].y - py.y});
        py = vec[i];
    }

    cout << prim() << endl;

    return 0;
}

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

int main() {
  string s;
  cin>>s;
  int n=s.size();
  int s_cnt=0,t_cnt=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='T'){
      if(s_cnt>0)s_cnt--;
      else t_cnt++;
    }else s_cnt++;
  }
  cout<<t_cnt*2<<endl;
  return 0;
}

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

int main(){
    while(1){
        string s;
        cin>>s;
        if(s=="-"){
            break;
        }
        int m;
        cin>>m;
        for(int i=0;i<m;i++){
            string tmp=s;
            s="";
            int h;
            cin>>h;
            for(int j=h;j<(int)tmp.size();j++){
                s+=tmp[j];
            }
            for(int j=0;j<h;j++){
                s+=tmp[j];
            }
        }
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 3152
# include <iostream>
# include <algorithm>

using namespace std;

int N, last, height[100010], dp[100010];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> height[i];
  
  dp[0] = 0;
  
  for (int i = 0; i < N; i++) {
    if (i == 0) continue;
    
    if (i == 1) {
      dp[i] = dp[i - 1] + abs(height[i] - height[i - 1]);
      continue;
    }
    
    dp[i] = min(dp[i - 1] + abs(height[i] - height[i - 1]), dp[i - 2] + abs(height[i] - height[i - 2]));
  }
  
  cout << dp[N - 1] << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n = f.read_int()
    s = [f.read_str() for _ in xrange(n)]

    ans = 0
    for a in xrange(n):
        si = s[a:] + s[:a]

        flg = True
        for i in xrange(n):
            for j in xrange(n):
                if si[i][j] != si[j][i]: flg = False

        if flg: ans += 1

    return ans * n


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 35816