akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args){



		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		long counter =0;

		int big = (int) Math.log10(n);


		for(int i = 1;i<10;i++) {
			for(int j=1;j<10;j++) {
				int a = 0;
				int b = 0;
				if(i==j&&i<=n) {
					a++;
					b++;
				}
				for(int k = 0;k<big-1;k++) {
					a+=Math.pow(10,k);
					b+=Math.pow(10,k);
				}
				int aa = (int) (i*Math.pow(10, big)+j);
				
				if(n-aa>=0) {
					a++;
					int niner = 0;
					for(int k =1;k<big;k++) {
						niner += (int) (9*Math.pow(10,k));
					}
					if(n>=niner+aa) {
						a+=niner/10;
					}else {
						a+=(n-aa)/10;
					}
				}

				int bb = (int) (j*Math.pow(10, big)+i);
				if(n-bb>=0) {
					b++;
					int niner = 0;
					for(int k =1;k<big;k++) {
						niner += (int) (9*Math.pow(10,k));
					}
					if(n>=niner+bb) {
						b+=niner/10;
					}else {
						b+=(n-bb)/10;
					}
				}
				counter+=(long)a*b;
				//if(i!=j)counter+=(long)a*b;
			}
		}


		System.out.println(counter);

	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int n;
	cin>>n;
	int a[n];
	ll count[n+1]={};
	rep(i,n){
		cin>>a[i];
		count[a[i]]++;
	}
	ll ans=0;
	rep(i,n+1)ans+=(count[i]*(count[i]-1)/2);

	rep(i,n){
		cout<<ans-count[a[i]]+1<<endl;
	}


	return 0;
}


Measured memory_bytes: 4992
// chenkl1995@gmail.com
// https://atcoder.jp/contests/dp/tasks
#include <bits/stdc++.h>
using namespace std;

using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T> inline void IN(T &x) {
	x = 0; T f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); }
	x *= f;
}
template<typename A, typename B> inline void IN(A &x, B &y) { IN(x); IN(y); }
template<typename A, typename B, typename C> inline void IN(A &x, B &y, C &z) { IN(x); IN(y); IN(z); }

#define FastI ios_base::sync_with_stdio(0), cin.tie(0);
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define endl '\n'
#define REP(i, l, r) for (auto i = (l); i <= (r); ++i)
#define PER(i, l, r) for (auto i = (l); i >= (r); --i)
#define FOR(i, l, r) for (auto i = (l); i < (r); ++i)
#define ROF(i, l, r) for (auto i = (l); i > (r); --i)
#define FORN(i, n) for (auto i = 0; i < (n); ++i)
#define REPN(i, n) for (auto i = 1; i <= (n); ++i)
#define FORA(i, a) for (auto &i : a)
template<class T> void cout_1d(T &v) { FORA(i, v) cout << i << " "; puts(""); }
template<class T> void cout_2d(T &vv) { FORA(v, vv) cout_1d(v); }
#define ALL(X) (X).begin(), (X).end()
#define RALL(X) (X).rbegin(), (X).rend()
#define SIZE(X) ((int)(X).size())
#define UNIQUE(x) (X).erase(unique(ALL(x), (X).end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define NEG1(a) memset(a, -1, sizeof(a))
#define MAXA(a) memset(a, 0x3f, sizeof(a))
#define MAXB(b) memset(b, 0x7f, sizeof(b))
#define MP make_pair
#define PB push_back
#define X first
#define Y second

const LD PI = acos(-1.0);
const LL MOD = 998244353;
//const LL MOD = 1e9+7;
const LL MAXN = 2e5 + 7;

int h[MAXN];
void solve1() {
	int N;  IN(N);
	REPN(i, N) IN(h[i]);
	// VI dp(N+1, 0);  dp[2] = abs(h[2] - h[1]);
	// REP(i, 3, N) dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	VI dp(N+1, 0);
	REP(i, 2, N) dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), 
			i <= 2 ? INT_MAX : dp[i-2] + abs(h[i] - h[i-2]));
	cout << dp[N] << endl;
}

void solve2() {
	int N, K;  IN(N, K);
	REPN(i, N) IN(h[i]);
	VI dp(N+1, INT_MAX);
	dp[1] = 0;
	REP(i, 2, N) REP(j, 1, K) // if (j >= i) break;
		dp[i] = min(dp[i], i <= j ? INT_MAX : dp[i-j] + abs(h[i] - h[i-j]));
	cout << dp[N] << endl;
}

int a[MAXN], b[MAXN], c[MAXN];
void solve_Vacation() {
	int N;  IN(N);
	int mxa, mxb, mxc;
	// mxa = mxb = mxc = 0;
	REPN(i, N) IN(a[i], b[i], c[i]);
	mxa = a[1];  mxb = b[1];  mxc = c[1];
	REP(i, 2, N) {
		int ta = mxa, tb = mxb, tc = mxc;
		mxa = a[i] + max(tb, tc);
		mxb = b[i] + max(ta, tc);
		mxc = c[i] + max(ta, tb);
	}
	cout << max(mxa, max(mxb, mxc)) << endl;
}

