akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

long long min(long long a, long long b) {return a < b ? a : b;}
long long min(int a, long long b) {return a < b ? a : b;}
long long min(long long a, int b) {return a < b ? a : b;}
long long min(int a, int b) {return a < b ? a : b;}

long long max(long long a, long long b) {return a > b ? a : b;}
long long max(int a, long long b) {return a > b ? a : b;}
long long max(long long a, int b) {return a > b ? a : b;}
long long max(int a, int b) {return a > b ? a : b;}

#define int long long

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const long long INF = 1e18;
const int N = 2101;
const int MOD = 998244353;
const double eps = 1e-8;

ll n, k;
ll a[N][N];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    k = 38;
    n = k * (k - 1) + 1;
    int c = 1;
    for (int i = 0; i < k; i++)
    {
        a[i][0] = 1;
        for (int j = c; j < c + k - 1; j++)
        {
            a[i][j] = 1;
        }
        c = c + k - 1;
    }
    int r = k;
    for (int j = 1; j < k; j++)
    {
        int d = j - 1;
        for (int e = k; e < 2 * k - 1; e++)
        {
            a[r][j] = 1;
            int sigmum = e - k;
            for (int L = k, R = k + k - 1; R <= n; L += k - 1, R += k - 1)
            {
                a[r][L + sigmum] = 1;
                sigmum = (sigmum + d) % (k - 1);
            }
            r++;
        }
    }
    /*for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }*/
    cout << n << " " << k << "\n";
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (a[i][j] == 1)
            {
                cout << j + 1 << " ";
            }
        }
        cout << "\n";
    }
}


Measured memory_bytes: 24576
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>
#include <numeric>

using namespace std;

const int MOD = 1e9+7;
long long int fact[100001];
void init(void)
{
	fact[0] = 1;
	for (int i = 1; i < 100001; i++)
	{
		fact[i] = ((fact[i - 1] * i)%MOD);
	}
}
int main(void)
{
	int a, b;

	init();

	cin >> a >> b;

	if (abs(a - b) >= 2)
	{
		cout << '0' << endl;
	}
	else
	{
		long long int res = 0;
		if (a == b)
		{
			res = (fact[a] * fact[a]);
			res %= MOD;
			res = (res * 2);
			res %= MOD;
		}
		else
		{
			res = (fact[a] * fact[b]);
			res %= MOD;
		}
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = 1e18;
    for(int i = 1; i*i <= n; ++i){
        if(n%i == 0){
            int a = i,b = n/i;
            ans = min(ans,(a + b - 2));
        }
    }    
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
int somaDigito (int N) {
    int soma = 0;
    while (N != 0) {
        soma += N % 10;
        N /= 10;
    }
    return soma;
}

int main()
{
  int N;
  
  std::cin >> N;

  if(N%somaDigito(N)==0){
    std::cout << "Yes" <<std::endl;
  }else{
    std::cout << "No" <<std::endl;
  }
    
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in= new Scanner(System.in);
		while(in.hasNext())
		{
			char[] c1=in.next().toCharArray();
			if(c1[0]=='0')
				return;
			char[] c2=in.next().toCharArray();
			char[] c3=in.next().toCharArray();

			if(c1[0]=='b'&&c1[1]=='b'&&c1[2]=='b'||c2[0]=='b'&&c2[1]=='b'&&c2[2]=='b'||c3[0]=='b'&&c3[1]=='b'&&c3[2]=='b'
					||c1[0]=='b'&&c2[0]=='b'&&c3[0]=='b'||c1[1]=='b'&&c2[1]=='b'&&c3[1]=='b'||c1[2]=='b'&&c2[2]=='b'&&c3[2]=='b'
					||c1[0]=='b'&&c2[1]=='b'&&c3[2]=='b'||c1[2]=='b'&&c2[1]=='b'&&c3[0]=='b')
				System.out.println("b");
			else if(c1[0]=='w'&&c1[1]=='w'&&c1[2]=='w'||c2[0]=='w'&&c2[1]=='w'&&c2[2]=='w'||c3[0]=='w'&&c3[1]=='w'&&c3[2]=='w'
					||c1[0]=='w'&&c2[0]=='w'&&c3[0]=='w'||c1[1]=='w'&&c2[1]=='w'&&c3[1]=='w'||c1[2]=='w'&&c2[2]=='w'&&c3[2]=='w'
					||c1[0]=='w'&&c2[1]=='w'&&c3[2]=='w'||c1[2]=='w'&&c2[1]=='w'&&c3[0]=='w')
				System.out.println("w");
			else System.out.println("NA");
		}
	}
}

Measured memory_bytes: 12000
import java.util.*;

class Main {
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      long[] A = new long[N+2];
      long[] B = new long[N+1];

      long cnt = 0;
      long wk = 0;
      long wk2 = 0;
      for(int i=0;i<N+1;i++) {
          A[i] = sc.nextInt();
      }
      for(int i=0;i<N;i++) {
          B[i] = sc.nextInt();
      }
      
      for(int i=0;i<N;i++) {
   	   wk = B[i] - A[i];
   	   if(wk<=0) {
   		   cnt = cnt + B[i];
   	   } else {
   		   cnt = cnt + A[i];
   		   wk2 = A[i+1] - wk;
   		   if(wk2<=0) {
   			   cnt = cnt + A[i+1];
   			   A[i+1] = 0;
   		   } else {
   			   A[i+1] = wk2;
   			   cnt = cnt + wk;
   		   }
   	   }
   	   
   	   
   	   
   	   
      }
      System.out.print(cnt);

  }
}

