akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD 1000000007
// Use cout.flush() for interactive problems.
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
ll h, w;
char a[1005][1005];
ll dp[1005][1005];
ll compute(int i, int j)
{
    if(i==h-1&&j==w-1) return dp[i][j] = 1;
    if(dp[i][j]!=-1) return dp[i][j];
    ll ans = 0;
    if(i!=h-1&&a[i+1][j]=='.') 
    {
        ans += compute(i+1, j);
        ans %= MOD;
    }
    if(j!=w-1&&a[i][j+1]=='.')
    {
        ans += compute(i, j+1);
        ans %= MOD;
    }
    return dp[i][j] = ans;
    
}
int main()
{
    she_told_me_dont_worry
    cin>>h>>w;
    ll i, j;
    FOR0(i, h)
    {
        string s;
        cin>>s;
        FOR0(j, w)
        {
            a[i][j] = s[j];
            dp[i][j] = -1;
        }
    }
    cout<<compute(0, 0);
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 9216
Dataset = [2**i for i in range(18)]
def kakuritsu(n, K):
    for i, data in enumerate(Dataset):
        if n*data >= K:
            return (1/2)**i

N, K = map(int, input().split())
total = 0
for i in range(1, N+1):
    total += kakuritsu(i, K)
print(total/N)

Measured memory_bytes: 3060
unittest
{
	assert( [ "3 4", "4 3", "4 1", "2 2" ].parse.expand.solve == 5 );
	assert( [ "5 3", "1 2", "1 3", "1 4", "2 1", "2 3" ].parse.expand.solve == 10 );
	assert( [ "1 1", "2 1" ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	auto abs = new long[ 2 ][ nm[ 0 ] ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
	}
	return tuple( nm[ 1 ], abs );
}

auto solve( long m, long[ 2 ][] abs )
{
	abs.sort();
	
	auto ans = 0L;
	auto bs = heapify( new long[ abs.length ], 0 );
	foreach( d; 1L .. m + 1 )
	{
		while( !abs.empty && abs.front[ 0 ] <= d )
		{
			bs.insert( abs.front[ 1 ] );
			abs.popFront;
		}
		if( bs.empty ) continue;
		ans += bs.front;
		bs.popFront;
	}
	return ans;
}


Measured memory_bytes: 5372
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define rei(n) for(int i=0;i<(int)n;i++)
#define rel(n) for(int l=0;l<(int)n;l++)
#define all(s) s.begin(),s.end()
#define INT_MAX 2147483647
#define debug(x) cout<<#x<<": "<<x<<endl;
#define PI 2*acos(0,0)
#define pb push_back
#define inin(x) int x; cin>>x;
#define ll long long
#define pb push_back

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

int main()
{
	string a;
	while (cin >> a)
	{
		int ansj = 0, ansi = 0;
		for (int i = 0; i < a.size() - 2; i++)
		{
			if (a[i] == 'J'&&a[i + 1] == 'O'&&a[i + 2] == 'I')ansj++;
			if (a[i] == 'I'&&a[i + 1] == 'O'&&a[i + 2] == 'I')ansi++;
		}
		cout << ansj << endl;
		cout << ansi << endl;
	}
}

Measured memory_bytes: 1200
#include <stdio.h>

int main()
{
	char b;

	scanf("%c", &b);

	switch (b) {
	case 'A':
		printf("T\n");
		break;
	case 'T':
		printf("A\n");
		break;
	case 'C':
		printf("G\n");
		break;
	case 'G':
		printf("C\n");
		break;
	}

	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    private static int INF = 100100100;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[][] key = new int[M][2];
        for (int i = 0; i < M; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            key[i][0] = a; // cost
            int s = 0;
            for (int j = 0; j < b; j++) {
                int c = sc.nextInt();
                s |= 1 << (c-1);
            }
            key[i][1] = s; // set
        }

        int size = 1 << N;
        int[] dp = new int[size];
        Arrays.fill(dp, INF);
        dp[0] = 0;
        for (int s = 0; s < size; s++) {
            for (int j = 0; j < M; j++) {
                int t = s | key[j][1];
                dp[t] = Math.min(dp[t], dp[s]+key[j][0]);
            }
        }
        
        System.out.println(dp[size-1] == INF ? -1 : dp[size-1]);
    }
}


Measured memory_bytes: 32480
def check(H, A, B, n):
    cnt = 0
    for h in H:
        v = max(0, h - n * B)
        cnt += (v + A - B - 1) / (A - B)
    if cnt <= n:
        return True
    else:
        return False

N, A, B = map(int, raw_input().split())
H = [int(raw_input()) for _ in range(N)]

nmax = 10 ** 10
nmin = 0
while nmax - nmin > 1:
    n = (nmax + nmin) / 2
    if check(H, A, B, n):
        nmax = n
    else:
        nmin = n
print nmax


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

C=[]
A=[]
for i in range(n):
	t = list(map(int, input().split()))
	C.append(t[0])#price of books
	A.append(t[1:])#point of books
	
result = 10**9 #結果の初期値
#N冊の本買う/買わない　を総当たり
for i in range(1<<n):#range(0,2**n)と同意
	t = [0] * m #理解度m個
	c = 0 #値段0
	#1-n冊目までをシフト演算
	for j in range(n):
		if (i>>j)&1:#購入している場合
			for k in range(m):
				t[k] += A[j][k]#各理解度をインプット
			c += C[j] #購入した本の値段を足していく
		else:
			pass
	if min(t)>=x:
		result=min(result, c)
if result == 10**9:
	print(-1)
else:
	print(result)

Measured memory_bytes: 9164
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
using namespace std;

int main(){
    int n ;
    cin >> n ;
    vector<int> p(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> p.at(i) ;
    }
    int min = p.at(0) ;
    int ans = 0 ;
    for (size_t i = 0; i < n; i++)
    {
        if (p.at(i) <= min)
        {
            min = p.at(i) ;
            ans ++ ;
        }
        
    }
    cout << ans << endl ;
}    

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w,m;
string s,s1,s2;
//vvl v;
//vl vis,d;
vl a,v;
ll dp[101][100001],f[101][100001];

int main() {
    IOS;
    cin>>n>>k;
    a.resize(n+1);
    fo(i,n)cin>>a[i+1];
    f[1][0]=1;
    for(int i=0;i<=k;i++){dp[1][i]=(i<=a[1]);if(i>0)f[1][i]=f[1][i-1]+dp[1][i];}
    for(int i=2;i<=n;i++){
        for(int j=0;j<=k;j++){
            dp[i][j]=f[i-1][j]-(j>=a[i]+1?f[i-1][j-a[i]-1]:0)+mod;dp[i][j]%=mod;
            f[i][j]=(j>0?f[i][j-1]:0)+dp[i][j];f[i][j]%=mod;
            //cout<<dp[i][j]<<" "<<i<<" "<<j<<el;
        }
    }
    cout<<dp[n][k];
    return 0;
}


Measured memory_bytes: 157312
#include<cstdio>
#include<algorithm>
using namespace std;
int n,k;
long long sum;
int main() {
	scanf("%d %d",&n,&k);
	if(k==0) {
		printf("%lld\n",(long long)n*n);
		return 0;
	}
	for(int b=k+1;b<=n;b++) {
		int a=n%b;
		if(k<=a) sum+=a-k+1;
		sum+=n/b*(b-k);
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		scan.close();
		int c = 0;
		for (int a = 1; a < 10; a++) {
			for (int b = 1; b < 10; b++) {

				if (a * b == n)
					c = 1;

			}
		}
		if (c == 1)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

char ask(const vector<int>& A) {
  cout << "? " << A << endl;
  string s;
  cin >> s;
  return s[0];
}

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

  vector<int> A(N);
  iota(A.begin(), A.end(), 1);
  char lc = ask(A);
  iota(A.begin(), A.end(), N + 1);
  char rc = ask(A);
  int l = 1, r = N + 1;
  vector<char> ans(N * 2 + 1);
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    iota(A.begin(), A.end(), mid);
    if (ask(A) == lc)
      l = mid;
    else
      r = mid;
  }
  ans[l] = lc;
  ans[l + N] = rc;
  iota(A.begin(), A.end(), l);
  for (int i = 1; i < l; ++i) {
    A[0] = i;
    ans[i] = ask(A);
  }
  for (int i = l + N + 1; i <= N * 2; ++i) {
    A[0] = i;
    ans[i] = ask(A);
  }
  iota(A.begin(), A.end(), l + 1);
  for (int i = l + 1; i < l + N; ++i) {
    auto it = find(A.begin(), A.end(), i);
    *it = l;
    ans[i] = ask(A) == 'R' ? 'B' : 'R';
    *it = i;
  }
  cout << "! ";
  for (int i = 1; i <= N * 2; ++i)
    cout << ans[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 724
import java.awt.geom.Point2D;
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new aoj2151().doIt();
    }
    class aoj2151{
    	Ee d_e[][] = new Ee[101][101];
    	int dist[][] = new int[101][101];
    	int INF = Integer.MAX_VALUE/2;
    	PriorityQueue<Pos> q = new PriorityQueue<Pos>();
    	int dikstra(int N,int L){
    		int result = Integer.MAX_VALUE;
    		for(int i = 0;i < N;i++)Arrays.fill(dist[i], INF);
    		dist[0][L] = 0;
    		while(q.size() > 0){
    			Pos p = q.remove();
//    			System.out.println(p.v+" "+p.money+" "+p.enemy);
    			if(p.v == N-1)result = Math.min(result, p.enemy);
    			for(int i = 0;i < N;i++){
    				if(d_e[i][p.v].money == 0)continue;
    				if(p.v == i)continue;
    				if(p.money < d_e[i][p.v].money){
    					if(dist[i][p.money] <= p.enemy + d_e[i][p.v].enemy)continue;
    					dist[i][p.money] = p.enemy + d_e[i][p.v].enemy;
    					q.add(new Pos(i,p.money,p.enemy + d_e[i][p.v].enemy));
    				}else{
    					int mo = p.money - d_e[i][p.v].money;
    					if(dist[i][mo] > p.enemy){
    						dist[i][mo] = p.enemy;
    						q.add(new Pos(i,mo,p.enemy));
    					}
    					if(dist[i][p.money] > p.enemy + d_e[i][p.v].enemy){
    						dist[i][p.money] = p.enemy + d_e[i][p.v].enemy;
    						q.add(new Pos(i,p.money,p.enemy + d_e[i][p.v].enemy));
    					}
    				}
    			}
    		}
    		return result;
    	}
    	void set(){
    		for(int i = 0;i < 101;i++){
    			for(int j = 0;j < 101;j++){
    				d_e[i][j] = new Ee(0,0);
    			}
    		}
    	}
    	void doIt(){
    		while(true){
    			int N = sc.nextInt();
    			int M = sc.nextInt();
    			int L = sc.nextInt();
    			if(N+M+L == 0)break;
    			set();
    			q.add(new Pos(0,L,0));
    			for(int i = 0;i < M;i++){
    				int s = sc.nextInt()-1;
    				int e = sc.nextInt()-1;
    				Ee E = new Ee(sc.nextInt(),sc.nextInt());
    				d_e[s][e] = E;
    				d_e[e][s] = E;
    			}
    			System.out.println(dikstra(N,L));
    		}
        }
    	class Ee{
    		int money,enemy;
    		public Ee(int money,int enemy){
    			this.money = money;
    			this.enemy = enemy;
    		}
    	}
    	class Pos implements Comparable<Pos>{
    		int v,money,enemy;
    		public Pos(int v,int money,int enemy){
    			this.v = v;
    			this.money = money;
    			this.enemy = enemy;
    		}
    		public int compareTo(Pos o){
    			return this.enemy - o.enemy;
    		}
    	}
     }
}

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

ll MOD = 1e9+7;
int main()
{
    int N;
    cin >> N;
    vector<ll> nums(0);
    vector<vector<ll>> bitCount(60, vector<ll>(2, 0));
    for(int i = 0; i < N; i++)
    {
        ll a;
        cin >> a;
        for(int j = 0; j < 60; j++)
        {
            bitCount.at(j).at(a & 1)++;
            a >>= 1;
        }
    }
    ll total = 0;
    ll baseNum = 1;
    for(int i = 0; i < 60; i++)
    {
        total = (total + ((baseNum * bitCount.at(i).at(0)) % MOD) * bitCount.at(i).at(1)) % MOD;
        baseNum = (baseNum * 2) % MOD;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;

struct pruk{
	int piname;
	bool operator==(const pruk pr)
	{
		return piname==pr.piname;
	}
	bool operator>(const pruk pr)
	{
		return piname>pr.piname;
	}
};

int main()
{
	pruk a,b;
	scanf("%d %d",&a.piname,&b.piname);
	if(a.piname==1)a.piname=14;
	if(b.piname==1)b.piname=14;
	if(a==b)puts("Draw");
	else if(a>b)puts("Alice");
	else puts("Bob");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<vector>
#include<math.h>
#include<iomanip>
#include<bitset>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)
#define ll long long

struct edge{int to; double cost; };
typedef pair<double, pair<int, int> > pii;

ll INF = 10e17;
ll n, m, p, a, b;
vector<edge> g[30];
double d[30][1<<8];
int ticket[8];

void dijkstra(int s){
    priority_queue<pii, vector<pii>, greater<pii> > que;
    REP(i, m) REP(j, 1<<n) d[i][j] = INF;
    d[s][0] = 0;
    que.push(pii(0, make_pair(s, 0)));

    while(!que.empty()){
        pii p = que.top(); que.pop();
        int v = p.second.first;
        int t = p.second.second;
        if(d[v][t]<p.first) continue;
        REP(i, g[v].size()){
            edge e = g[v][i];
            REP(l, n){
                if((t>>l) % 2 == 0){
                    if(d[e.to][t|(1<<l)] > d[v][t] + e.cost / ticket[l]){
                        d[e.to][t|(1<<l)] = d[v][t] + e.cost / ticket[l];
                        que.push(pii(d[e.to][t|(1<<l)], make_pair(e.to, t|(1<<l))));
                    }
                }
            }
        }
    }
}

int main(){
    while(1){
        cin >> n >> m >> p >> a >> b;

        if(n==0) break;

        REP(i, n) cin >> ticket[i];
        REP(i, m) g[i].clear();
        REP(i, p){
            int x, y, z;
            cin >> x >> y >> z;
            edge e;
            e.to = y-1; e.cost = z;
            g[x-1].push_back(e);
            e.to = x-1;
            g[y-1].push_back(e);
        }

        dijkstra(a-1);
        double output = INF;
        REP(i, 1<<n){
            output = min(d[b-1][i], (double)output);
        }
        
        if(output==INF){
            cout << "Impossible" << endl;
        } else {
            cout << fixed << setprecision(4) << output << endl;
        }
    }
}

Measured memory_bytes: 4572
#include <iostream>
#include "string.h"
using namespace std;
int main(){
int n,cnt=0,Max=0;
string s;
cin>>n>>s;
if(0<n<=100){
for(int i=0; i<n; i++){
   if(s[i]=='I'){
         cnt++;
   }
   else{
        cnt--;
}
        if(Max<cnt){
        Max=cnt;

}
}
    cout<<Max<<endl;

}
}


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

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        int[] W = new int[N];

        for (int i = 0; i < N; i++) {
            W[i] = int.Parse(s.Split(' ')[i]);
        }

        //回答となる数値
        int ans = 1000000000;

        //以下のグループ
        int under;
        //以上のグループ
        int over;

        //すべてのTについて、検証する
        for (int T = 0; T < N; T++) {
            under = 0;
            over = 0;
            for (int i = 0; i <= T; i++) {
                under += W[i];
            }
            for (int i = T + 1; i < N; i++) {
                over += W[i];
            }
            ans = Math.Min(ans, Math.Abs(under - over));
        }

        //出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner cin = new Scanner(System.in);
		
		int N = cin.nextInt();
		Set<String> S = new HashSet<>();
		for(int i = 0;i<N;i++) S.add(cin.next());
		
		System.out.println(S.size());
		
	}

}


Measured memory_bytes: 76908
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;

int main(){
	int n, cnt1, ans, xin, yin;
	ans = 0;
	bool flag;
	cin >> n;

	vector<int> an(n);
	vector<vector<int>> x(n);
	vector<vector<int>> y(n);
	for(int i=0; i<n; i++){
		cin >> an[i];
		for(int j=0; j<an[i]; j++){
			cin >> xin >> yin;
			x[i].push_back(xin);
			y[i].push_back(yin);
		}
	}
	for(int bit=0; bit<(1<<n); bit++){
		flag = true;
		for(int i=0; i<n; i++){
			if(!(bit & (1<<i))){
			//	cout << "LINE: "<< __LINE__ << ", bit: " << bit<< endl;
				continue;
			}
			for(int j=0; j<an[i]; j++){
				if(y[i][j]==0){
					if(bit & 1<<(x[i][j]-1)){
						flag = false;
					}
				}else{
					if(!(bit & 1<<(x[i][j]-1))){
						flag = false;
					}
				}
			}
		}

		if(flag){
			//cout << "true bit: " << bit << endl;
			cnt1 = 0;
			for(int i=0; i<n; i++){
				if(bit & (1<<i)){
					cnt1++;
				}
			}
			ans = max(ans, cnt1);

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

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
AB = [tuple(map(int,input().split())) for i in range(n)]
AB.sort(key = lambda tup:tup[0]+tup[1],reverse  = True)
for i in range(n):
  if i % 2 == 0:
    ans += AB[i][0]
  else:
    ans -= AB[i][1]
print(ans)
# print(AB)

Measured memory_bytes: 58144
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stack>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pii pair<pi,int>
#define sqr(x) ((x)*(x))
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int s[3005];
int main()
{
	int n;
	cin>>n;
	int ans=0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		ans+=x-1;}
	cout<<ans<<endl;
	

   // system("pause");
    return 0;
}


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

int main() {
	int h, w;
	int i, j;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (i = 0; i < h; i++) {
			if (i % 2 == 0) {
				for (j = 0; j < w; j++) {
					if (j % 2 == 0) cout << "#";
					else cout << ".";
				}
			}
			else {
				for (j = 0; j < w; j++) {
					if (j % 2 == 0) cout << ".";
					else cout << "#";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
public class Main {

	public static void main(String[] args) {

		java.util.Scanner sc = new java.util.Scanner(System.in);

		int n = sc.nextInt();
		int[] x = new int[n];
		double sum = 0;
		int total = 0;
		
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		double val = sum / n;
		val = Math.round(val);
		int avg = (int)val;
		

		for(int i = 0; i < n; i++) {
			int num = avg - x[i];
			num = num * num;
			total += num;
		}
		
		System.out.println(total);
	}
}


Measured memory_bytes: 21972
_first_line = STDIN.gets
gem_values = STDIN.gets.strip.split(' ').map(&:to_i)
costs = STDIN.gets.strip.split(' ').map(&:to_i)

diff_sum = 0
gem_values.each_with_index do |value, idx|
  cost = costs[idx]
  diff = value - cost
  diff_sum = diff_sum + value - cost if diff > 0
end

puts diff_sum


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

int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++) cin >> d[i];
    sort(d.begin(),d.end());
    int a = d[N/2-1];
    int b = d[N/2];
    int ans = b-a;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define RREP(i, n) for(int i=(int)(n); i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define INF 2e9
typedef long long ll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return 1;}return 0;}

using namespace std;

ll w[101];
int v[101];
ll dp[111111];

int main(void)
{
	int N, V=0;
	ll W;
	cin >> N >> W;
	REP(i, N){
		cin >> w[i] >> v[i];
	}
	for(int i:v){V+=i;}
	REP(i, V+1){
		dp[i] = INF;
	}
	dp[0] = 0;
	REP(i, N){
		RREP(k, V+1){
			if(k-v[i]>=0){
				chmin(dp[k], dp[k-v[i]]+w[i]);
			}
		}
	}
	ll ans = 0;
	REP(i, V+1){
		if(dp[i] <= W){
			chmax(ans, (ll)i);
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 1024
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N, X, T = map(int, readline().split())
    p = (N//X)*T
    if N%X == 0:
        print(p)
    else:
        print(p+T)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef long long hey;
#define hi string
#define pi 3.141592653589793238
#define fi first
#define mod 1000000007
#define se second
#define pb push_back 
#define pop pop_back 
#define bs binary_search
#define mp make_pair
#define ma map< hey,hey >
#define vi vector < hey > 
#define vs vector < hi > 
#define all(v) v.begin(),v.end()
#define qu priority_queue< hey >
#define endl '\n'
#define forn(a,b) for (hey i = a; i <hey(b); ++i)
#define yorn(i, n) for (hey i = 0; i <hey(n); ++i)
#define vp vector< pair<hey,hey> >
// lower bound - first element equal to or greater than given value.
// upper bound - first element greater than given value.
        // 2 Pointers is love
hey prime(hey n)
{
    if(n<=1)
	return 0;
	if(n<=3)
	return 1;
	if(n%2==0 || n%3==0)
	return 0;
	for(hey i=5;i*i<=n;i=i+6)
	{
		if(n%i==0 || n%(i+2)==0)
		return 0;
	}
	return 1;
}

void curious()
{
    hey x,y;
    cin>>x>>y;
    hey k=2*x;
    hey l=4*x;
    if(y>=k&&y<=l&&y%2==0)
    {
        cout<<"Yes";
    }
    else
    cout<<"No";
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	    curious();
	}
	return 0;
}

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

int main(){
    int n; cin >> n;
    ll a[n]; rep(i,n) cin >> a[i];
    ll ans = 0;
    ll sum = 0;
    rep(i,n){
        if(a[i] == 0){
            ans += sum/2;
            sum = 0;
        }else{
            sum += a[i];
        }
    }
    ans += sum/2;
    cout << ans << endl;
}

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

using namespace std;

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

    vector<int> vs(m);
    for (auto& v : vs)
    {
        cin >> v;
    }
    sort(vs.begin(), vs.end(), greater<>());
    const vector<int> cost = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

    vector<int> dp(n + 1, -1);
    vector<int> recon(n + 1, 0);
    dp[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        for (auto v : vs)
        {
            auto a = cost[v];
            if (i - a >= 0 && (dp[i] < dp[i - a] + 1))
            {
                dp[i] = dp[i - a] + 1;
                recon[i] = v;
            }
        }
    }
    vector<int> ret;
    while (n > 0)
    {
        ret.push_back(recon[n]);
        n -= cost[recon[n]];
    }
    for (auto v : ret)
    {
        cout << v;
    }
    cout << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

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

	int d, t, s;
	cin >> d >> t >> s;
	if(s * t >= d) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 3628
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
def dfs(start,route):
    route.append(start)
    if len(route) == N:
        route.remove(start)
        return 1
    res = 0
    for i in edge[start]:
        if i not in route:
            res += dfs(i,route)
    route.remove(start)
    return res
print(dfs(0,[]))

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

using namespace std;

typedef long long ll;

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, x;
    cin >> n >> x;
    int ans = 1;
    int d = 0;
    for (int i = 0; i < n; ++i) {
        int l;
        cin >> l;
        d += l;
        if (d <= x) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cout<<#x<<" = "<<x<<endl;
#define lowbit(x) x&(-x)
using namespace std;
typedef long long LL;
inline int read()
{
	int l = 0, f = 1;
	char a = getchar();
	for (; a < '0' || a > '9'; a = getchar())
		if (a == '-') f = -1;
	for (; a >= '0' && a <= '9'; a = getchar())
		l = l*10+a-48;
	return l*f;
}
map <int, bool> mp;
int n, mx, mxx;
int main(int argc, char const *argv[])
{
	n = read();
	for (int i = 1; i <= n; ++i)
	{
		int x = read();
		if (mp[x])
		{
			if (mx < x) mxx = mx, mx = x;
			else if (mxx < x) mxx = x;
			mp[x] = 0;
		}
		else mp[x] = 1;
	}
	printf("%lld\n", (LL)mxx*mx);
	return 0;
}

Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
from heapq import heappop, heappush
def solve(): 
    N = int(input())
    edges = [[] for _ in range(N+1)]
    for _ in range(N-1):
        u, v, w = map(int, input().split())
        edges[u].append((v, w&1))
        edges[v].append((u, w&1))

    D = [-1]*(N+1)
    hq = [(0,1)]
    checked = set()
    while hq:
        c, u = heappop(hq)
        checked.add(u)
        D[u] = c
        for v, w in edges[u]:
            if not v in checked:
                heappush(hq, (c^w, v))

    res = '\n'.join(map(str, D[1:]))
    return str(res)

if __name__ == '__main__':
    print(solve())




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

using ll = long long;

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

    ll ans = B[0] + B[N - 2];
    for (int i = 0; i < N - 2; ++i) {
        ans += min(B[i], B[i + 1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(i=j;i<k;i++)
#define all(obj) obj.begin(), obj.end()

signed main(){
    int k,a,b;
    bool l = false;
    cin>>k;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            l = true;
            break;
        }
    }
    if(!l) cout<<"NG"<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
ll A,B,ans=0;
int  main()
{
	//freopen("input.inp","r",stdin);
	ios_base::sync_with_stdio(false);
	cin>>n>>A>>B;
	ll np=0,tx;
	for (int i=1;i<=n;i++)
	{
		cin>>tx;
		//cout<<tx<<" "<<np<<endl;
		if (i==1) np=tx;
		else
		{
			ans+=min((tx-np)*A,B);
			np=tx;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeSet;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int w=sc.nextInt();
        int n=sc.nextInt();
        int x[]=new int [w];
        for(int i=0;i<w;i++){
            x[i]=i+1;
        }
        for(int i=0;i<n;i++){
            String c=sc.next();
            String []ab=c.split(",");
            int a = Integer.parseInt(ab[0]) - 1;
            int b = Integer.parseInt(ab[1]) - 1;
            int tmp=x[a];
            x[a]=x[b];
            x[b]=tmp;
        }
        for(int i=0;i<w;i++){
            System.out.println(x[i]);
        }
    }
}



Measured memory_bytes: 26236
package main

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

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func pow64(x, y int64) int64 {
	return int64(math.Pow(float64(x), float64(y)))
}

func pow(x, y int) int {
	return int(pow64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	N := nextInt()
	s, t := nextLine(), nextLine()
	i := 0
	for ; !strings.HasPrefix(t, s[i:]) && i < N; i++ {
	}
	out(N - i + i*2)
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Procon20191202_2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] line1 = Console.ReadLine().Trim().Split(' ');
            int n = int.Parse(line1[0]);
            int m = int.Parse(line1[1]);
            int t = int.Parse(line1[2]);

            string[] line2 = Console.ReadLine().Trim().Split(' ');
            var arriveTime = Array.ConvertAll(line2, int.Parse);

            int ans = 0;
            ans += arriveTime[0] - m;
            if (arriveTime[n - 1] + m < t)
            {
                ans += t - (arriveTime[n - 1] + m);
            }
            for (int i = 0; i < n - 1; i++)
            {
                if (arriveTime[i] + m <= t)
                {
                    if (arriveTime[i] + m < arriveTime[i + 1] - m)
                    {
                        ans += (arriveTime[i + 1] - m) - (arriveTime[i] + m);
                    }
                }
                else
                {
                    break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}



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

typedef long long ll;

using namespace std;

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

    for (int i = 0; i < 100; i++) {
        if (4 * i > n) {
            break;
        }

        int m = n - 4 * i;

        if (m % 7 == 0) {
            cout << "Yes";
            return 0;
        }
    }

    cout << "No";
}

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

int main (){
  int n;
  cin >> n;
  int a[n];
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  for (int i = n-1; i>=0; i--){
    cout << a[i];
    if (i!= 0){
      cout << ' ';
    }
  }
 cout << endl;
  return 0;
}


Measured memory_bytes: 3096
#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 n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
     cin>>a[i];
    }
    sort(a.begin(),a.end());
    cout<<a[n-1]-a[0]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double EPS = 0.0000000001;
int sign(double x){
	if (x > EPS){
		return 1;
	} else if (x < -EPS){
		return -1;
	} else {
		return 0;
	}
}
bool equals(double x, double y){
	return abs(x - y) < EPS;
}
struct point{
	double x;
	double y;
	point(){
		x = 0;
		y = 0;
	}
	point(double X, double Y){
		x = X;
		y = Y;
	}
	point operator +(){
		return point(x, y);
	}
	point operator -(){
		return point(-x, -y);
	}
	point operator +(point P){
		return point(x + P.x, y + P.y);
	}
	point operator -(point P){
		return point(x - P.x, y - P.y);
	}
	point& operator +=(point P){
		x += P.x;
		y += P.y;
		return *this;
	}
	point& operator -=(point P){
		x -= P.x;
		y -= P.y;
		return *this;
	}
	point operator *(double k){
		return point(x * k, y * k);
	}
	point operator /(double k){
		return point(x / k, y / k);
	}
	point& operator *=(double k){
		x *= k;
		y *= k;
		return *this;
	}
	point& operator /=(double k){
		x /= k;
		y /= k;
		return *this;
	}
	bool operator ==(point P){
		return equals(x, P.x) && equals(y, P.y);
	}
	bool operator !=(point P){
		return !(*this == P);
	}
	bool operator <(point P){
		return sign(P.x - x) == 1 || (equals(x, P.x) && sign(P.y - y) == 1);
	}
	bool operator >(point P){
		return (P < *this);
	}
	double norm(){
	    return x * x + y * y;
	}
	double size(){
	    return sqrt((*this).norm());
	}
	point& rotate(double t){
	    double X = x * cos(t) - y * sin(t);
	    double Y = x * sin(t) + y * cos(t);
	    x = X;
	    y = Y;
	    return *this;
	}
	point& rotate(point P, double t){
	    *this -= P;
	    (*this).rotate(t);
	    *this += P;
	    return *this;
	}
	point& rotate90(){
	    swap(x, y);
	    x = -x;
	    return *this;
	}
};
istream& operator >>(istream &is, point &p){
	double x, y;
	is >> x >> y;
	p = point(x, y);
	return is;
}
ostream& operator <<(ostream &os, point p){
	os << p.x << ' ' << p.y;
	return os;
}
double norm(point P){
    return P.x * P.x + P.y * P.y;
}
double abs(point P){
    return sqrt(norm(P)); 
}
double dot(point P, point Q){
    return P.x * Q.x + P.y * Q.y;
}
double cross(point P, point Q){
    return P.x * Q.y - P.y * Q.x;
}
int ccw(point P, point Q, point R){
    Q -= P;
    R -= P;
    if (sign(cross(Q, R)) == 1){
        return 1;
    } else if (sign(cross(Q, R)) == -1){
        return -1;
    } else if (sign(dot(Q, R)) == -1){
        return -2;
    } else if (sign(abs(R) - abs(Q)) == 1){
        return 2;
    } else {
        return 0;
    }
}
int main(){
  point p0, p1;
  cin >> p0 >> p1;
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
    point p2;
    cin >> p2;
    int ans = ccw(p0, p1, p2);
    if (ans == 1){
      cout << "COUNTER_CLOCKWISE" << endl;
    } else if (ans == -1){
      cout << "CLOCKWISE" << endl;
    } else if (ans == -2){
      cout << "ONLINE_BACK" << endl;
    } else if (ans == 2){
      cout << "ONLINE_FRONT" << endl;
    } else {
      cout << "ON_SEGMENT" << endl;
    }
  }
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define INF 1e18
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    string s;cin>>s;
    int n=s.size();
    int win=0,lose=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='o')
            win++;
        else 
            lose++;
    }
    int rem=15-n;
    if((win+rem)>=8)
        cout<<"YES";
    else
        cout<<"NO";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(void){
	int n;

	cin >> n;
	for(int i = 0; i < n; ++i){
		int nowPos = 0;
		int dir = 0;
		string train;
		string s;
		cin >> s;

		train += s[0];
		for(unsigned int j = 1; j < s.length(); ++j){
			if( s[j] == '<' ){
				--nowPos;
				++j;
			}else if( s[j] == '-' ){
				++nowPos;
				++j;
			}else{
				if( nowPos >= (signed)train.length() ){
					train += s[j];
					nowPos = train.length() - 1;
				}else if( nowPos < 0 ){
					train.insert( train.begin(), s[j] );
					nowPos = 0;
				}
			}
		}
		cout << train << '\n';
	}
	return 0;
}

Measured memory_bytes: 0
l=list("abcdefghijklmnopqrstuvwxyz")
# print(l)
n=int(input())
w=[]
while n>0:
    n-=1
    w.append(l[n%26])
    n//=26

    # s[i]=l[m//(27**(i+1)-1]
w.reverse()
print("".join(w))

Measured memory_bytes: 9180
from collections import deque

i,qtime = map(int,input().split())
ttime = 0
deque = deque()
dic= {}
for s in range(i):
    name,value = map(str,input().split())
    dic[name] = int(value)
    deque.append(name)
while len(deque) > 0:
    time = qtime
    while time > 0:
        if dic[deque[0]] > time:
            dic[deque[0]] = dic[deque[0]] - time
            deque.append(deque.popleft())
            ttime += time
            time = 0
        else:
            ttime += dic[deque[0]]
            time = 0
            dic[deque[0]] = 0
            print("{0} {1}".format(deque[0],ttime))
            deque.popleft()


Measured memory_bytes: 12552
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e4+5;

int dp[maxn], s[10];

int digits[] = {1,2,3,4,5,6,7,8,9};
int num_sticks[] = {2,5,5,4,5,6,3,7,6};

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n,m;
    cin>>n>>m;
    vector<int> a(m, 0);
    
    set<int> len;
    
    for(int i = 0; i<m; i++){
        cin>>a[i];
        len.insert(num_sticks[a[i]-1]);
        s[num_sticks[a[i]-1]] = max(s[num_sticks[a[i]-1]], a[i]);
    }
    
    fill(dp, dp+n+1, -1);
    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        for(auto j:len ){
            if(i>=j&&dp[i-j]!=-1)dp[i] = max(dp[i], dp[i-j]+1);
        }
    }

    int k = n;
    vector<char> ss;
    while(k){
        int somelen = *(len.begin());
        for(auto i: len){
            if(i!=somelen&&k-somelen>=0&&k-i>=0)
                if(dp[k-somelen]<dp[k - i]||(dp[k-somelen]==dp[k - i]&&s[somelen]<s[i]))
                somelen = i;
        }
        ss.push_back(s[somelen] + '0');
        k -= somelen;
    }
    
    sort(ss.rbegin(), ss.rend());
    for(auto i: ss)cout<<i;
    cout<<endl;
    return 0;
}



Measured memory_bytes: 384
#n=int(input())
n,m=map(int,input().split())
xl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
cuml=[]
if n>=m:
    print(0)
else:
    xl.sort()
    rng=xl[m-1]-xl[0]
    ans=rng
    for i in range(1,m):
        cuml.append(xl[i]-xl[i-1])
    cuml.sort()
    for i in range(n-1):
        ans-=cuml[m-2-i]
    print(ans)

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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  int cnt = 0;
  rep(i,n-1){
    if(a.at(i) == a.at(i+1)){
      a.at(i+1) = 10001;
      cnt++;
    }
  }
  cout << cnt << endl;
      
}


Measured memory_bytes: 256