akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define N 100
#define WHITE 0
#define BLACK 1
#define NIL -1

int prim();

int A[N][N];
int num;
int color[N];

int main(){
  int i, j;

  scanf("%d", &num);

  for(i = 0; i < num; i++){
    for(j = 0; j < num; j++){
      scanf("%d", &A[i][j]);
    }
  }

  printf("%d\n", prim());

  return 0;
}

int prim(){
  int i, j, u, v, min, res = 0;

  for(i = 0; i < num; i++){
    color[i] = WHITE;
  }

  color[0] = BLACK;

  while(1){
    min = 2100000000;

    for(i = 0; i < num; i++){
      if(color[i] == WHITE){
	continue;
      }
      
      for(j = 0; j < num; j++){
	if(A[i][j] != NIL){
	  if(color[j] != BLACK && A[i][j] < min){
	    min = A[i][j];
	    u = i;
	    v = j;
	  }
	}
      }
      
    }

    if(min == 2100000000){
      break;
    }

    color[v] = BLACK;
    res += A[u][v];

  }

  return res;
}



Measured memory_bytes: 2052
#include <iostream>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int dp[5005][5005];

int main() {
    int n;
    string s;
    cin >> n >> s;
    for (int i = n-1; i >= 0; --i) {
        for (int j = n - 1; j >= 0; --j) {
            if (s[i] != s[j]) dp[i][j] = 0;
            else dp[i][j] = dp[i+1][j+1] + 1;
        }
    }
    int ans = 0;
    rep(i, n) rep(j, n) {
        if (i >= j) continue;
        int now = min(dp[i][j], j - i);
        ans = max(ans, now);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 98048
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n, m;
ll d[100000];
vector<pi> e[100000];
string ans;
vector<int> anse;

bool cmp (const int& l, const int& r) {
    return d[l] < d[r];
}

bool cmp2 (const pi& l, const pi& r) {
    return d[l.first] < d[r.first];
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i,n) cin >> d[i];
    rep(i,n) ans.push_back('B');
    anse.resize(m);
    rep(i,m) anse[i] = -1;
    rep(i,m) {
        int u, v; cin >> u >> v; u--; v--;
        e[u].push_back(pi(v,i));
        e[v].push_back(pi(u,i));
    }
    rep(i,n) sort(e[i].begin(), e[i].end(), cmp2);
    vector<int> ind(n);
    vector<int> fixed(n, 0);
    rep(i,n) ind[i] = i;
    sort(ind.begin(), ind.end(), cmp);
    rep(_,n) {
        int i = ind[_];
        if (d[e[i][0].first] > d[i]) {
            puts("-1");
            return 0;
        }
        rep(j,e[i].size()) {
            int to = e[i][j].first;
            if (d[to] > d[i]) {
                break;
            }
            if (!fixed[i]) {
                if (ans[to] == 'B') ans[i] = 'W';
                else ans[i] = 'B';
                fixed[i] = true;
                fixed[to] = true;
            }
            anse[e[i][j].second] = d[i];
        }
    }
    cout<< ans << endl;
    rep(i,m) cout << anse[i] << endl;
}

Measured memory_bytes: 12672
import math
a = [int(s) for s in input().split()]
b = int(max([a[0], a[1]]))
c = int(min([a[0], a[1]]))
d = 0.5 * (a[2] * 60 + a[3])
e = 6 * a[3]
f = abs(d - int(e))

if f >= 180:
  f = 360 - f
if f != 0 and f!= 180:
  print(math.sqrt(a[0] ** 2 + a[1] ** 2 - 2 * a[0] * a[1] * math.cos(math.radians(f))))
elif f == 0:
  print(b-c)
else:
  print(b+c)

Measured memory_bytes: 62668
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <cassert>

using namespace std;

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
const int mod = int(1e9) + 7;
const long long infLL = 2e18;
const int MX = 300105;

pair<int,pair<int,int>> a[MX];
int r[MX];
const int delta = 1 << 17;
int b[2 * delta];

int get(int pos){
    pos += delta;
    int ans = 0;
    while(pos){
        ans += b[pos];
        pos >>= 1;
    }
    return ans;
}

void add(int l, int r, int val){
    l += delta;
    r += delta;
    while(l <= r){
        if(l & 1){
            b[l++] += val;
            continue;
        }
        if(r % 2 == 0){
            b[r--] += val;
            continue;
        }
        l >>= 1;
        r >>= 1;
    }
}

int main()
{
    //init();
    //cerr << delta << endl;
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        int l, r;
        cin >> l >> r;
        a[i] = {r - l + 1, {l, r}};
        add(l, r, 1);
    }
    sort(a, a + n);
    int to_add = 0;
    for(int i = m; i > 0; i--){
        while(n > 0 && a[n - 1].first == i){
            to_add++;
            add(a[n - 1].second.first, a[n - 1].second.second, -1);
            n--;
        }
        r[i] = to_add;
        for(int j = 0; j <= m; j += i){
            r[i] += get(j);
        }
    }
    for(int i = 1; i <= m; i++){
        cout << r[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 5632
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	S := 0
	for i := 0; i < M; i++ {
		var j int
		fmt.Scan(&j)
		S += j
	}
	if N-S >= 0 {
		fmt.Println(N - S)
	} else {
		fmt.Println(-1)
	}
}


Measured memory_bytes: 2464
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int w,h;

int solve(int m[30][30],int res){
	if(res>10)return 11;
	int xx[]={1,-1,0,0},yy[]={0,0,1,-1};
	int x,y;
	int i,j;
	int xxx,yyy;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(m[i][j]==2){x=j;y=i;}
			if(m[i][j]==3){xxx=j;yyy=i;}
		}
	}
	int dx,dy,r=11;
	for(i=0;i<4;i++){
		dx=dy=0;
		while(1){
			dx+=xx[i];
			dy+=yy[i];
			if(x+dx<0||w<=x+dx||y+dy<0||h<=y+dy)break;
			if(m[y+dy][x+dx]==3)return res;
			if(m[y+dy][x+dx]==1){
				dx-=xx[i];
				dy-=yy[i];
				if(dx==0&&dy==0)break;
				m[y+dy][x+dx]=2;
				m[y][x]=0;
				m[y+dy+yy[i]][x+dx+xx[i]]=0;
				chmin(r,solve(m,res+1));
				m[y+dy][x+dx]=0;
				m[y][x]=2;
				m[y+dy+yy[i]][x+dx+xx[i]]=1;
				break;
			}
		}
	}
	return r;
}

