akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1LL<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1LL<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

const int MX = 400010;

int f[MX];
int rf[MX];

int C(int l,int k, int md) 
{
    if (k<0||k>l){
        return 0;
    }
    return f[l]*rf[k]%md*rf[l-k]%md;
}

void precfac() {
    f[0]=1;
    for (int i=1;i<MX;i++){
        f[i]=f[i-1]*i%MOD;
    }
    rf[MX-1]=powmod(f[MX-1],MOD-2, MOD);
    for (int i=MX-2;i>=0;i--){
        rf[i]=rf[i+1]*(i+1)%MOD;
    }
}
int cmp(const ii& p1, const ii& p2) {
    return p1.ff+p1.ss<p2.ff+p2.ss;
}
signed main(void)
{
	IOS;
	int n; cin>>n;
    vii sw(n);
    for(int i = 0; i < n; i++) {
        cin>>sw[i].ff>>sw[i].ss;
    }
    sort(all(sw),cmp);
    int dp[n][n+1];
    // for(int i = 0; i < n; i++) {
    //     cout<<sw[i].ff<<" "<<sw[i].ss<<endl;
    // }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= n; j++)
            dp[i][j]=inf;
    }
    dp[0][1]=sw[0].ss;
    dp[0][0]=0;
    for(int i = 0; i < n-1; i++) {
        for(int j = 0; j <= n; j++) {
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            if(dp[i][j] <= sw[i+1].ff) {
                if(j+1 <= n)
                    dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+sw[i+1].ss);
            }
        }
    }
    for(int i = n; i >= 0; i--) {
        if(dp[n-1][i] < inf) {
            cout<<i<<endl;
            return 0;
        }
    }
	return 0;
}


Measured memory_bytes: 195712
n = int(input())
s = input()

w = [0]
e = [0]

tmp_w = 0
tmp_e = 0

for i in range(1, n):

    j = (n - 1) - i

    if (s[i-1] == 'W'):
        w.append(tmp_w + 1)
        tmp_w += 1
    else:
        w.append(tmp_w)

    if (s[j+1] == 'E'):
        e.append(tmp_e + 1)
        tmp_e += 1
    else:
        e.append(tmp_e)

e.reverse()

# ans = 10 ** 6 
# for i in range(n):
#     ans = w[i] + e[i] if w[i] + e[i] < ans else ans

result = []

for i in range(n):
    result.append(w[i] + e[i])

print(min(result))

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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/14  Problem: 068_arc_a / Link: https://arc068.contest.atcoder.jp/tasks/arc068_a?lang=en  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	ans = (N) / 11LL*2;
	int left = N % 11;
	if (left > 6)ans += 2;
	else if (left > 0)ans += 1;
	cout << ans << "\n";

	return 0;
}


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

unsigned long long modpow(unsigned long long a, unsigned long long n, unsigned long long mod) {
   unsigned long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
void comb(vector<vector <long long int> > &v,unsigned long long mod) {
  //vector<入れたい型> v(配列の個数(x),vector<入れたい型> (配列の個数,初期値));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int k = 1; k < v.size(); k++) {
    for (int j = 1; j < k; j++) {
      v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%mod;
    }
  }
}



int main() {
  unsigned long long N, K;
  unsigned long long mod = 1000000000 + 7;
  cin >> N >> K;
  unsigned long long C=0;
  unsigned long long Ci=0;
  vector<vector<long long int> > v(N + 1, vector<long long int>(N + 1, 0));
  comb(v,mod);
  for(int i=1;i<K+1;i++){
    C=v[K-1][i-1]%mod;
    Ci=v[N-K+1][i]%mod;
    cout<<C*Ci%mod<<endl;
  }
  
  //modinv(N, mod,inv);
    
  return 0;
}


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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

