akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>

#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

int f(char c){
	if(c=='L')	return -1;
	if(c=='R')	return 1;
	return 0;
}

int main(){
	int T;	scanf("%d ",&T);
	while(T--){
		static char s[100001];	scanf("%s",s);

		bool okl=true,okr=true;
		char bef=s[0];
		int pos=f(s[0]);
		for(int i=1;s[i]&&(okl||okr);i++){
			if(bef==s[i])	okl=okr=false;

			int p=f(s[i]);
			if(i%2==1){
				if(p<pos)	okl=false;
				if(pos<p)	okr=false;
			}
			else{
				if(pos<p)	okl=false;
				if(p<pos)	okr=false;
			}

			bef=s[i];
			pos=p;
		}

		puts(okl||okr?"Yes":"No");
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n, k, ans=0;
    
    cin >> n >> k;
    
    vector<int> l(n);
    
    for(int i=0; i<=n-1; i++){
        
        cin >> l.at(i);
        
    }
    
    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());
    
    for(int i=0; i<=k-1; i++){
        
        ans += l.at(i);
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

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

def solve():
    """
    あるXに着目した時、X-1とX+1はXにできる。
    よって、各Xについて数を数える
    """
    N = int(input())
    A = list(map(int, input().split()))

    dic = {}
    for a in A:
        if not a in dic:
            dic[a] = 1
        else:
            dic[a] += 1
        if not a-1 in dic:
            dic[a-1] = 1
        else:
            dic[a-1] += 1
        if not a+1 in dic:
            dic[a+1] = 1
        else:
            dic[a+1] += 1
    
    dic_values = list(dic.values())
    dic_values.sort()
    print(dic_values[-1])


if __name__ == "__main__":
    solve()


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

int main() {
    long long n,k;
    cin>>n>>k;
    vector<long long> h(n);
    for(int i=0;i<n;i++){
        cin>>h.at(i);
    }
    sort(h.begin(),h.end());
    long long  min=1000000000;
    for(int i=0;i<n-k+1;i++){
        if((h.at(i+k-1)-h.at(i))<min){
            min=h.at(i+k-1)-h.at(i);
        }else continue;
    }
    cout<<min<<endl;
}

Measured memory_bytes: 1024
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

s = LS2()
K = I()
n = len(s)

A = set()
for i in range(n):
    for j in range(i,min(n,i+5)):
        A.add(''.join(s[i:j+1]))

A = list(A)
A.sort()

print(A[K-1])


Measured memory_bytes: 70096
import java.util.Scanner;
class Main {
	int H,W,x,y,a,b;
	public void suzuki(){
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		while(H != 0 || W != 0){
			for(x = 0;x != H;x++){
				for(y = 0;y != W;y++){
					a = x % 2;
					b = y % 2;
					if(b == 0){
						if(a == 0){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}else{
						if(a == 1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
			H = sc.nextInt();
			W = sc.nextInt();
		}
	}
	public static void main(String[] args){
		new Main().suzuki();
	}
}

Measured memory_bytes: 25808
#include<iostream>
#include<algorithm>
#include<cstdio>
#define ll long long 
using namespace std;
string s,t;
int a[100005],b[100005],x,ans;
int tag[30],c[30][100005];
int  main()
{
	cin>>s;
	cin>>t;
	int lens=s.length() ,lent=t.length() ;
	for(int i=0;i<lens;i++) a[i+1]=s[i]-'a'+1,tag[a[i+1]]=1;
	for(int i=0;i<lent;i++){
		b[i+1]=t[i]-'a'+1;
		if(!tag[b[i+1]]) {printf("-1");return 0;}
	} 
	for(int i=1;i<=26;i++)
	  if(tag[i]){
	  	x=0;
	  	for(int j=lens;j>=1;j--){c[i][j]=x;if(a[j]==i)x=j;}
		for(int j=1;j<=lens;j++) if(!c[i][j]) c[i][j]=x;
	  }
	x=c[b[1]][lens];
	for(int i=2;i<=lent;i++){
		if(c[b[i]][x]<=x) ans++;
	    x=c[b[i]][x];
	}
	printf("%lld",(ll)ans*lens+x);
	return 0;
}


Measured memory_bytes: 12672
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007
 
int main(){
  ll a,b;
  cin>>a>>b;
  vector<ll> v;
  v.pb(a);
  v.pb(b);
  sort(all(v));
  if(v[0]==1&&v[1]==2){
    cout << 3 << endl;
  }
  if(v[0]==2&&v[1]==3){
    cout << 1 << endl;
  }
  if(v[0]==1&&v[1]==3){
    cout << 2 << endl;
  }  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
const int INF=0x3f3f3f3f;
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}
struct edge{
	int to,nxt,cap,flow;
}e[30005];
int a[105],last[105],cur[105],dis[105],S,T,n,cnt=0;
ll min(ll x,ll y) {return x<y?x:y;}
void insert(int u,int v,int w)
{
	e[++cnt]=(edge){v,last[u],w,0};
	last[u]=cnt;
}
int bfs()
{
	queue<int> q;
	for(int i=1;i<=n+2;i++) dis[i]=INF;
	dis[S]=0;q.push(S);
	while(q.size())
	{
		int x=q.front();q.pop();
		for(int i=last[x];i;i=e[i].nxt)
		if(e[i].cap>e[i].flow&&dis[e[i].to]==INF)
		{
			dis[e[i].to]=dis[x]+1;
			q.push(e[i].to);
		}
	}
	return dis[T]!=INF;
}
ll dfs(int x,ll low)
{
	if(x==T||low==0) return low;
	ll ret=0,st;
	for(int i=cur[x];i;i=e[i].nxt)
	{
		cur[x]=i;
		if(dis[e[i].to]==dis[x]+1&&(st=dfs(e[i].to,min(low,e[i].cap-e[i].flow)))>0)
		{
			ret+=st;
			low-=st;
			e[i].flow+=st;
			e[((i-1)^1)+1].flow-=st;
			if(!low) break;
		}
	}
	return ret;
}
ll dinic()
{
	ll ret=0;
	while(bfs())
	{
		for(int i=1;i<=n+2;i++) cur[i]=last[i];
		ret+=dfs(S,INF);
	}
	return ret;
}
ll ans;
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	S=n+1;T=n+2; 
	for(int i=1;i<=n;i++)
	{
		if(a[i]>0) ans+=a[i],insert(i,T,a[i]),insert(T,i,0);
		else insert(S,i,-a[i]),insert(i,S,0);
	}
	for(int i=1;i<n;i++)
		for(int j=2;j<=n/i;j++)
		{
			insert(i,i*j,a[i*j]);
			insert(i*j,i,0);
		}
	ans-=dinic();
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
	int n, a, b;
	cin >> n;
	vector<pair<int, int>> vp(n);
	rep(i, n){
		cin >> a >> b;
		vp.at(i) = make_pair(a, b);
	}
	sort(vp.begin(), vp.end(), [](auto const &lp, auto const &rp)->bool{
		if(lp.second != rp.second){
			return lp.second < rp.second;
		}else{
			return lp.first < rp.first;
		}
	});
	
	ll t = 0;
	rep(i, n){
		t += vp.at(i).first;
		if(t > vp.at(i).second){
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 1920
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int count = sc.nextInt();
    String str = sc.next();
    int out = 0;
 
    for (int i = 0; i < count -2; i++) {
      if ('A' == str.charAt(i) && 'B' == str.charAt(i + 1) && 'C' == str.charAt(i + 2)) {
            out++;
      }
    }
    System.out.println((long) out);
  }
}

Measured memory_bytes: 23764
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

using namespace std;

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    rep(i, n){
        int a;
        cin >> a;
        if(a%2 == 1){
            cnt++;
        }
    }
    if(cnt % 2 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

class point {
public:
	double x, y;
	point() {}
	point( double x_, double y_ ) :x(x_), y(y_) {}
	point operator -( point p ) { return point( x - p.x, y - p.y ); }
	point operator +( point p ) { return point( x + p.x, y + p.y ); }
	point operator *( int a ) { return point( x * a, y * a ); }
	double dot( point p ) { return p.x * x + p.y * y; }
	double norm() { return x * x + y * y; }
};

int main()
{
	point vp[2];
	cin >> vp[0].x >> vp[0].y >> vp[1].x >> vp[1].y;
	point base = vp[1] - vp[0];
	double norm = base.norm();
	int q;
	cin >> q;
	for( int i = 0; i < q; i++ ) {
		point p;
		cin >> p.x >> p.y;

		double dot = base.dot( p - vp[0] );
		double xd = vp[0].x + base.x * dot / norm;
		double yd = vp[0].y + base.y * dot / norm;
		p = p + ( point( xd, yd ) - p ) * 2;
		cout << fixed << setprecision(10) << p.x << " " << p.y << endl;
	}
}



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

int main() {
	int n,mx=0,mi=1000000000;
	cin >> n;
	for(int i = 0;i < n;i++)
	{
		int a;
		cin >>a;
		mi = min(mi,a);
		mx = max(mx,a);
	}
    cout << mx - mi << endl;
	return 0;
}


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

class DisjoinSet {
    public:
        vector<int> rank, p;

        DisjoinSet() {}
        DisjoinSet(int size) {
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size; i++) makeSet(i);
        }

        void makeSet(int x) {
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x, int y) {
            return findSet(x) == findSet(y);
        }

        void unite(int x, int y) {
            link(findSet(x), findSet(y));
        }

        void link(int x, int y) {
            if (rank[x] > rank[y]) {
                p[y] = x;
            } else {
                p[x] = y;
                if (rank[x] == rank[y]) {
                    rank[y]++;
                }
            }
        }

        int findSet(int x) {
            if (x != p[x]) {
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

int main() {
    int n, a, b, q;
    int com;

    cin >> n >> q;
    DisjoinSet ds = DisjoinSet(n);

    for (int i = 0; i < q; i++) {
        cin >> com >> a >> b;
        if (com == 0) {
            ds.unite(a, b);
        } else {
            if (ds.same(a, b)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=1e5+5;
const ll MAXLG=__lg(MAXN)+2;

ll h,w,k;
ll dp[200][10];
ll two[20][2];

ll mul(ll a,ll b) {
    return a*b%MOD;
}

ll add(ll a,ll b) {
    return (a+b)%MOD;
}

ll t(ll d){
    if(d<0)return 1;
    else return add(two[d][0],two[d][1]);
}
/********** Good Luck :) **********/
int main()
{
    IOS();
    two[0][0] = 1;
    two[0][1] = 0;
    for(ll i=1;i<15;i++){
        two[i][0] = add(two[i-1][0],two[i-1][1]);
        two[i][1] = two[i-1][0];
    }
    cin>>h>>w>>k;
    dp[0][1] = 1;
    for(ll i=1;i<=h;i++){
        for (ll j=1;j<=w;j++) {
            dp[i][j] = mul(dp[i-1][j],mul(t(j-2),t(w-j-1)));
            
            debug(i,j,dp[i][j]);
            if(j>1) dp[i][j] = add(dp[i][j],mul(dp[i-1][j-1],mul(t(j-3),t(w-j-1))));
            if(j<w) dp[i][j] = add(dp[i][j],mul(dp[i-1][j+1],mul(t(j-2),t(w-j-2))));
            debug(i,j,dp[i][j]);
        }
    }
    cout<<dp[h][k]<<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    s=SI()
    n=len(s)
    for i in range(8):
        s1=s[:i]
        s2=s[n+i-7:]
 
        if s1+s2=="keyence":
            print("YES")
            exit()
    print("NO")
        








if __name__=="__main__":
    main()


Measured memory_bytes: 65800
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int A = reader.nextInt();
		int B = reader.nextInt();
		int C = reader.nextInt();
		int[] gaps = new int[6];

		gaps[0] = Math.abs(A - B) + Math.abs(B - C);
		gaps[1] = Math.abs(A - C) + Math.abs(C - B);
		gaps[2] = Math.abs(B - A) + Math.abs(A - C);
		gaps[3] = Math.abs(B - C) + Math.abs(C - A);
		gaps[4] = Math.abs(C - A) + Math.abs(A - B);
		gaps[5] = Math.abs(C - B) + Math.abs(B - A);

		int min = gaps[0];
		for (int i = 1; i < 6; i++) {
			if (gaps[i] < min) {
				min = gaps[i];
			}
		}

		reader.close();
		System.out.print(min);
	}
}



Measured memory_bytes: 23764
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int x, y;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> x >> y;
    int z = y - x - x;
    if (z < 0 || z % 2) {
        cout << "No\n";
    }
    else {
        z /= 2;
        int c = x - z;
        if (c < 0) cout << "No\n";
        else cout << "Yes\n";
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>


int main()
{
    double x1,y1,x2,y2,xq,yq,ax,ay,bx,by,b;
    while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq)!=EOF)
    {
        ax=x2-x1;
        ay=y2-y1;
        bx=ay;
        by=-ax;
        
        b=(ax*(yq-y1)-ay*(xq-x1))/(ay*bx-by*ax);
        
        printf("%lf %lf\n",xq+2*b*bx,yq+2*b*by);
    }

    return 0;
}


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

using namespace std;

const int MOD = 998244353;

int main(){
    int N, M;
    while(cin >> N >> M){
        vector<vector<int>> A(N, vector<int>(M, 0));
        for(auto& v : A){
            for(auto& t : v) cin >> t;
        }
        int c = 0;
        int r = 0;
        for(int i=0;i<min(N, M);i++){
            int pivot = i;
            while(c < M){
                pivot = i;
                for(int j=i+1;j<N;j++){
                    if(A[pivot][c] < A[j][c]){
                        pivot = j;
                    }
                }
                if(A[pivot][c] == 0){ c++; continue; }
                break;
            }
            if(c == M) break;
            r++;
            if(pivot != i){
                for(int j=0;j<M;j++) swap(A[i][j], A[pivot][j]);
            }
            for(int j=i+1;j<N;j++){
                if(A[j][c] != A[i][c]) continue;
                for(int k=c;k<M;k++){
                    A[j][k] = (A[j][k] + A[i][k])%2;
                }
            }
        }
        long long powM = 1, powN = 1;
        for(int i=0;i<M-1;i++) powM = (2*powM) % MOD;
        for(int i=0;i<N;i++) powN = (2*powN) % MOD;
        powN = (powN + MOD - 1) % MOD;
        long long sub = 1;
        for(int i=N-1;i>=r;i--){
            powN = (powN + MOD - sub) % MOD;
            sub = (2*sub) % MOD;
        }
        cout << (powN*powM) % MOD << endl;
    }
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<ArrayDeque<Integer>> matrix = new ArrayList<>();
		ArrayDeque<Integer> deq = new ArrayDeque<>();
		ArrayDeque<Integer> next = new ArrayDeque<>();
		for (int i = 0; i < n; i++) {
		    ArrayDeque<Integer> tmp = new ArrayDeque<>();
		    for (int j = 0; j < n - 1; j++) {
		        tmp.add(sc.nextInt() - 1);
		    }
		    matrix.add(tmp);
		    deq.add(i);
		}
		int times = 0;
		while (deq.size() > 0) {
		    times++;
		    boolean[] used = new boolean[n];
		    while(deq.size() > 0) {
		        int x = deq.poll();
		        if (!used[x] && matrix.get(x).size() > 0) {
		            int y = matrix.get(x).peek();
		            if (!used[y] && matrix.get(y).peek() == x) {
		                next.add(x);
		                next.add(y);
		                used[x] = true;
		                used[y] = true;
		                matrix.get(x).poll();
		                matrix.get(y).poll();
		            }
		        }
		    }
		    ArrayDeque<Integer> tmp = next;
		    next = deq;
		    deq = tmp;
		}
        int count = 0;
        for (ArrayDeque tmp : matrix) {
            count += tmp.size();
        }
        if (count > 0) {
            System.out.println(-1);
            return;
        }
		System.out.println(times - 1);
   }
}


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

using namespace std;
using ll = long long;

int main(){
  int N, W;
  cin >> N >> W;
  ll wv[N][2];
  for(int i=0; i<N; ++i){
    cin >> wv[i][0] >> wv[i][1];
  }
  ll dp[N+1][W+1];
  for(int i=0; i<=N; ++i){
    for(int j=0; j<=W; ++j){
      dp[i][j] = 0;
    }
  }
  for(int i=0; i<N; ++i){
    for(int j=0; j<=W; ++j){
      if(j-wv[i][0] >= 0){
        if(dp[i][j-wv[i][0]] + wv[i][1] >= dp[i+1][j]){
          dp[i+1][j] = dp[i][j-wv[i][0]] + wv[i][1];
        }
      }
      if(dp[i+1][j] < dp[i][j]){
        dp[i+1][j] = dp[i][j];
      }
    }
  }

  cout << dp[N][W] << endl;
  return 0;
}

Measured memory_bytes: 79104
// Problem : F - Yakiniku Optimization Problem
// Contest : AtCoder - AtCoder Beginner Contest 157
// URL : https://atcoder.jp/contests/abc157/tasks/abc157_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 65

//Solution

db x[N],y[N],c[N];
int n,k;

struct circle{
    db x,y,r;
    circle(db a,db b,db c){
        x = a;
        y = b;
        r = c;
    }
};

db sqr(db x){return x*x;}

bool inside(circle cir, pair<db,db> pt){
    return sqr(cir.x-pt.fi)+sqr(cir.y-pt.se)-sqr(cir.r) < EPS;
}

bool in_k_circles(vector<circle> cir, pair<db,db> pt){
    int cnt = 0;
    for(circle cc : cir){
        if(inside(cc,pt)) cnt++;
    }
    return cnt >= k;
}

bool check(db t){
    vector<circle> cir;
    for(int i=0;i<n;i++) cir.pb(circle(x[i],y[i],t/c[i]));
    vector<pair<db,db>> pts;
    for(int i=0;i<n;i++) pts.pb({x[i],y[i]});
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            db dx = cir[j].x-cir[i].x;
            db dy = cir[j].y-cir[i].y;
            db r = cir[i].r;
            db a = -2*dx; 
            db b = -2*dy;
            db c = dx*dx+dy*dy+r*r-cir[j].r*cir[j].r;
            db x0 = -a*c/(a*a+b*b), y0 = -b*c/(a*a+b*b);
            if (c*c > r*r*(a*a+b*b)+EPS) continue;
            else if (abs (c*c - r*r*(a*a+b*b)) < EPS) pts.pb({x0+cir[i].x,y0+cir[i].y});
            else {
                db d = r*r - c*c/(a*a+b*b);
                db mult = sqrt (d / (a*a+b*b));
                db ax, ay, bx, by;
                ax = x0 + b * mult;
                bx = x0 - b * mult;
                ay = y0 - a * mult;
                by = y0 + a * mult;
                pts.pb({ax+cir[i].x,ay+cir[i].y});
                pts.pb({bx+cir[i].x,by+cir[i].y});
            }
        }
    }
    for(auto pt : pts){
        if(in_k_circles(cir,pt)) return true;
    }
    return false;
}

void solve(){
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>c[i];
    db lo=0, hi=1e6;
    while(hi-lo>EPS){
        db mid = (lo+hi)/2;
        if(check(mid)) hi = mid;
        else lo = mid;
    }
    cout<<fixed<<setprecision(9)<<lo<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;

int main(){
    int n; cin >> n;
    
    int count = 0;
    int a=0,b=0,ba=0;
    string s;
    for(int i=0; i<n; i++){
        cin >> s;
        if(s[0]=='B' && s[s.size()-1]=='A')
            ba++;
        else if(s[0]=='B')
            b++;
        else if(s[s.size()-1]=='A')
            a++;
        
        for(int j=1; j<s.size(); j++){
            if(s[j-1]=='A' && s[j]=='B')
                count++;
        }
    }
    
    if(ba==0)count += min(a,b);
    if(ba!=0){
        if(b==0 && a==0)
            count += ba-1;
        else
            count += ba + min(a,b);
    }
    
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
int a[12345];
int main(){
    std::ios::sync_with_stdio(false);
    int n,m,x,i;
    cin>>n>>m>>x;
    int l=0,r=0;
    rep(i,m){
    	cin>>a[i];
    	if(a[i]>x)
    		l++;
    	else
    		r++;
    }
    cout<<min(l,r)<<endl;
    
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

string S;
int main() {
    while (cin >> S) {
        int res = 0;
        char prev = 'A';
        for (int i = 0; i < S.size(); ++i) {
            if (S[i] <= prev) ++res;
            prev = S[i];
        }
        cout << res << endl;
    }
}
































Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int k, s, a, b, ans = 0, c;
	cin >> k >> s;
	for (a = 0; a <= k; a++) {
		for (b = 0; b <= k; b++) {
			c = s - a - b;
			if ((c >= 0) && (c <= k)) ans++;
		}
	}
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 632
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
int main()
{
	map<string, int> q;
	int n, mx = 0;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		string x;
		cin >> x;
		++q[x];
	}
	for (auto i : q) mx = max(i.second, mx);
	for (auto i : q) if (i.second == mx) cout << i.first << endl;
	return 0;
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll fac[100010],g[100010],a[100010];
const int mod=1e9+7;
int read()
{
	int x=0;char c=getchar(),flag='+';
	while(!isdigit(c)) flag=c,c=getchar();
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	return flag=='-'?-x:x;
}
ll qpow(ll a,ll b)
{
	ll ans=1,base=a;
	while(b)
	{
		if(b&1) ans=ans*base%mod;
		base=base*base%mod;
		b>>=1;
	}
	return ans%mod;
}
int main()
{
	int n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	fac[0]=1;
	for(int i=1;i<=100000;i++) fac[i]=fac[i-1]*i%mod;
	ll num=0,ans=0;
//	for(int i=0;i<=n-1;i++) num=(num+C(n-1,i)*fac[n-i-1]%mod)%mod;
//	ans=(ans+num*a[1])%mod;
//	for(int i=2;i<=n;i++)
//	{
//		num=(num+C[nl
//	}
	g[1]=0;
//	inv[1]=1;
//	for(int i=2;i<=100000;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=100000;i++) g[i]=(g[i-1]+qpow(i,mod-2))%mod;
	for(int i=1;i<=n;i++)
	{
		ans=(ans+a[i]*fac[n]%mod*g[i]%mod+a[i]*fac[n]%mod*g[n-i+1]%mod+a[i]*fac[n])%mod;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	if (N==1){
		cout<<1<<endl;
		return 0;
	}
	int i;
	int s=0;
	for (i=1;i<N;i++){
		if (i*(i+1)>=2*N){
			break;
		}
	}

	int Min=1;
	int Max=i;
	s = Max;
	i=Max-1;
	while (i>0){
		if (i+s<=N){
			cout<<i<<endl;
			s+=i;
		}
		i--;
	}
	cout<<Max<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        
        System.out.println(N % 1000 == 0 ? 0 : 1000 - N % 1000);
    }
}


Measured memory_bytes: 35496
s = input()
t = input()

ans = 2000

for i in range(len(s) - len(t) + 1):
    s1 = s[i:i+len(t)]
    tmp = 0
    for i in range(len(s1)):
        if s1[i] != t[i]:
            tmp += 1
    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 9004
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}


int main()
{
    int n, k;    
    cin >> n >> k;
    vector<int> x(n);
    rep(i,n) cin >> x[i];

    int ans = 0;
    rep(i,n) {
        ans += min(abs(0 - x[i])*2, abs(k - x[i])*2);
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
a.insert(n + 1,0)

t = 0
for i in range(1,n + 2):
  t += abs(a[i] - a[i-1])

for i in range(1,n + 1):
  print(t - abs(a[i] - a[i -1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]))

Measured memory_bytes: 13920
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{

    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var val = (int)Math.Truncate(N / 1.08);
            for (int i = val - 1; i <= val + 1; i++)
            {
                if ((int)Math.Truncate(i * 1.08) == N)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
            Console.WriteLine(@":(");
        }
    }
}

Measured memory_bytes: 27448
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll N,K;cin>>N>>K;
    vl x(N),y(N);
    rep(i,N)cin>>x[i]>>y[i];
    ll ans=INF;
    rep(i,N)rep(j,N)rep(k,N)rep(l,N){
        if(x[i]>x[j])continue;
        if(y[k]>y[l])continue;
        ll count=0;
        rep(m,N){
            if(x[i]<=x[m] and x[m]<=x[j] and y[k]<=y[m] and y[m]<=y[l])count++;
        }
        if(count>=K)ans=min(ans,(x[j]-x[i])*(y[l]-y[k]));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import static java.util.Arrays.deepToString;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		while (sc.hasNextLine()) {
			char[] s = sc.nextLine().toCharArray();
			char[] t = getCode1(s);
			System.out.println(new String(t));
		}
	}
	
	char[] getCode1(char[] s) {
		ArrayList<Integer> L = new ArrayList<Integer>();
		
		for (char c : s) {
			String t = f(c);
			for (int i = 0; i < t.length(); i++) {
				L.add(t.charAt(i) == '1' ? 1 : 0);
			}
		}
		while (L.size() % 5 > 0) {
			L.add(0);
		}
		
		char[] res = new char[L.size() / 5];
		for (int i = 0; i < L.size(); i += 5) {
			String cc = "";
			for (int j = 0; j < 5; j++) cc += L.get(i + j);
			res[i/5] = g(cc);
		}
		return res;
	}
	
	Map<String, Character> mp;
	
	
	char g(String s) {
		if (mp == null) {
			mp = new HashMap<String, Character>();
			mp.put("00000",'A');
			mp.put("00001",'B');
			mp.put("00010",'C');
			mp.put("00011",'D');
			mp.put("00100",'E');
			mp.put("00101",'F');
			mp.put("00110",'G');
			mp.put("00111",'H');
			mp.put("01000",'I');
			mp.put("01001",'J');
			mp.put("01010",'K');
			mp.put("01011",'L');
			mp.put("01100",'M');
			mp.put("01101",'N');
			mp.put("01110",'O');
			mp.put("01111",'P');
			mp.put("10000",'Q');
			mp.put("10001",'R');
			mp.put("10010",'S');
			mp.put("10011",'T');
			mp.put("10100",'U');
			mp.put("10101",'V');
			mp.put("10110",'W');
			mp.put("10111",'X');
			mp.put("11000",'Y');
			mp.put("11001",'Z');
			mp.put("11010",' ');
			mp.put("11011",'.');
			mp.put("11100",',');
			mp.put("11101",'-');
			mp.put("11110",'\'');
			mp.put("11111",'?');
		}
		return mp.get(s);
	}
	
	String f(char c) {
		switch(c) {
	case ' ': return"101";
	case '\'': return"000000";
	case ',': return"000011";
	case '-': return"10010001";
	case '.': return"010001";
	case '?': return"000001";
	case 'A': return"100101";
	case 'B': return"10011010";
	case 'C': return"0101";
	case 'D': return"0001";
	case 'E': return"110";
	case 'F': return"01001";
	case 'G': return"10011011";
	case 'H': return"010000";
	case 'I': return"0111";
	case 'J': return"10011000";
	case 'K': return"0110";
	case 'L': return"00100";
	case 'M': return"10011001";
	case 'N': return"10011110";
	case 'O': return"00101";
	case 'P': return"111";
	case 'Q': return"10011111";
	case 'R': return"1000";
	case 'S': return"00110";
	case 'T': return"00111";
	case 'U': return"10011100";
	case 'V': return"10011101";
	case 'W': return"000010";
	case 'X': return"10010010";
	case 'Y': return"10010011";
	case 'Z': return"10010000";
		}
		return "";
	}
	
	
}

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    return 0;
}

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

int main()
{
 int d;
 while(cin>>d)
 {
 int y=0;
for(int i=1; i*d<600; i++)
{
 y+=d*(d*i)*(d*i);
 }
cout<<y<<endl;
}
return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

#define MAX_NO_OF_NODES 100000

typedef enum{
    root,
    internal_node,
    leaf
} node_state;

typedef struct{
    int parent;
    int left;
    int right;
} node_t;

void matchParent(int, int);
int getDepth(int);
void printNode(int);

int n;
node_t node[MAX_NO_OF_NODES];

int main()
{
    int i, j, id, degree, tempChild, currentChild;
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) node[i].parent = node[i].left = node[i].right = -1;
    
    for (i = 0; i < n; i++){
        scanf("%d %d", &id, &degree);
        if (degree != 0){
            for (j = 0; j < degree; j++) {
                scanf("%d", &tempChild);
                if (j == 0) node[id].left = tempChild;
                else node[currentChild].right = tempChild;
                node[tempChild].parent = id;
                currentChild = tempChild;
            }
        }
    }
    
    for (i = 0; i < n; i++){
        printNode(i);
    }
    
}

int getDepth(int targetID){
    int i = 0;
    while (node[targetID].parent != -1){
        i++;
        targetID = node[targetID].parent;
    }
    return i;
}

void printNode(int i){
    int j;
    int depth = getDepth(i);
    printf("node %d: parent = %d, ", i, node[i].parent);
    printf("depth = %d,", depth);
    
    if (node[i].parent == -1) printf(" root, [");
    else if (node[i].left == -1) printf(" leaf, [");
    else printf(" internal node, [");

    if (node[i].left != -1){
        printf("%d", node[i].left);
        int cur = node[i].left;
        while(node[cur].right != -1){
            printf(", %d", node[cur].right);
            cur = node[cur].right;
        }
    }
    printf("]\n");
}




Measured memory_bytes: 2892
n=int(input())
a=list(map(int,input().split()))
stock,bill=0,1000
i=0
while i<n:
    if a[i]<=a[i+1]:
        t=i
        while i<n-1 and a[i]<=a[i+1]: i+=1
        temp=bill//a[t]
        stock+=temp
        bill-=temp*a[t]
        if i==n-1:
            bill+=stock*a[n-1]
            print(bill)
            exit()
    elif a[i]>=a[i+1]:
        t=i
        while i<n-1 and a[i]>=a[i+1]: i+=1
        bill+=stock*a[t]
        stock=0
        if i==n-1:
            print(bill)
            exit()

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

int main() {
  int n;
  cin>>n;
  map<int, int> md;
  ++md[0];
  for (int i=0; i<n; i++) {
    int di;
    cin>>di;
    ++md[di];
  }
  vector<int> d1, d2;
  for (auto e: md) {
    int v = e.second;
    if (v == 1) {
      if (e.first == 0) {
        d2.push_back(e.first);
      } else {
        d1.push_back(e.first);
      }
    } else if (v == 2) {
      d2.push_back(e.first);
      d2.push_back(24 - e.first);
    } else {
      cout<<0<<endl;
      return 0;
    }
  }
  int size = d1.size();
  int ans = 0;
  for (int state=0; state<(1<<size); state++) {
    vector<int> v;
    for (int i=0; i<size; i++) {
      if ((state>>i) & 1) {
        v.push_back(24 - d1[i]);
      } else {
        v.push_back(d1[i]);
      }
    }
    for (int di: d2) {
      v.push_back(di);
    }
    sort(v.begin(), v.end());
    int s = 12;
    for (int i=0; i<v.size(); i++) {
      int x = abs(v[(i+1)%v.size()] - v[i]);
      s = min(min(x, 24 - x), s);
    }
    ans = max(s, ans);
  }
  cout<<ans<<endl;
}

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

using namespace std;

int n,k,c;
char s[200005];
int f[500005];

int main()
{
	scanf("%d%d%d",&n,&k,&c);
	scanf("%s",s+1);
	memset(f,0,sizeof(f));
	for (int i=n;i>=1;--i)
	{
		f[i]=f[i+1];
		if (s[i]=='x') continue;
		f[i]=max(f[i],1+f[i+c+1]);
	}
	int now=0,last=-1e9;
	vector<int> v;
	v.clear();
	for (int i=1;i<=n;++i)
	{
		if (s[i]=='x') continue;
		if (f[i+1]+now>=k)
		{
			if (i-last>=c+1) now++,last=i;
		} else
		{
			v.push_back(i);
			now++;
			last=i;
		}
	}
	for (int i=0;i<v.size();++i) printf("%d\n",v[i]);
	return 0;
}

Measured memory_bytes: 4596
#include <cstdio>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

#define ALL(v) (v).begin(),(v).end()
typedef long long LL;

const LL MOD = 998244353;

struct segtree{
	vector<int> dat;
	int m;
	segtree(int n){
		for(m = 1; m < n; m *= 2);
		dat.assign(m * 2 - 1, -1);
	}
	void update(int k, int v){
		k += m - 1;
		dat[k] = v;
		while(k){
			k = (k - 1) / 2;
			dat[k] = max(dat[k], v);
		}
	}
	int query(int a, int b){
		return query(a, b, 0, 0, m);
	}
	int query(int a, int b, int k, int l, int r){
		if(b <= l || r <= a){ return -1; }
		if(a <= l && r <= b){ return dat[k]; }
		int md = (l + r) >> 1;
		int x = query(a, b, k * 2 + 1, l, md);
		int y = query(a, b, k * 2 + 2, md, r);
		return max(x, y);
	}
};

int main(){
	int n;
	scanf("%d", &n);
	vector<LL> xs(n), ds(n);
	vector<LL> ps;
	for(int i = 0; i < n; ++i){
		scanf("%lld%lld", &xs[i], &ds[i]);
		ps.push_back(xs[i]);
		ps.push_back(xs[i] + ds[i]);
	}
	ps.push_back(LLONG_MAX);
	sort(ALL(ps));
	ps.erase(unique(ALL(ps)), ps.end());

	int sz = ps.size();
	vector<int> to(sz, -1);
	for(int i = 0; i < n; ++i){
		int k = lower_bound(ALL(ps), xs[i]) - ps.begin();
		int l = lower_bound(ALL(ps), xs[i] + ds[i]) - ps.begin();
		to[k] = l;
	}

	segtree st(sz);
	vector<LL> dp(sz);
	dp[sz - 1] = 1;
	for(int i = sz - 2; i >= 0; --i){
		LL &r = dp[i];
		r = dp[i + 1];
		if(to[i] >= 0){
			int a = st.query(i, to[i]);
			if(a < 0){ a = i + 1; }
			r += dp[a];
			st.update(i, a);
		}
		r %= MOD;
	}
	printf("%lld\n", dp[0]);
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

ll BIG = 10000000000000000;

vll step(vll& state, int ind) {
    int N = state.size();
    vll nstate(N-1);
    for(int j=0;j<ind-1;j++) nstate[j] = state[j];
    nstate[ind-1] = state[ind-1] + state[ind];
    nstate[ind] = state[ind] + state[ind+1];
    for(int j=ind+2;j<N;j++) nstate[j-1] = state[j];
    return nstate;
}

ll get_optimal(vll& A, int L, int R, ll mL, ll mR) {
    ll mC = mL + mR;
    if (R < L) return 0; // shouldn't happen
    if (R == L) return mC*A[L];

    ll opt = BIG;
    for (int c=L; c<=R; c++) {
        ll cur = A[c]*mC + get_optimal(A, L, c-1, mL, mC) + get_optimal(A, c+1, R, mC, mR);
        opt = min(cur, opt);
    }
    return opt;
}

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

    int N;
    cin >> N;

    vll A(N);
    for(int i=0;i<N;i++) cin >> A[i];

    ll ans = get_optimal(A, 1, N-2, 1, 1);
    ans += A[0] + A[N-1];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_B&lang=ja

def solve(n, x):
    count = 0
    for largest in range(1, n+1):
        for middle in range(1, largest):
            for smallest in range(1, middle):
                if largest+middle+smallest == x:
                    count += 1
    return count

while True:
    n, x = map(int, input().split(" "))
    if n == 0 and x == 0:
        break
    print(solve(n, x))


Measured memory_bytes: 5600
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
As.sort()
M = As.pop()

diff = 10**18
for a in As:
    if abs(M/2-a)<diff:
        diff = abs(M/2-a)
        ans = a

print(M, ans)

Measured memory_bytes: 86236
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define repe(i,n) for (int i = 1; i <= (int)(n); ++i)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define ll long long
using namespace std;
typedef vector<vector<int> > Graph;

int ans = 0;
int N,M,Q;
vector<int> a,b,c,d;
void dfs(vector<int> vec){
        int now = 0;
        if(vec.size() == N+1){
            rep(i,Q){
                if(vec.at(b.at(i))-vec.at(a.at(i)) == c.at(i)) now += d.at(i);
            }
            ans = max(ans,now);
            return;
        }
        vec.push_back(vec.back());
        while(vec.back() <= M){
            dfs(vec);
            vec.back()++;
        }
    }

int main(){

    cin >> N >> M >> Q;
    a = b = c = d = vector<int> (Q);
    rep(i,Q) cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    vector<int> vec(1,1);
    dfs(vec);
    cout << ans << endl;

}


Measured memory_bytes: 3604
#import sys
#input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

c = str(input())
if c == 'A':
	print('T')
elif c == 'T':
	print('A')
elif c == 'C':
	print('G')
else:
	print('C')
	

Measured memory_bytes: 38384
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
int main(){
	int n=0;
	int k=0;
	scanf("%d %d\n",&n,&k);
	if(2*k-1<=n){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	
}

Measured memory_bytes: 128
n = int(input())

ans = [0] * (n+1)
x = 1
while n > x*x:
    x += 1
for i in range(1,x+1):
    for j in range(1,x+1):
        for k in range(1,x+1):
            m = i*i + j*j + k*k + i*j + j*k + k*i
            if m <= n:
                ans[m] += 1

for i in range(1,n+1):
    print(ans[i])

Measured memory_bytes: 9432
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int a[4][1 << 16];
int main() {
	for (int i = 1; i < 256; i++) {
		a[0][i*i] = 1;
		for (int j = 1; j + i*i < (1 << 16); j++) {
			for (int k = 1; k < 4; k++) {
				a[k][j + i*i] += a[k - 1][j];
			}
		}
	}
	int n;
	while(cin >> n, n) {
		cout << a[0][n] + a[1][n] + a[2][n] + a[3][n] << endl;;
	}
	return 0;
}

Measured memory_bytes: 4080
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int c=a+b;
	if(a%3==0||b%3==0||c%3==0)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	


    return 0;
}


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

int main(void){
    vector<int> A(3);
    for(int i=0; i<3; i++) cin >> A[i];
    sort(A.begin(), A.end());

    if(A[0]==A[1]) cout << A[2] << endl;
    else cout << A[0] << endl;

    return 0;
}

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

int main()
{
    long hantei;
    long yokin = 100;
    cin >> hantei;
    for (long i = 1;; i++)
    {
        yokin *= 1.01;
        if (yokin >= hantei)
        {
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 3592