int main() {
	while(cin>>w>>h,w){
		int m[30][30];
		int i,j;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				cin>>m[i][j];
			}
		}
		int res=solve(m,1);
		if(res>10)cout<<-1<<endl;
		else cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 868
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
s_set = list(set(s))
win = max(s.count(s_set[i]) - t.count(s_set[i]) for i in range(len(s_set)))
print(max(0,win))

Measured memory_bytes: 9104
package main

import (
    "fmt"
)

func main() {
    var s []byte
    fmt.Scan(&s)
    var l, max int 
    for _, b := range s { 
        switch b { 
        case 'A', 'T', 'C', 'G':
            l++ 
            if l > max {
                max = l 
            }   
        default:
            l = 0 
        }   
    }   
    fmt.Println(max)
}


Measured memory_bytes: 512
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// }}}
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;

int n;
const int N = 1e5;
int v[N];

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> n;
  for(int i = 0; i < n - 1; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    v[x] ^= a;
    v[y] ^= a;
  }
  int cnt[16] = {};
  for(int i = 0; i < n; i++) cnt[v[i]]++;
  int ans = 0;
  int s = 0;
  for(int i = 1; i < 16; i++) ans += cnt[i] / 2, cnt[i] &= 1, s |= cnt[i] << (i - 1);

  int popcount[1 << 15] = {};
  int ok[1 << 15] = {};

  for(int i = 1; i < 1 << 15; i++) popcount[i] = popcount[i >> 1] + (i & 1);
  for(int i = 1; i < 1 << 15; i++) { // O(2^15 * 15)
    int sum = 0;
    for(int j = 1; j <= 15; j++) if(i & (1 << (j - 1))) {
      sum ^= j;
    }
    ok[i] = sum == 0;
  }
  
  // 部分集合に対するbitDP O(3^15)
  int dp[1 << 15] = {};
  for(int i = 1; i < 1 << 15; i++) {
    dp[i] = 1e9;
    for(int j = i; j > 0; j = (j - 1) & i) if((s & j) == j) if(ok[j]) {
      dp[i] = min(dp[i], dp[i^j] + popcount[j] - 1);
    }
  }

  cout << ans + dp[s] << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[m];
		int[] d = new int[m];
		int[] man = new int[m];
		int[] min = new int[n];
		int[] minnum = new int[n];
		final int INF = Integer.MAX_VALUE;
		Arrays.fill(min, INF);
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
			b[i] = scan.nextInt();
		}
		for (int i = 0; i < m; i++) {
			c[i] = scan.nextInt();
			d[i] = scan.nextInt();
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				man[j] = Math.abs(a[i]-c[j])+Math.abs(b[i]-d[j]);
				if (min[i] > man[j]) {
					min[i] = man[j];
					minnum[i] = j+1;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.println(minnum[i]);
		}
	}
}


Measured memory_bytes: 23124
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
max_diff = k - a[n-1] + a[0]
for idx in range(len(a)-1):
  diff = a[idx+1] - a[idx]
  if max_diff < diff:
    max_diff = diff
max_diff = max_diff
ans = k - max_diff
print(ans)

Measured memory_bytes: 26436
// #pragma GCC optimize(2)
// #pragma G++ optimize(2)
// #pragma comment(linker,"/STACK:102400000,102400000")

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

typedef long long int64;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef double dl;
typedef pair<int,int> pii;
#if (WIN32) || (WIN64) || (__WIN32) || (__WIN64) || (_WIN32) || (_WIN64) || (WINDOWS)
#define lld "%I64d"
#define llu "%I64u"
#else
#define lld "%lld"
#define llu "%llu"
#endif
#define uint(n) ((unsigned int)(n))
#define int64(n) ((long long)(n))
#define ull(n) ((unsigned long long)(n))
#define fl(n) ((float)(n))
#define dl(n) ((double)(n))
#define char(n) ((char)(n))
#define Bool(n) ((bool)(n))
#define fixpoint(n) fixed<<setprecision(n)

const int INF=1061109567;
const int NINF=-1044266559;
const int64 LINF=4557430888798830399;
const dl eps=1e-15;
#define MOD (1000000007)
#define PI (3.1415926535897932384626433832795028841971)

