akhauriyash/Code-Regression huggingface dataset:
import math

n, m=map(int, input().split())
t = {}
a = int(math.sqrt(m))

s=0

line = [2, 3] + [i%2*2 + i//2 * 6 + 5 for i in range(a)]
# line = [2] + list(range(3, m+2, 2))

for i in line:
# for i in range(2, m+2, 2):
#     print(i)
    cnt = 0
    while m%i==0:
        m=m//i
        cnt += 1

    if cnt>0:
        t[i]=cnt

    if m==1:
        break

if m!=1:
    t[m]=1

def combi(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) 

out=1
for tk in t.keys():
    out *= combi(t[tk]+n-1, n-1)
#     out = out%(1000000007)
print(out%(1000000007))

Measured memory_bytes: 115292
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<cmath>
using namespace std;
int main()
{
	int n;
	long long ans=1;
	cin>>n;
	char a[2][n];
	vector<int>b;
	bool s=0;
	for(int i=0;i<2;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int j=0;j<n;)
	{
		if(a[0][j]==a[1][j])
		{
			b.push_back(1);
			j++;
		}
		else
		{
			b.push_back(2);
			j+=2;
		}
	}
	for(int j=0;j<b.size();j++)
	{
		if(b[j]==1)
		{
			if(b[j-1]==1&&j!=0)
			{
				ans*=2;
			}
			if(j==0)
			{
				ans*=3;
			}
		}
		else
		{
			if(j==0)
			{
				ans*=6;
			}
			if(b[j-1]==1&&j!=0)
			{
				ans*=2;
			}
			if(b[j-1]==2&&j!=0)
			{
				ans*=3;
			}
		}
	}
	ans%=1000000007;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
int N; ll M, A[100005], S[100005];
ll getCount(ll val) {
  ll cnt = 0LL;
  for(int i = 1; i <= N; ++i) {
    auto itr = lower_bound(A+1, A+N+1, val-A[i])-A-1;
    cnt += N-itr;
  }
  return cnt;
}
int main() {
  scanf("%d %ld", &N, &M);
  for(int i = 1; i <= N; ++i) scanf("%ld", &A[i]);
  sort(A+1, A+N+1);
  for(int i = 1; i <= N; ++i) S[i] += S[i-1]+A[i];
  ll l = 0, r = 2e5+1;
  while(r-l > 1) {
    ll m = (l+r)/2;
    if(getCount(m) < M) r = m;
    else l = m;
  }
  ll val = r, cnt = 0LL, ans = 0LL;
  for(int i = 1; i <= N; ++i) {
    auto itr = lower_bound(A+1, A+N+1, val-A[i])-A-1;
    ans += S[N]-S[itr]+A[i]*(N-itr);
    cnt += N-itr;
  }
  ans += (M-cnt)*l;
  printf("%ld\n", ans);
}

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

int main(){
  vector<char> w={'A','B','C'};
  vector<int> u(3,0);

  vector<string> s(3);
  for(int i=0;i<3;++i){
    cin>>s[i];
  }

  int n=0;
  while(true){
    char x=s[n][u[n]];
    if(x=='a'){
      ++u[n];
      n=0;
    }
    if(x=='b'){
      ++u[n];
      n=1;
    }
    if(x=='c'){
      ++u[n];
      n=2;
    }
    if(u[n]==s[n].size()){
    cout<<w[n]<<endl;
    break;
    }
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int maxn = 1e5 + 5;
const int inf = 1e9;
typedef long long ll;
typedef double db;

void solve() {
    int n;

    while (cin >> n) {
        int tmp = n * 2;
        int k = -1;
        for (int i = 2; ; i++) {
            if (i * (i-1) > tmp) break;
            if (i * (i-1) == tmp) {
                k = i;
            }
        }
        if (k == -1) {
            cout << "No\n";
        }
        else {
            cout << "Yes\n";
            cout << k << endl;
            int cur = 1;
            vector<int> G[1005];
            for (int i = 1; i <= k; i++) {
                int cnt = 0;
                for (int j = 0; j < k-1; j++) {
                    cnt++;
                    if (cnt <= i - 1) {
                        G[i].push_back(G[cnt][i-2]);
                    }
                    else {
                        G[i].push_back(cur++);
                    }
                }
            }
            for (int i = 1; i <= k; i++) {
                printf("%d", k-1);
                for (int j = 0; j < G[i].size(); j++) {
                    printf(" %d", G[i][j]);
                }
                puts("");
            }
        }
    }
}

int main() {
    //freopen("in.txt", "r", stdin);
    int t= 1;
    //scanf("%d",&t);
    while(t--) {
        solve();
    }
}


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

int main(){
    ll a,b,n,x,ans;
    cin>>a>>b>>n;
    ll m=n-(n%b)-1;
    ans=max(max(a*n/b-a*(n/b) , a*(n-1)/b-a*((n-1)/b)) , a*(m)/b-a*((m)/b));
    //ans=a*n/b-a*(n/b);
    cout<<ans<<endl;
}


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

int n;
ll W;
const ll inf=9999999999;
int v[101],w[101];
ll dp[101][10001];

int main(){
 ios::sync_with_stdio(false);
 cin.tie(0);
 cin>>n>>W;
 for(int i=0;i<n;i++){
  cin>>v[i]>>w[i];
 }
 for(int i=0;i<101;i++)for(int j=0;j<10001;j++)dp[i][j]=inf;
 dp[0][0]=0;
 for(int i=0;i<n;i++){
  for(int j=0;j<10001;j++){
   if(dp[i][j]+w[i]<=W){
    dp[i+1][j+v[i]]=min(dp[i][j]+w[i],dp[i+1][j+v[i]]);
   }
   dp[i+1][j]=min(dp[i][j],dp[i+1][j]);
  }
 }
 ll ans=0;
 for(int i=0;i<10001;i++){
  if(dp[n][i]!=inf)ans=i;
 }
 cout<<ans<<endl;
 return 0;
}

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

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int q;
    cin >> q;
    double x, y;
    vector< pair<int, int> > p(q);

    for(int i = 0; i < q; i++){
        cin >> p[i].first >> p[i].second;
    } 

    //係数の分母が０のときの処理
    if(x2-x1 == 0){
        for(int i = 0; i < q; i++){
            if(p[i].first > x1){
                x = p[i].first - 2*(p[i].first - x1);
            }
            else {
                x = p[i].first + 2*(x1 - p[i].first);
            }
            y = p[i].second;
            printf("%.10lf %.10lf\n", x, y);
        }
        
        return 0;
    }

    double cfi, inv_cfi, cst;
    cfi = double(y2-y1)/(x2 - x1);
    //係数を求める
    
    cst = y1 - cfi * x1; //p1p2の定数
    if(cfi == 0){
        for(int i = 0; i < q; i++){
            if(p[i].second > y1){
                y = p[i].second - 2*(p[i].second - y1);
            }
            else {
                y = p[i].second + 2*(y1 - p[i].second);
            }
            x = p[i].first;
            printf("%.10lf %.10lf\n", x, y);
        }
        return 0;
    }

    inv_cfi = -1/cfi;
    
    for(int i = 0; i < q; i++){
        double cst_p, ans_x, ans_y;
        cst_p = p[i].second - inv_cfi * (p[i].first);
        ans_x = (cst_p - cst) / (cfi - inv_cfi);
        ans_y = inv_cfi*ans_x + cst_p;
        
        if(p[i].second > ans_y){
            y = p[i].second - 2*(p[i].second - ans_y);
        }
        else {
            y = p[i].second + 2*(ans_y - p[i].second);
        }
        if(p[i].first > ans_x){
            x = p[i].first - 2*(p[i].first - ans_x);
        }
        else {
            x = p[i].first + 2*(ans_x - p[i].first);
        }
        
        printf("%.10lf %.10lf\n", x, y);

    }
    
}


Measured memory_bytes: 3232
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string S;

int main()
{
	in >> S;
	std::sort(S.begin(), S.end());
	out << (S == "abc" ? "Yes" : "No") << std::endl;
	return 0;
}


Measured memory_bytes: 256
use std::collections::HashSet;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut set = HashSet::new();
    for _ in 0..n {
        let x:usize = read();
        set.insert(x);
    }
    if set.len() == n {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 5524
# 第一行目の入力
n = int(input())
# 第２行目以降の入力
r_list = [int(input()) for i in range(n)]
score = -2000000000000000000000
minv = r_list[0]
"""
ループ内で
今まで出た最小値を持っておく
新しい値との差をとる
既存のスコアより大きければスコアを更新
"""
for r in r_list[1:]:
    score = max(score, r - minv) 
    minv = min(minv, r)        
print(score)


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

using namespace std;

template <class T> inline bool chmin(T &a, T b) { /* {{{ */
  if (a > b) {
    a = b;
    return true;
  }
  return false;
} /* }}} */

int main() {
  int N;
  cin >> N;
  vector<int> C(26, 1e9);
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    vector<int> cnt(26);
    for (int j = 0; j < s.length(); j++) {
      int c = s[j] - 'a';
      cnt[c]++;
    }
    for (int j = 0; j < 26; j++) {
      chmin(C[j], cnt[j]);
    }
  }
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < C[i]; j++) {
      cout << (char)('a' + i);
    }
  }
  cout << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
        };

        Int K;
        cin >> K;
        K--;
        cout << arr[K] << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

int main(){
  int h,w;
  scanf("%d%d",&h,&w);
  vector<string>  v(h);
  for(int i=0;i<h;i++)
     cin>>v[i];
  
  long long int dp[h+5][w+5];
  memset(dp,0,sizeof(dp));
    
  long long int mod=1e9+7;
   dp[0][0]=1;                              
  for(int i=0;i<h;i++){
     for(int j=0;j<w;j++){
       if(v[i][j]!='#'){
         if(j+1<w )
           dp[i][j+1]=((dp[i][j+1]%mod)+(dp[i][j]%mod))%mod;
         if(i+1<h )
             dp[i+1][j]=((dp[i+1][j]%mod)+(dp[i][j]%mod))%mod;
         }
        }
  
    }
                             
    printf("%lld\n",dp[h-1][w-1]);
    return 0;
}

Measured memory_bytes: 9216
#include <iostream>
using namespace std;
   
int main() {
  int n;
  cin >> n;
  int ary[n], x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    ary[i] = x;
  }
  for (int j = n - 1; j > -1; j--) {
    if (j != 0) {
      cout << ary[j] << " ";
    } else {
      cout << ary[j] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {
	public static void main(String[] args){
 
        Scanner sc = null;
        sc = new Scanner(System.in);
        int x = sc.nextInt();
        sc.close();

        if (x == 0) {
            System.out.println(1);
        } else {
            System.out.println(0);
        } 
      }
}

Measured memory_bytes: 35616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

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

	int k;
	cin >> k;
	while (k--) cout << "ACL";
	cout << endl;
}

Measured memory_bytes: 3596
from collections import deque
S = input()
S = [S[i] for i in range(len(S))]
S = deque(S)                         
Q = int(input())
rev = 1
for i in range(Q):
  comm = input()
  if comm == "1":
    rev *= -1
  else:
    T, F, C = comm.split()
    F = int(F) * 2 - 3
    if rev * F == 1:
      S.append(C)
    else:
      S.appendleft(C)
S = list(S)
ans = ""
for i in range(len(S)):
  ans += S[i * rev + (rev-1) // 2]
print(ans)
      

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

int main(){
  int64_t X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<int64_t> S, A(X), B(Y), C(Z);
  
  for (int i = 0; i < X; i++){
    cin >> A.at(i);
  }
  for (int i = 0; i < Y; i++){
    cin >> B.at(i);
  }
  for (int i = 0; i < Z; i++){
    cin >> C.at(i);
  }
  
  sort(A.rbegin(), A.rend());
  sort(B.rbegin(), B.rend());
  sort(C.rbegin(), C.rend());
  
  for (int i = 0; i < X; i++){
    for (int j = 0; j < Y; j++){
      for (int k = 0; k < Z; k++){
        if ((i+1)*(j+1)*(k+1) <= K){
          S.push_back(A[i]+B[j]+C[k]);
        }
        else{
          break;
        }
      }
    }
  }
  
  sort(S.rbegin(), S.rend());
  
  for (int i = 0; i < K; i++){
    cout << S.at(i) << endl;
  }
}

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


int main() {
  int n ;
  cin >> n ;
  
  vector<int> a(n);
  vector<int> b(n);
  
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<n;i++){
    int c=0;
    if(i>0){
      if(b.at(i-1)>0){
        b.at(i)=b.at(i)-1;
        continue;
      }
    }
    for(int j=1;j<n-i;j++){
      if(a.at(i+j-1)>=a.at(i+j)){
        c++;
      }
      else{
        break;
      }
    }
 
    b.at(i)=c;
    if(c>n/2){
      break;
    }
  }
  
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  
  cout << b.at(0) << endl;
}

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



int main(void) {
    int a, b, c;
    cin >> a >> b >> c;
    int t[60] = {0};
    int now_time=0;
    while(1) {
        if (t[now_time%60]==1) {
            cout << -1 << endl;
            exit(0);
        }
        t[now_time%60] = 1;
        if ( (now_time%60 < c && c <= now_time%60+a) ) {
            cout << now_time + (c - now_time%60) << endl;
            exit(0);
        }
        now_time += a;
        now_time += b;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,a,b;
cin>>n>>a>>b;
if(a<b){
int c=a;
a=b;
b=c;
}
cout<<b<<" ";
if(a+b>=n)cout<<a+b-n;
else cout<<"0";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define N 1000002
#define mod 1000000007
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mxN = 5005;
void solve(){
	int n,k;
	cin>>n>>k;
	int a[n];
	int l = 1;
	int r = 0;
	for(int i =0;i<n;i++){
		cin>>a[i];
		r = max(r,a[i]);
	}
	int mid;
	while(l<r){
		mid = l + (r-l)/2;
		int s = 0;
		for(int i =0;i<n;i++){
			s+=(a[i]-1)/mid;
		}
		if(s<=k)
			r = mid;
		else
			l = mid+1;
	}
	cout<<l<<'\n';
}
int main() {	
	IOS
	ll T;
	// cin>>T;
	T = 1;
	// ll i = 1;
	while(T--){
		// cout<<"Case #"<<i<<": ";
		solve();
		// i++;
	}
	return 0;
	
}

Measured memory_bytes: 4368
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

vector<pair<int,int> >Red,Blue;
bool used[100];

int main(void) {
    int N;
    cin>>N;
    for(int i = 0;i < N;i++) 
    {
        int x,y;
        pair<int,int> xy;
        cin>>x>>y;
        xy.first = x,xy.second = y;
        Red.push_back(xy);
    }
    for(int i = 0;i < N;i++) {
        int x,y;
        pair<int,int> xy;
        cin>>x>>y;
        xy.first = x,xy.second = y;
        Blue.push_back(xy);
    }

    sort(Red.begin(),Red.end());
    sort(Blue.begin(),Blue.end());

    int ans = 0;
    for(int b = 0;b < N;b++) {
        int my = -1;
        int index = -1;
        for(int r = 0;r < N;r++) {
            if(used[r])
                continue;
            if(Blue[b].first > Red[r].first && Blue[b].second > Red[r].second) {
                if(Red[r].second > my) {
                    my = Red[r].second;
                    index = r;
                }
            }
        }
        if(index != -1) {
            used[index] = true;
            ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}


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

constexpr double eps = 1e-8;

double calc(double x1, double y1, double x2, double y2, double x) {
    double a = (y1 - y2) / (x1 - x2);
    double b = y1 - a * x1;
    return a * x + b;
}

using pdd = pair<double, double>;

int main() {
    int n;
    while(cin >> n, n) {
        vector<int> x(n), y(n);
        for(int i=0; i<n; ++i) {
            cin >> x[i] >> y[i];
        }
        int lx = *min_element(x.begin(), x.end());
        int rx = *max_element(x.begin(), x.end());
        int res = 0;
        for(int i=lx; i<rx; ++i) {
            vector<pdd> ys;
            for(int j=0; j<n; ++j) {
                int nj = (j + 1) % n;
                if(min(x[j], x[nj]) <= i && i+1 <= max(x[j], x[nj])) {
                    double y1 = calc(x[j], y[j], x[nj], y[nj], i);
                    double y2 = calc(x[j], y[j], x[nj], y[nj], i+1);
                    if(y1 > y2) {
                        swap(y1, y2);
                    }
                    ys.emplace_back(y1, y2);
                    //cout << y1 << ' ' << y2 << endl;
                }
            }
            sort(begin(ys), end(ys));
            int yr = -1e9;
            for(int j=0; j<(int)ys.size()-1; j+=2) {
                int l = max((int)floor(ys[j].first + eps), yr),
                    r = ceil(ys[j+1].second - eps);
                res += r - l;
                yr = r;
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 2964
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
	int n,m;
	cin>>n>>m;
	ll ti=1900*m+100*(n-m);
	ll q=1;
	for(int i=0;i<m;i++) q*=2;
	cout<<ti*q<<endl;
	//E=cost+(1-p)*E
}

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

using namespace std;
#define int int64_t
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{
   cin.tie(0);
   ios::sync_with_stdio(false);

   string s;
   cin >> s;
   int cnt = 0, ans = 0;

   rep(i, s.size())
   {
      if (s[i] == '0')
      {
         ++cnt;
      }
      else
         ++ans;
   }
   cout << min(cnt, ans) * 2 << '\n';
}

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

long long int a[7];
long long int ans;

int main(){
	for(int i=0; i<7; ++i)
		cin >> a[i];
	ans += a[1];
	if(a[3] > 0 && a[4] > 0 && a[0] > 0) ans += max(3+(a[3]-1)/2*2+(a[4]-1)/2*2+(a[0]-1)/2*2, a[3]/2*2+a[4]/2*2+a[0]/2*2);
	else ans += a[3]/2*2+a[4]/2*2+a[0]/2*2;
	cout << ans << endl;
}

Measured memory_bytes: 256
class SegTree:
    def __init__(self, init_val, n, ide_ele, seg_func):
        self.segfunc = seg_func
        self.num = 2**(n-1).bit_length()
        self.ide_ele = ide_ele
        self.seg=[self.ide_ele]*2*self.num
        for i in range(n):
            self.seg[i+self.num-1]=init_val[i]    
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 
        
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        # k+1ではなくkでは？
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])
        
    def query(self, p, q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res
from collections import defaultdict
import sys;input=sys.stdin.readline
N, = map(int, input().split())

A = [0] + list(map(int, input().split()))
G = [[] for _ in range(N+1)]
for v in range(N-1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)

iA = [(i, a) for i, a in enumerate(A)]
iA.sort(key=lambda x:x[1])
d = dict()
AA = [0]*(N+1)
a2f = [0]*(N+1)
rj = 0
for j, (i, a) in enumerate(iA):
    AA[i] = j
    if a not in d:
        rj = j
    a2f[i] = rj
    d[a] = 1
#print(AA, a2f)

R = [0]*(N+1)
R[1] = 1
ss = SegTree([0]*(N+1), N+1, -1, max)
ss.update(AA[1], 1)
stack = []
for u in G[1]:
    stack += [-1, u]
visited = set([1])
path = [1]
while stack:
    v = stack.pop()
    if v > 0:
        visited.add(v)
        path.append(v)
        qq = ss.query(0, a2f[v])
        ss.update(AA[v], qq+1)
        R[v] = ss.query(0, N+1)
        for u in G[v]:
            if u in visited:
                continue
            stack += [-v, u]
    else:
        child = path.pop()
        ss.update(AA[child], 0)
for i in range(1, N+1):
    print(R[i])


Measured memory_bytes: 175912
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    char a;
    cin>>a;
    if(isupper(a))puts("A");
    else puts("a");
    return 0;
}

Measured memory_bytes: 3648
<?php

$input_number = trim(fgets(STDIN));

$input_arr = str_split($input_number);

$continue_num = 0;
$prev_val = '';
foreach ($input_arr as $value)
{
	if ($prev_val === $value)
	{
		$continue_num++;
	}
	else
	{
		$continue_num = 1;
	}
	$prev_val = $value;

	if ($continue_num >= 3)
	{
		break;
	}
}

$result = ($continue_num >= 3)? 'Yes' : 'No';
echo $result;


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

typedef long long ll;

int main() {

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

    int bingo[3][3];
    int bingo_check [3][3];

    memset(bingo, 0, sizeof(bingo));
    memset(bingo_check, 0, sizeof(bingo_check));

    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> bingo[i][j];
        }
    }

    int n = 0;
    cin >> n;
    int temp = 0;
    for(int i = 0; i < n; i++) {
        cin >> temp;
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 3; k++) {
                if(temp == bingo[j][k]) {
                    bingo_check[j][k] = 1;
                }
            }
        }
    }


    int ans = 0;
    for(int i = 0; i < 3; i++) {
        int tmp = 0;
        for(int j = 0; j < 3; j++) {
            tmp += bingo_check[j][i];
        }
        if(tmp == 3) ans = 1;
    }

    for(int i = 0; i < 3; i++) {
        int tmp = 0;
        for(int j = 0; j < 3; j++) {
            tmp += bingo_check[i][j];
        }
        if(tmp == 3) ans = 1;
    }

    if(bingo_check[0][0] + bingo_check[1][1] + bingo_check[2][2] == 3) ans = 1;
    if(bingo_check[2][0] + bingo_check[1][1] + bingo_check[0][2] == 3) ans = 1;

    if(ans) cout << "Yes\n";
    else cout << "No\n";
    
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>

int main() {

	unsigned long long int n[3] = { 2, 1 };
	int N;

	scanf("%d", &N);

	if (N < 2) printf("%llu\n", n[N]);
	else {
		for (int i = 2; i <= N; i++) {
			n[2] = n[0] + n[1];
			n[0] = n[1];
			n[1] = n[2];
		}
		printf("%llu\n", n[1]);
	}

	return 0;
}

Measured memory_bytes: 128
n, m = map(int,input().split())

mod = 10**9 + 7

if abs(n-m) > 1:
    print(0)
    quit()

elif abs(n-m) == 1:
    a = max(n,m)
    b = min(n,m)
    ans = 1
    for i in range(1,a+1):
        ans *= (i%mod)
        ans %= mod
    for i in range(1,b+1):
        ans *= (i%mod)
        ans %= mod
    print(ans%mod)

else:
    ans = 1
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    print((2*ans)%mod)

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// DON'T USE THESE MACROS DURING ICPC PRACTICE
#define For(i,n) for (int i=0; i<n; i++)
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define Down(i,n) for (int i=n-1; i>=0; i--)
#define DOWN(i,a,b) for (int i=b; i>=a; i--)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<int> vi;

const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

struct Edge {
	int a,b,c;
};

const int N = 2500+1;
const int M = 5e3+1;
int dist[N], rev[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(10);

	int n,m,p;
	cin>>n>>m>>p;

	vector<Edge> edges;
	For(i,m) {
		int a,b,c;
		cin>>a>>b>>c;
		edges.push_back({a,b,p-c});
	}

	memset(dist,INF,sizeof dist);
	memset(rev,INF,sizeof rev);
	dist[1] = 0;
	rev[n] = 0;
	For(i,n-1) {
		for (const Edge& e : edges) {
			dist[e.b] = min(dist[e.b], dist[e.a]+e.c);
			rev[e.a] = min(rev[e.a], rev[e.b]);
		}
	}
	for (const Edge& e : edges) {
		if (dist[e.a]<INF/2 && rev[e.b]<INF/2) {
			if (dist[e.a]+e.c < dist[e.b]) {
				cout << -1 << nl;
				return 0;
			}
		}
	}
	if (dist[n]>INF/2) {
		cout << "bad statement" << nl;
		return 0;
	}
	cout << max(0, -dist[n]) << nl;

	return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pop_b pop_back
#define pf push_front
#define pop_f pop_front
#define mt make_tuple
#define eb emplace_back
#define sf(x) sizeof(x)
#define len(x) x.length()
#define sz(x) x.size()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef long double ld; 
typedef vector<int> vi;
typedef vector<set<ll>> vset;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef deque<ll> dql;
typedef deque<int> dqi;
typedef unsigned long long ull;
typedef tuple<int,int,int> State;

#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 << ", ";
	err(++it, args...);
	cout<<"\n";
}

#define vmax(type)   std::numeric_limits<type>::max()
#define vmin(type)   std::numeric_limits<type>::min()
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;
#define resize_vec(a) a.resize(unique(a.begin(), a.end()) - a.begin());
#define ms(dp, x) memset(dp, x, sf(dp))
#define endl '\n'

ll powm(ll a, ll b, ll mod) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const ll mod = 1e9 + 7;
const ll N = 1000005;
const ll inf = 1e9;

void solve()
{
	int n;
	cin>>n;
	int cnt = 0, hi = 0;
	rep(i, n){
		int x, y;
		cin>>x>>y;
		if(x == y)
			cnt++;
		else
			cnt = 0;
		if(cnt == 3){
			hi = 1;
			// return;
		}
	}
	if(hi)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

// #define _DEBUG 
// #define testCases
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(15);
	
	int tc = 1;
#ifdef testCases
	cin>>tc;
#endif
	while(tc--)
	{
#ifdef _DEBUG
	int tt = clock();
#endif
		solve();
		
#ifdef _DEBUG
		cerr << "TIME = " << clock() - tt << endl;
		tt = clock();
#endif
	}
	return 0;
}


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

int main()
{

        int sx, sy;
        int tx, ty;
        cin >> sx >> sy >> tx >> ty;

        int dx = abs(sx - tx);
        int dy = abs(sy - ty);

        cout << string(dy, 'U');
        cout << string(dx, 'R');
        cout << string(dy, 'D');
        cout << string(dx, 'L');
        cout << 'L';
        cout << string(dy+1, 'U');
        cout << string(dx+1, 'R');
        cout << 'D';
        cout << 'R';
        cout << string(dy+1, 'D');
        cout << string(dx+1, 'L');
        cout << 'U';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin>>n;
    vl A;
    rep(i,n){
        cin>>x;
        A.push_back(x-1);
    }

    rep(i,n){
        if(A[A[i]]==i)ans++;
    }

    cout<<ans/2<<endl;
}


Measured memory_bytes: 1400
#include <stdio.h>
#include <stdlib.h>

#define SENTINEL (1000000001)

static int Merge(int A[], int left, int mid, int right);
static int MergeSort(int A[], int left, int right);

int main(void) {
	int i;
	int c;
	int n;
	int S[500000];
	
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%d", &S[i]);
	}
	
	c = MergeSort(S, 0, n);
	
	for (i = 0; i < n; ++i) {
		if (i > 0) {
			putchar(' ');
		}
		printf("%d", S[i]);
	}
	putchar('\n');
	
	printf("%d\n", c);

	return 0;
}

int Merge(int A[], int left, int mid, int right) {
	int c = 0;
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;
	int *L = (int *)calloc(n1 + 1, sizeof(int));
	int *R = (int *)calloc(n2 + 1, sizeof(int));
	for (i = 0; i < n1; ++i) {
		L[i] = A[left + i];
	}
	for (i = 0; i < n2; ++i) {
		R[i] = A[mid + i];
	}
	L[n1] = R[n2] = SENTINEL;
	i = j = 0;
	for (k = left; k < right; ++k) {
		++c;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			++i;
		} else {
			A[k] = R[j];
			++j;
		}
	}
	free(L);
	free(R);
	return c;
}

int MergeSort(int A[], int left, int right) {
	int c = 0;
	int mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		c += MergeSort(A, left, mid);
		c += MergeSort(A, mid, right);
		c += Merge(A, left, mid, right);
	}
	return c;
}

Measured memory_bytes: 4492
#include <iostream>
using namespace std ;
int main() {
    int a, b;
    cin >> a >> b;
    if(a+b >= a-b && a+b >= a*b) cout << a+b;
    else if (a-b >= a+b && a-b >= a*b) cout << a-b;
    else cout << a*b;
    return 0;
}


Measured memory_bytes: 256
n, t = gets.split.map(&:to_i)
arr = gets.split.map(&:to_i)

diff_arr = {}
min = arr[0]
max = arr[0]
arr.each do |n|
  if n < min
    min = n
    max = n
  elsif max <= n
    d = n - min
    diff_arr[d] ||= 0
    diff_arr[d] += 1
    max = n
  end
end

key =  diff_arr.keys.max
puts diff_arr[key]


Measured memory_bytes: 25028
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  long long N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  
  long long a = (N+A-1)/A;
  long long b = max((N+B-1)/B, a); // +1
  long long c = max((N+C-1)/C, b); // +2
  long long d = max((N+D-1)/D, c); // +3
  long long e = max((N+E-1)/E, d); // +4
  long long ans = 4 + e;
  
  cout << ans << endl;
  return 0;
}

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