int main() {
#ifdef _DEBUG
    freopen("../in.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#endif
    FastI

	// solve1();
	// solve2();
	solve_Vacation();

    return 0;
}


Measured memory_bytes: 1408
import java.util.*;
import java.io.*;

public class Main {


    public Main(FastScanner in, PrintWriter out) {
        int N = in.nextInt();
        int M = in.nextInt();
        StringBuilder res = new StringBuilder();
        if (N % 2 == 1) {
            for (int i = 1, j = N; i <= M; i++, j--) {
                res.append(String.format("%d %d%n", i, j));
            }
        } else {
            boolean change = false;
            for (int i = 1, j = N; i <= M; i++, j--) {
                int cwDist = j - i, acwDist = N - cwDist;
                if (!change && cwDist <= acwDist) {
                    change = true;
                    j--;
                }
                res.append(String.format("%d %d%n", i, j));
            }
        }
        out.print(res);
    }

    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        // Scanner in = new Scanner(
                // new BufferedReader(new InputStreamReader(System.in)));
        FastScanner in = new FastScanner(System.in);

        Main sol = new Main(in, out);

        out.close();
    }
}


class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner(InputStream stream)
    {
        this.stream = stream;
    }

    int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    boolean isSpaceChar(int c)
    {
        return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
    }

    boolean isEndline(int c)
    {
        return c=='\n'||c=='\r'||c==-1;
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}


Measured memory_bytes: 107996
n = int(input())
b_array = [int(x) for x in input().split()]
a_array = []
a_array.append(b_array[0])
for i in range(n-2):
    a_array.append(min(b_array[i], b_array[i+1]))
else:
    a_array.append(b_array[-1])
print(sum(a_array))


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


