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

const size_t maxN = 100005;

int N;
std::vector<int> G[maxN];
int Fa[maxN], Dep[maxN], Size[maxN];

void DFS(int i)
{
	Size[i] = 1;
	for (auto to : G[i])
		if (to != Fa[i])
		{
			Fa[to] = i;
			Dep[to] = Dep[i] + 1;
			DFS(to);
			Size[i] += Size[to];
		}
}

int main()
{
	scanf("%d", &N);
	for (int u, v, i = 1; i != N; ++i)
	{
		scanf("%d%d", &u, &v);
		G[u].push_back(v), G[v].push_back(u);
	}

	Dep[1] = 1, DFS(1);

	int cnt = Dep[N] / 2;
	int o = N;
	while (--cnt)
		o = Fa[o];

	puts(N - Size[o] > Size[o] ? "Fennec" : "Snuke");

	return 0;
}

Measured memory_bytes: 11520
n, w_max = gets.split.map(&:to_i)
items = Array.new(n){gets.split.map(&:to_i)}
dp = Hash.new(Float::INFINITY)
dp[0] = 0
items.each do |w, v|
  dp.dup.each do |pv, pw|
    nw = pw + w
    nv = pv + v
    dp[nv] = nw if nw <= w_max && dp[nv] > nw
  end
end
puts dp.keys.max


Measured memory_bytes: 79308
import Data.Bool

main = do
 [n,a,b,c,d] <- map read . words <$> getLine
 putStrLn $ bool "NO" "YES" $ moderate n a b c d

moderate n a b c d = any (within b) [(a + i*d + j*c, a + i*c + j*d) | i<-[-(n-1)..0], let j = (n-1) - abs i]

within x (a,b) = a <= x && x <= b

Measured memory_bytes: 1020
#ifndef LOCAL
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

string s;

int cc[100];

int main() {
	cin >> s;
	for (int i = 0; i < s.size(); ++i)
		++cc[s[i] - 'a'];
	for (int i = 0; i < 3; ++i)
		for (int j = 0; j < 3; ++j) {
			if (abs(cc[i] - cc[j]) >= 2) {
				cout << "NO\n";
				return 0;
			}
		}
	cout << "YES\n";
	return 0;
}




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

int main()
{
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }

    sort(s.begin(), s.end());

    for(int i = 0; i < n; i++){
        cout << s[i];
    }

    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
class MagicNumberThree
{

    public:
int countSubsequences(string s)
{

}

};

int dp[2][45005]={};
int tmp[2][45005]={};
int main()
{
    string a;
    while(cin>>a){
            int x,y;
    cin>>x>>y;
            int now=0;
dp[1][8000]=1;
        int i;
        for(i;a[i]=='F';i++);

        dp[0][8000+i]=1;
        int cnt=0;
        for(i;i<=a.sz;i++){
            if(a[i]=='F'){
                cnt++;
            }
            else{
                for(int j=cnt;j<20000;j++){
                    tmp[now][j-cnt]=max(tmp[now][j-cnt],dp[now][j]);
                     tmp[now][j+cnt]=max(tmp[now][j+cnt],dp[now][j]);
                }
                for(int j=0;j<20000;j++){
                    dp[now][j]=tmp[now][j];
                }
                ms(tmp,0);
                cnt=0;
                now^=1;
            }

        }
        if(dp[0][x+8000]&&dp[1][y+8000]){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }

    }


    return 0;
}


Measured memory_bytes: 896
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        int nmin = Integer.MAX_VALUE;

        int answer=0;

        //List<Integer> list1 = new ArrayList<>();
        //List<String> list2 = new ArrayList<>();
        //int array[] = new int[];
        Euclid e1=new Euclid();
        //入力
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[]=new int[N];
        for(int i=0;i<N;i++)
        {
            A[i]=sc.nextInt();
        }
        //処理
        int L[]=new int[N+1];
        for(int i=0;i<N+1;i++)
        {
            if(i==0)
            {
                L[i]=0;
            }else
            {
                L[i]=e1.gcd(L[i-1],A[i-1]);
            }
        }
        //System.out.println(Arrays.toString(L));

        int R[]=new int[N+1];
        int cc=N;
        for(int i=0;i<N+1;i++)
        {
            if(i==0)
            {
                R[N]=0;
            }else
            {
                //System.out.println(A[N-i]);
                R[N-i]=e1.gcd(R[cc],A[N-i]);
                cc--;
            }
        }
        //System.out.println(Arrays.toString(R));

        int a1;
        for(int i=0;i<N;i++)
        {
            a1=e1.gcd(L[i],R[i+1]);
            //System.out.println(i);
            if(max<a1)
            {
                max=a1;
            }
        }
        /*
        a1=e1.gcd(L[0],R[1]);
        a1=e1.gcd(L[1],R[2]);
        a1=e1.gcd(L[2],R[3]);
        a1=e1.gcd(L[3],R[4]);
         */
        answer=max;
        //Collections.sort(a);
        //System.out.println(Arrays.toString(list1.toArray()));
        //System.out.println(Arrays.toString(array1));
		//System.out.println(Arrays.deepToString(a));
        System.out.println(answer);
    }
}

