akhauriyash/Code-Regression huggingface dataset:
/* ***************************************
Author        :Scau.ion
Created Time  :2017/09/23 19:58:01 UTC+8
File Name     :ion.cpp
*************************************** */

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

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

int main()
{
    IOS;
    string s;
    cin>>s;
    if (s.size() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
//Solution for aoj:0530 Pyon-Pyon River Crossing
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int INF = 10000000000, MAX_N = 150;
typedef pair<int, int> P;
int n, m, ans;
int dp[MAX_N + 3][1001][76];
P stone, stone2;
vector<P> Stone[151]; //first:??????second:???????????????
int main(){
	while (cin >> n >> m){
		if (!n&&!m)
			return 0;
		for (int i = 1; i <= n; i++)
			Stone[i].clear();
		for (int i = 1; i <= n; i++){
			int a, b, c;
			cin >> c;
			for (int j = 0; j < c; j++){
				cin >> a >> b;
				Stone[i].push_back(P(a, b));
			}
		}
		for (int i = 2; i <= n; i++){
			for (int j = 1; j <= 1000; j++){
				for (int k = 0; k <= m; k++){
					dp[i][j][k] = 0;
				}
			}
		}
		for (int i = 0; i < Stone[2].size(); i++){
			stone = Stone[2][i];
			dp[2][stone.first][m] = INF;
		}
		for (int i = 3; i <= n; i++){
			for (int j = 0; j < Stone[i].size(); j++){
				stone = Stone[i][j];
				for (int k = 0; k <= 75; k++)
					dp[i][stone.first][k] = INF;
			}
		}
		for (int i = 1; i < n; i++){
			for (int j = 0; j < Stone[i].size(); j++){
				stone = Stone[i][j];
				for (int k = 0; k < Stone[i + 1].size(); k++){
					stone2 = Stone[i + 1][k];
					for (int l = m; l >= m - i / 2; l--){
						if (l < 0)
							break;
						dp[i + 1][stone2.first][l] = min(dp[i + 1][stone2.first][l], (stone.second + stone2.second)*abs(stone.first - stone2.first) + dp[i][stone.first][l]);
					}
				}
				for (int k = 0; k < Stone[i + 2].size(); k++){
					if (i + 2 > n)
						break;
					stone2 = Stone[i + 2][k];
					for (int l = m - 1; l >= m - (i + 2) / 2; l--){
						if (l < 0)
							break;
						dp[i + 2][stone2.first][l] = min(dp[i + 2][stone2.first][l], (stone.second + stone2.second) * abs(stone.first - stone2.first) + dp[i][stone.first][l + 1]);
					}
				}
			}
		}
		ans = INF;
		for (int i = 0; i < Stone[n].size(); i++){
			stone = Stone[n][i];
			for(int j = 0; j <= m; j++)
			  ans = min(dp[n][stone.first][j], ans);
		}
		for (int i = 0; i < Stone[n - 1].size(); i++){
			stone = Stone[n - 1][i];
			for(int j = 1; j <= m; j++)
			  ans = min(dp[n - 1][stone.first][j], ans);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 45684
#include <stdio.h>
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<17, stdin), p1 == p2) ? EOF : *p1++)
char buf[(1 << 17)], *p1 = buf, *p2 = buf;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int ab[(1<<17)];
int main(int argc, char *argv[])
{
	int n = read(),m = read();
	for (int i = 0; i < m; ++i) {
		int a = read(),b = read();
		if (*(ab+b) < a) {*(ab+b) = a;}
	}
	int ans = 0;
	int k = 1;
	for (int i = 1; i <= n; ++i) {
		if (k <= *(ab+i)) {
			k = i;
			++ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

//create arrays outside of main()
int a[50] = {};

stack<char> s;


int main() {

    int n;
    int k;
    cin >> n >> k;

    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    sort(a, a+n, greater<int>());

    int sum=0;

    for(int i=0; i<k; i++){
        sum += a[i];
    }

    cout << sum;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<int> sum1(n+1,0),sum2(n+1,0);
	rep(i,n){
		sum1[i+1]=sum1[i];
		if(s[i]=='W') sum1[i+1]++;
	}
	for(int i=n-1;i>=0;i--){
		sum2[i]=sum2[i+1];
		if(s[i]=='E') sum2[i]++;
	}
	int ans=INF;
	rep(i,n){
		chmin(ans,sum1[i]+sum2[i+1]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define FORD(i,a,b) for(int i = (a); i >= (b); i--)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define M_PI 3.14159265358979323846
template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
	while (*sdbg != ',')cerr << *sdbg++; cerr << '=' << h << ','; _dbg(sdbg + 1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
	os << "["; for (auto& vv : V) os << vv << ","; os << "]";
	return os;
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
	return os << "(" << P.st << "," << P.nd << ")";
}


#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif

template<typename Out>
void split(const std::string &s, char delim, Out result) {
	std::stringstream ss(s);
	std::string item;
	while (std::getline(ss, item, delim)) {
		*(result++) = item;
	}
}

std::vector<std::string> split(const std::string &s, char delim) {
	std::vector<std::string> elems;
	split(s, delim, std::back_inserter(elems));
	return elems;
}

void trim(string & s) {
	int idx = 0;
	int n = s.size();
	REP(i, n) {
		if (s[i] != ' ' && s[i] != '\t') {
			s = s.substr(i);
			break;
		}
	}
	while (!s.empty()) {
		if (s.back() == ' ' || s.back() == '\t') {
			s.pop_back();
		}
		else {
			break;
		}
	}
}

bool usuwaj;
int nodes;
int32_t main(int32_t argc, char ** argv) {
	ios_base::sync_with_stdio(0);
	string s;
	cin >> s;
	if (s.find("AC") != string::npos) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

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

using namespace std;

void solve()
{
	int N;
	cin >> N;
	vector< vector<int> > integer(N, vector<int>(3));
	for(int i = 0; i < N; ++i)
	{
		for(int j = 0; j < 3; ++j)
		{
			cin >> integer[i][j];
		}
	}
	vector<int> sum(N);
	for(int a = 0; a < 3; ++a)
	{
		for(int i = 0; i < N; ++i)
		{
			bool same_flag = false;
			for(int j = 0; j < N; ++j)
			{
				if(i == j)
				{
					continue;
				}
				int point = integer[i][a];
				if(point == integer[j][a])
				{
					same_flag = true;
					break;
				}
			}
			if(!same_flag)
			{
				sum[i] += integer[i][a];
			}
		}
	}
	for(int i = 0; i < N; ++i)
	{
		cout << sum[i] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <numeric>
#include <climits>
#define ll long long
#define INF 1000000000
using namespace std;
struct UnionFind{
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i=0;i<N;i++){
            par[i] = i;
        }
    }
    int root(int x){
        if(par[x]==x)return x;
        return par[x] = root(par[x]);
    }
    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx==ry) return;
        par[rx] = ry;
    }
    bool same(int x,int y){
        int rx = root(x);
        int ry = root(y);
        return rx==ry;
    }
    int parent(int x){
        return root(x);
    }
};

int main(){
    int ans=0;
    int N,M;
    cin >> N >> M;
    int a[M+5],b[M+5];
    int graph[N][N];
    for(int i=0;i<M;i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        graph[a[i]][b[i]] = 1;
        graph[b[i]][a[i]] = 1;
    }
    for(int i=0;i<M;i++){
        UnionFind tree(N+5);
        for(int j=0;j<M;j++){
            if(i!=j) tree.unite(a[j],b[j]);
        }
        if(!tree.same(a[i],b[i])) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
a = list(map(int, input().split()))
b = [v if v < x else x for v in a]
for i in range(1, n):
    if b[i - 1] + b[i] > x:
        b[i] = x - b[i - 1]
print(sum(i - j for i, j in zip(a, b)))

Measured memory_bytes: 14540
package main

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

func main() {
	S := readstr()
	fmt.Println(strings.Repeat("x", len(S)))
}

const (
	iobufsize = 1 * 1024 * 1024 // 1 MB
)

var stdinsc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, iobufsize), iobufsize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func readint() int {
	stdinsc.Scan()
	v, err := strconv.Atoi(stdinsc.Text())
	if err != nil {
		panic(err)
	}
	return v
}

func readstr() string {
	stdinsc.Scan()
	return stdinsc.Text()
}

func pow(x, y int) int {
	if y < 1 {
		return 1
	}
	return x * pow(x, y-1)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
constexpr double pi=3.141592653589793238;
//int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    double a,b;
    double h,m;
    cin>>a>>b>>h>>m;
    h+=m/60;
    if(h<=3)h=3-h;
    else h=15-h;
    //double cx=a*cos(h*pi/6),cy=a*sin(h*pi/6);
    if(m<=15)m=15-m;
    else m=75-m;
    double theta1=h*pi/6,theta2=m*pi/30,theta=abs(theta1-theta2);
    theta=min(theta,pi+pi-theta);
    printf("%.12lf\n",sqrt(a*a+b*b-2.0*a*b*cos(theta)));
    //double dx=b*cos(m*pi/30),dy=b*sin(m*pi/30);
    //printf("%.12lf\n",hypot(cx-cy,dx-dy));
    return 0;
}

Measured memory_bytes: 4240
#include <cstdio>
int main() {
	int n, cur_num = 1, next_num;
	scanf("%d", &n);
	int a[n + 2];
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= n; i++) {
		next_num = a[cur_num];
		cur_num = next_num;
		if (next_num == 2) {
			printf("%d\n", i);
			return 0;
		}
	}
	printf("-1\n");
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    ll cnt = 0;
    rep(i, N){
        ll x; cin >> x;
        while (true){
            if (x % 2 == 0){x /= 2; cnt++;}else{break;}
        }
    }
    cout << cnt << endl;
}

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


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

using namespace std;

int main() { 

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	int n;
	cin >> n;

	vector<long long> a(n);
	
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] *= 2;
	}
	int k = 1;
	long long s = 0;
	for(int i = 0; i < n; i++) {
		if(k == 1) s += a[i];
		else s -= a[i];
		k = 1 - k; 
	}
	vector<long long> ans(n);
	ans[0] = s / 2;
	for(int i = 1; i < n; i++) {
		ans[i] = a[i-1] - ans[i-1];
	}
	for(auto i : ans) cout << i << ' ';

	return 0; 
}

Measured memory_bytes: 2944
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
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var ans = 0;
            for(int i = N; i > 0; i--)
            {
                if(((int)Log10(i) + 1) % 2 == 0)
                {
                    i = (int)Pow(10, (int)Log10(i)) - 1;
                    ans++;
                    continue;
                }
                ans++;
            }
            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: 13268
#include<bits/stdc++.h>
using namespace std;
int graph[101][101];
int main(){
    int n;
    cin>>n;
    int max_cnt=INT_MIN;
    int maxx=1;
    for(int i=1;i<=n;i++){
        int cnt=0;
        int x=i;
        while(x%2==0){
            x=x/2;
            cnt++;
        }
        if(cnt>max_cnt){
            max_cnt=cnt;
            maxx=i;
        }
    }
    cout<<maxx<<endl;
    return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int p,q,m;
    cin >> p >> q >> m;

    int a[p], b[q];
    int mia = 1001001001;
    int mib = 1001001001;
    rep(i,p){
        cin >> a[i];
        mia = min(mia, a[i]);
    }
    rep(i,q){
        cin >> b[i];
        mib = min(mib, b[i]);
    }

    int ans = mia + mib;

    rep(i,m){
        int x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        ans = min(ans, a[x] + b[y] - c);
    }

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


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  function<int(int, int, int, int)> f = [&](int idx, int a, int b, int c) {
    if (idx == N) {
      if (a == 0 || b == 0 || c == 0) return 1 << 28;
      return abs(A - a) + abs(B - b) + abs(C - c) - 30;
    }
    int res = 1 << 28;
    res = min(res, f(idx + 1, a, b, c));
    res = min(res, f(idx + 1, a + L[idx], b, c) + 10);
    res = min(res, f(idx + 1, a, b + L[idx], c) + 10);
    res = min(res, f(idx + 1, a, b, c + L[idx]) + 10);
    return res;
  };
  cout << f(0, 0, 0, 0) << '\n';
  return 0;
}


Measured memory_bytes: 256
S,C[100][100];main(s,d){for(;scanf("%d%d",&s,&d)*s;printf("%d\n",S)){int D[100]={S=0},u=s+d,c[100],x,p,m,i,j,v;memset(C,0,4e4);for(j=0;j<s;j++)for(i=0;i<d;i++)scanf("%d",&v),C[j][s+i]=C[s+i][j]=v?v:1e9;for(j=0;j<d-1;j++)for(i=0;i<d-j-1;i++)scanf("%d",&v),C[s+j][s+j+1+i]=C[s+j+1+i][s+j]=v?v:1e9;for(i=s+d;i--;)c[i]=1e9;for(x=m=0;u--;x=p)for(D[x]=1,S+=m,m=1e9,i=s+d;i--;)!D[i]?C[x][i]<c[i]?c[i]=C[x][i]:0,c[i]<m?m=c[p=i]:0:0;}}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc =new Scanner(System.in);
        int index= Integer.parseInt(sc.nextLine());
        String[] str = sc.nextLine().split(" ");
        for(int loo=str.length;loo>0;loo--){
            if(loo!=1)System.out.print(str[loo-1]+" ");
            else System.out.print(str[loo-1]);
        
    }
    System.out.println();

}}


Measured memory_bytes: 26128
X,K,D = map(int,input().split())

if X>0:
  zen = X//D
  amari = X%D
  if K<zen:
    print(X-K*D)
  elif K==zen or (K-zen)%2 == 0:
    print(amari)
  else:
    print(abs(amari-D))
    
elif X<0:
  zen = -X//D
  amari = -(-X%D)
  if K<zen:
    print(abs(X+K*D))
  elif K==zen or (K-zen)%2 == 0:
    print(abs(amari))
  else:
    print(amari+D)

else:
  if K%2==1:
    print(D)
  else:
    print(0)

Measured memory_bytes: 9236
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in h,w;
  cin>>h>>w;
  in cc=0;
  string s;
  forn(i,h){
    cin>>s;
    forn(j,w)
      cc+=(s[j]=='#');
  }
  if(cc==(h+w-1))
    cout<<"Possible"<<endl;
  else
    cout<<"Impossible"<<endl;
  return 0;
}


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

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

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

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  string ss[h];
  rep(i, h) {
    cin >> ss[i];
  }

  rep(i, w + 2) cout << "#";
  cout << endl;

  rep(i, h) {
    cout << "#";
    cout << ss[i];
    cout << "#" << endl;
  }

  rep(i, w + 2) cout << "#";
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

counts = {}
for a in A:
    if a not in counts:
        counts[a] = 1
    else:
        counts[a] += 1
        
count_pairs = []
for key,val in counts.items():
    count_pairs.append((val, key))
    
    
count_pairs.sort()
count_pairs.reverse()
if len(count_pairs) <= K:
    print(0)
else:
    non_change_num = 0
    for i in range(K):
        val, _ = count_pairs[i]
        non_change_num += val
    print(N - non_change_num)

Measured memory_bytes: 38428
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll n;
  cin >> n;
  vll a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  vll dp(100100, INF); //dp.at(i)は長さi+1のときの最終要素の最小値
  dp.at(0) = a.at(0);
  for(int i = 0; i < n; i++){
    *lower_bound(ALL(dp), a.at(i)) = a.at(i);
  }
  ll ans = distance(dp.begin(), lower_bound(ALL(dp), INF));
  cout << ans << endl;
}


Measured memory_bytes: 4432
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
string S;
cin >> S;
for (int i = 0;i < S.size() -1;i++) {
    for (int j = i+1;j < S.size();j++) {
        if (S.at(i) == S.at(j)) {
            cout << "no" << endl;
            return 0;
        }
    }
}
cout << "yes" << endl;


return 0;
}