int main(void){
  string str;
  cin >> str;
  int count = 0;
  for(int i = 0; i != str.size(); i++)if(str[i] == 'o')count++;
  if(count + (15 - str.size()) >= 8)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 200001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int n;
  scanf("%d", &n);
  int a[MAX];
  rep(i, 0, n) scanf("%d", &a[i]);

  int h[MAX], r[MAX];
  int hi = 0, ri = 0;
  rep(i, 1, n) {
    if ( n % 2 == 0 ) {
      if ( i % 2 == 1 ) h[hi++] = a[i];
      else r[ri++] = a[i];
    } else {
      if ( i % 2 == 0 ) h[hi++] = a[i];
      else r[ri++] = a[i];
    }
  }
  for ( int i = hi-1; i >= 0; i-- )
    printf("%d ", h[i]);
  printf("%d ", a[0]);
  for ( int i = 0; i < ri; i++ )
    printf("%d ", r[i]);
  return 0;
}


Measured memory_bytes: 3712
def main():
    n=int(input())
    a=list(map(int,input().split()))
    
    def judge(k):
        cnt=0
        for i in a:
            cnt+=max((i-n+k)//(n+1)+1,0)
        if cnt>k:
            return False
        else:
            return True

    #a,bには下限と上限、valueにはOKな範囲のときはTrue、そうでないときにFalseを返す関数を入れる
    #limは下限を知りたいときはlower、上限を知りたいときはupperを入れる
    def b_search(a,b,value,lim):
        med=(a+b)//2
        if a==b:return a
        elif lim=='upper':
            if a+1==b:
                if value(b):return b
                else:return a
            elif value(med):return b_search(med,b,value,lim)
            else:return b_search(a,med-1,value,lim)
        else:
            if a+1==b:
                if value(a):return a
                else:return b
            elif value(med):return b_search(a,med,value,lim)
            else:return b_search(med+1,b,value,lim)

    j=b_search(0,10**18,judge,'lower')
    ans=j
    for i in range(j-1,max(j-3000,-1),-1):
        if judge(i):
            ans=i
    print(ans)
main()

Measured memory_bytes: 3064
N, T = map(int, input().split())

TLE_flag = True
result = 1001
for i in range(N):
    c, t = map(int, input().split())
    if t <= T and c < result:
        if TLE_flag:
            TLE_flag = False
        result = c

if TLE_flag:
    print('TLE')
else:
    print(result)


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>

using namespace std;
 int N,A[100010];
int main(){
  cin>>N;
  vector<pair<int,int>>pairs(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    pairs[i]=make_pair(A[i],i);
  }
  sort(pairs.begin(),pairs.end());
  for(int i=0;i<N;i++){
    cout<<pairs[i].second+1<<endl;
  }



 return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, K, Q; cin >> N >> K >> Q;
    vector<int> A(N, 0);
    rep(i, Q){
        int n; cin >> n;
        A[n - 1]++;
    }
    vector<int> points(N, K);
    rep(i, N){
        points[i] = points[i] - Q + A[i];
        if(points[i] <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    char n[15];
    for(int i=0;i<12;i++) cin>>n[i];
    for(int i=0;i<4;i++) cout<<n[i];
    cout<<" ";
    for(int i=4;i<12;i++) cout<<n[i];
    cout<<'\n';
    return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n];
  int cnt[101];fill(cnt,cnt+101,0);
  for(int i=0;i<n;i++){
    cin>>a[i];
    cnt[a[i]]++;
  }
  sort(a,a+n);
  bool ok=true;
  if(cnt[a[n-1]]==1){
    ok=false;
  }
  else{
    if(a[n-1]%2==0){
      for(int i=1;i<a[n-1];i++){
        if(i<a[n-1]/2){
          if(cnt[i]>0)ok=false;
        }
        else if(i==a[n-1]/2){
          if(cnt[i]!=1)ok=false;
        }
        else{
          if(cnt[i]<=1)ok=false;
        }
      }
    }
    else{
      for(int i=1;i<a[n-1];i++){
        if(i<=a[n-1]/2){
          if(cnt[i]>0)ok=false;
        }
        else if(i==a[n-1]/2+1){
          if(cnt[i]!=2)ok=false;
        }
        else{
          if(cnt[i]<=1)ok=false;
        }
      }
    }
  }
  if(ok)cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
}

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

int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)
        cin>>arr[i];
    int cost[n];
    cost[0]=0;
    cost[1]=abs(arr[1]-arr[0]);
    cost[2]=abs(arr[2]-arr[0]);
    for(int i=3; i<n; i++)
        cost[i] = min(cost[i-1] + abs(arr[i]-arr[i-1]), cost[i-2] + abs(arr[i]-arr[i-2]));
    cout<<cost[n-1];
}


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