// 繰り返し二乗法
ll power(ll a, ll b){
    if(a==1)return a;
    // if(a==0)re
    ll res=1;
    while(b>0){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

const int MAX=2100000;

ll fact[MAX], fact_inv[MAX];

void init_fact(ll n){
    fact[0]=1;
    // 階乗の計算
    for(ll i=0; i<n; i++) fact[i+1]=fact[i]*(i+1)%MOD;
    fact_inv[n]=power(fact[n], MOD-2);
    // 逆元の計算
    for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}

ll comb(ll n, ll r){
    return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

ll perm(ll n, ll r){
    return (fact[n]*fact_inv[n-r])%MOD;
}

int main() {
    cout<<fixed<<setprecision(10);

    ll n,k; cin>>n>>k;

    cout<<min(1ll, n%k)<<endl;

    return 0;

}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

int f[1001][1001];
int ct[1001][1001];

int main()
{
    int H,W,N;
    while(scanf(" %d %d %d", &H, &W, &N),H)
    {
        rep(i,H)rep(j,W) scanf(" %d", &f[i][j]);
        #define IN(x,y) (0<=x && x<W && 0<=y && y<H)

        memset(ct,0,sizeof(ct));
        ct[0][0]=N-1;

        int dx[2]={0,1}, dy[2]={1,0};
        rep(s,H+W+1)
        {
            int l=max(0,s-H), r=min(W-1,s);
            for(int x=l; x<=r; ++x)
            {
                int y=s-x;
                rep(i,2)
                {
                    int nx=x+dx[i], ny=y+dy[i];
                    if(!IN(nx,ny)) continue;

                    int nct=ct[y][x]/2;
                    if(ct[y][x]%2==1 && f[y][x]==i) ++nct;

                    ct[ny][nx]+=nct;
                }
            }
        }

        int X=0,Y=0;
        while(IN(X,Y))
        {
            int d=(f[Y][X]+ct[Y][X])%2;
            X+=dx[d];
            Y+=dy[d];
        }
        printf("%d %d\n", Y+1,X+1);
    }
    return 0;
}

Measured memory_bytes: 10996
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int a,b;
  cin >> a >> b;
  cout << (a-1)*(b-1) << endl;
}

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

public class Main {
	public static void main (String[] args) { new Main(); }

	public Main() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		char[] str = fs.next().toCharArray();
		
		int[][] freq = new int[2][2020];
		freq[0][0]++;
		
		int curNum = 0, curPow = 1;
		
		long res = 0;
		for(int i = 0; i < str.length; i++) {
			int nxt = curNum*10+(str[i]-'0');
			nxt %= 2019;
			
			res += freq[0][nxt];
			freq[0][nxt]++;
			for(int j = 0; j < 2019; j++) {
				freq[1][j] = freq[0][j];
				freq[0][j] = 0;
			}
			for(int j = 0; j < 2019; j++) {
				int to = 10*j;
				if(to >= 2019) to %= 2019;
				freq[0][to] += freq[1][j];
			}
			
			
			curNum = nxt; 
		}
		
		out.println(res);
		
		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}

Measured memory_bytes: 35300
n, k = map(int, input().split())
MOD = 10**9+7

ans = 0
for i in range(k, n+2):
  ll = 0
  lr = i - 1
  rl = n-(i-1)
  rr = n
  lsum = lr*(lr+1)//2 - ll*(ll+1)//2
  rsum = rr*(rr+1)//2 - rl*(rl-1)//2
  ans += rsum - lsum + 1
  ans %= MOD
  #print(rsum, lsum)
  
print(ans)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()

const int N = 1e3 + 5;
string s, t;
vector<int> in[N];

main()
{
    cin >> s >> t;
    s = ' ' + s;
    t = ' ' + t;
    for(int i = 1; i < s.size(); ++i)
    {
        in[s[i] - 'a'].push_back(i);
    }
    for(int i = 1; i < t.size(); ++i)
    {
        if(in[t[i] - 'a'].empty())
        {
            cout << -1;
            return 0;
        }
    }
    int id = 1, c = 0;
    for(int i = 1; i < t.size(); ++i)
    {
        int u = lower_bound(all(in[t[i] - 'a']), id) - in[t[i]-'a'].begin();
        if(u == in[t[i]-'a'].size()) c++, id = in[t[i]-'a'][0] + 1;
        else
        {
            id = in[t[i] - 'a'][u] + 1;
            if(u == s.size() - 1)
            {
                u = 0, c++;
            }
        }
    }
    cout << c * (s.size() - 1) + id - 1;
}


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

int main()
{
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    int anW = 0, anS = 0;
    double a = -1;
    for (int i = 0; A * 100 * i <= F; i++)
    {
        for (int j = 0; A * 100 * i + B * 100 * j <= F; j++)
        {
            double W = A * 100 * i + B * 100 * j;
            for (int k = 0; C * k <= E * W / 100 && W + C * k <= F; k++)
            {
                for (int l = 0; C * k + D * l <= E * W / 100 && W + C * k + D * l <= F; l++)
                {
                    double S = C * k + D * l;
                    if (W != 0)
                    {
                        double ans = 100 * S / (W + S);
                        if (ans > a)
                        {
                            a = ans;
                            anW = W + S;
                            anS = S;
                        }
                    }
                }
            }
        }
    }
    cout << anW << " " << anS << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Random rand = new Random();
        int a,b,c;
		// 整数の入力
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
 
        if(a==b && b!=c){
            System.out.println("Yes");
        }else if(a==c && c!=b){
            System.out.println("Yes");
        }else if(b==c && c!=a){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
	}
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N,M,K;
    cin >> N >> M >> K;
    vector<ll> A(N+1);
    vector<ll> B(M+1);
    A[0] = 0;
    REPS(i,N){
        ll tmp;
        cin >> tmp;
        A[i] = tmp + A[i-1];
    }
    B[0] = 0;
    REPS(i,M){
        ll tmp;
        cin >> tmp;
        B[i] = tmp + B[i-1];
    }
    ll answer = 0;
    RREP(i,N+1){
        ll remain = K - A[i];
        if(remain < 0){
            continue;
        }else{
            chmax(answer,i+(upper_bound(ALL(B), remain)-B.begin()));
        }
    }
    cout << answer - 1 << "\n";
}

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


int main(){
    int n, **daar, **dadp;
    cin>>n;
    daar = new int*[n];
    dadp = new int*[n];
    for(int i=0;i<n;i++){
        daar[i] = new int[3];
        dadp[i] = new int[3];
        for(int j=0;j<3;j++){
            cin>>daar[i][j];
            dadp[i][j]=-1;
        }
    }

    for(int j=0;j<3;j++){
        dadp[0][j] = daar[0][j];
    }

    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(k==j)continue;
                dadp[i][j] = max(dadp[i][j], daar[i][j] + dadp[i-1][k]);
            }
        }
    }

    int ans = -1;
    for(int i=0;i<3;i++){
        ans = max(ans, dadp[n-1][i]);
    }

    cout << ans;

    return 0;
}

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

