akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long mod=1000000007;
  long long N,b,ans;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){cin >> A[i];}
  sort(A.begin(),A.end());
  int a=0; 
  if(N%2==0){
    for(int i=0;i<N;i++){
      b=A[i];  if(i%2==0){b--;}
      if(b!=i){a=1;}
    }
    if(a==1){cout << 0 << endl;}
    else{
      ans=1;
      for(int i=0;i<N/2;i++){ans*=2; ans=ans%mod;}
      cout << ans << endl;}
  }
  else{
    if(A[0]!=0){a=1;}
    for(int i=1;i<N;i++){
      b=A[i]; if(i%2==1){b--;}
      if(b!=i){a=1;}
    }
    if(a==1){cout << 0 << endl;}
    else{
      ans=1;
      for(int i=0;i<(N-1)/2;i++){ans*=2; ans=ans%mod;}
      cout << ans << endl;}
  }
}

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

struct elm {
  int v, c;
};

int main () {
  int n;
  cin >> n;
  vector<elm> a(1e5+1), b(1e5+1);
  rep(i,1e5+1) {
    a[i] = elm{i,0};
    b[i] = elm{i,0};
  }

  rep(i,n/2) {
    int x, y;
    cin >> x >> y;
    a[x].c++;
    b[y].c++;
  }

  sort(a.begin(), a.end(), [](const elm& l, const elm& r ) {
      return l.c > r.c;
    });
  sort(b.begin(), b.end(), [](const elm& l, const elm& r ) {
      return l.c > r.c;
    });

  if(a[0].v != b[0].v) {
    cout << n - a[0].c - b[0].c << endl;
  } else {
    int ans = 1e5+1;
    ans = min(ans, n - a[0].c - b[1].c);
    ans = min(ans, n - a[1].c - b[0].c);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
//難しい解説ACできず保留
int main() {
  string s;
  cin>>s;
  string t="zyxwvutsrqponmlkjihgfedcba";
  if(s==t){
    cout<<-1<<endl;
    return 0;
  }
  vector<bool> siyou(26,0);
  int n=s.size();
  for(int i=0;i<n;i++){
    int x=s[i]-'a';
    siyou[x]=1;
    //cout<<x<<endl;
  }
  if(s.size()==26){
    string u;
    for(int i=0;i<26;i++){
      if(s[i]=='z'){
        bool hantei=true;
        int irekae;
        for(int j=i+1;j<25;j++){
          if(s[j]< s[j+1]){
            hantei=false;
            irekae=j;
          }
        }
        if(hantei){
          for(int k=i;k<n;k++){
          int x=s[k]-'a';
          siyou[x]=0;
          //cout<<x<<endl;
          }
          u=s.substr(0,i);
          int count=0;
          //cout<<"koko"<<siyou[s[i-1+count]-'a'+1];
          while(siyou[s[i-1+count]-'a'+1]==1){
            count++;
          }
          u[i-1]=(char)(s[i-1]+count+1);
          //cout<<(char)(s[i-1]+count+1)<<" kore "<<i-1;
          cout<<u<<endl;
          return 0;
        }else{
          for(int k=irekae;k<n;k++){
          int x=s[k]-'a';
          siyou[x]=0;
          //cout<<x<<endl;
          }
          u=s.substr(0,irekae+1);
           int count=0;
          //cout<<"koko "<<u[irekae]<<" ";
          while(siyou[u[irekae]+count-'a'+1]==1){
            count++;
            //cout<<"check "<<siyou[u[irekae]+count-'a'+1];
          }
         //cout<<"koko"<<(char)(u[irekae]+count+1);
          u[irekae]=(char)(u[irekae]+count+1);
          cout<<u<<endl;
          return 0;
        }
      }
    }
  }else{
    char c;
    for(int i=0;i<26;i++){
      if(siyou[i]==0){
        c=i+'a';
        break;
      }
    }
    cout<<s<<(char)c<<endl;
    return 0;
  }
  return 0;
}

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

using namespace std;

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define PQ priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define FORD(i, n) for (int (i) = (int)(n) - 1; i>= 0; i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl;
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1 << 30;
const int N = 1005;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

inline ll read()
{
	ll x = 0; int f = 1, c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
	return x * f;
}

string s, t, u; 
map <string, int> mp; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	cin >> s >> t; 
	mp[s] = read(); mp[t] = read(); 
	cin >> u; 
	mp[u]--; 
	printf("%d %d\n", mp[s], mp[t]); 
	
	return 0;
}


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

// #define rep(i,n) for(int i=0;i<(n);i++)
// #define fi first
// #define se second
// #define pb push_back
// #define mp make_pair

using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using pii = pair<int,int>;

template<typename T> ostream& operator<< (ostream& os,const vector<T>& vec){ os << "{"; for(T v:vec) os << v << ","; os << "}"; } template<typename T> ostream& operator<< (ostream& os,const set<T>& st){ os << "{"; for(T v:st) os << v << ","; os << "}"; }
template<typename T,typename U> ostream& operator<< (ostream& os,const pair<T,U>& p){ os << "{" << p.first << "," << p.second << "}"; return os; }

struct Result {
    int num;
    int ac;
    int pen;

    Result() : num(-1), ac(0), pen(0) {}

    bool operator < (const Result& o) const {
        return ac == o.ac ? pen == o.pen ? num > o.num : pen < o.pen : ac > o.ac;
    }
};

int main(){
    int M, T, P, R;
    while (true) {
        cin >> M >> T >> P >> R;
        if (M == 0 && T == 0 && P == 0 && R == 0) break;

        int ac[50][10], wa[50][10], pen[50][10];
        for (int j = 0; j < T; ++j) {
            fill(ac[j], ac[j]+P, 0);
            fill(wa[j], wa[j]+P, 0);
            fill(pen[j], pen[j]+P, -1);
        }

        for (int i = 0; i < R; ++i) {
            int m, t, p, j;
            cin >> m >> t >> p >> j;
            --t; --p;
            if (j == 0 && ac[t][p] == 0) {
                ac[t][p] = 1;
                pen[t][p] = m;
            }
            if (j != 0 == ac[t][p] == 0) {
                wa[t][p]++;
            }
        }

        Result res[50];
        for (int j = 0; j < T; ++j) {
            res[j].num = j+1;
            for (int k = 0; k < P; ++k) {
                if (ac[j][k] == 1) {
                    res[j].ac ++;
                    res[j].pen += wa[j][k] * 20 + pen[j][k];
                }
            }
        }

        sort(res, res+T);
        cout << res[0].num;
        for (int j = 1; j < T; ++j) {
            if (res[j-1].ac == res[j].ac && res[j-1].pen == res[j].pen) {
                cout << "=";
            } else {
                cout << ",";
            }
            cout << res[j].num;
        }
        cout << endl;
    }
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
bool used[9], d[9][9];

void dfs(int p,int c){
    if(c == n) ans++;
    used[p] = true;
    for(int i = 1; i <= n; i++)
        if(!used[i] && d[p][i]) dfs(i,c + 1);
    used[p] = false;
}

int main(){
    cin >> n >> m;
    for(int i = 0, a, b; i < m;i++){
        cin >> a >> b;
        d[a][b] = d[b][a] = true;
    }
    dfs(1,1);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

const int MAX_N = 200000;

ll fact[MAX_N+100];
ll frev[MAX_N+100];

ll rev(ll a, ll p){
    if(p == 0) return 1;
    ll tmp = rev(a, p/2);
    tmp = tmp * tmp % MOD;
    if(p % 2 == 1) tmp = tmp * a % MOD;
    return tmp;
}


void calc_fact(){
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }
}


ll comb(int n, int k){
    if(n < 0 || k < 0 || n < k) return 0;
    if(n == 0 || k == 0) return 1;
    return fact[n] * frev[k] % MOD * frev[n-k] % MOD;
}


int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i,N){
        cin >> A[i];
    }

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

    //in main function
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }

    ll ans = 0;
    REP(i,N){
        ll a = A[i];
        ans += (a * comb(i, K-1)) % MOD;
        ans %= MOD;
        ans += MOD - (a * comb(N-i-1, K-1)) % MOD;
        ans %= MOD;
    }

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


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
vector<string>grid(1002);
ll dp[1002][1002];
	void add(ll &A,ll B)
	{
		A=A+B;
		if(A>MOD)A-=MOD;
	}
int main()
{
	int H,W;cin>>H>>W;
	for(int i=0;i<H;i++)cin>>grid[i];
    for(int i=0;i<W;i++)
    {
    	if(grid[0][i]=='#')break;
    	dp[0][i]=1;
    }
    for(int i=0;i<H;i++)
    {
    	if(grid[i][0]=='#')break;
    	dp[i][0]=1;
    }
    for(int i=1;i<H;i++)
    {
    	for(int j=1;j<W;j++)
    	{
    		if(grid[i][j-1]=='.')add(dp[i][j],dp[i][j-1]);
    		if(grid[i-1][j]=='.')add(dp[i][j],dp[i-1][j]);
    	}
    }
    cout<<dp[H-1][W-1];
	
	
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;cin>>H>>W;
  vector<vector<int>>A(H,vector<int>(W));
  for(int i=0;i<H;i++)for(int j=0;j<W;j++)cin>>A[i][j];
  int x=0,y=0,ex=(H%2==0?0:W-1),ey=H-1;
  vector<string>S;
  while(x!=ex||y!=ey){
    int vx,vy;
    if(x==0&&y%2==1){vx=0;vy=1;}
    else if(x==W-1&&y%2==0){vx=0;vy=1;}
    else if(y%2==0){vx=1;vy=0;}
    else {vx=-1;vy=0;}
    if(A[y][x]%2==1){
      A[y][x]--;A[y+vy][x+vx]++;
      S.push_back(to_string(y+1)+" "+to_string(x+1)+" "+to_string(y+vy+1)+" "+to_string(x+vx+1));
    }
    x+=vx;y+=vy;
  }
  cout<<S.size()<<endl;
  for(int i=0;i<S.size();i++)cout<<S[i]<<endl;
}

Measured memory_bytes: 11892
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define gr vector<vector<pii>>
#define fi first
#define se second
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= (int)1E6; i++)
        if (floor(0.08 * i) == a && floor(0.1 * i) == b)
        {
            cout << i << endl;
            return 0;
        }
    cout << -1 << endl;
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    cin >> n;
    int t_sum = 0, h_sum = 0;
    rep(i, n)
    {
        string a, b;
        cin >> a >> b;
        if (a > b)
        {
            t_sum += 3;
        }
        else if (a < b)
        {
            h_sum += 3;
        }
        else
        {
            t_sum++;
            h_sum++;
        }
    }
    cout << t_sum << " " << h_sum << endl;
    return 0;
}


