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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	string s, t;
	cin >> s >> t;
	cout << t << s;
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main() {
    int A, B;
    cin >> A >> B;

    if (A < B) {
        swap(A, B);
    }


    int ans = 0;
    ans = max(A, B);

    int C, D;

    A = A - 1;

    if (A > B) {

        D = A;

    }

    else{

        D = B;
    }

    C = ans + D;

    cout << C;

    return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1e9 + 100;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 1e5 + 100;
int n;
int t, e;
int x[maxn];

ll st[2][maxn * 4];

void build(int t, int v, int vl, int vr) {
  st[t][v] = 1e18;
  if (vl == vr - 1) {
    return;
  }
  int mid = (vl + vr) / 2;
  build(t, v * 2, vl, mid);
  build(t, v * 2 + 1, mid, vr);
}

void update(int t, int v, int vl, int vr, int pos, ll val) {
  if (vl == vr - 1) {
    st[t][v] = val;
    return;
  }
  int mid = (vl + vr) / 2;
  if (pos < mid) {
    update(t, v * 2, vl, mid, pos, val);
  } else {
    update(t, v * 2 + 1, mid, vr, pos, val);
  }
  st[t][v] = min(st[t][v * 2], st[t][v * 2 + 1]);
}

ll get(int t, int v, int vl, int vr, int l, int r) {
  if (vr <= l || r <= vl) {
    return 1e18;
  }
  if (l <= vl && vr <= r) {
    return st[t][v];
  } else {
    int mid = (vl + vr) / 2;
    return min(get(t, v * 2, vl, mid, l, r), get(t, v * 2 + 1, mid, vr, l, r));
  }
}

bool read() {
  if (scanf("%d%d%d", &n, &e, &t) < 3) {
    return false;
  }
  x[0] = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", x + i);
  }
  x[n + 1] = e;
  n += 2;
  return true;
}

ll dp[maxn];

void solve() {
  build(0, 1, 0, n);
  build(1, 1, 0, n);
  update(0, 1, 0, n, 0, -2 * x[1]);
  update(1, 1, 0, n, 0, 0);
  for (int i = 1; i < n; i++) {
    int left = (int) (upper_bound(x, x + n, x[i] - (t + 1) / 2) - x);
    left = max(0, left - 1);
    dp[i] = 1e18;
    if (left) {
      dp[i] = min(dp[i], get(0, 1, 0, n, 0, left) + 2 * x[i]);
    }
    if (left < i) {
      dp[i] = min(dp[i], get(1, 1, 0, n, left, i) + t);
    }
    update(0, 1, 0, n, i, dp[i] - 2 * x[i + 1]);
    update(1, 1, 0, n, i, dp[i]);
  }
  printf("%lld\n", dp[n - 2] + e);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time: %.18f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const ll INF = 1LL << 60;

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = -INF;
    ans = max(ans, a * c);
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);
    cout << ans << endl;
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, M;
  cin >> N >> M;
  VL xs(N), ys(M);
  REP(i,N) cin >> xs[i];
  REP(i,M) cin >> ys[i];

  REP(i,N-1) xs[i] = xs[i+1] - xs[i];
  REP(i,M-1) ys[i] = ys[i+1] - ys[i];

  VL ax(N), ay(M);
  REP(i,N-1)  (ax[i+1] = xs[i] + ax[i]) %= MOD;
  REP(i,M-1)  (ay[i+1] = ys[i] + ay[i]) %= MOD;

  LL sx = 0, sy = 0;
  REP(i,N) (sx += ax[i]) %= MOD;
  REP(i,M) (sy += ay[i]) %= MOD;

  VL aax(N), aay(M);
  aax[0] = sx;
  aay[0] = sy;
  FOR(i,1,N)
	(aax[i] = aax[i-1] + MOD - xs[i-1] * (N-i) % MOD) %= MOD;
  FOR(i,1,M)
	(aay[i] = aay[i-1] + MOD - ys[i-1] * (M-i) % MOD) %= MOD;

  sx = sy = 0;
  REP(i,N) (sx += aax[i]) %= MOD;
  REP(i,M) (sy += aay[i]) %= MOD;

  cout << sx * sy % MOD << endl;

  return 0;
}


Measured memory_bytes: 4992
H, W, A, B = map(int, input().split())
l = [[0]*W for _ in range(H)]

for i in range(B):
    for j in range(A):
        l[i][j] = 1

