akhauriyash/Code-Regression huggingface dataset:
n = int(input())
c = []
for i in range(n):
    c.append(input())
d = []
m = int(input())
for i in range(m):
    d.append(input())

scores = []
for i in c:
    score = 0
    for j in range(n):
        if i == c[j]:
            score += 1
    for j in range(m):
        if i == d[j]:
            score -= 1
    scores.append(score)
if max(scores) >= 0:
    print(max(scores))
else:
    print(0)

Measured memory_bytes: 38896
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val ans = getAns("", n)
    println(ans)
}

val dic = mutableMapOf<String,MutableMap<Int, Long>>()

fun getAns(log:String,remain:Int):Long {
    val key = if(log.length <= 4) log else log.takeLast(4)
    if(!dic.containsKey(key)) {
        dic[key] = mutableMapOf()
    }
    dic[key]!![remain]?.let { return it }
    if(remain == 0) {
        return if(isValid(key)) 1 else 0
    }
    var ans = 0L
    for(c in "ACGT") {
        if(!isValid((key+c).takeLast(4))) {
            continue
        }
        ans += getAns(key+c, remain-1)
        ans = ans % (1000000000 + 7)
    }
    dic[key]!![remain]= ans
    return ans
}

val validDic = mutableMapOf<String, Boolean>()
fun isValid(target:String):Boolean {
    if(validDic.containsKey(target)) {
        return validDic[target]!!
    }
    if(target.length < 3) {
        validDic[target] = true
        return true
    }
    if(target.contains("AGC")) {
        validDic[target] = false
        return false
    }
    for(i in (1 until target.length)) {
        val tmp = target.toMutableList()
        val c = tmp[i]
        tmp[i] = tmp[i-1]
        tmp[i-1] = c
        val unValid = tmp.joinToString("")
        if(unValid.contains("AGC")) {
            validDic[target] = false
            return false
        }
    }
    validDic[target] = true
    return true
}




Measured memory_bytes: 56368
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_N 110
#define MAX_R 110
#define MAX_D 110
 
struct State{
    int r,d;
    State(){}
    State(int r,int d) : r(r),d(d) {}
};
 
int D,N;
int a[MAX_N],e[MAX_N],r[MAX_N];
 
int bfs(){
    queue<State> Q; Q.push(State(0,D));
    queue<int> step; step.push(0);
    bool visited[MAX_R][MAX_D] = {{false}};
    visited[0][D] = true;
    while(!Q.empty()){
	State s = Q.front(); Q.pop();
	int stp = step.front(); step.pop();
	if(s.d == 0){ return stp; }
	for(int i = 0 ; i < N ; i++){
	    State ns = (State){min(100,s.r+e[i]),max(0,s.d-a[i])};
	    if(s.r >= r[i] && !visited[ns.r][ns.d]){
		visited[ns.r][ns.d] = true;
		Q.push(ns);
		step.push(stp+1);
	    }
	}
    }
    return -1;
}
 
int main(){
    while(cin >> D >> N, D){
	for(int i = 0 ; i < N ; i++){
	    cin >> a[i] >> e[i] >> r[i];
	}
	int res = bfs();
	if(res == -1){
	    cout << "NA" << endl;
	}else{
	    cout << res << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define in(x); { for (auto &qwertyhgfdsa : x) cin >> qwertyhgfdsa; }
#define out(x); { for (auto qwertyhgfdsa : x) cout << qwertyhgfdsa << ' '; cout << endl; }
#define int long long

typedef long long ll;

using namespace std;

const int INF = 1e9;
const long long INFll = 2e18;
const long long base1 = 239;
const long long base2 = 653;
const long long mod = 1e9 + 7;
const double eps = 1e-6;
const int len = 140;



void solve() {
    ll h, w;
    cin >> h >> w;
    if (min(h, w) == 1ll)
        cout << 1;
    else
        cout << h * w / 2 + ((h * w) % 2);
}

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

    solve();
}


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

int main(){
  int n, m;
  int a, b;
  bool from1[200000] = {false}, ton[200000] = {false};
  std::cin >> n >> m;

  for(int i = 0; i < m; i++){
    std::cin >> a >> b;
    if(a == 1){
      from1[b] = true;
    }
    if(b == n){
      ton[a] = true;
    }
  }

  for(int i = 1; i < m+1; i++){
    if(from1[i] == true && ton[i] == true){
      std::cout << "POSSIBLE";
      return 0;
    }
  }

  std::cout << "IMPOSSIBLE";

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <numeric>

using namespace std;
int H, W;
char S[2000][2000];
int field[2000][2000][4];

int main() {
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S[i][j];
    }
  }
  int mx = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '.') {
        // north
        if (i == 0) {
          field[i][j][0] = 1;
        } else {
          field[i][j][0] = field[i-1][j][0] + 1;
        }
        // west
        if (j == 0) {
          field[i][j][1] = 1;
        } else {
          field[i][j][1] = field[i][j-1][1] + 1;
        }
      }
      int k = H - 1 - i;
      int l = W - 1 - j;
      if (S[k][l] == '.') {
        // east
        if (l == W - 1) {
          field[k][l][2] = 1;
        } else {
          field[k][l][2] = field[k][l+1][2] + 1;
        }
        // south
        if (k == H - 1) {
          field[k][l][3] = 1;
        } else {
          field[k][l][3] = field[k+1][l][3] + 1;
        }
      }
      int tmp1 = accumulate(field[i][j], field[i][j] + 4, -3);
      int tmp2 = accumulate(field[k][l], field[k][l] + 4, -3);
      mx = max(mx, max(tmp1, tmp2));
    }
  }
  cout << mx << endl;
}

