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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; }}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b; cin >> a >> b;
    cout << lcm(a,b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main(){
    int n,a,b;cin>>n>>a>>b;
    int ans = a*n < b ? a*n : b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define mod 1000000007

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(!(n%10)){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  ll i,N,K,ans=0,a[200000];
  cin>>N>>K;
  while(N<=K){N*=2;ans++;}
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    string s,t,u;
	int a,b;
	cin>>s>>t>>a>>b>>u;
	if(s==u){
      cout<<a-1<<" "<<b;
    }else{
      cout<<a<<" "<<b-1;
    }
	return 0;
}

Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=tf-8
#

"""
"""

from collections import defaultdict
import bisect

import sys
input = sys.stdin.readline

def solve(s,t):
    l = len(t)
    flags = [True]+[False]*3
    tmp = 0
    for i in range(len(s)-l+1):
        tmp2 = 0
        for j in range(l):
            if s[i+j] == t[j]:
                tmp2 += 1
        tmp = max(tmp,tmp2)
    print(l-tmp)

            

def main():
    s = input().rstrip()
    t = input().rstrip()
    solve(s,t)


if __name__ == "__main__":
    main()

Measured memory_bytes: 73560
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<map>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int N=1e5+10;
ll a,b,n,ans=0;
int main()
{
    cin>>a>>b>>n;
    if(n<b)
    {
        cout<<a*n/b<<endl;
    }
    else if(n==b)
    {
        cout<<a*(n-1)/b<<endl;
    }
    else
    {
        cout<<a*(b-1)/b<<endl;
    }
    return 0;
}

Measured memory_bytes: 3568
from itertools import combinations
from bisect import bisect_left
N, K = map(int,input().split())
A = list(map(int,input().split()))

ans=0

for i,j in combinations(range(N+2),2):
  l = sorted(A[0:i]+A[j-1:N])
  if len(l)<=K:
    m = bisect_left(l,0)
    ans = max(ans,sum(l[min(K-len(l),m):]))
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a;
  cin >> b;
  int answer;
  int r = (a + b) % 2;
  if (r == 0) {
    answer = (a + b) / 2;
  } else {
   	answer = (a + b) / 2 + 1;
  }
  cout << answer << endl;
}


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

int main() {
  int D, G;
  cin >> D >> G;
  vector<int> P(D), C(D);
  for (int i = 0; i < D; i++) cin >> P.at(i) >> C.at(i);

  int ans = 1e9;
  for (int bit = 0; bit < 2 << D; bit++) {
    int sum = 0;
    int num = 0;
    for (int i = 0; i < D; i++) {
      if (bit >> i & 1) {
        sum += P.at(i) * (i + 1) * 100 + C.at(i);
        num += P.at(i);
      }
    }
    if (sum >= G) ans = min(ans, num);
    else {
      for (int i = D - 1; i >= 0; i--) {
        if (bit >> i & 1) continue;
        for (int j = 0; j < P.at(i); j++) {
          if (sum >= G) break;
          sum += (i + 1) * 100;
          num++;
        }
      }
      ans = min(ans, num);
    }
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    x, a, b = gets.chomp.split.map(&:to_i)

    xa = (x - a).abs
    xb = (x - b).abs

    if xa < xb
      puts "A"
    else
      puts "B"
    end
  end
end

if __FILE__ == $0
  Solver.new.main
end


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

int main(){
  int w,a,b;
  cin>>w>>a>>b;
  if(max(b-a-w,a-b-w)<=0){
    cout<<0;
  }else{
    cout<<max(b-a-w,a-b-w);
  }
}

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

int main() {
	int n;
	cin >> n;
	vector<int> btn(n);
	for (int i = 0; i < n; i++) cin >> btn.at(i);
	for (int i = 0; i < n; i++) btn.at(i)--;
	vector<int> visit(n, -1);
	int count = 0;
	int now = 0;
	int next = 0;
	for (int i = 0; i < n; i++)
	{
		count++;
		next = btn.at(now);
		if (next == 1)
		{
			cout << count << endl;
			return 0;
		}
		if (visit.at(next) != -1) break;
		visit.at(next) = count;
		now = next;
	}
cout << -1 << endl;
return 0;

}


Measured memory_bytes: 4064
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N, K;
    scan(N, K);
    auto a = readln.split.to!(long[]).sort();

    auto mc = ModComb(N);

    long ans;

    foreach (i ; 0 .. N) {
        ans += a[i] * mc.c(i, K - 1) % mod;
        ans %= mod;
        ans += mod - (a[i] * mc.c(N  - 1 - i, K - 1) % mod);
        ans %= mod;
    }

    writeln(ans);
}


struct ModComb {
    int _N;
    long[] _fact, _factinv;
    long _mod;

    this(int n, long mod = 1_000_000_007L) {
        _N = n;
        _fact = new long[](_N + 1);
        _factinv = new long[](_N + 1);
        _mod = mod;

        _fact[0] = 1;
        foreach (i ; 1 .. _N + 1) {
            _fact[i] = (_fact[i-1] * i) % mod;
        }

        _factinv[_N] = _powmod(_fact[_N], mod - 2);
        foreach_reverse (i ; 0 .. _N) {
            _factinv[i] = (_factinv[i+1] * (i+1)) % mod;
        }
    }

    long c(int n, int k) {
        if (k < 0 || k > n) return 0;
        return f(n) * finv(n - k) % _mod * finv(k) % _mod;
    }

    long p(int n, int r) {
        if (r < 0 || r > n) return 0;
        return f(n) * finv(n - r) % _mod;
    }

    long f(int n) {
        return _fact[n];
    }

    long finv(int n) {
        return _factinv[n];
    }

    long _powmod(long x, long y) {
        return y > 0 ? _powmod(x, y>>1)^^2 % _mod * x^^(y & 1) % _mod : 1;
    }
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 4300
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		//枠の中かチェック
		if(x >= 0 && y >= 0) {
			if((x+r) <= W && (y+r) <= H) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}else {
			System.out.println("No");
		}

		sc.close();
	}

}


Measured memory_bytes: 26432
#include <math.h>
#include <stdio.h>
int main(void)
{
	char a[4], b[4], c[7];
	int	x = 0;
	int	y = 0;
	int i, j;
	if (scanf("%s %s", a, b) == EOF) return(0);
	j = 0;
	for (i = 0; i < 3; i++) {
		if ((a[i] <= 0x39 ) && (a[i] >=  0x30)) {
			c[j] = a[i];
			j++;
		} else break;
	}
	for (i = 0; i < 3; i++) {
		if ((b[i] <= 0x39 ) && (b[i] >=  0x30)) {
			c[j] = b[i];
			j++;
		} else break;
	}
	c[j] = '\0';
	for (i = 0; i < 6; i++) {
		if (c[i] == '\0') break;
		x = x*10 + (c[i] - 0x30);
	}
	y = (int)sqrt(x);
	y *= y;
	if (x == y) 
		printf("Yes\n");
	else	printf("No\n");
	return (0);
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace kozaiyApp
{
    public class DEvenRelation
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var to = new List<int>[N]; // 隣接リスト
            var cost = new List<int>[N]; // 距離リスト

            // 配列の中にリスト作る
            for (int i = 0; i < N; i++)
            {
                to[i] = new List<int>();
                cost[i] = new List<int>();
            }

            // 隣接リスト記入
            for (int i = 0; i < N - 1; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int u = int.Parse(input[0]);
                int v = int.Parse(input[1]);
                int w = int.Parse(input[2]);

                // indexが1はじまりなので
                u -= 1;
                v -= 1;

                to[u].Add(v);
                to[v].Add(u);

                cost[u].Add(w);
                cost[v].Add(w);
            }

            var ans = Enumerable.Repeat<int>(-1, N).ToArray(); // -1で初期化
            var q = new Queue<int>();
            ans[0] = 0;
            q.Enqueue(0);
            while (q.Count > 0) // queueが空になるまで
            {
                int v = q.Peek(); // queueの先頭
                q.Dequeue();

                for (int i = 0; i < to[v].Count; i++) // 隣接している頂点を一つずつ確認
                {
                    int n = to[v][i]; // 隣接頂点の番号
                    int w = cost[v][i]; // 隣接bh頂点との距離

                    if (ans[n] != -1) continue; // すでにきている
                    ans[n] = (ans[v] + w) % 2;
                    q.Enqueue(n);
                }
            }

            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(ans[i]);
            }
        }
    }
}