Measured memory_bytes: 91840
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    s=readline().strip()
    K=int(readline())

    N=len(s)
    words=[]
    for i in range(N):
        words.append(s[i])
    for i in range(N-1):
        words.append(s[i:i+2])
    for i in range(N-2):
        words.append(s[i:i+3])
    for i in range(N-3):
        words.append(s[i:i+4])
    for i in range(N-4):
        words.append(s[i:i+5])
    words=set(words)
    words=list(words)
    words.sort()
    print(words[K-1])
    
if __name__=="__main__":
    main()

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

using namespace std;
int main()
{
  int n, l;
  cin >> n >> l;
  vector <string> s(n);
  for(int i = 0; i <n; i++) cin >> s[i];
  sort(s.begin(),s.end());
  for(int i = 0; i <n; i++) cout << s[i];
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (N % 2 == 0) {
		cout << N / 2 << endl;
	}
	else {
		cout << N / 2 + 1 << endl;
	}




}


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

#define pb push_back
using namespace std;
 
int main()
{
 

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

 	
 	
    long n;
    cin>>n;
    long long sum=0;

    long a=n/15;
    long b=n%15;

    sum+=8*15*a*(a-1);
    sum/=2;
    //cout<<sum<<endl;
    sum+=60*a;
    //sum*=60;
   // sum+=()*15*b;
   // cout<<sum<<endl;
    for(int i=1;b and i<15;i++)
    {
        if(i%3 and i%5)
        {
            sum=sum+(a*15)+i;
        }
        b--;
    }

    cout<<sum;




	return 0;
}

Measured memory_bytes: 3636
def main():
    MOD = 10 ** 9 + 7

    s = input()
    r = [0] * 13
    r[0] = 1
    p = 1
    for c in reversed(s):
        if c == '?':
            tank = []
            for x in range(10):
                x = x * p % 13
                tank.append(r[13 - x:] + r[:13 - x])
            r = map(sum, zip(*tank))
            *r, = map(lambda x: x % MOD, r)


        else:
            x = int(c)
            x = x * p % 13
            r = r[13 - x:] + r[:13 - x]
        p = p * 10 % 13

    print(r[5])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

mini = float('inf')
ans = 0

for i in range(n):
    temp = t - h[i]*0.006
    diff = abs(a-temp)
    if diff < mini:
        mini = diff
        ans = i+1

print(ans)

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

void solve(long long K, std::string S){
    if(S.size()<=K)cout<< S <<endl;
    else{
        rep(i,K)cout<< S.at(i);
        cout<< "..." <<endl;
    }
}

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


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

int root(int x,int *array){
    if(x==array[x]){
        return x;
    }else{
        return root(array[x],array);
    }
}

bool same(int x,int y,int *array){
    return root(array[x],array)==root(array[y],array);
}

void Unit(int x,int y,int *array,int *size){
    x=root(x,array);
    y=root(y,array);
    if(x!=y){
        if(size[x]>size[y]){
            array[y]=x;
            size[x]+=size[y];
            size[y]=size[x];
        }else if(size[x]<=size[y]){
            array[x]=y;
            size[y]+=size[x];
            size[x]=size[y];
        }
    }
}


