akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<ll> enum_div(ll n) {
    std::vector<ll> ret;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    string S;
    cin >> N >> S;

    int l = 0;
    int r = count(ALL(S), '.');
    int ans = r;
    REP(i, N) {
        if (S[i] == '.') {
            r--;
        } else {
            l++;
        }
        chmin(ans, r + l);
    }

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

Measured memory_bytes: 720
import math

def solve(n):
    n = n+1
    ans = 0
    for i in range(1,n):
        for j in range(1,n):
            tmp = math.gcd(i, j)
            for k in range(1,n):
                ans += math.gcd(tmp, k)
    return ans

def main():
    k = int(input())
    print(solve(k))

if __name__ == '__main__':
    main()


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



int main() {
    int64_t a,b,c,d;
    vector<int64_t> ans(4);
    cin >> a >> b >> c >>d;
    ans.at(0)=a*c;
    ans.at(1)=a*d;
    ans.at(2)=b*c;
    ans.at(3)=b*d;
    int64_t max = *std::max_element(ans.begin(), ans.end());
    cout <<max<<endl;

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int64_t lcm(int64_t a, int64_t b) {
    return (a / __gcd(a, b) * b);
}

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

    vector<int64_t> t(n);
    int64_t max_time = 1;
    for (auto i = 0; i < n; i++) {
        cin >> t[i];
        max_time = lcm(max_time, t[i]);
    }

    cout << max_time << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static string ABCD;
    static void input()
    {
        cin = new Scanner();
        ABCD = cin.next();
    }
    static void solve()
    {
        input();
        int n = 1 << 3;
        for(int i = 0; i <= n; i++)
        {
            int v = int.Parse(ABCD[0].ToString());
            for(int j = 0; j < 3; j++)
            {
                if (((i >> j) & 1) == 1)
                    v += int.Parse(ABCD[j + 1].ToString());
                else
                    v -= int.Parse(ABCD[j + 1].ToString());
            }
            if(v == 7)
            {
                string ans = ABCD[0].ToString();
                for(int j = 0; j < 3; j++)
                {
                    if (((i >> j) & 1) == 1)
                        ans += "+" + ABCD[j + 1].ToString();
                    else
                        ans += "-" + ABCD[j + 1].ToString();
                }
                ans += "=7";
                WriteLine(ans);
                return;
            }
        }
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

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

        public long nextLong()
        {
            return long.Parse(next());
        }

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

        public double nextDouble()
        {
            return double.Parse(next());
        }

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

Measured memory_bytes: 11092
#!/usr/bin/env python3
import sys
from bisect import bisect_right

def main():
    N, M = map(int, input().split())
    P = [None] * M
    Y = [None] * M
    ans = [set() for _ in range(N)]
    for i in range(M):
        p, y = map(int, input().split())
        P[i], Y[i] = p, y
        ans[p-1].add(y)
    ans = [sorted(a) for a in ans]
    
    for i in range(M):
        k = P[i]
        j = bisect_right(ans[k-1],Y[i])
        print(str(k).zfill(6)[-6:] + str(j).zfill(6)[-6:])


if __name__ == '__main__':
    main()


Measured memory_bytes: 47572
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#define maxn 1010
#define INF 0x3f3f3f3f
#define LL long long
#define ULL unsigned long long
#define E 1e-8
#define mod 1000000007
#define P pair<int,int>
using namespace std;

int dis[15];
int n,k;

int judge(int x){
    while(x>0){
        int flag = x%10;
        for(int i=1;i<=k;++i){
            if(flag == dis[i])
                return 0;
        }
        x /= 10;
    }
    return 1;
}
int main()
{
    while(scanf("%d %d",&n,&k)!=EOF){
        int ans;
        for(int i=1;i<=k;++i){
            scanf("%d",&dis[i]);
        }
        for(int i=n;i<=100000000;++i){
            if(judge(i)==1){
                ans = i;
                break;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

vector<vector<int>> graph;
ll ans = 0;
int N, M;

void dfs(int node, set<int> visited) {
  dump(node, visited);
  if(visited.size() == N - 1) {
    ans++;
  }
  dump(next_cnt);
  for(auto next : graph[node]) {
    if(visited.find(next) == visited.end()) {
      visited.insert(node);
      dfs(next, visited);
    }
  }
}

int main() {
  cin >> N >> M;
  graph = vector<vector<int>>(N, vector<int>());
  REP(i, M) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  dfs(0, set<int>());
  cout << ans << endl;
}


Measured memory_bytes: 256
package main
import (
    "fmt"
    "math"
)
func main(){
    minTime, human := 1000000000000000.0, 0.0
    fmt.Scan(&human)
    for i, time:=0, 0.0; i<5; i++{
        fmt.Scan(&time)
        if minTime > time{
            minTime = time
        }
    }
    fmt.Println(int(4 + math.Ceil(human/minTime)))
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>

#define N 100000
#define T 1000000000
#define A 1000000000

#define CONS 1000000007
#define MULT(x,y) (((x%CONS)*(y%CONS))%CONS)
#define MIN(x,y) ((x<y)?x:y)
#define llint long long int

int main(void){
  int n;
  int t[N];
  int a[N];

  llint count = 1;

  std::cin >> n;
  for(int i=0; i<n; i++){
    std::cin >> t[i];
  }
  for(int i=0; i<n; i++){
    std::cin >> a[i];
  }


  bool change[N];
  for(int i=0; i<n; i++){
    if(i==0 || t[i-1]!=t[i]){
      change[i] = true;
      if(t[i]>a[i]) count = 0;
    }else if(i==n-1 || a[i]!=a[i+1]){
      change[i] = true;
      if(a[i]>t[i]) count = 0;
    }
  }

  if(count == 0){
    std::cout << count << std::endl;
    return 0;
  }

  for(int i=0; i<n; i++){
    if(change[i]==false){
      count = MULT(count, MIN(t[i],a[i]));
    }
  }

  std::cout << count << std::endl;
  
  return 0;
}

Measured memory_bytes: 1152
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	const s = input.split("\n")[0];
  
  	const nextSunday = {
      "SUN": 7,
      "MON": 6,
      "TUE": 5,
      "WED": 4,
      "THU": 3,
      "FRI": 2,
      "SAT": 1,
    };
	//出力
	console.log('%d',nextSunday[s]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	ote(min({a,b}) + min({c,d}));
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) a[i] = sc.nextLong();
		long ans = 0;
		for(int i = 0 ; i < n ; i++) {
			ans += a[i] - 1;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 24556
#include<bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
double PI=acos(-1);
ll n,w,weight[105],value[105];
ll dp[105][100005];
ll inf=1e18;

int main(){
    IO
    cin>>n>>w;
    int ans;
    for(int i=0;i<105;i++){
        for(int j=0;j<100005;j++) dp[i][j]=inf;
    }
    for(int i=1;i<n+1;i++) cin>>weight[i]>>value[i];
    for(int i=1;i<n+1;i++){
        for(int j=1;j<=100000;j++){
             if(j-value[i]<=0) dp[i][j]=min(weight[i],dp[i-1][j]);
             else dp[i][j]=min(dp[i-1][j],dp[i-1][j-value[i]]+weight[i]);
        }
    }
    for(int i=1;i<=100000;i++){
        if(dp[n][i]<=w) ans=i;
    }
    /*for(int i=1;i<=n;i++){
        for(int j=1;j<=100000;j++){
            if(dp[i][j]<inf)cout<<dp[i][j]<<" ";
        }
        cout<<'\n';
    }*/
    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 85716
#include <iostream>
#include <string>

int main(){
	int n;
	std::string msg;
	std::cin >> n;

	switch(n){
		case 22:
			msg = "Christmas Eve Eve Eve";
			break;
		case 23:
			msg = "Christmas Eve Eve";
			break;
		case 24:
			msg = "Christmas Eve";
			break;
		case 25:
			msg = "Christmas";
			break;
		}
	std::cout << msg << std::endl;

	return 0;
}

Measured memory_bytes: 256
# python template for atcoder1
from functools import reduce
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def gcd(a, b):
    """
    return gcd of a,b
    ユークリッド
    """
    while b:
        a, b = b, a % b
    return a


def list_gcd(l):
    """
    l: list
    l のgcd を返す
    """
    return reduce(gcd, l)


def lcm(a, b):
    """
    a,bの最小公倍数
    """
    return a*b//gcd(a, b)


def list_lcm(l):
    """
    l:list
    lのlcmを返す
    """
    return reduce(lcm, l)


n = int(input())
l = list(map(int, input().split()))
print(list_lcm(l))



Measured memory_bytes: 6284
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli h,w,ans;
    cin>>h>>w;
    if(h==1||w==1){
        ans=1;
    }
    else{
        if((h*w)%2==0){
            ans=(h*w)/2;
        }
        else{
            ans=(h*w+1)/2;
        }
    }
    out(ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#define BMI(weight,height) (weight/height)/height
int main(){
    int num;
    double weight,height;
    while (scanf("%d,%lf,%lf",&num,&weight,&height) != EOF){
        if (BMI(weight,height) >= 25) {
            printf("%d\n",num);
        }
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    char a; cin >> a;

    int t = a - 'a';

    if (0 <= t && t <= 26) {
        puts("a");
    } else {
        puts("A");
    }
}

Measured memory_bytes: 3564
n = int(input())
rList = [int(input()) for i in range(n)]
minR = rList[0]
maxDiff = -10**9
for i in range(1, n):
    maxDiff = max(maxDiff, rList[i] - minR)
    minR = min(minR, rList[i])
print(maxDiff)



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 1e9;
const LL LLINF = 1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

LL X[2'000000];

void solve()
{
    int N, K; cin >> N >> K;


    REP0(i, N)  cin >> X[i];

    LL ans = LLINF;

    REP0(i, N-K+1)
    {
        int L = i; int R = i + K - 1;

        if (X[L] <= 0 && 0 <= X[R])
        {
            LL way1 = max(-X[L], X[R]);
            LL way2 = min(-X[L], X[R]);
            ans = min(ans, way1 + 2*way2);
        }
        else
        {
            ans = min(ans, max( abs(X[L]), abs(X[R]) ) );
        }
    }

    cout << ans << endl;

}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 1024
x,y,z=map(int,input().split())
if x > y:
    if y > z or y == z:
        print(z, y, x)
    elif y < z:
        print(y, z, x)
elif x < y:
    if y < z or y == z:
        print(x, y, z)
    elif y > z or y == z:
        print(x, z, y)
elif z < x:
    if x < y or x == y:
        print(z, x, y)
    elif x > y or x == y:
        print(z, y, x)


Measured memory_bytes: 5596
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	a, b = IN()
	for i in range(1, 30000):
		if int(i * 0.08) == a and int(i * 0.10)==b:
			return i
		
	return -1
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

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

        int numEven = k / 2;
        int numOdd = (k + 1) / 2;

        int ans = numEven * numOdd;

        System.out.println(ans);
    }

}


Measured memory_bytes: 23764
N,M,X = map(int, input().split())
A = list(map(int, input().split()))
#初期化
L = [0]*(N+1)
for i in range(M):
  L[A[i]] = 1
#分断
left = L[:X]
right = L[X:]

print(min(sum(left), sum(right)))
  

Measured memory_bytes: 9072
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <set>
#include <string>

int main() {
  intmax_t n, a, b;
  scanf("%jd %jd %jd", &n, &a, &b);

  intmax_t res = n / (a+b) * a;
  res += std::min(n % (a+b), a);
  printf("%jd\n", res);
}


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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

void solve(std::string s){
  int n = s.size();
  cout << s[0] << n - 2 << s[n - 1] << endl;
}

int main() {
  std::string s;
    std::cin >> s;
  solve(s);
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k,t=0,w=0,s=0;
    cin>>n>>k;
    vector<ll> a(n),nx(n);
    vector<vector<ll>> b(200001);
    fr(i,n) cin>>a[i],b[a[i]].emplace_back(i);
    Fr(i,200000) fr(j,b[i].size()) nx[b[i][j]]=b[i][(j+1)%b[i].size()];
    while(1){
        if(w==n) break;
        t+=nx[w]+1-w;
        if(nx[w]<=w) t+=n;
        w=nx[w]+1;
    }
    t/=n;
    k%=t;
    w=0;
    while(1){
        if(s+nx[w]+1-w+(nx[w]<=w)*n>k*n) break;
        s+=nx[w]+1-w;
        if(nx[w]<=w) s+=n;
        w=nx[w]+1;
    }
    if(s==k*n) return 0;
    for(;w<n;++w){
        if(nx[w]<=w) cout<<a[w]<<" ";
        else w=nx[w];
    }/*
    vector<ll> ans;
    vector<bool> vis(200001);
    for(;w<n;++w){
        if(vis[a[w]]){
            while(*ans.rbegin()!=a[w]) ans.pop_back();
            ans.pop_back();
        }
        else ans.emplace_back(a[w]),vis[a[w]]=1;
    }
    for(auto i:ans) cout<<i<<" ";*/
    cout<<endl;
}

Measured memory_bytes: 17152
from fractions import gcd
import math

mod = 998244353

def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft

def S(x1, y1, x2, y2, x3, y3):
    return heron(math.sqrt((x1 - x2)**2 + (y1 - y2)**2), math.sqrt((x1 - x3)**2 + (y1 - y3)**2), math.sqrt((x3 - x2)**2 + (y3 - y2)**2))

def heron(a, b, c):
    try:
        d = (a + b + c) / 2
        return round(math.sqrt(d * (d - a) * (d - b) * (d - c)) * 2)
    except Exception as e:
        return 0

def main():
    a, b, c = map(int, input().split())
    a -= b
    c -= a
    print(max(0, c))
main()


Measured memory_bytes: 5684
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl


int main(){
	int a,b;
	double x=0,y=0;
	double rad=M_PI/2.0;
	while(true){
		scanf("%d,%d", &a, &b);
		if(a==b && a==0)break;
		x+=(double)a*cos(rad);
		y+=(double)a*sin(rad);
		rad-=(double)b/180.0*M_PI;
	}
	cout<<(x>0?(int)(floor(x)):(int)(floor(x))+1)<<endl;
		cout<<(y>0?(int)(floor(y)):(int)(floor(y))+1)<<endl;
	
	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(c) (c).begin(), (c).end()
#define P pair<int, int>
#define chmin(x, y) x = min(x, y)

int main()
{
  ll n, x, m;
  cin >> n >> x >> m;
  vector<int> a;
  map<int, int> mp;
  int cnt = 0;
  ll tot = 0;
  while (mp.count(x) == 0)
  {
    a.push_back(x);
    mp[x] = cnt;
    cnt++;
    tot += x;
    x = x * x % m;
  }
  if (n <= cnt)
  {
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
      ans += a[i];
    }
    cout << ans << endl;
    return 0;
  }
  ll ans = tot;
  ll s = 0; // 1ループの数値和
  for (int i = mp[x]; i < cnt; i++)
  {
    s += a[i];
  }
  ll t = cnt - mp[x];   // 1ループの長さ
  ll u = (n - cnt) / t; // ループの周回数
  ans += s * u;
  for (int i = mp[x]; i < n - (u + 1) * t; i++)
  {
    ans += a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 5868
import java.util.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().run();
	}
	void run(){
		new AOJ1135();
	}
	
	class AOJ1135{
		AOJ1135(){
			int n=sc.nextInt();
			while(--n>=0)	solve();
		}
		void solve(){
			int m=sc.nextInt(),y=sc.nextInt(),n=sc.nextInt(),ans=0;
			while(--n>=0){
				int a=sc.nextInt();
				double rate = sc.nextDouble();
				int b=sc.nextInt();
				if(a==0){
					int mm=m,c=0;
					for(int i=0; i<y; ++i){
						c += (double)mm*rate;
						mm-=b;
					}
					ans=max(ans, mm+c);
				}else{
					int mm=m;
					for(int i=0; i<y; ++i){
						mm+=(double)mm*rate;
						mm-=b;
					}
					ans=max(ans, mm);
				}
			}
			System.out.println(ans);
		}
	}
	
	

}

Measured memory_bytes: 41708
N,T = gets.split.map(&:to_i)
c = Array.new
t = Array.new
for i in 0..N-1
    c[i],t[i] = gets.split.map(&:to_i)
    if t[i] > T 
        c[i] += 1000
    end
end

if c.min > 1000
    puts 'TLE'
else
    puts c.min
end


Measured memory_bytes: 1916
using System;
using System.Text;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
   string S=Console.ReadLine();
   string T=Console.ReadLine();
      string str="";
      int N=S.Length;
      bool flg=false;
      for(int i=0;i<N;i++){
       str=S.Substring(1)+S.Substring(0,1);
        S=str;
        if(S==T){
          flg=true;
          break;
        }
      }
 if(flg){
   Console.WriteLine("Yes");
 }else{
   Console.WriteLine("No");
 }
      
    }
  }
}

Measured memory_bytes: 25836
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define f first
#define s second
 
const int N = 400 + 10;
const int mod = 1000 * 1000 * 1000 + 7;
const ll inf = 1e18;

ll dp[N][N];
ll dis[N][N];
set<pair<ll, int>> s;
vector<pair<int, int>> adj[N];
	
	
int n, m, l;
void dij(int u)
{
	for(int i = 0; i < n; i++)
	{
		dis[u][i] = inf;
	}
	dis[u][u] = 0;
	for(int i = 0; i < n; i++)	
		s.insert({dis[u][i], i});
		
	while(!s.empty())
	{
		int x = s.begin()->s;
		s.erase(s.begin());
		for(int i = 0; i < adj[x].size(); i++)
		{	
			int v = adj[x][i].f, w = adj[x][i].s;
			if(dis[u][v] > dis[u][x] + w)
			{
				s.erase({dis[u][v], v});
				dis[u][v] = dis[u][x] + w;
				s.insert({dis[u][v], v});
			}
		}
	}
		

}	
	

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

	cin >> n >> m >> l;
	for(int i = 0; i < m; i++)
	{
		int x, y, w;
		cin >> x >> y >> w;
		x--; y--;
		adj[x].push_back({y, w});
		adj[y].push_back({x, w});
	}
	for(int i = 0; i < n; i++)
		dij(i);
		
		
	
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(dis[i][j] <= l)
				dp[i][j] = 0;
			else
				dp[i][j] = inf;
		}
	}
	
	
	for(int k = 0; k < n; k++)
	{	
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < n; j++)
			{
				dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]+1);		
			}
		}
	}


	int q;
	cin >> q;
	while(q--)
	{
		int x, y;
		cin >> x >> y;
		x--; y--;
		if(dp[x][y] == inf)
			cout << -1 << endl;
		else
			cout << dp[x][y] << endl;
	}
	
	
    return 0;
}
 
 
 



Measured memory_bytes: 3584
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int sum[405][405],dp[405][405],n; 
int dfs(int l,int r){
	if(dp[l][r]!=-1)RE dp[l][r];
	if(l==r)RE dp[l][r]=0;
	int re=dfs(l,l)+dfs(l+1,r);
	rep(i,l+1,r)gmin(re,dfs(l,i)+dfs(i+1,r));
	RE dp[l][r]=re+sum[l][r];
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a[405];
	cin>>n;
	FOR(i,1,n)cin>>a[i];
	FOR(i,1,n){
		sum[i][i]=a[i];
		FOR(j,i+1,n)sum[i][j]=sum[i][j-1]+a[j];
	}
	FILL(dp,-1);
	cout<<dfs(1,n)<<'\n';
	RE 0;
}




Measured memory_bytes: 2816
l, r = gets.split.map(&:to_i)
ans = -1

d = 0
while d <= 2019 && l + d <= r
  if (l + d) % 2019 == 0
    ans = 0
    break
  end
  d += 1
end

if ans == 0
  puts ans
else
  ansmin = 2019
  for i in l..r
    for j in (i+1)..r
      if ansmin > (i * j) % 2019
        ansmin = (i * j) % 2019
      end
    end
  end
  puts ansmin
end  

Measured memory_bytes: 1788
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())