Measured memory_bytes: 256
# encoding: ISO-8859-1
$n = gets.to_i
$s = gets.chop
$t = gets.chop

def st_intersection?(i)
  $s[-i..-1] ==  $t[0..(i-1)]
end

def find_largest_intersection
  $n.downto(1) do |i|
    return i if st_intersection? i
  end
   return 0
end


common = find_largest_intersection


puts 2 * $n - common

Measured memory_bytes: 1788
N = int(input())
AS = [int(i) for i in input().split()]
BS = [int(i) for i in input().split()]

cnt = 0
for i, b in enumerate(BS):
    a = AS[i]
    if a <= b:
        cnt += a
        s = b - a
        if s >= AS[i + 1]:
            cnt += AS[i + 1]
            AS[i + 1] = 0
        else:
            cnt += s
            AS[i + 1] -= s
    else:
        cnt += b


print(cnt)


Measured memory_bytes: 18468
#include<stdio.h>

long gcm(int a,int b){
		if(a%b==0)return b;
		return gcm(b,a%b);
}

int main(){
		int n,m;
		long ans,i,a,b;
		char s[100001],t[100001];
		scanf("%d%d%s%s",&n,&m,s,t);
		ans=(long)n*m/gcm(n,m);
		a=(long)n/gcm(n,m);
		b=(long)m/gcm(n,m);
		for(i=0;i<ans;i+=(a*b)){
				if(s[i/b]!=t[i/a]){
						puts("-1");
						return 0;
				}
		}
		printf("%ld\n",ans);
		return 0;
}