int main(){
    int N,M,K;
    cin >> N >>M>>K;
    int array[N+1];
    int size[N+1];
    int fr[N+1];
    int br[N+1];
    for(int i=1;i<N+1;i++){
        array[i]=i;
        size[i]=1;
        fr[i]=0;
        br[i]=0;
    }

    for(int i=0;i<M;i++){
        int a,b;
        cin >> a>>b;
        Unit(a,b,array,size);
        fr[a]++;
        fr[b]++;
    }

    for(int i=0;i<K;i++){
        int a,b;
        cin >> a>>b;
        if(same(a,b,array)){
            br[a]++;br[b]++;
        }
    }

    for(int i=1;i<N+1;i++){
        cout << size[root(i,array)]-fr[i]-br[i]-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 2432
var x = require('fs').readFileSync('/dev/stdin', 'utf8');
a = x.split(' ');
m = parseInt(a[0]);
n = parseInt(a[1]);
if(m > n){
    console.log('a > b');
}
else if(m < n){
    console.log('a < b');
}
else if(m === n){
    console.log('a == b');
}


Measured memory_bytes: 15096
#include<iostream>
using namespace std;
#define MAX 500010
int prime[MAX];
int sump[MAX];
int main()
{
    prime[0]=1;
    prime[1]=1;
    for(int i=0;i<MAX;i++)
    {
        if(prime[i]==0)
        for(int j=2;j<MAX;j++)
        {
            if( i*j>MAX) break;
            prime[i*j] = 1;
        }
    }
    int num=1;
    for(int i=0;i<MAX;i++)
    {
        if(prime[i]==0)
        {
            if(num==10001)break;
            sump[num] = sump[num-1] + i;
            num++;
        }
    }
    int n;
    while(cin >> n)
    {
        if(n==0)break;
        cout << sump[n] << endl;
    }

    return 0;

}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#define pb pusuh_back
#define mp make_pair
using namespace std;
const int N=1e5+5;

int n;
int a[N],b[N],c[N];

long long dp_b[N],dp_c[N];

long long ans;

int main()
{
   int i;
   int last;
   int low,high,mid;

   scanf("%d", &n);
   for(i=1;i<=n;i++)
   {
       scanf("%d", &a[i]);
   }
   for(i=1;i<=n;i++)
   {
       scanf("%d", &b[i]);
   }
   for(i=1;i<=n;i++)
   {
       scanf("%d", &c[i]);
   }

   sort(a+1,a+n+1);
   sort(b+1,b+n+1);
   sort(c+1,c+n+1);


   for(i=1;i<=n;i++)
   {
      last=0;
      low=1;
      high=n;

      while(low<=high)
      {
          mid=(low + high)/2;

          if(b[i] > a[mid])
          {
              last=mid;
              low=mid+1;
          }
          else
          {
              high=mid-1;
          }
      }

      dp_b[i]=last;
   }

   for(i=1;i<=n;i++)
   {
       dp_b[i]+=dp_b[i-1];
   }


   for(i=1;i<=n;i++)
   {
      last=0;
      low=1;
      high=n;

      while(low<=high)
      {
          mid=(low + high)/2;

          if(c[i] > b[mid])
          {
              last=mid;
              low=mid+1;
          }
          else
          {
              high=mid-1;
          }
      }

      dp_c[i]=dp_b[last];
   }

   for(i=1;i<=n;i++)
   {
       ans+=dp_c[i];
   }

   printf("%lld\n", ans);

   return 0;
}

Measured memory_bytes: 3072
n = input().split(" ")
input = input().split(" ")
dist = []

for i in range(0, int(n[1]) - 1):
    dist.append(int(input[i + 1]) - int(input[i]))

dist.sort()
dist.reverse()

if dist[0] >= int(input[0]) + (int(n[0]) - int(input[int(n[1]) - 1])):
    print(int(n[0]) - dist[0])
else:
    print(int(input[int(n[1]) - 1]) - int(input[0]))

Measured memory_bytes: 20148
h, w = [ int(v) for v in input().split() ]
cost_list = [ [ int(v) for v in input().split() ] for i in range(10) ]


for k in range(10):
    for i in range(10):
        for j in range(10):
            cost_list[i][j] = min( cost_list[i][j], cost_list[i][k] + cost_list[k][j] )

ans = 0

for i in range(h):
    line = [ int(v) for v in input().split() ]
    for j in line:
        if j not in [1,-1]:
            ans += cost_list[j][1]

print(ans)

Measured memory_bytes: 41580
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

using namespace std;
typedef long long ll;

#define f first
#define s second

string s;
int n;
int main()
{
  ios_base::sync_with_stdio(false);
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i < n - 2; i++) {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
    ans++;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n,m,z) = readLine()!!.split(" ").map { it.toInt() }
    val lr = (1..m).map { readLine()!!.split(" ").map { it.toInt() } }
    val pq = (1..z).map { readLine()!!.split(" ").map { it.toInt() } }

    val train = Array(n+1){ IntArray(n+1) }
    lr.forEach { train[it[0]][it[1]]++ }
    for (i in 1..n)for(j in 2..n) train[i][j]+=train[i][j-1]
    for (i in 2..n)for(j in 1..n) train[i][j]+=train[i-1][j]

    val ans = pq.map {
        val (p,q) = it
        train[q][q]-train[p-1][q]-train[q][p-1]+train[p-1][p-1]
    }.joinToString("\n")

    println(ans)
}

Measured memory_bytes: 99344
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var _s = cin.Read;
            var s = _s.ToCharArray();
            var ans = s[0] + (s.Length - 2).ToString() + s[s.Length - 1];
            WriteLine(ans);
        }

        /*public long C(long n, long r)
        {
            if (r == 0 || r == n) return 1L;
            if (n < r) return 0L;
            long[,] Pascal = new long[n + 1, n + 1];
            Pascal[0, 0] = 1;
            for (long i = 1; i <= n; i++)
            {
                Pascal[i, 0] = 1;
                Pascal[i, i] = 1;
                for (long j = 1; j < n; j++)
                {
                    Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
                }
            }
            return Pascal[n, r];
        }*/

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n,k,c; cin>>n>>k>>c;
	string s; cin>>s;
	int L[k],R[k];
	int st=0,id=0; 
	while(st<n && id<k)
	{
	    if(s[st]=='x'){ st++; continue; }
	    L[id]=st; id++;
	    st += (c+1);
	}
	int en=n-1,id1=k-1;
	while(en>=0 && id1>=0)
	{
	    if(s[en]=='x'){ en--; continue; }
	    R[id1]=en; id1--;
	    en -= (c+1);
	}
	vector <int> v;
	for(int i=0;i<k;i++)
	{
	    if(L[i]==R[i]) v.pb(L[i]);
	}
	//for(int i=0;i<k;i++) cout<<L[i]<<' '<<R[i]<<'\n';
	if(!v.empty())
	{
	    //cout<<v.size()<<'\n';
	    for(auto it:v) cout<<it+1<<'\n';
	}
	
	return 0;
}


