akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
typedef pair<int, int> PR;

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}
//cout<<""<<endl;

int main(){
  int N;
  string S;
  cin>>   N;
  int cnt=0;
  for(int a=1;a<=N;a++){
    for(int b=1;b<=N;b++){
      if(a*b>N)break;
      if(N-a*b>0)cnt++;
    }
  }
  cout<<cnt<<endl;
  
}



Measured memory_bytes: 3724
#include<iostream>
using namespace std;
char S[1024];

int main(){
  char K[8]="keyence";
  int p=0,q=0;
  cin >> S;
  int l = strlen(S);
  for(int i=0;i<7;i++){
    if (S[i]==K[i]){p++;}else{break;}
  }
  for(int i=0;i<7;i++){
    if (S[l-1-i]==K[6-i]){q++;}else{break;}
  }
  if (p+q>=7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define bp __builtin_popcountll
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
int main() 
{
    FAST;
    ll a,b,c;
    cin >> a >> b >> c;
    ll temp = a;
    a = a - c;
    a = max(a,0LL);
    c = c - (temp-a);
    if(c>0)
    {
        b = b - c;
        b = max(b,0LL);
    }
    cout<<a << " "<<b;
}


 

Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  int[] a; readA(n, a);
  writeln(a.map!(ai => ai.bsf).sum);
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }

  pure T bitSet(T)(T n, size_t s, size_t e) { return n | ((T(1) << e) - 1) & ~((T(1) << s) - 1); }
  pure T bitReset(T)(T n, size_t s, size_t e) { return n & (~((T(1) << e) - 1) | ((T(1) << s) - 1)); }
  pure T bitComp(T)(T n, size_t s, size_t e) { return n ^ ((T(1) << e) - 1) & ~((T(1) << s) - 1); }

  import core.bitop;
  pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); }
  pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); }
  pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); }
}


Measured memory_bytes: 508
#include<iostream>
#include<string.h>
#include<vector>
#include <algorithm>
using namespace std;


int main()
{

  long long X,K,D;
  cin >> X >> K >> D;  
  
  
//  if( abs(X) > abs(K*D))
  if( abs(X)/D > K)
  {
//    cout << "CASE1" << endl;
    
    cout << abs(X) - abs(K*D);
  }else
  {
    long long res = abs(X)%D;
    long long count = abs(X)/D;
    int sign = X/abs(X);
    
    if((K-count)%2==0)
    {
//          cout << "CASE2" << endl;

      cout << res;
      return 0;
    }
    else
    {
//          cout << "CASE3" << endl;

      cout << abs(res-D);
      return 0;
    }
  }

    return 0;
  
}

Measured memory_bytes: 3632
// Date: 2020-04-07

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

LL fac[N];
int main() {
    FIO;
    fac[0] = 1;
    rep(i, 1, N-1) fac[i] = fac[i-1] * i % mod;
    int n, m;
    cin >> n >> m;
    if(n > m) swap(n, m);
    LL ans = 0;
    if(n == m-1) {
        ans += fac[m] * fac[n] % mod;
    } else if(n == m) {
        ans += 2*fac[m]*fac[n]%mod;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin>>n;
 int a[n];
 for(int i=0;i<n;i++)
 cin>>a[i];
int dp[n]={0};
dp[0]=0;
dp[1]=abs(a[1]-a[0]);
for(int i=2;i<n;i++)
{
  dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),abs(a[i]-a[i-2])+dp[i-2]);
}
cout<<dp[n-1];
}






Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {

    int a, b, c, x;
    cin >> a >> b >> c;
    
    if(a > b){
        x = b;
        b = a;
        a = x;
    }
    if(b > c){
        x = c;
        c = b;
        b = x;
    }
    if (a > b){
        x = a;
        a = b;
        b = x;
    }
    cout << a << " " << b << " " << c << endl;;
        
    return 0;
}

