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

using namespace std;

string rotate(string& str) {
  return str.back() + str.substr(0, str.length() - 1);
}
int main() {
  string s, t;
  cin >> s >> t;
  bool isOk = false;
  string newS = s;
  while (true) {
    newS = rotate(newS);
    if (newS == t) {
      isOk = true;
      break;
    } else if (newS == s)
      break;
  }

  cout << (isOk ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cassert>
#include <algorithm>
using namespace std;

#define iter(i, n) for (int i = 1; i <= n; ++i)

const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<i64, i64> pii;

#define fi first
#define se second

vector<pii> vec[100];
i64 f[100];

int F(i64 a, i64 b) {
	if (a < b) swap(a, b);
	return !b ? 0 : F(b, a % b) + 1;
}

int main() {
	f[0] = 1, f[1] = 1;
	int n = 1;

	
	while (f[n] <= 1e18) {
		++n;
		f[n] = f[n - 1] + f[n - 2];
	}
	f[n + 1] = f[n];
	--n;

	vec[0].push_back(pii(0, 1));
	vec[0].push_back(pii(0, 2));
	iter(i, n) {
		for (pii p : vec[i - 1]) {
			i64 a = p.fi, b = p.se;
		//	if (i == 4) printf("[%lld %lld] %d %d %lld\n", a, b, i-1, F(a, b), f[i+1]);
			assert(F(a, b) == i - 1);

//			printf("%d [%lld %lld]", i, a, b);
			for (; a + b <= f[i + 2]; a += b) {
				//gcd(f[i+2],f
				if (F(b, a + b) == i) vec[i].push_back(pii(b, a + b));
			}
		}
	}
	int q;
	scanf("%d", &q);
	iter(id, q) {
		i64 a, b;
		scanf("%lld%lld", &a, &b);
		if (a > b) swap(a, b);
		int ans = 1; i64 cnt = 0;
		iter(i, n) {
			if (a >= f[i] && b >= f[i + 1]) ans = i;
			else break;
		}
		printf("%d ", ans);
		for (pii p : vec[ans - 1]) {
			if (p.se <= a && p.fi + p.se <= b && p.fi != p.se) cnt = (cnt + (b - p.fi) / p.se) % mod;
			swap(a, b);
			if (p.se <= a && p.fi + p.se <= b && p.fi != p.se) cnt = (cnt + (b - p.fi) / p.se) % mod;
			swap(a, b);
			
		}
		printf("%lld\n", ans != 1 ? cnt : a * b % mod);
	}
	//
	return 0;
}


Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll N;

//スター型のグラフを作ると直径が2なので後はちょうど2の辺がK個できるか数えるだけ
int main(){

    ll N, K; cin >> N >> K;

    if((N-1) * (N-2) / 2 >= K){
        //スターグラフを書くと最大(N-1)*(N-2)/2の条件に当てはまる最短距離2のノードのペアができる
        //数を調整したいときは最短距離が2のペアのノードに直通の距離1のパスを貼ってやる
        ll tmp = (N-1) * (N-2) / 2;
        cout << N - 1 + tmp - K << endl;
        for(ll i = 1; i <= N - 1; i++){
            cout << i << " " << N << endl;
        }

        ll edge1 = 1;
        ll edge2 = 2;
        for(ll i = 0; i < tmp - K; i++){
            cout << edge1 << " " << edge2 << endl;
            edge2++;
            if(edge2 == N){
                edge1++;
                edge2 = edge1 + 1; 
            }
        }

    }else{
        cout << -1 << endl;
    }
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> E;

llint n;
llint a[100005];

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a+1, a+n+1);
	
	if(a[n]-a[1] >= 2){
		cout << "No"<< endl;
		return 0;
	}
	if(a[n] == a[1]){
		if(a[1] == n-1 || a[1] * 2 <= n) cout << "Yes" << endl;
		else cout << "No" << endl;
		return 0;
	}
	llint cnt = 0, kind = a[n];
	for(int i = 1; i <= n; i++){
		if(a[i] == a[1]) cnt++;
	}
	if(cnt >= kind || 2*(kind-cnt) > n-cnt) cout << "No" << endl;
	else cout << "Yes" << endl;
	
	return 0;
}


Measured memory_bytes: 4408
use List::Util 'min';

chomp($s = <>);

$r = 753;
for $i (1 .. 9){
	$pos = index($s, $i);
	next if($pos == -1);
	$t = substr($s, $pos, 3);
	while(1){
		last if(length($t) < 3);
		$r = min($r, abs(753 - $t));
		$pos = index($s, $i, $pos + 1);
		last if($pos == -1);
		$t = substr($s, $pos, 3);
	}
}

print "$r\n";


Measured memory_bytes: 640
#include<stdio.h>

int main()
{
    int a,p;
    scanf("%d%d", &a,&p);
    if(0<=a && p<=100){
    if(a%2==1 && p%2==1)
          printf("%d\n",a+(a/2)+(p/2)+1);
    else
          printf("%d\n",a+(a/2)+(p/2));
    }
}


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

int gcd(int x, int y){
    if(x%y==0) return y;
    else{
        return gcd(y, x%y);
    }
}

int main(){
    ll a,b;
    cin >> a >> b;
    cout << a*b/gcd(max(a,b), min(a,b)) << endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)
 
const int MAXN = 3e5+5;
const int MOD = 1e9+7;
const int INF = 1e9+1;

int N;
LL A[MAXN];
int P[MAXN][61];
int pw2[61];
int ans;

void add(int &a, int b) {
    a += b;
    if(a >= MOD) a -= MOD;
}
void mul(int &a, int b) {
    a = (1LL*a*b) % MOD;
}

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    pw2[0] = 1;
    fore(i,1,60) pw2[i] = (pw2[i-1]*2) % MOD;

    cin >> N;
    fori(i,N) {
        cin >> A[i];
        for(int b = 0; (1LL<<b) <= A[i]; b++) {
            if((1LL<<b)&A[i]) {
                P[i][b] = 1;
                //cout << i << ' ' << b << endl;
            }
        }
    }

    //fori(i,N) {
        //fori(b,2) {
            //cout << i << ' ' << b << ' '  << P[i][b] << endl;
        //}
    //}
    //cout << "-------" << endl;

    ford(i,N-2) {
        fori(b,60) {
            add(P[i][b],P[i+1][b]);
            //cout << i << ' ' << b << ' ' << P[i][b] << endl;
        }
    }

    //fori(i,N) {
        //fori(b,2) {
            //cout << i << ' ' << b << ' '  << P[i][b] << endl;
        //}
    //}

    ford(i,N-2) {
        fori(b,60) {
            if((1LL<<b)&A[i]) {
                int t = N-i-1;
                int z = t-P[i+1][b];
                mul(z,pw2[b]);
                add(ans,z);
            } else {
                int o = P[i+1][b];
                mul(o,pw2[b]);
                add(ans,o);
            }
        }
    }

    cout << ans << endl;
    return 0;
}


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


