akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

class Program
{
    private static List<int>[] children;
    static int Solve(int n)
    {
        int N = children[n].Count;
        var counts = new int[N];
        for (int i = 0; i < N; ++i) { counts[i] = Solve(children[n][i]); }
        Array.Sort(counts, (a, b) => (b - a));
        int max = 0;
        for (int i = 0; i < N; ++i) { max = Math.Max(counts[i] + i + 1, max); }
        return max;
    }
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        children = new List<int>[N + 1];
        for (int i = 1; i <= N; ++i) { children[i] = new List<int>(); }
        for (int i = 2; i <= N; ++i)
        {
            int n = int.Parse(Console.ReadLine());
            children[n].Add(i);
        }
        Console.WriteLine(Solve(1));
    }
}


Measured memory_bytes: 24312
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A, B) << " " << max(A + B - N, 0) << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;

const int INF = 1000000000;

bool cand[1005];
int n;
int dist[105];
vector <pair <int, int>> graf[105];

struct edge{
    int a, b, c;
};

vector <edge> edges;

void dijkstra(int root){
    set <pair <int, int>> q;
    for(int i=1; i<=n; i++) dist[i] = INF;
    dist[root] = 0;
    q.insert({0, root});
    while(!q.empty()){
        pair <int, int> par = *q.begin();
        q.erase(q.begin());
        int v = par.second;
        for(auto p : graf[v]){
            if(dist[p.first] > dist[v] + p.second){
                q.erase({dist[p.first], p.first});
                dist[p.first] = dist[v] + p.second;
                q.insert({dist[p.first], p.first});
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int m;
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        edges.push_back({a, b, c});
        graf[a].push_back({b, c});
        graf[b].push_back({a, c});
    }
    for(int i=1; i<=n; i++){
        dijkstra(i);
        for(int j=0; j<m; j++){
            if(!cand[j] && edges[j].c == abs(dist[edges[j].a] - dist[edges[j].b])){
                cand[j] = 1;
            }
        }
    }
    int cnt = 0;
    for(int i=0; i<m; i++){
        cnt += 1-cand[i];
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
import math


def rotate(x, y, theta):
    """
    (x, y)をtheta回転時計回りに回転させる
    thetaはdegree
    """
    r = -math.radians(theta)
    new_x = x * math.cos(r) - y * math.sin(r)
    new_y = x * math.sin(r) + y * math.cos(r)
    return new_x, new_y


def submit():
    a, b, h, m = [int(e) for e in input().split()]
    minutes = h * 60 + m
    theta_a = 360 * minutes / (12 * 60)
    theta_b = 360 * minutes / 60

    point_a = rotate(0, a, theta_a)
    point_b = rotate(0, b, theta_b)

    dist = (point_a[0] - point_b[0]) ** 2 + (point_a[1] - point_b[1]) ** 2
    print(math.sqrt(dist))


if __name__ == "__main__":
    submit()

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

typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

// cout<<fixed<<setprecision(10);

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;}

int main(){
    int h, w, n; cin >> h >> w >> n;
    int x = max(h, w);
    int ans = n%x==0 ? n/x : n/x+1;
    cout << ans << endl;
}



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

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 2e5 + 7, M = 31;
int n, a[N], b[N], ans;
map<int, int> c;

int main() {
	rd(n), rda(a, n);
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) {
		++c[a[i]], b[i] = 1;
		while (b[i] <= a[i]) b[i] <<= 1;
		b[i] -= a[i];
	}
	for (int i = n; i; i--)
		if (c[a[i]]) {
			--c[a[i]];
			if (c[b[i]]) --c[b[i]], ++ans;
		}
	print(ans);
	return 0;
}

Measured memory_bytes: 25816
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main(void) {
	int n, w[100], s[100],sum = 1000000000;
	cin >> n;
	rep(i, n) {
		cin >> w[i];
	}
	s[0] = w[0];
	for(int i =1;i < n;i++) {
		s[i] = s[i - 1] + w[i];
	}
	int l, r;
	rep(i, n) {
		l = s[i];r = s[n - 1] - s[i];
		sum = min(abs(l - r), sum);
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define printjudge(cond) {if(cond) printf("Yes\n"); else printf("No\n");}
#define printans(ans) {printf("%d\n", (ans));}

#define point(x) {if(N>=(x)) ans++;}

int main(){
    int N, ans = 0;
    scanf("%d", &N);
    point(3*5*7);
    point(3*5*11);
    point(3*5*13);
    point(3*3*3*5);
    point(3*3*3*7);
    printans(ans);
    return 0;
}

Measured memory_bytes: 128
//Author - Soumik Roy
//Date & Time - August 29, 2020 6:04 PM
//Problem name - B - Substring
//Problem url - https://atcoder.jp/contests/abc177/tasks/abc177_b
//Time limit - 2000 ms
//Memory Limit - 1024 MB    

#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define MOD                   1000000007
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define eb                    emplace_back
#define ull                   unsigned long long
#define bug(x)				  cout<<"  [ "#x<<" = "<<x<<" ]"<<endl;
#define KAMEHAMEHA            ios_base::sync_with_stdio(0);
#define RASENGAN              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int dir[]={0,1,0,-1,1,0,-1,0};
void solve()
{
	string s,t;
	cin>>s>>t;
	int ssize=s.size(),tsize=t.size(),mx=0;
	for(int i=0;i<=ssize-tsize;i++)
	{
		int match=0;
		for(int j=0;j<tsize;j++)
		{
			if(s[i+j]==t[j])
				match++;
		}
		mx=max(mx,match);
	}
	cout<<tsize-mx<<endl;
}
int main()
{
    KAMEHAMEHA
	int t=1;
	//cin>>t;
	for(int cn=1;cn<=t;cn++)
	{
		solve();
	}
    return 0;
}



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

void main()
{
    auto N = readln.chomp;
    int X;
    foreach (c; N.to!(char[])) X += c-48;
    writeln(N.to!int % X == 0 ? "Yes" : "No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std ;
const int maxn=1e5+10;
int n,cnt=0;
int arr[maxn];
multiset<int>s;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&arr[i]);
    for(int i=1;i<=n;i++){
        auto p=s.lower_bound(arr[i]);
        if(p!=s.begin()){
            p--;
            s.erase(p);
        }
        s.insert(arr[i]);
    }
    printf("%d\n",s.size());
}


Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define all(x) (x).begin(),(x).end()

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

  int N; cin >> N;
  string S; cin >> S;
  vector<vector<int>> v(26);
  for (int i = 0; i < N; i++) {
    v[S[i]-'a'].push_back(i);
  }
  int Q; cin >> Q;
  for (int k = 0; k < Q; k++) {
    int type; cin >> type;
    if (type == 1) {
      int i; cin >> i; i--;
      char c; cin >> c;
      if (S[i] == c) continue;
      int j = S[i] - 'a';
      v[j].erase(lower_bound(all(v[j]), i));
      S[i] = c;
      j = c - 'a';
      v[j].insert(lower_bound(all(v[j]), i), i);
    }
    else {
      int l, r; cin >> l >> r; l--; r--;
      int ans = 0;
      for (int i = 0; i < 26; i++) {
        if (v[i].empty()) continue;
        int index = lower_bound(all(v[i]), l) - v[i].begin();
        if (index < v[i].size() && v[i][index] <= r) ans++;
      }
      cout << ans << "\n";
    }
  }
}

Measured memory_bytes: 3868
N,D=map(int,input().split())
list1=[]
count=0
for i in range(N):
    list1.append(list(map(int,input().split())))
for i in range(N):
    for j in range(i+1,N):
        templen=0
        for k in range(D):
            templen+=(list1[i][k]-list1[j][k])**2
        templen=templen**(1/2)
        if templen==int(templen):
            count+=1
print(count)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int N;
  cin >> N;
  vector<pair<int, int>> a(N);
  REP(i, N) {
    int b;
    cin >> b;
    a.at(i).first = b;
    a.at(i).second = i;
  }
  sort(ALL(a));
  REP(i,N){
    cout << a.at(i).second + 1 << " ";
  }
  cout << endl;
}

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

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

    string S;
    cin >> S;

    long long n = S.length();
    long long ans = 1 << 29;
    for (long long i = 1; i <= n - 1; ++i)
    {
        if (S[i - 1] != S[i])
        {
            ans = min(ans, (long long)max(i, n - i));
        }
    }

    if (ans == 1 << 29)
    {
        ans = n;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>

int main()
{
	long long K,A,B;
	std::cin >> K >> A >> B;

	long long bis = 1;//ビスケット枚数
	long long yen = 0;

	long long guchoku = 1+K;
	long long ans;


	if (A >= B) {//損するパターン
		ans = guchoku;
	}
	else {
/*		std::cout << "スタート " << std::endl;
		std::cout << "bis " << bis << std::endl;
		std::cout << "K   " << K << std::endl;
*/			
		bis = bis + A - 1;
		K = K - A + 1;

		if (fmod(K, 2) == 0) {//偶数
			long long val = K / 2;
			bis = bis + val * (B - A);
			K = 0;
		}
		else {//奇数
			long long val = (K-1) / 2;
			bis = bis + val * (B - A);
			K = 1;
			bis += 1;
			K -= 1;
/*			std::cout << "増やす " << std::endl;
			std::cout << "bis " << bis << std::endl;
			std::cout << "K   " << K << std::endl;*/
		}



		}
//	}

	ans = bis > guchoku ? bis : guchoku;
//	std::cout << bis << std::endl;
//	std::cout << guchoku << std::endl;


	std::cout << ans << std::endl;
//		std::cout << bis;

Last:
	int hoge;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <functional> 
#include <vector>
#include <cstring>

using namespace std;

int main(){

    int n,a,b;
    cin >> n;
    cin >> a;
    cin >> b;

    cout << min(a*n,b);

    return 0;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

const int N = 110;

int n,m,ei,ej;
char t[N][N];

int dp[N][N], sumv[N][N], sumh[N][N];

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

    cin >> n >> m;
    forn(i,n) cin >> t[i];
    forn(i,n) forn(j,m) if (t[i][j] == 'E') {
        ei = i; ej = j;
        t[i][j] = '.';
        break;
    }
    if (ei > n-1-ei) {
        forn(i,n) for (int j1 = 0, j2 = m-1; j1 < j2; j1++, j2--) swap(t[i][j1], t[i][j2]);
        ei = n-1-ei;
    }
    if (ej > m-1-ej) {
        forn(j,m) for (int i1 = 0, i2 = n-1; i1 < i2; i1++, i2--) swap(t[i1][j], t[i2][j]);
        ej = m-1-ej;
    }
    forn(i,n) forn(j,m) t[i][j] = (t[i][j] == 'o' ? 1 : 0);

    int a = ei+1, b = ej+1;
    forn(j,m) {
        sumv[n][j] = 0;
        dforsn(i,0,n) {
            sumv[i][j] = t[i][j] + sumv[i+1][j];
            if (i+a < n) sumv[i][j] -= t[i+a][j];
        }
    }

    forn(i,n) {
        sumh[i][m] = 0;
        dforsn(j,0,m) {
            sumh[i][j] = t[i][j] + sumh[i][j+1];
            if (j+b < m) sumh[i][j] -= t[i][j+b];
        }
    }

    int res = 0;
    forn(i0,a) forn(j0,b) {
        int fi = i0 + n - ei - a;
        int fj = j0 + m - ej - b;
        dforsn(i,i0,fi+1) dforsn(j,j0,fj+1) {
            if (i == fi && j == fj) {
                dp[i][j] = 0;
                forn(x,a) forn(y,b) dp[i][j] += t[i+x][j+y];
            }
            else {
                dp[i][j] = 0;
                if (j < fj) dp[i][j] = max(dp[i][j], sumv[i][j] + dp[i][j+1]); 
                if (i < fi) dp[i][j] = max(dp[i][j], sumh[i][j] + dp[i+1][j]);
            }
        }
        int cand = dp[i0][j0];
        res = max(res, cand);
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  
  int n = s.size(), m = t.size();
  
  bool flag = false;  
  for (int i = n - m; i >= 0; i--) {
    bool ok = true;
    for (int j = 0; j < m; j++) {
      if (s[i + j] == '?') {
        continue;
      }
      if (s[i + j] != t[j]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      for (int j = 0; j < m; j++) {
        s[i + j] = t[j];
      }
      flag = true;
      break;
    }
  }
  if (!flag) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  for (int i = 0; i < n; i++) {
    if (s[i] == '?') {
      cout << 'a';
    } else {
      cout << s[i];
    }
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def factorization(num):
    prime = []
    n = num
    p = 2
    while p * p <= num:
        if n % p == 0:
            cnt = 0
            while n % p == 0:
                cnt += 1
                n //= p
            prime.append((p, cnt))
        p += 1
    if n != 1:
        prime.append((n, 1))
    if not prime:
        prime.append((num, 1))
    return prime

def Main():
    a, b = read_ints()
    g = GCD(a, b)
    if g == 1:
        print(1)
        exit()
    prime = factorization(g)
    print(len(prime)+1)

if __name__ == '__main__':
    Main()

Measured memory_bytes: 9268
import java.util.HashSet;
import java.util.Scanner;
 
class Main {
	int N;
	String[] s;
	int M;
	String[] t;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}
	Main(Scanner sc){
		N = sc.nextInt();
		s = new String[N];
		for(int i=0;i<N;i++){
			s[i] = sc.next();
		}
		M = sc.nextInt();
		t = new String[M];
		for(int i=0;i<M;i++){
			t[i] = sc.next();
		}
	}
	void solve(){
		HashSet<String> h = new HashSet<String>();
		for(int i=0;i<N;i++) h.add(s[i]);
		for(int i=0;i<M;i++) h.add(t[i]);
		int max = 0;
		for(String str:h){
			int cnt = 0;
			for(int i=0;i<N;i++) if(str.equals(s[i])) cnt++;
			for(int i=0;i<M;i++) if(str.equals(t[i])) cnt--;			
			max = Math.max(max, cnt);
		}
		System.out.println(max);
	}
}

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

int main(){
  int a,b,c; cin >> a >> b >> c;
  int ans = 0;
  ans = (a - b) - c;
  if (ans > 0) ans = 0;
  if (ans < 0) ans = ans * -1;
  cout << ans << endl;
}


Measured memory_bytes: 256
def abc_145_b
    n = gets.chomp.to_i
    s = gets.chomp
    if n % 2 == 1
        puts 'No'
        exit
    end

    t1 = s[0..n/2-1]
    t2 = s[n/2..-1]

    puts t1 == t2 ? 'Yes' : 'No'
end

abc_145_b

Measured memory_bytes: 1788
from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat
import math
import random

# sys.stdin = open('input')

def inp():
    re = map(int, raw_input().split())
    if len(re) == 1:
        return re[0]
    return re

def inst():
    return raw_input().strip()

def gcd(x, y):
   while(y):
       x, y = y, x % y
   return x

def my_main():
        n, k, c = inp()
        st = inst()
        front, end = [], []
        def get(now, ans):
            while now < n:
                if len(ans) == k:
                    return
                for i in range(now, n):
                    if st[i]=='o':
                        ans.append(i+1)
                        now = i+c+1
                        break
                else:
                    break
        get(0, front)
        st = st[::-1]
        get(0, end)
        for i in range(len(end)):
            end[i] = n-end[i]+1
        end.sort()
        if len(front)!=k or len(end)!=k:
            return
        ans = []
        # print front, end
        for i in range(k):
            if front[i] == end[i]:
                ans.append(front[i])
        if ans:
            print '\n'.join(map(str, ans))

my_main()


Measured memory_bytes: 65276
#include "bits/stdc++.h"
using namespace std;
#define maxn 501
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define pb push_back
#define mp make_pair
#define mod 1000000007

int n;
long long m;
vector<vector<int> > a;
void solve(){
	cin >> m;
	n = 50;
	vector<int> x(n,0);
	a.pb(x);
	rep(i, n){
		x[i] -= n + 1;
		rep(j, n) x[j]++;
		a.pb(x);
		//for (int _ : x) cout << _ << ' '; cout << endl;
	}
	long long A = m / n;
	long long B = m % n;
	cout << n << endl;
	rep(i, n){
		cout << A + n + a[n-B][i];
		if (i < n - 1) cout << ' ';
	}
	//vector<long long> ans(a[n - B]);
}

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(0);
    solve();
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main()
	{

	string s = Console.ReadLine();
      string sub = "";
      char[] c = s.ToCharArray();//stringをcharにして、書き換え可能にする
      for(int i = 0; i < s.Length; i+=2)sub += s[i];//charの４文字目を変更
Console.WriteLine(sub);

	}
}

Measured memory_bytes: 34772
from collections import Counter
def solve():
  N = int(input())
  S = list(input())
  c = Counter(S)
  ans = c['R']*c['G']*c['B']
  for i in range(N):
    for j in range(i+1,N):
      k = j*2-i
      if k>N-1:
        break
      if S[i]!=S[j] and S[j]!=S[k] and S[i]!=S[k]:
        ans -= 1
  return ans
print(solve())


Measured memory_bytes: 9352
nums = int(input())

S = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

for i in range(0, nums):
    input_str = input()
    if input_str in S:
        S[input_str] += 1

print('AC x %d' % S['AC'])
print('WA x %d' % S['WA'])
print('TLE x %d' % S['TLE'])
print('RE x %d' % S['RE'])


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#include <fstream>
#include <string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


typedef  long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;


#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N=5000+5;
ll mod=1e9+7,inf=1e18;
ll mul (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll add (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a+b+mod)%mod;
}
ll fastpow(ll b, ll p)
{
    if(p==0)
        return 1;
    ll ans=fastpow(b,p/2);
    ans=mul(ans,ans);
    if(p%2)ans=mul(ans,b);
    return ans;
}
ll dis[N][N];
ll graph[N][N],total[N][N];
ll l, n;

void floyd1()
{
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            dis[i][j]=min(dis[i][j],graph[i][j]);
        }
    }

    for(int k=1; k<=n; k++)
    {
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=n; j++)
            {
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
            }

        }
    }

}
void floyd2()
{
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {

            if(dis[i][j]<=l&&i!=j)
                total[i][j]=1;
        }
    }

    for(int k=1; k<=n; k++)
    {
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=n; j++)
            {
                total[i][j]=min(total[i][j],total[i][k]+total[k][j]);
            }

        }
    }

}


