akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 VVI a(3,VI(3));
  rep(i,3){
    rep(j,3){
      cin >> a.at(i).at(j);
    }
  }
  int n;
  cin >> n;
  VI b(n);
  rep(i,n){
    cin >> b.at(i);
  }
  rep(i,3){
    rep(j,3){
	 rep(k,n){
       if(b.at(k)==a.at(i).at(j)){
         a.at(i).at(j)=0;
       }
     }
    }
  }
  bool ans=false;
  rep(i,3){
    if(a.at(i).at(0)==0 && a.at(i).at(1)==0 && a.at(i).at(2)==0){
		ans=1;
    }
  }
   rep(i,3){
    if(a.at(0).at(i)==0 && a.at(1).at(i)==0 && a.at(2).at(i)==0){
		ans=1;
    }
  }
    if(a.at(0).at(0)==0 && a.at(1).at(1)==0 && a.at(2).at(2)==0){
		ans=1;
    }
    if(a.at(2).at(0)==0 && a.at(1).at(1)==0 && a.at(0).at(2)==0){
		ans=1;
    }
  if(ans) cout <<"Yes" <<endl;
  else cout <<"No" <<endl;
  
}

Measured memory_bytes: 256
S = input()
left = 0
right = len(S) - 1
ACGT = "ACGT"
acgt_index = []
for i in range(len(S)):
    if S[i] in ACGT:
        acgt_index.append(i)
if len(acgt_index) == 0:
    print(0)
    exit()
dif = [acgt_index[i + 1] - acgt_index[i] for i in range(len(acgt_index) - 1)]
ans = 0
now = 0
for i in dif:
    if i == 1:
        now += 1
        ans = max(ans, now)
    else:
        now = 0
print(ans+1)


Measured memory_bytes: 38552
fun main() = abc166d()

@OptIn(ExperimentalStdlibApi::class)
fun abc166d() {
    val x = readLine()!!.toLong()

    val set = mutableSetOf<Long>()

    for (i in -500L..500L) {
        set.add(pow(i, 5))
    }

    val list = set.sorted().toLongArray()

    for (left in list.indices) {
        for (right in list.indices) {
            if (list[left] - list[right] == x) return println("${left - 500} ${right - 500}")
        }
    }

    error("nande?")
}

private fun pow(n: Long, p: Long): Long = (1L..p).fold(1L) { acc, i -> acc * n }


Measured memory_bytes: 38408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int x[100005];
int dx[100005], dx2[100005];

int main() {
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> x[i];
	for (int i = 0; i <= n; i++) dx[i] = abs(x[i + 1] - x[i]);
	for (int i = 0; i < n; i++) dx2[i] = abs(x[i + 2] - x[i]);
	int sum = 0;
	for (int i = 0; i <= n; i++) sum += abs(x[i + 1] - x[i]);
	for (int i = 1; i <= n; i++) cout << sum - dx[i - 1] - dx[i] + dx2[i - 1] << endl;
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back

int main(){
    
    // 1. 入力情報.
    char c[2020];
    int w;
    scanf("%s %d", c, &w);
    
    // 2. 文字を連結.
    string ans = "";
    int l = strlen(c);
    rep(i, l) if(i % w == 0) ans.pb(c[i]);
    
    // 3. 出力.
    printf("%s\n", ans.c_str());
    return 0;
    
}

Measured memory_bytes: 3700
import numpy as np
MOD = 10**9 + 7

def plu(a,b):
    return (a + b)%MOD

plus = np.frompyfunc(plu,2,1)

n = int(input())
c = np.sort(np.array(input().split(),dtype = np.int64))
p = pow(2,2*n-2,MOD)
print(plus.reduce(np.mod(np.mod(p*c,MOD)*(n-np.arange(n)+1),MOD)))



Measured memory_bytes: 37324
import java.util.*;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long a[] = new long[3*n];
		for(int i=0; i<3*n; i++) {
			a[i]=sc.nextLong();
		}

		PriorityQueue<Long> pq1 = new PriorityQueue<>();//前
		ArrayList<Long> tmp1 = new ArrayList<Long>();
		{
			long sum1 = 0;
			for(int i=0; i<n; i++) {
				pq1.add(a[i]);
				sum1+= a[i];
			}

			tmp1.add(sum1);
			for(int i=n; i<2*n; i++) {
				pq1.add(a[i]);
				sum1 += a[i];
				sum1 -= pq1.poll();
				tmp1.add(sum1);
			}
		}
		PriorityQueue<Long> pq2 = new PriorityQueue<>(Collections.reverseOrder());
		ArrayList<Long> tmp2 = new ArrayList<Long>();
		{
			long sum1 = 0;
			for(int i=3*n-1; i>=2*n; i--) {
				pq2.add(a[i]);
				sum1+= a[i];
			}

			tmp2.add(sum1);
			for(int i=2*n-1; i>=n; i--) {
				pq2.add(a[i]);
				sum1 += a[i];
				sum1 -= pq2.poll();
				tmp2.add(sum1);
			}
		}
		long ans = -Long.MAX_VALUE;
		for(int i=0; i<=n; i++) {
			ans = Math.max(ans, tmp1.get(i) - tmp2.get(n-i))  ;
		}
		System.out.println(ans);
		sc.close();
	}


}


Measured memory_bytes: 69120
import sys
sys.setrecursionlimit(1<<30)
M = 10**9+7
N, Blue =map(int,input().split())
Red = N-Blue
Comb = [[0]*(N+1) for i in range(0,N+1)]
for i in range(1,N+1):
    Comb[i][0] = 1
    Comb[i][1] = i
    Comb[i][i] = 1