class Euclid
{
    public static int gcd(int x,int y)//ユークリッドの互除法を使って2値の最大公約数を求める
    {
        int tmp;
        if(x<y)
        {
            tmp=x;
            x=y;
            y=tmp;
        }
        if(x==0)//(x or y)=0の時は0でない時の値を返す
        {
            return y;
        }else if(y==0)
        {
            return x;
        }else
        {
            while ((tmp = x % y) != 0)
            {
                x = y;
                y = tmp;
            }
            return y;
        }
    }
}

Measured memory_bytes: 48676
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <algorithm>
#include <functional>
#include <limits.h>
#include <bitset>

#include <tuple>
#include <unordered_map>

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

const int INF = 1 << 29;
const double EPS = 1e-9;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int MAX_HW = 1500;
int dp[MAX_HW][MAX_HW];
int board[MAX_HW][MAX_HW];
int H, W;
int main() {
  cin >> H >> W;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> board[i][j];
    }
  }
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      dp[i][j] = (board[i][j] + 1) % 2;
    }
  }
  int res = 0;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (board[i][j] == 0) {
        dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
      }
      res = max(res, dp[i][j]);
    }
  }
  cout << res *res << endl;
  return 0;
}

Measured memory_bytes: 18156
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
#define cl(x,y) memset(x,y,sizeof(x))
#define ct cerr<<"Time elapsed:"<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define lson x<<1,l,mid
#define rson x<<1|1,mid+1,r
const int N=1e6+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
using namespace std;
string s,fr,ba;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int q,f=1,i;
	cin>>s>>q;
	while(q--)
	{
		int x;
		cin>>x;
		if(x==1)
			f^=1;
		else
		{
			int p;
			char c;
			cin>>p>>c;
			p--;
			if(p^f)
				fr+=c;
			else
				ba+=c;
		}
	}
	if(f)
	{
		reverse(fr.begin(),fr.end());
		cout<<fr<<s<<ba<<endl;
	}	
	else
	{
		reverse(ba.begin(),ba.end());
		reverse(s.begin(),s.end());
		cout<<ba<<s<<fr<<endl;
	}		
	return 0;
}


Measured memory_bytes: 1040
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;


int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	ll sum = 0;
	rep(i, n)	{
		ll t;
		cin >> t;
		t = t - (i + 1);
		a[i] = t;
	}
	vector<ll> b = a;
	sort(b.begin(), b.end());
	ll med;
	if(n % 2){
		med = b[n / 2];
	} else {
		med = (b[n / 2] + b[n / 2 - 1]) / 2;
	}
	ll ans = 0;
	rep(i, n){
		ans += abs(a[i] - med);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
n = int(input())
import collections

a = list(input())
ans = collections.Counter(a)
for i in range(n-1):
    l = collections.Counter(list(input()))
    for i in ans.keys():
        if i in l:
            ans[i] = min(ans[i],l[i])
        else:
            ans[i] = 0
l = []
for i in ans.keys():
    for j in range(ans[i]):
        l.append(i)
if len(l) == 0:
    print("")
else:
    l.sort()
    print(*l,sep="")

Measured memory_bytes: 3316
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(int argc, char const* argv[])
{
	int n;
	int a[100000];

	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}

		for (int i = 0; i < n; i++){
			scanf("%d", a + i);
		}

		sort(a, a + n);
		reverse(a, a + n);
		
		long long ans = 0;
		for (int i = 0; i < n; i++){
			ans += a[i] * i;
		}

		printf("%lld\n", ans);
	}

	return 0;
}

Measured memory_bytes: 1088
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int w = scanner.nextInt()-1;
		int h = scanner.nextInt()-1;
		int n = scanner.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		int[] a = new int[n];
		String[][] s = new String[w + 1][h + 1];

		for (int i = 0; i < n; i++) {
			x[i] = scanner.nextInt();
			y[i] = scanner.nextInt();
			a[i] = scanner.nextInt();

		}

		for (int k = 0; k < n; k++) {
			if (a[k] == 1) {
				for (int i = 0; i <= h; i++) {
					for (int j = 0; j < x[k]; j++) {
						s[j][i] = "B";
					}
				}
			} else if (a[k] == 2) {
				for (int i = 0; i <= h; i++) {
					for (int j = x[k]; j <= w; j++) {
						s[j][i] = "B";
					}
				}
			} else if (a[k] == 3) {
				for (int i = 0; i < y[k]; i++) {
					for (int j = 0; j <= w; j++) {
						s[j][i] = "B";
					}
				}
			} else if (a[k] == 4) {
				for (int i = y[k]; i <= h; i++) {
					for (int j = 0; j <= w; j++) {
						s[j][i] = "B";
						
					}
				}
			}
		}

		int ans = 0;
		for (int i = 0; i <= h; i++) {
			for (int j = 0; j <= w; j++) {
				if (s[j][i] == null) {
					ans++;
				}
			}
		}

		System.out.println(ans);

	}
}


