akhauriyash/Code-Regression huggingface dataset:
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=233333333;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

vector<int> g[1111];
int p[1111],n,v[1111],sz[1111],dp[1111][2];

int mn[1111][5555];

void dfs(int x)
{
	for(int i=0;i<(int)g[x].size();i++)
		dfs(g[x][i]);
	int sz=(int)g[x].size();
	for(int i=0;i<sz;i++)
	{
		for(int j=0;j<=5000;j++)
		{
			mn[i+1][j]=inf;
			if(j>=v[g[x][i]])mn[i+1][j]=min(mn[i+1][j],mn[i][j-v[g[x][i]]]+dp[g[x][i]][1]);
			if(j>=dp[g[x][i]][0])mn[i+1][j]=min(mn[i+1][j],mn[i][j-dp[g[x][i]][0]]+v[g[x][i]]);
		}
	}
	dp[x][0]=mn[sz][v[x]];dp[x][1]=inf;
	for(int i=0;i<=5000;i++)if(mn[sz][i]<=v[x])dp[x][1]=min(dp[x][1],i);
}
int main()
{
	get1(n);
	for(int i=2;i<=n;i++){get1(p[i]);g[p[i]].pb(i);}
	for(int i=1;i<=n;i++)get1(v[i]);
	
	dfs(1);
	if(dp[1][0]<inf||dp[1][1]<inf)puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 22784
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		char[] c = sc.next().toCharArray();
		Arrays.sort(c);
		for (int i = 1; i < c.length; i++) {
			if (c[i] == c[i - 1]) {
				System.out.println("no");
				return;
			}
		}
		System.out.println("yes");
	}

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


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
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; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

bool dp[100100];

int main(){
    int N,K;cin >> N >> K;
    vector<int> a(N);
    rep(i,N)cin >> a[i];



    for(int i = 1;i <= K;++i) rep(j,N) if(i - a[j] >= 0)dp[i] |= !dp[i - a[j]];

    string ans = "";
    if(dp[K])ans = "First";
    else ans = "Second";
    cout << ans << endl;
}



Measured memory_bytes: 384
import numpy as np 
from itertools import combinations

n, m, x = [int(i) for i in input().split()]
A = np.array([[int(i) for i in input().split()]for j in range(n)])
cost = n*(10**5)
A_index_set = range(n)
satisfy_flag = False
for L in range(1, n+1):
    for subset in combinations(A_index_set, L):
        ans = np.array([0 for i in range(m+1)])
        for j in subset:
            ans += A[j,:]
        for sub_j in range(1, m+1): # check if everyone is more than x
            if  ans[sub_j] < x:
                break
        else:
            satisfy_flag = True
            cost = min(cost, ans[0])
if satisfy_flag:
    print(cost)