Comb[0][0] = 1
for i in range(1,N+1):
    for j in range(2,i+1):
        Comb[i][j] = (Comb[i-1][j] + Comb[i-1][j-1])%M
for i in range(1,Blue+1):
    A = Comb[Red+1][i] * Comb[Blue-1][i-1]
    print(A%M)

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

using namespace std;

int main(){
    int n;
    string s;
    int flag=0,count=0,rui=0;
    cin>>n;
    while(flag<n*3){
        cin>>s;
        if(s=="OUT"){
            flag++;
            if(flag%3==0){
                cout<<count<<endl;
                count=0;rui=0;
            }
        }
        else if(s=="HIT"){
            if(rui<3)rui++;
            else count++;
        }
        else {
            count+=rui;++count;
            rui=0;
        }
    }
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M,X,Y; cin >> N >> M >> X >> Y;
    int  x[110],y[110];
    for(int i=0; i < 110; i++) x[i] = -110;
    for(int i=0; i < 110; i++) y[i] = 110;
    for(int i=0; i<N; i++) cin >> x[i];
    for(int i=0; i<M; i++) cin >> y[i];
    sort(x, x+110, greater<int>());
    sort(y, y+110);
    for(int i=X+1; i <= Y; i++){
        if(x[0] < i){
            if(y[0] >= i){
                cout << "No War" << endl;
                return 0;
            }
        }
    }
    cout << "War" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll x, y;
    cin >> x >> y;
    if (abs(x - y) <= 1)
        cout << "Brown"
             << "\n";
    else
        cout << "Alice"
             << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int p[N];
    for(int i = 0; i < N; i++) cin >> p[i];

    int a,b;
    int cnt = 0;
    for(int i = 1; i <= N; i++){
      if(p[i - 1] != i){
        if(cnt == 0){
          a = i;
          cnt++;
        }else if(cnt == 1){
          b = i;
          cnt++;
        }else{
          cout << "NO" << endl;
          cnt++;
          break;
        }
      }
    }
    if(cnt == 0 || cnt == 2) cout << "YES" << endl;
}


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


int main() {
  int N, K;
  cin >> N >> K;
  
  int board = 1;
  for (int i=0; i<N; i++) {
    if (board <= K) board *= 2;
    else board += K;
  }
  
  cout << board << endl;

  return 0;
}


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

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; }

const ll INF = 1LL << 60;

vector<vector<int>> dp(100010, vector<int>(3, 0));

int main() {
    int N;
    cin >> N;
    vector<vector<int>> V(N + 1, vector<int>(3));
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < 3; j++) {
            scanf("%d", &V[i][j]);
        }
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) {
                    continue;
                }
                chmax(dp[i][j], dp[i - 1][k] + V[i][j]);
            }
        }
    }
    
    int ans = max(dp[N][0], max(dp[N][1], dp[N][2]));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
#if 0
	??????????????????????????????
#endif
#include <iostream>
#include <queue>

using namespace std;

int main(){
	int n, u, k, v;
	int D[100];
	bool adj[100][100] = {};
	int pushed[100] = {};
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> u >> k;
		for (int j = 1; j <= k; j++){
			cin >> v;
			adj[u][v] = true;
		}
	}
	for (int i = 1; i <= n; i++){
		D[i] = -1;
	}
	queue<int> Q;
	Q.push(1);
	D[1] = 0;
	pushed[1] = 1;
	while(!Q.empty()){
		int m = Q.front();
		Q.pop();
		for (int i = 1; i <= n; i++){
			if (adj[m][i] == true && pushed[i] == 0){
				D[i] = D[m]+1;
				Q.push(i);
				pushed[i] = 1;
			}
		}
	}
	
	for (int i = 1; i < n+1; i++){
		cout << i << ' ' << D[i] << endl;
	}
}

Measured memory_bytes: 3072
import sys
k=int(raw_input())
n=k

if n<50:
    if n%2==0:
        print 2
        print "%d %d" %( n/2+1,n/2+1)
    else:
        print 2
        print "%d %d" % ((n-1)/2,(n-1)/2+3)
    sys.exit(0)


def proc(ls):
    ls.sort()
    ls[-1]-=len(ls)
    for i in range(len(ls)-1):
        ls[i]+=1
    return ls
if k%5==0:
    print 50
    ans= [k/50+49]*50
    for i in range(49):
        sys.stdout.write(str(ans[i])+" ")
    sys.stdout.write(str(ans[49]))
    sys.stdout.write("\n")
else:
    print 50
    k+=50
    ans=[k/50+49]*50
    for i in range(50-k%50):
        ans=proc(ans)
    for i in range(49):
        sys.stdout.write(str(ans[i])+" ")
    sys.stdout.write(str(ans[49]))
    sys.stdout.write("\n")


Measured memory_bytes: 2696
"use strict"

