akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  if (n % 2) {
    cout << 0 << endl;
  } else {
    ll ans = 0;
    ll t = 10;
    for (; t <= n; t *= 5) {
      ans += n / t;
    }

    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int n, p;
string s;
vector <int> md = {0}; //md[i] - mod cua xau tao boi i chu so dau tien cho p
int cnt[10005];

int powmod(int u, int v) {
    if (v == 0) return 1;
    int mid = powmod(u, v/2);
    mid = (mid*mid)%p;
    if (v%2==0) return mid;
    else return (mid*u)%p;
}
// main solution goes here:
void execute(int test_number)
{
    cin>>n>>p>>s;
    if (p == 2 || p == 5) {
        int ans = 0;
        for (int i=0; i<n; i++) if ((s[i] - '0') % p == 0) ans += i+1;
        cout<<ans;
    } else {
        for (int i=0; i<n; i++) md.push_back((md.back() + (s[i]-'0')*powmod(10, n-i))%p);
        int ans = 0;
        for (int i: md) {
            ans += cnt[i];
            cnt[i] ++;
        }
        cout<<ans;
    }
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

Measured memory_bytes: 5532
#include <cstdio>

int main(){
    int a,b,c,n;
    scanf("%d %d %d",&a,&b,&c);
    scanf("%d",&n);
    int d[3] = {a,b,c};
    int maxi = 0;
    for(int i = 0; i < 3; i++){
        if(d[i] > d[maxi]){
            maxi = i;
        }
    }

    int ans = 0;
    for(int i = 0; i < 3; i++){
        if(i != maxi){
            ans += d[i];
        }else{
            for(int j = 1; j <= n; j++){
                d[i] = d[i] * 2;
            }
            ans += d[i];
        }
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);++i)
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_C&lang=jp

class StronglyConnectedComponents {
private:
  ll n;
  vector<vector<ll>> dag,rdag,st;
  vector<ll> comp,order;
  vector<bool> used;
public:
  StronglyConnectedComponents(const vector<vector<ll>>& adj){
    n = adj.size();
    comp.resize(n);
    used.resize(n);
    dag.resize(n);
    rdag.resize(n);
    for(ll i=0;i<n;++i){
      for(const auto& x:adj[i]){
        dag[i].emplace_back(x);
        rdag[x].emplace_back(i);
      }
    }
  }

  inline auto operator[](ll idx)const{
    return comp[idx];
  }
  void dfs(ll now_v){
    if(used[now_v])return;
    used[now_v]=true;
    for(const auto& next_v:dag[now_v]) dfs(next_v);
    order.push_back(now_v);
  }
  auto rdfs(ll now_v,ll num){
    if(comp[now_v])return false;
    comp[now_v]=num;
    for(const auto& next_v:rdag[now_v]) rdfs(next_v,num);
    return true;
  }
  auto build(){
    for(ll i=0;i<n;++i) dfs(i);
    reverse(order.begin(),order.end());
    ll num=1;
    for(const auto& v:order) num+=rdfs(v,num);
    st.resize(num);
    for(ll i=0;i<n;++i){
      st[comp[i]].emplace_back(i);
    }
    return st;
  }
  void dump(){
    rep(i,n)cout<<i<<" ";cout<<endl;
    rep(i,n)cout<<comp[i]<<" ";cout<<endl;
  }
};

main(){

  ll n,m;
  cin>>n>>m;
  vector<vector<ll>> adj(n);
  rep(i,m){
    ll s,t;
    cin>>s>>t;
    adj[s].emplace_back(t);
  }

  StronglyConnectedComponents scc(adj);
  scc.build();

  ll q;
  cin>>q;
  rep(i,q){
    ll u,v;
    cin>>u>>v;
    if(scc[u]==scc[v])puts("1");
    else puts("0");
  }


}


Measured memory_bytes: 5216
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	ll n;
	cin>>n;
	//char a='a';
	
	deque<char>ans;
	while(n>0){
		ll k=n%26;
		if(k==0){
			k=25;
		}else{
			k--;
		}
		char tmp='a'+k;
		ans.push_front(tmp);
		n-=k;
		if(n==26)break;
		n/=26;
	}
	rep(i,size(ans)){
		cout<<ans[i];
	}
	cout<<endl;

}

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


Measured memory_bytes: 3652
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    int ff[N][100],c[N];ll a[N],b[N];
    int jump(int x,ll wt){fd(i,62,0)if(wt&bin(i))x=ff[x][i];return x;}
	void main()
	{
        int n=qread();fo(i,1,n) a[i]=qread(),c[i]=i;//自环
        int m=qread();ll K=qread();
        while(m--)
        {
            int i=qread();
            swap(c[i],c[i+1]);
        }
        fo(i,1,n) ff[c[i]][0]=i;//得出做m次后会到那里
        fo(j,1,70) fo(i,1,n) ff[i][j]=ff[ff[i][j-1]][j-1];
        fo(i,1,n) b[jump(i,K)]=a[i]-a[i-1];
        fo(i,1,n) b[i]+=b[i-1],printf("%.1lf\n",1.0*b[i]);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


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

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    string w, p;
    set<string> st;
    bool res = true;
    for (int i = 0; i < n; i++)
    {
        cin >> w;
        if (res && st.count(w) > 0)
        {
            res = false;
        }
        st.insert(w);

        if (i > 0 && p[p.length() - 1] != w[0])
        {
            res = false;
        }
        p = w;
    }

    printf("%s\n", res ? "Yes" : "No");

    return 0;
}


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

int main(){
    int N;
    int motiSize;
    cin >> N;
    set<int> moti;

    for(int i = 0;i < N;i++){
       cin >> motiSize;
       moti.insert(motiSize); 
    }
    cout << moti.size() << "\n" << endl;
}

Measured memory_bytes: 256
RGBN = [int(i) for i in input().split()]
RGB = []
for i in range(3):
    RGB.append(RGBN[i])
RGB.sort()
N = RGBN[3]

count = 0
r = 0
g = 0
b = 0
for i in range(int(N/RGB[0])+1):
    for j in range(int((N-i*RGB[0])/RGB[1])+1):
        if (N - i*RGB[0] - j*RGB[1]) % RGB[2] == 0:
            count += 1

print(count)

Measured memory_bytes: 3064
h, w = map(int, input().split())
dist = [list(map(int, input().split())) for _ in range(10)]
n = len(dist)
for k in range(n):
  for i in range(n):
    for j in range(n):
      if dist[i][j] > dist[i][k] + dist[k][j]:
        dist[i][j] = dist[i][k] + dist[k][j]       
list_a = [list(map(int, input().split())) for _ in range(h)]
result = 0
for one_row in list_a:
  for one_a in one_row:
    if one_a != -1:
      result += dist[one_a][1]
print(result)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vec;
typedef vector<vec> mat;
ll R[200001],RR[200001],L[200001],LL[200001];
int main(){
    ll n,c,x[200001],v[200001];
    cin>>n>>c;
    rep(i,n) cin>>x[i]>>v[i];
    vector<P> A;
    A.push_back(P(0,0));
    A.push_back(P(c,0));
    rep(i,n) A.push_back(P(x[i],v[i]));
    sort(A.begin(),A.end());
    rep(i,n+1){
        if(i==0) R[i]=0,RR[i]=0;
        else{
            R[i]=R[i-1]+A[i-1].first+A[i].second-A[i].first;
            RR[i]=RR[i-1]+A[i-1].first*2+A[i].second-A[i].first*2;
        }
    }
    reverse(A.begin(),A.end());
    rep(i,n+1){
        if(i==0) L[i]=0,LL[i]=0;
        else{
            L[i]=L[i-1]+(c-A[i-1].first)+A[i].second-(c-A[i].first);
            LL[i]=LL[i-1]+(c-A[i-1].first)*2+A[i].second-(c-A[i].first)*2;
        }
    }
    rep(i,n){
        R[i+1]=max(R[i+1],R[i]);
        RR[i+1]=max(RR[i+1],RR[i]);
        L[i+1]=max(L[i+1],L[i]);
        LL[i+1]=max(LL[i+1],LL[i]);
    }
    ll ans=0;
    rep(i,n+1) ans=max(ans,R[i]+LL[n-i]);
    rep(i,n+1) ans=max(ans,L[i]+RR[n-i]);
    cout<<ans<<"\n";
}

Measured memory_bytes: 10096
N = int(input())
edges = []
for i in range(1, N // 2 + 1):
    j = N - i + 1 - N % 2
    for k in range(1, N+1):
        if k == i or k == j:
            continue
        if i < k:
            edges.append((i, k))
        if j < k:
            edges.append((j, k))
print(len(edges))
for a, b in edges:
    print(a, b)

Measured memory_bytes: 43884
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;                               // a--c--b on line
}

int main() {
  int x0, y0, x1, y1, Q;
  cin >>x0 >>y0 >>x1 >>y1;
  P a = P(x0, y0), b = P(x1, y1);
  cin >>Q;
  REP(q, Q){
    int x, y; cin >>x >>y;
    P c = P(x, y);
    int ans = ccw(a, b, c);
    string s;
    if(ans == 1) s = "COUNTER_CLOCKWISE";
    if(ans == -1) s = "CLOCKWISE";
    if(ans == 2) s = "ONLINE_BACK";
    if(ans == -2) s = "ONLINE_FRONT";
    if(ans == 0) s = "ON_SEGMENT";
    cout <<s <<endl;
  }
  return 0;
}

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

int main() {
    int N;
    cin>>N;
    vector<int> x(N);
    vector<int> y(N);
    rep(i,N)cin >> x[i] >> y[i];
    double ans = 0;
    for(int i=0 ; i < N; ++i){
        for(int j=0;j<N;++j){
            ans += sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    }
  
  double h = ans/N;
   cout << setprecision(10) << h << endl;
    return 0;    
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if(a<=b)cout<<0<<endl;
  else cout<<a-b<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ms(a,b) memset(a,b,sizeof(a))
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int maxn=1e6+10;
const int mod=1e9+7;
const int maxm=1e3+10;
using namespace std;
bool cmp(string s1,string s2)
{
    return s1<s2;
}
int main(int argc, char const *argv[])
{
    #ifndef ONLINE_JUDGE

        srand((unsigned int)time(NULL));
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    map<string,int>mp;
    string s;
    cin>>n;
    set<string>se;
    int maxx=0;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        mp[s]++;
        maxx=max(maxx,mp[s]);
        se.insert(s);
    }
    vector<string>v;
    for(auto i:mp)
        if(i.second==maxx)
            v.push_back(i.first);
    sort(v.begin(),v.end(),cmp);
    for(auto i:v)
        cout<<i<<endl;
    #ifndef ONLINE_JUDGE
        cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<" s.\n";
    #endif
    return 0;
}

Measured memory_bytes: 34928
from bisect import bisect_right

s = input()
t = input()

char_list = [[] for i in range(26)]

for i in range(2*len(s)):
        if i<len(s):
                char_list[ord(s[i])-97].append(i)
        else:
                char_list[ord(s[i-len(s)])-97].append(i)

INF = 10**27

for i in range(26):
        char_list[i].append(INF)

next_list = [[char_list[j][bisect_right(char_list[j],i)] for j in range(26)] for i in range(len(s))]

flag = False
for i in range(len(s)):
        if t[0]==s[i]:
                flag=True
                x = i
                y = i
                break
if flag:
        flag2 = True
        for i in range(1,len(t)):
                n = next_list[x][ord(t[i])-97]
                y += n - x
                x = n%(len(s))
                if y >= INF:
                        flag2=False
                        break
        if flag2:
                print(y+1)
        else:
                print(-1)
else:
        print(-1)

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

int main()
{
    int k, x;
    cin >> k >> x;

    for (int i = 1; i <= 2 * (k - 1) + 1; i++)
    {
        cout << x - (k - i) << " " << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Point[] points = new Point[n];
		for (int i = 0; i < n; i++) {
			points[i] = new Point(sc.nextInt(), sc.nextInt(), sc.nextInt());
		}
		sc.close();

		int ansX = -1;
		int ansY = -1;
		int ansH = -1;
		label:
		for (int x = 0; x < 101; x++) {
			for (int y = 0; y < 101; y++) {
				int baseH = -1;
				boolean flg = true;
				for (int i = 0; i < n; i++) {
					if (points[i].h > 0) {
						int h = points[i].h + Math.abs(x - points[i].x) + Math.abs(y - points[i].y);
						if (baseH == -1) {
							baseH = h;
						} else if (baseH != h) {
							flg = false;
							break;
						}
					}
				}
				if (flg) {
					for (int i = 0; i < n; i++) {
						if (points[i].h == 0) {
							if (baseH > Math.abs(x - points[i].x) + Math.abs(y - points[i].y)) {
								flg = false;
								break;
							}
						}
					}
					if (!flg) {
						continue;
					}
					ansX = x;
					ansY = y;
					ansH = baseH;
					break label;
				}
			}
		}

		System.out.println(ansX + " " + ansY + " " + ansH);
	}

	static class Point {
		int x;
		int y;
		int h;
		public Point(int x, int y, int h) {
			this.x = x;
			this.y = y;
			this.h = h;
		}
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int cnt,ans,num[1000005];
inline int read() {
	int x=0,neg=1;char ch=getchar();
	while(!isdigit(ch)) {
		if (ch=='-') neg=-1;
		ch=getchar();
	}
	while(isdigit(ch)) {
		x=x*10+(ch-'0');
		ch=getchar();
	}
	return x*neg;
}
int main() {
	int n=read(),m=read();
	for (int i=1;i<=m;++i) {
		int start=read(),end=read();
		num[start]++;
		num[end+1]--;
	}
	for (int i=1;i<=n;++i) {
		cnt+=num[i];
		if (cnt==m) {
			++ans;
		}
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> red(n), blue(n);
    rep(i,n) cin >> red[i].first >> red[i].second;
    rep(i,n) cin >> blue[i].first >> blue[i].second;
    sort(red.begin(), red.end());
    sort(blue.begin(), blue.end());
    vector<bool> Rused(n, false);
    int ans = 0;
    rep(i,n){
        int idx = -1, mx = 0;
        rep(j,n){
            if(Rused[j]) continue;
            if(red[j].first < blue[i].first && red[j].second < blue[i].second){
                if(red[j].second >= mx){
                    mx = red[j].second;
                    idx = j;
                }
            }
        }
        if(idx != -1){
            Rused[idx] = true;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
N,W = map(int,input().split())
item = [list(map(int,input().split())) for _ in range(N)]

V = sum(map(lambda x:x[0],item))

dp = [W+1 for _ in range(V+1)]
dp[0] = 0

for i in range(N):
    v,w = item[i]
    for j in range(V+1)[::-1]:
        if j-v>=0:
            dp[j] = min(dp[j-v]+w,dp[j])

print(max(j for j in range(V+1) if dp[j] <= W))


Measured memory_bytes: 5980
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

from bisect import bisect_left

N = I()
A = [0]*N
for i in range(N):
    A[i] = I()

val = [-1]*N
for i in range(N):
    temp = bisect_left(val,A[i])
    val[temp-1] = A[i]

ans = 0
for i in range(N):
    if val[i]!=-1:
        ans += 1

print(ans)

Measured memory_bytes: 44380
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int arithmeticSequence(int a, int d, int n)
{
    return a + (n - 1) * d;
}
int main()
{
    int A, B;
    cin >> A >> B;
    for (int i = 1;; i++)
    {
        int res = arithmeticSequence(1, A - 1, i);
        if (res >= B)
        {
            cout << i - 1 << endl;
            break;
        }
    }
}

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


int main(){
  int n;
  string s;
  cin >> n >> s;
  rep(i,sz(s)) {
    s[i] += n;
    if (s[i] > 'Z') s[i] -= 26;
  }
  cout << s << endl;
  return 0;
} 

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int64
	fmt.Scan(&a, &b)

	d := greatestCommonDivisor(a, b)
	r := (a * b) / d
	fmt.Println(r)
}

func greatestCommonDivisor(a, b int64) int64 {
	for a%b != 0 {
		a, b = b, a%b
	}
	return b
}


Measured memory_bytes: 512
#include<stdio.h>   
#include<string.h>   
int main()  
{  
    int a,b,c;
    int s;
    scanf("%d %d %d",&a,&b,&c);
    s=a*b;
    if(s>c)
    printf("%d\n",c);
    else
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll h, w; cin >> h >> w;
    vector<string> img(h);
    rep(i, h) cin >> img[i];
    rep(i, h){
        rep(j, 2) cout << img[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define ull         unsigned long long int
#define ll          long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> 
 
const long long INF = (long long) 1e12+1;
const long long mod = (long long) 20437;
const long long hell = (long long) 1000000007;

ll power(ll x,ll y,ll m){
  ll res=1;
  while(y>0){
    if(y%2) res=(x%m*res%m)%m;
    x=(x%m*x%m)%m;    
    y=y/2;
  }
  
  return res%m;
}
 
ll modinv(ll x){
  return power(x,hell-2,1);
}

ll gcd(ll a,ll b){
    while(b!=0){
		ll t=b;
		b=a%t;
		a=t;
	}
	return a;
}    
    
void fastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
} 

void solve(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        if(i&1){
            if(x&1)
            ans++;
        }
    }
    cout<<ans;
}    
    
int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;    
   
   while(test--)
   solve();
}

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

int main(){
  int N,T,A,a=0;
  double b=1000;
  cin >> N >> T >> A;
  int H[N];
  for(int i=0;i<N;i++){
    cin >> H[i];
    double temp = T - H[i]*0.006;
    double c = max(temp-A,A-temp);
    if(c<b){
      b = c;
      a = i;
    }
  }
  cout << a +1 << endl;
}

Measured memory_bytes: 256
N = gets.to_i
G = Array.new(N+1){Array.new}
(N-1).times do
  u, v, w = gets.split.map &:to_i
  G[u] << [u, v, w]
  G[v] << [v, u, w]
end

color = Array.new(N + 1)
q = [[1, 1, 0]]
until q.empty?
  from, to, weight = q.shift
  color[to] = weight
  G[to].each do |(f, t, w)|
    next if t == from
    next if color[t]
    q << [f, t, w + weight]
  end
end

1.upto(N) do |i|
  puts color[i].odd? ? 1 : 0
end


Measured memory_bytes: 27516
#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
//const ll mod = 1000000007;
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

    ll size(int x){
        return Size[root(x)];
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    UnionFind uni(N);
    ll ans = N - 1;
    for(int i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        if(uni.merge(a, b)) ans--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

const int inf = 99999999;
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
vector<int> lis_fast(const vector<int>& a) {
	const int n = a.size();
	vector<int> A(n, inf);
	vector<int> id(n);
	for (int i = 0; i < n; ++i) {
		id[i] = index_of(A, a[i]);
		A[id[i]] = a[i];
	}
	if (id.size() == 0) return{};
	int m = *max_element(id.begin(), id.end());
	vector<int> b(m + 1);
	for (int i = n - 1; i >= 0; --i)
		if (id[i] == m) b[m--] = a[i];
	return b;
}


const ld PI = acos(-1);
const ld Q = 5 * PI;

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ll x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	if (x1 > x2)
	{
		swap(x1, x2);
		swap(y1, y2);
	}
	ll n; cin >> n;
	ld ans = -1;
	if (y1 <= y2)
	{
		vector<pii> v;
		REP(i, n)
		{
			ll x, y; cin >> x >> y;
			if (x >= x1 && x <= x2 && y >= y1 && y <= y2)
			{
				v.emplace_back(x, y);
			}
		}
		sort(ALL(v));
		vi a;
		for (auto i : v) a.push_back(i.second);
		ll t = lis_fast(a).size();
		ans = 100 * (x2 - x1) + 100 * (y2 - y1) + (Q * t - 20 * t);
		if (t == min(x2 - x1, y2 - y1) + 1)
		{
			ans += Q;
		}
	}
	else if (y1 > y2)
	{
		vector<pii> v;
		REP(i, n)
		{
			ll x, y; cin >> x >> y;
			if (x >= x1 && x <= x2 && y <= y1 && y >= y2)
			{
				v.emplace_back(x, -y);
			}
		}
		sort(ALL(v));
		vi a;
		for (auto i : v) a.push_back(i.second);
		ll t = lis_fast(a).size();
		ans = 100 * (x2 - x1) + 100 * (y1 - y2) + (Q * t - 20 * t);
		if (t == min(x2 - x1, y1 - y2) + 1)
		{
			ans += Q;
		}
	}
	else assert(false);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5232
#include<bits/stdc++.h>
using namespace std;
vector <int> des[1000010];
int col[1000010],sum[1000010],fa[1000010],st[1000010],ff[1000010];
bool ins[1000010];
int getf(int s){if (ff[s]==s) return s;return ff[s]=getf(ff[s]);}
void dfs(int s,int pre)
{
	col[s]=-col[pre];sum[s]=col[s];fa[s]=pre;
	for (int k=0;k<des[s].size();k++) if (des[s][k]!=pre)
	{
		dfs(des[s][k],s);
		sum[s]+=sum[des[s][k]];
	}
}
int main()
{
	int n,m,x=1,y=0;scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) ff[i]=i;
	for (int i=1;i<=m;i++)
	{
		int u,v;scanf("%d%d",&u,&v);
		if (getf(u)==getf(v)) {x=u;y=v;continue;}
		ff[getf(u)]=getf(v);
		des[u].push_back(v);des[v].push_back(u);
	}
	col[0]=-1;dfs(x,0);
	if (!y)
	{
		if (sum[x]) {printf("-1\n");return 0;}
		long long ans=0;
		for (int i=1;i<=n;i++) ans+=abs(sum[i]);
		printf("%lld\n",ans);return 0;
	}
	int top=0;
	for (int i=y;i!=0;i=fa[i]) {ins[i]=true;st[++top]=sum[i];}if (st[top]!=sum[x]) assert(0);
	if (top&1)
	{
		if (sum[x]&1) {printf("-1\n");return 0;}	
		long long ans=0;
		for (int i=1;i<=n;i++) if (ins[i]) ans+=abs(sum[i]-sum[x]/2);else ans+=abs(sum[i]);
		printf("%lld\n",ans);return 0;
	}
	if (sum[x]) {printf("-1\n");return 0;}
	sort(st+1,st+top+1);
	long long ans=0;
	for (int i=1;i<=n;i++) if (ins[i]) ans+=abs(sum[i]-st[top/2]);else ans+=abs(sum[i]);
	printf("%lld\n",ans);
}

Measured memory_bytes: 41728
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    /* ll t;
    cin>>t;
    while(t--) */
    {
        ll i,j,k,l,m,n,a,b,c,d,cnt=0,p=0,q;
        cin>>n;
        ll arr[n+1];
        map <int,int> mp;
        for(i=1;i<=n;i++)
        {
            cin>>arr[i];
            cnt+=mp[i-arr[i]];
            mp[i+arr[i]]++;
        }

        cout<<cnt<<endl;

    }
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cout<<v[i][j]<<" ";}cout<<endl;}


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


int main() {
  vi num(4);
  rep (i, 6) {
    int a;
    cin >> a;
    a--;
    num[a]++;
  }
  sort(all(num));
  vi ans = {1, 1, 2, 2};
  if (num == ans) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int H,W;
char s[123][123];
int used[123][123];

int main() {

    Scd2(H,W);

    Rep(i,H) Scs(s[i]);

    int dx[4] = {0,1,0,-1};
    int dy[4] = {1,0,-1,0};
    int ans = 0;
    deque<pii> q;
    Rep(h,H) Rep(w,W){
        if( s[h][w] == '#' ) continue;
        Rep(i,H) Rep(j,W) used[i][j] = -1;
        used[h][w] = 0;
        q.push_back({h,w});
        while( q.size() ){
            pii tt = q.front(); q.pop_front();
            int hi = tt.first;
            int wi = tt.second;
            int dist = used[hi][wi];
            ans = max(dist,ans);

            Rep(di,4){
                int hhi = hi+dx[di];
                int wwi = wi+dy[di];
                if( hhi >= H || hhi < 0 ) continue;
                if( wwi >= W || wwi < 0 ) continue;
                if( used[hhi][wwi] != -1 ) continue;
                if( s[hhi][wwi] != '.' ) continue;
                used[hhi][wwi] = dist+1;
                q.push_back({hhi,wwi});
            }

        }
    }

    printf ("%d\n", ans );

    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, r;
    cin >> n >> r;
    if (n >= 10) {
        cout << r;
    } else {
        cout << r + (100 * (10 - n));
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define endl "\n"
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
 
typedef long double ld;
typedef long long ll;
typedef pair<ll,ll> pp;
typedef pair<ll,pair<ll,ll> > ppp;
 
const ll N    = 5e5+5;
const ll INF  = 1e9;
const ll mod  = 1e9+7;

ll a[N];

void solve()
{
    ll x,n,d;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    vector<int> ans;
    for(int i=n;i>=1;i--)
    {
        if(a[i]){
            ans.push_back(i);
            for(int j=1;(1LL*j*j)<=i;j++){
                if(i%j==0){
                    if(1LL*j*j==i){
                        a[j] = 1-a[j];
                    }
                    else
                    {
                        a[j] = 1-a[j];
                        a[i/j] = 1-a[i/j];
                    }
                }
            }
        }
    }

    cout<<ans.size()<<endl;
    for(auto x:ans)
        cout<<x<<" ";

}     
 
int main(){
    FAST
    int t= 1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
} 

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vpii = vector<pii>;

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

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

template<class base_t, class func = function<base_t(const base_t&, const base_t&)>>
class mqueue
{
private:
    vector<pair<base_t, base_t>> s1, s2;
    func f;

    void move()
    {
        while(!s2.empty())
        {
            base_t x = s2.back().first;
            s2.pop_back();
            
            if(s1.empty()) s1.emplace_back(x, x);
            else s1.emplace_back(x, f(x, s1.back().second));
        }
    }

public:
    mqueue(const func& _f) { f = _f;}
    
    void pop() { if(s1.empty()) move(); s1.pop_back();}
    void push(base_t x)
    {
        if(s2.empty()) s2.emplace_back(x, x);
        else s2.emplace_back(x, f(x, s2.back().second));
    }
    
    base_t front() { if(s1.empty()) move(); return s1.back().first;}	
    base_t get()
    {
        if(!s1.empty() && !s2.empty())
            return f(s1.back().second, s2.back().second);
        else if(!s1.empty())
            return s1.back().second;
        else
            return s2.back().second;
    }
    
    int size() { return LEN(s1) + LEN(s2);}
    bool empty() { return size() == 0;}
    void clear() { s1.clear(); s2.clear();}
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    
    int n, m; cin >> n >> m;
    string s; cin >> s;

    if(s[n] == '1' || s[0] == '1')
    {
        cout << -1 << endl;
        return 0;
    }

    vector<ll> dp(n + 1);
    vi p(n + 1);

    mqueue<pair<ll, int>> q([&](pair<ll, int> a, pair<ll, int> b){ return min(a, b);});

    dp[0] = p[0] = 0;
    q.push({0, 0});

    for(int i = 1; i <= n; i++)
    {
        if(LEN(q) > m) q.pop();
        if(s[i] == '1') dp[i] = INF<int>;
        else dp[i] = 1 + q.get().first, p[i] = q.get().second;
        q.push({dp[i], i});
    }

    if(dp[n] >= INF<int>) cout << -1 << endl;
    else
    {
        vi ans;
        
        while(n)
        {
            ans.emplace_back(n - p[n]);
            n = p[n];
        }

        reverse(ALL(ans));

        for(int i = 0; i < LEN(ans); i++)
            cout << ans[i] << " \n"[i == LEN(ans) - 1];
    }

    return 0;
}

Measured memory_bytes: 13644
N = int(input())
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))

diff = []
neg = 0
count = 0

if sum(B) >  sum(A):
    print(-1)
    exit()

for a, b in zip(A, B):
    diff += [a-b]
    if a < b:
        count += 1
        neg += a - b

for d in sorted(diff, reverse=True):
    if neg >= 0:
        break
    count += 1
    neg += d

print(count)

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

int main(void)
{
	int ans = 0;
	int max = 0;
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		int p; cin >> p;
		ans += p;
		if (max < p)max = p;
	}
	ans -= (max / 2);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define cle(n) memset(n,0,sizeof(n))
using namespace std;
const int maxn=1000005;
#define inf 1000000009
const long long  mod=1e9+7;
int t;
int n,m,k;
int a[maxn];
int dp[maxn];
int main()
{

   while(~scanf("%d",&n))
   {
       int ans=0;
       for(int i=0;i<n;i++)
       {
           scanf("%d",&a[i]);
           ans+=a[i];
       }

     sort(a,a+n);
     if(ans%10!=0)
     {
         printf("%d\n",ans); continue;
     }
     int flag=0;
     for(int i=0;i<n;i++)
     {
         if(a[i]%10!=0)
         {
             ans-=a[i];
               // printf("%d\n",ans);

                 flag=1;
                 break;
         }

     }
     if(flag)
     {
          printf("%d\n",ans); continue;
     }
     if(flag==0)
     {
            printf("0\n"); continue;
     }


   }



    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <complex>

using namespace std;

typedef complex<int> P;

int n;

int m;
P base[9];
int sm[50];
P s[50][9];

P rotate_p = P(0,1);

bool cmp(int i)
{
	if(m != sm[i]) return false; //»à»àÜêéñªÙÈé

	for(int j = 0; j < 4; j++){
		int k;
		for(k = 0; k < m-1; k++){
			if(base[k] != s[i][k]) break;
		}
		if(k == m-1) return true;
		for(k = 0; k < m-1; k++){
			if(base[k] != s[i][m-2-k]) break;
		}
		if(k == m-1) return true;
		for(int k=0; k<m-1;k++) s[i][k] *= rotate_p; //90xñ]
	}

	return false;
}

void solve()
{
	int x,y;
	cin >> m;
	P buf[10];
	for(int i=0;i<m;i++){
		cin >> buf[i].real() >> buf[i].imag();
	}
	for(int i=0;i<m-1;i++){
		base[i] = buf[i+1]-buf[i];
	}

	for(int j =0;j<n;j++){
		cin >> sm[j];
		for(int i=0;i<sm[j];i++){
			cin >> buf[i].real() >> buf[i].imag();
		}
		for(int i=0;i<sm[j]-1;i++){
			s[j][i] = buf[i+1]-buf[i];
		}
	}

	for(int i = 0; i < n; i++){
		if(cmp(i)) cout << i + 1 << endl;
	}

	cout << "+++++" << endl;
}

int main()
{
	while(cin >> n,n)
		solve();

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i,a,b) for(int i=a;i<=b;i++)
int n,m;
LL sum,ans;
map<LL,LL>mp;
int main()
{
	cin>>n>>m;
	cout<<(n-1)*(m-1);

}


Measured memory_bytes: 256
def resolve():
    acgt = 'ACGT'
    S = input()

    cnt = 0
    max_cnt = 0
    for s in S:
        if s in acgt:
            cnt += 1
            max_cnt = max(max_cnt, cnt)
        else:
            cnt = 0
            
    print(max_cnt)
  
resolve()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll n, d;
  cin >> n >> d;
  vector<ll> x(n),y(n);
  rep(i,n) cin >> x[i] >> y[i];
  int cnt = 0;
  rep(i,n){
    double dist = hypot(x[i], y[i]);
    if (dist <= d) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 6488
import std.stdio, std.string, std.conv, std.algorithm;

void main() {
    readln;
    auto S = readln.chomp.map!(a => a == 'I' ? 1 : -1);
    auto c = 0;
    auto res = 0;
    foreach (s; S) {
        c += s;
        res = max(res, c);
    }
    writeln(res);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string S;
    cin >> S;
    string s;
    int N = S.size();
    int M = N - 1;
    
    int sum = 0;
    string sign[N];
    //1 2 3 
    // 0 0  1 + 2 + 3 
    // 0 1  1 + 2 - 3
    // 1 0  1 - 2 + 3
    // 1 1  1 - 2 - 3
    for(int bit = 0; bit < (1<<N);bit++){
        
        s = S.substr(0,1);
        sum += stoi(s);
        
        for(int i = 0; i < M; i++){
            
            s = S.substr(i+1,1);
            
            if(bit & (1<<i)){
                
                sum += stoi(s);
                sign[i] = "+";
                //cout << "+" << s; 
            }else{
                sum -= stoi(s);
                sign[i] = "-";
                //cout << "-" << s; 
            }
        
        }
        
        //cout << endl;
        
        //cout << sum << endl;
        if(sum == 7){
            
            for(int j = 0; j < N;j++)cout << S[j] << sign[j];
            cout <<"=7"<<endl;
            return 0;
        }
        sum = 0;
        
        
    }
    
}


Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

S,T=get
puts T+S

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int n;

int main(){
  cin >> n;
  int a,b;
  a=0;b=0;
  while(a*4<=n){
    b = 0;
    while(a*4+b*7<=n){
      if(a*4+b*7==n){
        cout << "Yes"<<endl;
        return 0;
      }
      b++;
    }
    a++;
  }
  cout << "No" <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
  int n,i,an=1;
  scanf("%d",&n);

  if(n==1) an=1;
  if(2<=n && n<4) an=2;
  if(4<=n && n<8) an=4;
  if(8<=n && n<16) an=8;
  if(16<=n && n<32) an=16;
  if(32<=n && n<64) an=32;
  if(64<=n && n<=100) an=64;

  printf("%d\n",an);

  return 0;
}

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

int main() {
  int N,C,K;
  cin >> N >> C >> K ;
  vector<int> T(N);
  for(int i=0;i<N;i++){
    cin >> T.at(i) ;
  }
  sort(T.begin(), T.end());
  int time=T.at(N-1);
  int person = 0;
  int bus = 0;
  for(int i=N-1;i>=0;i--){
    int t = T.at(i);
    if(time - t > K || person == C){
      bus++;
      person=0;
      time = t;
    }
    person++;
  }
  bus++;
  cout << bus << endl;
  return 0;
}

Measured memory_bytes: 640