Measured memory_bytes: 66688
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

vector<int> v;
int k;

bool can(int len){
  if (len == 0) return false;
  int cnt = k;
  for (int i = v.size()-1;i >= 0;i--){
    if (v[i] > len) cnt -=(v[i]/len);
    if (cnt < 0) return false;
  }
  return true;
}
int main(){
  int n;
  cin >> n >> k;
  v.resize(n);
  rep(i,n) cin >> v[i];
  int l = 0,r = 1e9+1;
  for (int i = 0;i < 100;i++){
    int mid = (l+r)/2;
    if (can(mid)) r = mid;
    else l = mid;
  }
  cout << r << endl;
    
  return 0;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define line cout<<"----------------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll mx=200009;
ll n; 
ll val[mx],cost[mx]; 
ll maxi=0; 
void call(ll ind, ll sum, ll c)
{
    if(ind==n) 
    {
        maxi=max(maxi,sum-c);
        return ; 
    }
    call(ind+1,sum+val[ind],c+cost[ind]);
    call(ind+1,sum,c);
}
int main()
{
    cin>>n; 
    for(ll i=0;i<n;i++) cin>>val[i]; 
    for(ll i=0;i<n;i++) cin>>cost[i]; 
    call(0,0,0);
    cout<<maxi<<endl; 
}


Measured memory_bytes: 3584
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int n,k;
	ll ans=0,val,val1,i;
	cin>>n>>k;
	f(i,k+1,n+1){
		val=n/i;
		val1=n%i;
		if(val1>=k){
			ans+=(val+1)*(val1-k+1);
			ans+=val*(i-1-val1);
			// if(k==0){
			// 	ans-=;
			// }
		}
		else{
			ans+=(val)*(i-k);
			// if(k==0){
			// 	ans-=val;
			// }
		}
		if(k==0){
			ans--;
		}

		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
} 
	

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n,i,x;
    long min,max,sum;
    scanf("%d",&n);
    scanf("%d",&x);
    min = max = sum = x;
    for(i=1;i<n;i++){
        scanf("%d",&x);
        sum = x + sum;
        if(x<min){
            min = x;
        }else if(max<x){
            max = x;
        }
    }
    printf("%ld %ld %ld\n",min,max,sum);
    return 0;
}

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