using namespace std;

const int MX = 50;

namespace dsu {
	int p[MX];
	
	void init(int n) {
		iota(p, p + n, 0);
	}
	
	int get(int v) {
		if (p[v] != v) p[v] = get(p[v]);
		return p[v];
	}
	
	bool merge(int u, int v) {
		u = get(u);
		v = get(v);
		p[u] = v;
		return u != v;
	}
}

int n, par[MX];
vector<int> G[MX];
vector<pair<int, int>> edges;
bool enabled[MX];

void dfs(int v, int p = -1, bool enable = true) {
	par[v] = p;
	enabled[v] = enable;
	for (int u : G[v]) {
		if (u == p) continue;
		if (enable && dsu::get(u) == dsu::get(v))
			dfs(u, v, true);
		else
			dfs(u, v, false);
	}
}

int solve(int root) {
	dfs(root);
	vector<int> deg(n, 0);
	vector<int> GG[MX];
	for (auto& e : edges) {
		deg[e.first]++;
		deg[e.second]++;
		
		GG[e.first].push_back(e.second);
		GG[e.second].push_back(e.first);
	}
	
	int res = 0;
	bool ok = true;
	while (ok) {
		ok = false;
		for (int i = 0; i < n; i++)
			if (deg[i] == 1 && enabled[i] == false && enabled[par[i]]) {
				enabled[i] = true;
				res++;
				for (int u : GG[i]) {
					deg[u]--;
				}
				ok = true;
			}
	}
	
	for (int i = 0; i < n; i++) if (enabled[i] == false) return n + 1;
	return res;
}