Measured memory_bytes: 3212
#include <stdio.h>
#include <string.h>
 
  int i,j,k,l,m;
  int n,e,s,w,un,up;
  int a[7];
int t;
 
 
void input() {
 for(i=0;i<6;i++){
   
    scanf("%d",&a[i+1]);
   
  }
}
 
 void N() {
   t = a[1];
   a[1] = a[2];
   a[2] = a[6];
   a[6] = a[5];
   a[5] = t;
 }
 
 void S() {
   t = a[1];
   a[1] = a[5];
   a[5] = a[6];
   a[6] = a[2];
   a[2] = t;
}
 
 void E() {
   t = a[1];
   a[1] = a[4];
   a[4] = a[6];
   a[6] = a[3];
   a[3] = t;
 }
 
 void W() {
   t = a[1];
   a[1] = a[3];
   a[3] = a[6];
   a[6] = a[4];
   a[4] = t;
 }
 
int main() {
 
  input();
  //  strlen(?) 文字の長さ(数)を表示
 char str[110];  
 scanf("%s",str);
 
 for(i=0;i<strlen(str);i++) {
 
   if(str[i] == 'N') {
     N();
   } else if(str[i] == 'S') {
     S();
   } else if(str[i] == 'W') {
     W();
   } else if(str[i] == 'E') {
     E();
   }
 }
 
 printf("%d\n",a[1]);
 
 return 0;
}