int main(){
  cout << fixed << setprecision(12);


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


  cout<< a / b <<" ";
  cout<< a % b <<" ";
  cout<< (double)a / b <<endl;


  return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int n;
int a[200000];
vector<int> tree[200000];
int ans[200000];
int d[200000];

void dfs(int i){
  int k=lower_bound(d,d+n,a[i])-d;
  int old=d[k];
  d[k]=a[i];
  ans[i]=lower_bound(d,d+n,2e9)-d;
  
  rep(j,0,tree[i].size()){
    if(ans[tree[i][j]]==0){
      dfs(tree[i][j]);
    }
  }
  d[k]=old;
}

int main(){
  cin>>n;
  rep(i,0,n) cin>>a[i];
  rep(i,0,n-1){
    int u,v;
    cin>>u>>v;
    tree[u-1].push_back(v-1);
    tree[v-1].push_back(u-1);
  }
  rep(i,0,n) d[i]=2e9;
  rep(i,0,n) ans[i]=0;
  dfs(0);
  rep(i,0,n) cout<<ans[i]<<endl;
}

Measured memory_bytes: 28300
package main

import (
  "fmt"
)

func main(){
  var a,b,c int64

  fmt.Scan(&a, &b, &c)
  if a%c != 0 {
    a += c - a % c
  }
  if b%c != 0 {
    b -= b % c
  }

  if a > b {
    fmt.Println(0)
  } else {
    fmt.Println((b-a)/c+1)
  }
}

Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

const int HW = 100;

int main() {
    int A, B;
    cin >> A >> B;
    char a = '.', b = '#';

    if (A > B) {
        swap(A, B);
        swap(a, b);
    }

    int both = A - 1;
    int single = B - (A - 1);
    vector<string> grid(HW, string(HW, a));

    for (int row = 0; row < HW; row += 4)
        for (int col = 0; col < HW; col += 4)
            if (both-- > 0) {
                grid[row][col] = grid[row][col + 1] = grid[row][col + 2] = b;
                grid[row + 1][col] = grid[row + 1][col + 2] = b;
                grid[row + 2][col] = grid[row + 2][col + 1] = grid[row + 2][col + 2] = b;
            } else if (single-- > 0) {
                grid[row][col] = b;
            }

    cout << HW << ' ' << HW << '\n';

    for (int row = 0; row < HW; row++)
        cout << grid[row] << '\n';
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace practice_csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine().Split(' ').Select(s=>int.Parse(s)).ToArray();
            if(n[0]+n[1]+n[2] >= 22){
                System.Console.WriteLine("bust");
            }
            else
            {
                System.Console.WriteLine("win");
            }
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(){
	
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long a,b;
    cin >> a >> b;
    cout << min(a % b, b - a % b);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static final String abc = "ABC";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();

        int count = 0;

        for (int i = 0; i < n - 2; i++) {
            char a = s.charAt(i);
            char b = s.charAt(i + 1);
            char c = s.charAt(i + 2);
            if (a == abc.charAt(0) && b == abc.charAt(1) && c == abc.charAt(2)) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23124
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "abc165_a.cpp"

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

  int k, a, b;
  cin >> k >> a >> b;
  FOR(i, a, b + 1) {
    if (i % k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3640
package main
import (
        "fmt"
)

func main() {
        var a, b int
        fmt.Scan(&a)
        fmt.Scan(&b)
        if a == b {
                fmt.Println("a == b")
        }
        if a > b {
                fmt.Println("a > b")
        }
        if a < b {
                fmt.Println("a < b")
        }
}



Measured memory_bytes: 1108
#include<iostream>
#include<algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <sstream>

using namespace std;
typedef long long ll;
map<string, int> m;

int main() {
	cin.sync_with_stdio(0); cin.tie(0); cout.tie(NULL);
	int t; cin >> t;
	while (t--) {
		string s; cin >> s;
		m[s] += 1;
	}

	cout << "AC x " << m["AC"] << '\n';
	cout << "WA x " << m["WA"] << '\n';
	cout << "TLE x " << m["TLE"] << '\n';
	cout << "RE x " << m["RE"] << '\n';






}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
#define ll          long long
#define dl          double
#define pb          push_back
#define eb          emplace_back
#define mp          make_pair
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(i=a;i<b;i++)
#define all(v)      v.begin(),v.end()
#define allr(v)     v.rbegin(),v.rend()
#define mod         1e9+7
#define CIN(V,s,n)  for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n) for(int i=s;i<n;i++){cout <<  V[i] << " ";}
#define SbS         sortbysec
#define fast        ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);   for(ll i=0;i<V.size();i++) V[i] = 0;

// map<ll,vector<ll> > M;
// map<ll,vector<ll> >:: iterator it;
// it = M.begin();
// it.F will be ll
// it.S will be vector<ll>

using namespace std;

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}

int main()
{
ll t=1;
//cin >> t;
while(t--)
{
    ll n,m,i,j,k,h,l1,l2,w,q=1,u,v,d,temp=0,cn=0,cp=0,c0=0,max1=0;
    cin >> n >> m;
    vector<ll> DP(n);
    ll min1=1e9,sum=0;
    for(i=1;i<=n;i++)
    {
        DP[i-1] = (m+i-1);
        if(abs(min1)>abs(DP[i-1]))
           {
               min1 = DP[i-1];
           }

        sum += DP[i-1];
    }
    cout << sum - min1 << endl;

}
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(S: str):
    N = len(S)
    l = list(S)

    from collections import Counter
    c = Counter(l)
    
    if(abs(c['a']-c['b']) <= 1 and abs(c['b']-c['c']) <= 1 and abs(c['c']-c['a']) <= 1):
        print(YES)
    else:
        print(NO)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4336
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b,c; cin>>a>>b>>c;
  a=a.at(0)+'A'-'a';
  b=b.at(0)+'A'-'a';
  c=c.at(0)+'A'-'a';
  cout<<a<<b<<c<<endl;
}

Measured memory_bytes: 256
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let () =
        Scanf.sscanf (read_line ()) "%f" (
        fun n -> 
                let a = n /. 1.08 in
                let fa = truncate ((floor a) *. 1.08) in
                let ca = truncate ((ceil a) *. 1.08) in
                        if fa = int_of_float n then
                                string_of_int (truncate (floor a))
                        else if ca = int_of_float n then
                                string_of_int (truncate (ceil a))
                        else
                                ":("
        ) |> Printf.printf "%s\n"


Measured memory_bytes: 1536
n,x=map(int,input().split())
l=list(map(int,input().split()))

zahyou=[0]
for i in range(n):
    zahyou.append(zahyou[i]+l[i])
for i in range(len(zahyou)):
    if zahyou[i]>x:
        del zahyou[i:n+1]
        break
print(len(zahyou))

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	int n; string s, a;
	cin >> n >> s;
	
	rep(i, 4){
		a.clear();
		a += (i/2 == 0)?'S':'W'; // 0 SS 1 SW 2 WS 3 WW
		a += (i%2 == 0)?'S':'W';
		rep(i, n){
			if(	(s[a.size()-2] == 'o' && a[a.size()-2] == 'S' && a[a.size()-1] == 'S') ||
				(s[a.size()-2] == 'x' && a[a.size()-2] == 'W' && a[a.size()-1] == 'S') ||
				(s[a.size()-2] == 'o' && a[a.size()-2] == 'W' && a[a.size()-1] == 'W') ||
				(s[a.size()-2] == 'x' && a[a.size()-2] == 'S' && a[a.size()-1] == 'W') ){
				a += 'S';
			}else a+= 'W';
		}
		if(a[0] == a[n] && a[1] == a[n+1]){
			cout << a.substr(1, n) << endl;
			return 0;
		}
	}
	
	cout << -1 << endl;
	return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 1000000007;

ll mod_pow(ll x, ll k)
{
    ll res = 1;
    for (; k; x = x * x % MOD, k /= 2) if (k & 1) res = res * x % MOD;
    return res;
}

int H, W, A, B;
ll fact[200010];
ll ifact[200010];
ll ret;

ll comb(ll n, ll k)
{
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] % MOD * ifact[n-k] % MOD;
}

int main() {
    cin >> H >> W >> A >> B;
    fact[0] = ifact[0] = 1;

    for (int i = 1; i < 200010; ++i) {
	fact[i] = fact[i-1] * i % MOD;
	ifact[i] = mod_pow(fact[i], MOD - 2);
    }

    for (int i = 1; i <= H - A; ++i) {
	ll t = comb(B - 1 + i - 1, B - 1);
	ll ad = t * comb(W - B - 1 + H - i, H - i);
	ret = (ret + ad) % MOD;
    }

    cout << ret << endl;
    
    return 0;
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

int main() {
    int n;
    string s;
    cin >> n >> s;
    ll ans = TEN(18);
    int wc = 0, ec = 0;
    for (char c: s) {
        if (c == 'E') ec++;
    }
    for (char c: s) {
        if (c == 'E') ec--;
        ans = min<ll>(ans, ec+wc);
        if (c == 'W') wc++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1028
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

typedef long long LL;

LL K;
char s[10] = "FESTIVA";

int main(){
	scanf("%lld" , &K);
	printf("%s" , s);
	if(K % 2 == 1) printf("L");
	K /= 2;
	repm(i,6,0){
		if(K == 0) break;
		printf("%s" , s + i);
		if(K % 2 == 1) printf("L");
		K /= 2;
	}
	if(K > 0){
		printf("%s" , s);
		if(K % 2 == 1) printf("L");
		K /= 2;
	}
	repp(i,0,7){
		repp(j,1,8){
			if(K == 0) break;
			repm(t,1<<j,0){
				printf("%c" , s[i]);
			}
			printf("%s" , s + i + 1);
			if(K % 2 == 1) printf("L");
			K /= 2;
		}
	}
	repm(i,K*2,0){
		printf("L");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <cmath>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int a[20];
int n;

bool DFS(int k, int m, double r){
	int s=ceil(a[k]*(1-r));
	int e=ceil(a[k]*(1+r));
	for(int p=((s-1)/m+1)*m;p<e;p+=m)
		if(k==n-1)return true;
		else if(DFS(k+1,p,r))return true;
	return false;
}

int main(){
	scanf("%d",&n);
	REP(i,n)scanf("%d",&a[i]);
	double u=1.0,l=0.0;
	REP(i,30){
		double m=(u+l)*0.5;
		if(DFS(0,1,m))u=m;
		else l=m;
	}
	printf("%.9f\n",u);
	return 0;
}

Measured memory_bytes: 1072
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int M;
	cin >> M;
	REP(i, M) {
		string S;
		cin >> S;
		vector<string> Ans; //高々72 * 4 * 2通り、Uniqueで消せば十分。
		FOR(i, 1, SZ(S)) {//分割した2個目の車両の先頭車両
			string A = S.substr(0, i);
			string B = S.substr(i, SZ(S) - i);
			REP(k, 2) {
				Ans.push_back(A + B);
				rev(A);
				Ans.push_back(A + B);
				rev(B);
				Ans.push_back(A + B);
				rev(A);
				Ans.push_back(A + B);
				rev(B);
				swap(A, B);
			}
		}
		so(Ans);
		uni(Ans);
		cout << SZ(Ans) << endl;
	}
	return 0;
}



Measured memory_bytes: 3328
#include <iostream>
 
using namespace std;
 
using ll = long long;
 
int main(){
  ll A, B;
  cin >> A >> B;
  ll ans = 0;
  ll t = 1;
  while(t < B){
    t += A - 1;
    ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    vector<ll>x(n);
    ll ans=inf;
    rep(i,n)cin>>x[i];
    REP(i,1,101){
        ll cnt=0;
        rep(j,n){
            cnt+=(x[j]-i)*(x[j]-i);
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}

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

const int INF = 1e9;

int main() {
  int n,k;
  cin>>n>>k;
  vector<int> x;
  for(int i=0;i<n;i++){
    int xi;
    cin>>xi;
    x.push_back(xi);
  }

  auto it = lower_bound(x.begin(),x.end(),0);
  int left_size=it-x.begin();
  int right_size=n-left_size;

  long left[left_size+1];
  long right[right_size+1];
  left[0]=0;
  right[0]=0;
  for(int i=0;i<left_size;i++){
    left[i+1]=-*(it-i-1);
  }
  for(int i=0;i<right_size;i++){
    right[i+1]=*(it+i);
  }

  long ans = 1e9;
  for(int i=0;i<=min(k,left_size);i++){
    if(i<k){
      if(k-i>right_size){
        continue;
      }
      ans = min(ans, left[i]*2+right[k-i]);
    }else{
      ans = min(ans, left[i]);
    }
  }
  for(int i=0;i<=min(k,right_size);i++){
    if(i<k){
      if(k-i>left_size){
        continue;
      }
      ans = min(ans, right[i]*2+left[k-i]);
    }else{
      ans = min(ans, right[i]);
    }
  }
  cout<<ans<<endl;
}

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

int main() {
  int A, B, C = 0;

  cin >> A >> B >> C;

  int check = 0;

  if(A < C && C < B) {
	check = 0;
  } else if (A > C && C > B) {
	check = 0;
  } else {
	check = 1;
  }

  if (check == 0) {
	cout << "Yes" << endl;
  } else {
	cout << "No" << endl;
  } 
}

Measured memory_bytes: 256
import java.util.*;
import java.util.TreeMap;
import java.util.Map;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int[] A = new int[N];
        TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
        
        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
            if(map.containsKey(A[i])){
                map.put(A[i], map.get(A[i]) + 1);
            }
            else{
                map.put(A[i], 1);
            }
        }
        long sum = 0;
        for(int i : map.keySet()){
            sum += (long)map.get(i) * (map.get(i) - 1) / 2;
        }

        for(int i=0; i<N; i++){
            long a = sum;
            a -= (long)map.get(A[i]) * (map.get(A[i]) - 1) / 2;
            a += (long)(map.get(A[i]) - 1) * (map.get(A[i]) - 2) / 2;
            System.out.println(a);
        }
    }
}

Measured memory_bytes: 101436
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
input = input.split("\n");
var A = input[1].split(" ").map(function(e){ return parseInt(e,10)});

console.log(A.join(" "));
for (i = 1; i < A.length; i++) {
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v) {
        A[j + 1] = A[j];
        j--;
    }
    A[j + 1] = v;
    console.log(A.join(" "));
}



Measured memory_bytes: 16572
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;
  cin>>n>>m;
  int a[111111];
  for(int i=0;i<n;i++)cin>>a[i];
  map<int,int> mp;
  a[0]%=m;
  mp[a[0]]++;
  for(int i=1;i<n;i++){
    a[i]+=a[i-1];
    a[i]%=m;
    mp[a[i]]++;
  }
  int sum=0;
  int k=0;
  for(int i=0;i<n;i++){
    sum+=mp[k];
    k=a[i];
    mp[a[i]]--;
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
#define ll long long
#define rep(i,n) for (i = 0; i < n; ++i) 
#define REP(i,k,n) for (i = k; i <= n; ++i) 
#define REPR(i,k,n) for (i = k; i >= n; --i)
using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);
bool prime(ll x)
{
  if(x==1)
    return false;
  if(x==2||x==3||x==5)
    return true;
  for(ll i=2;i<=sqrt(x);i++)
  {
    if(x%i==0)
      return false;
  }
  return true;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin); 
   //freopen("error.txt", "w", stderr); 
   freopen("output.txt", "w", stdout); 
#endif 
   
 ll T = 1 ;
 //cin>>T;

 for(ll t=0;t<T;t++)
 {
  ll n , tm , s;
  cin>>n>>tm>>s;
  if(s*tm>=n)
  cout<<"Yes"<<endl;
  else cout<<"No"<<endl;  
 }
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <cmath>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int, int> pii;
const int mod = (int)1e9 + 7;

vector<vector<pii>> r;

const int INF = 1<<28;
VI dijkstra(int s){
	priority_queue< pii, vector<pii>, greater<pii> > que;
	VI d(sz(r), INF);
	d[s] = 0; 
	que.push(pii(0, s));
	while(!que.empty()){
		int cost, v; tie(cost, v) = que.top();
		que.pop();
		if(d[v] < cost) continue;
		for(const auto& rp : r[v]){ 
			ll rct, rto; tie(rto, rct) = rp;
			if(d[rto] > d[v] + rct){
				d[rto] = d[v] + rct;
				que.push(pii(d[rto], rto));
			}
		}
	}
	return d;
}




int main()
{

	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,k;
	cin >> n;
	r.resize(n+1);
	rep(i,n-1){
		int a,b; cin >>a >>b;
		r[a-1].emplace_back(b-1,1);
		r[b-1].emplace_back(a-1,1);
	}
	VI vc(n+1, -999999);
	cin >>k;
	vector<pii> vp(k);
	rep(i,k){
		int v,p; cin >>v >>p;
		vc[v-1] =p;
		vp[i] = pii(v-1,p);
		r[n].emplace_back(v-1,p);
	}
	
	auto rv = dijkstra(n);
	
	rep(i,n) if(vc[i] !=-999999 && vc[i] != rv[i]){puts("No"); return 0;}
	
	rep(i,n){
		for(auto x:r[i]){
			if(x.first==n) continue;
			if(abs(rv[i] - rv[x.first]) !=1) {puts("No"); return 0;}
		}
	}
	puts("Yes");
	rep(i,n) printf("%d\n", rv[i]);
	//for(auto x :rv) printf("%d, ",x); puts("");
	//for(auto x :vc) printf("%d, ",x); puts("");
	
	return 0;
}


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

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

int main(){

    int n;
    cin>>n;
    int a[n];
    a[0]=0;
    for(int i=1;i<n;i++)cin>>a[i];
    int ans[n]={};
    for(int i=1;i<n;i++)ans[a[i]-1]++;

    for(int i=0;i<n;i++)cout<<ans[i]<<endl;


    return 0;
}


Measured memory_bytes: 5200
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define pint pair<int, int>
#define mp make_pair

using namespace std;

typedef long long ll;



template<typename T>
struct lca {
	int n, l;
	int root;
	vector< vector<int> > to;
	vector< vector<T> > co;
	vector<int> dep;
	vector<T> depco;
	vector< vector<int> > par;

	lca(int n) : n(n), to(n), co(n), dep(n), depco(n) {
		l = 0;
		while ((1 << l) < n) l++;
		par = vector<vector<int>>(n + 1, vector<int>(l, n));
	}

	void addEdge(int a, int b, T c = 0) {
		to[a].push_back(b);
		to[b].push_back(a);

		co[a].push_back(c);
		co[b].push_back(c);
	}

	void dfs(int now, int d = 0, T c = 0, int p = -1) {
		if(p != -1) par[now][0] = p;
		dep[now] = d;
		depco[now] = c;
		for (ll i = 0; i<to[now].size(); i++) {
			int u = to[now][i];
			if (u == p) continue;
			dfs(u, d + 1, c + co[now][i], now);
		}
	}

	void init(int _root = 0) {
		root = _root;
		dfs(root);
		for (int i = 0; i< l - 1; i++) {
			for (int j = 0; j<n; j++) {
				par[j][i + 1] = par[par[j][i]][i];
			}
		}
	}

	int getLca(int a, int b) {
		if (dep[a] > dep[b]) swap(a, b);
		int gap = dep[b] - dep[a];
		for (int i = l - 1; i >= 0; i--) {
			int len = 1 << i;
			if (len <= gap) {
				b = par[b][i];
				gap -= len;
			}
		}
		if (a == b) return a;
		for (int i = l-1; i >= 0; i--) {
			if (par[a][i] != par[b][i]) {
				a = par[a][i];
				b = par[b][i];
			}
		}

		return par[a][0];
	}

	int length(int a, int b) {
		int c = getLca(a, b);
		return dep[a] + dep[b] - 2 * dep[c];
	}
	int dist(int a, int b) {
		int c = getLca(a, b);
		return depco[a] + depco[b] - 2 * depco[c];
	}
};


const int MX = 100005;
struct Edge {
	int to, co, col;
	Edge(int to, int co, int col) :to(to), co(co), col(col) {}
};
vector<Edge> es[MX];

vector<ll> ans;
struct Querry {
	int col, qid, y, coeff;
	Querry(int col, int qid, int y, int coeff) :col(col), qid(qid), y(y), coeff(coeff) {}
};
vector<Querry> qs[MX];
int cnt[MX];
ll sum[MX];

void dfs2(int v, int p = -1) {
	for (auto q : qs[v]) {
		ll x = -sum[q.col];
		x += (ll)q.y * cnt[q.col];
		ans[q.qid] += x*q.coeff;
	}
	for (auto e : es[v]) {
		if (e.to == p) continue;
		cnt[e.col]++; sum[e.col] += e.co;
		dfs2(e.to, v);
		cnt[e.col]--; sum[e.col] -= e.co;
	}
}

int main() {
	int n, q;
	cin >> n >> q;
	lca<ll> g(n);
	for (int i = 0; i<n - 1; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--; b--;
		es[a].emplace_back(b, d, c);
		es[b].emplace_back(a, d, c);
		g.addEdge(a, b, d);
	}
	g.init();
	ans = vector<ll>(q);
	for (int i = 0; i<q; i++) {
		int x, y, u, v;
		cin >> x >> y >> u >> v;
		u--; v--;
		int c = g.getLca(u, v);
		ans[i] = g.depco[u] + g.depco[v] - 2 * g.depco[c];
		qs[u].emplace_back(x, i, y, 1);
		qs[v].emplace_back(x, i, y, 1);
		qs[c].emplace_back(x, i, y, -2);
	}
	dfs2(0);
	for (int i = 0; i<q; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 44660
'use strict';
console.log(function(args){
  const tmp = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0) );
  const N = tmp[0][0], Q = tmp[0][1];
  const ki = Array(N+1).fill(0).map(_=>[]);
  for ( let i = 0; i < N-1; i++ ) {
    const a = tmp[i+1][0];
    const b = tmp[i+1][1];
    ki[a].push(b);
    ki[b].push(a);
  }
  const counter = Array(N+1).fill(0);
  for ( let j = 0; j < Q; j++ ) {
    const p = tmp[j+N][0];
    const x = tmp[j+N][1];
    counter[p] += x;
  }
  const queue = [1], done = Array(N).fill(false);
  let i = 0;
  done[1] = true;
  do {
    let q = queue[i++];
    for ( let child of ki[q] ) {
      if ( done[child] ) continue;
      counter[child] += counter[q];
      queue.push(child);
      done[child] = true;
    };
  } while( i < N );
  return counter.slice(1).join(' ');
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 167544
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }
    let mut dp = vec![0; k + 1];
    dp[0] = 0;
    for i in 1 .. k + 1 {
        let mut winning = 0;
        for &a in a.iter() {
            if a <= i && dp[i - a] == 0 {
                winning = 1;
                break;
            }
        }
        dp[i] = winning;
    }
    puts!("{}\n", ["Second", "First"][dp[k]]);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

template<typename T>
void print_old(vector<T>vec){
    for(int i=0; i< vec.size(); i++)
      cout<< vec[i]<<" ";
}
//  prints any type which supports iterators...
template <class T>
void print(T& c){
   for( typename T::iterator i = c.begin(); i != c.end(); i++ ){
      std::cout << *i << " ";
   }
   cout<< "\n";
}
// void f(const vector< int >& v) {
// int r = 0;
// tr(v, it) {
// r += (it)(*it);
// }
// return r;
// }
typedef vector< int > vi;
typedef pair< int,int > pii;
typedef vector<string> vs;
typedef vector<vi> vv;
#define sz(a) int((a).size())
#define pb push_back
#define forn(n) for(int i =0 ; i< n; i++)
#define all(c) c.begin(), c.end()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define ll long long
const int inf = 1e9 +5;


int main(){
    fastio;
   //  int t;
   //  cin>> t;
   int t = 1;
    while(t--){
     int n, k;
      cin >> n >> k;
      vector<int> vec(n);
      vector<int> cost(n, inf);
      // int temp;
      // for(int i = 0;i < n; i++){
      //    cin >> temp;
      //    vec.pb(temp);
      // }


     for(int & x : vec){
        cin >> x;
     }
      cost[0] = 0;
    
      for(int i = 0; i < n; ++i){
         for(int j = 1; j<= k; j++){
            if(j+i < n){
               cost[j+i] = min(cost[j+i], cost[i] + abs(vec[i] - vec[i+j]));
            }
         }
      }
      // print(cost);
      cout<< cost[n-1] <<"\n";

       
        
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAXN = 1000002;
const int MOD = 998244353;
const int MOD2 = 1000000007; 
const int INF = 1e8;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
#define fill(x,y) memset(x,y,sizeof(x))
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
ll fastpow(ll n,ll x)
{   
	if(x==0)
	return 1 ;
	if(x%2==0)
	return (fastpow(n*n%MOD2,x/2)%MOD2) ;
	return (x*fastpow(n*n%MOD2,(x-1)/2)%MOD2)%MOD2 ; 
}

int main(int argc, char** argv)
{   sws ;

   // tcase
    {
    	ll n,k ;
    	cin>>n>>k ;
    	ll a[n] ;
    	forn(i,n)
    	cin>>a[i] ;
    	ll dp[n];
    	forn(i,n)
    	dp[i]=10000000000007 ;
    	dp[0]=0 ;
    	for(int i=1; i<n;i++)
    	{
    		for(int j=i-1;j>=0&&j>=i-k;j--)
    		{
    			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j])) ;
			}
		}
		cout<<dp[n-1] ;
   
}

return 0 ;
}

Measured memory_bytes: 5128
s = raw_input()
c = len(s)
l = 0
was_es = True
for i in xrange(len(s)):
    if s[i] == "S":
        if was_es == True:
            l += 1
        was_es = True
    else:
        if l > 0:
            l -= 1
            c -= 2
print c

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


signed main(){
    int A, B;
    cin >> A >> B;
    if((A + B) % 2 == 0){
        PRINT((A + B) / 2);
    }else{
        PRINT("IMPOSSIBLE");
    }
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc110/tasks/abc110_d

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")
#define ITR(c,it)  for(auto it = c.begin(); it != c.end(); it++)

//------------------------------------------------------------------------------
map<int, int> prime_factor(int n) {
  map<int, int> res;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) {
        res[i]++;
        n /= i;
      }
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}

//------------------------------------------------------------------------------
ll mod_pow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

ll mod_inverse(ll x, ll mod) {
  return mod_pow(x, mod - 2, mod);
}

ll mod_comb(ll n, ll k, ll mod) {
  if (n < 0 || k < 0 || n < k) return 0;
  ll a = 1, b = 1;
  while(k > 0) {
    a = a * n-- % mod;
    b = b * k-- % mod;
  }
  return a * mod_inverse(b, mod) % mod;
}

//------------------------------------------------------------------------------
const int N_MAX = 1e5;
const int M_MAX = 1e9;
const int MOD = 1e9+7;

int N, M;

void solve() {
  map<int, int> pd = prime_factor(M);
  ll ans = 1;

  ITR(pd, it) {
    ans = ans * mod_comb(N + it->second - 1, it->second, MOD) % MOD;
  }

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

void input() {
  scanf("%d%d", &N, &M);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200000)
readline = sys.stdin.buffer.readline


def dfs(C, h, w):
    # 一度訪ねた陸地は'0'(海)に置き換える
    C[h][w] = '0'
    for i in range(-1, 2):
        for j in range(-1, 2):
            if 0 <= h+i < len(C) and 0 <= w+j < len(C[0]) and C[h+i][w+j] == '1':
                dfs(C, h+i, w+j)


W, H = 1, 1
while W != 0 or H != 0:
    W, H = map(int, input().split())
    C = []
    for h in range(H):
        c = list(input().split())
        #c = readline().split()
        C.append(c)

    count = 0
    for h in range(H):
        for w in range(W):
            if C[h][w] == '1':
                dfs(C, h, w)
                count += 1
    if W != 0 or H != 0:
        print(count)


Measured memory_bytes: 8000
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1e16
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b,ll m){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a) % m;  a = (a * a) % m;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e4 + 3;
ll a,b,c;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a>>b>>c;
    cout<<min(a + b, min(a + c, b + c));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n, m;
  int a, buf = 0;
  ll ans = 0;
  map<int, int> d;
  cin >> n >> m;
  d[0]++;
  for(int i=0;i<n;i++){
    cin >> a;
    buf = (a + buf) % m; 
    d[buf]++;
  }
  for(map<int, int>::iterator iter = d.begin();iter !=d.end();iter++){
    ll cnt = iter->second;
    ans += (cnt * (cnt - 1)) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3200
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 60;

string s[N];
int t[N];

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> s[i] >> t[i];
	}
	string x; cin >> x;
	int ans = 0;
	bool seen = false;
	for (int i = 1; i <= n; ++i) {
		if (seen) {
			ans += t[i];
		}
		if (s[i] == x) {
			seen = true;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e6 + 100;
int n, x, ans, maxx, res, i, j, num[N];
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	cin >> n >> ans;
	num[ans]++;
	for (i = 2; i <= n; i++) {
		cin >> x;
		num[x]++;
		maxx = max(maxx, x);
		ans = gcd(ans, x);
	}
	if (ans != 1) cout << "not coprime\n";
	else {
		for (i = 2; i <= maxx; i++) {
			for (j = i, res = 0; j <= maxx; j += i) res += num[j];
			if (res > 1) {
				cout << "setwise coprime";
				return 0;
			}
		}
		cout << "pairwise coprime\n";
	}
	return 0; 
}


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

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

Measured memory_bytes: 3100
import math

a, b, h, m = map(int, input().split())
angle = min(abs(30 * h - 5.5 * m), 360 - abs(30 * h - 5.5 * m))
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(angle))))

Measured memory_bytes: 62508
#include <stdio.h>
#include <string.h>

int n;
char arr[10000][11];
int l[10000];
int type[3];

int main()
{
	scanf("%d", &n);
	int ans = 0;

	for (int i = 0; i < n; i++)
	{
		scanf("%s", arr[i]);
		l[i] = strlen(arr[i]);

		for (int j = 0; j < l[i] - 1; j++)
		{
			if (arr[i][j] == 'A' && arr[i][j + 1] == 'B')
				ans++;
		}
		if (arr[i][0] == 'B')
		{
			if (arr[i][l[i] - 1] == 'A')
				type[2]++;
			else
				type[1]++;
		}
		else if (arr[i][l[i] - 1] == 'A')
		{
			type[0]++;
		}
	}

	if (type[1] > 0 && type[0] > 0)
	{
		ans += type[2] + 1;
		type[0]--;
		type[1]--;
	}
	else if (type[1] == 0 && type[0] == 0)
	{
		if(type[2] != 0)
			ans += type[2] - 1;
	}
	else if (type[1] == 0)
	{
		ans += type[2];
		type[0]--;
	}
	else
	{
		ans += type[2];
		type[1]--;
	}

	int temp = type[0] > type[1] ? type[1] : type[0];
	ans += temp;
	

	printf("%d", ans);
	

	return 0;
}

Measured memory_bytes: 256