Measured memory_bytes: 35720
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
    char a, b, c;
    cin >> a >> b >> c;
    if(a == 'R') {
        if(b == 'R') {
            if(c=='R') cout << 3;
            else cout << 2;
        } else {
            cout << 1;
        }
    } else {
        if(b =='R') {
            if(c=='R') cout << 2;
            else cout << 1;
        } else {
            if(c=='R') cout << 1;
            else cout << 0;
        }
    }
    cout << endl;
}


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

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

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

int n, ma, mb, inf = 1e9 + 7, dp[50][410][410];

int main(){
    cin >> n >> ma >> mb;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++){
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
    }
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= 400; j++){
            for (int k = 0; k <= 400; k++){
                dp[i][j][k] = inf;
            }
        }
    }
    dp[0][0][0] = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j <= 400; j++){
            for (int k = 0; k <= 400; k++){
                if (dp[i][j][k] == inf) continue;
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
                dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
            }
        }
    }
    int ans = inf;
    for (int i = 1; i <= 400; i++){
        for (int j = 1; j <= 400; j++){
            if (i * mb == j * ma) ans = min(ans, dp[n][i][j]);
        }
    }
    if (ans == inf) ans = -1;
    printf("%d\n", ans);
}


Measured memory_bytes: 28928
import java.util.*;

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

        long N = sc.nextLong();
        long b = sc.nextLong();
        if (b == 0) {
            System.out.println(0);
            return;
        }
        long r = sc.nextLong();

        long x = N / (r + b);
        long ans = b * x;
        long mod = N % (r + b);
        System.out.println(ans + Math.min(mod, b));
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;
typedef tuple<int, int, int> T;