Measured memory_bytes: 2144
S = input()
l = [0] * (len(S) + 1)
l[1] = 1
l[2] = 1 if S[0] == S[1] else 2
for i in range(3, len(S)+1):
    if S[i-1] != S[i-2]:l[i] = l[i-1] + 1
    else:l[i] = l[i-3] + 2
print(l[-1])


Measured memory_bytes: 41840
using System;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadIntArray(5);
            int k = cin.ReadInt;

            bool f = (n[4] - n[0] > k);            

            Console.WriteLine((f) ? ":(":"Yay!");
        }
    }

    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; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}



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

int main(void){
    int n, count_max = 0;
    bool flag = true;
    
    cin >> n;
    
    vector<int> a(n);
    vector<vector<int>> x(n, vector<int>(n)), y(n, vector<int>(n));

    rep(i, n){
        cin >> a.at(i);
        rep(j, a.at(i)){
            cin >> x.at(i).at(j) >> y.at(i).at(j);
        }
    }


    for(int bit = 0; bit < (1 << n); ++bit){
        rep(i, n){
            if(!(bit & (1<<i))) continue;
            for(int j = 0; j < a.at(i); ++j){
                if(y.at(i).at(j) == 1){
                    if(!(bit & (1<<(x.at(i).at(j)-1)))){
                        flag = false;
                       break; 
                    }
                } else {
                    if(bit & (1<<(x.at(i).at(j)-1))){
                        flag = false;
                       break; 
                    }
                }
            }
        }
        if(flag){
            if(count_max < __builtin_popcount(bit)){
                count_max = __builtin_popcount(bit);
            }
        }
        flag = true;
    }

    cout << count_max << endl;

    return 0;
}

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