Measured memory_bytes: 4236
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	ll K;
	scan(K);
	ll now=0;
	rep1(i,K+1){
		now=(now*10+7)%K;
		if(now==0){
			prin(i);
			return 0;
		}
	}
	prin(-1);
	return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int n;
string s[10004];
int d[3],ans=0;
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>s[i];
		for (int j=0;j<s[i].size()-1;j++)
			if (s[i].substr(j,2)=="AB")
				ans++; 
		if (s[i][0]=='B' && s[i][s[i].size()-1]=='A') d[0]++;
		else if (s[i][0]=='B') d[1]++;
		else if (s[i][s[i].size()-1]=='A') d[2]++;
	}
	if (d[0]){
		ans+=d[0]-1;
		if (d[1]) ans++,d[1]--;
		if (d[2]) ans++,d[2]--;
		ans+=min(d[1],d[2]);
	}
	else if (d[1] && d[2])ans+=min(d[1],d[2]);
	cout<<ans;
}

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

int main() {
  string S;
  cin >> S;
  int ans = 700;
  for(int i = 0; i < S.size(); ++i) {
    if(S[i] == 'o') {
      ans += 100;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  int m = n;
  int a = 0;
  while(m > 0) {
    m /= 10;
    a++;
  }
  if(a == 1) cout << n << endl;
  if(a == 2) cout << 9 << endl;
  if(a == 3) cout << 9 + n - 99 << endl;
  if(a == 4) cout << 909 << endl;
  if(a == 5) cout << 909 + n - 9999 << endl;
  if(a == 6) cout << 90909 << endl;
}


Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    if(x-r >= 0 && y-r>=0 && x+r <=w && y+r<=h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3116
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int money = Integer.parseInt(sc.nextLine());
        int a = Integer.parseInt(sc.nextLine());
        int b = Integer.parseInt(sc.nextLine());
        money -= a;
        while(money >= b){
            money -= b;
        }
        System.out.println(money);
    }
}


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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		pr.printf("ABC%d\n", n);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
def binary_search(key):
    '''
    条件を満たす最小のindexを求める
    '''
    right = 10 ** 9 + 1
    left = 0
    while right - left > 1:
        mid = (right + left) // 2

        cnt = 0
        for v in a:
            cnt += (v + mid - 1) // mid - 1

        if cnt <= key:
            right = mid
        else:
            left = mid
    
    return right


n, k = map(int, input().split())
a = list(map(int, input().split()))

print(binary_search(k))

Measured memory_bytes: 104268
#n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
from collections import deque
# n = int(input())# ノードの数
n, m = map(int, input().split())

# 隣接リストで格納する
adjl = [[] for _ in range(n+1)]
for i in range(m):  # 隣接関係を受け取る
    a, b = map(int, input().split())
    adjl[a].append(b)
    adjl[b].append(a)

NIL = -1  # 未発見を示す値
d = [-1 for i in range(n+1)]  # 頂点1からの距離を格納するリスト
color = [NIL for i in range(n+1)]  # 未到達かを示すリスト


def bfs(start_node, color_id):  # start_nodeは探索の開始点
    global color, d
    q = deque([start_node])
    d[start_node] = 0
    color[start_node] = color_id
    while len(q) != 0:
        u = q.popleft()
        for v in adjl[u]:
            if color[v] == NIL:
                d[v] = d[u]+1
                color[v] = color_id
                q.append(v)


color_id = 0
for u in range(1, n+1):  # node全てからスタートする
    if color[u] == NIL:
        color_id += 1
        bfs(u, color_id)

colordic = {}
for u in range(1, n+1):
    colordic[color[u]] = True

print(len(colordic)-1)


Measured memory_bytes: 28840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

struct Edge{
    int to, id;
    Edge(int to,int id): to(to), id(id){}
};

vector<Edge> g[55];

vector<int> es;

bool dfs(int v, int tv, int p){
    if(v == tv){
        es = vector<int>();
        return true;
    }

    for(auto e : g[v]){
        if(e.to == p) continue;
        if(dfs(e.to, tv, v)){
            es.eb(e.id);
            return true;
        }
    }
    return false;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    REP(i,N-1){
        int a,b; cin >> a >> b;
        a--; b--;
        g[a].eb(b,i);
        g[b].eb(a,i);
    }
    int M; cin >> M;
    vector<LL> eset(M);
    REP(i,M){
        int u,v; cin >> u >> v;
        u--; v--;
        dfs(u,v,-1);
        for(auto e : es){
            eset[i] |= (1LL << e);
        }
    }

    LL ans = 0;
    REP(i, 1LL << M){
        LL mask = 0;
        REP(j,M){
            if(i >> j & 1){
                mask |= eset[j];
            }
        }
        int white = __builtin_popcountll(mask);
        LL now = 1LL << (N-1-white);
        if(__builtin_popcountll(i)%2 == 0) ans += now;
        else ans -= now;

        dump(i)
        dump(now)
        dump(ans)
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
let split str =
  let rec split_inner ct b=
    if String.length str = ct then [int_of_string b]
    else
      match str.[ct] with
        ' ' -> (int_of_string b)::split_inner (ct+1) ""
      | c -> split_inner (ct+1) (b^(Char.escaped c))
  in split_inner 0 "";;

let () =
  let f x y =
    let matrix_multi m2 m1 =
      List.fold_left (fun p q -> (List.fold_left2 (fun a b1 c1 -> a + b1 * c1) 0 q m2)::p) [] m1
      |> List.rev and
        read_list u = read_line u |> String.trim |> split and
        read_int2 u = read_line u |> String.trim |> int_of_string in
    let rec read fin i =
      let line = fin () in
      if i <= 0 then [line] else line::read fin (i-1)in
    let result = matrix_multi (read read_int2 (y-1)) (read read_list (x-1))
    in List.iter (fun e-> string_of_int e |> print_endline) result
  in match read_line () |> String.trim |> split with
       [a;b] ->f a b
     | _ -> ();;

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

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) cin >> v[i];

  set<int> st;
  for (int i : v) st.insert(i);
  cout << st.size() << endl;
}


Measured memory_bytes: 256
//***********************
//Author:kibi11
//Quarantine Days
//***********************

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define fr(i, n) for(int i = 0; i < n; i++)
#define fr1(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,k) for(int i=a;i>=k;i--)
#define same int t;cin>>t;while(t--)
#define check(x) cout << (#x) << " is " << (x) << endl;
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define f first
#define s second
#define XOX
#define pi = 3.14159265358979323846

//////////////////////////////////////////////////////////////////////////
/////////////////DEBUGING ZONE//////////////////////////////

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
///////////////////////////////////////////////////////////////////////////
 
ll powermod(ll base, ll exp, ll mod) {
	ll result = 1;
	while (exp != 0) {
		if ((exp % 2) == 1) {
			result = (result * base) % mod;
		}
		base = (base * base) % mod;
		exp /= 2;
	}
	return result;
}

///////////////////////////////////////////////////////////////////////////
//Fuctions if any:





///////////////////////////////////////////////////////////////////////////
int main() 
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tt = clock();
//ios_base& scientific (ios_base& str);

int k;
cin>>k;
ll count=1;
int val=7%k;
bool found=false;

while(count<=1e7)
{
	if(val==0)
	{
		found=true;
		break;
	}
	count++;
	val=(val*10+7)%k;

}
if(found) cout<<count<<endl;
else
	cout<<"-1"<<endl;



cerr << "TIME = " << (double) 1.0 * (clock() - tt) / CLOCKS_PER_SEC << " seconds" << endl;
return 0;
}