int main() {
  string S;
  cin >> S;

  if (S.size() % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  bool even = false;
  for (char ch : S) {
    char hi = even ? 'i' : 'h';
    if (ch != hi) {
      cout << "No" << endl;
      return 0;
    }
    even = !even;
  }

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


Measured memory_bytes: 256
n=int(input())
a=[]
for i in range(n):
    x,y=map(int,input().split())
    a.append([x,y])
    
f=0
# print(a)
for i in range(n-2):
    if(a[i][0]==a[i][1]):
        if(a[i+1][0]==a[i+1][1]):
            if(a[i+2][0]==a[i+2][1]):
                f=1
                break
if f==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9168
#include <bits/stdc++.h>
//#define int long long

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

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>> a(2, vector<int>(n));
    REP(i, 2) REP(j, n) cin >> a[i][j];

    int ans = 0;
    REP(i, n){
        int cnt = 0;
        REP(j, i+1) cnt += a[0][j];
        for(int j = n-1; j >= i; j--) cnt += a[1][j];
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000

int p[N];
int d[N];

void init(void) {
	f(i, N) {
		p[i] = i;
		d[i] = 1;
	}
	return;
}

int pa(int x) {
	if (p[x] == x)return x;
	else return p[x] = pa(p[x]);
}


void uni(int x, int y) {
	int px = pa(x);
	int py = pa(y);
	if (px == py)return;
	if (d[px] < d[py]) {
		p[px] = py;
		d[py] = max(d[py], d[px] + 1);
	}
	else {
		p[py] = px;
		d[px] = max(d[px], d[py] + 1);
	}
	return;
}

bool jud(int x, int y) {
	int px = pa(x);
	int py = pa(y);
	if (px == py)return true;
	else return false;
}



int main() {
	int n, q;
	int x, y, z;
    bool v;
	scanf("%d", &n);
	init();
	scanf("%d", &q);
	f(qq, q) {
		scanf("%d %d %d", &z, &x, &y);
		if (z == 0) {
			uni(x, y);
		}
		else if (z == 1) {
			v = jud(x, y);
			if (v)printf("1\n");
			else printf("0\n");
		}
	}
	return 0;
}



Measured memory_bytes: 3220
# 726 diff 1000
# 解法 836 XYへ到達する場合はどの経路も合計の長さは同じ = 動き方1,2の合計は同じ．
# なので合計値 L がわかればLについてmove1=i,move2=L-iとして，実際の経路の構成の仕方は,L_C_iなので

move1 = [1,2]
move2 = [2,1]
X,Y = map(int,input().split())
# まず，目的地へ到達できるか？到達できる場合は合計どれだけの移動量が必要かを計算する
max_move1 = int(Y/2)
move2_num = -1
move1_num = -1
for i in range(max_move1+1):
    rest = [X-i,Y-2*i]
    if (X-i) == 2*(Y-2*i):
        move1_num = i
        move2_num = (Y-2*i)
if move1_num == -1:
    print(0)
    exit()

# 到達するのに必要な合計の移動量がわかったので，それらの並べ替えについて考える．
# 求めるのは nCk　すなわち，いつもの奴
large = 10**9 + 7
# mod(x^p-1,p) = 1 よってmod(x^p-2,p) = 1/x となる.
ans = 1
for i in range(move1_num):
    ans *= (move1_num+move2_num - i)
    ans %= large
for j in range(2,move1_num+1):
    ans *= pow(j,large-2,large)
    ans %= large
print(ans)


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


int main() {
  int w, h, n;
  cin >> w >> h >> n;
  int x[n], y[n], a[n];
  rep(i, n) cin >> x[i] >> y[i] >> a[i];
  
  vector<vector<bool>> s(h, vector<bool>(w));
  rep(i, n){
    if(a[i] == 1){
      rep(j, x[i]){
        rep(k, h) s[k][j] = true;
      }
    }
    if(a[i] == 2){
      for(int j = x[i]; j < w; j++){
        rep(k, h) s[k][j] = true;
      }
    }
    if(a[i] == 3){
      rep(j, y[i]){
        rep(k, w) s[j][k] = true;
      }
    }
    if(a[i] == 4){
      for(int j = y[i]; j < h; j++){
        rep(k, w) s[j][k] = true;
      }
    }
  }
  int cnt = 0;
  rep(i, h){
    rep(j, w){
      if(!s[i][j]) cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;

int main() {
int N,M;
cin>>N>>M;
int num_b[N+1];
bool red[N+1];
rep3(i,N){
  num_b[i]=1;
  if(i!=1){
    red[i]=false;
  }
  else{
    red[i]=true;
  }
}
rep(i,M){
  int x,y;
  cin>>x>>y;
  if(red[x]){
    if(num_b[x]>1){
      num_b[x]--;
      num_b[y]++;
      red[y]=true;
    }
    else{
      num_b[x]--;
      red[x]=false;
      num_b[y]++;
      red[y]=true;
    }

  }
  else{
    num_b[x]--;
    num_b[y]++;

  }
}
int count=0;
rep3(i,N){
  if(red[i])count++;
}
cout<<count<<endl;
return 0;
}

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

int main() {
  string s;
  cin>>s;
  if(s[0]==s[2]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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


int main(){

int N;
cin>>N;
vector<long long> A(N);

rep(i,N){
    cin>>A[i];
}
sort(A.begin(),A.end());

vector<pair<long long ,long long >>ope(N-1);
bool both=false;

if(A[0]<0 && A[N-1]>=0)both=true;

if(both){
    int p=0;
    for(int i=1;i<N-1;i++){
        if(A[i]<0){
            ope[p]=make_pair(A[N-1],A[i]);
            A[N-1]-=A[i];
        }
        else{
            ope[p]=make_pair(A[0],A[i]);
            A[0]-=A[i];
        }
        p++;
    }
    ope[N-2]=make_pair(A[N-1],A[0]);
    A[N-1]-=A[0];
    cout<<A[N-1]<<endl;
    for(int i=0;i<N-1;i++){
        cout<<ope[i].first<<" "<<ope[i].second<<endl;
    }
}
else if(A[0]>=0)
{   
    
    for(int i=1;i<N-1;i++){
        ope[i-1]=make_pair(A[0],A[i]);
        A[0]-=A[i];
    }
    ope[N-2]=make_pair(A[N-1],A[0]);
    A[N-1]-=A[0];
    cout<<A[N-1]<<endl;
    for(int i=0;i<N-1;i++){
        cout<<ope[i].first<<" "<<ope[i].second<<endl;
    }
}
else if(A[0]<0){
    for(int i=N-2;i>=0;i--){
        ope[N-2-i]=make_pair(A[N-1],A[i]);
        A[N-1]-=A[i];
    }

    cout<<A[N-1]<<endl;
    for(int i=0;i<N-1;i++){
        cout<<ope[i].first<<" "<<ope[i].second<<endl;
    }
}

 return 0;
}
/*
3
1 -1 2


4
-1 1
2 -2


3
1 1 1

1
1 1
1 0
*/

Measured memory_bytes: 4224
#include<stdio.h>
int main (){
	int n,i,j;
	int a[100];
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%d",&a[i]);
	}
	j = --n;
	while(1){
		printf("%d",a[j]);
		if(j <= 0)break;
		printf(" ");
		j--;
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <utility>
#include <tuple>
using namespace std;

using Graph = vector< vector<int> >;

void read_field(vector<char> &board, Graph &G) {
  int N, M; cin >> N >> M;
  board.resize(N);
  G.resize(N);

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

  for(int i=0; i<M; i++) {
    int u, v; cin >> u >> v;
    u--; v--;

    // directed !!!
    G[u].push_back(v);
  }
}

int rec[110][110];
struct Elem {
  int u1, u2, cost;
};

int main() {
  vector<char> A_char, B_char;
  Graph A_Graph, B_Graph;
  read_field(A_char, A_Graph);
  read_field(B_char, B_Graph);

  bool operate_inf = false;
  int N1 = A_char.size(), N2 = B_char.size();

  queue< Elem > que;

  // equal
  for(int i=0; i<N1; i++) {
    for(int j=0; j<N2; j++) {
      if(A_char[i] == B_char[j]) {
        rec[i][j] = 1;
        que.push(Elem{i, j, 1});
      }
    }
  }

  while(que.size()) {
    int u1, u2, p_cost;

    u1 = que.front().u1;
    u2 = que.front().u2;
    p_cost = que.front().cost;
    que.pop();
    
    if(p_cost < rec[u1][u2]) continue;
    if(rec[u1][u2] > max(N1, N2)) {
      operate_inf = true;
      break;
    }
    else {
      // move (both)
      for(auto v1 : A_Graph[u1]) {
        for(auto v2 : B_Graph[u2]) {
          char c1 = A_char[v1], c2 = B_char[v2];

          int cost = 0;
          if(c1 == c2) {
            cost = p_cost + 1;
          }
          else {
            cost = p_cost;
          }

          if(rec[v1][v2] < cost) {
            rec[v1][v2] = cost;
            que.push(Elem{v1, v2, cost});
          }
        }
      }

      if(A_char[u1] != B_char[u2]) {  
        // move (A)
        for(auto v1 : A_Graph[u1]) {
          int v2 = u2;

          char c1 = A_char[v1], c2 = B_char[v2];

          int cost = 0;
          if(c1 == c2) {
            cost = p_cost + 1;
          }
          else {
            cost = p_cost;
          }

          if(rec[v1][v2] < cost) {
            rec[v1][v2] = cost;
            que.push(Elem{v1, v2, cost});
          }
        }

        // move (B)
        for(auto v2 : B_Graph[u2]) {
          int v1 = u1;

          char c1 = A_char[v1], c2 = B_char[v2];

          int cost = 0;
          if(c1 == c2) {
            cost = p_cost + 1;
          }
          else {
            cost = p_cost;
          }

          if(rec[v1][v2] < cost) {
            rec[v1][v2] = cost;
            que.push(Elem{v1, v2, cost});
          }
        }
      }
    }
  }

  if(operate_inf) {
    cout << -1 << endl;
    return 0;
  }
  
  int ans = 0;
  for(int i=0; i<N1; i++) {
    for(int j=0; j<N2; j++) {
      // printf("%d ", rec[i][j]);
      ans = max(ans, rec[i][j]);
    }
    // cout << endl;
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 3340
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define y1 djsfah
using namespace std;
const int N=45;
int n;
char e[N][N];
ll f[N][N][N],ans;
int main(){
	scanf("%d",&n); n*=2;
	For(i,1,n) scanf("%s",e[i]+1);
	For(i,1,n) For(j,1,n) e[i][j]-='0';
	For(i,1,n) f[i][i][i]=1;
	for (int l=1;l<=n;l+=2)
		for (int i=1;i+l-1<=n;i++){
			int j=i+l-1;
			for (int k=i;k<=n;k+=2)
				for (int l=j;l>k;l-=2){
					ll S=0;
					For(p1,i,k) For(p2,l,j)
						if (e[p1][p2]) S+=f[i][k][p1]*f[l][j][p2];
					For(p1,k+1,l-1)
						f[i][j][p1]+=f[k+1][l-1][p1]*S;
				}
		}
	For(i,2,n)
		if (e[1][i])
			ans+=f[2][n][i];
	printf("%lld\n",ans);
}

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = (c + b - 1) / b;
  int y = (a + d - 1) / d;
  if (x > y)
    puts("No");
  else
    puts("Yes");

  return 0;
}


Measured memory_bytes: 3564
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 262144
#define REP(i,n) for(long long i = 0;i < n;++i)
long long pan[300000];
long long azi[300000];
long long value[300000];
vector<pair<long long,long long>> vertexs[200000];
long long dist[300000] = {};
int visited[300000];
long long dp[300000] = {};
long long ans[300000];
int main() {
#define int long long
	int n, m, k;
	cin >> n >> m >> k;
	REP(i, n) {
		cin >> pan[i];
	}
	REP(i, n) {
		cin >> azi[i];
		azi[i]--;
	}
	REP(i, n) {
		cin >> value[i];
		dist[i] = LONG_INF;
	}
	REP(i, k) {
		ans[i] = -LONG_INF;
	}
	dist[0] = 0;
	REP(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		vertexs[a].push_back(make_pair(b, c));
		vertexs[b].push_back(make_pair(a, c));
	}
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> first_next;
	first_next.push(make_pair(0, 0));
	while (first_next.empty() == false) {
		int now = first_next.top().second;
		first_next.pop();
		if (visited[now] == 1) continue;
		visited[now] = 1;
		for (int q = 0; q < vertexs[now].size(); ++q) {
			int cost = dist[now] + vertexs[now][q].second;
			if (dist[vertexs[now][q].first] > cost) {
				dist[vertexs[now][q].first] = cost;
				first_next.push(make_pair(cost, vertexs[now][q].first));
			}
		}
	}
	priority_queue<pair<int, int>> next;
	REP(i, n) {
		visited[i] = 0;
		dp[i] = pan[i] - dist[i];
		next.push(make_pair(dp[i], i));
	}
	while (next.empty() == false) {
		int now = next.top().second;
		next.pop();
		if (visited[now] == 1) continue;
		visited[now] = 1;
		for (int q = 0; q < vertexs[now].size(); ++q) {
			int cost = dp[now] - vertexs[now][q].second;
			if (dp[vertexs[now][q].first] < cost) {
				dp[vertexs[now][q].first] = cost;
				next.push(make_pair(cost, vertexs[now][q].first));
			}
		}
	}
	REP(i, n) {
		ans[azi[i]] = max(ans[azi[i]],dp[i] + value[i] - dist[i]);
	}
	REP(i, k) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 25632
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
 	string s;
 	cin>>s;
 	if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes"<<endl;
 	else cout<<"No"<<endl;	   
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Study0001
{
    class Program
    {
        static void Main(string[] args)
        {
            int inputNum = int.Parse(Console.ReadLine());

            var inputs = new List<string>();
            for (int i = 0; i < inputNum; i++)
            {
                inputs.Add(Console.ReadLine());
            }

            foreach (var input in inputs)
            {
                var parts = input.Split(' ');
                int a = int.Parse(parts[0]);
                int b = int.Parse(parts[1]);
                int c = int.Parse(parts[2]);

                bool ischeck = false;
                if (a >= b && a >= c)
                {
                    ischeck = a * a == b * b + c * c;
                }
                else if (b >= c && b >= a)
                {
                    ischeck = b * b == a * a + c * c;
                }
                else if (c >= a && c >= b)
                {
                    ischeck = c * c == a * a + b * b;
                }

                if (ischeck)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }

            //Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9084
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MAXD=110000;
int c[MAXD];

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

	int N;
	cin>>N;
	
	int arc=0,abc=0;
	rep(i,0,N) {
		int d;
		cin>>d;
		c[d]++;
		abc++;
	}
	
	
	int res=0;
	per(k,1,MAXD) {
		arc+=c[k];
		abc-=c[k];
		if (arc==abc) res++;
	}
	cout<<res<<"\n";
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    int count=0;
    for(int i=0;i<n;i+=2)
    {
        if(a[i]%2!=0)
            count++;
    }
    printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 3808
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    string siin = "w kstnhmyr";
    string boin = "aiueo";

    vector<int> index(128, -1);
    index['T'] = 0;
    index['L'] = 1;
    index['U'] = 2;
    index['R'] = 3;
    index['D'] = 4;

    string s;
    cin >> s;
    int n = s.size();

    for(int i=0; i<n; i+=2){
        if(s[i] == '1'){
            cout << boin[index[s[i+1]]];
        }else if(s[i] == '0' && s[i+1] == 'U'){
            cout << "nn";
        }else{
            cout << siin[s[i]-'0'] << boin[index[s[i+1]]];
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1188
n = int(input())
a = sorted(map(int, input().split()))

cnt = [0] * (a[-1] + 1)
for i in a:
    cnt[i] += 1
for i in set(a):
    if cnt[i] >= 1:
        for j in range(i * 2, a[-1] + 1, i):
            cnt[j] = 0
print(cnt.count(1))


Measured memory_bytes: 39504
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,odc=0;
  cin >> n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%2==1){
      odc++;
    }
  }
  if(odc>=1){
    cout <<"first\n";
  }else{
    cout <<"second\n";
  }
}


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

int main(){
  ios::sync_with_stdio(false);
  string str, w;
  int num = 0;
  cin >> w;
  transform(w.begin(), w.end(), w.begin(), ptr_fun<int, int>(tolower));
  for(;;){
    cin >> str;
    if(str == "END_OF_TEXT"){ break; }
    transform(str.begin(), str.end(), str.begin(), ptr_fun<int, int>(tolower));
    if(w == str)
      num++;
  }
  cout << num << endl;
  return 0;
}

Measured memory_bytes: 1192
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
  
struct node{
    unsigned int key;
    struct node *next;
    struct node *prev;
};
  
typedef struct node * NodePointer;
  
NodePointer nil;
  
NodePointer listSearch(int key){
    NodePointer cur = nil->next;
    while (cur != nil && key != cur->key)
        cur = cur->next;
    return cur;
}
  
void init(){
    nil = (NodePointer)malloc(sizeof(struct node));
    nil->next = nil;
    nil->prev = nil;
}
  
void printList(){
    NodePointer cur = nil->next;
    int isf = 1;
    while (1){
        if (cur == nil) break;
        if (isf == 0)  printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
        isf = 0;
    }
    printf("\n");
}
  
void deleteNode(NodePointer t){
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}
  
void deleteFirst(){
    NodePointer t = nil->next;
    if (t == nil) return;
    deleteNode(t);
}
  
void deleteLast(){
    NodePointer t = nil->prev;
    if (t == nil) return;
    deleteNode(t);
}
  
void delete(int key){
    NodePointer t = listSearch(key);
    if (t == nil)return;
    deleteNode(t);
}
  
  
void insert(int key){
    NodePointer x;
    x = (NodePointer)malloc(sizeof(struct node));
    x->key = key;
  
    x->next=nil->next;
    nil->next->prev = x;
    x->prev = nil;
    nil->next = x;
}
  
int main(){
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for (i = 0; i < n; i++){
        scanf("%s%d", com, &key);
        if (com[0] == 'i') { insert(key); np++; size++; }
        else if (com[0] == 'd') {
            if (strlen(com) > 6){
                if (com[6] == 'F') deleteFirst();
                else if (com[6] == 'L') deleteLast();
            }
            else {
                delete(key); nd++;
            }
            size--;
        }
    }
  
    printList();
    return 0;
}

Measured memory_bytes: 31788
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{

     ll a,b,x,i,j,k,dif,mn,f=0;
     cin>>x;
     for(i=-120;i<=120;i++)
     {
         for(j=-120;j<=120;j++)
         {
             if(pow(i,5)-pow(j,5)==x)
             {
                 cout<<i<<" "<<j<<endl;
                 f=1;
                 break;
             }
         }
         if(f==1)
            break;
     }
    return 0;
}



Measured memory_bytes: 4100
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int arr[101] = {0};

int main()
{
	long long int n, a, b, total=0;
	cin >> n >> a >> b;
	total = n/(a+b)*a;
	n %= (a+b);
	if(n > a)
	{
		total += a;
	}
	else
	{
		total += n;
	}
	cout << total;
}



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

using namespace std;

int main() {
  int N;
  
  cin >> N;
  
  vector<int> l;
  
  for (int i = 0; i < N; i++) {
    int _in;
    
    cin >> _in;
    
    l.push_back(_in);
  }
  
  double u = 0;
  
  for (int i = 0; i < N; i++) {
    u += 1.0 / l[i];
  }
  
  cout << 1.0 / u << endl;
  
  return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X;
  cin >> X;
  bool res = false;
  for (int i = 100; i < 105; i++){
    int j = i + 1;
    for (int k = 0; i * k <= X; k++){
      if ((X - i * k) % j == 0) res = true;
    }
  }
  if (res){
    cout << 1;
  } else {
    cout << 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string S, T;
    cin >> S >> T;
    int a = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) a++;
    }
    cout << a << endl;
}

Measured memory_bytes: 3856
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll a, b; cin >> a >> b;
  if (a == b) cout << "Draw" << endl;
  else if (a == 1) cout << "Alice" << endl;
  else if (b == 1) cout << "Bob" << endl;
  else if (a < b) cout << "Bob" << endl;
  else cout << "Alice" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B,C;
    cin >> A >> B >> C;

    cout << max(0,C-A+B) << endl;



}


Measured memory_bytes: 256
// ABC139_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N;
    cin >> N;
    vector<ll> vec(N);
    REP(i, N) cin >> vec[i];
    
    // calculation
    if (N == 1) {
        cout << 0 << "\n";
    } else {
        ll res = 0, sm = 0;
        for (ll i = 1; i < N; ++i) {
            if (vec[i-1] >= vec[i]) {
                sm++;
            } else {
                res = max(res, sm);
                sm = 0;
            }
        }
        res = max(res, sm);
        cout << res << "\n";
    }
    
    return 0;
}

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

int MOD=1000000007;
 
int main() {
  int N;
  string S,A;
  cin >> N >> S >> A;
  long long ans;
  int i=0;
  bool cur;
  if (S[0]==S[1]){
    ans=6;
    i++;
    cur=true;
  }
  else {
    ans=3;
    cur=false;
  }
  S+='0';
  while (i<N-1){
    if (S[i+1]!=S[i+2]&&!cur){
      ans=ans*2%MOD;
      i++;
      cur=false;
    }
    else if (S[i+1]==S[i+2]&&!cur){
      ans=ans*2%MOD;
      i+=2;
      cur=true;
    }
    else if (S[i+1]!=S[i+2]&&cur){
      i++;
      cur=false;
    }
    else if (S[i+1]==S[i+2]&&cur){
      ans=ans*3%MOD;
      cur=true;
      i+=2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

int main () {
	ios_base::sync_with_stdio(0);
//	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);

    int n, m, k;
    cin >> n >> m >> k;

    bool key = false;
    for (int i = 0; i <= n; ++i) {
    	for (int j = 0; j <= m; ++j) {
    		if (i * m + j * n - 2 * i * j == k) {
    			key = true;
    			break;
    		}
    	}
    	if (key) {
    		break;
    	}
    }

    cout << (key ? "Yes" : "No") << "\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    int x, y;
    cin >> x >> y;

    ll res = 0;
    if(x == 1){
        res += 300000;
    }else if(x == 2){
        res += 200000;
    }else if(x == 3){
        res += 100000;
    }

    if(y == 1){
        res += 300000;
    }else if(y == 2){
        res += 200000;
    }else if(y == 3){
        res += 100000;
    }

    if(x==1 && y == 1){
        res += 400000;
    }
    cout << res << endl;

    return 0;
}


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

int n, a[300010];
deque <int> wl;
long long ans = 0;

int main() {
    scanf("%d", &n);
    for(int i = 0; i < 3*n; i++) scanf("%d", &a[i]);
    sort(a, a + 3*n);
    for(int i = 0; i < 3*n; i++) wl.push_back(a[i]);
    for(int i = 0; i < n; i++) {
        wl.pop_front(); wl.pop_back();
        ans += wl.back(); wl.pop_back();
    }
    printf("%lld", ans);
}

Measured memory_bytes: 2688
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        boolean[] test = new boolean[N];
        int count1 = 0;
        int count2[] = new int[N];
        int count3 = 0;
        
        for(int i=0; i<M; i++){
            int p = sc.nextInt();
            String str = sc.next();
            if(!test[p-1] && str.equals("AC")){
                count1++;
                test[p-1] = true;
            }else if(!test[p-1] && str.equals("WA")){
                count2[p-1]++;
            }
        }
        for(int i=0; i<N; i++){
            if(!test[i]){
                count2[i]=0;
            }
            count3 += count2[i];
        }
        System.out.println(count1+" "+count3);
    }
}

Measured memory_bytes: 60304
#!/usr/bin/env python3

# from typing import Optional
# from typing import List
# from typing import Dict
# from typing import Tuple
# from typing import Sequence


def main():
    args = input().split()
    D = int(args[0])
    T = int(args[1])
    S = int(args[2])

    time = D / S
    if T >= time:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9164
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const int MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	cin >> n;
	ll mod = n % 11;
	ll ans = n / 11 * 2;
	if (mod >= 7) ans += 2;
	else if (mod > 0) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    vll a(n);
    REP(i,n){
        cin >> a[i];
    }
    sort(rALL(a));
    vll sum(n+1,0LL);
    REP(i,n){
        sum[i+1] = sum[i]+a[i];
    }
    ll ok = LLINF;
    ll ng = -1;
    ll okcnt = 0;
    ll okt = 0;
    while(abs(ok-ng)>1){
        ll mid = (ok+ng)/2;
        ll t = 0;
        ll cnt = 0;
        REP(i,n){
            ll oki = -1;
            ll ngi = n;
            while(abs(oki-ngi)>1){
                ll midi = (oki+ngi)/2;
                if(a[i]+a[midi]>=mid){
                    oki = midi;
                }else{
                    ngi = midi;
                }
            }
            t += sum[oki+1]+(oki+1)*a[i];
            cnt+=oki+1;
        }
        if(cnt<=m){
            ok = mid;
            okcnt = cnt;
            okt = t;
        }else{
            ng = mid;
        }
    }
    ll ans = okt;
    if(okcnt<m){
        ans += (m-okcnt)*ng;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

#define rep(i, n)	for(int i=0;i<int(n);i++)
#define repn(i, n)	for(int i=1;i<=int(n);i++)
#define set(i, n)	memset(i, n, sizeof(i))

#define pb	push_back
#define f	first
#define s	second

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int N = 5005;
const int oo = 1e6;

int dp[N][N];
int n, a[N], k;

bool OK(int pos){
	if(a[pos] >= k) return false;
	int val = a[pos]; a[pos] = 0;
	int need = k  - val;
	for(int i=0;i<=n;i++) for(int j=0;j<=need;j++) dp[i][j] = oo;
	for(int i=0;i<=n;i++) dp[i][0] = 0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=need;j++){
			dp[i][j] = min(dp[i][j], dp[i-1][j]);
			int f = min(need, j + a[i]);
			dp[i][f] = min(dp[i][f], dp[i-1][j] + a[i]);
		}
	}
	/*
	cout << "#" << val << endl;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=need;j++){
			printf("%7d", dp[i][j]);
		}
		printf("\n");
	}
	*/
	bool ret = false;
	if(dp[n][need] >= k) ret = 1;
	a[pos] = val;
	return ret;
}

int main(){
	scanf("%d %d", &n, &k);
	repn(i, n) scanf("%d", &a[i]);
	sort(a+1, a+1+n);
	int lo = 1, hi = n, ret = 0;
	while(lo <= hi){
		int mid = (lo + hi) / 2;
		if(OK(mid)) ret = mid, lo = mid + 1;
		else hi = mid - 1;
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 98176
a = [int(input())]

i = 0
while True:
    if a[i]%2 == 0:
        a.append(int(a[i]/2))
    else:
        a.append(int((3*a[i])+1))
    if a.count(a[i]) == 2:
        break
    i += 1

print(i+1)

Measured memory_bytes: 9156
#include<stdio.h>
int main()
{
    int N,K;
    int ans=1;
    int i;
    // 整数の入力
    scanf("%d", &N);
    scanf("%d", &K);

    for(i=0;i<N;i++){
      if(ans+K > ans *2 ){
         ans =  ans * 2;
        }
      else {
        ans = ans + K;
        }
    }

    // 出力
    printf("%d\n", ans);
    return 0;
}

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

int main()
{
  int A = 0;
  char s;
  while (cin >> s)
  {
    if (s == '+')
    {
      A++;
    }
    else if (s == '-')
    {
      A--;
    }
  }
  cout << A << endl;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
int main() {
	int i,j,k,n,imin=0;
	int minn=INT_MAX;
	int maxx=INT_MIN;
	cin>>n>>k;
	int dp[k+1];
	int arr[n];
	for(i=0;i<=k;i++){
	    dp[i]=1;
	}
	for(i=0;i<n;i++){
	    cin>>arr[i];
	    if(arr[i]<minn){
	        imin=i;
	        minn=arr[i];
	    }
	    dp[arr[i]]=0;
	}
	for(i=imin+1;i<=k;i++){
	    if(dp[i]!=0){
    	    for(j=0;j<n;j++){
    	        if(i>=arr[j] && dp[i-arr[j]]==1){
    	            dp[i]=0;
    	            break;
    	        }
    	    }
	    }
	}
	if(dp[k]==0){
	    cout<<"First";
	}
	else{
	    cout<<"Second";
	}
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
  long long int h;
  scanf("%lld",&h);
  long int i;
  for(i=1;;i++)
  {
    if(h==1)
      break;
    h=h/2;
  }
  i=i-1;
  long long int sum=1; 
  for(long int j=1;j<=i;j++)
  {
     sum=sum*2;
  }
  printf("%lld",2*(sum-1)+1);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,t;cin>>n>>t;
    vector<ll> d(n);
    rep(i,0,n)cin>>d[i];
    ll ans=1;
    sort(d.begin(),d.end());
    rrep(i,n-1,0){
        ll y=lower_bound(d.begin(),d.end(),d[i]-t)-d.begin();
        (ans*=i-y+1)%=mod;
    }
    cout<<ans<<endl;
}







Measured memory_bytes: 3540
def main():
    A = list(map(int, input().split()))
    cnt = 0
    while 1:
        A.sort()
        if(A[0] == A[1] and A[1] == A[2]):
            break
        else:
            if(A[0] < A[2] and A[1] < A[2]):
                A[0] = A[0] + 1
                A[1] = A[1] + 1
                cnt = cnt + 1
            else:
                A[0] = A[0] + 2
                cnt = cnt + 1

    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064