akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}

signed main() {
	int n, ans = 0;
	cin >> n;
	int a[200005];
	rep(i, n) {
		cin >> a[i];
	}
	int now = 1;
	rep(i, n) {
		if (a[i] == now) {
			now++;
		}
		else {
			ans++;
		}
	}
	if (ans == n) {
		cout << -1 << endl;
		return 0;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
# AGC002C - Knot Puzzle
def main():
    N, L = tuple(map(int, input().split()))
    A = tuple(map(int, input().split()))
    B = [i + j for i, j in zip(A, A[1:])]
    for i, (a, b) in enumerate(zip(A, A[1:]), 1):
        if a + b >= L:
            ans = [i for i in range(1, i)]
            ans += [i for i in range(N - 1, i, -1)] + [i]
            print("Possible")
            print(*ans, sep="\n")
            break
    else:
        print("Impossible")


if __name__ == "__main__":
    main()

Measured memory_bytes: 18156
#include<bits/stdc++.h>
using namespace std;
int f[3001][3001];
int g[3001][3001];
char s[3001],t[3001];
void mypf(int x,int y)
{
	if(x==0||y==0)
		return;
	if(f[x][y]==1)
		mypf(x-1,y); 
	else if(f[x][y]==2)
		mypf(x,y-1); 
	else if(f[x][y]==3)
		mypf(x-1,y-1);
	if(s[x-1]==t[y-1])
		printf("%c",s[x-1]); 
}
int main()
{
	int i,j,len_s,len_t;
	scanf("%s",s);

	scanf("%s",t);

	len_s=strlen(s);
	len_t=strlen(t);
	for(i=1;i<=len_s;i++)
	{
		for(j=1;j<=len_t;j++)
		{	
			if(s[i-1]==t[j-1])
			{
				f[i][j]=3;
				g[i][j]=g[i-1][j-1]+1;
			}
			else
			{
				if(g[i-1][j]>=g[i][j-1])
				{
					f[i][j]=1;
					g[i][j]=g[i-1][j];
				}
				else
				{
					f[i][j]=2;
					g[i][j]=g[i][j-1];				
				}				
			}
			//printf("i=%d j=%d ",i,j);
			//mypf(f[i][j]);
		}
	}
	mypf(len_s,len_t);
	return 0;
}

Measured memory_bytes: 70656
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF ll 1 << 60
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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;
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int dig(int n){
    int s = 0;
    while(n != 0){
        s += n%10;
        n/=10;
    }
    return s;
}

void solve(void){
    int n;
    cin >> n;
    int s = dig(n);
    if(n%s == 0) ys();
    else ns();

}

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

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, M, X, Y = map(int, input().split())
    max_x = max(max(map(int, input().split())), X)
    min_y = min(min(map(int, input().split())), Y)

    if max_x < min_y:
        print('No War')
    else:
        print('War')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007 
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n,m;
string U;
int a[505];
int s,t,b;

struct edge
{
	int to,cap,rev;
};
vector<edge>G[1005];
bool used[1005];

void add_edge(int from,int to,int cap)
{
	G[from].push_back((edge){to,cap,G[to].size()});
	G[to].push_back((edge){from,0,G[from].size()-1});
}
int dfs(int v,int t,int f)
{ 
	if(v==t) return f;
	used[v]=true;
	for(int i=0;i<G[v].size();i++)
	{
		edge &e=G[v][i];
		if(!used[e.to] && e.cap>0)
		{ 
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0) 
			{ 
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s,int t)
{ 
	int flow=0;
	while(1)
	{ 
		memset(used,0,sizeof(used));
		int f=dfs(s,t,INF);
		if(!f) return flow;
		flow+=f;
	}
}


int main(){
	cin>>n>>m;
	cin>>U;
	for(int i=0;i<n;i++){
		cin>>a[i];
		add_edge(1000,i,(U[i]=='L')?a[i]:0);
		add_edge(i,1001,(U[i]=='R')?a[i]:0);
	}
	for(int i=0;i<m;i++){
		cin>>s>>t>>b; s--; t--;
		if(s < t) swap(s,t);
		add_edge(s,t,b);
	}
	cout<<max_flow(1000,1001)<<endl;
}


Measured memory_bytes: 3292
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  // cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k; cin >> n >> k;
  double ans = 0;
  FOR(dice, 1, n + 1) {
    double tmp = 1.0 / n;
    int score = dice;
    while (score < k) {
      tmp /= 2;
      score *= 2;
    }
    ans += tmp;
  }
  printf("%.12f\n", ans);
  return 0;
}


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

int main(){

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

    int q;
    cin >> q;
    for(int i = 0; i < q; ++i){
        int b, e;
        cin >> b >> e;
        reverse(a.begin() + b, a.begin() + e);
    }

    for(int i = 0; i < a.size(); ++i){
        if(i){
            cout << " ";
        }
        cout << a[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
using namespace std;
#pragma warning (disable: 4996)

const int BASE = (1 << 20);

long long N, L;
long long T[1 << 19], V[1 << 19];

int cl, cr;
long double X[1 << 21], Y[1 << 21];
long double offset_x, offset_y;

int main() {
	scanf("%lld%lld", &N, &L);
	for (int i = 1; i <= N; i++) scanf("%lld%lld", &T[i], &V[i]);

	cl = BASE; cr = BASE;
	X[cr - 1] = 0; Y[cr - 1] = 0; cr++;
	X[cr - 1] = L; Y[cr - 1] = 0; cr++;

	for (int i = 1; i <= N; i++) {
		offset_x += V[i];
		offset_y += T[i] * V[i];

		while (true) {
			if (cr - cl >= 2 && X[cr - 2] + offset_x > 1.0L * L) { X[cr - 1] = 0; Y[cr - 1] = 0; cr--; }
			else if (X[cr - 1] + offset_x > L) {
				long double E = Y[cr - 2] + 1.0L * (Y[cr - 1] - Y[cr - 2]) * ((L - offset_x) - X[cr - 2]) / (X[cr - 1] - X[cr - 2]);
				X[cr - 1] = L - offset_x;
				Y[cr - 1] = E;
				break;
			}
			else break;
		}

		while (cr - cl >= 2) {
			long double a1 = (Y[cl] + offset_y) / (X[cl] + offset_x);
			long double a2 = (Y[cl + 1] + offset_y) / (X[cl + 1] + offset_x);
			if (a1 <= a2) { X[cl] = 0; Y[cl] = 0; cl++; }
			else break;
		}

		cl--;
		X[cl] = -offset_x;
		Y[cl] = -offset_y;
		printf("%.12Lf\n", 1.0L * (Y[cr - 1] + offset_y) / L);
	}
	return 0;
}

Measured memory_bytes: 40192
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

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

   cout<<z<<" "<<x<<" "<<y<<"\n";




    



}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,k,N,mod,i,temp,res;
    int num[10];
    for(i=0;i<n;i++) num[i]=0;
    cin>>n>>k;
    for(i=0;i<k;i++){
        cin>>temp;
        num[temp]=1;
    }
    while(1){
        N=n;
        while(N){
            if(num[N%10]==1){
                n=n+1;
                break;
            }
            N=N/10;
        }
        if(N==0){
            res=n;
            break;
        }
    }
    cout<<n<<endl;
}


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

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int ar[n];
    for (int i = 0; i < n; i++) {
        cin >> ar[i];
    }
    sort(ar, ar + n);
    cout << ar[n / 2] - ar[n / 2 - 1] << '\n'; 
    return 0;
}

Measured memory_bytes: 640
o = list(input())
e = list(input())
s =[]
a=0
b=0
for i in range(len(o) + len(e)):
    if i % 2 == 0:
        s.append(o[a])
        a += 1
    else :
        s.append(e[b])
        b += 1

    
print('{}'.format("".join(s)))


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

const int cons = 1e9 + 7;

//D
int main(void) {
	ll n;
	cin >> n;
	vector<ll> a = vector<ll>(n);
	rep(0, n) cin >> a[i];
	vector<vector<ll>> dp = vector<vector<ll>>(n);
	dp[0].push_back(a[0] + a[1]);
	dp[0].push_back(-a[0] - a[1]);
	ll ans = max(dp[0][0],dp[0][1]);
	rep(1, n-1) {
		dp[i].push_back(max(dp[i - 1][0], dp[i - 1][1])+a[i+1]);
		dp[i].push_back(max(dp[i - 1][0] - 2*a[i], dp[i - 1][1] + 2 * a[i]) - a[i+1] ) ;
	}
	cout << max(dp[n - 2][0], dp[n - 2][1]) << endl;
}


Measured memory_bytes: 6528
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>

#pragma warning( disable: 4996 )

using namespace std;

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


#define INF 1000000000
#define EPS 1e-10
#define PI (atan(1.0) * 4.0)

#define MAX_N 100
#define MAX_M 100
#define MAX_L MAX_N - 2
#define MAX_A MAX_N - 1
#define MAX_H MAX_N - 1

int N;//町の数
int M;//再冷凍を行うまでの制限時間
int L;//冷凍施設のある町の数
int K;//町と町を直接結ぶ道路の数
int A;//本国の首都番号
int H;//お姫様がいる町の番号

int d[MAX_N][MAX_N];

bool city[MAX_N];

vector<int> ans_list;

void warshall_froyd(){
	for (int k = 0; k < N; k++){
		for (int i = 0; i < N; i++){
			for (int j = 0; j < N; j++){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int cost[MAX_N][MAX_N];
int dd[MAX_N];
bool used[MAX_N];

void dijkstra(int s){
	
	fill(dd, dd + N, INF);
	fill(used, used + N, false);
	dd[s] = 0;

	while (true){
		
		int v = -1;
		for (int i = 0; i < N; i++){
			if (!used[i] && (v == -1 || dd[v] > dd[i]))
				v = i;
		}

		if (v == -1)
			break;

		used[v] = true;

		for (int u = 0; u < N; u++){
			dd[u] = min(dd[u], dd[v] + cost[v][u]);
		}

	}

}

int main() {

	while (true){
		cin >> N >> M >> L >> K >> A >> H;
		if (N == 0 && M == 0 && L == 0 && K == 0 && A == 0 && H == 0)
			break;

		for (int i = 0; i < N; i++){
			for (int j = 0; j < N; j++){
				d[i][j] = INF;
				cost[i][j] = INF;
			}
			d[i][i] = 0;
		}

		fill(city, city + N, false);

		city[A] = city[H] = true;
		for (int i = 0; i < L; i++){
			int l;
			cin >> l;
			city[l] = true;
		}

		for (int i = 0; i < K; i++){
			int X, Y, T;
			cin >> X >> Y >> T;
			d[X][Y] = d[Y][X] = T;
		}

		warshall_froyd();

		for (int i = 0; i < N; i++){
			for (int j = 0; j < N; j++){
				if (i == j)
					continue;
				else if (city[i] && city[j] && d[i][j] <= M){
					cost[i][j] = cost[j][i] = d[i][j];
				}
			}
		}

		dijkstra(A);

		if (dd[H] == INF)
			ans_list.push_back(-1);
		else if (dd[H] <= M)
			ans_list.push_back(dd[H]);
		else
			ans_list.push_back(dd[H] * 2 - M);


	}

	for (int i = 0; i < ans_list.size(); i++){
		if (ans_list[i] != -1)
			cout << ans_list[i] << endl;
		else
			cout << "Help!" << endl;
	}

	return 0;
}

Measured memory_bytes: 1308
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto &x: a) cin >> x;

  ll mult = 0;
  for (int i = 0; i < n; i++) mult = (mult + a[i]) % mod;

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    mult -= a[i];
    if (mult < 0) mult += mod;
    ans = (ans + (a[i] * mult)) % mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4744
#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> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e20;
const int INF = 1e9;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, a;
  cin >> x >> a;
  x < a ? out(0) : out(10);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int N,L;
  scanf("%d %d", &N, &L);
  int a[N];
  for(int i=0;i<N;i++){
    scanf("%d", &a[i]);
  }

  int last = -1;
  for(int i=0;i<N-1;i++){
    if(a[i] + a[i+1] >= L) {
      last = i;
    }
  }
  if (last == -1) {
    printf("Impossible\n");
    return 0;
  }
  printf("Possible\n");
  for(int i=0;i<last;i++){
    printf("%d\n", i + 1);
  }
  for(int i=N-2;i>=last;i--){
    printf("%d\n", i + 1);
  }
}

Measured memory_bytes: 1152
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int a[100010],n;
int bs(int k){
	if(a[0]>k)return 0;
	int l=0,r=n;
	while(r-l>1){
		int m=(l+r)/2;
		if(a[m]<=k)l=m;
		else r=m;
	}
	return a[l]==k;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	int q;
	scanf("%d",&q);
	while(q--){
		int k;
		scanf("%d",&k);
		printf("%d\n",bs(k));
	}
}



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

int main(){
    int N, R;
    cin >> N >> R;
    
    if (N < 10) cout << R + 100 * (10-N) << endl;
    else cout << R << endl;
}

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

int* mallocint(int si)
{
    return (int*) malloc(si * sizeof(int));
}

int* inputint(int n)
{
    int *ans = mallocint(n);
    for( int i = 0; i < n; i++ ) cin >> ans[i];
    return ans;
}

int main()
{
    map<string, int> c;
    int n;
    cin >> n;
    string s;
    getline(cin, s);
    for( int i = 0; i < n; i++ )
    {
        getline(cin, s);
        int l = 0;
        for( l = 0; l < s.length(); l++ )
        {
            if( s[l] < 'a' || s[l] > 'z') break;
        }
        c[s.substr(0, l)]++;

    }

    cout << c.size();

    return 0;    
}

Measured memory_bytes: 19192
import sys
from copy import deepcopy

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def drop(H, W, G):
    for i in range(1, H):
        for j in range(W):
            if G[i][j] == -1 and G[i - 1][j] != -1:
                k = i
                for k in range(i, 0, -1):
                    if G[k][j] != -1:
                        break
                    G[k][j], G[k - 1][j] = G[k - 1][j], -1


def main():
    H, W, K = map(int, readline().split())
    G_init = [list(map(int, readline().strip())) for _ in range(H)]

    ans = 0
    for i in range(H):
        for j in range(W):
            G = deepcopy(G_init)
            G[i][j] = -1
            drop(H, W, G)

            current_ans = 0
            step = 0
            while True:
                score = 0
                for row in G:
                    cnt = 1
                    for k in range(1, W):
                        if row[k] == row[k - 1]:
                            cnt += 1
                        else:
                            if cnt >= K and row[k - 1] != -1:
                                score += row[k - 1] * cnt
                                row[k - cnt : k] = [-1] * cnt
                            cnt = 1
                    if cnt >= K and row[W - 1] != -1:
                        score += row[W - 1] * cnt
                        row[W - cnt : W] = [-1] * cnt

                if score == 0:
                    break

                current_ans += score * pow(2, step)
                step += 1
                drop(H, W, G)

            if current_ans > ans:
                ans = current_ans

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 54236
let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f
let [| n; k; q; |] = reads int64
let ns = Array.zeroCreate (int n)
for t = 0 to (int q)-1 do
    let i = (read int) - 1
    ns.[i] <- ns.[i]+1
 
for v in ns do
    if k - (q-(int64 v)) <= 0L then
        printfn "No"
    else
        printfn "Yes"

Measured memory_bytes: 18388
import math
import sys

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n = int(input())

if n <= 1:
    print(0)
    sys.exit()

yakusu = set(make_divisors(n))
yakusu.discard(1)

sosu = set([min(yakusu)])
tansaku = set(yakusu)
kari = set(tansaku)



while 1:
    for var in tansaku:
        if var % max(sosu) == 0:
            kari.discard(var)
    tansaku = set(kari)
    if len(tansaku) == 0:
        break
    sosu.add(min(tansaku))
sosu = sosu | tansaku

i = 1
j = 0
kari = set(sosu)

while n != 1:
    for var in sosu:
        if n % (var ** i) == 0:
            n = n / (var ** i)
            j += 1
        else:
            kari.discard(var)
    sosu = set(kari)

    i += 1
    if i > 1000:
        break

print(j)


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  vector<int> b;

  for (int i=0; i<n; i++) {
    if (i%2==0) {
      b.insert(b.begin(), a[i]);
    } else {
      b.push_back(a[i]);
    }
  }
  if (n%2==0) reverse(b.begin(), b.end());

  cout << b[0];
  for (int i=1; i<n; i++) {
    cout << " " << b[i];
  }
  cout << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <sstream>
#include <bitset>
using namespace std;

int main() {
    int number;
    cin >> number;
    int min_count = 100;
    for(int i = 0; i < number ; i++)
    {
        int x;
        cin >> x;
        stringstream ss;
        ss << static_cast<std::bitset<40> >(x);
        string input_number = ss.str();
        int count = -1;
        for(int j = input_number.size(); j> 0 ; j--)
        {
            if(input_number[j] == '1') break;
            count++;
        }
        min_count = min(min_count, count);
    }
    cout << min_count << endl;

}

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


int main(){
    string s,t;
    cin>>s>>t;

    if(s[0]==t[2] && s[1]==t[1] && s[2]==t[0]) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');
  var params = inputs[0].split(' ').map(Number);

  (function(a, b) {
    // ????????????????????????
console.log(a*b,(a+b)*2);
  })(params[0], params[1]);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;
#define sz              300005
#define Fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

string s;

int main(){
    Fast;
    int a,b,c, i,j, n,m,t, cs=1;
    cin>>n>>s;

    if(s.size()<=n){
        cout<<s<<endl;
        return 0;
    }
    for(i=0; i<n; i++){
        cout<<s[i];
    }
    cout<<"..."<<endl;


    return 0;
}



Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <numeric>
#include <chrono>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <cstring>
#include <cassert>
using namespace std;

const int N = 2e5 + 10, mod = 1e9 + 7;


int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
    // scanf("%d", &tc);
    set<int> hon, pon, bon;
    hon = {2, 4, 5, 7, 9};
    pon = {0, 1, 6, 8};
    bon = {3};
    for(int cn = 1; cn <= tc; cn++) {
        int n; scanf("%d", &n);
        int d = n % 10;
        if(hon.erase(d)) puts("hon");
        else if(pon.erase(d)) puts("pon");
        else puts("bon");
    }  
    return 0;
}

Measured memory_bytes: 3692
#include <stdio.h>
int main()
{
  int n,i,j,min,tmp,count=0;
  int buf[101];
  scanf("%d",&n);
  for(i=0;i<n;i++){
	  scanf("%d",&buf[i]);
  }
  for(i=0;i<n;i++){
	  min=i;
	  for(j=i;j<n;j++){
		  if(buf[j] < buf[min]){
			  min=j;
		  }
	  }
	  if(i!=min){
		  tmp=buf[i];	
		  buf[i]=buf[min];
		  buf[min]=tmp;
		  count++;
	  }
  }
  for(i=0;i<n;i++){
	  printf("%d",buf[i]);
	  if(i==n-1) printf("\n");
	  else printf(" ");
  }  
  printf("%d\n",count);
  return 0;
}

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

#define datatype pair

typedef struct {
	int val;
	int pos;
}pair;

//比較関数
int compare(datatype a, datatype b){
	if(a.val < b.val){
		return -1;
	}
	else if(a.val > b.val){
		return 1;
	}
	else{
		return 0;
	}
}

int root(int a, int *array){
	if(array[a] == a){
		return a;
	}
	else{
		array[a] = root(array[a], array);
		return array[a];
	}
}

void combine(int a, int b, int *array, int *array_rank){
	int a_root = root(a, array);
	int b_root = root(b, array);
	if(a_root == b_root){
		return;
	}
	else if(array_rank[a_root] < array_rank[b_root]){
		array[a_root] = b_root;
		array_rank[b_root] += array_rank[a_root];
	}
	else{
		array[b_root] = a_root;
		array_rank[a_root] += array_rank[b_root];
	}
}

//昇順
void sort_sub(datatype *origin, int left, int right, datatype *tmp){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp);
		sort_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if((compare(tmp[j], tmp[k]) <= 0 && j < half) || k == right){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(datatype *origin, int N){
	datatype *tmp = (datatype *)malloc(sizeof(datatype) * N);
	sort_sub(origin, 0, N, tmp);
}

int main(){
	int N, x, i, j, k, prev;
	scanf("%d", &N);
	int *a0 = (int *)malloc(sizeof(int) * (N + 1));
	int *b0 = (int *)malloc(sizeof(int) * (N + 1));
	int *a = (int *)malloc(sizeof(int) * (N + 1));
	int *b = (int *)malloc(sizeof(int) * (N + 1));
	x = 0;
	for(i = 0; i < N; i++){
		scanf("%d", &a0[i]);
		x ^= a0[i];
	}
	a0[N] = x;
	x = 0;
	for(i = 0; i < N; i++){
		scanf("%d", &b0[i]);
		x ^= b0[i];
	}
	b0[N] = x;
	for(i = 0, j = 0; i < N; i++){
		if(a0[i] != b0[i]){
			a[j] = a0[i];
			b[j] = b0[i];
			j++;
		}
	}
	a[j] = a0[N];
	b[j] = b0[N];
	N = j;
	if(N == 0){
		printf("0\n");
		return 0;
	}
	pair *a2 = (pair *)malloc(sizeof(pair) * (N + 1));
	pair *b2 = (pair *)malloc(sizeof(pair) * (N + 1));
	for(i = 0; i <= N; i++){
		a2[i].val = a[i];
		b2[i].val = b[i];
		a2[i].pos = i;
		b2[i].pos = i;
	}
	sort(a2, N + 1);
	sort(b2, N + 1);
	for(i = 0, j = -1, prev = -1; i <= N; i++){
		if(a2[i].val != b2[i].val){
			printf("-1\n");
			return 0;
		}
		if(prev != a2[i].val){
			j++;
		}
		prev = a2[i].val;
		a[a2[i].pos] = j;
		b[b2[i].pos] = j;
	}
	j++;
	int *uni = (int *)malloc(sizeof(int) * j);
	int *uni_rank = (int *)malloc(sizeof(int) * j);
	int *exist = (int *)malloc(sizeof(int) * j);
	for(i = 0; i < j; i++){
		uni[i] = i;
		uni_rank[i] = 1;
		exist[i] = -1;
	}
	for(i = 0; i <= N; i++){
		combine(a[i], b[i], uni, uni_rank);
	}
	for(i = 0, k = 0; i < j; i++){
		if(exist[root(i, uni)] == -1){
			exist[root(i, uni)] = 1;
			k++;
		}
	}
	printf("%d\n", N + k - 1);
	return 0;
}

Measured memory_bytes: 6016
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>

using namespace std;

unsigned long long int a = 0, b = 0, c =0, d = 0, e = 0, n = 0, maxy = 0, mini = 9999, ans = 0, counter = 0, sur = 0;
std::vector<int> vec{};
std::vector<char>cha{};

int arraykun[2300] = {}, nyan[1001] = {}, koji[50][50];
std::string output, output2, str, input;
int kakunou[50][50] = { 53 }, moji[50];

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
int dp(int i, int j) {
	bool okada = true;
	if (i == 0 || j == 0) {
		okada = false;
		return 0;
	}
	if (koji[i][j] == -1) {
		okada = false;
		return 0;
	}
	if (i == 1 && j == 1) {
		okada = false;
		return 1;
	}
	if (okada) {
		return dp(i - 1, j) + dp(i, j - 1);
	}

}
int main()
{

	cin >> input;
	for (int i = 0; i < input.size(); i++) {
		if (input[i]=='W') {
			counter++;
			ans += i+1-counter;
		}
	}
	cout << ans << endl;

}






Measured memory_bytes: 640
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>
#include <numeric>

using namespace std;

template <typename T>
using TABLE = vector<vector<T>>;

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;


int main(){
    long long H, W;
    cin >> H >> W;

    TABLE<long long> A(H, vector<long long>(W, 0));
    string s;

    vector<pair<int, int>> v;
    for(int y = 0; y < H; ++y){
        cin >> s;
        for(int x = 0; x < W; ++x){
            if(s[x] == '.'){
                A[y][x] = 1;
            }
            else{
                v.push_back(pair<int, int>(y, x));
            }
        }
    }

    int count = 0;
    vector<pair<int, int>> v_sub;

    while(v.size()){
        v_sub.clear();
        for(auto& pos : v){
            int y = pos.first;
            int x = pos.second;

            if(y != 0 && A[y-1][x]){
                A[y-1][x] = 0;
                v_sub.push_back(pair<int, int>(y-1, x));
            }
            if(x != 0 && A[y][x-1]){
                A[y][x-1] = 0;
                v_sub.push_back(pair<int, int>(y, x-1));
            }
            if(y != H - 1 && A[y+1][x]){
                A[y+1][x] = 0;
                v_sub.push_back(pair<int, int>(y+1, x));
            }
            if(x != W - 1 && A[y][x+1]){
                A[y][x+1] = 0;
                v_sub.push_back(pair<int, int>(y, x+1));
            }
        }
        swap(v, v_sub);
        ++count;
    }

    cout << count - 1;
}


Measured memory_bytes: 20968
#include <bits/stdc++.h>
using namespace std;
int v[100005],s;
int main()
{
    scanf("%d",&s); v[s]=1;
    for(int i=2;;i++){
        if(s%2) s=s*3+1;
        else s/=2;
        if(v[s]){
            printf("%d",i);
            break;
        }
        v[s]=1;
    }
    return 0;
}


Measured memory_bytes: 256
from math import log10, sqrt
n = int(input())
def keta(n):
    res = 0
    while n >0 :
        res +=1
        n //= 10
    return res
ans = 1 << 22
for a in range(1, int(sqrt(n))+1):
    if n % a == 0:
        b = n // a
        ans = min(ans, max(keta(a) , keta(b)))
print(ans)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

N, T = map(int, input().split(' '))
costs = []
for _ in range(N):
    c, t = map(int, input().split(' '))
    if t <= T:
        costs.append(c)

if len(costs) == 0:
    print('TLE')
else:
    print(min(costs))

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

using namespace std;

using ll = long long;

int const maxn = 101;
int const maxv = 1010;
ll const inf = 0x3f3f3f3f3f3f3f3f;

struct Item {
    int w, v;
};

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

    int n, s;
    cin >> n >> s;

    vector<Item> items(n);
    int maxv = 0;

    for (auto& i  : items) {
        cin >> i.w >> i.v;
        maxv += i.v;
    }

    vector<long long> dp(s+1, -inf);
    dp[0] = 0;

    for (auto item : items) {
        for (int i = s; i >= item.w; i--) {
            dp[i] = max(dp[i], dp[i-item.w] + item.v);
        }
    }

    ll ans = *max_element(dp.begin(), dp.end());

    cout << ans << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (ll i=0, i##_limit=(n); i<i##_limit; ++i)
#define FOR(i, a, b) for (ll i=(a), i##_limit=(b); i<i##_limit; ++i)
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using pi = pair<int, int>;

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

    ll sum[N];
    sum[0] = A[0];
    FOR(i, 1, N) sum[i] = sum[i-1] + A[i];

    double c = sum[N-1] / 2.0;
    ll ci;
    REP (i, N) if (sum[i-1] < c && sum[i] >= c) { ci = i; break; }
    double len = sum[ci] - c;

    cout << (ll)(min(len, A[ci]-len)*2) << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007
//#define MOD 7

using namespace std;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void){
    // Your code here!
    long long n, k;
    long long comb1[2001] = {};
    long long comb2[2001] = {};
    comb1[0] = 1;
    comb2[0] = 1;
    
    cin >> n >> k;
    for(int i = 1; i <= n - k + 1; i++)
        comb1[i] = ((comb1[i-1] * (n - k + 1 - i + 1) % MOD) * modinv(i, MOD)) % MOD;
        
    for(int i = 1; i <= k; i++)
        comb2[i] = ((comb2[i-1] * (k - 1 - i + 1) % MOD) * modinv(i, MOD)) % MOD;
   
    for(long long i = 1; i <= k; i++)
        cout << ((comb1[i] % MOD) * comb2[i-1]) % MOD << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
a = int(input())
S = 'abcdefghij'

def dfs(s,c):
    if c == a:
        ans.append(s)
        return 
    for i in S[:c+1]:
        if i in s:dfs(s+i,c+1)
        else:
            dfs(s+i,c+1)
            return 
ans = []

dfs("",0)

for i in ans:
    print(i)

Measured memory_bytes: 12656
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
typedef pair<pair<lint, int>, pair<int, int>> ppp;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 1e9 + 7;
const lint INF = mod;
const int MAX = 100010;

int main(){
    int n, t;
    scanf("%d%d", &n, &t);
    pii p[n];
    rep(i, n) scanf("%d%d", &p[i].fi, &p[i].se);
    sort(p, p+n, [](const pii &a, const pii &b){return a.fi==b.fi ? a.se>b.se : a.fi<b.fi;});

    int dp[n+1][t+1];
    rep(i, n+1)rep(j, t+1) dp[i][j]=-1;
    dp[0][0]=0;
    rep(i, n)rep(j, t+1)if(dp[i][j]>=0){
        chmax(dp[i+1][j], dp[i][j]);
        if(j<t) chmax(dp[i+1][min(t, j+p[i].fi)], dp[i][j]+p[i].se);
    }

    int ans=0;
    rep(j, t+1) chmax(ans, dp[n][j]);
    printf("%d\n", ans);
}

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

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);

    unsigned long long int nm[100000];
    long double ans = 1;
    for (int i = 0; i < n; i++)
    {
        scanf("%llu", &nm[i]);
        if (nm[i] == 0)
        {
            printf("0");
            return 0;
        }
    }

    for (int i = 0; i < n; i++)
    {
        ans *= nm[i];

        if (ans > 1000000000000000000 || ans < 0)
        {
            printf("-1");
            return 0;
        }
    }

    printf("%lld", (long long int)ans);

    return 0;
}

Measured memory_bytes: 4548
#include <iostream>
#include <climits>
#include <cstdio>
#include <stdio.h> 
#include <map>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

bool check(char ch) {
	return ch == 'A' || ch=='G' || ch=='T' || ch=='C';
}

int main() {
	string s;
	cin>>s;
	int mx = 0;
	for (int i=0; i<s.size(); i++) {
		if(check(s[i])) {
			int cnt = 1;
			while(check(s[i])) {
				cnt++;
				i++;
			}
			mx = max(mx, cnt-1);
		}
	}
	cout << mx;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    ll res=0;
    rep(i,n){
        int x;
        cin >> x;
        res+=(x-1);
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

long long n, a[100005], sum = 0, b[100005];

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    if(sum %( n * (n + 1) / 2) != 0){
        cout << "NO\n";
        return 0;
    }
    long long num = sum / (n * (n + 1) / 2);
    for(int i = 0; i < n; i++){
        b[i] = -a[(i + 1)%n] + a[i] + num;
        if(b[i] >= 0 && b[i] % n == 0){

        }
        else{
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}


Measured memory_bytes: 1792
N, *A = map(int, open(0).read().split())
X = [(x-l, x+l) for x, l in zip(*[iter(A)]*2)]
X.sort()
ans = 1
L, R = X[0]
for l, r in X[1:]:
    if R <= l:
        ans += 1
        L = l
        R = r
    elif R > r:
        R = r
print(ans)


Measured memory_bytes: 33116
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;
ll dp[100005][2];
// dp[i][j] := a+b を i 桁目まで見て、 
// j = 0 := a+b が i桁までが一致している
// j = 1 := a+b が L 未満であることが既に確定している

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

    string s;
    cin >> s;
    int N = s.size();
    dp[0][0] = 1;
    for(int i=0;i<N;i++){
        { // a + b = 0 
            if(s[i] == '0'){
                dp[i+1][0] = dp[i][0];
                dp[i+1][1] = dp[i][1];
            }else{
                dp[i+1][1] = (dp[i][0] + dp[i][1])% mod;
            }
        }
        { // a + b = 1
            if(s[i] == '0'){
                dp[i+1][1] += dp[i][1] * 2 % mod;
            }else{
                dp[i+1][0] += dp[i][0] * 2 % mod;
                dp[i+1][1] += dp[i][1] * 2 % mod;
            }
        }
    }
    ll ans = (dp[N][0] + dp[N][1]) % mod;
    cout << ans << endl;
}

Measured memory_bytes: 2000
#include <iostream>
 
using namespace std;
 
int main(int argc, char* argv[])
{
    int num[3];
    int temp;
    cin >> num[0] >> num[1] >> num[2];
     
  
    while(num[0] > num[1] or num[1] > num[2])
    {
        if(num[0] > num[1])
        {
            temp = num[1];
            num[1] = num[0];
            num[0] = temp;
            if(num[1] > num[2])
            {
                temp = num[2];
                num[2] = num[1];
                num[1] = temp;
            }
        }
        else if(num[1] > num[2])
        {    
           temp = num[1];
           num[1] = num[2];
           num[2] = temp;
        }
    }
    cout << num[0] <<" "<< num[1] <<" "<< num[2] << endl;
}

Measured memory_bytes: 3100
#include <iostream>
#include <string>

using namespace std;

int main(){

  int i,m,M;
  string S,T,U;
  double N;
  const double PI=3.14159265358979323846;
  //cin>>S>>T;
  
  cin>>N;
  //cin>>U;

  
  //  cout<<S<<endl;
  cout<<N*PI*2.0<<endl;
    return 0;
}


Measured memory_bytes: 3708
n,m=map(int,input().split())
a=list(map(int,input().split()))
ki=[[] for _ in range(n)]
for _ in range(m):
  x,y=map(int,input().split())
  ki[x].append(y)
  ki[y].append(x)
ans=0
cost=[]
mi=set(range(n))
cnt=0
from heapq import heappop,heappush,heapify
while mi:
  todo=[mi.pop()]
  g=[a[todo[0]]]
  while todo:
    v=todo.pop()
    for nv in ki[v]:
      if nv in mi:
        todo.append(nv)
        heappush(g,a[nv])
        mi.discard(nv)
  ans+=heappop(g)
  cost+=g
  cnt+=1
if cnt==1:
  print(0)
elif 2*(cnt-1)<=n:
  cost.sort()
  k=(cnt-1)*2-cnt
  ans+=sum(cost[:k])
  print(ans)
else:
  print('Impossible')

Measured memory_bytes: 108580
from sys import stdin, setrecursionlimit


def main():
    input = stdin.readline
    n = int(input())
    s_arr = []
    t_arr = []
    for _ in range(n):
        s, t = list(map(str, input().split()))
        t = int(t)
        s_arr.append(s)
        t_arr.append(t)
    x = input()[:-1]
    print(sum(t_arr[s_arr.index(x) + 1:]))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
using namespace std;

 long long modpow( long long a,  long long n,  long long mod) {
     long long res = 1;
    while (n > 0) {
        if (n & 1) res = res%mod * a % mod;
        a = a%mod * a % mod;
        n >>= 1;
    }
    return res;
}


int main(){
     long long N;
    cin >> N;
     long long answer = 0;
    if(N==1) answer = 0;
    if(N>=2){
        answer = (modpow(10,N,1000000007)-2*modpow(9,N,1000000007)%1000000007+modpow(8,N,1000000007))%1000000007;
    }
    answer=(answer+1000000007)%1000000007;
  cout << answer << endl;
    return 0;
}

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

using namespace std;

typedef long long LL;

const int N = 1010;

int n, t, a;
double res = 0x3f3f3f3f;
int idx;

int main()
{
    cin >> n >> t >> a;
    for(int i = 1; i <= n; i++)
    {
        double h;
        cin >> h;
        if(abs(a - (t - 0.006 * h)) < res)
        {
            res = abs(a - (t - 0.006 * h));
            idx = i;
        }
    }

    cout << idx << endl;
    return 0;
}


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


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

    int n;
    cin>>n;

    long long ans = 0, prv = 0;
    for (int i=1; i<=n; i++) {
        int x;
        cin>>x;

        if (x == 0) prv = 0;
        else if (x%2 == 0)      ans += x/2;
        else {
            ans += x/2;
            x = 1;
            if (prv)    ans++, prv = 0;
            else        prv = 1;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <bitset>
#include <ciso646>
#include <algorithm>


#define REP(i,N) for(size_t i=0;i<N;++i)

using namespace std;

int main() {
    using ll = long long;
    ll N; cin >> N;
    vector<ll> as, bs;
    REP(i,N){
        ll a; cin >> a;
        as.emplace_back(a);
    }
    REP(i,N) {
        ll b; cin >> b;
        bs.emplace_back(b);
    }

    bitset<30> res;
    REP(bit, 30){
        ll mask = (1 << (bit+1)) - 1;
        vector<ll> maskA(as);
        vector<ll> maskB(bs);
        for(auto &a:maskB) a &= mask;
        for(auto &a:maskA) a &= mask;
        sort(maskB.begin(), maskB.end());
        ll cnt = 0;
        for(auto &a:maskA){
            ll left =  (1 << bit) - a;
            ll right = (1 << (bit+1)) - a;
            auto leftIndex = lower_bound(maskB.begin(), maskB.end(), left);
            auto rightIndex = lower_bound(maskB.begin(), maskB.end(), right);
            cnt += std::distance(leftIndex, rightIndex);
            if(bit == 29) continue;
            left =  (1 << bit) + (1 << (bit+1)) - a;
            right = (1 << (bit+2)) - a;
            leftIndex = lower_bound(maskB.begin(), maskB.end(), left);
            rightIndex = lower_bound(maskB.begin(), maskB.end(), right);
            cnt += std::distance(leftIndex, rightIndex);
        }
        res[bit] = (cnt%2);
    }
    cout << res.to_ullong() << endl;
    return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{
    int n;
    cin >> n;
    map<int, int> countNumMap[2];
    REP(i, n)
    {
        int t;
        cin >> t;
        if (countNumMap[i % 2].find(t) == countNumMap[t % 2].end())
        {
            countNumMap[i % 2][t] = 1;
        }
        else
        {
            countNumMap[i % 2][t]++;
        }
        
    }

    vector<pair<int, int>> countPair[2];
    for (int i = 0; i <= 1; ++i)
    {
        for (auto iter = countNumMap[i].begin(); iter != countNumMap[i].end(); ++iter)
        {
            countPair[i].push_back(make_pair(iter->first, iter->second));
        }
        sort(countPair[i].begin(), countPair[i].end(), compare_by_b);
    }

    int ans;
    if (countPair[0][0].first != countPair[1][0].first)
    {
        ans = n / 2 - countPair[0][0].second + n / 2 - countPair[1][0].second;
    }
    else
    {
        int numEven = countPair[0].size() == 1 ? n / 2 : n / 2 - countPair[0][1].second;
        int numOdd = countPair[1].size() == 1 ? n / 2 : n / 2 - countPair[1][1].second;
        ans = min(n / 2 - countPair[0][0].second + numOdd, numEven + n / 2 - countPair[1][0].second);
    }

    cout << ans << endl;
}


Measured memory_bytes: 6136
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
constexpr long long MOD = 1000000007;

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

std::vector<std::vector<int>> A;
std::vector<int> C;
int X;
int dfs(int i, int c, std::vector<int>& B)
{
  if(i == C.size())
  {
    auto it = std::find_if(B.begin(), B.end(), [=](int x) { return x < X; });
    return it == B.end() ? c : INT_MAX;
  }
  int ans = dfs(i + 1, c, B);
  for(int j = 0; j < B.size(); ++j)
  {
    B[j] += A[i][j];
  }
  ans = std::min(ans, dfs(i + 1, c + C[i], B));
  for(int j = 0; j < B.size(); ++j)
  {
    B[j] -= A[i][j];
  }
  return ans;
}

int main()
{
  int N, M;
  std::cin >> N >> M >> X;
  while(N--)
  {
    int c;
    std::cin >> c;
    C.push_back(c);
    A.push_back(std::vector<int>(M));
    for(auto& val: A.back())
      std::cin >> val;
  }
  std::vector<int> B(M, 0);
  auto ans = dfs(0, 0, B);
  std::cout << (ans == INT_MAX ? -1 : ans) << std::endl;
  return 0;
}



Measured memory_bytes: 3644