bool vist[N];

int main()
{
    FIO
    int m;
    cin>>n>>m>>l;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            graph[i][j]=inf;
            dis[i][j]=inf;
            total[i][j]=inf;
        }
    }
    for(int i=0; i<m; i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
        if(z>l)
            continue;
        graph[x][y]=z;
        graph[y][x]=z;
    }
    floyd1();
    floyd2();

    int q;
    cin>>q;
    while(q--)
    {
        int a ,b;
        cin>>a>>b;
        if(total[a][b]!=inf)
            cout<<total[a][b]-1<<endl;
        else
            cout<<-1<<endl;

    }


    return 0;
}


Measured memory_bytes: 37760
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		double A = stdIn.nextDouble();
		double B = stdIn.nextDouble();
		long N = stdIn.nextLong();
		
		long max = 0;
		
		for(long i = (long)B - 1; i < N; i += (long)B) {
			if(max < sub(A, B, i)) {
				max = sub(A, B, i);
			}else {
				break;
			}
		}
		
		max = Math.max(max, sub(A, B, N));
		System.out.println(max);
	}
	
	public static long sub(double A, double B, long x) {
		long ret = (long) (Math.floor(A * x / B) - A * Math.floor(x / B));
		return ret;
	}
}


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

int main(){
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;
    string res = "";
    for(int i =0; i < N; i++){
        res = res + s[i];
        res = res + t[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int solve(const int *A, const int &n, int i, int m){
 if(i == n){
		return 0;
	}else if(A[i] == m){
		return 1;
	}else{
		int new_i = i + 1;
		int a = solve(A, n, new_i, m);
		int new_m = m - A[i];
		int b = solve(A, n, new_i, new_m);

		if(a == 0 && b==0){
			return 0;
		}else{
			return 1;	
		}
	}
}

int main(){
	int n, q;
	scanf("%d", &n);

	int *A = new int[n];
	for(int i=0; i<n; ++i){
		scanf("%d", &A[i]);
	}

	scanf("%d", &q);
	int *m = new int[q];
	for(int i=0; i<q; ++i){
		scanf("%d", &m[i]);
	}

	int res;
	for(int i=0; i<q; ++i){
		int index = 0;
		int mv = m[i];
		res = solve(A, n, index, mv);	
		if(res){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}

	return 0;
}


Measured memory_bytes: 2640
N = int(input())
A = [int(input()) for i in range(N)]
i = 0
cnt = 1
cmpr = [0]
while A[i] != 2:
    if A[i] == i + 1:
        print(-1)
        exit()
    i = A[i] - 1
    cmpr.append(i)
    cnt += 1
    if cnt > N:
        print(-1)
        exit()
print(cnt)

Measured memory_bytes: 16836
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

int main()
{
    int n,m;
    cin>>n>>m;
    vector<vector<int>> s(m);
    rep(i,m)
    {
        int k;
        cin>>k;
        rep(j,k)
        {
            int ts;
            cin>>ts;
            ts--;
            s[i].push_back(ts);

        }
    }
    vector<int> p(m);
    rep(i,m)
    {
        cin>>p[i];
    }
    int ans=0;


    for(int bit=0;bit<(1<<n);bit++)
    {
        bool flag=true;

        rep(i,m)
        {
            int count=0;
            for(auto v:s[i])
            {
                if(bit & (1<<v))count++;
            }
            if(count%2!=p[i])flag=false;
        }
        if(flag)ans++;

    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  int main() {
int N;
    cin >>N;
    
vector<long long> F(87);
    F[0] = 2, F[1] = 1;
    for (int n = 2; n < 87; ++n) {
        F[n] = F[n-1] + F[n-2];
    }
        cout << F[N] << endl;
  
}


Measured memory_bytes: 256
N, T = map(int, input().split())
A = list(map(int, input().split()))

INF = 10 ** 10
min_cum_A = [INF] * N
for i in range(N):
    min_cum_A[i] = min(A[i], min_cum_A[i-1])
ans = 0
max_profit = 0
for i in range(1, N):
    if A[i] - min_cum_A[i-1] > max_profit:
        ans = 1
        max_profit = A[i] - min_cum_A[i-1]
    elif A[i] - min_cum_A[i-1] == max_profit:
        ans += 1
print(ans)


Measured memory_bytes: 62704
#include <stdio.h>

int main(void)
{
	int n;
	int a[24], v[24] = {0};
	int i;
	int ans_a = 0, ans_v = 0;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d%d", &a[i], &v[i]);
		if (!ans_a) ans_a = a[i];
		if (v[i] > ans_v) {
			ans_v = v[i];
			ans_a = a[i];
		} else if (v[i] == ans_v) {
			if (a[i] < ans_a) {
				ans_a = a[i];
			}
		}
	}
	printf("%d %d\n", ans_a, ans_v);
	return (0);
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

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

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    int n,k; cin >> n >> k;

    COMinit();

    for(int i=1; i<=k; ++i){

        ll a = COM(n-k+1,i)*COM(k-1,(i-1)) %MOD;

        cout << a << endl;
    }


    return 0;
}

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

int main()
{
	string str1,str2,str3;
	cin>> str1 >>str2 >>str3;
	str1[0]-= 32;
	str2[0]-= 32;
	str3[0]-= 32;
	cout << str1[0]<<str2[0]<<str3[0]<<endl;
	return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD  998244353
#define REP(i,n) for(long long i = 0;i < n;++i)
vector<int> vertexs[200000];
int visited[200000] = {};
int main(){
	int n, m;
	cin >> n >> m;
	REP(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		vertexs[a].push_back(b);
		vertexs[b].push_back(a);
	}
	int ans = 0;
	queue<int> next;
	for (int i = 1; i <= n; ++i) {
		if (visited[i] == 0) {
			visited[i] = 1;
			next.push(i);
			ans++;
			while (next.empty() == false) {
				int now = next.front();
				next.pop();
				for (int i = 0; i < vertexs[now].size(); ++i) {
					if (visited[vertexs[now][i]] == 0) {
						visited[vertexs[now][i]] = 1;
						next.push(vertexs[now][i]);
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

const i32 MOD=1e9+7;

int main(){
    i64 N=read(),K=read(),Ans=0,Sl=0,Sr=0;
    f(i,1,I,K-1){
        Sl+=i-1;
        Sr+=N-(i-1);
    }
    f(i,K,I,N+1){
        Sl+=i-1;
        Sr+=N-(i-1);
        Ans=(Ans+Sr-Sl+1)%MOD;
    }
    print( (Ans+MOD)%MOD );
    output();
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 303;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n, a, b;
	cin >> n >> a >> b;
	if(n>2) {
		a = abs(a-b)-1;
		cout << ((a&1)?"Alice":"Borys");
	} else cout << "Borys";
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::pair<int,pi> pipi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
typedef std::queue<pipi> qpipi;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int H,W;
char s[410][410];
int ss[410][410];
bool f[410][410];
ll bfs(int c,int i,int j){
  ll w=0,b=0;
  qpipi q;
  q.push(mp(c,(mp(i,j))));
  f[i][j]=false;
  while(!q.empty()){
    pipi p=q.front();q.pop();
    int cc=p.first,xx=p.second.first,yy=p.second.second;
    if(cc==1) w++;
    else b++;
    if(xx!=0){
      if(ss[xx-1][yy]!=cc&&f[xx-1][yy]){
	q.push(mp(-cc,mp(xx-1,yy)));
	f[xx-1][yy]=false;
      }
    }
    if(xx!=H-1){
      if(ss[xx+1][yy]!=cc&&f[xx+1][yy]){
	q.push(mp(-cc,mp(xx+1,yy)));
	f[xx+1][yy]=false;	
      }
    }
    if(yy!=0){
      if(ss[xx][yy-1]!=cc&&f[xx][yy-1]){
	q.push(mp(-cc,mp(xx,yy-1)));
	f[xx][yy-1]=false;	
      }
    }
    if(yy!=W-1){
      if(ss[xx][yy+1]!=cc&&f[xx][yy+1]){
	q.push(mp(-cc,mp(xx,yy+1)));
	f[xx][yy+1]=false;	
      }
    }
  }
  return w*b;
}
int main(){
  cin>>H>>W;
  rep(i,H){
    rep(j,W){
      cin>>s[i][j];
    }
  }
  rep(i,H){
    rep(j,W){
      f[i][j]=true;
      if(s[i][j]=='.') ss[i][j]=1;//white
      else ss[i][j]=-1;//black
    }
  }
  ll res=0;
  rep(i,H){
    rep(j,W){
      if(f[i][j]){
	res+=bfs(ss[i][j],i,j);
      }
    }
  }
  prin(res);
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> dp(n + 1);
    dp[0] = 1; dp[1] = 1;
    for (int i = 2; i <= n; i++)
        dp[i] = dp[i - 1] + dp[i - 2];

    cout << dp[n] << endl;
    return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int N = 26, D;
vi last (N, -1);
vi CS (N);
vector<vi> SAT;

ld heuristic(int day, int choice) {
	ld res = SAT[day][choice];
	F0R(i, N) if (i != choice) {
		res -= CS[i] * (day - last[i]);
	} 
	return res;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> D;
	F0R(i, N) cin >> CS[i];
	SAT = vector<vi> (D, vi (N));
	F0R(i, D) F0R(j, N) cin >> SAT[i][j];

	F0R(i, D) {
		ld best = -INF; 
		int ind = -1;
		F0R(j, N) {
			ld score = heuristic(i, j);
			if (score > best) {
				best = score;
				ind = j;
			}
		}
		print(ind+1);
	}
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;
const ll    inf = 2e18;

ll  add(ll  x,ll  y)    {   x += y; if (x > inf)    x = inf;    return  x;  }
ll  mul(ll  x,ll  y)    {
    if (x == 0) return  0;
    if (y == 0) return  0;
    if (x >= inf / y)
        return  inf;
    else
        return  x * y;
}

string S;
ll  l, r;
int kmp[N];

vector<ll>  fib;
vector<ll>  calc()  {
    if (r == 0) return  vector<ll>(26,0);
    int n = sz(S);

    int len1 = n - kmp[n];
    int len2 = n - len1;

    ll  cnt1 = 0;
    ll  cnt2 = 0;

    for(int i = sz(fib) - 1 ; i > 1 ; --i)
        if (add(mul(fib[i - 1],len1),mul(fib[i - 2],len2)) <= r)    {
            cnt1 += fib[i - 1];
            cnt2 += fib[i - 2];

            r -= fib[i - 1] * len1;
            r -= fib[i - 2] * len2;
        }
    vector<ll>  res(26,0);

    for(int i = 0 ; i < r ; ++i)    res[S[i] - 'a']++;

    for(int i = 0 ; i < len1 ; ++i) res[S[i] - 'a'] += cnt1;
    for(int i = len1 ; i < n ; ++i) res[S[i] - 'a'] += cnt2;

    return  res;
}

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

    fib.pb(0);
    fib.pb(1);

    while (fib.back() < inf)
        fib.pb(0),
        fib.back() += fib[sz(fib) - 2],
        fib.back() += fib[sz(fib) - 3];

    cin >> S;       S.resize(sz(S) / 2);
    cin >> l >> r;

    kmp[1] = 0;
    kmp[0] = -1;

    for(int i = 2 ; i <= sz(S) ; ++i)
    for(int j = kmp[i - 1] ; j >= 0 ; j = kmp[j])
        if (S[j] == S[i - 1])   {
            kmp[i] = j + 1;
            break;
        }    
    vector<ll>  cnt1 = calc();  r = l - 1;
    vector<ll>  cnt2 = calc();

    for(int i = 0 ; i < 26 ; ++i)
        cout << cnt1[i] - cnt2[i] << " ";
}

Measured memory_bytes: 916
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n, m, a[2009], b[2009];
ll dp[2009][2009], mod=1e9+7;
int main()
{
    IO;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        cin>>a[i];
    for(int i=1; i<=m; i++)
        cin>>b[i];
    dp[0][0]=1;
    for(int i=0; i<=n; i++)
        for(int j=0; j<=m; j++)
        {
            if(i==0 || j==0)
            {
                dp[i][j]=1;
                continue;
            }
            dp[i][j]=((dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%mod+mod)%mod;
            if(a[i]==b[j])
                dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod;
        }
    cout<<dp[n][m];
}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;

  bool ma[1010][1010];
  CLR(ma);
  int dx=tx-sx,dy=ty-sy;
  cout<<string(dx,'R')<<string(dy,'U');
  cout<<string(dx,'L')<<string(dy,'D');
  cout<<'L'<<string(dy+1,'U')<<string(dx+1,'R')<<'D';
  cout<<'R'<<string(dy+1,'D')<<string(dx+1,'L')<<'U';
  cout<<endl;


  return 0;
}


Measured memory_bytes: 1280
/*
author: rootn
*/

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

#define X first
#define Y second
#define pb push_back
#define mp make_pair

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int visited[100001];

int color[100001];

int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    int n;cin >> n;
    vector<vii> t(n+1, vii(0));
    int u, v, w;
    for(int i = 0;i < n-1;i++)
    {
        cin >> u >> v >> w;
        t[u].pb(mp(v, w));
        t[v].pb(mp(u, w));
    }
    memset(color, -1, sizeof color);
    memset(visited, 0, sizeof visited);
    color[1] = 1;
    stack<int> st;
    st.push(1);
    while(!st.empty())
    {
        int k = st.top();
        visited[k] = 1;
        st.pop();
        for(int j = 0;j < (int)t[k].size();j++)
        {
            int vt = t[k][j].X;
            if(!visited[vt])
            {
                int wt = t[k][j].Y;
                if(color[k] == 1)
                {
                    if(wt%2 == 0)
                        color[vt] = 1;
                    else
                        color[vt] = 0;
                }
                else
                {
                    if(wt%2 == 0)
                        color[vt] = 0;
                    else
                        color[vt] = 1;
                }
                st.push(vt);
            }
        }
    }
    for(int i = 1;i <= n;i++)
        cout << color[i] << "\n";
    return 0;
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long long int d,t,s;
    cin>>d>>t>>s;
    //s=d/t;
    if(1LL*s*1LL*t>=d)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


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

int main() {
    int n;
    cin >> n;
    vector<int>p(n);
    for (int i = 0; i < n; ++i) {
      cin >> p[i];
    }
    int ans = 0;
    for (int i = 1; i < n-1; ++i) {
        if(p[i-1] < p[i] && p[i] < p[i+1]) ans++;
        if(p[i-1] > p[i] && p[i] > p[i+1]) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final int MAX = 100100;
    InputStream in = System.in;
    PrintStream out = System.out;

    public void _main(String[] args) {
        Scanner sc = new Scanner(in);
        String s = sc.next();
        for(int i=0;i<s.length()-1;i++) {
            if (s.charAt(i)==s.charAt(i+1)) {
                out.println("Bad");
                return;
            }
        }
        out.println("Good");
    }

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


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	int a=0,b=0;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(i%2==0){
			if(s.substr(i,1)=="1")a++;
		}else{
			if(s.substr(i,1)=="0")a++;
		}
	}
	for(int i=0;i<s.length();i++){
		if(i%2==0){
			if(s.substr(i,1)=="0")b++;
		}else{
			if(s.substr(i,1)=="1")b++;
		}
	}
	cout<<min(a,b)<<endl;
}


Measured memory_bytes: 512
#include <iostream>
 
using namespace std;
 
int main(void)
{
    int N, i, j, judge=0;
 
    cin >> N;
 
    for(i=1; i<=9; i++){
        for(j=1; j<=9; j++){
            if(i * j == N){
                judge = 1;
            }
        }
    }
 
    if(judge == 1){
        cout << "Yes" << endl;
    }
 
    else{
        cout << "No" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
	int left;
	int right;
} pool;

int main(void)
{
	int i, j, len, k, le, ri, he, h[20001], area[10000], areasum;
	char ch;
	pool p[10000];
	
	h[0] = 0;
	i = 0;
	while(1) {
		scanf("%c",&ch);
		if( ch == '\n' ) break;
		switch (ch) {
		case '/':
			h[i+1] = h[i] + 1;
			break;
		case '\\':
			h[i+1] = h[i] - 1;
			break;
		case '_':
			h[i+1] = h[i];
			break;
		}
		i++;
	}
	len = i;
	
	k = 0;
	for (i=0; i<=len-1; i++) {
		if( h[i] > h[i+1] ) {
			for (j=i+1; j<=len; j++) {
				if( h[i] == h[j] ) {
					p[k].left = i;
					p[k].right = j;
					k++;
					i = j - 1;
					break;
				}
			}
		}
	}
	
	areasum = 0;
	for (i=0; i<k; i++) {
		le = p[i].left;
		ri = p[i].right;
		area[i] = 0;
		he = h[le];
		for (j=le; j<ri; j++) {
			area[i] += ( he - h[j] ) + ( he - h[j+1] );
		}
		area[i] /= 2;
		areasum += area[i];
	}
	
	if( k == 0 ) {
		printf("0\n0\n");
	} else {
		printf("%d\n",areasum);
		printf("%d ",k);
		for (i=0; i<k-1; i++) {
			printf("%d ",area[i]);
		}
		printf("%d\n",area[k-1]);
	}
	
	return 0;
}

Measured memory_bytes: 656
#include <bits/stdc++.h>
  using namespace std;
  typedef long long ll;
  int main()
  {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    char c;
    cin>>c;
    if(c>=97 && c<=122)
        cout<<'a'<<endl;
    else
        cout<<'A'<<endl;
    return 0;
  }


Measured memory_bytes: 3612
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-05-12 11:42:56

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int l[MAXN], r[MAXN], a[MAXN];
int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i)	cin >> a[i];
	for(int i = 1; i <= n; ++i)	l[i] = __gcd(l[i-1], a[i]);
	for(int i = n; i >= 1; --i)	r[i] = __gcd(r[i+1], a[i]);
	int res = 0;
	for(int i = 1; i <= n; ++i){
		res = max(res, __gcd(l[i-1], r[i+1]));
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1408