Measured memory_bytes: 23380
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll(x);cin >> (x);
#define stin(x) str(x);cin >> (x);
#define vllin(x,n) vll(x)(n);FOR(i,0,n-1){cin >> (x)[i];}
#define vllin2(a,b,n) vll(a)(n);vll(b)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vllin3(a,b,c,n) vll(a)(n);vll(b)(n);vll(c)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >> (x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vpl4in(x,n) vpl4(x)((n),mp(0,0));FOR(i,0,n-1){cin >> x[i].fi >> x[i].se;}
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define rFOR(i,b,a) for(ll i=a;i>=b;i--)
#define SORT(x) sort(x.be,x.en)
#define rSORT(x) sort(x.rbegin(),x.rend())
#define say(x) cout << (x);
#define sal(x) cout << (x) << endl;
#define says(x) cout << (x) << (' ');
#define sas cout << (' ');
#define sayR(x) cout << fixed << setprecision(10) << (x);
#define salR(x) cout << fixed << setprecision(10) << (x) << endl;
#define yn(a) cout << ((a) ? "yes" : "no") << endl;
#define Yn(a) cout << ((a) ? "Yes" : "No") << endl;
#define YN(a) cout << ((a) ? "YES" : "NO") << endl;
#define Imp(a) cout << ((a) ? "Possible" : "Impossible") << endl;
#define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll MOD = 998244353;

signed main()
{
    llin(n);
    vllin(a,n);
    ll s=0;
    FOR(i,0,n-1){
        s+=a[i];
    }
    vll c(s/2+1,0);
    vll cc(s/2+1,0);
    cc[0]=1;
    c[0]=1;
    FOR(i,0,n-1){
        rFOR(j,a[i],s/2){
            c[j]=(c[j]+c[j-a[i]]*2)%MOD;
            cc[j]=(cc[j]+cc[j-a[i]])%MOD;
        }
    }
    ll t=0;
    ll r=1;
    FOR(i,1,n){
        r=(3*r)%MOD;
    }
    FOR(i,0,s/2){
        t=(c[i]+t)%MOD;
    }
    if(s%2==0) t-=cc[s/2];
    sal((r-((t*3)%MOD)<0)?(r+MOD-((t*3)%MOD))%MOD:(r-(t*3)%MOD)%MOD)
}


Measured memory_bytes: 896
# from datetime import datetime

# measure_start = datetime.now()
move = [[[10, 10], [4, 4]], [[8, 2],[4, 2]]]

MAX_N = 10000000+1
sos = [1] * (MAX_N+1)
sos[0] = sos[1] = 0
for i in range(2, int(MAX_N**0.5)+1):
    if sos[i]:
        for j in range(i+i, MAX_N+1, i):
            sos[j] = 0

while 1:
    try:
        n = int(input())

        if not n: break
        n -= (n%2 == 0)
        while n >= 13:
            if sos[n] and sos[n-2] and sos[n-6] and sos[n-8]:
                print(n)
                break
            else:
                n -= move[sos[n-8]][sos[n-6]][sos[n-2]]
    # measure_stop = datetime.now()
    # print(measure_stop - measure_start)
    except:
        pass