#define MP make_pair
#define MT make_tuple
#define All(a) (a).begin(),(a).end()
#define pall(a) (a).rbegin(),(a).rend()
#define Log(x,y) log(x)/log(y)
#define SZ(a) ((int)(a).size())
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define rep1(i,n) for(int i=1;i<=((int)(n));i++)
#define repd(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define repd1(i,n) for(int i=((int)(n));i>=1;i--)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)
#define repE(i,v) for(auto &i:v)
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x) MS(x,0)
#define MINF(x) MS(x,63)
#define MCP(x,y) memcpy(x,y,sizeof(y))
#define UN(v) sort(All(v)),v.erase(unique(All(v)),v.end())
#define filein(x) freopen(x,"r",stdin)
#define fileout(x) freopen(x,"w",stdout)
#define fileio(x)\
	freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout)
#define filein2(filename,name) ifstream name(filename,ios::in)
#define fileout2(filename,name) ofstream name(filename,ios::out)
#define fileio2(filename,name) fstream name(filename,ios::in|ios::out)
#define sqr(x) ((x)*(x))
#define Pause system("pause")
#define Cls system("cls")
#define fs first
#define sc second
#define SF scanf
#define PF printf

const int maxn=100010;

int n,m,q,par[maxn],rnk[maxn],cc;

struct clue
{
	int u,v,typ;
} c[maxn];

inline int unfind(int u)
{
	return par[u]==u?u:par[u]=unfind(par[u]);
}

inline void unmerge(int u,int v)
{
	u=unfind(u);v=unfind(v);
	if(u==v) return;

	if(rnk[u]<rnk[v]) par[u]=v;
	else
	{
		par[v]=u;
		if(rnk[u]==rnk[v]) rnk[u]++;
	}
}

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

	for(int i=0;i<n;i++) par[i]=i,rnk[i]=1;

	for(int i=0;i<q;i++)
	{
		SF("%d%d%d",&c[i].u,&c[i].v,&c[i].typ);
		if(c[i].typ==0) unmerge(c[i].u,c[i].v);
	}

	for(int i=0;i<n;i++) if(i==unfind(i)) cc++;

	int hav1=0;
	for(int i=0;i<q;i++) if(c[i].typ==1)
	{
		hav1=1;
		if(unfind(c[i].u)==unfind(c[i].v)) return !PF("No");
	}

	int64 l=hav1?max(3ll,1ll*cc):cc-1,r=1ll*cc*(cc-1)/2,x=m-(n-cc);
	if(l<=x&&x<=r) PF("Yes"); else PF("No");

	return 0;
}

Measured memory_bytes: 5792
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926


int main(){
    string s;
    cin >> s;
    if(s == "Sunny")
        cout << "Cloudy";
    else if(s == "Cloudy")
        cout << "Rainy";
    else    
        cout << "Sunny";
}

    

	


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        long A[] = new long[H+1];
        for(int i = 1 ; i <= H ; i++)
            A[i] = sc.nextLong();
        for(int i = 1 ; i <= H ; i++){
            System.out.print("node " + i + ": key = " + A[i]+ ", ");
            if(i / 2 >= 1)
                System.out.print("parent key = " + A[i/2] + ", ");
            if(2 * i <= H)
                System.out.print("left key = " + A[2 * i] + ", ");
            if(2 * i + 1 <= H)
                System.out.print("right key = " + A[2 * i + 1] + ", ");
            System.out.println();
        }
    }
}


Measured memory_bytes: 27512
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, AB):
    ans = 0
    return ans


def main():
    N = read_int()
    if N > 999:
        print('ABD')
    else:
        print('ABC')


if __name__ == '__main__':
    main()


Measured memory_bytes: 7876
using System.Linq;
using static System.Console;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            var a = ReadLine().Split().Select(int.Parse).ToList();
            var ans = new int[n];
            for(int i = 0; i < n - 1; i++)
            {
                ans[a[i] - 1]++;
            }
            for(int i = 0; i < n; i++)
            {
                WriteLine(ans[i]);
            }
        }
    }
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 11111

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
    ios::sync_with_stdio(0) ;
    char ch1 , ch2 ;
    cin >> ch1 >> ch2 ;

    if(ch1 == ch2) cout << "=" << endl ;
    else if(ch1 < ch2) cout << "<" << endl ;
    else cout << ">" << endl ;
    return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<20;



const int M_N=100001;

struct UnionFind{
    int par[M_N];
    int rank[M_N];
    LL number[M_N];

    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
            number[i]=1;
        }
    }

    int find(int x){
        if(par[x]==x){
            return x;
        }
        else{
            return par[x]=find(par[x]);
        }
    }

    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
            number[y]+=number[x];
        }
        else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
            number[x]+=number[y];
        }
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }

    int get(int x){
        return number[find(x)];
    }

};