Measured memory_bytes: 1168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int[] d10 = new int[10];
        d10[0] = 1;
        for (int i = 1; i < d10.length; i++) {
            d10[i] = d10[i-1] * 10;
        }
        ArrayList<Integer> list = new ArrayList<>();
        ArrayDeque<Integer> que = new ArrayDeque<>();
        que.add(3);
        que.add(5);
        que.add(7);
        while(list.size() <= 26484){
            int n = que.removeFirst();
            boolean use3 = false;
            boolean use5 = false;
            boolean use7 = false;
            int nn = n;
            int d = 0;
            while(nn>0){
                if(nn%10==3) use3=true;
                if(nn%10==5) use5=true;
                if(nn%10==7) use7=true;
                nn = nn/10;
                d++;
            }
            if(use3&&use5&&use7) list.add(n);
            if(d>9) break;
            que.addLast(n+3*d10[d]);
            que.addLast(n+5*d10[d]);
            que.addLast(n+7*d10[d]);
        }
        int ans = 0;
        for (Integer n : list) {
            if(n<=N){
                ans++;
                // System.out.println(n);
            }
        }
        out.println(ans);
    }

    final int mod = 1000000007;
    int mul(int x, int y){
        return (int)((x * 1L * y) % mod);
    }
    int add(int x, int y) {
        x += y;
        return x >= mod ? (x - mod) : x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        return x >= mod ? (x - mod) : x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 37516
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		if(a<b) System.out.println("a < b");
		if(a>b) System.out.println("a > b");
		if(a==b) System.out.println("a == b");

	}

}