int main() {
  string s;
  cin>>s;
  if (s == "SAT") {
    cout<<1<<endl;
  } else if (s == "SUN") {
    cout<<7<<endl;
  } else if (s == "MON") {
    cout<<6<<endl;
  } else if (s == "TUE") {
    cout<<5<<endl;
  } else if (s == "WED") {
    cout<<4<<endl;
  } else if (s == "THU") {
    cout<<3<<endl;
  } else if (s == "FRI") {
    cout<<2<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;

inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){return (a%mod * b%mod)%mod;}
inline int power(int a,int b,int MOD){int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
int dp[100][100][3000];
signed main()
{
     SPEED;
     int n,a;
     cin>>n>>a;
     vi v(n);
     in(v,n);
     for(int i=0;i<=n;i++)
     	dp[i][0][0]=1;
     for(int i=1;i<=n;i++)
     {
     	 for(int size=1;size<=n;size++)
     	 {
     	 	  for(int sum=0;sum<=2500;sum++)
     	 	  {
     	 	  	   if(sum>=v[i-1])
     	 	  	   	dp[i][size][sum]+=dp[i-1][size-1][sum-v[i-1]];
     	 	  	   dp[i][size][sum]+=dp[i-1][size][sum];
     	 	  }
     	 }
     }
     int res=0;
     for(int i=1;i<=n;i++)
     	res+=dp[n][i][i*a];
     cout<<res<<endl;
     time();
     return 0;
}

Measured memory_bytes: 116992
H, W = map(int, input().split())
A = []
for _ in range(H):
    a = list(map(int, input().replace('.', '0').replace('#', '1')))
    A.append(a)

ans1 = []
for a in A:
    if sum(a) != 0:
        ans1.append(a)

ans2 = []
for a in zip(*ans1):
    if sum(a) != 0:
        ans2.append(a)

ans2 = [list(map(str, i)) for i in zip(*ans2)]
for a in ans2:
    print(''.join(a).replace('0', '.').replace('1', '#'))


Measured memory_bytes: 3828
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 200010
using namespace std;
int top,n;
char s[N],sta[N];
int main(){
	scanf("%s",s);n=strlen(s);
	for(int i=0;i<n;i++){
		if(top&&sta[top]=='S'&&s[i]=='T') top--;
		else sta[++top]=s[i];
	}
	printf("%d",top);
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;

namespace AizuOnlineJudgement.ITP1_1_C
{
	public static class Program
	{
		public static void Main (string[] args)
		{
			var ab = Console.ReadLine ().Split (' ').Select (n => int.Parse (n)).ToArray ();
			Console.WriteLine ((ab[0] * ab[1]) + " " + (ab[0] * 2 + ab[1] * 2));
		}
	}
}



Measured memory_bytes: 9620
// Author: Zark84010 (Aditya Ranjan)

#include <bits/stdc++.h>
 
using namespace std;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"
 
#define sz(a) ((int)(a).size())
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())      //
#define cpres(c, val) (find(all(c), val) != (c).end()) //

#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define forf(i, a, b) for (int i = (a); i < (b); i++)
#define forb(i, a, b) for (int i = (b); i >= (a); i--)
#define fo(i, n) forf(i, 0, n)
#define fob(i, n) forb(i, 0, n - 1)
 
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
 
const int INF = 9e18;
const int N = 1e9 + 7;
// const int N = 998244353;
const double eps = 1e-9;
 
const auto start_time = std::chrono::high_resolution_clock::now();
 
void zark() {
  #ifdef ZARK
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time - start_time;
    cerr << "Time Taken : " << diff.count() << "s\n";
  #endif
}
 
#ifdef ZARK
  #include "/home/aranjan/Desktop/CP/header.h"
  #else
  #define dbg(args...)
#endif

/* ------------------ Actual Coding Starts ------------------ */

void solve() {
  int n,m,k;
  cin>>n >>m>>k;
  vector<vi> a(n, vi(m+1));
  fo(i, n) fo(j, m+1) cin >> a[i][j];
  int ans = INF;
  for(int b = 0; b < (1<<n); b++) {
  	bool ok = true;
  	int bb = b;
  	vi s(m+1);
  	int ss = 0;
  	fo(i, n) {
  		if(bb%2) {
  			forf(j, 1, m+1) s[j] += a[i][j];
  			ss += a[i][0];
  		}
  		bb /= 2;
  	}
  	forf(j, 1, m+1) ok &= s[j]>=k;
  	if(ok) ans = min(ans, ss);
  }
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}

int32_t main() {
  fastio;
  #ifdef ZARK
  freopen("input.in", "r", stdin);
  #endif
 
  // freopen("txt.in", "r", stdin);
  // freopen("txt.out", "w", stdout);
  // cout << fixed << setprecision(35);
 
  solve();
  zark();
  return 0;
}

Measured memory_bytes: 3660