Measured memory_bytes: 84732
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			int k = cin.Int();
			var ab = new Tuple<int, int>[n];
			for (int i = 0; i < n; i++) {
				int a = cin.Int();
				int b = cin.Int();
				ab[i] = new Tuple<int, int>(a, b);
			}

			int kr = ~k;
			long ans = 0;
			for (int i = 0; i < n; i++) {
				if ((ab[i].Item1 & kr) == 0) {
					ans += ab[i].Item2;
				}
			}

			var bits = new List<int>();
			int msb = 0;
			int temp = k;
			while (temp > 0) {
				++msb;
				if (temp % 2 == 1) {
					bits.Add(msb);
				}
				
				temp >>= 1;
			}

			foreach (int bit in bits) {
				int target = 0;
				for (int i = 1; i <= msb; i++) {
					if (i < bit) {
						target |= 1 << (i - 1);
					} else if (i == bit) {
					} else {
						int t = 1 << (i - 1);
						if ((k & t) != 0) {
							target |= t;
						}
					}
				}

				int tr = ~target;
				long sum = 0;
				for (int i = 0; i < n; i++) {
					if ((ab[i].Item1 & tr) == 0) {
						sum += ab[i].Item2;
					}
				}

				ans = Math.Max(ans, sum);
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 22084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 6005;
#define pb push_back
#define pii pair<int,int>

int t;
int n,m;
pii A[MN];
int f[MN][MN],g[MN][MN];
int dp[MN];
int main()
{
	memset(f,0,sizeof f);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%d%d",&A[i].first,&A[i].second);
	sort(A+1,A+1+n);
//	for(int i=1;i<=n;++i) printf("(%d,%d,%d)\n",i,A[i].first,A[i].second);
	for(int i=1;i<=n;++i)
	{
		int c = A[i].first, w = A[i].second;
		for(int j=0;j<m;++j) f[i][j] = f[i-1][j];
		for(int j=m-1;j>=c;--j)
		{
//			dp[j] = max(dp[j],dp[j-c]+w);
			f[i][j] = max(f[i-1][j],f[i-1][j-c]+w);
		}
	}
	for(int i=n;i>=1;--i)
	{
		int c = A[i].first, w = A[i].second;
		for(int j=0;j<m;++j) g[i][j] = g[i+1][j];
		for(int j=m-1;j>=c;--j)
		{
//			dp[j] = max(dp[j],dp[j-c]+w);
			g[i][j] = max(g[i-1][j],g[i-1][j-c]+w);
		}
	}
	int ans = 0;
	for(int i=1;i<=n;++i)
	{
		int w = A[i].second;
		for(int j=0;j<m;++j)
		{
			
			ans = max(ans,f[i-1][j]+w+g[i+1][m-j-1]);
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 213760
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int a, b;

    cin >> a >> b;

    if (a >= 6 && a <= 12) {
        b /= 2;
    } else if (a <= 5) {
        b = 0;
    }

    cout << b << endl;

    return 0;
}



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

using namespace std;

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

  int X, Y; cin>>X>>Y;
  int sum = X == 1 and X == Y ? 4 : 0;
  sum += 4 - min(X, 4) + 4 - min(Y, 4);
  sum *= 100000;
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#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()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int a[N];
  REP(i,N)cin>>a[i];
  int i=a[0];
  int ans=1;
  while(ans<=N){
    if(i==2){
      cout<<ans<<endl;
      return 0;
    }
    i=a[i-1];
    ans++;
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 1148
import java.util.Random;
import java.util.Scanner;

public class Main {
	private static final int K = 26;
	private static final int TIME = 300;
	private static Random rand = new Random(System.currentTimeMillis());

	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var d = sc.nextInt();
		var c = new int[K];
		var s = new int[d][K];
		for (var i = 0; i < K; i++) {
			c[i] = sc.nextInt();
		}
		for (var i = 0; i < d; i++) {
			for (var j = 0; j < K; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		sc.close();

		var t = search(c, s, d);
		for (var i = 0; i < d; i++) {
			System.out.println(t[i]);
		}
	}

	private static int[] search(int[] c, int[][] s, int d) {
		var time = System.currentTimeMillis();
		var t = create(c, s, d);
		while (System.currentTimeMillis() - time <= TIME) {
			var mdi = rand.nextInt(d);
			var mti = rand.nextInt(K);
			var check = check(c, s, t, d, mdi, mti);
			if (border(time) < check) {
				t[mdi] = mti + 1;
			}

			var mdi1 = rand.nextInt(d);
			var mdi2 = rand.nextInt(d);
			var check1 = check(c, s, t, d, mdi1, t[mdi2] - 1);
			var tbk = t[mdi1];
			t[mdi1] = t[mdi2];
			var check2 = check(c, s, t, d, mdi2, tbk - 1);
			if (border(time) < check1 + check2) {
				t[mdi2] = tbk;
			} else {
				t[mdi1] = tbk;
			}
		}

		return t;
	}

	private static int border(long time) {
		return (int) (-300.0 * (System.currentTimeMillis() - time) / TIME);
	}

	private static int check(int[] c, int[][] s, int[] t, int d, int mdi, int mti) {
		var sum = 0;
		var ti = t[mdi] - 1;
		sum += s[mdi][mti] - s[mdi][ti];

		var last1 = 0;
		var last2 = 0;
		for (var i = mdi - 1; i >= 0; i--) {
			if (t[i] == ti + 1) {
				last1 = i + 1;
				break;
			}
		}
		for (var i = mdi - 1; i >= 0; i--) {
			if (t[i] == mti + 1) {
				last2 = i + 1;
				break;
			}
		}

		var count1 = 1;
		var count2 = 1;
		for (var i = mdi + 1; i < d; i++) {
			if (t[i] == ti + 1) {
				break;
			}
			count1++;
		}
		for (var i = mdi + 1; i < d; i++) {
			if (t[i] == mti + 1) {
				break;
			}
			count2++;
		}
		sum += (mdi - last2 + 1) * c[mti] * count2 - (mdi - last1 + 1) * c[ti] * count1;

		return sum;
	}

	private static int score(int[] c, int[][] s, int[] t, int d) {
		var sum = 0;
		var last = new int[K];
		for (var i = 0; i < d; i++) {
			var ti = t[i] - 1;
			sum += s[i][ti];
			last[ti] = i + 1;
			for (var j = 0; j < K; j++) {
				sum -= ((i + 1) - last[j]) * c[j];
			}
		}

		return sum;
	}

	private static int[] create(int[] c, int[][] s, int d) {
		var t = new int[d];
		for (var i = 0; i < d; i++) {
			t[i] = rand.nextInt(K) + 1;
		}
		return t;
	}

	private static void test(int[] c, int[][] s) {
		for (var i = 0; i < c.length; i++) {
			c[i] = rand.nextInt(101);
		}
		for (var i = 0; i < s.length; i++) {
			for (var j = 0; j < s[i].length; j++) {
				s[i][j] = rand.nextInt(20001);
			}
		}
	}
}


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

int a, b, c;
void input() { cin >> a >> b >> c; }
void solve() {
  vi k(3);
  k = {a, b, c};
  sort(all(k));
  debugv(k);
  if (k[0] == 5 && k[1] == 5 && k[2] == 7) {
    cout << "YES" << endl;

  } else {
    cout << "NO" << endl;
  };
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;

		try {
			scanner = new Scanner(System.in);

			System.out.println((scanner.nextInt() - scanner.nextInt()) + 1);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numH = 0;
		int numW = 0;

		try {
			scanner = new Scanner(System.in);
			numH = scanner.nextInt();
			numW = scanner.nextInt();

			char[][] wk = new char[numH][numW];

			char[] def = new char[numW];
			for (int i = 0; i < numW; i++) {
				def[i] = '@';
			}

			int index = Integer.MAX_VALUE;
			for (int i = 0; i < numH; i++) {
				String wkS = scanner.next();
				if (wkS.indexOf('#') < 0) {
					wk[i] = def;
				} else {
					index = Math.min(i, index);
					wk[i] = wkS.toCharArray();
				}
			}
			char[] wk1 = wk[index];
			for (int i = 0; i < numW; i++) {
				if (wk1[i] == '.') {
					int count = 0;
					for (int j = 0; j < numH; j++) {
						if (wk[j][i] == '.' || wk[j][i] == '@') {
							count++;
						}
					}
					if (count == numH) {
						for (int j = 0; j < numH; j++) {
							wk[j][i] = '@';
						}
					}
				}
			}
			for (int i = 0; i < numH; i++) {
				StringBuilder builder = new StringBuilder();
				for (int j = 0; j < numW; j++) {
					if (wk[i][j] != '@') {
						builder.append(wk[i][j]);
					}
				}
				if (builder.length() != 0) {
					System.out.println(builder.toString());
				}
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 23172
n,k= list(map(int, input().split()))
r,s,p= list(map(int, input().split()))
t=list(input())
ans=0
rf=sf=pf=0
for i in range(k):
    tmp=t[i::k]
    before="a"
    for j in tmp:
        if before==j:
            if before=="r":
                rf+=1
            elif before=="s":
                sf+=1
            else:
                pf+=1
            before="a"
        else:
            before=j
from collections import Counter
d=Counter(t)
for k,v in d.items():
    if k=="r":
        ans+=(v-rf)*p
    elif k=="s":
        ans+=(v-sf)*r
    else:
        ans+=(v-pf)*s
print(ans)

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


int main() {
    long long int t;
    cin>>t;
    long long a[t],b[t];
    for(int i=0;i<t;i++){ cin>>a[i]; b[i]=a[i]; }
    sort(a,a+t);
    long long m=a[t-1],l=a[t-2];
    for(int i=0;i<t;i++){
        if(b[i]==m) cout<<l<<"\n";
        else cout<<m<<"\n";
    }
	return 0;
}

Measured memory_bytes: 4736
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int lis[31][10000][40];//[n]?????????[x]??????????????°???[];
int sz[31];
int main(){
    for(int i=1;i<=30;i++){
        lis[i][0][0]=i;sz[i]++;
        for(int j=1;j<i;j++){
            for(int k=0;k<sz[j];k++){
                if(i-j<lis[j][k][0])continue;
                else{
                    lis[i][sz[i]][0]=i-j;
                    for(int l=0;;l++){
                        if(lis[j][k][l]==0)break;
                        else{
                            lis[i][sz[i]][l+1]=lis[j][k][l];
                        }
                    }
                    sz[i]++;
                }
            }
        }
    }
    while(1){
        int n;
        cin>>n;
        if(!n)break;
        for(int i=0;i<sz[n];i++){
            for(int j=0;;j++){
                if(j==0)cout<<lis[n][i][j];
                else if(lis[n][i][j]!=0)cout<<' '<<lis[n][i][j];
                else{
                    puts("");
                    break;
                }
            }
        }
    }
    return 0;
}

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

#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)
#define rep(i,x,N) for(int i=x;i<=N;i++)
#define ar array

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;
using vll=vector<ll>;
using vd=vector<double>;
using vvi=vector<vi>;
int ctoi(char c) {return c-'0';}
int slen(string s) {return s.length();}
int vsize(vi a) {return (int)a.size();}
int in() {int x;cin>>x;return x;}
void tf(bool ok) {cout<<(ok ? "YES" : "NO")<<endl;}

//https://atcoder.jp/contests/abc179/tasks/abc179_b

void rrrrrrrrrrrrrresi() {
  int N;
  cin>>N;
  int cnt=0;
  int ok=0;
  forn(i,N) {
    int x,y;
    cin>>x>>y;
    if(x==y)
      cnt++;
    if(cnt==3)
      ok=1;
    if(x!=y) {
      cnt=0;
    }
  }
  cout<<(ok ? "Yes" : "No")<<endl;
}

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

int Q=1;
//cin>>Q;
while(Q--)
  rrrrrrrrrrrrrresi();
return 0;
}




Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int i;
  double a,b,res;
  cin >> a >> b;
  res=floor(a/0.08);
  for(i=0;i<=14;i++)
    if(floor((res+i)*0.08)==a && floor((res+i)*0.1)==b){
      cout << (int)(res+i) << endl;
      return 0;
    }
  cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<algorithm>
#include <string>
#include <vector>

using namespace std;

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

	vector<int> temp1(S.size());
	vector<int> temp2(S.size());

	int cnt1 = 0;
	int cnt2 = 0;
	for (int i = 0; i < S.size(); i++){
		temp1[i] = i % 2 == 0 ? '0' : '1';
		temp2[i] = i % 2 == 0 ? '1' : '0';
	}

	for (int i = 0; i < S.size(); i++){
		if (temp1[i] != S[i])
			cnt1++;

		if (temp2[i] != S[i])
			cnt2++;
	}

	cout << min(cnt1, cnt2) << endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
const int M=105;
int n,k,i,f,a[M];

bool is(int x){
	for(i=1;i<=k;i++)
	if(a[i]==x) return false;
	return true;
}

int main(){
	cin>>n>>k;
	
	
	for(i=1;i<=k;i++)
	cin>>a[i];
	
	if(k==0){
		cout<<n;
		return 0;
	}
	
	for(i=1;i<=105;i++){
		if(is(n-f)){
			cout<<n-f;
			return 0;
		}else if(is(n+f)){
			cout<<n+f;
			return 0;
		}
		f++;
	}
	
	return 0;
}

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

bool bad(string s){
	for(int i = 0 ; i+1 < s.size() ; i++){
		if( s[i] == s[i+1] ) return true;
	}
	return false;
}
vector<string> trans(string t){
	vector<string> ans;
	for(int i = 1 ; i+1 < t.size() ; i++){
		string w = t.substr(0,i) + t.substr(i+1);
		if( !bad(w) ) ans.push_back(w);
	}
	return ans;
}
map<string,int> memo;
int game(string w){
	if( memo.count(w) ) return memo[w];
	for( auto i : trans(w) ){
		if( !game(i) ) return memo[w] = true;
	}
	return memo[w] = false;
}
bool fast(string s){
	return ((s.back()==s.front())^(s.size()%2));
}
void solve(string s){
	string r[] = {"Second","First"};
	cout << r[fast(s)] << endl;
}

void test(){
	for(int i = 0 ; i < 100000 ; i++){
		int l = rand() % 10 + 1;
		string w;
		
		for(int j = 0 ; j < l ; j++) w += rand() % 5+ 'a';
		
		if(!bad(w)){
			if( game(w) != fast(w) ) cout << "Error" << " " << w << endl;
			//cout << w << endl;
			//cout << w << " " << game(w) << "|" << fast(w) << endl;
		}else i--;
	}
	
}

int main(){	
	//test();
	//return 0;
	string s;
	cin >> s;
	solve(s);
	return 0;
}


Measured memory_bytes: 512
Nc = input()
N = int(Nc)
c = map(int,input().split())
l = list(c)
maiorP = l[0]
menorP = l[0]


for num in l:
    if 1 <= N <= 100 and 0 <= len(l) <= 100 and type(num) == int:
        if num > maiorP:
            maiorP = num
        if num < menorP:
            menorP = num
print(maiorP - menorP)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  ll a; long double b;
  cin >> a >> b;
  cout << (long long) (a*b) << endl;

  return 0;
}



Measured memory_bytes: 3728
N = int(input())
H = list(map(int, input().split()))

M = [0] * N
M[0] = 0

for i in range(1, N) :
    M[i] = max(M[i-1], H[i-1])
    
ret = 0
for i in range(N) :
    if H[i] >= M[i] :
        ret += 1
        
print(ret)

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*

	Optimizer

*/
//#pragma GCC optimize("Ofast")

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;

  LL T;
  cin >> T;

  vector<LL> t(N);
  REP(N) cin >> t[i];

  LL ans = 0;
  REP(N-1) {
    if((t[i+1] - t[i]) < T) {
      ans += (t[i+1] - t[i]);
    }
    else {
      ans += T;
    }
  }
  ans += T;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
import java.util.*

fun main(args: Array<String>) {
    val (h, w) = readIntegerList()
    val matrix = Array(h) { readLine()!! }

    var max = 0
    for (i in 0 until (h * w)) {
        for (j in i until (h * w)) {
            max = Math.max(max, calc(i % w, i / w, j % w, j / w, matrix))
        }
    }

    println(max)
}

fun calc(x1: Int, y1: Int, x2: Int, y2: Int, matrix: Array<String>): Int {
    if (matrix[y1][x1] == '#' || matrix[y2][x2] == '#') {
        return 0
    }

    val map = Array(matrix.size) { Array(matrix[0].length) { -1 } }
    val queue = ArrayDeque<Pair<Int, Int>>().apply { addLast(Pair(x1, y1)) }
    map[y1][x1] = 0
    while (queue.isNotEmpty()) {
        val point = queue.removeFirst()
        val cost = map[point.second][point.first]

        if (point.first == x2 && point.second == y2) {
            return cost
        }

        for (i in -1..1 step 2) {
            val x = point.first + i
            val y = point.second

            if (y in matrix.indices && x in matrix[y].indices) {
                if (map[y][x] == -1 && matrix[y][x] == '.') {
                    map[y][x] = cost + 1
                    queue.addLast(Pair(x, y))
                }
            }
        }

        for (i in -1..1 step 2) {
            val x = point.first
            val y = point.second + i

            if (y in matrix.indices && x in matrix[y].indices) {
                if (map[y][x] == -1 && matrix[y][x] == '.') {
                    map[y][x] = cost + 1
                    queue.addLast(Pair(x, y))
                }
            }
        }
    }

    return 0
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 118632
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#define mop 1000000007

using namespace std;

int main() {
    
    string s;
    cin >> s;
    int ans = 10000;
    for (int i = 0;i<s.length()-2;i++){
        int p;
        string q;
        q = s.substr(i,3);
        p = stoi(q.c_str());
        if(abs(ans - 753) > abs(p-753)){
            ans = p;
        }
    }
    cout << abs(ans - 753) << endl;
}

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

const int MAX_N = 10000;

bool linearSearch(int* S, int n, int key) {
    S[n] = key;

    int i = 0;
    while(S[i] != key) {
        i++;
    }
    
    return i != n;
}

int main() {
    int n, q;
    int S[MAX_N + 1];

    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> S[i];
    }
    
    cin >> q;
    
    int ans = 0;
    int key;
    for(int i = 0; i < q; i++) {
        cin >> key;
        if(linearSearch(S, n, key)) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

int A,B;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> A >> B;
  if(A % 2 == 0 || B % 2 == 0){
    cout << "No";
  }
  else{
    cout << "Yes";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;

public class Main {


  private static void solve() {
    char[] s = ns();
    ArrayDeque<Character> q = new ArrayDeque<>();
    int ret = 0;
    for (char c : s) {
      if (q.size() == 0 || q.peekFirst() == c) {
        q.addFirst(c);
      } else {
        q.poll();
        ret ++;
      }
    }
    System.out.println(ret * 2);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 24660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;

    vector<int> L(k+1), R(k+2);
    L[0] = -INF;
    R[k+1] = INF;

    int jb = 0;
    // 最速で働いた場合
    for(int i=0; i<n; i++){
        if(s[i] == 'o' && L[jb] + c < i){
            jb++;
            L[jb] = i;
        }
        if(jb >= k) break; 
    }

    // もっとも遅い場合
    jb = k+1;
    for(int i=n-1; i>=0; i--){
        if(s[i] == 'o' && R[jb] - i > c){
            jb--;
            R[jb] = i;
        }
        if(jb <= 1) break;
    }

    for(int i=1; i<=k; i++){
        if(L[i] == R[i]){
            cout << L[i]+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3332
a = ('a'..'z').to_a
s = gets.chomp.split("")
t = gets.chomp.split("")
if s.size >= t.size
  max = t.size
else
  max = s.size
end
flag = 0

s.sort!
t = t.sort.reverse

max.times do |i|
  if a.index(s[i]) < a.index(t[i])
    puts "Yes"
    break
  elsif a.index(s[i]) > a.index(t[i])
    puts "No"
    break
  end
  flag = 1 if i == max - 1
end

if flag == 1
  if s.size >= t.size
    puts "No"
  else
    puts "Yes"
  end
end

Measured memory_bytes: 1788
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	d := nextInt()

	cnt := 0

	for i := 0; i < n; i++ {
		x, y := nextInt(), nextInt()
		if d *d  >=  x * x + y *y{
			cnt++
		}
	}
	fmt.Println(cnt)

}

func abs(n int) int {
	y := n >> 63
	return (n ^ y) - y
}


Measured memory_bytes: 4892
using System;
//using System.Text;
//using System.Linq;
class Program
{
    static void Main()
    {
        double a = 100;
        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++) a=Math.Ceiling(a *= 1.05);
        Console.WriteLine((int)a * 1000);
    }
}

Measured memory_bytes: 9052
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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 T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}

long double eps=1e-8;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int n){
    return uniform_int_distribution<int>(0, n)(rng);
}
double drnd(){
    return (double)(rnd(INT_MAX))/INT_MAX;
}
main(){
    int n=in(),k=in();
    double tmp=0;
    double ans=0;
    vector<double> a;
    rep(i,n)a.pb((double)(in()+1)/(double)2);
    rep(i,k)tmp+=a[i];
    ans=tmp;
    rep2(i,k,n-1){
        tmp+=a[i];
        tmp-=a[i-k];
        chmax(ans,tmp);
    }
    printf("%.10f\n",ans);
}

Measured memory_bytes: 2420
N, L = map(int, input().split())
taste = [L+i-1 for i in range(1, N+1)]
min_num = [abs(i) for i in taste]
min_num = sum(min_num)
result = 0
for i in taste:
  num = abs(sum(taste) - (sum(taste) - i))
  if min_num > num:
    min_num = num
    result = sum(taste) - i
print(result)

Measured memory_bytes: 3064
n = STDIN.gets.to_i
array = STDIN.gets.split.map(&:to_i)
puts array.join(' ')

for i in 1..(n-1) do
  v = array[i]
  j=i-1
  while (j>=0 && array[j] > v) do
    array[j+1] = array[j]
    j-=1
  end
  array[j+1] = v
  puts array.join(' ')
end

Measured memory_bytes: 8820
import java.util.*;

class P
{
	int x;
	int y;
	P(int x, int y)
	{
		this.x = x;
		this.y = y;
	}
}
public class Main 
{
	static int[] dx = {1, 0, -1, 0};
	static int[] dy = {0, -1, 0, 1};
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int W = stdIn.nextInt();
			int H = stdIn.nextInt();
			if(W == 0 && H == 0)
			{
				break;
			}
			char[][] field = new char[H][W];
			Queue<P> que = new ArrayDeque<P>();
			for(int i = 0; i < H; ++i)
			{
				String s = stdIn.next();
				for(int j = 0; j < W; ++j)
				{
					if(s.charAt(j) == '@')
					{
						P p = new P(j, i);
						que.add(p);
						field[i][j] = '#';
					}
					else
					{
						field[i][j] = s.charAt(j);
					}
				}
			}
			int count = 1;
			while(!que.isEmpty())
			{
				P p = que.poll();
				for(int i = 0; i < dx.length; ++i)
				{
					P np = new P(0, 0);
					np.x = p.x + dx[i];
					np.y = p.y + dy[i];
					if((0 <= np.x && np.x < W) && (0 <= np.y && np.y < H) && field[np.y][np.x] == '.')
					{
						que.add(np);
						field[np.y][np.x] = '#';
						++count;
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 13000
def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
k= [0]
l = [0]
m=[]
co = range(1,10**5+2,2)
ce = range(0,10**5+2,2)
f = 1
def say(i):return print("Yes" if i == 1 else "No")
def Say(i):return print("YES" if i == 0 else "NO")
#def rep(i):return for i in range()
def addarray(k,l):
    for i in range(n):
        a ,b,c = map(int,input().split())
        k.append(a)
        l.append(b+c)
n = ai()
addarray(k,l)
for i in range(1,n+1):
    t = k[i]-k[i-1]
    if t%2==1 and abs(l[i]-l[i-1]) in co[:t//2+1]:
        f = 1
    elif t%2==0 and abs(l[i]-l[i-1]) in ce[:t//2+1]:
        f = 1
    else:
        f = 0
        break
say(f)
    

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

int main(void)
{
    int a, b;
    cin >> a >> b;

    cout << a*b;
    return 0;
}

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

//create arrays outside of main()
int N = 10;
int heights[100000] = {};

int main() {
    
    int n;
    int k;
    int total;

    cin >> n >> k;

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

    for(int i=0; i<n; i++){
        if(heights[i]>=k){
            total += 1;
        }
    }

    cout << total;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{
	int a, b, c, d, e, k = 0;
	cin >> a >> b >> c >> d >> e >> k;
	if ((e - a) > k || (e - b) > k || (e - c) > k || (e - d) > k || (d - a) > k || (d - b) > k || (d - c) > k || (c - a) > k || (c - b) > k || (b - a) > k )
	{
		cout << ":(" << endl;
	}
	else
	{
		cout << "Yay!" << endl;
	}
	return 0;
}

Measured memory_bytes: 256