Measured memory_bytes: 26072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(int i=int(x);i<int(y);++i)
#define For(i,x,y)  for(int i=int(x);i<=int(y);++i)
#define FOr(i,x,y)  for(int i=int(x);i>=int(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define Max(x,y)    ((x)=((x)<(y)?(y):(x)))
#define Min(x,y)    ((x)=((x)>(y)?(y):(x)))
#define E(x)        return writeln(x),0
#define LL			(long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue		puts("\nGuYueNa________________________________________________________________________________")
typedef complex<double> E;
namespace cqz{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_; 
#endif 
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*S=SZB,*T=SZB;
    inline char gc(){   if (S==T){  T=(S=SZB)+fread(SZB,1,GYN,stdin); if (S==T) return '\n';  }   return *S++;    }
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
	void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);}
	void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);}
	void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);}
	void writeln(ll x){write(x);puts("");}
}using namespace cqz;
const ll N=200010;
ll a[N],del[N],q[N],cur[N],sum,answ,top,n,Left=0;
int main(){
	n=read();
	For(i,1,n)a[i]=read();
	For(i,1,n)if (i-a[i]<=0)return puts("-1"),0;
	FOr(i,n,1){
		for(;(Left<top)&&(q[Left+1]>=i);++Left);
		for(;top&&(q[top]>=i);--top);
//		For(j,1,top)write(q[j]),putchar('	');puts("");
		Min(Left,top);
		if ((Left<top)&&Left+1<cur[i])return puts("-1"),0;
		if (!a[i]){if (top)return writeln(-1),0;}
		lf (!top||(q[top]!=i-a[i])){q[++top]=i-a[i];del[i-a[i]]++;++sum;
									Max(cur[i-a[i]],top);}
		sum-=del[i];		answ+=sum;
	}writeln(answ);
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
int a[1<<18];
int ft[300001];
void update(int i, int v){
    for(;i<=300000;i+=(i&-i)) ft[i] += v;
}
int query(int i){
    int ans = 0;
    for(;i>0;i-=(i&-i)) ans+=ft[i];
    return ans;
}

int main(){
    int n;
    scanf("%d", &n);
    vector<int> idx;
    idx.push_back(0);
    for(int i=0;i<(1<<n);i++){
        scanf("%d", &a[i]);
        idx.push_back(a[i]);
    }
    sort(a, a+(1<<n));
    reverse(a, a+(1<<n));
    sort(idx.begin(), idx.end());
    idx.erase(unique(idx.begin(), idx.end()), idx.end());
    for(int i=1;i<(1<<n);i++){
        int j = lower_bound(idx.begin(), idx.end(), a[i]) - idx.begin();
        update(j, 1);
    }
    int j = lower_bound(idx.begin(), idx.end(), a[0]) - idx.begin();
    vector<int> v;
    v.push_back(j);
    bool ok = 1;
    for(int i=1;i<=n;i++){
        vector<int> v2;
        for(int i=0;i<v.size();i++) v2.push_back(v[i]);
        for(int i=0;i<v.size();i++){
            int val = v[i];
            int lo = 1, hi = val-1, ans = -1;

            int q = query(val-1);
            if(q == 0){
                ok = 0;
                break;
            }
            while(lo <= hi){
                int mid = (lo+hi)/2;
                if(q-query(mid) == 0) ans = mid, hi = mid-1;
                else lo = mid+1;
            }

            if(ans == -1){
                ok = 0;
                break;
            }
            update(ans, -1);
            v2.push_back(ans);
        }
        if(!ok) break;
        v = v2;
        sort(v.begin(), v.end());
        reverse(v.begin(), v.end());
    }

    if(ok) printf("Yes\n");
    else printf("No\n");
}

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

int main() {
	int N, T;
	cin >> N >> T;
	vector<int>A;
	pair<int, int>C;
	for (int i = 0; i < N; i++) {
		cin >> C.first >> C.second;
		if (C.second <= T) A.push_back(C.first);
	}
	if (A.empty()) {
		cout << "TLE" << endl;
		return 0;
	}
	sort(A.begin(), A.end());
	cout << A.at(0) << endl;
}

Measured memory_bytes: 256
import queue

dx = [-1, 1, 0, 0]
dy = [0, 0, -1, 1]


def bfs():
    max_dist = 0
    while not que.empty():
        pos = que.get()
        for y, x in zip(dy, dx):
            ty = pos[0] + y
            tx = pos[1] + x
            if ty < 0 or H <= ty:
                continue
            if tx < 0 or W <= tx:
                continue
            if visited[ty][tx]:
                continue
            if S[ty][tx] == "#":
                continue
            que.put((ty, tx, pos[2] + 1))
            visited[ty][tx] = True
            max_dist = max(max_dist, pos[2] + 1)
    return max_dist


H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append([c for c in input()])
ans = 0
for sy in range(H):
    for sx in range(W):
        if S[sy][sx] == "#":
            continue
        visited = [[False for _ in range(W)] for _ in range(H)]
        visited[sy][sx] = True
        que = queue.Queue()
        que.put((sy, sx, 0))
        ans = max(ans, bfs())
print(ans)

Measured memory_bytes: 4080
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll>vi;
vector<ll> :: iterator vt;
ll arr[200009];
int main()
{
    ll n,t,x,y,z,m,j,i,k,flag =0,maxi=LONG_LONG_MIN ,mini=LONG_LONG_MAX,sum=0,c=0;
    map<ll,ll>mp;
    map<ll,ll> :: iterator mt;
    string s, ss;
    cin>>n>>m;
    x=n*m;
    if(n==1 && m==1)
        cout<<1<<endl;
    else if(m==2 || n==2)
        cout<<0<<endl;
    else if( m == 1 )
    {
        cout<<n-2<<endl;
    }
    else  if(n == 1)
        cout<<m-2<<endl;
    else{
        cout<<m*n - m*2-n*2 +4<<endl;
    }


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

int main(void)
{
    ll N;
    cin >> N;

    ll ans = 0;
    for ( ll i = 1; i <= N; i++ ) {
        if ( (i % 3 != 0) && (i % 5 != 0) ) {
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

const ll L = 1e5+5;

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

    string s, t;
    cin >> s >> t;

    cout << t+s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <sstream>
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<set>

using namespace std;


int main(int ac, char* av[]){
    int N;
    cin >> N;
    vector<long> A;
    vector<int> cmd;
    for(int i=0;i<N;i++){
        long a;
        cin >> a;
        A.push_back(a);
    }
    int nxtstate = 1;
    for(int i=0;i<N-1;i++){
        if(nxtstate == 1){
            if(A[i] < A[i+1]){
                cmd.push_back(1);
                nxtstate = -1;
            }else{
                cmd.push_back(0);
            }
        }else{
            if(A[i] > A[i+1]){
                cmd.push_back(-1);
                nxtstate = 1;
            }else{
                cmd.push_back(0);
            }
        }
    }
    cmd.push_back(-1);
    long stocks=0;
    long money = 1000;
    for(int i=0;i<N;i++){
        if(cmd[i] == 1){
            //buy
            stocks += money / A[i];
            money -= A[i] * stocks;
        }else if(cmd[i] == -1){
            //sell
            money += stocks*A[i];
            stocks = 0;
        }
    }



    cout << money << endl;
    return 0;
}



Measured memory_bytes: 3200
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto nk = readln.split.to!(long[]);
    auto N = nk[0];
    auto K = nk[1];
    long[] ps, ns;
    long zc, nc, pc;
    foreach (a; readln.split.to!(long[])) {
        if (a > 0) {
            ps ~= a;
        } else if (a < 0) {
            ns ~= -a;
        } else {
            ++zc;
        }
    }
    zc = zc * (zc-1) / 2L + zc * (N-zc);
    nc = (ps.length * ns.length).to!long;

    if (K <= nc) {
        sort!"a > b"(ns);
        sort!"a > b"(ps);
        if (K == nc) {
            writeln(-ns[$-1] * ps[$-1]);
            return;
        }
        long l = ns[0] * ps[0]+1, r;
        while (l > r+1) {
            auto m = (l+r)/2;
            long k;
            foreach (p; ps) {
                if (p * ns[0] < m) continue;
                long ll, rr = ns.length.to!long;
                while (ll+1 < rr) {
                    auto mm = (ll+rr)/2;
                    if (p * ns[mm] >= m) {
                        ll = mm;
                    } else {
                        rr = mm;
                    }
                }
                k += rr;
            }
            if (k < K) {
                l = m;
            } else {
                r = m;
            }
        }
        writeln(-r);
    } else if (K <= nc + zc) {
        writeln(0);
    } else {
        sort!"a < b"(ns);
        sort!"a < b"(ps);
        K -= nc + zc;
        long l, r = 10L^^18+1;
        while (l+1 < r) {
            auto m = (l+r)/2;
            long k;
            foreach (i; 0..ns.length.to!long-1) {
                if (ns[i] * ns[i+1] > m) continue;
                long ll = i+1, rr = ns.length.to!long;
                while (ll+1 < rr) {
                    auto mm = (ll+rr)/2;
                    if (ns[i] * ns[mm] <= m) {
                        ll = mm;
                    } else {
                        rr = mm;
                    }
                }
                k += ll - i;
            }
            foreach (i; 0..ps.length.to!long-1) {
                if (ps[i] * ps[i+1] > m) continue;
                long ll = i+1, rr = ps.length.to!long;
                while (ll+1 < rr) {
                    auto mm = (ll+rr)/2;
                    if (ps[i] * ps[mm] <= m) {
                        ll = mm;
                    } else {
                        rr = mm;
                    }
                }
                k += ll - i;
            }
            if (k < K) {
                l = m;
            } else {
                r = m;
            }
        }
        writeln(r);
    }
}

Measured memory_bytes: 14028
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x;
		int i = 1;

		for(;;) {

			x = sc.nextInt();
			if(x == 0)break;


			System.out.println( "Case " +i+ ": " + x);
			i++;



		}

	}

}



Measured memory_bytes: 41680
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, du[N], f[N];
int tot, fi[N], a[N << 1], ne[N << 1];
inline void Add(int x, int y) {
    a[++tot] = y; ne[tot] = fi[x]; fi[x] = tot;
}
inline void Dp(int x, int fa) {
    int cnt = 0;
    for (int i = fi[x]; i; i = ne[i]) if (a[i] != fa) {
        Dp(a[i], x);
        ++cnt;
    }
    if (cnt == 0) {
        f[x] = 0;
    } else if (cnt == 1) {
        for (int i = fi[x]; i; i = ne[i]) if (a[i] != fa) f[x] = f[a[i]];
    } else {
        bool have_lian_son = 0;
        for (int i = fi[x]; i; i = ne[i]) if (a[i] != fa) {
            f[x] += max(f[a[i]], 1);
            if (!f[a[i]]) have_lian_son = 1;
        }
        f[x] -= have_lian_son;
    }
}
int main() {
    scanf("%d", &n);
    for (int i = 1, x, y; i < n; ++i) {
        scanf("%d%d", &x, &y);
        ++x; ++y;
        Add(x, y); Add(y, x);
        ++du[x]; ++du[y];
    }
    if (n == 1) return puts("0"), 0;
    int rt = 0;
    for (int i = 1; i <= n; ++i) if (du[i] > 2) rt = i;
    if (!rt) return puts("1"), 0;
    Dp(rt, 0);
    printf("%d\n", f[rt]);
    return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
#define INF 1e9+7


int main(){

    string s,tmp;
    cin >> s;
    string akb = "AKIHABARA";
    bool ans = false;
    REP(i,s.length()){
        if(s[i] != 'A'){
            tmp.push_back(s[i]);
        }
    }

    if(tmp != "KIHBR"){
        /*Aを除いた時にKIHBRになっていないものはAKIHABARAにできない*/
        cout << "NO" << endl;
        return 0; 
    }

    /*AKIHABARAが含まれているがその他に余分なものがついている場合*/
    REP(i,akb.size()){
        if(s[i] != akb[i]){
            s.insert(s.begin()+i,'A');
        }
    }
    if(s == akb){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

   
    return 0;
}

Measured memory_bytes: 256
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Split(bufio.ScanWords)
	var N int
	N = nextInt()
	sum := 0
	for i := 1; i <= N; i++ {
		if i%3 == 0 || i%5 == 0 {
			continue
		} else {
			sum += i
		}
	}
	fmt.Println(sum)
}

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

func nextStr() string {
	stdin.Scan()
	i := stdin.Text()
	// if err != nil {
	// 	panic(err)
	// }
	return i
}


Measured memory_bytes: 1760
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define sz(a) (int)(a.size())
#define all(a) begin(a), end(a)
#define deb(a) cout << #a << ": " << a << ENDL
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;

int main()
{   _
    int n; cin >> n;
    cout << (n + 1) % 2 << ENDL;
    return 0;
}


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

int n,m,id[100005],ans=0;
struct Node{
	int l,r;
}node[100005];

int main(void){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d %d",&node[i].l,&node[i].r);
		id[node[i].l]++;
		id[node[i].r+1]--;
	}
	int s=0;
	for(int i=1;i<=n+1;i++){
		s+=id[i];
		if(s==m)ans++;
	}
	printf("%d",ans);
}

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

int main(){
    long long n, m, sum=0, cnt=0, ans;
    cin >> n >> m;
    vector<long long> a(m);
 
    for(int i = 0; i < m; i++) {
        cin >> a[i];
        sum += a[i];
        cnt++;
    }
    if(n >= sum) {
        ans = n-sum;
        cout << ans << endl;
    }else{
        cout << "-1" << endl;
    }
 
    return 0;
}
 
long long facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}

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

int main() {
  string s_1, s_2;
  cin >> s_1 >> s_2;
  int l_1 = (int)s_1.size(), l_2 = (int)s_2.size();
  int dp[l_1 + 1][l_2 + 1];
  memset(dp, 0, sizeof(dp));
  rep(i, l_1+1) {
    dp[i][0] = i;
//    cout << dp[i][0];
  }
  rep(i, l_2+1) {
    dp[0][i] = i;
  }
  
  rep(i, l_1) {
    rep(j, l_2) {
      if (s_1[i] == s_2[j]) {
        dp[i+1][j+1] = min(dp[i][j], min(dp[i+1][j], dp[i][j+1]) + 1);
//        cout << dp[i+1][j+1];
      }
      else {
        dp[i+1][j+1] = min(dp[i][j], min(dp[i+1][j], dp[i][j+1])) + 1;
//        cout << dp[i+1][j+1];
      }
    }
  }
  
  cout << dp[l_1][l_2] << endl;
}


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

int main()
{
  int N, D; cin >> N >> D;

  vector<vector<int>> X(N, vector<int>(D));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < D; j++)
    {
      cin >> X[i][j];
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      int dis = 0;
      for (int k = 0; k < D; k++)
      {
        dis += abs(X[i][k] - X[j][k]) * abs(X[i][k] - X[j][k]);
      }
      if ((int)sqrt(dis) * (int)sqrt(dis) == dis) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
int dp[100005];
bool visited[100005];
vector<int> adj[100005];
 
void visit(int vertex){
	visited[vertex] = 1;
	dp[vertex] = 0;
	for(int child:adj[vertex]){
		if(!visited[child]){
			visit(child);
		}
		dp[vertex] = max(dp[vertex] , 1 + dp[child]);
	}
}
 
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		adj[x].push_back(y);
	}
	
	for(int i = 1; i <= n; i++){
		if(!visited[i]){
			visit(i);
		}
	}
	
	int ans = 0;
	for(int i = 1; i<=n ; i++){
		ans = max(ans, dp[i]);
	}
	
	cout<<ans;
	
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  vector<int> memory(N,0);
  
  for (int i=0;i<N;i++) {
    cin >> a.at(i);
  }
  
  int count = 0;
  int now = 0;
  while (true) {
    memory.at(now) += 1;
    now = a.at(now)-1;
    count++;
    
    if (memory.at(now) == 2) {
      cout << -1 << endl;
      break;
    }
    else if (now ==1) {
      cout << count << endl;
      break;
    }
  }
    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m,x;
  cin >> n >> m >> x;
  int tmp;
  int left = 0;
  REP(i,m){
      cin >> tmp;
      if (x > tmp)left++;
  }
  cout << min(left, m-left) << endl;
}