Measured memory_bytes: 384
//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX=200000;

int main(){
    int K,N,ans=0;
    int A[MAX];
    int num[MAX+1]={0};
    cin>>N>>K;
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
        num[A[i]]++;
    }
    sort(num,num+MAX);
    int* bnd=lower_bound(num,num+MAX+1,1);
    for(int i=bnd-num;i<=MAX;i++){
        if(MAX-i<=K){
            break;
        }
        ans+=num[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
using System;

class Atcoder47
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');

        if (input[0] == "H" && input[1] == "H")
            Console.WriteLine("H");
        else if (input[0] == "H" && input[1] == "D")
            Console.WriteLine("D");
        else if (input[0] == "D" && input[1] == "H")
            Console.WriteLine("D");
        else
            Console.WriteLine("H");
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string s;
	cin >> s;
	int ans = 0;
	rep(i, 0, 4)
	{
		if (s[i] == '+')ans++;
		else ans--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int n; cin >> n;
  if (n==1) cout << 0 << endl;
  else cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 3628
n = int(input())
a = list(map(int, input().split()))
count = 0
alice = 0
bob = 0
a.sort()
f = 0
while(len(a) != 0):
    if f == 0:
        alice = alice + a.pop(-1)
        f = 1
    else:
        bob = bob + a.pop(-1)
        f = 0
print(alice - bob)


Measured memory_bytes: 3060
n,k = map(int, input().split())
x = list(map(int, input().split()))

s = 10**9
for i in range(n-k+1) :
  m = min(abs(x[i]) +abs(x[i+k-1] - x[i]) , abs(x[i+k-1]) + abs(x[i+k-1] - x[i]))
  if s >m :
    s = m
print(s)



Measured memory_bytes: 14384
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] arr = reader.readLine().split(" ");
        int a = Integer.parseInt(arr[0]);
        int b = Integer.parseInt(arr[1]);
        int ans = 0;
        if (a < b) {
            ans = a;
            for (int i = 0; i < b - 1; i++)
                ans = 10 * ans + a;
        } else {
            ans = b;
            for (int i = 0; i < a - 1; i++)
                ans = 10 * ans + b;
        }
        System.out.println(ans);
    }
}

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