else:
    print(-1)

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repc(i, a, b) for(int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main() {
  int n, m;
  cin >> n >> m;
  vec<int> h(n+1);
  vec<int> h_max(n+1, 0);
  repc(i, 1, n) cin >> h[i];
  repc(i, 1, m) {
    int a, b;
    cin >> a >> b;
    h_max[a] = max(h_max[a], h[b]);
    h_max[b] = max(h_max[b], h[a]);
  }
  int ans = 0;
  repc(i, 1, n) {
    if(h[i] > h_max[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(void) {
  string s;
  int q;
  cin >> s >> q;
  int r, f;
  char c;
  int head = 1;
  string headstr = "";
  string tailstr = "";
  for (int i = 0; i < q; ++i) {
    cin >> r;

    if (r == 1) {
      head = head == 1 ? 2 : 1;

    } else {
      cin >> f >> c;

      if (f == head) {
        headstr += c;
      } else {
        tailstr += c;
      }
    }
  }

  string result;
  if (head == 1) {
    reverse(headstr.begin(), headstr.end());
    result = headstr + s + tailstr;
  } else {
    reverse(tailstr.begin(), tailstr.end());
    reverse(s.begin(), s.end());
    result = tailstr + s + headstr;
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 4268
#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("sumsqr.in");ofstream out("sumsqr.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    ll a,k; cin>>a>>k;
    set<int> s;
    for(; k--;){
        ll x; cin>>x;
        for(; x--;){
            int u; cin>>u;
            s.insert(u);
        }
    }
    cout<<a-s.size();
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
// #define var(t,n,...) t n;scan(n,__VA_ARGS__)
// template<class V,class H,class...T>void scan(V&a,H )

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	set<int> v;
	rep(i,n){
		int a,b; cin>>a>>b;
		v.insert(a*8+b);
	}

	vi a(8);
	iota(all(a),0);
	do{
		vi b(8);
		auto c=v;
		rep(i,8){
			b[i]=a[i]+i*8;
			if(c.find(b[i])!=c.end()) c.erase(b[i]);
		}
		if(c.size()!=0)continue;
		bool ok=true;
		rep(i,8){
			rep(j,i){
				ok&=(b[j]%8==0 or (b[i]-b[j])%7!=0 or (b[i]-b[j])/7!=i-j);
				ok&=(b[j]%8==7 or (b[i]-b[j])%9!=0 or (b[i]-b[j])/9!=i-j);
			}
		}
		if(!ok)continue;
		rep(i,8){
			rep(j,8){
				cout<<".Q"[a[i]==j];
			}
			cout<<endl;
		}
	}while(next_permutation(all(a)));
	return 0;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define MAX 105
#define int long long int

void solve()
{
    string S,T;
    cin >> S >> T;
    int n=S.size();
    int m = T.size();
    int ans = LLONG_MAX;
    for(int i = 0 ; i < n ; i++)
    {
        string temp;
        int cnt =0;
        for(int j = i ; j < n ; j++)
        {
            if(cnt==m)
                break;
            temp.pb(S[j]);
            cnt++;
        }
        if(cnt!=m)
            break;
        int x = 0;
        for(int j = 0 ; j < m ; j++)
        {
            if(T[j] != temp[j])
                x++;
        }
        ans = min(ans,x);
        
    }
    
    cout << ans;
    
    
    return;
}

int32_t main()
{
    int T = 1;
    //cin >> T;
    for(int i = 1 ; i <= T ; i++)
        solve();
    
    return 0;
}
/*
 AtCoder after Google Online Challenge Fail:(
 */


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

ll f(ll a, ll b, ll x){
    return (a*x)/b - (x/b) * a;
}

int main(void) 
{
    ll a, b, n;
    cin >> a >> b >> n;
    ll ans =0;
    ans = f(a,b,min(b-1,n));
    cout << ans << endl;
}

Measured memory_bytes: 3640
class AC:
    @staticmethod
    def inputStr(char):
        return input().split(char)
    
    @staticmethod
    def inputInt(char):
        a = input().split(char)
        for i in range(len(a)):
            a[i] = int(a[i])
        return a

N  = int(input())
a = AC.inputInt(" ")

counter_1 = 1 #探す番号
counter_2 = 0 #ループ用
delete = 0

for i in range(N):
    if a[i] == counter_1:
        counter_1 = counter_1 + 1
counter_1 = counter_1 - 1

if counter_1 == 0 :
    print(-1)
else:
    print(N - counter_1)

Measured memory_bytes: 18800
#include<stdio.h>
int main(){
  int a,b,c,d,x,y;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  x=(a+b+c+d)/60;
  y=(a+b+c+d)%60;
  printf("%d\n",x);
  printf("%d\n",y);
  return(0);
}

Measured memory_bytes: 596
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
const int N=302;
int n,m,k,ans[N][N],cnt[N];
char s[N][N];
int main() {
	scanf("%d%d%d",&n,&m,&k);
	for (int i=1;i<=n;i++)
	 for (int j=1;j<=m;j++) {
	 	cin>>s[i][j];
	 	if (s[i][j]=='#')++cnt[i];
	 }
	int sta,en;
	for (int i=1;i<=n;i++) if (cnt[i]) {
		sta=i;
		break;
	}
	int p=0;
	for (int i=sta;i<=n;i++) {
		if (!cnt[i]) {
			for (int j=1;j<=m;j++)
			 ans[i][j]=ans[i-1][j];
			continue;
		}
		p++;
		for (int j=1;j<=m;j++) {
			ans[i][j]=p;
			if (s[i][j]=='#') {
				cnt[i]--;
				if (cnt[i])p++;
			}
		}
	}
	for (int i=sta-1;i>0;i--) {
		for (int j=1;j<=m;j++)
		 ans[i][j]=ans[i+1][j];
	}
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++)printf("%d ",ans[i][j]);
		printf("\n");
	}
	return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll h, w;
  vector <string> s(h);
  cin >> h >> w;
  forll(i, 0, h){
	cin >> s[i];
  }
  cout << string(w + 2, '#') << endl;
  forll(i, 0, h){
	cout << '#' << s[i] << '#' << endl;
  }
  cout << string(w + 2, '#') << endl;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int const N = 50001;

/*void dfs(int u, int c)
{
    connect[u] = c;
    rep(i, G[u].size())
    {
        if (connect[G[u][i]] == -1)
        {
            dfs(G[u][i], c);
        }
    }
    return;
}*/

int main()
{
    int n, m;
    cin >> n >> m;
    int p[n] = {};
    vector<int> G[n];
    vector<int> connect(n, -1);
    rep(i, n)
    {
        cin >> p[i];
        p[i]--;
    }

    rep(i, n)
        connect[i] = -1;

    rep(i, m)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    int cnt = 0;

    rep(u, n)
    {
        if (connect[u] != -1)
            continue;
        queue<int> q;
        q.push(u);
        cnt++;
        while (!q.empty())
        {

            int v = q.front();
            connect[v] = cnt;
            q.pop();
            rep(i, G[v].size())
            {
                if (connect[G[v][i]] == -1)
                    q.push(G[v][i]);
            }
        }
    }

    int ans = 0;
    rep(i, n) if (connect[i] == connect[p[i]]) ans++;

    OP(ans);

    return 0;
}

Measured memory_bytes: 6528
n,y = (int(i) for i in input().split())
a,b,c = -1,-1,-1
if n*1000 <= y <= n*10000:
	y2 = (y-y%10000)//10000
	for j in range(y2,-1,-1):
		y3 = ((y-j*10000)-(y-j*10000)%5000)//5000
		for k in range(y3,-1,-1):
			if (n-j-k)*1000+j*10000+k*5000 == y:
				a,b,c = j,k,n-j-k
				break
				break
print(a,b,c)

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int map[101][101];
int main(void) {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		int m;
		cin >> m;
		for (int j = 0; j < m; j++) {
			int b;
			cin >> b;
			map[a][b] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (j != 1) cout << " ";
			cout << map[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3132
using System;

namespace abc104_a
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			if (n < 1200) Console.WriteLine("ABC");
			else if(n < 2800)Console.WriteLine("ARC");
			else Console.WriteLine("AGC");
		}
	}
}


Measured memory_bytes: 11092
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop, heapify
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()

LR = [[A[-1], A[-1]]]
for b in A[::-1][1:]:
	LR.append([-(-LR[-1][0]//2)+b, LR[-1][1]+b])

LR = LR[::-1]
if LR[0][0] <= 1 <= LR[0][1]:
	pass
else:
	print(-1)
	exit()

ans = 1
tmp = 1
for i, (L, R) in enumerate(LR[1:], 1):
	tmp = min(2*tmp-A[i], R-A[i])
	ans += tmp+A[i]

print(ans)

Measured memory_bytes: 32828
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include<bits/stdc++.h>
//#include <bits/extc++.h>
#define fi first
#define se second
#define db double
#define mp make_pair
#define pb push_back
#define mt make_tuple
//#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 1000000007
#define ld long double
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define bpc __builtin_popcount
#define base 1000000000000000000ll
#define fin freopen("a.txt","r",stdin)
#define fout freopen("a.txt","w",stdout)
#define mr mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
inline ll mul(ll a,ll b,ll c){return (a*b-(ll)((ld)a*b/c)*c+c)%c;}
inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=mul(ans,a,c);a=mul(a,a,c),b>>=1;}return ans;}

using namespace std;
//using namespace __gnu_pbds;

const ld pi = acos(-1);
const ull ba=233;
const db eps=1e-8;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=300+10,maxn=1000000+10,inf=0x3f3f3f3f;

int a[N][N],b[N][N];
int main()
{
    int n,m,l;scanf("%d%d%d",&n,&m,&l);
    memset(a,inf,sizeof a);
    for(int i=1;i<=m;i++)
    {
        int x,y,z;scanf("%d%d%d",&x,&y,&z);
        if(z<=l)a[x][y]=a[y][x]=z;
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            for(int k=1;k<=n;k++)
                if(a[j][i]+a[i][k]<=l)
                    a[j][k]=min(a[j][k],a[j][i]+a[i][k]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            b[i][j]=(a[i][j]<=l?1:inf);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            for(int k=1;k<=n;k++)
                b[j][k]=min(b[j][k],b[j][i]+b[i][k]);
    int q;scanf("%d",&q);
    while(q--)
    {
        int s,t;scanf("%d%d",&s,&t);
        if(b[s][t]==inf)puts("-1");
        else printf("%d\n",b[s][t]-1);
    }
    return 0;
}
/********************

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


Measured memory_bytes: 1280
#include<stdio.h>
#include<string.h>
#include<math.h>
int main (){
	long long int a=0,b,i,c=0,f;
	scanf("%lld",&a);
	b=a;
	while(a!=0){
    c=c+a%10;
    a=a/10;	
	}
	
	if(b%c==0){
		printf("Yes\n");
		}
	else printf("No\n");
	return 0;
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    string s; cin >> s;
    int w; cin >> w;

    string ans;
    for (int i = 0; i < s.size(); i += w)
        ans.push_back(s[i]);

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 500000

int n;

void maxHeapify(int *A,int i)
{
  int l = 2*i;
  int r = 2*i+1;
  int largest;
  int m;
  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= n && A[r] > A[largest]) largest = r;
  if(largest != i){
    m = A[i];
    A[i] = A[largest];
    A[largest] = m;
    maxHeapify(A,largest);
  }
}

void buildMaxHeap(int *A)
{
  for(int i = n/2;i > 0;i--) maxHeapify(A,i);
}

int main()
{
  int i;
  int key[MAX+1];

  scanf("%d",&n);
  for(i = 1;i < n+1;i++){
    scanf("%d",&key[i]);
  }

  buildMaxHeap(key);
  
  for(i = 1;i < n+1;i++){
    printf(" %d",key[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3684
// https://atcoder.jp/contests/arc061/tasks/arc061_a
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.length();
    ll sum = 0;
    REP(i, BIT(n - 1)) {
        ll t = 0;
        REP(j, n) {
            t *= 10;
            t += s[j] - '0';
            if ((i & BIT(j)) || j == n - 1) {
                sum += t;
                t = 0;
            }
        }
    }
    cout << sum << endl;

    return 0;
}


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

int main ()
{
  int x, hp = 0, remainder;
  
  scanf("%d", &x);
  
  hp += (x/500)*1000;
  remainder = x%500;
  hp += (remainder/5)*5;

  printf("%d", hp);
  fflush(stdout);
  
  return 0;
}
  
  


Measured memory_bytes: 128
#include <iostream>
 
using namespace std;
 
int main() {
  int n; long long d; cin >> n >> d;
  long long d2 = d * d;
  int sum = 0;
  for (int i = 0; i < n; i++) {
  	long long a, b; cin >> a >> b;
    if (a * a + b * b <= d2) sum++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main()
{
  int N, T;
  cin >> N >> T;
  int array[100][2];
  for (int i=0; i<N; i++)
  {
    cin >> array[i][0];
    cin >> array[i][1];
  }
  int min_cost = 1001;
  for (int i=0; i<N; i++)
  {
    if (array[i][0] < min_cost && array[i][1]<=T)
      min_cost = array[i][0];
  }
  if (min_cost == 1001)
    cout << "TLE";
  else
    cout << min_cost;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    ll N,Y;
    cin >> N >> Y;
    vector<ll> ans = {-1,-1,-1};
    for(int i = 0; i <= Y / 10000; i++){
        for(int j = 0; j <= Y / 5000; j++){
            if(i + j > N) continue;
            if(i * 10000 + j * 5000 + (N - i - j) * 1000 == Y){
                ans[0] = i;
                ans[1] = j;
                ans[2] = N - i - j;
            }
        }
    }
    cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
    return 0;
}


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

int main(void){
  int n, a, b;
  cin >> n >> a >> b;
  int sum = 0;
  for(int i=1;i<=n;i++){
    int x = i, dig=0;
    while(x>0){
      dig += x%10;
      x /= 10;
    }
    if(dig >= a && dig <= b) sum += i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int int64;
typedef vector<int64> VI64;
typedef vector<pair<int64,int64>> VII64;
typedef vector<string> VS;
typedef vector<vector<int64>> VVI;

int main()
{
    IOS;
    int64 T=1;
    //cin>>T;
    while(T--)
    {
        string s;
        cin>>s;
        int64 k,i;
        cin>>k;
        int64 n=s.size();
        int64 ans=0;
        int64 cnt=1;
        bool tr=true;
        int64 fst;
        bool fsm=true;
        for(i=1;i<n;i++)
        {
            if(s[i]==s[(i-1)])
            {
                cnt++;
            }
            else
            {
                fsm=false;
                if(tr)
                {
                    tr=false;
                    fst=cnt;
                }
                ans+=cnt/2;
                cnt=1;
            }

        }
        ans+=cnt/2;
        if(k==1)
        {
            cout<<ans;
        }
        else if(fsm)
        {
            cout<<(k*n)/2;
        }
        else
        {
            ans*=k;
            if(s[0]==s[n-1])
            {
                ans+=(k-1)*((fst+cnt)/2);
                ans-=(k-1)*(fst/2 + cnt/2);
            }
            cout<<ans;
        }
    }

    return 0;
}

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

int main() {
	
	int A, B;
	
	cin >> A >> B;
	
	if(A < 6){
		cout << "0" << endl;
	}
	else if(12 < A){
		cout << B << endl;	
	}
	else{
		cout << B / 2 << endl;
	}
	return 0;
}

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

using ll = long long;

ll gcd(ll a, ll b){
	if(b == 0) return a;
	return gcd(b, a % b);
}

int main(){
	ll a, b, c;
	cin >> a >> b >> c;
	ll g = gcd(gcd(a, b), c);
	cout << (gcd(a / g, b / g) == 1 ? "YES" : "NO") << endl;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int x, y, a,b,c;
	cin >>x >> y >>a >>b >>c;
	
	VL p(a), q(b), r(c);
	rep(i, a) cin >>p[i];
	rep(i, b) cin >>q[i];
	rep(i, c) cin >>r[i];
	sort(p.rbegin(), p.rend());
	sort(q.rbegin(), q.rend());
	sort(r.rbegin(), r.rend());
	VL cr; cr.reserve(x+y);
	rep(i, x) cr.push_back(p[i]);
	rep(i, y) cr.push_back(q[i]);
	sort(all(cr));

	rep(i, min(x+y, c)){
		if(cr[i] < r[i]) cr[i] = r[i];
		else break;
	}
	ll ans = accumulate(all(cr), 0LL);
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 3968
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
struct huowu
{
	int w,v;
}g[105];
huowu A[105], B[105], C[105], D[105];
bool cmp(huowu a,huowu b)
{
	return a.v > b.v;
}
int n,W;
int main()
{
	scanf("%d %d",&n,&W);
	int a, b, c, d, f;
	a = b = c = d = f = 0;
	for(int i = 1;i <= n;i++)
	{
		scanf("%d %d",&g[i].w,&g[i].v);
		if(g[i].w == g[1].w)
		{
			A[++a] = g[i];
		}
		else if(g[i].w == g[1].w + 1)
		{
			B[++b] = g[i];
		}
		else if(g[i].w == g[1].w + 2)
		{
			C[++c] = g[i];
		}
		else if(g[i].w == g[1].w + 3)
		{
			D[++d] = g[i];
		}
	}
	sort(A + 1,A + 1 + a,cmp);
	sort(B + 1,B + 1 + b,cmp);
	sort(C + 1,C + 1 + c,cmp);
	sort(D + 1,D + 1 + d,cmp);
	LL swa[110],swb[110],swc[110],swd[110];
	LL sva[110],svb[110],svc[110],svd[110];
	swa[0] = swb[0] = swc[0] = swd[0] = 0;  
    sva[0] = svb[0] = svc[0] = svd[0] = 0;  
    for(int i = 1;i <= a;i++)  
    {  
        swa[i] = swa[i - 1] + A[i].w;  
        sva[i] = sva[i - 1] + A[i].v;  
    }  
    for(int i = 1;i <= b;i++)  
    {  
        swb[i] = swb[i - 1] + B[i].w;  
        svb[i] = svb[i - 1] + B[i].v;  
     }  
     for(int i = 1;i <= c;i++)  
     {  
         swc[i] = swc[i - 1] + C[i].w;  
         svc[i] = svc[i - 1] + C[i].v;  
     }  
     for(int i = 1;i <= d;i++)  
     {  
        swd[i] = swd[i - 1] + D[i].w;  
        svd[i] = svd[i - 1] + D[i].v;  
      }  
    int sumv = 0;  
    int ans = 0;  
	for(int i = 0;i <= a;i++)  
    {  
         for(int j = 0;j <= b;j++)  
         {  
            for(int k = 0;k <= c;k++)  
            {  
             for(int l = 0;l <= d;l++)  
              {  
			      LL sum = swa[i] + swb[j] + swc[k] + swd[l];  
					if(sum <= (LL)W)  
					{  
                      f = max((LL)f,sva[i] + svb[j] + svc[k] + svd[l]);  
					}  
			 }  
            }  
        }  
    }  
    printf("%d\n",f); 
    return 0;  
}  
	
	

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

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(ll i = 0; i < n; ++i){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    int ret = 0;
    for(ll i = 0; i < n - 1; ++i)ret += min(v[i], v[i + 1]);
    cout << accumulate(v.begin(), v.end(), 0) - ret;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int i;
  int s[5][2];
  int max,maxI;

  for(;;){
    scanf("%d%d",&s[0][0],&s[0][1]);
    if(s[0][0]==0 && s[0][1]==0)
      break;
    for(i=1;i<5;i++)
      scanf("%d%d",&s[i][0],&s[i][1]);

    max=0;
    maxI=0;
    for(i=0;i<5;i++)
      if(max<s[i][0]+s[i][1]){
        max=s[i][0]+s[i][1];
        maxI=i;
      }

    if(maxI==0) printf("A");
    else if(maxI==1) printf("B");
    else if(maxI==2) printf("C");
    else if(maxI==3) printf("D");
    else if(maxI==4) printf("E");
    printf(" %d\n",max);
  }

  return 0;
}

Measured memory_bytes: 0
/*宣言*/
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string.h>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
int main()
{
	int n, a[101], ans = 0,cnt=0;
	cin >> n;
	rep(i, n)
	{
		cin >> a[i];
		if (a[i] != 0)
			cnt++;
		else
			cnt = 0;
		if (ans < cnt)
		{
			ans = cnt;
		}
	}
	cout << ans+1 << endl;
	return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>
#include<iostream>

int A,B;

int main(void) {
    std::cin >> A >> B;

    if (A > 9 || B > 9) {
        std::cout << -1 << std::endl;
        return 0;
    }

    int ans = A * B;
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
  const M: i64 = 1_000_000_007;
  input! {
    n: i64,
    k: i64,
  }
  let mut res: i64 = 0;
  for i in k..=n+1 {
    let min: i64 = (i-1) * i / 2;
    let max: i64 = (n+n-i+1) * i / 2;
    res += max - min + 1;
    res %= M;
  }
  println!("{}", res);
}

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

int main()
{
    string s;
    int a, b;
    cin >> a >> b;

    if (a > b) swap(a, b);

    for (int i = 0; i < b; i++)
    {
        s += a + '0';
    }

    cout << s << endl;
}

Measured memory_bytes: 3540
#include <iostream>
#include <vector>
using namespace std;
 
struct st {int from, to;};
vector<st> v;

int main() {
    int m, n, x, y;
    cin >> m >> n;
 
    int c[21];
	fill(c, c+21, 0);
    for (int i=0; i<n; ++i) {
        cin >> x >> y;
        v.push_back((st){x, y});
        c[y] ++;
    }
 
    for (int i=0; i<m; ++i) {
        for (int j=1; j<=m; ++j) {
            if (c[j] == 0) {
                cout << j << endl;
            	c[j] = (1 << 10);
                for (int k=0; k<n; ++k) {
                    c[v[k].to] -= (v[k].from == j);
                }
                break;
            }
        }
    }
    return 0;
}

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

using namespace std;
using ll = long long;

#define int ll
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#define pb push_back
#define sz(x) int(x.size())

const int N = 1e6 + 100;
bool can[N];
int n;
int a[N];
signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	can[0] = true;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		can[x] |= can[x - 1];
	}
	int mx = 0;
	for (int i = 1; i < N; ++i) {
		if (can[i]) {
			mx = i;
		}
	}
	if (mx == 0) {
		cout << "-1\n";
		return 0;
	}
	cout << n - mx << endl;
	return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  bool c = false;
  for (int i = 0; i <= x; i++) {
    int j = x - i;
    int sum = 2 * i + 4 * j;
    if (sum == y) {
      c = true;
      break;
    }
  }
  if (c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

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

  vector<string> weather = { "Sunny", "Cloudy", "Rainy" };

  for (int i = 0; i < weather.size(); i++) {
    if (S == weather.at(i)) {
      if (i != weather.size() - 1) {
        cout << weather.at(i + 1) << endl;
      }
      else {
        cout << weather.at(0) << endl;
      }
    }
  }
}


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

int main(){
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<vector<int>> dp(N+1, vector<int>(N+1));
    for(int i=1;i< N;i++){
        for(int j=i+1;j<=N;j++){
            dp[i][j] = min(j-i, abs(i-X)+1+abs(j-Y));
        }
    }
    vector<int> cnt(N);
    for(int i=1;i<=N;i++){
        for(int j=i+1;j<=N;j++){
            cnt[dp[i][j]]++;
        }
    }
    for(int i=1;i<N;i++) cout << cnt[i] << endl;
}

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

using namespace std;
#define lint long long
#define P pair<int, int>

int main() {
    int N, K;
    cin >> N >> K;
    
    lint cnt = 0;
    
    if(K == 0){
        cnt = (lint)N * N;
    } else {
        for(int b = K + 1; b <= N; ++b){
            cnt += (N / b) * (b - K) + max(0, N % b - K + 1);
        }
    }
    
    cout << cnt << endl;
}

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

int main(){
    int s;
    cin >> s;
    int n[1000000], i=0;
    while(true){
        n[i] = s;
        i++;
        if (s%2 == 0) s = s/2;
        else s = 3*s + 1;
        for(int j=0;j<i;j++){
            if(n[j] == s){
                cout << i + 1 << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vector<int> A, B;
string S, T;

void input() {
  int x, y, z;
  cin>>N>>M>>K;
  ;
}
void solve() {
  int ans = 0;
  if (N>=M+K){
    ans++;
    N -= M+K;
    N -= K;
  }

  ans += (N/(M+K));
  cout<<ans<<endl;

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
def I(): return int(input())
N = I()
S = input()
ans = 0
for i in range(1000):
    num = str(i).zfill(3)
    if S.find(num[0])==-1:
        continue
    S1 = S[S.find(num[0])+1:]
    if S1.find(num[1])==-1:
        continue
    S2 = S1[S1.find(num[1])+1:]
    if S2.find(num[2])==-1:
        continue
    ans += 1
print(ans)

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

int main() {
    ll x,y;
    cin >> x >> y;
    int len = 0;
    ll a = x;
    do {
        len++;
        a *= 2;
    } while (a <= y);
    cout << len << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from sys import stdin,stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
#@lru_cache(maxsize=None) #for optimizing the execution time of callable objects/functions(placed above callable functions)
mod=((10**9)+7)
def rec(s,dp):
    if s<0:return 0
    if s==0:return 1
    if dp[s]!=-1:return dp[s]
    ans=0
    for i in range(3,s+1):
        ans+=rec(s-i,dp)%mod
        ans%=mod
    dp[s]=ans
    return ans




try:
    s=int(input())
    dp=[-1]*(s+1)
    print(rec(s,dp))
    
except EOFError as e:
    print(e)


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

int main(){
  int n,k,r,s,p;
  char *t;
  int i,j,count=0;
  
  scanf("%d %d",&n,&k);
  scanf("%d %d %d",&r,&s,&p);
  t=(char*)malloc(sizeof(char)*(n+1));
  scanf("%s",t);
  t[n]='\0';
  
  for(i=0;i<n/k+1;i++){
    for(j=0;j<k;j++){
      if(t[i*k+j]=='\0'){
        break;
      }
      if(i!=0 && t[i*k+j]==t[(i-1)*k+j]){
        t[i*k+j]='x';
      }
      
      if(t[i*k+j]=='r'){
        count+=p;
      } else if(t[i*k+j]=='s'){
        count+=r;
      } else if(t[i*k+j]=='p'){
        count+=s;
      }
    }
  }
  
  printf("%d",count);
  free(t);
}


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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    
    int n;
    cin>>n;
    int p = n/100;
    n %= 100;
    if(p*5 < n){
        cout << 0 << endl;
    }
    else cout << 1 << endl;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
H.append(10**10)
ans = 0
tmp = 0
for i in range(1, N+1):
    if H[i] <= H[i-1]:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
print(ans)

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

double dp[3007][3007];

double solve(vector<double> &p, int n, int x){
 if(x==0)
   return 1;
  if(n==0)
    return 0;
  
  if(dp[n][x] > -0.9)
    return dp[n][x];
  dp[n][x] = p[n]*solve(p,n-1,x-1)+ (1-p[n])*solve(p,n-1,x);
  return dp[n][x];
}
int main(){
    int n;
  cin>>n;
  memset(dp, -1, sizeof(dp));
  
  vector<double> p(n+1);
  for(int i=1;i<=n;i++)
    cin>>p[i];
  cout<<fixed << setprecision(10)<<solve(p,n,(n+1)/2);
return 0;
}

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

struct S {
	int now, t, rem;
};
bool comp(const S& s1, const S& s2) {
	return s1.t < s2.t;
}

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

	int n;
	while(cin >> n, n) {
		deque<S> lane[2];
		for(int i = 0; i < n; i++) {
			int t, c;
			cin >> t >> c;
			S s = { 0, t, c };
			lane[0].push_back(s);
		}
		sort(lane[0].begin(), lane[0].end(), comp);

		int ans = 0;
		while(lane[0].size() + lane[1].size()) {
			int idx = 0;
			if(lane[0].size() == 0 || lane[1].size() && lane[0][0].t - lane[0][0].now > lane[1][0].t - lane[1][0].now)
				idx = 1;

			int time = lane[idx][0].t - lane[idx][0].now;
			deque<S> temp;
			while(lane[idx].size() && lane[idx][0].t - lane[idx][0].now <= time) {
				S s = lane[idx][0];
				lane[idx].pop_front();

				s.now = 0;
				if(idx == 1) s.rem--;
				if(s.rem) temp.push_back(s);
			}

			sort(temp.begin(), temp.end(), comp);
			for(int i = 0; i < 2; i++) {
				for(S& s : lane[i]) {
					s.now += time;
				}
			}

			for(S s : temp) {
				lane[1 - idx].push_back(s);
			}
			ans += time;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,c = 0;
    cin >> n;
    bool done[10] = {0};
    rep(i,n){
        cin >> a;
        if (a >= 3200) c++;
        else done[a/400] = 1;
    }
    int cnt = 0;
    rep(i,10){
        if (done[i]) cnt++;
    }
    if (cnt == 0) PRINT(1 << " " << c);
    else PRINT(cnt << " " << c+cnt);
}


Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
    int a,b,c,d,e,t,x,i;
    while (scanf("%d%d",&a,&b)!=EOF)
    {
        c=b;
        while (c>0)
        {
            a*=10;
            c/=10;
        }
        d=a+b;
        for (i=0;i<400;i++)
        {
            t=i*i;
            if (t==d)
            {
                printf("Yes\n");
                x=1;
            }
        }
        if (x==0) printf ("No\n");
        x=0; 
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int n,p,q,r,cur,i,j,k,x,y,z,c1=0,c2=0,c3=0,f=0;
    //cin>>n>>k;
    map<long long int,long long int>m;
    //vector<long long int>v;
    set<long long int>s;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        m[x]++;
        s.insert(x);
    }
    for(auto y:s)
    {
        if(m[y]<y)
        {
            c1+=m[y];
        }
        else if(m[y]>y)
        {
            c1+=m[y]-y;
        }
    }
    cout<<c1<<endl;

    return 0;
}




Measured memory_bytes: 10752
#include<iostream>
using namespace std;
int n;
int main(){
    string s;
    cin>>n>>s;
    int ans=0;
    for(int i=1;i<n;i++){
        int cnt=0;
        for(char a='a';a<='z';a++){
            bool ss=0,t=0;
            for(int j=0;j<i;j++){
                if(s[j]==a)ss=1;
            }
            for(int j=i;j<n;j++){
                if(s[j]==a)t=1;
            }
            if(ss && t)cnt++;
        }
        if(ans<cnt)ans=cnt;
    }
    cout<<ans<<endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}
const int N=1e5+5;
int32_t main(){
    string s,t;
    cin>>s>>t;
    int ans=0;
    forn(i,3)ans+=s[i]==t[i];
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int list[10] = {};

int abs(a){
    return (a>0) ? a : -a;
}

void list_set(){
    int i;
    for(i=0; i<8; i++){
        list[i] = i+1;
    }
}
//list = {1,2,3,4,5,6,7,8,0,0}

int list_where(int n){
    int i;
    for(i=0; i<8; i++){
        if(list[i]==n){
            return i;
        }
    }
    return 0;
}

void list_d(int n){
    int i, j;
    for(i=0;i<10;i++){
        if(list[i]==n){
            for(j=i; j<9; j++){
                list[j] = list[j+1];
            }
        }
    }
}

unsigned int kaijo(unsigned int n){
    if(n==0 || n==1){
        return 1;
    }
    else{
        return n * kaijo(n-1);
    }
}

int main(){
    int n, i, j, a, b;
    int p[8] = {};
    int q[8] = {};
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &p[i]);
    }
    for(i=0; i<n; i++){
        scanf("%d", &q[i]);
    }
    a = b = 0;
    list_set();
    for(i=0; i<n; i++){
        a += list_where(p[i]) * kaijo(n-i-1);
        list_d(p[i]);
    }

    list_set();
    for(i=0; i<n; i++){
        b += list_where(q[i]) * kaijo(n-i-1);
        list_d(q[i]);
    }
    printf("%d\n", abs(a-b));
    return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

const int D = 9;
int N;

set<int> se;

void dfs(string& S) {
    if (S.size() == D) {
        string result = S;
        reverse(all(result));

        bool ok1 = false, ok2 = false, ok3 = false;
        for (auto c : result) {
            if (c == '7') ok1 = true;
            if (c == '5') ok2 = true;
            if (c == '3') ok3 = true;
        }
        int n753 = stoi(result);
        if (n753 <= N && ok1 && ok2 && ok3) { se.insert(n753); }
        return;
    }

    if (S.size() > 0 && S.back() == '0') {
        S.push_back('0');
        dfs(S);
        S.pop_back();
        return;
    } else {
        S.push_back('0');
        dfs(S);
        S.pop_back();

        S.push_back('7');
        dfs(S);
        S.pop_back();

        S.push_back('5');
        dfs(S);
        S.pop_back();
        S.push_back('3');
        dfs(S);
        S.pop_back();
    }
    return;
}

int main() {
    cin >> N;

    string S = "";
    dfs(S);

    cout << se.size() << endl;
    return 0;
}

Measured memory_bytes: 4888
from itertools import accumulate
from collections import defaultdict

N,M = map(int, input().split())
A = list(map(int, input().split()))

#1 累積和をとる
B = [0] + list(accumulate(A))

#2 そのmodをとる
B = [b%M for b in B]

#3 1～Nまで、辞書内の当該キーをansにプラスしながら進む
cnt = defaultdict(int)
ans = 0

for b in B:
    ans += cnt[b]
    cnt[b] += 1
    
print(ans)


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



int main() {
    int n;
    cin >> n;
    
    vector<char> c(n);
    rep(i,n) {
        cin >> c[i];
    }
    
    int cnt = 0;
    rep(i,n) {
        if(c[i] == 'W')
            cnt++;
    }
    
    int cnt1 = 0;
    rep(i,n-cnt) {
        if(c[i] == 'W')
            cnt1++;
    }
    
    cout << cnt1 << endl;
    
    
    return 0;
}




Measured memory_bytes: 3628