int main(){
    LL N,M;
    cin >> N >> M;
    vector<P> E;
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        a--,b--;
        E.push_back(P(a,b));
    }
    UnionFind uf;
    uf.init(N);
    vector<LL> ans;
    LL t=0;
    for (int i = M-1; i >= 0; i--) {
        P p = E[i];
        int x=p.fs,y=p.sc;
        ans.pb(t);
        if(!uf.same(x,y)){
            t+=uf.get(y)*uf.get(x);
            uf.unite(x,y);
        }
    }
    for (int i = M-1; i >= 0; i--) {
        cout << N*(N-1)/2-ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4596
import java.io.PrintWriter

val squares = (1..127).map { it * it }

fun check(x: List<Int>, y: List<Int>): Boolean {
    val distanceSquared = x.zip(y).map { (it.first - it.second) * (it.first - it.second)}.sum()
    return distanceSquared in squares
}

fun solve(out: PrintWriter): Boolean = with(out) {
    val (N, D) = readLine()!!.split(" ").map { it.toInt() }
    val X = (1..N).map { readLine()!!.split(" ").map { it.toInt() } }

    var cnt = 0;
    for (i in 0 until N-1) {
        for( j in i+1 until N) {
            if (check(X[i], X[j]))
                cnt++;
        }
    }

    println(cnt);
    return false
}

// with(PrintWriter(System.out))
// with(File("out.txt").printWriter())
// with(File(args[1]).printWriter())
fun main(args: Array<String>) = with(PrintWriter(System.out)){
//    System.setIn(File(args[0]).inputStream())
    while(solve(this));
    flush()
}

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

int main(){
  int a[5], k;
 cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
  
  for (int i=0;i<4;++i){
    for(int j = i+1; j < 5; ++j){
  	if(a[i] - a[j] > k || a[j] - a[i] > k){
    	cout << ":(" << endl;
      return 0;
    }
    }
  }
  
  cout << "Yay!" << endl;
  
  return 0; 
}

Measured memory_bytes: 256
import bisect
import sys
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

x = int(input())
for i in range(100):
    if is_prime(x) == 1:
        print(x)
        sys.exit()
    x += 1

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int K,X;
    cin >> K >> X;
    if(500 * K >= X){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

    int n, count=0;

    scanf("%d", &n);

    char s[n+3];

    scanf("%s", &s);

    for(int i=0;i<n+3;i++){
        if(s[i]=='A'){
            i++;
            if(s[i]=='B'){
                i++;
                if(s[i]=='C'){
                    count++;
                }else{
                    i--;
                }
            }else{
                i--;
            }
        }
    }

    printf("%d", count);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void){
  int N;
  cin >> N;
  int rem = N%10;
  if(rem == 3){
    cout << "bon" << endl;
    return 0;
  }
  if(rem == 0 || rem == 1 || rem == 6 || rem == 8){
    cout << "pon" << endl;
    return 0;
  }
  cout << "hon" << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
    int a[101],b=0,j=0,i,s,e,o;
    scanf("%d",&e);
    for(i=0;i<e;i++)
    {
        scanf("%d",&a[i]);
        //s=0;
        if(a[i]%2==0)
           {

            j++;
            //s=0;

                if(a[i]%3==0 || a[i]%5==0) b++;

                }
    }

    if(j==b)
        printf("APPROVED\n");
    else
        printf("DENIED\n");
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <tuple>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

#define ALL(x) begin(x), end(x)

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

  vector<tuple<string, int, int>> r;
  string s;
  int p;
  for (int i = 0; i < N; i++) {
    cin >> s >> p;
    r.emplace_back(s, -p, i + 1);
  }
  sort(ALL(r));

  for (auto &x : r) {
    cout << get<2>(x) << endl;
  }

  return 0;
}


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

double n, m, d;
int main() {
	scanf("%lf%lf%lf", &n, &m, &d);
	double t = (n-d) * (m-1) /n / n;
	printf("%.10lf\n", d == 0 ? t : 2 * t);
}

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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

static int dp[2][5][5][5][5];
int dfs(int h, int i, int j, int k, int l) {
	if (i >= 5)i = 0;
	if (j >= 5)j = 0;
	if (k >= 5)k = 0;
	if (l >= 5)l = 0;
	if (dp[h][i][j][k][l] != -1)return dp[h][i][j][k][l];
	dp[h][i][j][k][l] = -2;
	if (DBG)cerr << h << i << j << k << l << endl;
	if (h == 1) {
		if (i != 0 && k != 0 && dfs(0, i + k, j, k, l) == 1)return dp[h][i][j][k][l] = 1;
		if (i != 0 && l != 0 && dfs(0, i + l, j, k, l) == 1)return dp[h][i][j][k][l] = 1;
		if (j != 0 && k != 0 && dfs(0, i, j + k, k, l) == 1)return dp[h][i][j][k][l] = 1;
		if (j != 0 && l != 0 && dfs(0, i, j + l, k, l) == 1)return dp[h][i][j][k][l] = 1;
		return dp[h][i][j][k][l] = 0;
	}
	else {
		if (k != 0 && i != 0 && dfs(1, i, j, k + i, l) == 0)return dp[h][i][j][k][l] = 0;
		if (k != 0 && j != 0 && dfs(1, i, j, k + j, l) == 0)return dp[h][i][j][k][l] = 0;
		if (l != 0 && i != 0 && dfs(1, i, j, k, l + i) == 0)return dp[h][i][j][k][l] = 0;
		if (l != 0 && j != 0 && dfs(1, i, j, k, l + j) == 0)return dp[h][i][j][k][l] = 0;
		return dp[h][i][j][k][l] = 1;
	}
}

signed main() {
	//0:ISONO 1:NAKAJIMA
	int Li, Ri, Ln, Rn; cin >> Li >> Ri >> Ln >> Rn;
	memset(dp, -1, sizeof(dp));
	rep(i, 0, 5)rep(j, 0, 5) {
		if (i == 0 && j == 0)break;
		dp[0][0][0][i][j] = 1;
		dp[1][i][j][0][0] = 0;
	}
	cout << (dfs(0, Li, Ri, Ln, Rn) ? "NAKAJIMA" : "ISONO") << endl;
	return 0;
}

Measured memory_bytes: 3120
#include <stdio.h>
int main()
{
    char a;
    while(scanf("%c",&a)!=EOF)
    {
        if(a=='A')
            printf("T");
        else if(a=='T')
            printf("A");
        else if(a=='G')
            printf("C");
        else if(a=='C')
            printf("G");
        printf("\n");
        getchar();
    }
    return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ;
  cin >> n;
  vector<int> v(n);
  int S = 0 ;
  
  rep(i,n){
    int w;
    cin >> w ;
    S += w ;
    v.at(i) = S;
  }
  
  int ans = 100;
  rep(i,n-1){
    int high = max(v.at(i),v.at(n-1) - v.at(i));
    int low =  min(v.at(i),v.at(n-1) - v.at(i));
    ans = min(ans, high - low);
  }
  
  cout << ans ;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
cnt = 0

B = Counter(i + a for i, a in enumerate(A))
C = Counter(j - a for j, a in enumerate(A))
#print(B)
#print(C)
for k, v in B.items():
    cnt += C[k] * v
print(cnt)

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

using namespace std;

typedef long long ll;
#define int long long
#define F first
#define S second
#define pii pair<int,int>
#define mpr make_pair

const int maxn = 4e5+10;
const int mod = 1e9+7;
const ll inf = 1e18+10;

int n;
struct fenwick
{
    int fen[maxn], mx;

    fenwick()
    {
        memset(fen, 0, sizeof fen);
        mx = -1;
    }

    void _add(int pos, int val)
    {
        for(; pos <= n; pos |= (pos+1))
            (fen[pos] += val) %= mod;
    }

    void add(int l, int r, int val)
    {
        _add(l,val);
        _add(r+1,-val);
    }

    int qu(int pos)
    {
        if(pos <= mx) return 0;
        int res = 0;
        for(; pos >= 0; pos = (pos&(pos+1))-1)
            (res += fen[pos]) %= mod;
        return res;
    }
} fen;

int a[maxn], Max[maxn], Min[maxn], L[maxn], R[maxn];
vector<pii> ve;
vector<int> interval[maxn];

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

    cin>> n;
    for(int i = 1, x, v; i <= n; i++)
    {
        cin>> x >> v;
        ve.push_back({x,v});
    }
    sort(ve.begin(), ve.end());

    Max[0] = -inf;
    for(int i = 1; i <= n; i++)
    {
        a[i] = ve[i-1].S;
        Max[i] = max(Max[i-1],a[i]);
    }
    Min[n+1] = inf;
    for(int i = n; i >= 1; i--)
        Min[i] = min(Min[i+1],a[i]);


    for(int i = 1; i <= n; i++)
    {
        int lo = 0, hi = n+1;
        while(hi-lo > 1)
        {
            int tm = (hi + lo) >> 1;
            if(Max[tm] >= a[i]) hi = tm;
            else                lo = tm;
        }
        L[i] = hi;
    }
    for(int i = n; i >= 1; i--)
    {
        int lo = 0, hi = n+1;
        while(hi-lo > 1)
        {
            int tm = (hi + lo) >> 1;
            if(Min[tm] <= a[i]) lo = tm;
            else                hi = tm;
        }
        R[i] = lo;
        interval[R[i]].push_back(L[i]);
    }

    fen.add(0,0,1);
    for(int r = 1; r <= n; r++)
    {
        int DP = fen.qu(r-1);
        fen.add(r,r,(DP*2)%mod);

        for(auto l : interval[r])
        {
            int dp = fen.qu(l-1);
            fen.add(l,r,-dp);
            fen.mx = max(fen.mx, l-1);
        }
    }
    cout<< (fen.qu(n)+mod)%mod;
}




Measured memory_bytes: 32756
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
#define repM1(i, n) for(ll i = (ll)(n - 1); i > 0; i--)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

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

	ll k;
	string s;

	cin >> k >> s;

	if (s.size() > k)
		cout << s.substr(0, k) << "..." << endl;
	else
		cout << s << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int mas[m];
    for(int i = 0; i < m; i++){
        int k;
        cin >> k;
        int ma = 0;
        for(int j = 0; j < k; j++){
            int s;
            cin >> s;
            ma = ma | (1<<(s-1));
        }
        mas[i] = ma;
    }
    int ps[m];
    for(int i = 0; i < m; i++){
        int p;
        cin >> p;
        ps[i] = p;
    }

    int s = 0;
    for(int i = 0; i < 1<<n; i++){
        int light = 0;
        for(int j = 0; j < m; j++){
            bitset<10> an = bitset<10>(i&mas[j]);
            if(an.count()%2 == ps[j]){
                light++;
            }
        }
        if(light == m){
            s++;
        }
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const ll INF=1e16;


int main() {
    ios_base::sync_with_stdio(false); 
    
    ll n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i,n+1) cin >> a[i];
    vector<ll> up(n+1);
    bool flag=1;
    up[0]=1-a[0];
    vector<ll> down(n+1);
    if (n>0) {
        rep(i,n) {
            if (up[i]<INF) up[i+1]=up[i]*2-a[i+1];
            else up[i+1]=up[i];
            if ((up[i+1]<=0 && i<n-1) || up[i+1]<0) flag=0;
        }
        down[n-1]=a[n];
        if (a[n]==0) flag=0;
        invrep(i,n-1) {
            down[i]=down[i+1]+a[i+1];
            if (down[i]<=0) flag=0;
        }
    } else {
        if (a[0]!=1) flag=0;
    }
    ll ans=0;
    rep(i,n) {
        ll mi=(up[i]<down[i])?up[i]:down[i];
        ans+=mi+a[i];
    }
    if (flag) cout << ans+a[n] << endl;
    else cout << -1 << endl;
    
    return 0;
}

Measured memory_bytes: 5568
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    if(a==4){
        cout<<1988+b<<endl;
    }else if(a==3){
        cout<<1925+b<<endl;
    }else if(a==2){
        cout<<1911+b<<endl;
    }else if(a==1){
        cout<<1867+b<<endl;
    }else if(a==0){
        if(1912>b){
            cout<<"M"<<b-1867<<endl;
        }else if(1926>b){
            cout<<"T"<<b-1911<<endl;
        }else if(1989>b){
            cout<<"S"<<b-1925<<endl;
        }else if(2017>b){
            cout<<"H"<<b-1988<<endl;
        }
    }
}



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

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