int main() {
	int T;
	ignore = scanf("%d", &T);
	while (T--) {
		ignore = scanf("%d", &n);
		
		edges.clear();
		dsu::init(n);
		for (int i = 0; i < n; i++) {
			G[i].clear();
		}
		
		for (int i = 1, u, v; i < n; i++) {
			ignore = scanf("%d %d", &u, &v);
			u--; v--;
			edges.emplace_back(u, v);
		}
		
		for (int i = 1, u, v; i < n; i++) {
			ignore = scanf("%d %d", &u, &v);
			u--; v--;
			G[u].emplace_back(v);
			G[v].emplace_back(u);
			
			for (auto& e : edges)
				if ((e.first == u && e.second == v) || (e.first == v && e.second == u)) {
					dsu::merge(u, v);
				}
		}
		
		int ans = n + 1;
		for (int i = 0; i < n; i++) ans = min(solve(i), ans);
		
		if (ans > n) {
			dsu::init(n);
			for (int v = 0; v < n; v++) {
				int id = -1;
				for (int i = 0; i < n - 1; i++)
					if (edges[i].first == v || edges[i].second == v) {
						if (id != -1) id = -2;
						else id = i;
					}
				
				if (id >= 0) {
					auto e = edges[id];
					for (int u = 0; u < n; u++) {
						if (u == v) continue;
						edges[id] = make_pair(v, u);
						if (solve(v) != n + 1) ans = n;
					}
					edges[id] = e;
				}
			}
		}
		
		if (ans > n) ans = -1;
		printf("%d\n", ans);
	}
	
	return 0;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a = list(map(int, readline().split()))

    for i, x in enumerate(a, 1):
        if x == 0:
            print(i)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61664
from sys import stdin

s = stdin.readline().rstrip()

if len(s) == 1:
    print(int(s))
    exit()

if s == "9"*len(s):
    print(9*len(s))
else:
    if s[1:] == "9"*(len(s)-1):
        print(int(s[0])+9*(len(s)-1))
    else:
        print(int(s[0])-1+9*(len(s)-1))

Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

const (
	a = 0
	b = 1
	c = 2
)

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	h := make([][]int, n)
	dp := make([][]int, n)

	for i := 0; i < n; i++ {
		h[i] = make([]int, 3)
		dp[i] = make([]int, 3)
		for j := 0; j < 3; j++ {
			h[i][j] = readInt()
		}
	}
	for i := a; i <= c; i++ {
		dp[0][i] = h[0][i]
	}

	for i := 1; i < n; i++ {
		for j := a; j <= c; j++ {
			for k := a; k <= c; k++ {
				if j != k {
					dp[i][j] = max(dp[i][j], dp[i-1][k]+h[i][j])
				}
			}
		}
	}
	ans := 0
	for i := a; i <= c; i++ {
		ans = max(ans, dp[n-1][i])
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func maxIntSlice(list []int) int {
	max := 0
	for _, v := range list {
		if v > max {
			max = v
		}
	}
	return max
}


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

int main() {
	int N,M,X,Y;
  	cin >> N >> M >> X >> Y;
  
  	vector<int> a(N),b(M);
  	for(int i = 0; i < N; i++) {
    	cin >> a.at(i);
    }
  	
  	for(int i = 0; i < M; i++) {
    	cin >> b.at(i);
    }
  
  	sort(a.begin(),a.end());
  	sort(b.begin(),b.end());
  
  	if(a.at(N - 1) < b.at(0) && X < a.at(N - 1) && b.at(0) <= Y) {
    	cout << "No War" << endl;
    }else {
    	cout << "War" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'


int main() {
  int n, e, t;
  cin >> n >> e >> t;
  vl x(n + 1);
  rep1 (i, n) cin >> x[i];

  vl dp(n + 1, INF);

  set<pll> near, far;
  dp[0] = 0;
  near.insert(pll(0, 0));
  rep1 (i, n) {
    while (near.size() > 0) {
      auto itr = near.begin();
      ll val = itr->first, j = itr->second;
      if (2*(x[i] - x[j + 1]) >= t) {
        near.erase(near.begin());
        far.insert(pll(dp[j] - x[j] - 2*x[j + 1], j));
      }
      else {
        dp[i] = dp[j] - x[j] + x[i] + t;
        break;
      }
    }
    if (far.size() > 0) {
      auto itr = far.begin();
      ll val = itr->first, j = itr->second;
      chmin(dp[i], val + 3 * x[i]);
    }
    /*
    DEBUG("near");
    for (auto itr = near.begin(); itr != near.end(); itr++) DEBUG(*itr);
    DEBUG("far");
    for (auto itr = far.begin(); itr != far.end(); itr++) DEBUG(*itr);
    //*/
    near.insert(pll(dp[i] - x[i], i));
  }
  //DEBUG_VEC(dp);
  cout << dp[n] + e - x[n] << endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	if(a==3){
		cout<<"YES"<<endl;
	}
	else if(a==5){
		cout<<"YES"<<endl;
	}
	else if(a==7){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}


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

using ll = long long;

int const N = 200 * 1000 + 16;
int const M = 1000 * 1000 * 1000 + 7;


int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  int n, t;
  cin >> n >> t;
  ll sum = 0;
  ll last = -1;

  while(n--) {
    int x;
    cin >> x;
    if(x <= last)
      sum -= last-x;
    sum += t;
    last = x+t;
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mem(dp, v) memset(dp, v, sizeof dp);
using namespace std;

const int N = 1e6 + 7, inf = 1e9;
int ar[N], n, k, t, w[10007], cost[10007], dp[1002][10002], H;

int foo(int i, int H)
{
    int &ret = dp[i][H];
    if(i >= n) return inf;
    if( H <= 0) return 0 ;
    if(ret != -1) return ret;
    ret = min(cost[i] + foo(i, H - w[i]), foo(i + 1, H));
    return ret;
}
int main()
{
    mem(dp, -1);
    ios_base::sync_with_stdio(false);
    cin>>H>>n;
    for(int i = 0; i < n; i++)
    {
        cin>>w[i]>>cost[i];
    }
    cout<<foo(0, H)<<endl;
    return 0;
}


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

using namespace std;

int gcd(int a, int b) {
  if (!b) return a;
  return gcd(b, a % b);
}

int main(void) {
  int n, k;
  cin >> n >> k;

  vector<int> a(n);
  bool hasK = false;
  int M = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == k) {
      hasK = true;
    }
    M = max(M, a[i]);
  }

  int GCD = a[0];
  for (int i = 1; i < n; i++) {
    GCD = gcd(GCD, a[i]);
  }

  if (hasK || (M > k && (M - k) % GCD == 0)) {
    cout << "POSSIBLE\n";
  } else {
    cout << "IMPOSSIBLE\n";
  }

  return 0;
}

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

void hantei(double x[], double y[]);

int main() {
  int n;
  double x[4], y[4];
  scanf("%d", &n);
  for(int i=0;i<n;i++) {
    for(int j=0;j<4;j++) scanf("%lf %lf", &x[j], &y[j]);
    hantei(x, y);
  }
}

void hantei(double x[], double y[]) {
  if(x[0]==x[1]) {
    if(x[2]==x[3])printf("YES\n");
    else printf("NO\n");
  } else if(x[2]==x[3])printf("NO\n");
  else {
    if((y[1]-y[0])/(x[1]-x[0])==(y[3]-y[2])/(x[3]-x[2]))
      printf("YES\n");
    else printf("NO\n");
  }
  /*
    if(x[0]==x[1]) {
    if(x[2]==x[3]) return true;
    else return false;
    } else if(x[2]==x[3]) return false;
    else {
    if(x[1]-x[0]/y[1]-y[0] == x[3]-x[2]/y[3]-y[2]) return true;
    else  return false;
    }
  */
}

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


int main(){
    int N;
    cin >> N;
    vector<int> jewelry_value;
    vector<int> jewelry_cost;
    
    rep(i,N){
        int x;
        cin >> x;
        jewelry_value.push_back(x);
    }
    
    rep(i,N){
        int x;
        cin >> x;
        jewelry_cost.push_back(x);
    }
    
    
    int ans=0;
    rep(i,N){
        int V,C;
        V=jewelry_value[i];
        C=jewelry_cost[i];
        
        if(V-C > 0){
            ans += V-C;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

std::vector<double> base_expected(int N, std::vector<std::vector<int>>const& edge)
{
	std::vector<double> ret(N);
	for (auto i : boost::irange(0, N - 1) | adaptor::reversed)
	{
		for (auto j : edge[i])
		{
			ret[i] += 1 + ret[j];
		}
		ret[i] /= edge[i].size();
	}
	return ret;
}

void Main()
{
	int N, M;
	std::cin >> N >> M;
	std::vector<std::vector<int>>edge(N);
	for (auto i : boost::irange(0, M))
	{
		int s, t;
		std::cin >> s >> t;
		--s; --t;
		edge[s].emplace_back(t);
	}
	auto expected = base_expected(N, edge);
	auto min = expected[0];
	for (auto i : boost::irange(0, N - 1))
	{

		if (edge[i].size() == 1)
		{
			continue;
		}
		for (auto j : boost::irange(0, N - 1) | adaptor::reversed)
		{
			expected[j] = 0;
			auto max = 0.0;
			for (auto n : edge[j])
			{
				expected[j] += expected[n] + 1;
				max = std::max(max, expected[n] + 1);
			}
			expected[j] -= (i == j) * max;
			expected[j] /= (edge[j].size() - (i == j));
		}
		min = std::min(min, expected[0]);
	}
	std::cout << min << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	ll n; cin>>n;
	ll t = 0;
	vl a(n); forn(i, n) cin>>a[i], t = t ^ a[i];
	forn(i, n) a[i] = t ^ a[i];
	forn(i, n) cout<<a[i]<<" ";
	cout<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

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

int main(){
  
  int n, a[100010];
  bool f[1000010]={};

  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }

  int x=1, cnt=0;
  f[x]=true;
  while(1){
    if(f[a[x]]==false){
      f[a[x]]=true;
      cnt++;
      x=a[x];
    }else{
      cout<<-1<<endl;
      return 0;
    }

    if(x==2){
      cout<<cnt<<endl;
      return 0;
    }
  }
  
  return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;


void solve(){
  ll n,a,b;
  cin>>n>>a>>b;
  cout<<n/(a+b)*a+min(a,n%(a+b));
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left
import sys
s = input()
t = input()

alpha = [[] for _ in range(26)]
c2i = lambda x: ord(x) - ord('a')

for i, sl in enumerate(s):
    alpha[c2i(sl)].append(i)

pos = -1
count = 0
length = len(s)
for tl in t:
    places = alpha[c2i(tl)]
    if len(places) == 0:
        print(-1)
        break

    index = bisect_left(places, pos+1)
    if index != len(places):
        place = places[index]
        count += place - pos
        pos = place
    else:
        count += (length-pos-1) + places[0] + 1
        pos = places[0]
else:
    print(count)

Measured memory_bytes: 45936
# B - Magic 2
A, B, C = map(int, input().split())
K = int(input())
count = 0

while B <= A:
	B *= 2
	count += 1

while C <= B:
	C *= 2
	count += 1

if count <= K:
	print('Yes')
else:
	print('No')	

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

int main(){
  string S;
  cin >> S;
  int L = S.size();
  string ans = "AC";
  if(S[0] != 'A'){
    ans = "WA";
  }

  //2文字目以降を見る
  int cnt = 0;//先頭から3文字目と末尾から2文字目の間（両端含む）の'C'の個数
  for(int i = 1; i < L; ++i){
    if(isupper(S[i])){//isupper()は、文字が英大文字かどうか判定する
      if(i == 1 || i == L - 1 || S[i] != 'C'){//2番目に大文字or最後に大文字or2番目から最後までに'C'以外の大文字
        ans = "WA";
      }
      ++cnt;
    }
  }
  if(cnt != 1){
     ans = "WA";
  }
    cout << ans << endl;
}
//PDFの解答


Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************


int main(){

    ll x, k, d;
    cin >> x >> k >> d;

    x = abs(x);

    ll num = x / d;

    if (num >= k) {
        cout << x - d * k << endl;
        return 0; 
    }

    x = x % d;
    ll rem = k - num;

    if (rem % 2 == 0){
        cout << x << endl;
    } else{
        cout << abs(x - d) << endl;
    }



    return 0;
}


Measured memory_bytes: 3676
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  char c[3],t[3];
  rep(i,3)cin>>c[i];
  rep(i,3)cin>>t[i];
  if(c[0]==t[2]&&c[1]==t[1]&&c[2]==t[0])
    puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll x; cin >> x;
    ll ans = x / 11 * 2;
    if (x % 11 == 0)cout << ans << "\n";
    else if (x % 11 <= 6)cout << ans + 1 << "\n";
    else cout << ans + 2 << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
char a[105][105];
int f[2][105][105][105],line[105][105],list[105][105],n,m;
void upd(int &x,int w){
	x=(x<w)?w:x;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%s",a[i]+1);
	int x,y;
	for(int i=1;i<=n;i++){
		for(int p=1;p<=m;p++){
			if(a[i][p]=='E') x=i,y=p;
			line[i][p]=line[i][p-1]+(a[i][p]=='o');
			list[i][p]=list[i-1][p]+(a[i][p]=='o');
		}
	}
	int pre=0,nxt=1,ans=0;
	for(int i=0;i<=n-x;i++,pre^=1,nxt^=1){
		memset(f[nxt],0,sizeof(f[nxt]));
		for(int p=0;p<x;p++){
			for(int j=0;j<=m-y;j++){
				for(int k=0;k<y;k++){
					int w=f[pre][p][j][k],W;
					if(x+i+1<=n-p) W=max(0,line[x+i+1][min(m-k,y+j)]-line[x+i+1][max(j,y-k-1)]);
					else W=0;
					upd(f[nxt][p][j][k],w+W);
					if(x-p-1>i) W=max(0,line[x-p-1][min(m-k,y+j)]-line[x-p-1][max(j,y-k-1)]);
					else W=0;
					upd(f[pre][p+1][j][k],w+W);
					if(y+j+1<=m-k) W=max(0,list[min(n-p,x+i)][y+j+1]-list[max(i,x-p-1)][y+j+1]);
					else W=0;
					upd(f[pre][p][j+1][k],w+W);
					if(y-k-1>j) W=max(0,list[min(n-p,x+i)][y-k-1]-list[max(i,x-p-1)][y-k-1]);
					else W=0;
					upd(f[pre][p][j][k+1],w+W);
					ans=max(ans,f[pre][p][j][k]);
				}
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 +c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int64 B,A;
int64 h[MAXN];
void Solve() {
    read(N);read(A);read(B);
    for(int i = 1 ; i <= N ; ++i) {
        read(h[i]);
    }
    sort(h + 1,h + N + 1);
    int64 L = 0,R = 1000000000;
    while(L < R) {
        int64 mid = (L + R) >> 1;
        int64 rem = 0;
        for(int i = 1 ; i <= N ; ++i) {
            if(h[i] - mid * B > 0) rem += (h[i] - mid * B - 1) / (A - B) + 1;
        }
        if(rem <= mid) R = mid;
        else L = mid + 1;
    }
    out(L);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int x,h,m,s;
	cin>>x;
	
	h = x/3600;

	x = x-3600*h;
	m=x/60;
	x=x-60*m;
	s=x;

    cout <<h<<":"<<m<<":"<<s<< endl;



    return 0;
}



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

int main(){
    int N;
    std::cin >> N;
    for(int i = 0; i < N; i++){
        int t;
        std::cin >> t;
        if(t % 2 == 0) {
           if(t % 3 != 0 && t % 5 != 0){
                std::cout << "DENIED" << std::endl;
                return 0;
           }
        } 
            
    }
    std::cout << "APPROVED" << std::endl;
    return 0;
}

Measured memory_bytes: 888
// Palace
#include<iostream>
using namespace std;
int N,T,A,answear;
double temp,delta;
int main(){
    cin>>N;
    int H[N];
    cin >> T >> A;
    for(int i=0;i<N;++i){
        cin >> H[i];
    }
    answear = 1;
    temp = T - 0.006*H[0];
    delta = (temp-A)*(temp-A);
    for(int i = 0; i<N;++i){
        temp = T - 0.006*H[i];
        if((temp-A)*(temp-A)<delta){
            delta = (temp-A)*(temp-A);
            answear = i+1;
        }
    }
    cout << answear << endl;
}

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

using namespace std;
using cd=complex<double>;

void solve() {
    int n; cin >> n;
    vector<cd> a(n);
    for (int i = 0; i < n; i++) {
        double x,y;
        cin >> x >> y;
        a[i] = {x,y};
    }
    double res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            res += abs(a[i] - a[j]);
        }
    }
    res /= n; res *= 2;
    cout << fixed << setprecision(10) << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
	int N;
	string S;
	cin >> N >> S;
	int sum = 0;

	for (int i = 0; i < N; i++)
	{
		if (S[i] != S[i+1])
			sum += 1;
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  bl b=true;
  FOR(i,0,n){
    ll a;
    	ci(a);
    if(a%2==1){
      b=false;
      co("first")
        break;
    }
  }
  if(b){
    co("second")
}
}


Measured memory_bytes: 256
D = gets.to_i
C = gets.chomp.split.map(&:to_i)
s = D.times.map{gets.split.map(&:to_i)}
c = Array.new(26, 0)
t = []

(0..D-1).each do |i|

  (0..25).each do |l|
    c[l] += C[l]
  end
ans = 0
boder = s[i][0]+c[0]-55*C[0]

  (1..25).each do |e|
    if s[i][e]+c[e]-55*C[e] >= boder
      ans = e
      boder = s[i][e]+c[e]-55*C[e]
    end
  end
c[ans] = 0
puts ans+1
end


  



Measured memory_bytes: 14360
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

  int s,w;
  cin>>s>>w;
  if(w>=s)
    cout<<"unsafe";
  else
    cout<<"safe";  

// -------------------------------------Code ends here------------------------------------------------------------------
    clock_t clk;
  clk = clock();

    clk = clock() - clk;
  cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
  return 0;
}


Measured memory_bytes: 3804
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
  // abcabcabc

  string s;
  cin >> s;

  vector<int> cnt(3);
  for (char c : s) {
    cnt[c - 'a']++;
  }

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

  if (cnt[0] + 1 >= cnt[2]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}



Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int arr[5];
int main()
{
	int k,sum=0,temp;
	for(int i=0;i<3;i++){
		cin>>arr[i];
		sum+=arr[i];
	}
	cin>>k;
	sort(arr,arr+3);
	sum-=arr[2];
	temp=arr[2];
	for(int i=1;i<=k;i++){
		temp*=2;
		
	}
	cout<<sum+temp;
	return 0;
}

Measured memory_bytes: 256