int main() {
	string a,b;
	cin>>a>>b;
	int n = a.length(),m=b.length(),i,j;
	int dp[n+1][m+1];
	memset(dp,0,sizeof(dp));
	
	for(i=1;i<=n;i++){
	    for(j=1;j<=m;j++){
	        if(a[i-1] == b[j-1])
	            dp[i][j] = 1+dp[i-1][j-1];
	        else
	            dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
	    }
	}
	string res = "";
	i=n,j=m;
	while(i>0 && j>0){
	    if(a[i-1] == b[j-1]){
	        res.push_back(a[i-1]);
	        i--;
	        j--;
	    }
	    else if(dp[i][j] == dp[i-1][j])
	        i--;
	    else
	        j--;
	}
	reverse(res.begin(),res.end());
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 38816
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,k; cin >> n >> k;
    ll ans = 0;
    for(ll i=k;i<=n+1;i++){
        ll sum_max = i*(2*n-i+1) % MOD * modinv(2,MOD) % MOD;
        ll sum_min = i*(i-1) % MOD * modinv(2,MOD) % MOD;
        ans = (ans + sum_max + 1) % MOD;
        ans = (ans - sum_min + MOD) % MOD; 
    }

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

Measured memory_bytes: 3672
#include<iostream>
using namespace std;
int main(){
  int m,n,light[7]={0};
  int math[10][7]={{0,1,1,1,1,1,1},{0,0,0,0,1,1,0},{1,0,1,1,0,1,1},{1,0,0,1,1,1,1},{1,1,0,0,1,1,0},{1,1,0,1,1,0,1},{1,1,1,1,1,0,1},{0,1,0,0,1,1,1},{1,1,1,1,1,1,1},{1,1,0,1,1,1,1}};
  while(1){
    for(int i=0;i<7;i++){
      light[i]=0;
    }
    cin >> n;
    if(n==-1){
      break;
    }
    for(int i=0;i<n;i++){
      cin >> m;
      for(int i=0;i<7;i++){
	if(light[i]==math[m][i]){
	  cout << "0";
	}
	else{
	  cout << "1";
	}
	light[i]=math[m][i];
      }
      cout << endl;
    }
  }
  return (0);
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int n;
	cin>>n;
	
	vector<int>d(n);
	for(int i=0;i<n;i++){
		cin>>d.at(i);
	}
	sort(d.begin(),d.end());
	d.erase(unique(d.begin(),d.end()),d.end());
	cout<<d.size()<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    Scanner sc = new Scanner(System.in);

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

    void run() {

        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();

        char[] copyT = new char[t.length];

        Arrays.sort(t);
        for (int i=0; i<t.length; i++) {
            copyT[t.length-1-i] = t[i];
        }

        Arrays.sort(s);
        String sortS = new String(s);
        String sortCT = new String(copyT);

//        System.out.println(sortS);
//        System.out.println(sortCT);
//        System.out.println(sortS.compareTo(sortCT));

        if (sortS.compareTo(sortCT) < 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll,ll>;
using vpl = vector<pll>;
using vb = vector<bool>;
using vs = vector<string>;

const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define has(c,i) (c.find() != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)

#define DBG 1
#define TR(X) ({ if(DBG) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

	double val = 0;
	ll n;
	cin >> n;
	FOR(i,0,n){
		ll tmp;
		cin >> tmp;
		val += 1.0 / tmp;
	}

	cout << 1.0 / val << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;
vector<int> v;
int main()
{
    int n,i,cnt;
    long long res;
    string s1,s2;
    cin>>n;
    cin>>s1>>s2;
    cnt=0;
    for(i=0;i<n;i++)
    {
        cnt++;
        if (i==n-1 || s1[i]!=s1[i+1])
        {
            v.push_back(cnt);
            cnt=0;
        }
    }
    if (v[0]==1) res=3;
    else res=6;
    for(i=1;i<v.size();i++)
    {
        if (v[i]==1 && v[i-1]==1) res=2*res;
        if (v[i]==1 && v[i-1]==2) res=res;
        if (v[i]==2 && v[i-1]==1) res=2*res;
        if (v[i]==2 && v[i-1]==2) res=3*res;
        res%=mod;
    }
    cout<<res<<endl;
    return 0;
}


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

ll INF = 1e+18;

int 
main()
{
  ll N; cin >> N;
  vector<char> ans;
  int plus = 96;

  while(N > 0){
    int tmp = N % 26;
    if(tmp == 0){
      tmp = 26;
      N = N / 26 - 1;
    } else {
      N /= 26;
    }
    ans.push_back((char)(tmp + plus));
  }

  reverse(ans.begin(), ans.end());
  for(auto c: ans){
    cout << c;
  }
  cout << endl;

}


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

int main(){
    string s;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    else if(s =="Cloudy") cout << "Rainy" <<endl;
    else cout << "Sunny" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main() {
  double W , H , x , y ;
  cin >> W >> H >> x >> y ;
  double ans = W * H / 2;
  cout << ans << endl ;
  if (x== W/2 && y == H/2 ) cout << 1 << endl ;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int N, K;
  cin >> N >> K;

  int total = 0;
  for (int i = 0; i < N; ++i) {
    int x;
    cin >> x;
    if (x > K / 2) {
      total += (K - x) * 2;
    } else {
      total += x * 2;
    }
  }

  cout << total << endl;

  return 0;
}

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

long long A[100005];

int K;

bool doesItWork(long long num){
    long long temp = num;
    for(int i = 0; i < K; i ++){
        temp = temp/A[i]*A[i];
    }
    return temp == 2;
}

int main(){
    scanf("%d", &K);

    for(int i = 0; i < K; i ++){
        scanf("%lld", &A[i]);
    }

    long long num = 2;
    for(int i = K-1; i >= 0; i --){
        long long temp = 1+(num-1)/A[i];
        num = temp*A[i];
    }

    long long num2 = 2;
    for(int i = K-1; i >= 0; i --){
        long long temp = 1+(num2-1)/A[i];
        num2 = (temp+1)*A[i]-1;
        if(i != 0){
            num2 = num2/A[i-1]*A[i-1];
        }
    }

    //printf("num2=%lld\n", num2);

    if(doesItWork(num)){
        printf("%lld %lld", num, num2);
        return 0;

        long long lo = num;
        long long hi = 1LL << 61;
        while(lo < hi){
            long long mid = (lo+hi+1)/2;
            if(doesItWork(mid)){
                lo = mid;
            }else{
                hi = mid-1;
            }
        }
        printf("%lld", lo);
    }else{
        printf("-1");
    }
    return 0;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)
#define SORT(a) sort(ALL(a))
#define VSORT(a, type) sort(ALL(a),greater<type>())
#define MAPIN(a,i,j) (a).insert(make_pair(i,j))

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef unsigned long long lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > Matrix;

int main() {
    ll i,j,k,n,x,ans;

    cin>>n;
    k=sqrt(n);
    ans=pow(10,12);
    for(i=k;i>0;i--){
        if(n%i==0){
            x=(i-1)+(n/i-1);
            ans=min(ans,x);
        }
    }
    cout<<ans;

	return 0;
}


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

using namespace std;


int main()
{


/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	long long  n;
	cin >> n;

	long long cnt = 100;
	int ans = 0;

	while (cnt < n)
	{

		cnt  = cnt * 1.01;
		ans++;

	}

	cout << ans;

}



Measured memory_bytes: 3640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define ort (b+s)/2
#define y2 asrwjaelkf
#define y1 asseopirwjaelkf
#define set multiset

using namespace std;

typedef long long Lint;
typedef double db;
typedef pair<int,int> ii;
typedef pair<int,char> ic;
typedef pair<db,db> dd;
typedef pair<ii,int> iii;
typedef pair<ii,ii> i4;

const int maxn = 100020;
const int maxm = 1000020;
const int MOd = 998244353;

vector<int> w[maxn];
int st[maxn], at = 0, used[maxn], a, b, mark[maxn];

int bfs( int n ) {
	memset( used, 0, sizeof( used ) );
	queue<ii> q;
	for(int i=0;i<w[n].size();i++)
		q.push( ii( w[n][i], n ) );
	int F = n, ans=0;
	while( !q.empty() ) {
		int n = q.front().fi;
		int b = q.front().se;
		q.pop();
		if( used[n] ) continue;
		used[n] = b;
		if( n == F ) {ans=1;break;}
		for(int i=0;i<w[n].size();i++)
			q.push( ii( w[n][i], n ) );
	}
	if( ans ) {
		for(int i=1;i<=a;i++) mark[i] = 0;
		int h = used[F], cnt = 0;
		cnt++;
		mark[F] = 1;
		while( h != 0 && h != F ) {
			cnt++;
			mark[h] = 1;
			h = used[h];
		}
		for(int i=1;i<=a;i++) {
			if( mark[i] ) {
				int x = 0;
				for(int j=0;j<w[i].size();j++)
					if( mark[ w[i][j] ] ) x++;
				if( x > 1 ) {ans=0;break;}
			}
		}
		if( ans ) {
			printf("%d\n",cnt);
			for(int i=1;i<=a;i++)
				if( mark[i] ) printf("%d\n",i);
			return 1;
		}
	}
	return 0;
}

void solve() {
	scanf("%d %d",&a,&b);
	for(int i=1,j,k;i<=b;i++) {
		scanf("%d %d",&j,&k);
		w[j].pb( k );
	}
	for(int i=1;i<=a;i++)
		if( bfs(i) ) {
			return;
		}
	printf("-1\n");
}

int main() {

    //freopen("asd.in","r",stdin);
    //freopen("output17.txt","w",stdout);

	int n = 1;
	//scanf("%d",&n);
	while( n-- ) solve();

	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long i,j,k,a,b,c=0,d,n,m,t=1,x;
cin>>n>>d>>x;
if(n+d>=x) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}


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

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define COUT(x) out << (x) << endl;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;


class CBuildStairs {
public:
    ll N;
    ll H[100000]{0};

    void solve(std::istream &in, std::ostream &out) {
        in >> N;
        REP(i, N) in >> H[i];
        ll tmp = --H[0];
        FOR(i, 1, N) {
            if (H[i-1] < H[i]) --H[i];
        }
        FOR(i, 1, N) {
            if (tmp > H[i]) { COUT("No"); return; }
            tmp = H[i];
        }
        COUT("Yes");
    }
};


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


Measured memory_bytes: 1024
n,m=map(int,input().split())
if n%2==1:
    for i in range(m):
        print(i+1,2*m-i)
else:
    if n==4:print(2,3);exit()
    d=n//2-1
    ans=[]
    if d%2:
        s=n//2
        for i in range(d//2+1):
            ans.append((i+1,s-i))
        dsa=n*2-(d//2)*2
        for i in range(d//2):
            ans.append(((dsa+(i+1)*2)//2,(dsa-(i+1)*2)//2))
    else:
        s=n//2-1
        for i in range(d//2):
            ans.append((i+1,s-i))
        dsa=n*2-d
        for i in range(d//2):
            ans.append(((dsa+(i+1)*2)//2,(dsa-(i+1)*2)//2))
    for i in range(m):
        print(*ans[i])

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<'\n'

int main(){
    int h,w;
    cin >> h >> w;
    string sum[h];
    REP(i,h)cin >> sum[i];
    int count=0;
    REP(i,h){
        REP(j,w){
            if(sum[i][j]=='#')count++;
        }
    }
    if(count==(h+w-1))COUT("Possible");
    else COUT("Impossible");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

/*
円周上にN個の箱が並んでいて、i番目の箱には石がA[i]個入っている。
次の操作を繰り返す：
ある箱を決めて、そこから番号昇順に1,2,...,N個の石を取り除く。
すべての箱を空にできるか？

まずA[i]の和をN(N+1)/2で割れば何回の操作が必要かわかる。回数をMとおく。ここで割り切れなかったらダメ。
つぎに、i番目の箱から始まった操作の回数をB[i]とおく。
i番目とi-1番目の箱の個数の差は、-(N-1)されることを考えると、
A[i] - A[i-1] = -B[i]*(N-1) + (M-B[i]) = -B[i] * N + M
よって、
B[i] = (-A[i] + A[i-1] +M) / N
となる。
*/

int main() {
	long long N,A[100000];
	long long i,M,B[100000];
	long long sum,P;
	scanf("%lld",&N);
	for(i=0;i<N;i++){
		scanf("%lld",&A[i]);
	}
	sum = 0;
	for(i=0;i<N;i++){
		sum = sum + A[i];
	}
	P = (N*(N+1))/2;
	if(sum % P == 0){
		M = sum/P;
	}else{
		printf("NO\n");
		return 0;
	}
	for(i=1;i<N;i++){
		if((-A[i]+A[i-1]+M) <  0){
			printf("NO\n");
			return 0;
		}
	}
	for(i=1;i<N;i++){
		if((-A[i]+A[i-1]+M) % N != 0){
			printf("NO\n");
			return 0;
		}
	}
	if((-A[0]+A[N-1]+M) % N != 0){
			printf("NO\n");
			return 0;
	}
	if((-A[0]+A[N-1]+M) < 0){
			printf("NO\n");
			return 0;
	}
	printf("YES\n");
	return 0;
}

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

int main(){
    string s;
    cin>>s;
    int n=700;
    if(s[0]=='o'){n+=100;}
    if(s[1]=='o'){n+=100;}
    if(s[2]=='o'){n+=100;}
    cout<<n<<endl;
    return 0;
}

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

namespace abc123b
{
    class Program
    {
        static void Main(string[] args)
        {
            int tm = 0;
            int ama = 10;
            for (int i = 0; i < 5; i++)
            {
                double a = double.Parse(Console.ReadLine());
                tm += (int)((Math.Ceiling(a / 10)) * 10);
                if (a % 10 != 0)
                {
                    ama = Math.Min((int)a%10,ama);
                }
            }
            if(ama == 10)
            {
                ama = 0;
            }
            else
            {
                tm -= 10;
            }
            Console.WriteLine(tm + ama);
        }
    }
}


Measured memory_bytes: 11092
import numpy as np
n = int(input())
x = np.array(list(map(int, input().split())))

mins = min(x)
cnt = mins
x -= mins

while sum(x) != 0:
    mask = [1 if xi > 0 else 0 for xi in x]
    x -= mask
    
    for i in range(1, n):
        if mask[i] == 1 and mask[i-1] == 1:
            mask[i-1] = 0

    cnt += sum(mask)
    
print(cnt)

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

int main()
{
  int n;
  cin >> n;
  int sum = 0;
  vector<int> v(n);

  for (auto&& e : v) {
    cin >> e;
    sum += e;
  }

  int x = 0;
  int ans = sum;
  for (int i = 0; i < n; i++) {
    x += v[i];
    ans = min(ans, sum - x > x ? sum - x * 2 : x * 2 - sum);
  }
  cout << ans << endl;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main() {
  ll a; cin>>a;
  string s; cin>>s;
  if(a>=3200) cout<<s<<endl;
  else cout<<"red"<<endl;
  
}


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

using namespace std;
using ll = long long;
ll x, k, d;
int main() {
#ifdef LOCAL
    freopen("in1.txt", "r", stdin);
    freopen("out1.txt", "w", stdout);
#endif

    cin >> x >> k >> d;
    ll ans ;
    ll step;
    ll sh;
    //bool cro = false;
    x = abs(x);
    if(d >= x){
        step = 1;
        if((k - 1) % 2 == 0){
            ans = abs(abs(x) - d);
        }else{
            ans = abs(x);
        }
    }
    else{
        sh = abs(x) % d;
        step = x / d;
        if(d - sh < sh){
            sh = d - sh;
            step ++ ;
            //cro = true;
        }
        ll rem = k - step;
        if(rem < 0){
            ans = x - d * k;
        }
        else{
            if(rem % 2 == 0){
                ans = sh;
            }else{
                ans = abs(sh - d);
            }
        }
    }

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

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

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

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}


int cnt[10][10];

signed main(){
    int N;cin>>N;
    for(int i=1;i<=N;i++){
        stringstream ss;
        ss<<i;
        string s=ss.str();
        cnt[s[0]-'0'][s.back()-'0']++;
    }

    int ans=0;
    rep(i,10)rep(j,10)ans+=cnt[i][j]*cnt[j][i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

void solve(std::string S, long long K){
  bool can = true;
  ll ans=0; string x = S;
  ll n=0;
  for (int i = 0; i < S.length()-1; i++) {
    if(S[i] == S[i+1]){
      n++;
    }else{
      n++;
      can = false;
      ans += n/2;
      n=0;
    }
  }
  n++;
  ans += n/2;
  if(!can){
    S = x;
    ll i=0,a=0,b=0;
    if(S[0] == S[S.length()-1]){
      while(S[0] == S[i]){
        a++;i++;
      }
      i=S.length()-1;
      while(S[S.length()-1] == S[i]){
        b++;i--;
      }
    }
    cout << ans*K - (a/2 + b/2 -(a+b)/2)*(K-1) << endl;
  }else{
    cout << S.length()*K/2  << endl;
  }
}

int main(){
    std::string S;
				std::cin >> S;
				long long K;
				scanf("%lld",&K);
    solve(S, K);
    return 0;
}


Measured memory_bytes: 256
A, B, C = map(int, input().split())
if B < A:
    A, B = B, A

if C < A:
    A ,C = C, A

if C < B:
    B, C = C, B

if A != 5 or B != 5 or C != 7:
    print("NO")
else:
    print("YES")

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

int main() {
    string S1, S2;
    cin >> S1 >> S2;
    int N = S1.size(), M = S2.size(), dp[1100][1100];
    memset(dp, 0, sizeof(dp));
    S1 = ' ' + S1, S2 = ' ' + S2;
    for (int i = 0; i <= N; ++i) dp[i][0] = i;
    for (int j = 0; j <= M; ++j) dp[0][j] = j;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            int t = S1[i + 1] != S2[j + 1] ? 1 : 0;
            dp[i + 1][j + 1] = min(dp[i][j] + t, min(dp[i + 1][j] + 1, dp[i][j + 1] + 1));
        }
    }
    cout << dp[N][M] << endl;
    
    return 0;
}


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
using pii = pair<ll, ll>;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define ull unsigned long long
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))

///--------------Graph Moves--------------------------------------
///const ll fx[] = {+1,-1,+0,+0};
///const ll fy[] = {+0,+0,+1,-1};
///const ll fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const ll fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const ll fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const ll fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;

    ll n; cin >> n;
    ll s = 0;
    ll a[n + 2];
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
        s += a[i];
    }
    ll b = ceil(s / (1.0 * n));
    ll c = floor(s / (1.0 * n));
    ll ans = INT_MAX;

    ll s1 = 0, s2 = 0;
    for(ll i = 0; i < n; i++) {
        s1 += (((a[i]) - (b)) * ((a[i]) - (b)));
    }

    for(ll i = 0; i < n; i++) {
        s2 += (((a[i]) - (c)) * ((a[i]) - (c)));
    }

    cout << min(s1, s2) << endl;

    return 0;
}



Measured memory_bytes: 3704
// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}
int32_t main() {
    IOS;

        int n,m,x;
        cin>>n>>m>>x;
        int a[n][m],p[n];
        rep(i,0,n-1){cin>>p[i];rep(j,0,m-1)cin>>a[i][j];}
        int mask=(1<<n)-1,ans=1e12;
        for(int i=mask;i>0; i=(i-1)&mask)
        {
        	int val[m],price=0; memset(val,0,sizeof(val));
        	rep(j,0,n-1)if(i&(1<<j))
        	{
        		rep(k,0,m-1)val[k]+=a[j][k];
        		price+=p[j];
        	}
        	bool foo=true; 
        	rep(j,0,m-1)if(val[j]<x){foo=false;break;}
        	if(foo)ans=Min(ans,price);
        }
        if(ans<1e12)cout<<ans;
        else cout<<"-1";



        cout<<'\n';
    return 0;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

// ユークリッドの互除法により2数の最大公約数を求める。
// O(log b)
template <class T>
inline T gcd(T a, T b)
{
    T r;
    if (a < b)
        swap(a, b);

    while (b > 0)
    {
        r = a % b;
        a = b;
        b = r;
    }

    return a;
}

int K;

int main(void) {

    cin >> K;

    ll ans = 0;
    for(int a = 1; a <= K; ++a) {
        for (int b = 1; b <= K; ++b) {
            int ab = gcd(a, b);
            for (int c = 1; c <= K; ++c) {
                ans += gcd(ab, c);
            }
        }
    }

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

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

using ll = long long;

//各種nil
template <class T>
constexpr T nil = static_cast<T>(-1);

constexpr int nil_i = nil<int>;
constexpr int nil_ll = nil<ll>;
constexpr double nil_d = nil<double>;

//vector
template <class T>
using vec = std::vector<T>;

struct Item
{
    int weight, value;
};

void solve()
{
    using namespace std;

    constexpr int inf = 1 << 29;

    int N, W;
    cin >> N >> W;

    vec<Item> items(N);
    for (auto& i : items) cin >> i.value >> i.weight;

    //dp[w] 重さw以下のときの価値の最大値
    vec<vec<int>> dp(N + 1, vec<int>(W + 1, 0));

    for (int i = 0; i < N; ++i)
        for (int w = 0; w <= W; ++w)
        {
            if (items[i].weight <= w)
                dp[i + 1][w] = max(dp[i][w], dp[i + 1][w - items[i].weight] + items[i].value);
            else
                dp[i + 1][w] = dp[i][w];
        }

    cout << dp[N][W] << endl;
}

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


Measured memory_bytes: 6824
#include<stdio.h>

int main()
{
	int n,k,total=1;
	scanf("%d %d",&n,&k);getchar();
	for(int i=1;i<=n;i++)
	{
		if((total+k)<2*total) total=total+k;
		else total=total*2;
	}
	printf("%d\n",total);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
    int A, B, C, D, E;
    int time = 0;
    int order[5];
    int tmp;
    int k = 0;

    //料理が届く時間を入力
    for(size_t i = 0; i < 5; i++)
    {
        cin >> order[i];
    }
    //１桁目の数値が大きい順にソート(0の場合は先頭へ)
    for(size_t i = 0; i < 4; i++)
    {
        for(size_t j = i + 1; j < 5; j++)
        {
            if(order[i] % 10 < order[j] % 10 || order[j] % 10 == 0){
                tmp = order[i];
                order[i] = order[j];
                order[j] = tmp;
                //  cout << "[0] = " << order[0] << "[1] = " << order[1] << "[2] = " << order[2] << "[3] = " << order[3] << "[4] = " << order[4] << endl;
            }
            if(order[i] % 10 == 0){
                break;
            }
        }
    }
    for(size_t i = 0; i < 5; i++)
    {
        if(order[i] % 10 != 0 && i < 4){
            order[i] = order[i] + (10 - order[i] % 10);
        }
        // cout << "order[" << i << "] =" << order[i] << endl;
        time += order[i];
    }

    cout << time << endl;
    return 0;

}

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

ll INF = 1L << 60;

int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];

    ll min = INF;
    rep(p, 100)
    {
        ll count = 0;
        for (int j = 0; j < n; j++)
        {
            count += (x[j] - p) * (x[j] - p);
        }
        if (min > count)
        {
            min = count;
        }
    }
    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    while(1){
        string s;
        cin >> s;
        if (s=="#") break;
        
        int y,m,d;
        cin >> y >> m >> d;
        if (y > 31 || (y == 31 && m >= 5)){
            cout << "? " << y-30 << " " << m << " " << d << endl;
        } else {
            cout << "HEISEI " << y << " " << m << " " << d << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define INF 9003372036854775807LL
#define mod 998244353
#define SYOU(x) fixed<<setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii=pair<int, int > ;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol n,m,k;
  string s,w;
  cin >>s>>w;
  n=s.size(),m=w.size();
  if(n>m) cout <<"GREATER\n";
  else if(n<m) cout <<"LESS\n";
  else{
    if(s>w) cout <<"GREATER\n";
    else if(s<w) cout <<"LESS\n";
    else cout <<"EQUAL\n";
  }
  return (0);
}


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

typedef long long LL;
#define SZ(a) int((a).size())
#define FOR(var,a,b) for(int var=(a);var<(b);var++)
#define REP(var,n) FOR(var,0,n)
#define INT(n) int n;scanf("%d",&n);

int main(){
  INT(n);
  printf("%d:", n);
  FOR(i, 2, 100000){
    if (n < i * i){break;}
    while (n % i == 0){
      printf(" %d", i);
      n /= i;
    }
  }
  if (1 < n){printf(" %d", n);}
  printf("\n");
  return 0;
}

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

int main() {
	int n;
	int v[100010] = { 0 };
	cin >> n;
	int s[100010];
    int t[100010] = { 0 };
	int sum = 0;
	for (int i = 1;i <= n;i++) {
		cin >> v[i];
		s[i - 1] = abs(v[i] - v[i - 1]);
		if (i > 1)t[i - 1] =abs(v[i] - v[i - 2]);
		sum += s[i - 1];
	}
	s[n] = abs(0 - v[n]);
	//a_n+1の分
	sum += s[n];
	t[n] = abs(0 - v[n - 1]);
	for (int i = 0;i < n;i++) {
		cout << sum - (s[i] + s[i + 1]) + t[i + 1] << endl;
	}
}

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

using namespace std;

typedef long long ll;

int n1 = 0, n2 = 0, n = 0, s1[200], s2[200];

void work(ll N) {
	if(N == 1) return;
	work(N >> 1);
	s2[++n2] = ++n;
	if(N & 1) s1[++n1] = ++n;
}

int main() {
	ll N; scanf("%lld", &N); work(++N);
	printf("%d\n", n << 1);
	for(int i = 1; i <= n; i++) printf("%d ", i);
	for(int i = n1; i >= 1; i--) printf("%d ", s1[i]);
	for(int i = 1; i <= n2; i++) printf("%d ", s2[i]);
	puts("");
	return 0;
}


Measured memory_bytes: 256
r, c = gets.chomp.split.map(&:to_i)
x = []

r.times do
  x << gets.chomp.split.map(&:to_i)
end

xl = []
(0...c).each do |i|
  n = 0
  (0...r).each do |j|
    n += x[j][i]
  end
  xl << n
end
xl << xl.inject(:+)

x.each do |a|
  print a.join(' ') , ' ' , a.inject(:+)
  puts
end
puts xl.join(' ')

Measured memory_bytes: 6136
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0) x /= p, ++y;
      if (y != 0) res.emplace_back(p,y);
    }
    if (x != 1) res.emplace_back(x,1);
    return res;
  }
};

int main() {
  int n;
  cin>>n;
  vi a(n);
  REP(i, n) cin>>a[i];
  Sieve sieve(1000005);
  vi d(1000005);
  REP(i, n) {
    auto list = sieve.factor(a[i]);
    REP(i, list.size()) {
      d[list[i].first]++;
      // cout << list[i].first << endl;
    } 
  }
  bool b1 = true;
  bool b2 = true;
  FOR(i, 2, 1000002) {
    if (d[i] > 1) b1 = false;
    if (d[i] == n) b2 = false;
  }
  if(b1) cout << "pairwise coprime" << endl;
  else if(b2) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;

  return 0;
}

Measured memory_bytes: 15408
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>

#define N 20000005
#define M 8000005

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

#define mk make_pair
#define pb push_back
#define fi first
#define se second

#define Mo 1000000007

using namespace std;

int i,j,m,n,p,k,fac[N],inv[N];

int C(int x,int y)
{
		if (x<y) return 0;
		return 1ll*fac[x]*inv[y]%Mo*inv[x-y]%Mo;
}

int power(int x,int y)
{
		int sum=1;
		for (;y;y>>=1)
		{
				if (y&1) sum=1ll*sum*x%Mo;
				x=1ll*x*x%Mo; 
		} 
		return sum;
}

int main()
{
		fac[0]=1;for (i=1;i<N;++i) fac[i]=1ll*fac[i-1]*i%Mo;
		inv[N-1]=power(fac[i-1],Mo-2);
		for (i=N-2;i>=0;--i) inv[i]=1ll*inv[i+1]*(i+1)%Mo;
		scanf("%d%d%d",&n,&m,&k); p=n+m; 
		int ans=k; //(0,0) 
		ans=(ans+1ll*(n+m)*(1ll*k*power(p,Mo-2)%Mo+1ll*k*(k-1)%Mo*power(1ll*p*(p-1)%Mo,Mo-2)%Mo*(p-1)%Mo*power(2,Mo-2)%Mo)%Mo)%Mo;//(0,i),(j,0)
		ans=(ans+1ll*(n)*(m)%Mo*(1ll*k*(k-1)%Mo*power(1ll*p*(p-1)%Mo,Mo-2)%Mo+1ll*C(k,3)*power(C(p,3),Mo-2)%Mo*(p-2)%Mo*power(3,Mo-2)%Mo)%Mo)%Mo;
		ans=1ll*ans*fac[p]%Mo*inv[p-k]%Mo;
		printf("%d\n",ans); 
}


Measured memory_bytes: 156544
#include<stdio.h>
#include<string.h>
int main()
{
    char str[10];
    
    scanf("%s",&str);
    
    
    if (str[0]=='S')
    {
      printf("Cloudy\n");
    }
    else if (str[0]=='R') 
    {
      printf("Sunny\n");
    }
    else if (str[0]=='C')
    {
      printf("Rainy");
    }
    return 0;
}
   

Measured memory_bytes: 1620
N = int(input())
S = []
for _ in range(N):
    S.append(int(input()))

s = sum(S)
if s % 10 != 0:
    print(s)
else:
    S.sort()
    for i in S:
        if i % 10 != 0:
            s -= i
            break
    if s % 10 == 0:
        print(0)
    else:
        print(s)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
struct cities{
   int pref,city,idx;
   bool operator<(const cities& c)const{
      return (pref<c.pref || (pref==c.pref&& city<c.city)); 
   }
};
int main() {
  int n,m,x=0,y;
  cin>>n>>m;
  vector<cities> v(m);
  vector<pair<int,char*>> a(m);
  rep(i,m){
     cin>>v[i].pref>>v[i].city;
     v[i].idx=i;
  }
  sort(v.begin(),v.end());
  rep(i,m){
     if(x!=v[i].pref){
        x=v[i].pref;
        y=1; 
     } 
     char *c=new char[13];
     sprintf(c,"%06d%06d",v[i].pref,y++);
     a[i].first=v[i].idx;
     a[i].second=c;
  }
  sort(a.begin(),a.end());
  rep(i,m)
    printf("%s\n",a[i].second);
  return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int N, K;
int A[111111];

int main() {
   cin >> N >> K;
   rep (i, N) {
      cin >> A[i];
   }

   int idx = K - 1;
   int ans = 1;
   while (1) {
      if (idx >= N-1) break;
      idx += (K-1);
      ans++;
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
void dfs(int ver,vector<int> &v,vector<int> vm[]){
    v[ver]=1;
  for(auto x:vm[ver]){
    if(!v[x]){
      dfs(x,v,vm);
    }
  }
}
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> v[n+1];
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  vector<int> vis(n+1,0);
  int count=0;
  for(int i=1;i<=n;i++){
    if(!vis[i]){
    count++;
    dfs(i,vis,v);
    }
  }
  cout<<count-1<<"\n";
  return 0;
}

Measured memory_bytes: 10124
#include "bits/stdc++.h"
#define ll long long
#define PI 3.1415926535897932384626433832795l
#define MAX_NUM (long long)10000000000
#define line printf("-----------------\n");
using namespace std;
int SET(int N, int pos) { return N = N | (1 << pos); }
int RESET(int N, int pos) { return N = N & ~(1 << pos); }
bool CHECK(int N, int pos) { return (bool)(N & (1 << pos)); }
template <typename T>
inline T __lcm(T a, T b)
{
    return (a * b) / __gcd(a, b);
}
struct node
{
    ll x, y, i;
};
int dx[] = {0, 1, 0, -1, -1, 1, -1, 1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};



void solve()
{
    ll a[10];   
    for(ll i=1;i<=5;i++)
    {
        cin>>a[i];
    }
    for(ll i=1;i<=5;i++)
    {
        if(a[i]==0)
        {
            cout<<i<<endl;
            return;
        }
    }
}

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("inputf.txt", "r", stdin);
    //freopen("outputf.txt", "w", stdout);
#endif // ONLINE_JUDGE
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3588
a,b=[int(i) for i in raw_input().split()]
if b < 10:
	c = 10*a+b
elif b < 100:
	c = 100*a+b
else:
	c = 1000*a+b
flg = 0
for i in range(350):
	k=i+1
	if c == k*k:
		flg = 1
		break
if flg == 1:
	print ("Yes")
else:
	print ("No")

Measured memory_bytes: 2568