using namespace std;

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

  int result=700;
  rep(i,3){
    if(s.at(i)=='o')result+=100;
  }
  
  cout<<result;
  
  return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	d = LI()

	ans = 0
	for i in range(N-1):
		for j in range(i+1,N):
			ans += (d[i]*d[j])
	print(ans)


main()

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

int main() {
    int A, B;
    cin >> A >> B;
    int nowPlug = 1, ans;
    for (int i = 0;;) {
        if (nowPlug >= B) {
            ans = i;
            break;
        }
        i++;
        nowPlug--;
        nowPlug += A;
    }
    cout << ans << endl;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> used(n,0);
    vector<int> e(m);
    for(int i=0;i<m;i++){
        cin>>e[i];
    }
    for(int i=m-1;i>=0;i--){
        if(!used[e[i]-1]){
            cout<<e[i]<<endl;;
            used[e[i]-1]=true;
        }
    }
    for(int i=0;i<n;i++){
        if(!used[i]){
            cout<<i+1<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3852
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
  int i,j;
  int n,m;
  int sum;
  int **mat;
  int *vec;
  scanf("%d%d",&n,&m);
  mat=(int**)malloc(sizeof(int*)*n);
  for(i=0;i<n;i++)
    {
      mat[i]=(int*)malloc(sizeof(int)*m);
      for(j=0;j<m;j++) scanf("%d",&mat[i][j]);
    }
  vec=(int*)malloc(sizeof(int)*m);
  for(i=0;i<m;i++) scanf("%d",&vec[i]);
  for(i=0;i<n;i++)
    {
      sum=0;
      for(j=0;j<m;j++) sum+=mat[i][j]*vec[j];
      printf("%d\n",sum);
    }
  return 0;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  
  int sum = 0;
  for(int i=0; i < N; i++){
    int x;
    cin >> x;
    sum += (K-x < x ? 2*(K-x) : 2*x);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int N,L[100],i,max=0,sum=0,flag=0;
	
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d ",&L[i]);
	}
	
	for(i=0;i<N;i++){
		if(L[i]>max){
			max=L[i];
		}
	}
	
	for(i=0;i<N;i++){
		if(L[i]!=max||flag==1){
			sum+=L[i];
		}else{
			flag=1;
		}
	}
	
	if(sum>max){
		puts("Yes");
	}else{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>

using namespace std;

bool cards[52];

void addCard(char c, int i) {
	int n;
	if (c == 'S')
		n = 0;
	else if (c == 'H')
		n = 13;
	else if (c == 'C')
		n = 26;
	else if (c == 'D')
		n = 39;
	n += i - 1;
	cards[n] = true;
}

bool isCardThere(int i) {
	return cards[i];
}

int main() {
	int n;
	cin >> n;
	char c;
	int i;
	for (int j = 0; j < n; j++) {
		cin >> c;
		cin >> i;
		addCard(c, i);
	}
	for(int j = 0; j < 52; j++) {
		if (!isCardThere(j)) {
			char c;
			if(j / 13 == 0)
				c = 'S';
			else if(j / 13 == 1)
				c = 'H';
			else if(j / 13 == 2)
				c = 'C';
			else if(j / 13 == 3)
				c = 'D';
			int i = j % 13 + 1;
			cout << c << " " << i << endl;
		}
	}
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define LL long long int

int main() {
	LL n;
	cin>>n;
	LL a[n+1],b[n+1],c[n+1];
	for(LL i=1;i<=n;i++){
	    cin>>a[i];
	}
	for(LL i=1;i<=n;i++){
	    cin>>b[i];
	}
	for(LL i=1;i<=n;i++){
	    cin>>c[i];
	}
	LL cnt=0;
	LL prev=-1;
	for(LL i=1;i<=n;i++){
	    LL x=a[i];
	    cnt+=b[x];
	    if(prev!=-1){
	        if((x-prev)==1){
	            cnt+=c[prev];
	            prev=x;
	        }
	        else{
	            prev=x;
	        }
	    }
	    else{
	        prev=x;
	    }
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
b = input()

# if b == 'A':
#     print('T')
# elif b == 'T':
#     print('A')
# elif b == 'C':
#     print('G')
# elif b == 'G':
#     print('C')
# else:
#     pass

pattern = {
    'A':'T',
    'T':'A',
    'C':'G',
    'G':'C'
}

print(pattern[b])

Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        String [] S = new String [H];
        int [] [] ans = new int [H] [W];
        
        for(int i=0; i<H; i++){
            S[i] = sc.next();
        }
        
        for(int i =0; i<H; i++){
            for(int j=0; j<W; j++){
            if(S[i].charAt(j) == '#'){
                ans[i][j] = -1;
            }else{
                    if(i > 0 && S[i-1].charAt(j) == '#') ans[i][j]++;
                    if(i < H-1 && S[i+1].charAt(j) == '#') ans[i][j]++;
                    if(j > 0 && S[i].charAt(j-1) == '#') ans[i][j]++;
                    if(j < W-1 && S[i].charAt(j+1) == '#') ans[i][j]++;
                    if(i > 0 && j > 0 && S[i-1].charAt(j-1) == '#') ans[i][j]++;
                    if(i < H-1 && j < W-1 && S[i+1].charAt(j+1) == '#') ans[i][j]++;
                    if(i < H-1 && j > 0 && S[i+1].charAt(j-1) == '#') ans[i][j]++;
                    if(i > 0 && j < W-1 && S[i-1].charAt(j+1) == '#') ans[i][j]++;
            }
            }
        }
        
        for(int i =0; i<H; i++){
            for(int j=0; j<W; j++){
                if(ans[i][j] == -1){
                    System.out.print('#');
                }else{
                    System.out.print(ans[i][j]);
                }
            }
            
            System.out.println("");
        }
    }
}

Measured memory_bytes: 36480
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素因数の種類の数＋１が答え

def main():
  a, b = sorted(list(map(int, input().split())), reverse = True)
  while b != 0:
    a, b = b, a % b
  print(num_facto(a) + 1)  
  
def num_facto(n):
  ans = 0
  max_n = int(n ** 0.5) + 1
  is_prime = [True for x in range(max_n + 1)]
  is_prime[0], is_prime[1] = False, False
  for cursor in two_and_odds(max_n):
    if is_prime[cursor]:
      if n % cursor == 0:
        ans += 1
        while n % cursor == 0:
          n = n // cursor
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
  if n != 1:
    ans += 1
  return ans

def two_and_odds(max_n):
  if max_n >= 2: yield 2
  for i in range(3, max_n, 2): yield i
    
if __name__ == "__main__":
  main()


Measured memory_bytes: 113904
"""
Monsters Battle Royale
"""


def solve():
    pass
    '''データインプット'''
    monster_num = int(input())
    monster_hp = [int(i) for i in input().split()]
    '''れっつろわいある'''
    while True:
        # 最小の数値minを求める.
        minmum = min(monster_hp)
        # minで他の数値を割り、余りを求める.
        monster_hp = [i % minmum for i in monster_hp]
        monster_hp = [i for i in monster_hp if i != 0]
        #   ここで、余りが0ならば解はminとなる
        if sum(monster_hp) == 0:
            break
        else:
            monster_hp.append(minmum)
    print(minmum)


if __name__ == '__main__':
    solve()


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

int n, m, ans = 1;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cin >> n >> m;
	for(int i = 1; i * i <= m; ++i)
		if(!(m % i)) {
			if(m / i >= n) ans = max(ans, i);
			if(i >= n) ans = max(ans, m / i);
		}
	cout << ans;
	return 0;
}

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

int main() {
  size_t N;  // 文字列の長さ
  std::string S;  // 文字列
  std::cin >> N >> S;

  // 一致する部分文字列の最大長を求める
  size_t result = 0;  // 一致する部分文字列の最大長
  std::vector<size_t> z;  // [0, z[i])と[i, i+z[i])が一致するときの長さ
  for (size_t l1 = 0; l1 < N - 1; ++l1) {
    // バッファをクリアする
    z.clear();
    z.resize(N - l1, 0);

    // Z-Algorithm
    size_t beg = 0, end = 0;  // [l1, l1+(end-beg))と一致する[beg, end)
    for (size_t i = 1; i < z.size(); ++i) {
      if (i + z[i - beg] < end) {
        // 一致を確認した範囲の中であれば、以前に計算した値を再利用できる
        z[i] = z[i - beg];
      } else {
        // 一致を確認した範囲を外れる場合、改めて一致する部分を探す
        const size_t l2 = l1 + i;
        size_t len = i < end ? (end - i) : 0;  // 一致することが分かっている部分を長さに含める
        for (; l2 + len < N; ++len) {
          if (S[l1 + len] != S[l2 + len]) break;
        }
        z[i] = len;
        beg = i;
        end = i + len;
      }

      // 文字列同士が重ならないような長さ（l2-l1=i）を考慮しつつ最大長を求める
      result = std::max(result, std::min(i, z[i]));
    }
  }

  // 結果発表
  std::cout << result;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <numeric>
using namespace std;
#define MAX_N 400

// Input
int A[MAX_N];

int main() {
  cin >> A[0] >> A[1] >> A[2];

  int ans = 0;
  if ((A[0] + A[1] + A[2]) >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
}


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

int main() {
    int n, k, s;
    cin >> n >> k >> s;
    for (int i=0; i<n; ++i) {
        if (i < k) cout << s;
        else {
            if (i%2) cout << s/2+100;
            else cout << s/2+10;
        }
        if (i == n-1) cout << endl;
        else cout << " ";
    }
}

Measured memory_bytes: 1280
/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include<bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock()*1.0 / CLOCKS_PER_SEC << endl;
#define ffe freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
 
int main() {
  ioso

  string s,t;
  cin >> s >> t;
  ll cn=0;
  for(int i=0;i<s.length();i++) {
    if(s[i]!=t[i]) {
      cn++;
    }
  }
  cout << cn << endl;
}

Measured memory_bytes: 3880
#include <bits/stdc++.h>
using namespace std;
int main () {
	int n; cin >> n;
	int sum = 0, maxj = 0;
	for (int i = 0; i < n; i++) {
		int x, y; cin >> x >> y;
		if (x == y) sum++;
		else sum = 0;
		maxj = max(maxj, sum);
	}
	if (maxj >= 3) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{    
    long long a, b, n;
    cin >> a >> b >> n;

    // nがbの倍数より大きい場合, b-1
    long long ans = 0;
    if(n >= b){
        ans = (a*(b-1)/b);
    } 
    // nがbより小さいならマックス
    else{
        ans = (a*n/b);
    }

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

Measured memory_bytes: 3596
def linear_approximation(N: int, A: int)->int:
    """悲しさを f(b) = sum|ai - (b + i)| とする。
    これを少し変形して
    f(b) = sum|b - (ai - i)|
    とする。この形の関数は b = (ai - i) の位置で傾きが代わり、
    詳しくは述べないが、ソートして N/2 番目の点で最小値になる。
    """
    new_A = []  # A の各値から i+1 を引いたものを保持しておく
    for i, a in enumerate(A):
        tmp = a - (i+1)
        new_A.append(tmp)

    b = sorted(new_A)[N//2]

    return sum(abs(a-b) for a in new_A)


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = linear_approximation(N, A)
    print(ans)


Measured memory_bytes: 25200
#include <iostream>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>
#include <set>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <fstream>
#include <deque>
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define f first
#define PI 3.14159265358979323846
#define s second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()

const int inf = (int)1e9;
const int mod = inf+7;

string s;
int a[50];

int main(){

	cin >> s;
	int n = s.size();
	for(int i=0;i<n;i++){
		int num = s[i]-96;
		a[num]++;
	}

	for(int i=1;i<=26;i++){
		if(a[i]>1){
			printf("no\n");
			return 0;
		}
	}
	printf("yes\n");

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
long long dp[110][100010];

int main(){
	int n,m;
	int w[110],v[110];
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>w[i]>>v[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			dp[i][j]=dp[i-1][j];
			if(w[i]<=j){
				dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
			}
		}
	}
	cout<<dp[n][m];
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int main(){
    int n;
    cin >> n;
    vi x(n), y(n), h(n);
    rep(i, n){
        cin >> x[i] >> y[i] >> h[i];
    }

    int MAX = 100;

    for(int posY = 0; posY <= MAX; posY++){
        for(int posX = 0; posX <= MAX; posX++){
            int needH = -1;

            rep(i, n){
                if(h[i] > 0){
                    int tmp = h[i] + abs(posY - y[i]) + abs(posX - x[i]);
                    if(needH == -1){
                        needH = tmp;
                    }
                    else{
                        if(needH != tmp){
                            needH = -2;
                            break;
                        }
                    }
                }
            }
            if(needH == -2) continue;

            rep(i, n){
                if(h[i] == 0){
                    int dist = abs(posY - y[i]) + abs(posX - x[i]);
                    if(needH > dist){
                        needH = -2;
                        break;
                    }
                }
            }

            if(needH == -2) continue;

            //見つけられたら答えをそのまま返す．
            cout << posX << " " << posY << " " << needH << endl;
            return 0;
        }
    }


    return 0;
}

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

int main(){
	char WX[7][6],WY[6][7];
	for(int i=0;i<7;i++){
		for(int j=0;j<6;j++){
			WX[i][j] = 0;
			WY[j][i] = 0;
		}
	}
	for(int i=1;i<5;i++) cin >> WX[i][1];
	for(int i=1;i<6;i++) cin >> WY[1][i];
	for(int i=1;i<5;i++) cin >> WX[i][2];
	for(int i=1;i<6;i++) cin >> WY[2][i];
	for(int i=1;i<5;i++) cin >> WX[i][3];
	for(int i=1;i<6;i++) cin >> WY[3][i];
	for(int i=1;i<5;i++) cin >> WX[i][4];
	for(int i=1;i<6;i++) cin >> WY[4][i];
	for(int i=1;i<5;i++) cin >> WX[i][5];

	int NX = 1;
	int NY = 1;
	char s = 'R';
	while(1){
		if(s=='R'){
			if(WY[NY-1][NX]=='1'){ s = 'U'; NY--; cout << s;}
			else if(WX[NX][NY]=='1'){ NX++; cout << s;}
			else if(WY[NY][NX]=='1'){ s = 'D'; NY++; cout << s;}
			else s = 'L';
		}
		else if(s=='L'){
			if(WY[NY][NX]=='1'){ s = 'D'; NY++; cout << s;}
			else if(WX[NX-1][NY]=='1'){ NX--; cout << s;}
			else if(WY[NY-1][NX]=='1'){ s = 'U'; NY--; cout << s;}
			else s = 'R';
		}
		else if(s=='U'){
			if(WX[NX-1][NY]=='1'){ s = 'L'; NX--; cout << s;}
			else if(WY[NY-1][NX]=='1'){ NY--; cout << s;}
			else if(WX[NX][NY]=='1'){ s = 'R'; NX++; cout << s;}
			else s = 'D';
		}
		else if(s=='D'){
			if(WX[NX][NY]=='1'){ s = 'R'; NX++; cout << s;}
			else if(WY[NY][NX]=='1'){ NY++; cout << s;}
			else if(WX[NX-1][NY]=='1'){ s = 'L'; NX--; cout << s;}
			else s = 'U';
		}
		if(NX*NY==1) break;
	}
cout << endl;
}

Measured memory_bytes: 1132
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    string s;
    cin >> s;
    cout << s.substr(0, s.size() - 8) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char a,b,c,d;
    while(scanf("%c %c",&a,&b)!=EOF)
    {
        getchar();
        c=a-'A';
        d=b-'A';
        if(c==d)
        {
            printf("=\n");
        }
        else if(c>d)
        {
            printf(">\n");
        }
        else
        {
            printf("<\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256