using namespace std;

int main() {
  int n,m;
  cin >> n;
  cin >> m;

  vector<int> as;
  as.assign(n, 0);
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    as[a] = 1;
  }
  
  int step2[n+1];
  step2[0] = 1;
  for (int i = 1; i <= n; i++) {
    int b2 = i >= 2 && as[i-2] == 0 ? step2[i-2] : 0;
    int b1 = as[i-1] == 0 ? step2[i-1] : 0;
    step2[i] = (b1 + b2) % 1000000007;
  }
  
  cout << step2[n] << endl;
  
  return 0;
}

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

#include <cmath>

using std::cin;
using std::cout;
using std::endl;
using std::sqrt;
using std::vector;

int
main()
{
  int N, D;
  cin >> N >> D;
  vector<vector<int>> vv(N);
  for (int n = 0; n < N; n++)
  {
    auto &v = vv[n];
    v.resize(D);
    for (int d = 0; d < D; d++)
    {
      cin >> v[d];
    }
  }
  int count = 0;
  for (int i = 0; i < N - 1; i++)
  {
    auto &vi = vv[i];
    for (int j = i + 1; j < N; j++)
    {
      auto &vj = vv[j];
      int dd = 0;
      for (int d = 0; d < D; d++)
      {
        int diff = vi[d] - vj[d];
        dd += diff * diff;
      }
      double distance = sqrt(double(dd));
      int idsitance = int(distance);
      if (double(idsitance) == distance)
      {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int m = sc.nextInt();
    String[]a = new String[h];
    
    for(int i=0; i<h; i++) {
    	a[i] = sc.next();
    }
    for(int i=0; i<m+1; i++) {
    	System.out.print("#");
    }
    	System.out.println("#");
    for(int i=0; i<h; i++) {
    	System.out.println("#" + a[i] + "#");
    }
    for(int i=0; i<m+2; i++) {
    	System.out.print("#");
    }
}
}

Measured memory_bytes: 39156
#include<bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

typedef long long   ll;
typedef long double ld;
const int N  = 3e5+2;
const int M  = 20;
const ll mod = 1e9+7;
const ll inf = 1e18;
 
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb              push_back
#define mp              make_pair
#define ub              upper_bound                 // first element >  val(itr)
#define lb              lower_bound                 // first element >= val(itr) 
#define all(x)          (x).begin(),(x).end()
#define reset(a,x)      memset(a,x,sizeof(a))       // x can be 0 or -1
#define leadzero(a)     __builtin_clz(a)            // count leading zeroes
#define trailzero(a)    __builtin_ctz(a)            // count trailing zeroes
#define bitcount(a)     __builtin_popcount(a)       // count set bits
#define iceil(n,x)      ((n)+(x)-1)/(x)
#define test            int t; cin>>t; while(t--)
#define forn(i,a,e)     for(ll i = a; i < e; i++)
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;    }
ll powm(ll base,ll exp){ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
ll add(ll a,ll b)  { return (a%mod+b%mod)%mod;        }
ll sub(ll a, ll b) { return (a%mod+mod-b%mod)%mod;    }
ll mult(ll a,ll b) { return ((a%mod)*(b%mod))%mod;    }
ll choose2(ll n)   { ll ans=(n*(n-1))/2; return ans;  }
ll dist2(ll x1,ll y1,ll x2,ll y2){ ll ans=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1); return ans;}

ll h,w;
const int nax=1001;
ll dp[nax][nax];
string s[nax];

bool valid(ll i,ll j)
{
    return (i>=0 && j>=0 && i<h && j<w);
}

ll count(ll i,ll j)
{
    if(!valid(i,j))
        return 0;
    if(i==h-1 && j==w-1)
    {
        dp[i][j]=1;
        return 1;
    }
    
    else if(s[i][j]=='#')
    {
        dp[i][j]=0;
        return 0;
    }
    else if(dp[i][j]!=-1)
        return dp[i][j];
    else
    {
        dp[i][j]=add(count(i,j+1),count(i+1,j));
    }
    return dp[i][j];
}

int main()
{
    fast
    cin>>h>>w;
    forn(i,0,h)
    cin>>s[i];
    reset(dp,-1);
    cout<<count(0,0);
    return 0;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll vis[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

 ll n,m;
 cin>>n>>m;
 if(n%2==1)
 {
     for(int i=1;i<=m;i++)
     {
         cout<<i<<" "<<n<<endl;
         n--;
     }
 }
 else
 {
     ll t=n,f=0;
     for(int i=1;i<=m;i++)
     {
         ll p=i-1+t-n;
         if(p>=n-i-1&&f==0)
         {
                f=1;
                n--;
         }
         cout<<i<<" "<<n<<endl;
         n--;
     }
 }


return 0;
}



Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 202020;
vector<int> g[N];
int a[N];
int v[N];
stack<int> st[N];
int updated[N];
int ans[N];
void dfs (int cur, int par) {
  int p = lower_bound(v, v + N, a[cur]) - v;
  st[p].push(v[p]);
  v[p] = a[cur];
  ans[cur] = lower_bound(v, v + N, 1 << 30) - v;
  for (int child : g[cur]) if (child != par) {
    dfs(child, cur);
  }
  v[p] = st[p].top();
  st[p].pop();
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  fill(v, v + N, 1 << 30);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(0, -1);
  for (int i = 0; i < n; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 167560
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(){
	char s1[16];
	char s2[16];
	char s3[16];

	scanf("%s", s1);
	scanf("%s", s2);
	scanf("%s", s3);

	printf("%c",s1[0]-'a'+'A');
	printf("%c",s2[0]-'a'+'A');
	printf("%c",s3[0]-'a'+'A');
	printf("\n");

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
ll sum=0;

int dfs(int i,ll last,ll sm,int sz,string s){
    if (i==sz-1) {
        //cout<<last<<endl;
        sum+=sm+last;
        return 0;
    }
    //cout<<last<<'i'<<i<<endl;
    dfs(i+1,s[i+1]-'0',sm+last,sz,s);
    dfs(i+1,10*last+s[i+1]-'0',sm,sz,s);
    return 0;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int sz=s.size();
    dfs(0,s[0]-'0',0,sz,s);
    cout<<sum<<endl;
}

//r

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

typedef long long ll;
using pii = pair<int, int>;
template <class T>
using v = vector<T>;
template <class T>
using vv = v<v<T>>;
#define ALL(c) (c).begin(), (c).end()

int main()
{
    double w, h, x, y;
    cin >> w >> h >> x >> y;

    int o = 0;
    if(w/2==x&&h/2==y){
        o = 1;
    }
    cout << (double)w*h/2.0 <<" "<<  o << endl;
    return 0;
}

Measured memory_bytes: 3796
class MatrixLikeComputation
  def execute
    matrix=calculate_matrix_total(gets.to_i)    # 合計データを付加した行列を、全て結合した文字列を返す
  end

  def calculate_matrix_total(n)                 # 縦横のデータ数を受け取って、縦と横の合計のデータを付加した行列を返す
    return "" if n==0                           # n=0のときは、空文字列を結合して終了する
    ans_matrix=""                               # 行列を表す文字列
    rows = n.times.map{gets.split.map(&:to_i)}  # 行ごとの数値を配列に格納
    rows.each do |row|
      ans_matrix += (row << row.sum).map{|i| "%5d" % i}.join + "\n"   # 行ごとの数値と合計値を結合した文字列を作成
    end
    column_sums = n.times.map{|i| rows.inject(0){|column_sum,row| column_sum+row[i]}}   # 列ごとの合計を配列に格納
    # 列ごとの合計値を行列の末尾に追加し、次の行列を結合
    ans_matrix += (column_sums << column_sums.sum).map{|i| "%5d" % i}.join + "\n" + calculate_matrix_total(gets.to_i) 
  end
end

mlc = MatrixLikeComputation.new
puts mlc.execute


Measured memory_bytes: 7080
N, K = map(int, input().split())

a = N // K
b = N % K
ans = a ** 3

for i in range(1, K):
    if (2 * (K - i)) % K == 0:
        if i > b:
            if K - i > b:
                ans += a ** 3
            else:
                ans += a * ((a+1)**2)
        else:
            if K - i > b:
                ans += (a + 1) * (a ** 2)
            else:
                ans += (a + 1) ** 3

print(ans)


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

int main(){
    ll X,K,D; cin>>X>>K>>D;
    ll now=abs(X);
    ll num=min(K,now/D);
    K-=num;
    now-=num*D;

    if(K%2==0){
        cout<<now<<endl;
    }else{
        cout<<D-now<<endl;
    }
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cmath>
#include <math.h>
#include <ctime>
#include <cstring>
#include <climits>
#include <sstream>
#include <array>
#include <tuple>
#include <set>
#include <iterator>
#include <cstdio>
#include <string>
#include <stack>
#include <valarray>
#include <utility>
#include <iomanip>
#include <list>
#include <numeric>
#include <regex>
#include <map>
#include <queue>
#include <deque>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define PI          3.1415926535
#define pb          push_back
#define ins         insert
#define INF         LLONG_MAX
#define mk          make_pair
#define lb(v,x)     lower_bound(all(v),x)
#define ub(v,x)     upper_bound(all(v),x)
#define ff          first
#define ss          second
#define rev         reverse
#define uset        unordered_set
#define umap        unordered_map
#define endl        "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a)       (ll)a.size()
#define double      long double
#define minpq       priority_queue <ll,vector<ll>,greater<ll> > 
#define fill(x,y)   memset(x,y,sizeof(x))
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define MOD         1000000007 //1e9+7
#define bp(n)       __builtin_popcountll(n)
#define mxt(a)      *(max_element(a.begin(),a.end()))
#define mnt(a)      *(min_element(a.begin(),a.end())
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i, a, b) for(ll i = (a); i<= (b); ++i)
#define trav(a, x) 	 for(auto &a : x)
#define re(i,n)      for(ll i = 0; i < n; ++i) 
const ll N = 2e5 + 7;
typedef pair<ll,ll>   pii;
typedef vector<pii>   vpii;
typedef vector<ll>    vll;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
template<typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template<typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0){ if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll sqr(ll x) { return x * x;}
// always use 1ll*ans to avoid signed integer overflow; 
void prec(){
	
}
void solve(){
	int k;
	string s;
	cin>>k>>s;
	if(sz(s)<=k) cout<<s<<endl;
	else cout<<s.substr(0,k)+"..."<<endl;
}
int main()
{
    ios;
    int tc=1;
    //cin>>tc;
    prec();
    while(tc--)
    	solve();
    return 0; 
}


Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			String a = sc.next();
			
			if(a.toUpperCase().equals(a)) {
				System.out.println("A");
			}else {
				System.out.println("a");
			}



		}catch(Exception e) {
			e.printStackTrace();
		}

	}
}


Measured memory_bytes: 35652
n = int(input())
li = list(map(int,input().split()))
x = 0
y = 0

for i in li:
    if i%4 == 0: #4の倍数がカバーできるのはx*2+1個まで
        x += 1
    if i%4 != 0 and i%2 == 0: #4の倍数では無いけど2の倍数がカバーできるのは自分たちのみ
        y += 1

if x>0 and y>0:
    if 2*x+y >= n:
        print("Yes")
    else:
        print("No")

elif x>0:
    if 2*x+1 >= n:
        print("Yes")
    else:
        print("No")

elif y>0:
    if y == n:
        print("Yes")
    else:
        print("No")

else:
    print("No")

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

int main() {
  int h,w;
  cin>>h>>w;
  for (int i = 0; i <= w+1; ++i) cout<<'#';
  cout<<endl;
  for (int i = 0; i < h; ++i) {
    string s;
    cin>>s;
    cout<<'#'<<s<<'#'<<endl;
  }
  for (int i = 0; i <= w+1; ++i) cout<<'#';
  cout<<endl;
}


Measured memory_bytes: 256
#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];
    }
    sort(v.begin(), v.end());
    double ans = v[0];
    for (int i = 1; i < v.size(); i++) {
        ans = (ans + v[i]) / 2.0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int N,i;
    scanf("%d",&N);
    int ans=3;
    for(i=0;i<N;i++)
    {
        char ch;
        scanf("%c",&ch);
        if(ch=='Y') ans=4;
    }
    if(ans==3) printf("Three\n");
    else printf("Four\n");
    return 0;
} 

Measured memory_bytes: 128
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N,an=0;
	cin >> N;
	vector<ll> T(N);
	rep(i, N) {
		cin >> T.at(i);
		an += T.at(i);
	}
	ll M,ma=0;
	cin >> M;
	vector<ll> time(M);
	rep(i, M) {
		ll P, X;
		cin >> P >> X;
		time.at(i)= T.at(P - 1) - X;
	}
	rep(i, M) {
		cout << an - time.at(i) << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
int main(){
	int sum;
	while(cin>>sum){
		int ans=0;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				for(int k=0;k<10;k++){
					for(int l=0;l<10;l++){
						if(sum==i+j+k+l) ans++;
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}

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

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int l = 1, h = *max_element(a.begin(), a.end());
    while(l < h){
        int mid = (l + h) / 2, cnt = 0;
        rep(i, n){
            cnt += a[i] / mid;
            if(a[i] % mid == 0) --cnt;
        }
        if(cnt <= k) h = mid;
        else l = mid + 1;
    }
    cout << h << endl;
    return 0;
}

Measured memory_bytes: 4020
N,A = map(int,input().split())
X = [int(x)-A for x in input().split()]

z = 0 
dic = {}

for x in X:
    if x==0:
        z += 1
    else:
        dic[x] = dic.get(x,0) + 1
            
line = {}
line[0] = 1

for k in dic:    
    line_k = {}
    for i in range(dic[k]+1):
        line_k[k*i] = 1      
        for j in range(dic[k],dic[k]-i,-1):
            line_k[k*i] *= j
        for j in range(1,1+i):
            line_k[k*i] //= j
    line_tmp = {}
    for k_lk in line_k:
        for k_l in line:
            line_tmp[k_lk+k_l] = line_tmp.get(k_lk+k_l,0) + line_k[k_lk] * line[k_l]
    line = line_tmp.copy()
    
print(line[0] * (2**z) -1) 


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
  ll n,k;cin>>n>>k;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  rep(i,n)a[i]--;
  ll ans=0;
  while(k>0){
    if(k&1)ans=a[ans];
    vector<ll>ac(n);
    rep(i,n)ac[i]=a[a[i]];
    a=ac;
    k>>=1;
  }
  cout<<++ans<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 6364
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Monad
import Data.Int
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import Data.Array.Unboxed
import Data.Array.ST

modulo :: Int64
modulo = 10^9 + 7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod x y = (x + y) `rem` modulo
subMod x y = (x - y) `mod` modulo
mulMod x y = (x * y) `rem` modulo

main = do
  [h,w] :: [Int] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  -- 2 <= h, w <= 1000
  cells :: V.Vector BS.ByteString <- V.replicateM h $ BS.getLine
  let result :: UArray (Int,Int) Int64
      result = runSTUArray $ do
        arr <- newArray ((0,0),(h,w)) 0
        writeArray arr (1,1) 1
        forM_ [1..h] $ \i -> do
          forM_ [1..w] $ \j -> do
            if (i /= 1 || j /= 1) && (cells V.! (i - 1)) `BS.index` (j - 1) == '.'
              then do s <- readArray arr (i-1,j)
                      t <- readArray arr (i,j-1)
                      writeArray arr (i,j) (s `addMod` t)
              else return ()
        return arr
  print $ result ! (h,w)


Measured memory_bytes: 10748
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long LL;


void run_case() {
    int a, b, c;
    cin >> a >> b >> c;
    if((a == b && a != c) || (a == c && a != b) || (b == c && a != b)) cout << "Yes";
    else cout << "No";

}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    //cout.setf(ios_base::showpoint);cout.precision(8);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 100000
long long n,l;
long long fl=0;
long long a[MAXN+5];
long long read()
{
	long long x=0,f=1;
	char c=getchar();
	while('0'>c||c>'9'){if(c=='-') f=-1;c=getchar();}
	while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
int main()
{
	n=read(),l=read();
	for(int i=1;i<=n;i++)
	a[i]=read();
	for(int i=1;i<n;i++)
	{
		if(a[i]+a[i+1]>=l)
		{
			fl=i;
			break;
		}
	}
	if(!fl)
	{
		printf("Impossible\n");
	}
	else 
	{
		printf("Possible\n");
		for(int i=1;i<=fl-1;i++)
			printf("%d\n",i);
		for(int i=n-1;i>=fl;i--)
			printf("%d\n",i);
	}
}


Measured memory_bytes: 1536
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = ni()
b = ni()
c = ni()
d = ni()
e = ni()

k = min(a,b,c,d,e)

ans = 5 + (n-1) // k
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;


int main(){
    string S; cin >> S;
    map<char, int> M; for(auto c : S) M[c]++;
    int ca = M['a'], cb = M['b'], cc = M['c'];

    if(S.size() < 3){
        if(S == "aa" || S == "bb" || S == "cc"){
            cout << "NO" << endl;
            return 0;
        }
        else{
            cout << "YES" << endl;
            return 0;
        }
    }

    if(ca == 0 || cb == 0 || cc == 0){

        cout << "NO" << endl;
        return 0;
    } 

    if((ca == cb && abs(cc-ca) <= 1) || (cb == cc && abs(ca-cb) <= 1) || (ca == cc && abs(cb-ca) <= 1)){
        cout << "YES" << endl;
        return 0;
    }

   /*if(ca > cb+cc+1 || cb > ca+cc+1 || cc > ca+cb+1){
        cout << "NO" << endl;
        return 0;
    }*/
cout << "NO" << endl;
}


Measured memory_bytes: 512
/*
    Problem 14
    https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    ll ans = LINF;
    // 一番前は絶対見えるので
    // 2番目以降からK - 1個選んで見えるようにする
    for (int b = 0; b < (1 << (n - 1)); b++) {
        if (__builtin_popcount(b) != k - 1) continue;
        ll maxH = a[0], sum = 0;
        for (int i = 1; i < n; i++) {
            if ((b >> (i - 1)) & 1) {
                if (maxH >= a[i]) {
                    maxH++;
                    sum += maxH - a[i];
                }
            }
            maxH = max(a[i], maxH);
        }
        ans = min(sum, ans);
    }
    cout << ans << '\n';
}

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

int main(){
  int n,t,ma=-1,ans=0,l,r=0,m;cin>>n>>t;
  vector<int> a(n,0);
  REP(i,n) cin>>a.at(i);

  while(l<n){
    m=0;
    while(r<n&&a.at(l)<=a.at(r)){
      m=max(m,a.at(r)-a.at(l));
      ++r;
    }
    if(ma<m){
      ans=1;
      ma=m;
    }else if(ma==m) ans++;
    l=r;
  } 
  cout<<ans;
}

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

using namespace std;

int main(){
    int n;
    string a, b;
    
    scanf("%d", &n);
    cin >> ws >> a >> b;
    
    for(int i = 0; i < n; i++){
        printf("%c%c", a[i], b[i]);
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>                                                 
                                                                  
int main(void){                                                   
   int N,ans;                                                     
   scanf("%d",&N);                                                
                                                                  
   ans = N/500*1000;                                              
   ans += (N % 500)/5*5;                                          
   printf("%d",ans);                                              
   return 0;                                                      
} 

Measured memory_bytes: 1732
""" AtCoder """

x, y = map(int, input().split())

a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print("Yes")
else:
    print("No")


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

using namespace std;
# define M_PI 3.14159265358979323846
# define epsi 1e-9
# define F first
# define S second
# define REP(i,a,b) for(int i=a;i<=b;i++)
# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
using ll = long long int;
const int MOD = 1e9 + 7;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll W;
    cin>>n>>W;
    vector<pair<ll,ll>> weight_value_pair;
    for (int i = 0; i < n; ++i)
    {
        ll w,v;
        cin>>w>>v;
        weight_value_pair.emplace_back(w,v);
    }
    sort(weight_value_pair.begin(),weight_value_pair.end());
    //dp[i][j]=Max profit if items are chosen only from initial i items and the
    //capacity of knapsack is j
    ll dp[n+1][W+1];
    //Initializing 0th column as zero
    for(int i=0;i<=n;i++)
    {
        dp[i][0]=0;
    }
    //Initializing 0th row as zero
    for (int i = 0; i <=W ; ++i) {
        dp[0][i]=0;
    }
    for (int i = 1; i <=n ; ++i) {
        for (int j = 1; j <=W ; ++j) {
            if(j-weight_value_pair[i-1].first>=0)
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-weight_value_pair[i-1].first]+weight_value_pair[i-1].second);

            } else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][W];
}

Measured memory_bytes: 82420
from collections import defaultdict

N, M = map(int, input().split())

d = defaultdict(int)
for i in range(N):
    A, B = map(int, input().split())
    d[A] += B

ans = 0
for k, v in sorted(d.items(), key=lambda x: x[0]):
    if M == 0:
        break
    q = min(v, M)
    M -= q
    ans += k * q

print(ans)

Measured memory_bytes: 24544
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b;
	cout << (a + b) % 24 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;

int main(){
	int x, sum = 0;
	cin >> x;
	int t = 1;
	while(1){
		sum += t;
		if(sum >= x) break;
		t++;
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#define in inline
#define re register
#define int long long
#define M 1000000007
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();	
	while(v<'0'||v>'9'){
	v=getchar();
	}	
	while(v>='0'&&v<='9'){		
	t=(t<<3)+(t<<1)+(v^48);		
	v=getchar();	}
	return t;
}
int f[100002],a[100002],b,c,d,cnt[100002],n;
signed main(){
n=read();
for(re int i=1;i<=n;++i)a[i]=read();
f[0]=1;
for(re int i=1;i<=n;++i){
	if(a[i]==0)f[i]=f[i-1]*(3-cnt[0]);
	else f[i]=f[i-1]*(cnt[a[i]-1]-cnt[a[i]]);
	f[i]%=M;
	++cnt[a[i]];
}
cout<<f[n];
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=200010,P=1e9+7;
int n,qp,ans,c[MAXN];
int main () {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {scanf("%d",&c[i]);}
	sort(c+1,c+n+1);
	qp=1;
	for (int i=1;i<=2*n-2;i++) {qp=(qp+qp)%P;}
	for (int i=1;i<=n;i++) {
		ans=(ans+(1ll*c[i]*(((1ll*(n-i+1)*qp)%P+qp)%P))%P)%P;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024