Measured memory_bytes: 3836
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int n;
vector<pair<int,int>> *adj;
int *color,*color_v;//color_vに探索履歴を残す.

void init(){
    cin>>n;
    //例のごとく、index 0は使わない方針で。
    adj = new vector<pair<int,int>>[n+1];
    for(int i=1;i<n;i++){
        int u,v;cin>>u>>v;
        adj[u].push_back(make_pair(v,i));
        adj[v].push_back(make_pair(u,i));
    }
    color = new int[n];for(int i=0;i<n;i++)color[i]=0;
    color_v = new int[n+1];for(int i=0;i<n+1;i++)color_v[i]=0;
    //初期化とても大事....。
}
//必要色数は最大次数と同じ。だからあとは作られた色を割り当てるのみ!!

void solve(){
    int degree_M=0,max_v;
    for(int i=1;i<n+1;i++){
        if(degree_M < adj[i].size()){
            degree_M = adj[i].size();
            max_v = i;
        }
    }
    queue<int> Q;
    Q.push(max_v);
    while(!Q.empty()){
        int target = Q.front();Q.pop();
        color_v[target] = 1;//訪問.
        int NG_colors[degree_M+1]={};
        int now_color=1;

        for(int j=0;j<adj[target].size();j++){
            NG_colors[color[adj[target][j].second]] = 1;
        }

        for(int j=0;j<adj[target].size();j++){
            if(color_v[adj[target][j].first] == 0)Q.push(adj[target][j].first);
            if(color[adj[target][j].second] == 0){
                while(NG_colors[now_color] == 1){
                    now_color++;
                }
                color[adj[target][j].second] = now_color++;
            }
        }
    }
    cout<<degree_M<<endl;
    for(int i=1;i<n;i++){
        cout<<color[i]<<endl;
    }
}

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

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);