for i in range(B, H):
    for j in range(A, W):
        l[i][j] = 1

for i in l:
    print("".join(map(str, i)))

Measured memory_bytes: 11892
#include<stdio.h>
 
int main(void)
 
{
 
int a,b,c;
 
scanf("%d",&a);
 
scanf("%d",&b);
 
scanf("%d",&c);
 
if(a<b&&b<c)
 
{
 
printf("Yes\n");
 
}
 
else
 
{
 
printf("No\n");
 
}
 
return 0;
 
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}

int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int A, B; cin >> A >> B;
  int ans = 0;
  for(int i = 1; i <= 1000000; ++i) {
    int a = i * 0.08;
    int b = i * 0.1;
    if(a == A && b == B) {
      ans = i;
      break;
    }
    if(i == 1000000) ans = -1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using ll=long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	ll h = 0, w = 0;
	for (int i = 0; i < n; ++i)cin >> a[i];
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	for (int i = 0; i < a.size()-1; ++i) {
		if (a[i] == a[i + 1]) {
			if (h != 0) {
				w = a[i];
				break;
			}
			h = a[i];
			i++;
		}
	}
	cout << h * w << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
priority_queue<int> pq;
int main()
{
	char st[100];
	while(scanf("%s",st))
	{
			if(st[0]=='i')
			{
					int tmp;
					scanf("%d",&tmp);
					pq.push(tmp);
			}
			else if(st[1]=='x')
			{
				printf("%d\n",pq.top());
				pq.pop();
			}
			else
				break;
			
	}
	return 0;
}


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

//ユークリッドの互除法
int GCD(int x, int y){
    if( x % y == 0 ){
        return y;
    }
    return GCD( y , x % y );
}

//O(A+N)解
int main(){
    using namespace std;
    int MAX_A = 1000000;
    vector<int> lowerst_prime(MAX_A + 1, 0);//最小の素因数をいれる(2以上をみていけばいい)
    vector<int> primes;//MAX_A以下の素数の集合
    vector<int> count(MAX_A + 1, 0);//約数として出てくる回数を数える
    for(int i = 2; i <= MAX_A; i++){//線形時間で処理してくれる
        if(lowerst_prime[i] == 0){
            lowerst_prime[i] = i;
            primes.push_back(i);
        }
        for(int j = 0; j < primes.size()&& primes[j] <= lowerst_prime[i]&& i * primes[j] <= MAX_A; j++){
            lowerst_prime[i * primes[j]] = primes[j];//i * primes[j] == C(const)としてありえるi, jの組は高々一通りになるので、これは線形時間で処理される
        }
    }
    //入力
    int N;
    cin >> N;
    vector<int> A(N);
    int setwise_gcd = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        //setwise判定
        setwise_gcd = GCD(setwise_gcd, A[i]);//定義から、i == 0 ではA[0]を返す
    }
    if(setwise_gcd != 1){
        cout << "not coprime" << endl;
        return 0;
    }
    for(int i = 0; i < N; i++){
        while(A[i] > 1){
            int divide = lowerst_prime[A[i]];
            if(count[divide]){
                //A[x] % i == A[y] % i == 0 となるx != yが存在するので、i | gcd(x, y)となる
                cout << "setwise coprime" << endl;
                return 0;
            }
            count[divide]++;
            while(A[i] % divide == 0){//割れるだけ割る
                A[i] /= divide;
            }
        }
    }
    cout << "pairwise coprime" << endl;
}

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

const int MOD = 1e9 + 7;