Measured memory_bytes: 256
import bisect
import itertools
N = int(input())
A = [int(_) for _ in input().split()]
cum = list(itertools.accumulate(A))
ans = 10**10
for i2 in range(1, N - 2):
    i1 = i = bisect.bisect_left(cum, cum[i2] // 2)
    c = abs(cum[i2] - 2 * cum[i1])
    for j in range(i - 1, i + 2):
        if 0 <= j < i2 and abs(cum[i2] - 2 * cum[j]) < c:
            i1 = j
            c = abs(cum[i2] - 2 * cum[j])
    i3 = i = bisect.bisect_left(cum, (cum[i2] + cum[N - 1]) // 2)
    c = abs(cum[N - 1] + cum[i2] - 2 * cum[i3])
    for j in range(i - 1, i + 2):
        if i2 < j < N - 1 and abs(cum[N - 1] + cum[i2] - 2 * cum[j]) < c:
            i3 = j
            c = abs(cum[N - 1] + cum[i2] - 2 * cum[j])
    B = [cum[i1], cum[i2] - cum[i1], cum[i3] - cum[i2], cum[N - 1] - cum[i3]]
    ans = min(ans, max(B) - min(B))
print(ans)


Measured memory_bytes: 33092
use proconio::input;
use proconio::marker::Usize1;
use std::collections::HashMap;
 
fn main() {
  input! {
    n: usize,
    k: usize,
    ps: [Usize1;n],
    cs: [isize;n]
  }
  
  let mut result = isize::min_value();
  for i in 0..n {
    let mut routes = vec![];
    let mut current_index = i;
    let mut total = 0;
    loop {
      routes.push(current_index);
      current_index = ps[current_index];
      total += cs[current_index];      
      if i == current_index {
         break
      }
    }
    
    let route_len = routes.len();
    let mut small_sum = 0;
    for ii in 0..route_len {
      small_sum += cs[routes[ii]];
      if ii + 1 > k { break }
      let s_result = if total > 0 {
        let times = (k - ii - 1) as isize / route_len as isize;
        small_sum + (total * times)
      } else {
        small_sum
      };
      result = std::cmp::max(result, s_result);
    }
  }
  println!("{}", result);
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	ll x;
	cin>>x;

	ll ans=x/11*2;
	if(x%11>6)ans+=2;
	else if(x%11>0)ans+=1;

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    int R, C, K;
    cin >> R >> C >> K;
    
    vector<vector<int>> items(R+2,vector<int>(C+2,0));
    rep(i,0,K) {
        int r, c;
        int v;
        cin >> r >> c >> v;
        items[r][c] = v;
    }

    vector<vector<vector<ll>>> dp(R+2, vector<vector<ll>>(C+2, vector<ll>(4,0)));
    dp[1][1][1] = items[1][1];
    rep(r,1,R+1) {
        rep(c,1,C+1) {
            rep(k,0,4) {
                dp[r][c+1][k] = max(dp[r][c+1][k], dp[r][c][k]);
                if (k < 3) {
                    dp[r][c+1][k+1] = max(dp[r][c+1][k+1], dp[r][c][k]+items[r][c+1]);
                }
                dp[r+1][c][0] = max(dp[r+1][c][0],dp[r][c][k]);
                dp[r+1][c][1] = max(dp[r+1][c][1], dp[r][c][k] + items[r+1][c]);
            }
        }
    }

    cout << *max_element(all(dp[R][C])) << endl;
}

Measured memory_bytes: 672260
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#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 1000000000
#define mod 1000000007

int gcd(int a,int b){//最大公約数
	if(b==0)return a;
	return gcd(b,a%b);
}

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

	long long int N,X;
	cin>>N>>X;
	vector<long long int>x(N);
	REP(i,N){
		int a;
		cin>>a;
		x[i]=abs(X-a);
	}
	long long int ans=0;
	REP(i,N)
		ans=gcd(ans,x[i]);
		
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <deque>
using namespace std;

#define LET(name, value) __typeof(value) name = value
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define FOREQ(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOREACH(i, c) for (LET(i, (c).begin()); i != (c).end(); ++i)

int main() {
  int n, r;
  while (scanf("%d%d", &n, &r) != EOF) {
    deque<int> deck0, deckA, deckB;
    REP(i, n) { deck0.push_back(i); }
    REP(i, r) {
      int c; scanf("%d", &c);
      deckA.assign(deck0.begin() + n/2, deck0.end());
      deckB.assign(deck0.begin(), deck0.begin() + n/2);
      deck0.clear();
      while ((int)deck0.size() < n) {
        if (!deckA.empty()) {
          int m = min(c, (int)deckA.size());
          deck0.insert(deck0.end(), deckA.begin(), deckA.begin() + m);
          deckA.erase(deckA.begin(), deckA.begin() + m);
        }
        if (!deckB.empty()) {
          int m = min(c, (int)deckB.size());
          deck0.insert(deck0.end(), deckB.begin(), deckB.begin() + m);
          deckB.erase(deckB.begin(), deckB.begin() + m);
        }
      }
    }
    printf("%d\n", deck0.back());
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define EPS (1e-5)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, M, ans = 0, s = 0;
	vector<int> A;
	map<int,int> d;
	
	cin>>N>>M;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		s += A[i];
		
		d[s%M]++;
	}
	s = 0;
	for(int i = 0; i < N; i++){
		int t = s%M;
		ans += d[t];
		// cout<<A[i]<<" "<<d[t]<<" "<<t<<endl;
		s += A[i];
		d[s%M]--;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 4992
from fractions import gcd
def lcm(x, y):
  return (x * y) // gcd(x, y)
n,m=map(int,input().split())
x=lcm(n,m)
y=x//gcd(n,m)
a=input()
b=input()

for i in range(x//y):
  if a[(x//m)*i] != b[(x//n)*i]:
    print(-1)
    exit()
print(x)
    

Measured memory_bytes: 6372
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

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

  int ans = 1;
  for(int i = 0; i < n; i++) {
    if(ans*2 >= (ans+k))
      ans += k;
    else ans *= 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <stdio.h>
int main( void ){
	int x[31], w, n, t, a, b;
	scanf("%d%d",&w,&n);
	for( t = 1; t <= w; t++ )	x[t] = t;
	for(; n--; ){
		scanf("%d,%d", &a, &b );
		t = x[a];
		x[a] = x[b];
		x[b] = t;
	}		
	for( t = 1; t <= w; t++ )	printf("%d\n", x[t] );

	return 0;
}

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

int main() { 
  int a1, a2, a3;
  cin >> a1 >> a2 >>a3;
  if(a1 + a2 + a3 >= 22)
    cout << "bust" << endl;
  else cout << "win" << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [[0,0]] * n
time = 0

for i in range(n):
    x,y = map(int,input().split(" "))
    a[i] = [y,x]

a.sort()
for i,j in a:
    time += j
    if i < time:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 35600
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end() 
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
      void solve(){    
                ll n,p;
                cin>>n;
                for(int i=1;i*i<=n;i++){
                        if(n%i==0)
                        if(i<=9&&(n/i)<=9){
                                cout<<"Yes";
                                return ;
                        }
                }
                cout<<"No";
        }
        int main(){ 
                hs;
                ll t;
                t=1;
                // cin>>t;
                for (int i=1; i<=t; i++){
                        solve();
                 }
        return 0; 
}         
 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iterator>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <sstream> 
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <functional>
#pragma GCC optimize("O3")
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sp system("pause");
#define MOD 998244353 
#define mxN 2005




int main()
{
	fast;
	ll n, k, c;
	string s;
	cin >> n >> k >> c >> s;
	vector<ll> dpl(n + 1), dpr(n + 1);
	
	ll last = -9223372036854775808;
	for (int i = 1; i <= n; ++i) {
		if (s[i - 1] == 'x') dpl[i] = dpl[i - 1];
		else if (last + c < i) {
			last = i;
			dpl[i] = dpl[i - 1] + 1;
		}
		else dpl[i] = dpl[i - 1];
	}
	last = -9223372036854775808;
	for (int i = 1; i <= n; ++i) {
		if (s[n - i] == 'x') dpr[i] = dpr[i - 1];
		else if (last + c < i) {
			last = i;
			dpr[i] = dpr[i - 1] + 1;
		}
		else dpr[i] = dpr[i - 1];
	}

	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'o' && dpl[i] + dpr[n - i-1] + 1 == k)
			cout << i + 1 <<endl;
	}

	

	return 0;
}

Measured memory_bytes: 5012
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

// struct unionfind {
//     int par[1000000];
//     int rank[1000000];

//     void init(int n) {
//         for (int i = 0; i < n; i++) {
//             par[i] = i;
//             rank[i] = 0;
//         }
//     }

//     int find(int x) {
//         if (par[x] == x) {
//             return x;
//         } else {
//             return par[x] = find(par[x]);
//         }
//     }
    
//     void unite(int x, int y) {
//         x = find(x);
//         y = find(y);
//         if (x == y) {
//             return;
//         }
//         if (rank[x] < rank[y]) {
//             par[x] = y;
//         } else {
//             par[y] = x;
//             if (rank[x] == rank[y]) {
//                 rank[x]++;
//             }
//         }
//     }

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

//     int rankfind(int x) {
//         return rank[find(x)];
//     }
// };

struct unionFind {
    vector<int> data;
    unionFind(int size) : data(size, -1) {}
    
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if(data[y] < data[x]) {
                swap(x, y);
            }
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }

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

    int root(int x) {
        return (data[x] < 0) ? x : data[x] = root(data[x]);
    }

    int rank(int x) {
        return -data[root(x)];
    }
};

int main() {
    ll N, M;
    cin >> N >> M;
    vector<int> lng[M];
    for (int i = 0; i < N; i++) {
        int K;
        cin >> K;
        for (int j = 0; j < K; j++) {
            int L;
            cin >> L;
            lng[L - 1].push_back(i);
        }
    }
    unionFind u(N);
    for (int i = 0; i < M; i++) {
        int len = lng[i].size();
        for (int j = 0; j < len - 1; j++) {
            u.unite(lng[i][j], lng[i][j + 1]);
        }
    }
    bool ok = true;
    for (int i = 0; i < N - 1; i++) {
        if (!u.same(i, i + 1)) {
            ok = false;
        }
    }
    if (ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

typedef pair<int,int> P;
const int INF = 1e+9;

struct  edge{
	int to;
	int cost;
};

int dist[100005];
vector<edge> G[100005];

void dijkstra(int s){
	priority_queue<P,vector<P>,greater<P>> que;
	dist[s] = 0;
	que.push(make_pair(0,s));
	
	while (!que.empty()){
		auto p = que.top();
		que.pop();
		int v = p.second;
		for (auto nextv: G[v]){
			if(dist[nextv.to] > dist[v] + nextv.cost){
				dist[nextv.to] = dist[v] + nextv.cost;
				que.push(make_pair(dist[nextv.to], nextv.to));
			}
		}
	}
}

int main(){
	int V,E,r;
	cin >> V >> E >> r;
	
	
	rep(i,E){
		int s,t,d;
		cin >> s >> t >> d;
		edge e = {t,d};
		G[s].push_back(e);
	}
	
	rep(i,V){
		dist[i] = INF;
	}
	
	dijkstra(r);
	
	rep(i,V){
		if(dist[i] == INF){
			cout << "INF" << endl;
		}else{
			cout << dist[i] << endl;
		}
	}
	
    return 0;
}




Measured memory_bytes: 13064
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

def point(str):
  if str == "r":
    return p
  if str == "s":
    return r
  if str == "p":
    return s

total_point = 0
memory = [""] * k
for i in range(n):
  if t[i] != memory[i % k]:
    memory[i % k] = t[i]
    total_point += point(t[i])
  else:
    memory[i % k] = ""
print(total_point)

Measured memory_bytes: 43504
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct edge {
    int to, cost;
    edge() {}
    edge(int to, int cost) : to{to}, cost{cost} {}
};

struct State {
    int v, c;
    State() {}
    State(int v, int c) : v{v}, c{c} {}

    bool operator < (const State& st) const {
        return c > st.c;
    };
};

int main()
{
    int N, R;
    cin >> N >> R;
    
    constexpr int INF = (1 << 29);
    vector<vector<edge>> G(N);
    vector<vector<int>> c(N, vector<int>(N, INF));
    for (int i = 0; i < R; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        s--; t--;
        c[s][t] = c[t][s] = d;
        G[s].emplace_back(t, d);
        G[t].emplace_back(s, d);
    }

    vector<vector<int>> d(N, vector<int>(N, INF));
    for (int i = 0; i < N; i++) {
        d[i][i] = 0;
        priority_queue<State> pq;
        pq.push(State(i, 0));

        while (!pq.empty()) {
            State st = pq.top(); pq.pop();
            int v = st.v, c = st.c;
            if (c > d[i][v]) continue;
            for (auto& e : G[v]) {
                if (d[i][v] + e.cost < d[i][e.to]) {
                    d[i][e.to] = d[i][v] + e.cost;
                    pq.push(State(e.to, d[i][e.to]));
                }
            }
        }
    }
    
    int mx = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            mx = max(mx, d[i][j]);            
        }
    }
    
    vector<int> a, b;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (mx == d[i][j]) {
                a.emplace_back(i);
                b.emplace_back(j);
            }
        }
    }
    
    vector<int> town;
    for (int i = 0; i < N; i++) {
        bool quiet = 1;
        for (int j = 0; j < (int)a.size(); j++) {
            if (d[a[j]][i] + d[i][b[j]] == mx) {
                quiet = 0;
                break;
            }
        }
        if (quiet) {
            town.emplace_back(i + 1);
        }
    }
    
    int n = town.size();
    cout << n << endl;
    for (int i = 0; i < n; i++) {
        cout << town[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 33264
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, l, s = 0, m = 0;
  cin >> n >> x;
  for (int i = 0; i < n + 1; i++) {
    cin >> l;
    s += l;
    m++;
    if (s > x) {
      break;
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if (W >= x && H >= y && W - x >= r && x >= r && H - y >= r && y >= r){
    printf("Yes\n");
    } else {
    printf("No\n");
    } return 0;
}


Measured memory_bytes: 2104
#include<stdio.h>
int main(void){
  int S,s1,s2,s3,s4;
  scanf("%d",&S);
  s1=S/1000;
  s2=(S-s1*1000)/100;
  s3=(S-s1*1000-s2*100)/10;
  s4=(S-s1*1000-s2*100-s3*10);
  if(s1==s2 || s2==s3 || s3==s4){
    printf("Bad");
  }
  else{
    printf("Good");
  }
  return 0;
}

Measured memory_bytes: 128