int main(){
    int h,w,k,t;cin>>h>>w>>k;
    vector<string>s(h);
    rep(i,h)cin>>s[i];
    int x[h][w];
    int cnt =0;
    rep(i,h)rep(j,w){
        x[i][j]=0;
        if(s[i][j]=='#'){
            cnt++;
            x[i][j]=cnt;
        }
    }
    rep(i,h){
        rep(j,w){
            if(j==0)continue;
            if(x[i][j]==0&&x[i][j-1]!=0){
            x[i][j]=x[i][j-1];
        }
        for(int j=w-2;j>=0;j--){
            if(x[i][j]==0&&x[i][j+1]!=0){
                x[i][j]=x[i][j+1];
            }
        }
        }
    }
    rep(j,w){
        rep(i,h){
            if(i==0)continue;
            if(x[i][j]==0&&x[i-1][j]!=0){
                x[i][j]=x[i-1][j];
        }
        }
        for(int i=h-2;i>=0;i--){
            if(x[i][j]==0&&x[i+1][j]!=0){
                x[i][j]=x[i+1][j];
            }
        }
    }
    rep(i,h)rep(j,w){
        if(j==w-1)cout<<x[i][j]<<endl;
        else
        {
            cout<<x[i][j]<<' ';
        }
    }
}

Measured memory_bytes: 4040
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 998244353;