function Main(input) {
  const reverse = (s) => {
    return s.split('').reverse().join('');
  };

  const WORDS = ['dream', 'dreamer', 'erase', 'eraser'].map(reverse);
  const S = reverse(input.split('\n')[0]);

  let index = 0;

  while (true) {
    let w = WORDS.find((w) => S.startsWith(w, index));
    if (!w) break;
    index += w.length;
  }

  if (S.length === index) {
    console.log('YES');
  } else {
    console.log('NO');
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const int N = 1000 * 1000 + 5;
const int mod = 1000 * 1000 * 1000 + 7;

long long fac[N];
long long a[N];
long long ps[N];
int po(int x, int y) {
	if (y == 0)
		return 1;
	long long ans = po(x, y / 2);
	ans *= ans;
	ans %= mod;
	if (y % 2 == 1) {
		ans *= x;
		ans %= mod;
	}
	return ans;
}
int chs(int x, int y) {
	if (x < y || y < 0)
		return 0;
	long long ans = fac[x];
	ans *= po(fac[y], mod - 2);
	ans %= mod;
	ans *= po(fac[x - y], mod - 2);
	ans %= mod;
	return ans;
}

int main() {
	int n;
	cin >> n;
	if (n == 2) {
		cout << 1 << endl;
		return 0;
	}
	long long ans = 0;
	fac[0] = 1;
	for (int i = 1; i <= n; i++) {
		fac[i] = fac[i - 1] * i;
		fac[i] %= mod;
	}
//	cout << chs(4, 2) << endl;
	for (int i = 2; i < n; i++) {
		a[i] = chs(i - 1, n - 1 - i);
		a[i] *= fac[n - i - 1];
		a[i] %= mod;
		a[i] *= fac[i];
		a[i] %= mod;
	//	cout << i << " " << chs(i - 1, n - 1 - i) << " " << a[i] << endl;
		a[i] -= ps[i - 1];
		a[i] += mod;
		a[i] %= mod;
		ps[i] = ps[i - 1] + a[i];
		ps[i] %= mod;
		ans += a[i] * i;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 23808
import java.util.Scanner;
 
public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
 
        int n = stdIn.nextInt();
        int min = 10000000;
        int count = 0;
        //int c = stdIn.nextInt();
        //int x = stdIn.nextInt();
        int p[] = new int[n];
        //String s = stdIn.next();
        //String t = stdIn.next();
        //char c[] = s.toCharArray();
        
        //c[0] += 1;
        //int sum = 0;
        //boolean flag = true;
        for(int i = 0; i < n; i++){
            p[i] = stdIn.nextInt();
            
            if(min >= p[i]){
                count++;
                min = p[i];
            }
        }
        
        
        System.out.println(count);
        //System.out.println();
        //System.out.print();
 
        stdIn.close();
    }
}

Measured memory_bytes: 66884
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");
		int n = Integer.parseInt(tmpArray[0]);
		int m = Integer.parseInt(tmpArray[1]);
		
		System.out.println((n-1)*(m-1));

	}

}


Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
using namespace std;
int main() {
  int n,k;
  cin >> n >> k;
  vector<int> A(n);
  for(int i=0;i<n;i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  A.push_back(0);
  vector<int> S;
  int c=0;
  for(int i=0;i<n;i++) {
    c++;
    if(A[i] != A[i+1]) {
      S.push_back(c);
      c=0;
    }
  }
  sort(S.begin(), S.end());
  int count=S.size(), j=0, max=0;
  while(count > k) {
    count -= 1;
    max += S[j++];
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 2800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);

const int N = 2e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
ll OOL = 0x3f3f3f3f3f3f3f3f;
int tc;
int n, m;
string grid[1005];
int sr, sc, er, ec;
ll dis[1005][1005];
int dir[] = {-1,1,0,0};
int dic[] = {0,0,1,-1};
bool valid(int r, int c)
{
    return r >= 0 && r < n && c >= 0 && c < m  && grid[r][c]!= '#';
}
int main()
{
    FIO
    cin>>n>>m;
    cin>>sr>>sc;
    cin>>er>>ec;
    sr--, sc--, er--, ec--;
    for(int i = 0 ; i<n ; i++) cin>>grid[i];
    memset(dis,OOL, sizeof dis);
    priority_queue<pair<ll, pair<int, int> >  > q;
    q.push({0,{sr, sc}});
    dis[sr][sc] = 0;
    while(!q.empty())
    {
        int ur = q.top().second.first, uc = q.top().second.second; ll c = -q.top().first;
        q.pop();
        if(c!= dis[ur][uc])
            continue;
        if(ur == er  && uc == ec)
            break;
        for(int i = 0 ; i< 4 ; i++)
        {
            int vr = ur + dir[i], vc = uc + dic[i];
            if(valid(vr, vc) && dis[vr][vc] > dis[ur][uc])
            {
                dis[vr][vc] = dis[ur][uc];
                q.push({-dis[vr][vc], {vr, vc}});
            }
        }
        for(int i = ur - 2 ; i <= ur + 2 ; i++)
        {
            for(int j = uc -2 ; j <= uc+2; j++)
            {
                if(valid(i, j) && dis[i][j] > dis[ur][uc] + 1)
                {
                    dis[i][j] = dis[ur][uc] + 1;
                    q.push({-dis[i][j], {i, j}});
                }
            }
        }
    }
    dis[er][ec] == OOL ? cout<<-1: cout<<dis[er][ec];
    return 0;
}

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

int main() {
  char num[5] ;
  scanf("%s", num) ;
  if(num[1]== num[2]){
    if(num[0]==num[1] || num[2]==num[3]){
      printf("Yes\n");
      return 0;
    }     
  }
  printf("No\n") ;  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

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

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll k,s;
cin>>k>>s;
ll cnt=0;
for(ll i=0;i<=k;i++){
    for(ll j=0;j<=k;j++){
if(s-i-j>=0&&s-i-j<=k){
    cnt++;
}
    }
}
cout<<cnt<<endl;
}










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

using namespace std;

int main(){
	long long n;
	string data;
	long long i, j, k;
	long long r = 0,g = 0,b = 0;
	long long count;
	cin >> n;
	cin >> data;
	for (i = 0; i < n; i++) {
		if (data[i] == 'R')r++;
		else if (data[i] == 'G')g++;
		else b++;
	}
	count = r * g * b;
	for (i = 0; i < n - 2; i++) {
		for (j = i + 1; j < n - 1; j++) {
			k = 2 * j - i;
			if (k < n && j < k) {
				if (data[i] != data[j] && data[i] != data[k] && data[j] != data[k])count--;
			}
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 3612
#include <cstdio>
using namespace std;
constexpr int mod = 1000000007;
int a[100000];
int main() {
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        scanf("%d", a + i);
    int ans = 1;
    for(int i = 0, j = 0; i < n; i++) {
        while(j + 1 < n && a[j] >= 2 * (j - i) + 1)
            j++;
        // fprintf(stderr, "j=%d i=%d\n", j, i);
        ans = 1LL * ans * (j - i + 1) % mod;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<utility>

int gcd(int a, int b) {
	while (a) {
		b %= a;
		::std::swap(a, b);
	}
	return b;
}

int main() {
	int n;
	::std::cin >> n;
	int ans = 0;
	while (n--) {
		int a;
		::std::cin >> a;
		ans = gcd(ans, a);
	}
	::std::cout << ans << ::std::endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
c = []
for i in range(m):#h:高さ
    c.append([int(m) for m in input().split()])


graph = {}
for i in range(n):
    graph[i + 1] = []
for i in range(m):
    graph[c[i][0]] = graph[c[i][0]] + [c[i][1]]
    graph[c[i][1]] = graph[c[i][1]] + [c[i][0]]
stack = []
start = 1
i = start
visited = set()
visited.add(i)
root = [i]
while True:
    for j in graph[i]:
        if j not in visited:
            i = j
            root += [i]
            visited.add(i)
            break
    else:
        break
i = 1
root2 = []
while True:
    for j in graph[i]:
        if j not in visited:
            i = j
            root2 += [i]
            visited.add(i)
            break
    else:
        break
ver = len(root2) + len(root)
print(ver)
root = root2[::-1] + root
for i in root:
    print(i, "", end="")

Measured memory_bytes: 48120
/*
      author : nishi5451
      created: 12.08.2020 14:48:15
*/

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


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b && b==c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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


int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  int outlet = 1;
  while (outlet < b){
    outlet--;
    outlet += a;
    ans++;
  }
  cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long long a,b,c,k;
	cin>>a>>b>>c>>k;
    if (k%2==0)
	{
		cout<<a-b<<endl;
		system ("pause");
		return 0;
	} 
	else cout<<b-a<<endl;
	system ("pause");
	return 0;
} 

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;

int main(){
  int n, k;
  cin >> n >> k;
  set<P> st;
  rep(i, n){
    int a;
    cin >> a;
    bool flag = false;
    P target;
    for (auto itr = st.rbegin(); itr != st.rend(); itr++){
      if (abs(a - (itr->second)) <= k){
        int cnt = itr->first;
        target = P(cnt+1, a);
        flag = true;
        break;
      }
    }
    if (flag) st.insert(target);
    if (!flag){
      st.insert(P(1, a));
    }
  }
  cout << st.rbegin()->first << endl;
  
  return 0;
}

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

int main() {
  long n,m,j=0;
  cin >> n >> m;
  vector<long> a(101000);
  vector<long> dp(n+1);
  for(int i=0;i<m;i++) cin >> a.at(i);
  dp.at(0)=1;
  for(int i=1;i<=n;i++) {
    if(a.at(j)==i) {
      j++;
      if(j==m) j--;
    } else {
      if(i!=1) dp.at(i)+=dp.at(i-2);
      dp.at(i)+=dp.at(i-1);
      dp.at(i)=dp.at(i)%1000000007;
    };
  };
  cout << dp.at(n) << endl;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long a, long long b){
    if(b == 100){
        a = a*1000+b;
    }
    else if(b >=10){
        a = a*100+b;
    }
    else{
        a = a*10+b;
    }
    for(ll i=1; i*i <= a; i++ ){
        if(i*i == a){
            cout << YES << endl;
            return;
        }
    }
    cout << NO << endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    char S[4];      //予報
    char T[4];      //実際
    int i;
    int ans = 0;
    
    scanf( "%s", S );
    scanf( "%s", T );
    
    //printf( "%s,%s\n", S, T );
    
    for( i=0; i<3; i++ )
    {
        if( S[i] == T[i] )
        {
            ans++;
        }
    }
    printf( "%d", ans );
}


Measured memory_bytes: 128
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

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


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         <vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define MN                           INT_MIN
#define MX                           INT_MAX


bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}


int32_t main()
{
	int a,b;
	cin >> a >> b;
	cout<<  6 - a - b<<endl;
}

Measured memory_bytes: 3640
use std::io;
use std::io::{Read, BufReader};
use std::cmp;

fn next_token<R: Read>(reader: &mut R) -> Vec<u8> {
    let mut buf: [u8; 1] = [0];
    let mut read_chars = false;
    let mut ret: Vec<u8> = vec![];

    loop {
        if reader.read(&mut buf).unwrap() == 0 {
            break;
        } else {
            if buf[0] == '\r' as u8 || buf[0] == '\n' as u8 || buf[0] == ' ' as u8 {
                if read_chars {
                    break;
                }
            } else {
                read_chars = true;
                ret.push(buf[0]);
            }
        }
    };
    ret
}
fn next_i64<R: Read>(reader: &mut R) -> i64 {
    let token = next_token(reader);
    let mut ret: i64 = 0;
    let mut sgn = false;

    for c in token {
        if '0' as u8 <= c && c <= '9' as u8 {
            ret = ret * 10 + (c - ('0' as u8)) as i64;
        } else if '-' as u8 == c {
            sgn = true;
        }
    };
    ret * if sgn { -1 } else { 1 }
}
fn next_i32<R: Read>(reader: &mut R) -> i32 {
    next_i64(reader) as i32
}

fn gcd(a: i32, b: i32) -> i32 {
    if a % b == 0 { b } else { gcd(b, a % b) }
}
fn main() {
    let buf = &mut BufReader::new(io::stdin());
    let n = next_i32(buf);
    let k = next_i32(buf);
    let mut g = 0;
    let mut mx = 0;
    for _ in 0..n {
        let a = next_i32(buf);
        g = gcd(g, a);
        mx = cmp::max(mx, a);
    }
    if k <= mx && k % g == 0 {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }
}


Measured memory_bytes: 4352
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;

#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

ll n, k, m, M = 1e9 + 7;

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

    string s;
    cin >> s;

    int max = 0, num = 0;
    for(char x : s) {
        if(x == 'A' || x == 'C' || x == 'G' || x == 'T') {
            num++;
        } else {
            if(max < num) max = num;
            num = 0;
        }
    }
    if(max < num) max = num;

    cout << max << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
	  #define endl "\n"
	  #define ll long long int
	  #define mod 1000000007
	  #define inf 1000000000000000001;
	  using namespace std;
	  int main()
	  {
	    //  #ifndef ONLINE_JUDGE
	    //  // for getting input from input.txt
	    //  freopen("input.txt", "r", stdin);
	    //  // for writing output to output.txt
	    //  freopen("output.txt", "w", stdout);
	    // #endif
	    std::ios::sync_with_stdio(false);
	    cin.tie(NULL);
	    int n;
	    cin>>n;
	    auto s = to_string(n);
	    // stos(s);
	    for (int i = 0; i <= 2; ++i)
	    {
	    	/* code */
	    	if(s[i] == '9'){
	    		s[i] = '1';
	    	}
	    	else if(s[i] == '1'){
	    		s[i] = '9';
	    	}
	    }
	    cout<<stoi(s);
	    return 0;
	  }


Measured memory_bytes: 3704
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	num_list := []int{}

	scanner.Scan()
	line := scanner.Text()

	for _, n := range strings.Split(line, " ") {
		v, _ := strconv.Atoi(strings.TrimSpace(n))
		num_list = append(num_list, v)
	}

	fmt.Println(num_list[0] ^ num_list[1] ^ num_list[2])
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)

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

constexpr int MAXN = 5 + 1000000;

set<ll> s;

void add(ll x) {
  if (x > 1) s.insert(x);
}

void ndiv(ll x) {
  for (ll i = 1; i * i <= x; ++i) {
    if ((x % i) == 0) {
      add(i);
      add(x/i);
    }
  }
}

bool ok(ll x, ll d) {
  if (d == 1) return false;
  while ((x % d) == 0) x /= d;
  return (x % d) == 1;
}

void solve(ll x) {
  for (ll i = 1; i * i <= x; ++i) {
    if ((x % i) == 0) {
      ll d1 = i, d2 = x/i;
      if (ok(x,d1)) add(d1);
      if (ok(x,d2)) add(d2);
    }
  }
}


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

  ll n; cin >> n;
  if (n == 2) cout << 1 << '\n';
  else {
    solve(n);
    ndiv(n-1);

    cout << s.size() << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s1,s2,s3;
int main()
{
    int num1=0;
    int num2=0;
    cin>>s1;
    cin>>s2;
    for(int i=0;i<s1.size()+s2.size();i++)
    {
        if(i%2)
        {
            cout<<s2[num1++];
        }
        else
        {
            cout<<s1[num2++];
        }
    }
    cout<<endl;
    return 0;
}


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

int Prime(int);
int main(){
  int i,N,num,count=0;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&num);
    count+=Prime(num);
  }
  printf("%d\n",count);

  return 0;
}

int Prime(int num){
  int i;
  for(i=2;i<=sqrt(num);i++){
    if(num%i==0)return 0;
  }
  return 1;
}
  

Measured memory_bytes: 596
import collections

def f(l):
    array = []
    c = collections.Counter(l)
    for key, val in c.items():
        array.append([key,val])
    array = sorted(array, key=lambda x:x[1], reverse=True)
    return array

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

    V_odd = V[::2]
    V_even = V[1::2]
    mode_list_odd = f(V_odd)
    mode_list_even = f(V_even)

    first_mode_odd = mode_list_odd[0][0]
    first_mode_even = mode_list_even[0][0]

    ans = 0
    if first_mode_odd == first_mode_even:
        if len(mode_list_odd) == 1:
            if len(mode_list_even) == 1:
                ans = min(len(V_odd),len(V_even))
            else:
                ans = len(V_even)-mode_list_even[1][1]
        else:
            if len(mode_list_even) == 1:
                ans = len(V_odd)-mode_list_odd[1][1]
            else:
                count1 = len(V_odd)-mode_list_odd[0][1]+len(V_even)-mode_list_even[1][1]
                count2 = len(V_odd)-mode_list_odd[1][1]+len(V_even)-mode_list_even[0][1]
                ans = min(count1, count2)
    else:
        ans = len(V_odd)-mode_list_odd[0][1] + len(V_even)-mode_list_even[0][1]
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
    int n, q;
    cin >> n >> q;
    queue<int> que[n];

    for(int i = 0; i < q; i++) {
        int p;
        cin >> p;
        if(p == 0) {
            int t, x;
            cin >> t >> x;
            que[t].push(x);
        }
        else if(p == 1) {
            int t;
            cin >> t;
            if(que[t].size() == 0){
                continue;
            }
            cout << que[t].front() << endl;;
        }
        else {
            int t;
            cin >> t;
            if(que[t].size() == 0){
                continue;
            }
            que[t].pop();
        }
    }

}


Measured memory_bytes: 4200
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

const long int MOD = 1e9 + 7;

int main(void) {
  int n;  cin >> n;
  vector<int> a(n);
  REP (i, n) cin >> a[i];
  bool ok = true;
  long long ans = 1LL;
  sort(a.begin(), a.end());
  int s, m;
  (n % 2 == 0) ? (s = 0, m = 1) : (s = 1, m = 2);
  if (n % 2 != 0) if (a[0] != 0) ok = false;
  for (int i = s; i < n; i += 2) {
    if (a[i] != m || a[i + 1] != m) {
      ok = false;
      break;
    }
    m += 2;
    ans *= 2;
    ans %= MOD;
  }
  cout << (ok ? ans : 0) << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 405;
const LL mod = 1e9+7;
LL sum[MAXN];
LL A[MAXN],B[MAXN];
LL dp[MAXN][MAXN];
LL N,C;

LL calc(int a, int b)
{
    memset(sum,0,sizeof(sum));
    for(int i = a; i <= b; ++i)
    {
        LL t = 1;
        for(int j = 0; j <= C; ++j)
        {
            sum[j] = sum[j]+t;
            sum[j] %= mod;
            t = t*i%mod;
        }
    }
}

int main()
{
	cin >> N >> C;
	for(int i = 1; i <= N; ++i)
		cin >> A[i];
	for(int i = 1; i <= N; ++i)
		cin >> B[i];
	dp[0][0] = 1;
	for(int i = 1; i <= N; ++i)
	{
	    calc(A[i],B[i]);
		for(int j = 0; j <= C; ++j)
			for(int k = 0; k <= j; ++k)
				dp[i][j] = (dp[i][j] + dp[i-1][j-k]*sum[k])%mod;
	}
	cout << dp[N][C] << endl;
	return 0;
}


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

int main() {
    int n,y; cin>>n>>y;
    rep(i,n){
        rep(j,n-i){
            int k=n-i-j;
                if(i*10000+j*5000+k*1000==y) {
                    cout<<i<<' '<<j<<' '<<k<<endl;
                    return 0;
                }
        }
    }
        cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll fac[100010];
int a[100010];
bool vis[100010];
inline ll pow2(ll a,ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return res;
}
inline ll getInv(ll _x){
	return pow2(_x,mod-2);
}
inline ll getC(int n,int m){
	if(n<m) return 0;
	return fac[n]*getInv(fac[m])%mod*getInv(fac[n-m])%mod;
}
int main(){
	int N,p,p2;
	scanf("%d",&N);
	for(int i=1;i<=N+1;i++){
		scanf("%d",a+i);
		if(vis[a[i]]) p2=i;
		vis[a[i]]=true;
	}
	for(int i=1;i<=N+1;i++){
		if(a[i]==a[p2]){
			p=i;
			break;
		}
	}
	fac[0]=1;
	for(int i=1;i<=N+1;i++){
		fac[i]=fac[i-1]*i%mod;
	}
	for(int i=1;i<=N+1;i++){
		ll ans=(getC(N+1,i)+mod-getC(N+1-p2+p-1,i-1))%mod;
		printf("%lld\n",ans);
	}
	return 0;
}

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

const int N = 1e6+3;
int n;
ll a[N],f[N];


vector<ll>primes;
bitset<N>v;
void init() {
    for(ll i=2;i<N;++i) {
        if(!v[i]) {
            primes.push_back(i);
            for(ll j=i+i;j<N;j+=i)
                v[j] = 1;
        }
    }
}

void solve(){
    cin >> n;
    bool flg = 0;
    ll g = 0;
    for(int i=0;i<n;++i) {
        ll t;
        cin >> t;
        a[i] = t;
        g=__gcd(g,a[i]);
        for(int j=0;j<(int)primes.size()&&primes[j]*primes[j]<=t;++j) {
            if(t%primes[j]==0) {
                int cnt=0;
                while(t%primes[j]==0)
                    t/=primes[j] , cnt++;
                if(f[primes[j]]!=0)
                    flg=1;
                f[primes[j]]+=cnt;
            }
        }
        if(t>1) {
            if(f[t]>0)
                flg=1;
            f[t]++;
        }
    }
    if(!flg&&(g==1)) {
        cout << "pairwise coprime\n";
    }
    else if(g==1) {
        cout << "setwise coprime\n";
    }
    else {
        cout << "not coprime\n";
    }
}

int main(){
    init();
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    while(t--)
        solve();
    return  0;
}


Measured memory_bytes: 19676
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    ll n,a,b; cin >> n >> a >> b;
    if(a > b || (n == 1 && a != b)) cout << 0 << endl;
    else cout << (b*(n-1)+a) - (a*(n-1)+b) +1 << endl;
    return 0;
}


Measured memory_bytes: 256
x0, y0, x1, y1 = gets.split.map(&:to_f)

v0x = x1 - x0
v0y = y1 - y0
r0 = v0x*v0x+v0y*v0y
q = gets.to_i
q.times{
  x, y = gets.split.map(&:to_f)
  v1x = x - x0
  v1y = y - y0
  r1 = v1x*v1x+v1y*v1y
  cross_product = v0x * v1y - v0y * v1x
  if cross_product > 0
    puts "COUNTER_CLOCKWISE"
  elsif cross_product < 0
    puts "CLOCKWISE"
  else
    if v0x * v1x < 0 || v0y * v1y < 0
      puts "ONLINE_BACK"
    else
      if r0 < r1
        puts "ONLINE_FRONT"
      else
        puts "ON_SEGMENT"
      end
    end
  end
}

Measured memory_bytes: 8788
#include<iostream>
#include<cmath>
 
using namespace std;
 
int main(){
  int h,w,n;
  cin >> h;
  cin >> w;
  cin >> n;
  
  int a = max(h,w);
  int count = 0;
  
  while(1){
    n-=a;
    count++;
    if(n<=0){
      break;
    }
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#define for1(be,end,z) for(z=be;z<end;z++)
#define for2(end,z) for1(0,end,z)

using namespace std;
int g_lost[30];
/*void init()
{
    int i;
    for2(30,i)
    {
        g_lost[i]=i+1;
    }
}
void swap1(int a,int b)
{
    int tp;
    tp=g_lost[a-1];
    g_lost[a-1]=g_lost[b-1];
    g_lost[b-1]=tp;
}*/
int main()
{
    int w,n,i,tp;
    cin>>w>>n;
    int data[w];
    for2(w,i)
    {
        data[i]=i+1;
    }
    while(n--)
    {
        int a,b;
        scanf("%d,%d", &a, &b);
        tp=data[a-1];
        data[a-1]=data[b-1];
        data[b-1]=tp;
    }
    for2(w,i)
    {
        cout<<data[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>
#include <functional>
#include <sstream>

using namespace std;

#define ERROR_ID		0

#define PROCESS_ERROR(Condition)    \
{                                   \
		if (!(Condition))           \
		{                           \
			goto Exit0;             \
		}                           \
}

typedef unsigned char       BYTE;
typedef int                 BOOL;
typedef unsigned long       DWORD;
typedef long long			LLONG;

int main(int argc, char* argv[])
{
	int					nNumberCount;
	int					nNumber;
	deque<int>			dqNumberQueue;

	cin >> nNumberCount;

	for (int i = 1; i <= nNumberCount; i++)
	{
		cin >> nNumber;
		if (i % 2 == 1)
		{
			dqNumberQueue.push_front(nNumber);
		}
		else
		{
			dqNumberQueue.push_back(nNumber);
		}
	}

	if (nNumberCount % 2 == 0)
	{
		reverse(dqNumberQueue.begin(), dqNumberQueue.end());
	}

	while (!dqNumberQueue.empty())
	{
		cout << dqNumberQueue.front() << " ";
		dqNumberQueue.pop_front();
	}
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>

using namespace std;

int main()
{
    int n;
    char x;
    int y;
    bool cards[4][13];
    
    for(int i = 0; i < 4; i++)
    {
        for(int j = 0; j < 13; j++)
        {
            cards[i][j] = false;
        }
    }
    
    cin >> n;
    
    for(int i = 0; i < n; i++)
    {
        cin >> x >> y;
        
        if(x == 'S')
        {
            cards[0][y - 1] = true;
        }
        else if(x == 'H')
        {
            cards[1][y - 1] = true;
        }
        else if(x =='C')
        {
            cards[2][y - 1] = true;
        }
        else if(x == 'D')
        {
            cards[3][y - 1] = true;
        }
        else
        {
            break;
        }
    }

    
    for(int i = 0; i < 4; i++)
    {
        for(int j = 0; j < 13; j++)
        {
            if(cards[i][j] == false)
            {
                if(i == 0)
                {
                    cout << 'S' << " " << j + 1 << endl;
                }
                else if(i == 1)
                {
                    cout << 'H' << " " << j + 1 << endl;
                }
                else if(i == 2)
                {
                    cout << 'C' << " " << j + 1 << endl;
                }
                else if(i == 3)
                {
                    cout << 'D' << " " << j + 1 << endl;
                }
                else
                {
                    break;
                }
            }
        }
    }
    
    
    
   return 0;
}


Measured memory_bytes: 3084
#include <stdio.h>
#define min(a, b) ((a) < (b) ? (a) : (b))

#ifdef ONLINE_JUDGE
static char _in_buf[100000], *_in_p1 = _in_buf, *_in_p2 = _in_buf;
#define getchar() (_in_p1 == _in_p2 && (_in_p2 = (_in_p1 = _in_buf) + fread(_in_buf, 1, 100000, stdin), _in_p1 == _in_p2) ? EOF : *_in_p1 ++)
#endif
#ifdef __cplusplus
extern "C" {
#endif
__attribute__((always_inline)) __inline__
void read(int *now) {
  int f = *now = 0; register char c = getchar();
  while ((c > 57 || c < 48) && ~c && c != '-') c = getchar();
  (c == '-') && ((f = 1), c = getchar());
  for (; c > 47 && c < 58; *now = (*now << 3) + (*now << 1) + c - '0', c = getchar());
  f && (*now = -*now);
}
#ifdef __cplusplus
}
#endif

#define N 262144
#define inf 0x3f3f3f3f

int n, x, y, l, r, p[N];
int tr[N << 1 | 5], tr1[N << 1 | 5], tr2[N << 1 | 5];
#define build(tr) for (i = N; -- i; ) \
                   tr[i] = min(tr[i << 1], tr[i << 1 | 1])
#ifdef __cplusplus
extern "C" {
#endif
__attribute__((always_inline)) __inline__
int query(int *t, int l, int r) {
  int res = inf; l += N - 1, r += N + 1;
  for (; l ^ r ^ 1; l >>= 1, r >>= 1)
    (~l & 1) && (res = min(res, t[l + 1])), 
    (r & 1) && (res = min(res, t[r - 1]));
  return res;
}
#ifdef __cplusplus
}
#endif

struct node {
  int a, b, c, d;
} tp, q[N];
int sz = 0;
#ifdef __cplusplus
extern "C" {
#endif
__attribute__((always_inline)) __inline__
int cmp(struct node a, struct node b) {
  if (a.a ^ b.a) return a.a - b.a;
  if (a.b ^ b.b) return a.b - b.b;
  if (a.c ^ b.c) return a.c - b.c;
  return a.d - b.d;
}
__attribute__((always_inline)) __inline__
void swap(struct node *a, struct node *b) { struct node c = *a; *a = *b; *b = c; }
__attribute__((always_inline)) __inline__
void heap_push(struct node x) {
  q[++ sz] = x;
  for (int i = sz, j = i >> 1; j; i = j, j >>= 1)
    if (cmp(q[j], q[i]) > 0) swap(q + i, q + j);
}
__attribute__((always_inline)) __inline__
void heap_pop() {
  q[1] = q[sz --];
  for (int i = 1, j = i << 1; j <= sz; i = j, j <<= 1) {
    ((j | 1) <= sz && cmp(q[j | 1], q[j]) < 0) && (j |= 1);
    if (cmp(q[i], q[j]) > 0) swap(q + i, q + j);
    else break;
  }
}
__attribute__((always_inline)) __inline__
void push(int l, int r) {
  if (l > r) return; int x = query(l & 1 ? tr1 : tr2, l, r);
  heap_push((struct node){x, query(l & 1 ? tr2 : tr1, p[x] + 1, r), l, r});
}
#ifdef __cplusplus
}
#endif

int main() {
  register int i;
  for (read(&n), i = 1; i <= n; ++ i)
    read(&x), p[x] = i, tr[i + N] = x, 
    tr1[i + N] = i & 1 ? x : inf, tr2[i + N] = i & 1 ? inf : x;
  build(tr); build(tr1); build(tr2);
  for (push(1, n); sz; ) {
    x = q[1].a, y = q[1].b, l = q[1].c, r = q[1].d;
    printf("%d %d ", x, y), heap_pop();
    push(l, p[x] - 1), push(p[x] + 1, p[y] - 1), push(p[y] + 1, r);
  }
  putchar('\n');
}

Measured memory_bytes: 10112
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

int solve(int, int, int);

int main()
{
	int T=1, D, L;
	int anser[40] = { 0 };
	int count = 0;

	for (int i = 0; T != 0; i++) {

		scanf("%d %d %d", &T, &D, &L);

		if (T != 0) {
			anser[i]=solve(T, D, L);
		}
		count++;
	}

	for (int i = 0; i < count-1; i++) {
		cout << anser[i] << endl;
	}
	
	return 0;
}

int solve(int T, int D, int L)
{
	int x[100000] = { 0 };
	int anser=0;
	int wet = 0;

	for (int i = 0; i < T; i++) {
		scanf("%d", &x[i]);
	}

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

		if (wet > 0) {
			wet--;
			anser++;
		}

		if (x[i] >= L) {
			wet = D;
		}

	}

	return anser;
}


Measured memory_bytes: 3612
//   <<In The Name Of God>>
// PTD
/*
ID: alimora2
LANG: C++11
TASK: PROB
*/
#include <bits/stdc++.h>

#define sqr(A) (A) * (A)
using namespace std;
typedef long long ll;

const int mod = 1e9 + 7;
map<ll, ll> dp;

ll ans(ll n) {
	if (dp.find(n) != dp.end())
		return dp[n];
	dp[n] =  ans(n / 2) + ans((n - 1) / 2) + ans(n / 2 - 1);
	dp[n] %= mod;
	return dp[n];
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	dp[0] = 1, dp[1] = 2;
	ll n;
	cin >> n;
	cout << ans(n) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;



int main()
{
	//ifstream cin("input.txt");
	ll n,k;
	cin>>n>>k;
	vi h(n);

	rep(i,0,n-1)
		cin>>h[i];
	
	sort(h.begin(), h.end());
	ll min_k = INT_MAX;
	rep(i, k - 1, n-1)
		min_k = min(min_k, h[i] - h[i - k + 1]);
	
	cout<<min_k;

}


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

int main(){
	int n, x, l[100], sum=0, i=1;
  	cin >> n >> x;
  	while(sum <= x && i <= n){
    	cin >> l[i];
      	sum += l[i];
      	if(sum <= x) i++;
      	else {
        	cout << i;
        	return 0;
        }
    }
	cout << i;
  	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using GraphI = vector<vector<int>>;
using GraphC = vector<vector<char>>;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);

  ll straight = min(k, x / d);
  k -= straight;
  x -= straight * d;
  if (k % 2 == 0)
    cout << x << endl;
  else
    cout << d - x << endl;

  return 0;
}


Measured memory_bytes: 3608