struct UF {
	int par[200000];
	int sz[200000];
	UF() { for (int i = 0; i < 200000; i++) { par[i] = i; sz[i] = 1; } }
	int root(int x) { if (par[x] == x) return x; return par[x] = root(par[x]); }
	void unit(int x, int y) { x = root(x); y = root(y); if (x != y) { par[x] = y; sz[y] += sz[x]; } }
	bool same(int x, int y) { return root(x) == root(y); }
	int getSz(int x) { return sz[root(x)]; }
};

int n, m, k;
int c[100000];
int a, b, w;
T edges[100000];
UF uf;

signed main() {
	int i;
	
	cin >> n >> m >> k;
	rep(i, n) cin >> c[i];
	rep(i, m) {
		cin >> a >> b >> w;
		a--; b--;
		
		int x = c[a];
		int y = c[b];
		if (c[a] == 0) x = a + n;
		if (c[b] == 0) y = b + n;
		edges[i] = T(w, x, y);
	}
	sort(edges, edges + m);
	
	int ans = 0;
	int cnt = 0;
	rep(i, m) {
		int u = get<1>(edges[i]);
		int v = get<2>(edges[i]);
		int cst = get<0>(edges[i]);
		if (!uf.same(u, v)) {
			uf.unit(u, v);
			ans += cst;
			cnt++;
		}
		if (cnt == k - 1) break;
	}
	if (i == m) { cout << -1 << endl; }
	else { cout << ans << endl; }
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=10;
int n,a[maxn],b[maxn],d[maxn];
int flag,x,y,cnt;
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	for (int i=1;i<=n;i++) read(b[i]),d[i]=i;
	do {
		cnt++;
		flag=1;
		for (int i=1;i<=n;i++) if (d[i]!=a[i]) { flag=0; break; }
		if (flag) x=cnt;
		flag=1;
		for (int i=1;i<=n;i++) if (d[i]!=b[i]) { flag=0; break; }
		if (flag) y=cnt;
	} while (next_permutation(d+1,d+n+1));
	printf("%d\n",abs(x-y));
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 256
n,m,x=map(int,input().split())
a=list(map(int,input().split()))

fee1 = 0
fee2 = 0

for i in range(x+1,n+1):
  if i in a:
    fee1 += 1
    
for i in range(x-1,0,-1):
  if i in a:
    fee2 += 1

print(min(fee1, fee2))

Measured memory_bytes: 38256
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

s_a = [0]
s_b = [0]

(2..n+1).each do |i|
  s_a[i-1] = s_a[i-2] + a[i-2]
  s_b[i-1] = s_b[i-2] + b[i-2]
end

max = -1
(1..n).each do |j|
  candy = (s_a[j] - s_a[0]) + (s_b[n] - s_b[j-1])
  max = candy if candy > max
end

puts max

Measured memory_bytes: 1788
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,ans=0,tmp;
  cin >> n;
  ll a[2][n],asum[n],bsum[n];
  for(int i=0;i<n;i++){
    cin >> a[0][i];
    asum[i] = a[0][i];
  }
  for(int i=0;i<n;i++){
    cin >> a[1][i];
    bsum[i] = a[1][i];
  }
  for(int i=1;i<n;i++){
    asum[i]+=asum[i-1];
    bsum[n-i-1]+=bsum[n-i];
  }
  for(int i=0;i<n;i++){
    ans = max(ans,asum[i]+bsum[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from sys import stdin, stdout
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()

def main():
	N = int(rl())
	ans = 0
	while N:
		N, dig = divmod(N, 10)
		if dig == 7:
			ans = 1
			break
	if ans:
		stdout.write("Yes");stdout.write("\n")
	else:
		stdout.write("No");stdout.write("\n")
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 61936
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

ll llmax(ll a, ll b){
    if(a>b) return a;
    else return b;
}

////////////////////////////////////////////////////////////////////
int main()
{

    int X,Y,Z,K; cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    vector<ll> ans;
    REP(i,X) cin >> A[i];
    REP(i,Y) cin >> B[i];
    REP(i,Z) cin >> C[i];

    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    REP(i,X){
        REP(j,Y){
            REP(k,Z){
                if((i+1)*(j+1)*(k+1) <= K) ans.push_back(A[i]+B[j]+C[k]);
                else break;
            }
        }
    }

    sort(ans.begin(), ans.end(), greater<ll>());
    REP(i,K) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 1404
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
int main()
{

ll n;
cin>>n;
ll dp[2002];
for(ll i=0;i<2002;i++)
dp[i]=0;
dp[0]=1;dp[1]=0;dp[2]=0;

for(ll i=3;i<2002;i++)
{
	for(ll j=i-3;j>=0;j--)
	{
		dp[i]+=(dp[j])%MOD;
		dp[i]=dp[i]%MOD;
	}
}
/*for(ll i=0;i<=n;i++)
cout<<dp[i]<<endl;*/
cout<<dp[n]<<endl;
return 0;
}


Measured memory_bytes: 3600
N = int(input())
abc = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*3 for _ in range(N)]
dp[0][0],dp[0][1],dp[0][2] = abc[0][0],abc[0][1],abc[0][2]

for i in range(1,N):
  for j in range(3):
    for k in range(3):
      if j != k:
        dp[i][k] = max(dp[i][k], dp[i-1][j] + abc[i][k])

ans = max(dp[N-1])
print(ans)

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int a;
    string s;
    cin >> a >> s;

    if (a >= 3200)
    {
        OP(s)
    }
    else
    {
        OP("red")
    }
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
ans = H*W

if H % 3 == 0:
    ans = 0
else:
    ans = min(ans, W)

if W % 3 == 0:
    ans = 0
else:
    ans = min(ans, H)

for i in range(1, H):
    if W % 2 == 0:
        dif = abs(i*W - (H-i)*(W//2))
    else:
        dif = max(i*W, (H-i)*((W//2)+1)) - min(i*W, (H-i)*(W//2))
    ans = min(ans, dif)

for i in range(1, W):
    if H % 2 == 0:
        dif = abs(i*H - (W-i)*(H//2))
    else:
        dif = max(i*H, (W-i)*((H//2)+1)) - min(i*H, (W-i)*(H//2))
    ans = min(ans, dif)

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

ll solve(ll n){
  ll ans=0;
  reps(i,n+1){
    if(n%i==0)ans++;
  }
  return ans;
}



int main()
{

  ll n,ans=0;;
  cin>>n;
  if(n<105){
    cout<<0<<endl;
    return 0;
  }

  for(int i=105;i<=n;i++){
    if(solve(i)==8&&i%2==1)ans++;
  }

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


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll K,ans=0; cin>>K;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int k=1;k<=K;k++){
                ans+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

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


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a, b, c, k, ans = 0;
	cin>>a>>b>>c>>k;


	if(a>=k)
		ans = k;
	else
	{
		ans+=a;
		k-=a;
		if(b>=k)
			ans+=0;
		else
		{
			k-=b;
			if(c>=k)
				ans-=k;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3672
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll a,b,x;
	scanf("%lld%lld%lld",&a,&b,&x);
	if(a)printf("%lld",b/x-(a-1)/x);
	else printf("%lld",b/x+1);
}

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

int main(){
	int n;
	cin>>n;
	vector<int> a;
	for(int i=0;i<n;i++){
	int q,y;
	cin>>q;
	if(q==0){
	cin>>y; a.push_back(y);
	}else if(q==1){
	cin>>y; cout<<a[y]<<endl;
	}else {
	a.pop_back();
	}

	}



	return 0;
}



Measured memory_bytes: 3872
import math


def main():
    n = int(input())
    s = input()

    rs = []
    gs = []
    bs = {}
    for i in range(n):
        if s[i] == "R":
            rs.append(i)
        elif s[i] == "G":
            gs.append(i)
        else:
            bs.setdefault(i, 1)

    cnt = 0

    for ri in rs:
        for gi in gs:
            df = abs(gi - ri)
            rr = max(gi,ri) + df
            ll = min(gi,ri) - df
            mm = -1
            if df % 2 == 0:
                mm = int((gi + ri)/2)

            if rr in bs:
                cnt +=1
            if mm in bs:
                cnt+=1
            if ll in bs:
                cnt+=1

            # if ri < gi:
            #     df = gi - ri
            #     rr = gi + df
            #     ll = ri - df
            #     mm = -1
            #     if df % 2 == 0:
            #         mm = ri + int(df / 2)
            #
            #     lim = rr if rr <= (n - 1) else max(mm, ll)
            #
            #     if lim < 0:
            #         continue
            #
            #     for bi in bs:
            #         if bi < ll:
            #             continue
            #         if lim < bi:
            #             break
            #
            #         if bi == ll:
            #             cnt += 1
            #         elif bi == mm:
            #             cnt += 1
            #         elif bi == rr:
            #             cnt += 1
            #
            # else:
            #     df = ri - gi
            #     rr = ri + df
            #     ll = gi - df
            #     mm = -1
            #     if df % 2 == 0:
            #         mm = gi + int(df / 2)
            #
            #     lim = rr if rr <= (n - 1) else max(mm, ll)
            #
            #     if lim < 0:
            #         continue
            #     for bi in bs:
            #         if bi < ll:
            #             continue
            #         if lim < bi:
            #             break
            #
            #         if bi == ll:
            #             cnt += 1
            #         elif bi == mm:
            #             cnt += 1
            #         elif bi == rr:
            #             cnt += 1
    all_cnt = len(rs) * len(gs) * len(bs)

    print(all_cnt - cnt)


main()


Measured memory_bytes: 9304
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"    "<<"HERE"<<en

string jj("JOI");
string ii("IOI");

int main(){
  priority_queue<int> pq_w;
  for(int i=0; i<10; i++){
    int n;
    cin>>n;
    pq_w.push(n);
  }
  priority_queue<int> pq_k;
  for(int i=0; i<10; i++){
    int n;
    cin>>n;
    pq_k.push(n);
  }
  
  int w=0,k=0;
  for(int i=0; i<3; i++){
    w+=pq_w.top(); pq_w.pop();
    k+=pq_k.top(); pq_k.pop();
  }
  cout<<w<<" "<<k<<en
}



Measured memory_bytes: 3168
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a <= c && b <= d && c <= b) printf("%d\n",b-c);
	else if(a <= c && b >= d && b >= c) printf("%d\n",d-c);
	else if(a >= c && b <= d && b > c) printf("%d\n",b-a);
	else if(a >= c && b >= d && d > a) printf("%d\n",d-a);
	else if(a == b && b == c && c == d) printf("0\n");
	
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>=b)
	{
		for(int i=0;i<a;i++)
		{
			cout<<b;
		}
	}
	else
	{
		for(int i=0;i<b;i++)
		{
			cout<<a;
		}
	}
	
	cout<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string a, b, c;
  cin >> a >> b >> c;
  cout << a[0] << b[0] << c[0] << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <algorithm>
#include <cassert>

using namespace std;

typedef long long int LLI;
typedef pair<int,int> PII;

#define _ ios_base::sync_with_stdio(0);
#define debug
#define x first
#define y second
#define MXN 100005

const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-8; 


int main() { _
    int n, t, k, mx;
    LLI sum;
    while (cin >> n >> t) {
        mx = -1;
        sum = 0;
        for (int i = 0; i < n; ++i) {
            cin >> k;
            mx = max(mx, k);
            sum += k;
            if (sum <= t) cout << int(1+ceil((double)(t+0.5 - sum)/(double)mx)) << "\n";
            else cout << "1\n";
        }
    }

    return 0;
}



Measured memory_bytes: 3236
//2020.3.28 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
#define ctz(x) __builtin_ctz(x)
//#define pc(x) __builtin_popcountll(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define ull unsigned LL
#define lowbit(x) (x&-x)
#define gc getchar
#define kcz 998244353
//template <class T>using Tree=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
// inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
// }
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
// char sr[1<<21],z[20];
// int C=-1,Z=0;
// inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
// inline void print(res x){
//    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
//    while(z[++Z]=x%10+48,x/=10);
//    while(sr[++C]=z[Z],--Z);
// }
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
//inline void swap(res &x,res &y) {
//    x^=y^=x^=y;
//}
//inline void add(res &x,const res &y){
//    x+=y,x>=kcz?x-=kcz:(x<0?x+=kcz:1);
//}
//inline int Add(const res &x,const res &y){
//    return x+y>=kcz?x+y-kcz:(x+y<0?x+y+kcz:x+y);
//}
//inline int mul(const res &x,const res &y){
//    return int(1LL*x*y%kcz);
//}
//inline int mul(const res &x,const res &y,const res &d){
//    return int(1LL*x*y/d%kcz);
//}
//inline int qpow(res x,res y){
//    res ret=1;
//    while(y){
//        if(y&1)ret=mul(ret,x);
//        x=mul(x,x),y>>=1;
//    }
//    return ret;
//}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
namespace MAIN{
    inline void MAIN(){
        char str[10];
        scanf("%s",str+1);
        if(str[3]==str[4]&&str[5]==str[6]){puts("Yes");}
        else puts("No");
    }
}
int main(){
//    srand(19260817);
    // freopen("tracing.in","r",stdin);
    // freopen("tracing.out","w",stdout);
    MAIN::MAIN();
//    Ot();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/range/algorithm.hpp>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main()
{
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  vector<int> s(h * w);
  rep(i, h)
  {
    rep(j, w)
    {
      if ((i < b && j < a) || (i >= b && j >= a))
        s[i * w + j] = 1;
      else
        s[i * w + j] = 0;
    }
  }

  rep(i, h)
  {
    rep(j, w)
    {
      cout << s[i * w + j];
    }
    cout << endl;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF 1LL<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

int main(){
    ll a,b; cin >> a >> b;
    cout << max(a-2*b,0LL) << endl;
}

Measured memory_bytes: 256
def z_algorithm(S):
    # 文字列が与えられた時、各 i について
    # 「S と S[i:|S|-1] の最長共通接頭辞の長さ」を記録した配列 A を
    #  O(|S|) で構築するアルゴリズム
    # S: aaabaaaab
    # A: 921034210
    # 例えば、A[5] = 4だが、これは、S[0:4] == S[5:5+4] 
    # (Sの0文字目からと5文字目からは、4文字一致している(aaab)) ことを意味する。

    lenS = len(S)
    A = [0] * lenS
    i = 1; j = 0
    A[0] = lenS
    # i: 調査開始点
    # iを1文字目からlen(S)-1文字目まで左から順に動かしていく
    while i < lenS:
        # j: 何文字目まで一致するか(iからの距離)
        # 一致しなくなるまでjを左から右へ動かしていく
        while i + j < lenS and S[j] == S[i + j]:
            j += 1
        # 1文字も一致しない場合は調査開始点を一つ右にずらす
        if j == 0:
            i += 1
            continue

        A[i] = j

        # 例）S: momomosumomomomo
        # A[1] = 0, A[2] = 4 (A[0:4] == A[2:2+4] = "momo")

        # i=2の調査が終わった段階で、
        # S[3] = S[2 + 1] = S[1] = "o" 
        # で、A[3] = A[1] = 0（Sの1文字目からと3文字目からは一致しない）
        # のは明らかなので、i = 3の結果はi = 1の結果を流用して0とする。
        # つまり、A[3] = A[2 + 1] = A[1] = 0

        # 今回、i + j 文字目まで、一致するか調べたので、
        # A[i + 1] ~ A[i + j - 1] までの間で、計算結果を流用できるところは流用する
        # j <= k + A[k] となるようなkの場合、
        # j文字目以降は今回調べてないので一致するか本当に分からないので、流用をやめる
        # 今回の場合、
        # k = 1: 1 + A[1] = 1 + 0 = 1 < j = 4 なので、流用できる
        # k = 2: 2 + A[2] = 2 + 4 = 6 > j = 4 なので、流用できない
        # つなり、k=2となった瞬間、流用をせずにループを抜ける。
        k = 1
        while k + A[k] < j and i + k < lenS:
            A[i + k] = A[k]
            k += 1
        # 今回 1回 (=k-1回) 流用できた、つまり A[3] = A[2(=i) + 2(=k) - 1] まで確定したので、
        # 次は A[4] = A[i + k] から調べる
        i += k

        # また、k = 2 のとき、k + A[k] >= j となって流用を打ち切られたということは、
        # k + A[i + k] >= j  => A[i + k] >= j - k
        # A[4] は少なくとも j - k = 4 - 2 = 2 以上となることが確定する。
        # つまり、S[4:]とSは、少なくとも最初の2文字 (j-k文字) は一致する。
        # よって、A[4]を調べるときは、j=2から調査を開始すればよい。
        # （つまり、S[6]とS[4:][2]が一致しているか調べるところから始める）

        #             0123456
        # S         = momomosumomomomo
        # S[2:]     =   momosumomomomo   <- 5文字目が違う
        # S[2:][2:] =     mosumomomomo   <- 3文字目が違う
        # S[4:]     =     mosumomomomo   <- 3文字目が違う
        # S[4:][2:] =       sumomomomo   <- 1文字目が違う
        j -= k
    return A

def main():
    N = int(input())
    S = input()

    ans = 0

    # Z-algorithm で、最長共通接頭辞の長さを調べる。
    # Z-algorithm は、「S と S[i:|S|-1] の最長共通接頭辞の長さ」を記録するので、
    # S[1]以降の部分文字列同士の長さは、
    # S=S[i:]としてiをずらしながら最長共通接頭辞を調べることで分かる

    for i in range(N-1):
        A = z_algorithm(S[i:])
        # print(A)
        # 例えばS = ababa のとき、
        # A = [5, 0, 3, 0, 1] となる。
        # A[2] = 3 だが、範囲が被ってしまっているので、
        # A[i] > i の場合、一致する文字数はiまでにしておく。
        ans = max(ans, max([min(i, a) for i, a in enumerate(A)]))

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 55004
#include <stdio.h>

int main(void){

	int k,s;
	int x,y,z;
	int count=0;
	scanf("%d %d", &k, &s);

	for(x=0; x<=k; x++){
		for(y=0; y<=k; y++){
			if(s-x-y<=k && s-x-y>=0){
				count++;
			}
		}
	}

	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 128
from collections import Counter

n = int(input())
a_array = list(map(int, input().split()))
a_counter = Counter(a_array)
count_max = max(a_counter.values())

def nC2(n):
    return n * (n - 1) // 2

nc2_array = [0] * (count_max + 1)
sum_comb = 0
for a, count in a_counter.items():
    comb = nC2(count)
    sum_comb += comb
    nc2_array[count] = comb
    nc2_array[count - 1] = nC2(count - 1)

for a in a_array:
    a_count = a_counter[a]
    ans = sum_comb - nc2_array[a_count] + nc2_array[a_count - 1]
    print(ans)

Measured memory_bytes: 34136
#include <stdio.h>

int main(){
    int n;
    int a[100001] = {};
    int b;

    scanf("%d\n", &n);

    int ans = 0;
    for (int i = 0; i < n; i++){
        scanf("%d", &b);
        if (b > n){
            ans++;
            continue;
        }
        a[b]++;
    }

    for (int i = 1; i <= n; i++){
        if(a[i] == 0) continue;

        if(a[i] > i) ans += a[i] - i;
        if(a[i] < i) ans += a[i];
    }

    printf ("%d\n", ans);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
const long long mod = 1000000007;

int main() {
    int S, A[2000];
    cin >> S;
    A[0] = A[1] = A[2] = 0;
    A[3] = 1;
    for (int i = 4; i <= S; i++) {
        A[i] = (A[i - 1] + A[i - 3]) % mod;
    }
    cout << A[S] << endl;
}

Measured memory_bytes: 3584
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::collections::HashSet;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let ab = scan.readn::<i32>(2).into_iter().collect::<HashSet<_>>();
    let all = vec![1i32,2,3].into_iter().collect::<HashSet<_>>();
    println!("{}", all.difference(&ab).into_iter().next().unwrap());
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := range arr {
		fmt.Scan(&arr[i])
	}
	sort.Slice(arr, func(i, j int) bool {
		if arr[i] > arr[j] {
			return true
		}
		return false
	})
	var alice, bob int
	for i, v := range arr {
		if i%2 == 0 {
			alice += v
		} else {
			bob += v
		}
	}
	fmt.Println(alice - bob)
}


Measured memory_bytes: 1844
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            long sum = 0;
            for (int i = 1; i <= N; i++) {
                if (i % 3 != 0 && i % 5 != 0) {
                    sum += i;
                }
            }
            out.println(sum);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



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

typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

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

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

  vector<int> h(N);
  for(int i = 0; i < N; i++) {
    cin >> h.at(i);
  }

  vector<int> dp(N, INF);
  dp[0] = 0;
  for(int i = 1; i < N; i++) {
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if (i == 1) continue;
    chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }

  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1024
// ABC175C - Walking Takahashi

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

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	ll X;
	ll K, D;
	cin >> X >> K >> D;

	X = abs(X);

	if (X / D > K) {
		cout << min(X, abs(X - D * K)) << endl;
	} else {
		ll temp;
		temp = X / D;
		if ((K - temp) % 2 == 0) {
			cout << min(X, abs(X - temp * D)) << endl;
		} else {
			cout << min(abs(X - (temp-1) * D), abs(X - (temp+1) * D)) << endl;
		}
	}

	return 0;
}




Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
	int thp, tatk, ahp, aatk;

	cin>>thp;
	cin>>tatk;
	cin>>ahp;
	cin>>aatk;

	/*cout<<thp<<endl;
	cout<<tatk<<endl;
	cout<<ahp<<endl;
	cout<<aatk<<endl;*/

	 while((thp>=0)||(ahp>=0)){
	 	//高橋くんの攻撃
	 	ahp=ahp-tatk;
	 	//cout<<"青木のhp"<<ahp<<endl;
	 	if(ahp<=0){
	 		cout<<"Yes"<<endl;
	 		return 0;
	 	}

	 	thp=thp-aatk;
	 	//cout<<"高橋のhp"<<thp<<endl;
	 	if(thp<=0){
	 		cout<<"No"<<endl;
	 		return 0;
	 	}


	 }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main()
{
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<P> pa(q);
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        pa[i]={l,r};
    }
    vector<int> sum(n+1);
    int j=1;
    while(j<n){
        sum[j]=sum[j-1];
        if(s[j-1]=='A' && s[j]=='C'){
            sum[j]++;
        }
        j++;
    }
    for(int i=0;i<q;i++){
        cout<<sum[pa[i].second-1]-sum[pa[i].first-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3072
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

list_ = list(range(1, n + 1))

for num ,v in enumerate(itertools.permutations(list_, n)):
    if p == list(v):
        res_p = num + 1
        
for num ,v in enumerate(itertools.permutations(list_, n)):
    if q == list(v):
        res_q = num + 1

ans = abs(res_p - res_q)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a, b;
  cin >> a >> b;
  if(a == 'H'){
    if(b == 'H'){
      cout << 'H' << endl;
    }
    else cout << 'D' << endl;
  }
  if(a == 'D'){
    if(b == 'H'){
      cout << 'D' << endl;
    }
    else cout << 'H' << endl;
  }
}

Measured memory_bytes: 256