int n,d[maxn],c[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>d[i];
    c[d[i]]++;
  }
  if(d[1]!=0||c[0]!=1){
    cout<<0<<endl;
    return 0;
  }
  ll ret = 1;
  for(int i=1;i<n;i++){
    if(c[i]){
      if(!c[i-1]){
        cout<<0<<endl;
        return 0;
      }
      for(int j=0;j<c[i];j++)ret=ret*c[i-1]%mod;
    }
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 1024
n,k = map(int,input().split())
x = [0]*k
mod = 10**9+7
def power(a,n):
  ans = 1
  while n:
    if n%2:
      ans = (ans*a)%mod
    a = (a*a)%mod
    n >>= 1
  return ans%mod  
for i in range(k,0,-1):
  c = power(k//i,n)
  j = 2
  while i*j <= k:
    c -= x[i*j-1]
    j += 1
  x[i-1] = c
s = 0
for i in range(1,k+1):
  s = (s + i*x[i-1])%mod
print(s)

  

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

int n, x;
int mi = 1010;
int ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> x;
	ans = n;
	for(int i=0; i<n; ++i){
		int a;
		cin >> a;
		mi = min(mi, a);
		x -= a;
	}
	ans += x / mi;
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    cin>>N;
    vector<pair<ll,ll>> AB(N);
    rep(i,N){
        cin>>AB.at(i).first>>AB.at(i).second;
    }
    vector<ll> A(N),B(N);
    rep(i,N){
        A.at(i)=AB.at(i).first;
        B.at(i)=AB.at(i).second;
    }
    sort(A.begin(),A.end());
    sort(B.rbegin(),B.rend());
    if(N%2==1){
        ll r=A.at((N-1)/2);
        ll l=B.at((N-1)/2);
        cout<<l-r+1<<endl;
        return 0;
    }
    else{
        ll r1=A.at(N/2-1);
        ll r2=A.at(N/2);
        ll l1=B.at(N/2);
        ll l2=B.at(N/2-1);
        cout<<l1+l2-r1-r2+1<<endl;
        return 0;
    }
}

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

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

    int n;
    ll k;
    cin >> n >> k;
    vector<pair<int, int>> inserted;

    for (int i = 0; i < n; ++i) {
        int a, b; cin >> a >> b;
        inserted.push_back(make_pair(a, b));
    }

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

    ll pos = 0;
    for (auto& i : inserted) {
        pos += i.second;
        if (pos >= k) {
            cout << i.first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  //input
  int N; cin>>N; 
  int n=N;
  //compute
  int sum=0;
  while(N>0){
    sum+=N%10;
    N/=10;
  }
  //output
  if(n%sum==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
  



Measured memory_bytes: 256
// フェルマーの小定理
package main

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

const (
	m = 1000000007
)

var (
	fac []int
)

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

func mpow(x int, n int) int {
	result := 1
	for n != 0 {
		if n&1 == 1 {
			result = result * x % m
		}
		x = x * x % m
		n >>= 1
	}
	return result
}

func mcomb(n int, k int) int {
	if n == 0 && k == 0 {
		return 1
	}
	if n < k || k < 0 {
		return 0
	}
	return (fac[n] * mpow(fac[n-k], m-2) % m) * mpow(fac[k], m-2) % m
}

func main() {
	X := readInt()
	Y := readInt()

	if (X+Y)%3 != 0 {
		fmt.Println(0)
		return
	}

	a := (2*Y - X) / 3
	b := (2*X - Y) / 3

	if a < 0 || b < 0 {
		fmt.Println(0)
		return
	}

	n := a + b
	k := min(a, b)

	fac = make([]int, n+1)
	fac[0] = 1
	for i := 0; i < n; i++ {
		fac[i+1] = fac[i] * (i + 1) % m
	}

	fmt.Println(mcomb(n, k))
}

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

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

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 7236
inputa = list(map(int, input().split()))
 
S = inputa[0] * inputa[1] / 2
 
if inputa[0] / 2 == inputa[2]:
  if inputa[1] / 2 == inputa[3]:
    print (S, " 1")
    exit(0)
print (S, " 0")

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(void){
    
    int A, B;
    
    cin >> A >> B;
    
    if(A % 3 != 0 && B % 3 != 0 && (A + B) % 3 != 0) cout << "Impossible" << endl;
    else cout << "Possible" << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

ll absolute(ll n) {
  if (n < 0) {
    n *= (-1);
  }
  return n;
}

int main() {
  ll x, y;
  cin >> x >> y;
  ll ax = absolute(x);
  ll ay = absolute(y);
  if (ax == ay) {
    printf("1\n");
    return 0;
  }
  if (ax < ay) {
    ll ans = ay - ax;
    if (ax != x) {
      ans += 1;
    }
    if (ay != y) {
      ans += 1;
    }
    printf("%lld\n", ans);
    return 0;
  }

  if (ax > ay) {
    ll ans = ax - ay;
    if (ax == x) {
      ans += 1;
    }
    if (y == 0) {
      printf("%lld\n", ans);
      return 0;
    }

    if (ay == y) {
      ans += 1;
    }
    printf("%lld\n", ans);
  }

  return 0;
}


Measured memory_bytes: 888
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n; cin>>n; 
    vi a(n+1);
    for (int i=1;i<=n;i++) cin>>a[i];
    if (n&1){
        for (int i=n;i>0;i-=2) cout << a[i] << " ";
        for (int i=2;i<=n;i+=2) cout << a[i] << " ";
        cout << endl;
    }
    else {
        for (int i=n;i>0;i-=2) cout << a[i] << " ";
        for (int i=1;i<=n;i+=2) cout << a[i] << " ";
        cout << endl;
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4752
n = int(input())
ans=0
a=[0 for i in range(n)]
x=[[0 for i in range(20)]for j in range(20)]
y=[[0 for i in range(20)]for j in range(20)]

for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        x[i][j], y[i][j] = map(int,input().split())
        x[i][j]-=1 # 
        
for bits in range(2**n):
    ok=True
    for i in range(n):
        if (bits>>i)&1 == 0:
            continue
        for j in range(a[i]):
            if y[i][j]^((bits>>x[i][j])&1):
                ok = False
    if ok:
        ans = max(ans,str(bin(bits)).count('1'))

print(ans)

Measured memory_bytes: 42604
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int a, b, k;
    std::cin>>a>>b>>k;

    std::vector<int> v;
    for(int i = 0;i < k;i++){
        if(a + i <= b){
            v.push_back(a + i);
        }
        if(b - i >= a){
            v.push_back(b - i);
        }
    }
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(),v.end()), v.end());

    for(auto i = v.begin();i != v.end();i++){
        std::cout<<*i<<std::endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
vector<ll> divisor(ll x){
	vector<ll> div;
	for(int i=1;i*i<=x;i++){
		if(i*i!=x && x%i==0){
			div.pb(i);
			div.pb(x/i);
		}
		else if(x%i==0) div.pb(i);
	}
	return div;
}
vector<ll> vectorprime(ll x){
	vector<bool> is_prime(x+1);
	vector<ll> prime;
	rep(i,x+1) is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=x;i++){
		if(is_prime[i]){
			prime.pb(i);
		}
		for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
	}
	return prime;
}

//a,b x
int main(){
	ll A,B; cin>>A>>B;
	if(A*B<=0) cout<<"Zero";
	else if(A>0) cout<<"Positive";
	else{
		if((-A+B)%2==0) cout<<"Negative";
		else cout<<"Positive";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, K;
    cin >> H >> W >> K;
    string S[6];
    rep(i, H) cin >> S[i];
    int ans = 0;
    rep(bit1, (1 << H)) {
        rep(bit2, (1 << W)) {
            string R[6];
            rep(i, H) R[i] = S[i];
            int cnt = 0;
            rep(i, H) {
                rep(j, W) {
                    if(bit1 & (1 << i)) R[i][j] = 'r';
                    if(bit2 & (1 << j)) R[i][j] = 'r';
                }
            }
            rep(i, H) {
                rep(j, W) {
                    if(R[i][j] == '#') cnt++;
                }
            }
            
            if(cnt == K) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
typedef long long ll;

int main(void)
{
    //priority_queue<ll, std::vector<ll>, std::greater<ll>> minpq;
    priority_queue<ll> maxpq;

    ll n, m;
    cin >> n >> m;
    REP(i, n)
    {
        ll a;
        cin >> a;
        maxpq.push(a);
    }
    ll ans = 0;
    while (m > 0)
    {
        ll top = maxpq.top();
        maxpq.pop();
        top /= 2;
        maxpq.push(top);
        m--;
    }
    while (maxpq.size() > 0)
    {
        ll top = maxpq.top();
        maxpq.pop();
        ans += top;
    }
    cout << ans << endl;
    //sort(v.begin(), v.end(), std::greater<ll>());
}

Measured memory_bytes: 1400
#include<iostream>
using namespace std;;
int main(){
int a;
  cin >>a;
  int b,c,d,e;
  b=a%10;
  a=a/10;
  c=a%10;
  a=a/10;
  d=a%10;
  a=a/10;
  e=a;
  int flag=0;
 
  if((b==c&&c==d)||(d==e&&d==c)){
  cout <<"Yes"<<endl;
  }
  else{
  cout <<"No"<<endl;
  }
return 0;
}

Measured memory_bytes: 256