long long pow_mod(long long x, int n) {
    long long res = 1;
    while (n) {
        if (n & 1) res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

long long cmb(int n, int r) {
    if (r < 0 || r > n) return 0;
    // nCr = x/y = n(n-1)...(n-r+1)/r(r-1)...1
    long long x = 1, y = 1;
    for (int i = 0; i < r; ++i) {
        x = x * (n - i) % MOD;
        y = y * (i + 1) % MOD;
    }
    return x * pow_mod(y, MOD - 2) % MOD;
}

int main() {
    int X, Y;  cin >> X >> Y;
    if ((2 * X - Y) % 3 || (2 * Y - X) % 3) {
        cout << 0 << endl;
        return 0;
    }
    int s = (2 * X - Y) / 3, t = (2 * Y - X) / 3;
    cout << cmb(s + t, s) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int a, b;
    cin >> a >>  b;
    if(1<=a && a<=9 && 1<=b && b <=9){
        cout << a * b << endl;
    }else{
        cout << -1 << endl;
    }
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
using ll = long long;
int main(){
	ll a, b, n;
	cin >> n >> a >> b;
	ll cnt = n / (a + b);
	n -= cnt * (a + b);
	ll ans;
	if(n >= a)
		ans = cnt * a + a;
	else 
		ans = cnt * a + n;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();
			lineBC = scanner.nextInt();

			if (lineBC % lineAB == 0) {
				System.out.println(lineAB + lineBC);
			} else {
				System.out.println(lineBC - lineAB);
			}

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
 long long GCD(long long a,long long b){
   if(b == 0) return a;
   else return GCD(b,a%b);
 }

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0;i<N;i++){
    cin >> A[i];
  }
  for(int i = 0;i<N-1;i++){
   A[i] =  GCD(A[i],A[i+1]);
   A[i+1] = GCD(A[i],A[i+1]);
  }
  cout << A[N-1] << endl;
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    ll ans = (1 + (n - 1)) * (n - 1) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;
const int N=100005;
int a[N];
int main()
{
	int n;scanf("%d",&n);
	rep(i,1,n)scanf("%d",&a[i]);int ma=0;
	rep(i,1,n)ma=max(ma,a[i]);rep(i,1,n)if(a[i]!=ma && a[i]!=ma-1){puts("No");return 0;}
	int cnt=0;rep(i,1,n)if(a[i]==ma-1) cnt++;
	if(!cnt){
		if(a[1]!=n-1 && a[1]>n/2){puts("No");return 0;}
		puts("Yes");return 0;
	}
	if(cnt>=ma||2*(ma-cnt)+cnt>n){puts("No");return 0;}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 512
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String S = sc.next();
		String T = sc.next();
		int ans = 0;
		for (int i = 0; i < 3; i++) {
			if (S.charAt(i) == T.charAt(i)) ans++;
		}
		System.out.println(ans);
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 21332
#include<iostream>
using namespace std;
int a[5],c5,c7;
int main()
{
	for(int i=1;i<=3;i++)
	{
		cin>>a[i];
		if(a[i]==5) c5++;
		if(a[i]==7) c7++;
	}
	if(c5==2&&c7==1) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    cin >> s;
    cout << s.substr(0, 5) + " " + s.substr(6, 7)
        + " " + s.substr(14) << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int f = sc.nextInt();
		int r = sc.nextInt();

		while(m != -1 || f!=-1 || r!=-1 ){

			if(m==-1 || f==-1)
				System.out.printf("F\n");
			else if(m+f>=80)
				System.out.printf("A\n");
			else if(m+f>=65 && m+f<80)
				System.out.printf("B\n");
			else if(m+f>=50 && m+f<65)
				System.out.printf("C\n");
			else if(m+f>=30 && m+f<50){
				if(r>=50)
					System.out.printf("C\n");
				else
					System.out.printf("D\n");
				
			}
			else
				System.out.printf("F\n");

			m = sc.nextInt();
			f = sc.nextInt();
			r = sc.nextInt();

		}
		
	}
}


Measured memory_bytes: 26340
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

inline int input() { int x; scanf("%d", &x); return x; }

int main() {
	int n = input();
	printf("%lld\n", 1ll * n * (n - 1) >> 1);
}


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

int main()
{
  ll x;
  cin>>x;
  if(x%(ll)500==0)
    cout<<(x/(ll)500)*(ll)1000<<endl;
  else if(x%(ll)500!=0)
    cout<<(x/(ll)500)*(ll)1000 + ((x%(ll)500)/(ll)5)*(ll)5<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void) {
	int str[30] ;
	long long int number, x;
	int count = 0, i;

	scanf("%lld", &number);

	while (number > 0) {
		x = number - 1;
		str[count++] = x % 26 + 'a';
		number = x / 26;
	}

	for (i = count - 1; i >= 0; i--) {
		printf("%c", str[i]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 2068
p=[]
for i in range(3):
    p.append(list(map(int,input().split())))

if (p[0][0]-p[0][1] == p[1][0]-p[1][1] == p[2][0]-p[2][1] and
p[0][1]-p[0][2] == p[1][1]-p[1][2] == p[2][1]-p[2][2] and
p[0][2]-p[0][0] == p[1][2]-p[1][0] == p[2][2]-p[2][0] and
p[0][0]-p[1][0] == p[0][1]-p[1][1] == p[0][2]-p[1][2] and
p[1][0]-p[2][0] == p[1][1]-p[2][1] == p[1][2]-p[2][2] and
p[2][0]-p[0][0] == p[2][1]-p[0][1] == p[2][2]-p[0][2]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll a[100010];
ll pr[100010];

const long long mod=1e9+7;
long long fact[100010];
void pre(){
    fact[0]=1;
    for(long long i=1; i<100010; ++i){
        fact[i]=(fact[i-1]*i)%mod;
    }
}
long long pwr(long long x, long long e){
    if(e==0)
        return 1;
    long long tmp=pwr(x,e/2);
    tmp=(tmp*tmp)%mod;
    if(e%2)
        tmp=(tmp*x)%mod;
    return tmp;
}
long long cmb(long long x, long long y){
    if(y>x)
        return 0;
    long long res, tmp;
    tmp=pwr(fact[x-y], mod-2);
    res=(fact[x]*tmp)%mod;
    tmp=pwr(fact[y],mod-2);
    res=(res*tmp)%mod;
    return res;
}


int main(){
    int n;
    pr[0]=1;
    for(int i=1; i<100010; ++i) {
        pr[i] = pr[i - 1] * 2;
        pr[i]%=mod;
    }
    pre();
    int k;
    while(cin>>n>>k){
        ll ans=0;
        for(int i=0; i<n; ++i){
            scanf("%lld",a+i);
        }
        sort(a, a+n);
        for(int i=0; i<n; ++i){
            ans+=cmb(i, k-1)*a[i]-cmb(n-1-i, k-1)*a[i];
            ans%=mod;
        }
        if(ans<0){
            ans+=mod;
        }
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 2560
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	w := getNextInt(scanner)
	h := getNextInt(scanner)
	n := getNextInt(scanner)
	yy := make([]int, h)
	xx := make([]int, w)
	for i := 0; i < n; i++ {
		x := getNextInt(scanner)
		y := getNextInt(scanner)
		a := getNextInt(scanner)
		switch a {
		case 1:
			for j := 0; j < x; j++ {
				xx[j] = 1
			}
		case 2:
			for j := x; j < w; j++ {
				xx[j] = 1
			}
		case 3:
			for j := 0; j < y; j++ {
				yy[j] = 1
			}
		case 4:
			for j := y; j < h; j++ {
				yy[j] = 1
			}
		}
	}
	var ans int
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			ans += 1 - (yy[i] | xx[j])
		}
	}
	fmt.Fprintln(writer, ans)
}


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

// 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;
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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(2000005);

mint g(int r, int c) {
  return comb(r+c+2, r+1) - 1;
}

int main() {
  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  --r1; --c1;

  mint ans = g(r2,c2);
  ans -= g(r1,c2);
  ans -= g(r2,c1);
  ans += g(r1,c1);
  cout << ans.x << endl;
  return 0;
}


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

main(){
  int N,T;
  cin >> N >> T;
  int c[N],t[N];
  for(int ii=0;ii<N;ii++){
    cin >> c[ii] >> t[ii];
  }
  int ans=INF;
  int cnt=0;
  for(int ii=0;ii<N;ii++){
    if(t[ii]<=T){
      ans=min(ans,c[ii]);
      cnt=1;
    }
    //    cout << c[ii] << endl;
  }
  if(cnt==0)cout << "TLE" << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(M);
  int I, co, X;
  co = 0;
  rep(i, M) {
    vec.at(i) = 0;
  }
  rep(i, N) {
    cin >> I;
    rep(j, I) {
      cin >> X;
      vec.at(X - 1) += 1;
    }
  }
  rep(i, M) {
    if(vec.at(i) == N) {
      co++;
    }
  }
  cout << co << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
//#include <cstdlib>

using namespace std;

int main(void)
{
	int N,X;
	int i;
	int result = 0;
	int count = 1;

	cin >> N >> X;

	vector<int> L(N);

	for (i = 0; i < N; i++)
	{
		cin >> L[i];
	}

	if (N < 1 || N > 100)
		return 1;
	if (X < 1 || X > 10000)
		return 1;
	for (i = 0; i < N; i++)
	{
		if (L[i] < 1 || L[i] > 100)
			return 1;
	}

	for (i = 1; i < N + 1; i++)
	{
		if (N == 1)
			break;

		if (L[i - 1] <= 0)
			break;

		result += L[i-1];

		if (result <= X)
			count++;
	}

	cout << count;

	return 0;
}

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

int main(){
  int taka_hp, taka_atk, ao_hp, ao_atk;
  
  cin >> taka_hp >> taka_atk >> ao_hp >> ao_atk;
  
  while( taka_hp > 0 && ao_hp > 0){
    //高橋の攻撃
    ao_hp -= taka_atk;
    
    if( ao_hp <= 0 ){
      cout << "Yes" << endl;
      break;
    }
    
    //青木の攻撃
    taka_hp -= ao_atk;
    
    if( taka_hp <= 0 ){
      cout << "No" << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3564
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    C = list(input())
    Rs = []
    for i in range(N):
        if C[i] == 'R':
            Rs.append(i)
    count = 0
    for i in range(N):
        if C[i] == 'W':
            if len(Rs) == 0:
                break
            j = Rs.pop()
            if i < j:
                C[i], C[j] = C[j], C[i]
                count += 1
    return count


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 86692
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::cmp;

fn f(i: i64, N: usize, A: Vec<i64>) -> i64 {
    let mut B = A.iter().map(|a| a % i).collect::<Vec<_>>();
    B.sort();
    let mut k = N - 1;
    let mut q = 0;
    for j in 0..N {
        while B[j] > 0 && B[j] < i {
            if j == k {
                return 10000000000;
            }
            let d = cmp::min(i - B[k], B[j]);
            B[k] += d;
            B[j] -= d;
            if B[k] == i {
                k -= 1;
            }
            q += d;
        }
    }
    q
}

fn main() {
    let (N, K) = get!(usize, i64);
    let A = get!(Vec<i64>);

    // 解の候補はsum(A)の約数である
    let s = A.iter().sum::<i64>();
    let D = (1..s).take_while(|d| d * d <= s).collect::<Vec<_>>();
    let D2 = (1..s).take_while(|d| d * d <= s).map(|d| s / d).collect::<Vec<_>>();
    let ans = D.iter().chain(D2.iter())
        .filter(
            |&d|
            {
                let mut B = A.iter()
                    .map(|a| a % d)
                    .collect::<Vec<_>>();
                B.sort();
                let mut acc = vec!(0; N + 1);
                let mut rev_acc = vec!(0; N + 2);
                for i in 0..N {
                    acc[i + 1] = B[i] + acc[i];
                    rev_acc[N - i] = (d - B[N - i - 1]) + rev_acc[N - i + 1]
                }
                (0..(N + 1)).any(|i| acc[i] <= K && acc[i] == rev_acc[i + 1])
            }
        )
        .max()
        .unwrap();

    println!("{}", ans);
}

Measured memory_bytes: 4476
#include <cstdio>
using namespace std;
const int N=100005;
int n,m,pre[N],ans,ans2;
int h[N],tot;
struct Edge{
	int v,next;
}e[N];
int f[N];
inline int max(int x,int y){
	return x>y?x:y;
}
inline int min(int x,int y){
	return x<y?x:y;
}
inline void addEdge(int u,int v){
	e[++tot]=(Edge){v,h[u]}; h[u]=tot;
}
void readData(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&pre[i]);
}
void paint(int u,int fa,int dep){
	if(u!=1){
		if(!dep){
			ans2++;
			dep++;
		}
	}
	f[u]=0;
	for(int i=h[u],v;i;i=e[i].next)
		if((v=e[i].v)!=1){
			paint(v,u,(dep+1)%(m+1));
			f[u]=max(f[u],f[v]+1);
		}
	if(u!=1){
		if(f[u]>=m-1&&fa!=1){
			f[u]=-1;
			ans++;
		}
	}
}
int main(){
	readData();
	if(pre[1]!=1){
		ans++;
		ans2++;
		pre[1]=1;
	}
	for(int i=1;i<=n;i++)
		addEdge(pre[i],i);
	paint(1,0,0);
	printf("%d\n",min(ans,ans2));
	return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pair<int,pii>,vector<pair<int,pii> >,greater<pair<int,pii> > >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

const int M = 105; 
  
int dp[M][M][2]; 
int K; 
int n;
string s;

int countInRangeUtil(int pos, int cnt, int tight) 
{ 
    if (pos == n) 
    { 
        if (cnt == K) 
            return 1; 
        return 0; 
    } 
  
    if (dp[pos][cnt][tight] != -1) 
        return dp[pos][cnt][tight]; 
  
    int ans = 0; 
  
    int limit = (tight ? 9 : (s[pos]-'0')); 
  
    for (int dig = 0; dig <= limit; dig++) 
    { 
        int currCnt = cnt; 
  
        if (dig != 0) 
            currCnt++; 
  
        int currTight = tight; 
  
        if (dig < s[pos]-'0') 
            currTight = 1; 
  
        ans += countInRangeUtil(pos + 1, currCnt, currTight); 
    } 
    return dp[pos][cnt][tight] = ans; 
} 
  

int32_t main() 
{ 
    cin>>s;
    n=s.size();
    cin>>K;
    MSET(dp,-1);
    cout<<countInRangeUtil(0,0,0); 
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	ll a[22],b[22],c[22];
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i];a[i]--;
	}
	for(ll i=0;i<n;i++){
		cin>>b[i];
	}
	for(ll i=0;i<n;i++){
		cin>>c[i];
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		ll now=a[i];
		ans+=b[now];
	}
	for(ll i=0;i<n;i++){
		if(i==n-1){
			continue;
		}
		ll now=a[i];
		if(now==n){
			continue;
		}
		ll nex=a[i+1];
		if(now+1==nex){
			ans+=c[now];
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define INFTY 10000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};

int main(){
    ll n,m,k;cin>>n>>m>>k;
    vector<ll>a(n),b(m);
    rep(i,n)cin>>a[i];
    rep(i,m)cin>>b[i];
    ll mx = 0,time=0;
    ll an=0,bn=0;
    while(time+a[an]<=k&&an<n){
        time += a[an];
        an++;
    }
    while(time+b[bn]<=k&&bn<m){
        time += b[bn];
        bn++;
    }
    mx = an+bn;//cout<<mx<<endl;
    while(an>0&&bn<m){
        time -= a[an-1];an--;
        int cnt=0;
        while(time+b[bn]<=k&&bn<m){
            time += b[bn];
            bn++;cnt++;
        }
        mx = max(mx,an+bn);
    }
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 6428
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <string>


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

void view(const vector<int>& v) {
	for (size_t i = 0; i < v.size(); i++) {
		cout << v[i] << " ";
	}
	cout << endl;
}
void view(const vector<vector<long long>>& vv) {
	for (size_t i = 0; i < vv.size(); i++) {
		for (size_t j = 0; j < vv[i].size()-1; j++) {
			cout << vv[i][j] << " ";
		}
		cout << vv[i][vv[i].size()-1];
		cout << endl;
	}
}

int main() {
	long long X;
	cin >> X;
	int count = 0;
	long long X_2 = 100;
	while (X_2 < X)
	{
		X_2 += 0.01*X_2;
		count++;
	}

	cout << count;
	return 0;
}

Measured memory_bytes: 3644
N, x = input().split()
N = int(N)
x = int(x)
al = [int(a) for a in input().split()]

al.sort()

cum = [sum(al[:i+1])for i in range(len(al))]

ans = N-1
for i in range(len(al)):
    if cum[i] == x:
        ans = i+1
        break
    elif cum[i]>x:
        ans = i
        break
print(ans)
    
        
        


Measured memory_bytes: 3064
//arc072_d.cpp
//Tue Jan 14 22:04:23 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll x,y;
	cin >> x >> y;

	if (abs(x-y)<=1){
		cout << "Brown" << endl;
	}else {
		cout << "Alice" << endl;
	}
}

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

using namespace std;

const int MAX = 100;
const long long INFTY = (1LL << 32);

int n;
long long d[MAX][MAX];

void floyd(){
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      if(d[i][k] == INFTY) continue;
      for(int j=0;j<n;j++){
        if(d[k][j] == INFTY) continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main(){
  int e, u, v, c;
  cin >> n >> e;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      d[i][j] = ((i == j) ? 0 : INFTY);
    }
  }

  for(int i=0;i<e;i++){
    cin >> u >> v >> c;
    d[u][v] = c;
  }

  floyd();

  bool negative = false;
  for(int i=0;i<n;i++){
    if(d[i][i] < 0) negative = true;
  }

  if(negative){
    cout << "NEGATIVE CYCLE" << endl;
  }
  else{
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(j) cout << " ";
        if(d[i][j] == INFTY) cout << "INF";
        else cout << d[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3176
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
int ctoi(char c){
  if(c>='0'&&c<='9'){
    return c-'0';
  }
  return 0;
}
int xoror(int a,int b){
  return 0;
}


//cout << setprecision(123)<<ans;
//int a=atoi(S.c_str());
//string S=to_string(a);
//int &a=b;
int main(){
  ll N,ans=0;
  cin>>N;
  vector<ll>A(N);
  vector<int>V(65,0);
  REP(i,N){
    cin>>A[i];
    ll b=floor(log2(A[i]))+1;
    vector<ll>vv(65,0LL);
    REP(j,b){
      vv[j]=A[i]%2;
      A[i]/=2;
    }
    REP(j,65){
      V[j]+=vv[j];
    }
  }

  
  
  REP(i,65){
   unsigned long long a;
    a=(N-V[i])*V[i];
    a%=mod;
    if(i>0){
      REP(j,i){
        a*=2;
        a%=mod;
      }
    }
    ans+=a;
    ans%=mod;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
from collections import deque
lis = deque()
n = int(input())
a = list(map(int, input().split()))
for i, j in enumerate(a):
    if i % 2 == 0:
        lis.appendleft(j)
    else:
        lis.append(j)
if n % 2 == 0:
    lis = list(lis)[::-1]
print(" ".join(map(str, lis)))

Measured memory_bytes: 30784
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
ll H, W;

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

  cin >> H >> W;
  if (H==1 || W==1) {
    cout << 1 << endl;
  }
  else if (H%2==0 || W%2==0) {
    cout << H*W/2 << endl;
  } else {
    cout << (H*W)/2+1 << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

typedef struct {
    uint64_t A;
    uint64_t B;
} _jI;

static _jI jI[200000];

int compare_j(const void* a, const void* b) {
    const _jI* aP = (_jI*)a;
    const _jI* bP = (_jI*)b;

    return aP->B < bP->B ? -1 : 1;
}

int main(void) {
    size_t N;

    scanf("%zu\n", &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%"PRIu64" %"PRIu64, &(jI[i].A), &(jI[i].B));
        if (i < N - 1) {
            scanf("\n");
        }
    }

    qsort(jI, N, sizeof(_jI), compare_j);

    uint64_t t = 0;
    size_t pos = 0;
    bool ableToComplete = true;

    while (pos < N) {
        if (jI[pos].B < t + jI[pos].A) {
            ableToComplete = false;
            break;
        }

        t += jI[pos].A;
        pos++;
    }

    puts(ableToComplete ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 6396
package main

import (
	"fmt"
)

func main() {

	var a, b, c int
	var flag bool
	fmt.Scan(&a, &b, &c)

	if a < b {
		for i := a; i <= b; i++ {
			if i == c {
				flag = true
			}
		}
	}

	if a > b {
		for i := b; i <= a; i++ {
			if i == c {
				flag = true
			}
		}
	}

	if flag == true {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

struct Block{
    int w, s, x;
    bool operator<(const Block& a){
        return w + s < a.w + a.s;
    }
};

vector<Block> v;

vector<vector<ll>> dp;

ll recurse(int st, int n, ll w){
    if(st == n) return 0ll;
    ll &z = dp[st][w];
    if(~z) return z;
    z = recurse(st + 1, n, w);
    if(w > (ll) v[st].s) return z;

    /// 2 cases, either we pick this block or not, and we recurse for other options!
    return z = max(z, recurse(st + 1, n, w + (ll) v[st].w) + (ll) v[st].x);
}

void max_self(ll &a, ll b){
    a = max(a, b);
}

void solve(){
    int n, w, s, x;
    cin>>n;
    v.resize(n);
    ll mxw = 0ll;
    fr(i, n){
        cin>>w>>s>>x;
        v[i] = {w, s, x};
        mxw += w;
    }

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

    /*
    dp.resize(n, vector<ll>(mxw + 1ll, -1));
    /// dp[i][j] = max. value/score of the tower formed if we have j weights so far, and has to consider elements starting from i.

    recurse(0, n, 0);
    cout<<dp[0][0];
    */

    ll mxs = v.back().w + v.back().s;
    /// doing it like knapsack problem
    vector<ll> dp(mxs + 1ll, 0ll);
    /// dp[i] - max score with weight exactly i

    for(Block b: v){
        for(ll weight_already = min((ll) b.s, (ll) mxs - (ll) b.w); weight_already >=0; weight_already--){
            max_self(dp[weight_already + (ll) b.w], dp[weight_already] + (ll) b.x);
        }
    }

    ll ans = 0;
    for(ll i = 0; i <= mxs; ++i) max_self(ans, dp[i]);

    cout<<ans;
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 384
#!python3

import sys

from bisect import bisect
iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    inf = 10**9+1
    A = []
    for i in range(N):
        x, y = map(int, sys.stdin.readline().split())
        A.append((x, y, i))
    A.sort()

    lo, hi = 100, N//2+1
    while lo < hi:
        md = (lo + hi) // 2
        if md**2 <= N:
            lo = md + 1
        else:
            hi = md
    step = lo

    #S = [(-inf, [])]
    S = []
    for i in range(0, N, step):
        ss = list(map(lambda x: (x[1], x), A[i:i+step]))
        x1 = ss[0][1][0]
        ss.sort()
        S.append((x1, ss))

    Q = int(input())

    ans = []
    #print(step)
    #print(A)
    #print(S)
    for x1, x2, y1, y2 in (map(int, line.split()) for line in sys.stdin):
        ix1, ix2 = bisect(A, (x1, y1-1)), bisect(A, (x2, y2+1))
        r1, r2 = ix1 // step, ix2 // step
        S1 = [S[i][1] for i in range(r1 + 1, r2)]

        v1, v2 = (y1,), (y2+1,)
        ans1 = []
        if S1:
            ss = S[r1][1]
            a1 = bisect(ss, v1)
            a2 = bisect(ss, v2, a1)
            for i in range(a1, a2):
                val = ss[i][1]
                if x1 <= val[0]:
                    ans1.append(val[2])
            ss = S[r2][1]
            a1 = bisect(ss, v1)
            a2 = bisect(ss, v2, a1)
            for i in range(a1, a2):
                val = ss[i][1]
                if val[0] <= x2:
                    ans1.append(val[2])
        else:
            for i in range(ix1, ix2):
                val = A[i]
                if y1 <= val[1] <= y2:
                    ans1.append(val[2])
            ans1.sort()
            ans.append(ans1)
            continue

        for ss in S1:
            a1 = bisect(ss, v1)
            a2 = bisect(ss, v2, a1)

            for j in range(a1, a2):
                ans1.append(ss[j][1][2])
        #print(S1)
        ans1.sort()
        ans.append(ans1)
        #print("=", ans[-1])

    ss, br = "", "\n"
    for aa in ans:
        if len(aa):
            ss += br.join(map(str, aa)) + br
        ss += br
    print(ss, end="")


if __name__ == "__main__":
    resolve()




Measured memory_bytes: 125956
n = int(input())
arr = list(map(int, input().split()))
r = 0
cols = [0] * 8
for i in arr:
  color = i // 400
  if color <= 7:
    cols[color] = 1
  else:
    r += 1
c = sum(cols)
print(max(1, c), r+c)

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


int main()
{
  string s, t;
  cin >> s >> t;
  int ans = 0;
  int len = s.length();
  rep(i, len)
    if (s[i] != t[i])
      ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3860
#include <iostream>
using namespace std;
#define ll long long

int main () {
  ll n, m;
  cin >> n >> m;
  if (2 * n >= m) {
    cout << m / 2 << endl;  
  }   
  else {
    ll ans = n;
    m = m - 2 * n;
    ans = ans + m / 4;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string.h>
#define LL long long
#define MOD 11
using namespace std;
int clu(int i, int j)
{
    return 7 * i + j - 7;
}
int main()
{
    int n, k;
    LL res = 0;
    cin >> n >> k;
    for(int i = 1; i <= 5; i++)
    {
        int sum = 0, tmp = 3;
        for(int j = 0; j < 3; j++)
        {
            for(int k = 0; k < 3; k++)
            {
                sum += clu(1 + j, i + k);
            }
        }
        sum %= MOD;
        while(sum != k)
        {
            sum = (sum + 8) % MOD;
            tmp++;
        }
        if(tmp <= n)
        {
            //cout << tmp - 2 << " " << i << endl;
            res += (1 + (n - tmp) / MOD);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 384