#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, b, a) for(int i = (b); i >= (a); --i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define boost ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define M (ll)(1e9+7)
#define inf (ll)(2e9+9)
#define infl (ll)(2e18+9)
#define debug1(a) cout<<#a<<" = " <<a<<endl; 
#define debug2(a,b) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<endl; 
#define debug3(a,b,c) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<" , "<<#c<<" = "<<c<<endl; 
#define debug4(a,b,c,d) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<" , "<<#c<<" = "<<c<<" , "<<#d<<" = " <<d<<endl; 
  
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<char> vc; 
typedef vector<ll> vll; 
typedef vector< pair<int,int> > vpii;

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



void solve(){
  int n,w; cin>>n>>w; 
  vector<pair<int,int>> item(n); 
  rep(i,0,n-1){
    int wi,vi; cin>>wi>>vi; 
    item[i]={wi,vi}; 
  }
  vector<vector<ll>> dp(n,vector<ll>(w+1)); 
  rep(i,0,n-1){
    rep(j,0,w){
      if(i==0){
        if(j>=item[i].first) dp[i][j]=item[i].second;  
      }   
      else{
        if(j<item[i].first){
          dp[i][j]=dp[i-1][j];  
        } 
        else{
          dp[i][j]=max(dp[i-1][j],dp[i-1][j-item[i].first]+item[i].second); 
        }
      }
    }
  }
  cout<<dp[n-1][w]; 
}