K = int(input())
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(l[K-1])


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

#define mod 1000000007

int main() {
	// your code goes here
	
	ios_base :: sync_with_stdio(0);
	
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	}
	int sum=a[0];
	for(int i=1;i<n;i++)
	sum=sum^a[i];
	
	
	if(sum==0)
	cout<<"Yes";
	else
	cout<<"No";
	
	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
const int mod = 1e9 + 7, inf = 1e16;
 
int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n & 1) return (x * modpow(x * x % mod, n / 2) % mod + mod) % mod;
	return (modpow(x * x % mod, n / 2) + mod) % mod;
}
 
int fact(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= (i + 1);
		ans %= mod;
	}
	return (ans + mod) % mod;
}
 
int comb(int n, int r) {
	if (n < r) swap(n, r);
	if (n - r < r) r = n - r;
	return fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) % mod;
}
 
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
 
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
 
bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

int n, m, ans, cnt;
P p[114514];
signed main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> p[i].second >> p[i].first;
	}
	sort(p, p + m);
	rep(i, m) {
		if(p[i].second >= cnt) {
			ans++; cnt = p[i].first;
		}
	}
	cout << ans << endl;
}


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


int main(){
	int e;
	int tri[101];
	for(int i=0;i<=100;i++)tri[i]=i*i*i;
	int db[1001];
	for(int i=0;i<=1000;i++)db[i]=i*i;
	
	while(cin>>e,e){
		int ans=e;
		for(int i=100;i>=0;i--){
			for(int j=1000;j>=0;j--){
				int t=tri[i]+db[j];
				if(e>=t){
					ans=min(ans,e-t+i+j);
				}
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1160
import itertools

n=int(input())
s=list(input())
a=s.count('#')
b=0
ans=a

for i in range(1,n+1):
    if s[-i]=='.':
        b+=1
    else:
        a-=1
        
    ans=min(a+b,ans)
print(ans)


    

    
        
        
        
    
                
    
        

     

    

     

    


Measured memory_bytes: 61424
N = int(input())
numbers = list(map(int, input().split()))
canDevide = True
count = 0;
while canDevide :
  for i in range(N) :
    if numbers[i]%2 == 0 :
      numbers[i] /= 2
    else :
      canDevide = False
      break
  if canDevide :
    count += 1
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int a,b;
    cin >> a >> b;
    bool ans = false;
    rep(i,a+1)rep(j,b+1){
        if(i+j == a && i*2+j*4 == b){
            ans = true;
        }
    }
    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3588
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

using vi = vector<int>;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define show(x) cout << #x << " = " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define YesNo {cout<<"Yes";}else{cout<<"No";}
#define YESNO {cout<<"YES";}else{cout<<"NO";}
#define v(T) vector<T>

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}
template<class T> istream& operator>>(istream& i, v(T)& v) {
  F0R(j, sz(v)) i >> v[j];
  return i;
}
template<class A, class B> istream& operator>>(istream& i, pair<A, B>& p) {
  return i >> p.first >> p.second;
}
template<class A, class B, class C> istream& operator>>(istream& i, tuple<A, B, C>& t) {
  return i >> get<0>(t) >> get<1>(t) >> get<2>(t);
}
template<class T> ostream& operator<<(ostream& o, const vector<T>& v) {
  F0R(i, v.size()) {
    o << v[i] << ' ';
  }
  o << newl;
  return o;
}
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& m) {
  for (auto& p : m) {
    o << p.first << ": " << p.second << newl;
  }
  o << newl;
  return o;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string s;
  cin >> s;
  F0R(i, sz(s)) {
    if (s[i] == '1') s[i] = '9';
    else if (s[i] == '9') s[i] = '1';
  }
  cout << s;
}
#endif


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl;
#define mod 1000000007
#define pb push_back

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	long long n,k;
	cin>>n>>k;
	long long r,s,p;
	cin>>r>>s>>p;

	string t;
	cin>>t;

	long long a[t.size()];
	for(auto &it:a) it=0;
	long long ans = 0;

	for(long long i=0;i<k;i++)
	{
		if(t[i]=='r' )
		{
			a[i] = p;
		}
		else if(t[i]=='s')
		{
			a[i] = r;
		}
		else if(t[i] == 'p')
		{
			a[i] = s;
		}
	}

	for(long long i=k;i<t.size();i++)
	{
		if(t[i]=='r' )
		{
			if(a[i-k] ==0 || t[i-k]!='r') a[i] = p;
		}
		else if(t[i]=='s')
		{
			if(a[i-k] ==0 || t[i-k]!='s') a[i] = r;
		}
		else if(t[i] == 'p')
		{
			if(a[i-k] ==0 || t[i-k]!='p') a[i] = s;
		}
	}

	for(auto it:a) ans+=it;
	cout<<ans<<endl;


} 

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

int main() {
  int n, k;
  cin >> n >> k;
  int a[110];
  int ans = 0;
  rep(i,n) cin >> a[i];
  rep(i,n) ans += min(a[i], k - a[i]) * 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#if 0
date +%Y.%m.%d

观察偶串 SS 变换后的形式，事实上是 STST ，其中 T 是 S 的最小循环节。
那么设 g(S) = ST ，则有 f(SS) = g(S)g(S) ， f^k(SS) = g^k(S)g^k(S) 。
考虑 g^k(S) 的变换过程。

当 |T| | |S| 时，有 g(S) = ST, g^2(S) = STS, g^3(S) = STSST ...
容易得出递推式 g^k(S) = g^{k-1}(S) + g^{k-2}(S) 。

否则，有 g(S) = ST, g^2(S) = STT, g^2(S) = STTT ...
容易得出递推式 g^k(S) = g^{k-1}(S) + T 。

第一种情况下 g^k(S) 的长度增长很快，和斐波那契类似，
因此有用的 g^k(S) 很少，可以预处理出每个 g^k(S) 的字母构成。
假设要求 f..f(S) 的前 n 位，那么找到超过 n/2 的最小 g^k(S) ，
这个 g^k(S) 一定是 f..f(S) 的前半段，统计进去，
剩下的部分长 n - |g^k(S)| ，一定是 f..f(S) 后半段的前缀，即前半段的前缀，转为子问题。
由于每次长度至少减少一半，这样统计的次数是 O(log) 的。

第二种情况下 g^k(S) 长度增长呈等差数列，无法处理，
但是注意到上述算法中并不关心 g^k(S) 具体的 k 是多少，
因此可以按照第一种情况的递推式算，这样每个 g^k(S) 对应的实际上是一个 g^i(S) 满足 i > k 。
而只要 g^k(S) 能对应一个真正的 g^i(S) ，上述的算法就能保证正确性。
#endif
#include <cstdio>
#include <cstring>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long lolong;

inline int input() { int x; scanf("%d", &x); return x; }
inline lolong linput() { lolong x; scanf("%lld", &x); return x; }

const int maxn = 100005, maxk = 26;
struct Val {
	lolong a[maxk];
	lolong len;
	void operator += (Val an) {
		for(int i = 0; i < maxk; i ++)
			a[i] += an.a[i];
		len += an.len;
	}
	Val(): len(0) { memset(a, 0, sizeof a); }
};
char s[maxn << 1];
int fail[maxn];
Val g[100];

void solve(lolong n, Val &ans) {
	/* debug("%lld\n", n); */
	if(n <= g[0].len) {
		for(int i = 1; i <= n; i ++)
			ans.a[s[i] - 'a'] ++;
		ans.len += n;
		return;
	}

	int p = 0;
	while((g[p].len << 1) < n)
		p ++;
	ans += g[p];

	solve(n - g[p].len, ans);
}

int main() {
	scanf("%s", s + 1);
	int n = int(strlen(s + 1)) >> 1;

	fail[0] = -1;
	for(int i = 1; i <= n; i ++) {
		int j = fail[i];
		while(~j and s[j + 1] != s[i + 1])
			j = fail[j];
		fail[i + 1] = j + 1;
	}

	int k = n - fail[n];
	lolong l = linput(), r = linput();

	for(int i = 1; i <= n; i ++)
		g[0].a[s[i] - 'a'] ++;
	g[0].len = n;

	g[1] = g[0];
	for(int i = 1; i <= k; i ++)
		g[1].a[s[i] - 'a'] ++;
	g[1].len = n + k;

	for(int i = 2; (g[i - 1].len << 1) < r; i ++) {
		g[i] = g[i - 1];
		g[i] += g[i - 2];
	}

	Val a, b;
	solve(l - 1, a);
	solve(r, b);
	/* debug("%lld %lld\n", a.len, b.len); */

	for(int i = 0; i < maxk; i ++)
		printf("%lld ", b.a[i] - a.a[i]);
	puts("");
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

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

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b;

    cin >> a >> b;

    if (a == 1 && b == 1) Out("Yes");
    else if ((a == 1 && b == 3) || (a == 3 && b == 1)) Out("Yes");
    else if (a == 3 && b == 3) Out("Yes");
    else Out("No");

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

//20180511
//01

public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		int turn = scanner.nextInt();
		int pointTaro = 0;
		int pointHanako = 0;

		for(int i = 0;i < turn;i++) {
			String taro = scanner.next();
			String hanako = scanner.next();

			if(taro.compareTo(hanako) == 0) {
				pointTaro += 1;
				pointHanako += 1;
			} else if (taro.compareTo(hanako) > 0) {
				pointTaro += 3;
			} else {
				pointHanako += 3;
			}
		}

		System.out.printf("%d %d\n",pointTaro,pointHanako);

		scanner.close();
    }
}


Measured memory_bytes: 32152
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cstdlib>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>
#include <cstring>

using namespace std;

#define ll long long

#ifndef ONLINE_JUDGE
#define debug(format, ...) fprintf(stderr, \
    "%s:%d: " format "\n", __func__, __LINE__,##__VA_ARGS__)
#else
#define debug(format, ...)
#define NDEBUG
#endif

int n, m;

int a[105][105];
bool done[105][105];
int res1[105][105];
int res2[105][105];

bool graph[105][105];

bool vis[105];

/* number row # -> row placed in after step 1 */
int match[105];
int rmatch[105];

bool matching(int lnode)
{
    for (int rnode = 1; rnode <= n; rnode++) {
        if (graph[lnode][rnode] && !vis[rnode]) {
            vis[rnode] = true;
            if (!match[rnode] || matching(match[rnode])) {
                match[rnode] = lnode;
                return true;
            }
        }
    }
    return false;
}

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            scanf("%d", &(a[i][j]));
        }
    }
    for (int col = 1; col <= m; col++) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) graph[i][j] = false;
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (!done[i][j]) {
                    graph[i][(a[i][j] - 1) / m + 1] = true;
                }
            }
        }
        for (int i = 1; i <= n; i++) match[i] = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) vis[j] = false;
            matching(i);
        }
        for (int i = 1; i <= n; i++) {
            rmatch[match[i]] = i;
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if ((a[i][j] - 1) / m + 1 == rmatch[i] && !done[i][j]) {
                    done[i][j] = true; res1[i][col] = a[i][j]; break;
                }
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            printf("%d ", res1[i][j]);
        }
        printf("\n");
    }
    for (int col = 1; col <= m; col++) {
        vector<int> seq;
        for (int i = 1; i <= n; i++) {
            seq.push_back(res1[i][col]);
        }
        sort(seq.begin(), seq.end());
        for (int i = 1; i <= n; i++) {
            res2[i][col] = seq[i-1];
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            printf("%d ", res2[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll MOD=1e9+7;
const ll N=2e5+5;
const ld pi=3.14159265359;
const ll INF=(1LL<<63);
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()

ll t[2],a[2],b[2],A,B;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	REP(i,2)cin>>t[i];
	REP(i,2)cin>>a[i];
	REP(i,2)cin>>b[i];
	A=(a[0]-b[0])*t[0];B=(a[1]-b[1])*t[1];
	if(A>0)A*=-1,B*=-1;
	if(A+B<0)cout<<"0\n";
	else if(A+B==0){
		cout<<"infinity\n";
	}else{
		ll S=-A/(A+B);
		ll T=-A%(A+B);
		if(T!=0){
			cout<<S*2+1<<"\n";
		}else cout<<S*2<<"\n";
	}
	return 0;
}




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

using namespace std;

const int N = 2e5 + 5;

int n, a[N], f[N];
long long k;

bool check (long long mid) {
    long long tot = 0;
    for (int i = 1; i <= n; i++) {
        long long threshold = mid / f[i];
        if (threshold < a[i]) tot += a[i] - threshold;
    }
    
    return tot <= k;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> f[i];
    
    sort(a + 1, a + n + 1);
    sort(f + 1, f + n + 1, greater <int>());
    
    long long l = 0, r = 1e18;
    while (l <= r) {
        long long mid = (l + r) / 2;
        if (check(mid)) r = mid - 1;
        else l = mid + 1;
    }
    
    cout << l;
    return 0;
}

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

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

  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  int alice_score = 0;
  int bob_score   = 0;

  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      alice_score += a.at(i);
    } else {
      bob_score   += a.at(i);
    }
  }
  
  cout << alice_score - bob_score << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  string s;
  cin >> s;
  bool f = false;
  REP(i,s.size()){
    if(s[i] == 'C'){
      for(int j = i;j < s.size();j++){
	if(s[j] == 'F')
	  f = true;
      }
    }
  }
  if(f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256