int main() {
  clock_t beg=clock(); 
  boost;
  int t=1; 
  // cin>>t; 
  while(t--){
    solve(); 
  }
  clock_t end=clock(); 
  fprintf(stderr, "%lf\n", (double)(end-beg)/CLOCKS_PER_SEC);
}


Measured memory_bytes: 79488
//
// Created by Myabu on 2020/01/16.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    int R,G;
    cin>>R>>G;
    
    cout<<2*G-R<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int s=S.size();
  map<char,int> ma;
  for(int i=0;i<s;i++){
    ma[S[i]]++;
  }
  for(char c='a';c<='z';c++){
    if(ma[c]==0){
      cout<<c<<endl;
      return 0;
    }
  }
  cout <<"None"<<endl;
}
//電車のなかでACしました褒めてください

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

using namespace std;

typedef long long ll;

ll a[200001];
ll b[200001];
ll c[200001];

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

    int ans = 0;
    for (int k = 0; k < 29; ++k)
    {
        int T = 1 << k;
        for (int i = 0; i < N; ++i) c[i] = b[i] % (T*2);
        sort(c, c+N);

        int tmp = 0;
        for (int i = 0; i < N; ++i)
        {
            int aa = a[i] % (T*2);
            int t  = lower_bound(c, c+N, T - aa) - c;
            int t2 = lower_bound(c, c+N, 2*T - aa) - c;
            int t3 = lower_bound(c, c+N, 3*T - aa) - c;
            tmp += (t2 - t) + (N - t3);
        }
        if (tmp % 2 != 0) ans += T;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
using namespace std;
using ll = long long;

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

ll INF = 1e12;
/*
int main() {
  ll L, R;
  cin >> L >> R;
  ll min = INF;

  for(ll i = L; i < L + 2019 && i <= R - 1; ++i) {
    for(ll j = i + 1; j < i + 1 + 2019 && j <= R; ++j) {
      chmin(min, (i * j) % 2019);
      if(min == 0) {
        break;
      }
    }
  }
  cout << min << endl;
  return 0;
}
*/
int main() {
  ll L, R;
  cin >> L >> R;
  if((R - L) / 2019 > 0) {
    cout << 0 << endl;
    return 0;
  }
  ll l = L % 2019;
  ll r = R % 2019;
  if(l > r) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = INF;
  for(ll i = L; i <= R - 1; ++i) {
    for(ll j = i + 1; j <= R; ++j) {
      chmin(ans, (i * j) % 2019);
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	string n; cin >> n;
	int s = n.length();

	string ans;
	for (int i = 0; i < s; ++i) {
		if (n[i] == '0') ans += '0';
		else if (n[i] == '1') ans += '1';
		else if (n[i] == 'B' && !ans.empty()) ans.erase(ans.begin() + ans.length() - 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <deque>
//#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
const int N=1e5+7;
int a[N];
int main()
{
    int n;
    while(cin>>n)
    {
        for(int i=1;i<=n;i++)
            cin>>a[i];
        if(n%2==1)
        {
            cout<<"0"<<endl;
            continue;
        }
        sort(a+1,a+n+1);
        if(a[n/2]==a[n/2+1])
        {
            cout<<"0"<<endl;
            continue;
        }
        cout<<a[n/2+1]-a[n/2]<<endl;
    }
    return 0;
}

Measured memory_bytes: 640
X, N = map(int, input().split())
P = list(map(int, input().split()))

lis = [1] * (201)
for p in P: lis[p+99] -= 1

for i in range(100+1):
    up = X+i
    down = X-i
    if lis[100+down-1] == 1:
        print(down)
        exit()
    elif lis[100+up-1] == 1:
        print(up)
        exit()


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


int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    if (n == 1)
        cout << "Hello World\n";
    else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int n,S;
ll ans;
map<int,ll> mp;
void solve(){
	if(mp.size()<2){
		ans+=abs(mp.begin()->first-S);
		S=mp.begin()->first;
		return;
	}
	if(S<=mp.begin()->first||S>=mp.rbegin()->first){
		ans+=max(abs(mp.begin()->first-S),abs(mp.rbegin()->first-S));
		S=mp.begin()->first>=S?mp.rbegin()->first:mp.begin()->first;
		return;
	}
	if(mp.rbegin()->second>mp.begin()->second){
		mp.rbegin()->second+=mp.begin()->second;
		int w=mp.begin()->first;
		mp.erase(mp.begin());
		solve();
		ans+=abs(w-S);S=w;
	}
	else{
		mp.begin()->second+=mp.rbegin()->second;
		int w=mp.rbegin()->first;
		mp.erase(--mp.end());
		solve();
		ans+=abs(w-S);S=w;
	}

}
int main(){
	read(n);read(S);
	for(int i=1;i<=n;i++){
		int x,p;read(x);read(p);
		mp[x]+=p;
	}
	solve();
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 9088
import sys
import bisect

sys.setrecursionlimit(10**9)

N = int(input())

L = [0]
l = 0
for i in range(1,10**6) :
    l += i
    L.append(l+1)
ans = []
while N > 0 :
    tmp = bisect.bisect(L,N)
    
    ans.append(tmp)
    N -= tmp
    
print(*ans,sep="\n")


Measured memory_bytes: 50708
#include <bits/stdc++.h>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
#define MOD 1000000007 
//ll dx[4] = {1,-1,0,0};
//ll dy[4] = {0,0,1,-1};

/*ll pasc[100][100];
ll getPasc(ll n,ll k){
  if(pasc[n][k]!=0){
    return pasc[n][k];
  }else{
    pasc[n][k] = getPasc(n-1,k-1)+getPasc(n-1,k);
    return pasc[n][k];
  }
}*/


int main(){
  ll n;
  cin>>n;
  ll a[n],b[n];
  ll asum,bsum;
  asum = 0;
  bsum = 0;
  REP(i,n){
    cin>>a[i];
    asum += a[i];
  }
  REP(i,n){
    cin>>b[i];
    bsum += b[i];
  }
  ll k = bsum-asum;
  if(k<0){
    cout<<"No"<<endl;
    return 0;
  }
  ll ak = k;
  ll bk = k;
  REP(i,n){
    if(a[i]<b[i]){
      ll dk = (b[i]-a[i]+1)/2;
      a[i] += dk*2;
      ak -= dk;
    }
  }
  REP(i,n){
    if(b[i]<a[i]){
      ll dk = a[i]-b[i];
      b[i] += dk;
      bk -= dk;
    }
  }
  //cout<<ak<<" "<<bk<<endl;
  if(ak<0||bk<0){
    cout<<"No"<<endl;
    return 0;
  }
  if(ak*2==bk){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  
  
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

    System.out.println(res);
  }

  private static int serch_divisor_number(int a, int b, int c){
    int m = 0;
    for (int i = a; i <= b; i++){
      if (c % i == 0) m++;
    }
    return (m);
  }
}

Measured memory_bytes: 26304
#include<stdio.h>
#define Max  100
#define inf (1<<21)
#define W 0
#define G  1
#define B 2

int n,M[Max][Max];

int prim(){
  int i,u,minv,v;
  int d[Max],p[Max],col[Max];

  for(i=0;i<n;i++){
    d[i]=inf;
    p[i]= -1;
    col[i] = W;
  }

  d[0] = 0;

  while(1){
    minv = inf;
    u = -1;
    for(i=0;i<n;i++){
      if(minv > d[i] && col[i] != B){
        u =i;
        minv = d[i];
      }
    }
    if(u == -1)break;
    col[u] = B;
    for(v = 0;v < n; v++){
      if(col[v] != B && M[u][v] != inf){
        if(d[v]>M[u][v]){
          d[v] = M[u][v];
          p[v] = u;
          col[v]=G;
        }
      }
    }
  }
int sum = 0;
  for(i = 0;i<n;i++){
    if(p[i] != -1)sum+=M[i][p[i]];
  }

  return sum;
}

int main(){
  int i,j,e;
  scanf("%d",&n);

  for(i = 0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j] = (e == -1) ? inf : e;
    }
  }

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

  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int a[1<<12][1<<12],ans[1<<12][1<<12];
void calc(int k){
    if(k==0){
        a[0][0]=0;
        return;
    }
    calc(k-1);
    int n=1<<(k-1);
    rep(i,n){
        rep(j,n){
            a[i+n][j]=a[i][j];
            a[i][j+n]=a[i][j];
            a[i+n][j+n]=1-a[i][j];
        }
    }
}
int n,m;
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>m;
    int N=max(n,m);
    calc(N);
    N=1<<N;
    rep(i,N-1){
        rep(j,N-1){
            if((a[i][j+1]+a[i+1][j]+a[i][j])%2==a[i+1][j+1]%2)ans[i][j]=0;
            else ans[i][j]=1;
        }
    }
    rep(i,(1<<n)-1){
        rep(j,(1<<m)-1){
            cout<<ans[i][j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 28184
DBG = !true
n = gets.to_i
a = []
even1 = false
odd1 = false
for i in 0...n
  x,y = gets.split.map{|z| z.to_i}
  a << [x, y]
  if (x+y)%2 == 0
    even1 = true
  else
    odd1 = true
  end
end

if odd1 && even1
  print -1
  exit
end

# if odd, add one to y
addstr = ''
if even1
  a.map!{|x| [x[0], x[1]+1]}
  addstr = 'D'
end

ds = []
d = 1
0.upto(35) {
  ds << d
  d *= 2
}
szd = 36
if even1
  ds << 1
  szd += 1
end

print szd
puts ""
for i in 0...szd
  print ds[i], " "
end
puts ""

for k in 0...n
  x,y = a[k]
  s = "012345678901234567890123456789012345" + addstr
  cx = cy = 0
  35.downto(0) { |i|
    dx = x-cx
    dy = y-cy
    if dx+dy > 0 && dx-dy > 0
      s[i] = 'R'
      cx += ds[i]
    elsif dx+dy < 0 && dx-dy > 0
      s[i] = 'D'
      cy -= ds[i]
    elsif dx+dy > 0 && dx-dy < 0
      s[i] = 'U'
      cy += ds[i]
    else #if dx+dy < 0 && dx-dy < 0
      s[i] = 'L'
      cx -= ds[i]
    end
  }
  puts s

  if DBG
    cx = cy = 0
    for i in 0...szd
      ch = s[i]
      if ch == 'R'
        cx += ds[i]
      elsif ch == 'L'
        cx -= ds[i]
      elsif ch == 'U'
        cy += ds[i]
      elsif ch == 'D'
        cy -= ds[i]
      end
    end
    realy = y - (even1 ? 1 : 0)
    if cx==x && cy==realy
      puts "ok"
    else
      printf("ng: x %d y %d cx %d cy %d\n", x, y, cx, cy)
    end
  end
end


Measured memory_bytes: 2172
/*
ID: dorijan1
TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
LANG: C++11
*/
#include <bits/stdc++.h>

using namespace std;

const int MOD=1000000007;
typedef long long int ll;
const ll LLINF=1ll<<60;

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

int gcd(int a,int b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

ll mult(ll a,ll b)
{
	return (a*b)%MOD;
}

ll pot(ll n,ll k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

ll divide(ll a,ll b)
{
	return mult(a,pot(b,MOD-2));
}

ll sub(ll a,ll b)
{
	return (a-b+MOD)%MOD;
}

ll add(ll a,ll b)
{
	return (a+b)%MOD;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

int n,m;

int main()
{
	std::ios_base::sync_with_stdio(false);
	cin>>n>>m;
	if (n%m==0) cout<<-1<<endl;
	else cout<<n<<endl;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const int Nmax=2e5+1;
const int Nd=61;
const int INF=1e5;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main(){
  int n; cin>>n;
  vector<int>a(n);
  mint suma=0,sumaa=0;
  mint temp1;
  rep(i,n){
    cin>>a[i];
    suma+=a[i];
    temp1=a[i];temp1*=a[i];
    sumaa+=temp1;
  }
  mint ans= suma*suma;
  ans-=sumaa;
  ans /=2;
  cout<<ans<<endl;




}


Measured memory_bytes: 3952
// Lucky 7

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
const int INF = 1 << 29;
int main ()
{
    string N;
    cin >> N;
    if (N.find('7')!=string::npos) {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
    

    return 0;
}

Measured memory_bytes: 3124
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++ )

int main(){
  int N;
  while(cin >> N , N){
    int cnt = 0;
    vector<int> data(N);
    rep(i,N) cin >> data[i];
    while("homo"){
      vector<int> now = data;
      rep(i,N) now[i] = count(data.begin(),data.end(),data[i]);
      if(now == data) break;
      data = now;
      cnt++;
    }
    cout << cnt << endl;
    rep(i,N) cout << (i?" ":"") << data[i];
    cout << endl;
  }
}

Measured memory_bytes: 1224
n = int(input())
s = input()
cnt = 0
for i in range(1000):
    c = [str(i // 100), str((i // 10) % 10), str(i % 10)]
    t = 0
    for j in range(n):
        if s[j]==c[t]:
            t+=1
        if t==3:
            cnt+=1
            break
print(cnt)


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

int main()
{
	int N, X, ans = -1;
	
	cin >> N;
	
	X = (int)(N / 1.08);
	
	for (int i = -1; i <= 1; i++) {
		int x = (int)((X + i) * 1.08);
		
		if (x == N) {
			ans = X + i;
			break;
		}
	}
	
	if (ans < 0) {
		cout << ":(" << endl;
	}
	else {
		cout << ans << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define arr array
#define _min(a) *min_element(a.begin(), a.end());
#define _max(a) *max_element(a.begin(), a.end());
#define _sort(x) sort(x.begin(), x.end())
#define _rsort(x) sort(x.rbegin(), x.rend())
#define _reverse(x) reverse(x.begin(), x.end())
#define _debug(x) cout << #x << " = " << x << endl;
#define debug(x, y) cout << #x " = " << x << " " << #y << " = " << y << endl;
#define _lower_bound(a, x) lower_bound(a.begin(), a.end(), x) - a.begin()
#define _upper_bound(a, x) upper_bound(a.begin(), a.end(), x) - a.begin()
typedef long long ll;
using namespace std;

void solve() {	 
	string s; cin >> s;
	for (int i = 0; i < s.length(); ++i) {
		if (i&1 && (s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) continue;
		if (i % 2 == 0 && (s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) continue;
		cout << "No\n";
		return;
	}
	cout << "Yes\n";
}

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

    // int t; cin >> t;
    // while(t--) 
        solve();
}

Measured memory_bytes: 3616