akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int main() {

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

	int N;
	cin >> N;

	struct data { lint x, y, h; };
	vector<data> d(N);
	for (int i = 0; i < N; i++) cin >> d[i].x >> d[i].y >> d[i].h;

	for (int x = 0; x <= 100; x++) {
		for (int y = 0; y <= 100; y++) {
			
			lint ref = LINF;
			for (const auto &e : d) chmin(ref, e.h + abs(e.x - x) + abs(e.y - y));

			if (all_of(d.begin(), d.end(), 
				[&](data d) { return max(ref - abs(d.x - x) - abs(d.y - y), 0LL) == d.h; })) {

				cout << x << " " << y << " " << ref << "\n";
				return 0;
			}

		}
	}

	return -1;
}

Measured memory_bytes: 256
N=input()
digi=int(N[-1])
if digi == 2 or digi == 4 or digi == 5 or digi == 7 or digi == 9:
    print("hon")
elif digi == 0 or digi == 1 or digi == 6 or digi == 8:
    print("pon")
else:
    print("bon")


Measured memory_bytes: 9164
mod = 10 ** 9 + 7
mod2 = 2**61+1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

def iip(listed):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def iip_ord():
    return [ord(i) - ord("a") for i in input()]


def main():
    ans = solve()
    if ans is not None:
        print(ans)

def solve():
    N = iip(False)
    A = []
    for i in range(N):
        A.append(iip(False))

    maxes = [1]
    nc = 1
    for a in A:
        idx = bisect_right(maxes, -a)
        #print(idx, a)
        #print(maxes)
        if idx == nc:
            maxes.append(-a)
            nc += 1
        else:
            maxes[idx] = -a

    print(nc)

#####################################################ライブラリ集ここから

def split_print_space(s):
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def koenai_saidai_x_index(sorted_list, n):
    l = 0
    r = len(sorted_list)
    if len(sorted_list) == 0:
        return False
    if sorted_list[0] > n:
        return False

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] == n:
            return x
        elif sorted_list[x] > n:
            r = x
        else:
            l = x
    return l


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        # print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod - 2)


def power(n, p, mod_= mod):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

Measured memory_bytes: 11644
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}


int main() {

    int n;
    cin>>n;

    vector<ll>a(n*3);
    rep(i,n*3)cin>>a[i];

    sort(a.begin(),a.end());

    ll ans=0;

    for(int i=n;i<3*n;i+=2)ans+=a[i];

    cout<<ans<<endl;

}






Measured memory_bytes: 2560
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    x, a = LI()
    if x < a:
        print(0)
    else:
        print(10)
    return

#B
def B():
    n, x = LI()
    L = LI()
    ans = 0
    c = 1
    for i in L:
        ans += i
        if ans <= x:
            c += 1
            continue
        break
    print(c)
    return

#C
def C():
    W, H, x, y = LI()
    a = W * H / 2
    b = 0
    if W/2 == x and H/2 == y:
        b = 1
    print(a,b)
    return

#D
def D():
    n, k = LI()
    a = LI()
    dp = [0] * (n)
    for i in range(n):
        dp[i] += dp[i - 1] + a[i]
    ans = 0
    dp.insert(0, 0)
    #print(dp)
    for i in range(1,n+1):
        ai = bisect_left(dp, k + dp[i-1])
        ans += n+1 - ai
        #print(ai, i, k + dp[i-1])
    print(ans)

    return

#E
def E():
    n, m = LI()
    s = LI()
    t = LI()
    dp = [[0] * (m+1) for i in range(n+1)]
    dp[0][0] = 0
    for i in range(n+1):
        dp[i][0] = 1
    for k in range(m + 1):
        dp[0][k] = 1
    for i in range(1, n + 1):
        for j in range(1, m + 1):
            if s[i - 1] == t[j - 1]:
                dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod
            else:
                dp[i][j] = (dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%mod
    print(dp[n][m])
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    E()


Measured memory_bytes: 74204
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

xzy = []
for _ in range(4):
  xzy.append([])

for x, y in xy:
  xzy[0].append(x + y)
  xzy[1].append(x - y)
  xzy[2].append(-x + y)
  xzy[3].append(-x - y)


anses = []
for z in xzy:
  anses.append(max(z) - min(z))
print(max(anses))


Measured memory_bytes: 77400
/* C - One Quadrillion and One Dalmatians */

#include <stdio.h>
#define ALPH 26

/*
long long ExAlph(int n){
  if(n == 0) return 1;
  else return ALPH * ExAlph(n - 1);
}
*/

int main(void){
  long long N, n;
  long long exAlph[12];
  scanf("%lld", &N);
  for(int i = 0; i < 12; i++){
    if(i == 0){
      exAlph[i] = 1;
    }else{
      exAlph[i] = exAlph[i - 1] * ALPH;
    }
    // printf("%lld\n", exAlph[i]);
  }
  n = N;
  for(int i = 1; ; i++){
    if(n <= exAlph[i]){ // 出力される文字数はiで確定
      n--;
      for(int j = i; j > 0; j--){
        printf("%c", (int)('a' + n / exAlph[j - 1]));
        n -= n / exAlph[j - 1] * exAlph[j - 1];
      }
      break;
    }else{
      n -= exAlph[i];
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 1660
#include"bits/stdc++.h"
using namespace std;
#define int int64_t
int ar[20][20];
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,x;cin>>n>>m>>x;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i][0];
        for(int j=1;j<=m;j++)
            cin>>ar[i][j];
    }
    int len=pow(2,n+1);
    len-=1;
    int ans=(int)1e9;
    int tval=0;
    for(int i=1;i<=len;i++)
    {
        tval=0;
        bitset<32> kk=i;
        int br[20];
        for(int j=0;j<20;j++)
            br[j]=0;
        for(int j=0;j<20;j++)
        {
            if(kk[j]==1)
            {
                tval+=ar[j][0];
                for(int l=1;l<=m;l++)
                {
                    br[l]+=ar[j][l];
                }
            }
        }
        bool flag=true;
        for(int j=1;j<=m;j++)
            if(br[j]<x)
                flag=false;
        if(flag)
        {
            ans=min(ans,tval);
        }
    }
    if(ans==1e9)
        cout<<"-1\n";
    else
        cout<<ans<<"\n";
    return 0;
}


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

int main(){
  int h, w;
  
  while ( true ){
    cin >> h >> w;
    
    if(h==0 && w==0)break;
    
    rep(i, h) {
      rep(j, w) {
        if((i+j)%2==0) cout << "#";
        else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String str = sc.next();
		if(N>=3200){
			System.out.println(str);
		}else{
			System.out.println("red");
		}
	}
}

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

template<class T>
std::vector<T> read_vector(const uint64_t n) {
    auto v = std::vector<T>();
    v.reserve(n);

    for(uint64_t i = 0; i < n; ++i) {
        T t;
        std::cin >> t;
        v.push_back(t);
    }

    return v;
}

int main() {
    int k, n;
    std::cin >> k >> n;

    const auto as = read_vector<int>(n);

    int max_distance = k - as[n - 1] + as[0];

    for(int i = 0; i < n - 1; ++i) {
        max_distance = std::max(max_distance, as[i + 1] - as[i]);
    }

    std::cout << k - max_distance << std::endl;

    return 0;
}


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

string s;
int ans, tmp;

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

	cin >> s;
	for (int i = 0 ; i < s.size() ; i++){
		if (s[i] == 'A' ||s[i] == 'C' ||s[i] == 'G' ||s[i] == 'T' ){
		 	tmp++;
		}
		else {
		 	if (ans < tmp)
		 		ans = tmp;
		 	tmp = 0;	
		}
	}
	if (ans < tmp)
		ans = tmp;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if(x>0) cout<<"Positive"<<'\n';
    else if(y>=0) cout<<"Zero"<<'\n';
    else if((x&1)^(y&1)) cout<<"Positive"<<'\n';
    else cout<<"Negative";
    return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});
process.stdin.on('end', function() {
    main(g_input.split(/\r?\n/));
});

function main(inputs) {
  //`input` に入力が改行で区切られた配列として入ってくるので頑張って
  var rgb = inputs[0].split(" ");
  if((parseInt(rgb[1])*10 + parseInt(rgb[2])) % 4 == 0){
    console.log("YES");
  }else{
    console.log("NO");
  }
}


Measured memory_bytes: 21192
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    int n;
    cin >> n;
    vector <int> a(n),pre(n),suf(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(i){
            pre[i]=__gcd(pre[i-1],a[i]);
        }
        else{
            pre[i]=a[i];
        }
    }
    suf[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--){
        suf[i]=__gcd(suf[i+1],a[i]);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        int val=0;
        if(i){
            val=__gcd(val,pre[i-1]);
        }
        if(i<n-1){
            val=__gcd(val,suf[i+1]);
        }
        ans=max(ans,val);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1536
S=list(input())
N=len(S)
A=[]
B=[]
for i in range(N):
    A.append(str(i%2))
    B.append(str((i+1)%2))
countA=0
countB=0
for x in range(N):
    if A[x]!=S[x]:
        countA+=1
    else:
        countB+=1

print(min(countA,countB))

Measured memory_bytes: 16596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		sc.close();

		if ( (c - a - b) > 0 && 4 * a * b < (c - a - b) * (c - a - b) ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

// linear search
// bool linear_search(vector<int> &S, int key, int n) {
//     S.at(n) = key;
//     int i = 0;

//     while (S.at(i) != key) {
//         i++;
//     }
//     return i != n;
// }

// int main() {
//     int n;
//     cin >> n;
//     vector<int> S(10001);

//     for (int i = 0; i < n; i++)
//     {
//         cin >> S[i];
//     }

//     int q;
//     cin >> q;
//     vector<int> T(501);

//     for (int i = 0; i < q; i++) {
//         cin >> T[i];
//     }

//     int cnt = 0;
//     for (int i = 0; i < q; i++) {
//         if (linear_search(S, T.at(i), n)) {
//             cnt++;
//         }
//     }
//     cout << cnt << endl;
// }

bool linear_search(vector<int> S, int key) {
    for (int x : S) {
        if (x == key) {
            return true;
        }
    }
    return false;
}

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

    vector<int> S;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        S.push_back(tmp);
    }

    int q;
    cin >> q;
    vector<int> T;
    for (int i = 0; i < q;i++) {
        int tmp;
        cin >> tmp;
        T.push_back(tmp);
    }

    int cnt = 0;
    for (int x : T)
    {
        if (linear_search(S, x)) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


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

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

    rep(i,3) {
       if(n % 10 == 7){
          cout << "Yes" << endl;
          return 0;
       }
       n = n / 10;
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3588
#include <cstdio>
#include <cstring>

int a[1000][1000];

int main()
{
	int n; scanf("%d", &n);
	int id = -1;
	for(int i = 1; i * (i + 1) / 2 <= n; i++)
	{
		if(n == i * (i + 1) / 2) 
		{
			id = i; break;
		}
	}
	if(id == -1) return 0 * puts("No");
	puts("Yes");
	printf("%d\n", id + 1);
	int s = 0;
	for(int i = 1; i <= id + 1; i++)
	{
		printf("%d ", id);
		for(int j = 1; j < i; j++)
		{
			a[i][j] = a[j][i - 1];
		}
		for(int j = i; j <= id; j++)
			a[i][j] = ++s;
		for(int j = 1; j <= id; j++) printf("%d ", a[i][j]);
		puts("");
	}
	return 0;
}

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

int main(){
	int n,m;
	while(cin>>n>>m){
		if(n==0&&m==0)break;
		int last=0;
		if(n==1){
			for(int i=0;i<10;i++){
				if(i==m)last++;
			}
		}
		else if(n==2){
			for(int i=0;i<10;i++){
				for(int j=i+1;j<10;j++){
					if(i+j==m)last++;
				}
			}
		}
		else if(n==3){
			for(int i=0;i<10;i++){
				for(int j=i+1;j<10;j++){
					for(int k=j+1;k<10;k++){
						if(i+j+k==m)last++;
					}
				}
			}
		}
		else if(n==4){
			for(int i=0;i<10;i++){
				for(int j=i+1;j<10;j++){
					for(int k=j+1;k<10;k++){
						for(int l=k+1;l<10;l++){
							if(i+j+k+l==m)last++;
						}
					}
				}
			}
		}
		else if(n==5){
			for(int i=0;i<10;i++){
				for(int j=i+1;j<10;j++){
					for(int k=j+1;k<10;k++){
						for(int l=k+1;l<10;l++){
							for(int p=l+1;p<10;p++){
								if(i+j+k+l+p==m)last++;
							}
						}
					}
				}
			}
		}
		else if(n==6){
			for(int i=0;i<10;i++){
				for(int j=i+1;j<10;j++){
					for(int k=j+1;k<10;k++){
						for(int l=k+1;l<10;l++){
							for(int p=l+1;p<10;p++){
								for(int o=p+1;o<10;o++){
									if(i+j+k+l+p+o==m)last++;
								}
							}
						}
					}
				}
			}
		}
		else if(n==7){
			for(int i=0;i<10;i++){
				for(int j=i+1;j<10;j++){
					for(int k=j+1;k<10;k++){
						for(int l=k+1;l<10;l++){
							for(int p=l+1;p<10;p++){
								for(int o=p+1;o<10;o++){
									for(int u=o+1;u<10;u++){
										if(i+j+k+l+p+o+u==m)last++;
									}
								}
							}
						}
					}
				}
			}
		}
		else if(n==8){
			for(int i=0;i<10;i++){
				for(int j=i+1;j<10;j++){
					for(int k=j+1;k<10;k++){
						for(int l=k+1;l<10;l++){
							for(int p=l+1;p<10;p++){
								for(int o=p+1;o<10;o++){
									for(int u=o+1;u<10;u++){
										for(int y=u+1;y<10;y++){
											if(i+j+k+l+p+o+u+y==m)last++;
										}
									}
								}
							}
						}
					}
				}
			}
		}
		else if(n==9){
			for(int i=0;i<10;i++){
				for(int j=i+1;j<10;j++){
					for(int k=j+1;k<10;k++){
						for(int l=k+1;l<10;l++){
							for(int p=l+1;p<10;p++){
								for(int o=p+1;o<10;o++){
									for(int u=o+1;u<10;u++){
										for(int y=u+1;y<10;y++){
											for(int t=y+1;t<10;t++){
												if(i+j+k+l+p+o+u+y+t==m)last++;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		else{
			for(int i=0;i<10;i++){
				for(int j=i+1;j<10;j++){
					for(int k=j+1;k<10;k++){
						for(int l=k+1;l<10;l++){
							for(int p=l+1;p<10;p++){
								for(int o=p+1;o<10;o++){
									for(int u=o+1;u<10;u++){
										for(int y=u+1;y<10;y++){
											for(int t=y+1;t<10;t++){
												for(int q=t+1;q<10;q++){
													if(i+j+k+l+p+o+u+y+t+q==m)last++;													
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		cout<<last<<endl;
	}
}


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

using namespace std;

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

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

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


void solve(long long N, std::vector<long long> P) {
    vector<pair<int, int> > a;
    for (int i = 0; i < P.size(); i++) a.push_back({P[i], i});
    sort(a.rbegin(), a.rend());

    set<int> ps;
    ps.insert(-1);
    ps.insert(-2);
    ps.insert(N);
    ps.insert(N + 1);

    long long ans = 0;
    for (auto i : a) {
        int l = *--ps.lower_bound(i.second);
        int r = *ps.upper_bound(i.second);
        if (l >= 0) {
            int l2 = *--ps.lower_bound(l);
            int r2 = *ps.upper_bound(i.second);
            ans += 1ll * (l - l2) * (r2 - i.second) * i.first;
        }

        if (r < N) {
            int r2 = *ps.upper_bound(r);
            int l2 = *--ps.lower_bound(i.second);
            ans += 1ll * (r2 - r) * (i.second - l2) * i.first;
        }
        ps.insert(i.second);
    }
    cout << ans << endl;

}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> P(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &P[i]);
    }
    solve(N, std::move(P));
    return 0;
}


Measured memory_bytes: 6516
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int main()
{
	int n, p;
	while (scanf("%d", &n), n)
	{
		typedef pair<int, string> P;
		
		P pro[512];
		rep (i, n)
		{
			char buf[64];
			int w, s;
			scanf("%s%d%d", buf, &w, &s);
			pro[i] = P(w*24*60 + s/100*60 + s%100, buf);
		}
		sort(pro, pro + n);

		scanf("%d", &p);
		set<string> fav;
		rep (i, p)
		{
			char buf[64];
			scanf("%s", buf);
			fav.insert(buf);
		}

		const int week_minutes = 7*24*60;
		bool watch[week_minutes];
		fill_n(watch, week_minutes, false);
		int res = 0;
		rep (i, n)
		{
			string& name = pro[i].second;
			int time = pro[i].first;
			if (!fav.count(name))
				continue;

			for (int j = 0; j < 30; ++j)
			{
				int t = (time + j) % week_minutes;
				if (watch[t])
				{
					res = -1;
					break;
				}
				watch[t] = true;
			}
			if (res == -1)
				break;

			++res;
		}
		if (res == -1)
		{
			puts("-1");
			continue;
		}

		rep (i, n)
		{
			string& name = pro[i].second;
			int time = pro[i].first;
			bool ok = true;
			for (int j = 0; j < 30; ++j)
			{
				int t = (time + j) % week_minutes;
				if (watch[t])
				{
					ok = false;
					break;
				}
				watch[t] = true;
			}
			if (ok)
				++res;
		}

		printf("%d\n", res);
	}
}

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

#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL);
#define ll long long
#define rep(i,l,r) for(ll i=l;i<r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pp pair<ll,ll>
#define x first
#define y second


int main() {
	IOS;

	ll n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	if(s[k-1] < 97)
	    s[k-1] = s[k-1] + 32;
	cout<<s;
	return 0;
}

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

int main(){
  vector<int> vec(9);
  for (int i = 0; i < 9; i++) {
    cin >> vec.at(i);
  }
  int a;
  cin>>a;
  vector<int> vec2(a);
  for (int i = 0; i < a; i++) {
    cin >> vec2.at(i);
  }  
  vector<int> vec3(9);
  
  for (int n = 0; n < a; n++){
  for(int i= 0; i<9; i++){
    if(vec2[n]==vec[i]){vec3[i]=1;}
    }
    }
    
  int c =0;  

  if(vec3[1-1]+vec3[2-1]+vec3[3-1]==3) c=1;
  if(vec3[4-1]+vec3[5-1]+vec3[6-1]==3) c=1;
  if(vec3[7-1]+vec3[8-1]+vec3[9-1]==3) c=1;
  if(vec3[1-1]+vec3[4-1]+vec3[7-1]==3)c=1;
  if(vec3[2-1]+vec3[5-1]+vec3[8-1]==3)c=1;
  if(vec3[3-1]+vec3[6-1]+vec3[9-1]==3)c=1;
  
  if(vec3[1-1]+vec3[5-1]+vec3[9-1]==3)c=1;
  if(vec3[3-1]+vec3[5-1]+vec3[7-1]==3) c=1;
  
  if(c==1)cout << "Yes"<<endl;
  else cout << "No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
#define INF 10000000000000000
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
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;
}

struct edge
{
    ll to;
    ll cost;
};

typedef pair<ll, ll> P;

int main()
{
    ll n, m, s, t;
    cin >> n >> m >> s >> t;

    vector<edge> G1[n], G2[n];
    priority_queue<P, vector<P>, greater<P>> que1, que2;
    vector<ll> d1(n, INF), d2(n, INF);

    d1[s - 1] = 0;
    que1.push(P(0, s - 1));
    d2[t - 1] = 0;
    que2.push(P(0, t - 1));

    rep(i, m)
    {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        edge e1, e2, e3, e4;
        e1.to = v - 1;
        e1.cost = a;
        e2.to = v - 1;
        e2.cost = b;
        e3.to = u - 1;
        e3.cost = a;
        e4.to = u - 1;
        e4.cost = b;
        G1[u - 1].push_back(e1);
        G1[v - 1].push_back(e3);
        G2[u - 1].push_back(e2);
        G2[v - 1].push_back(e4);
    }

    while (!que1.empty())
    {
        P p = que1.top();
        que1.pop();
        ll v = p.second;
        if (d1[v] < p.first)
        {
            continue;
        }
        rep(i, G1[v].size())
        {
            edge e = G1[v][i];
            if (d1[e.to] > d1[v] + e.cost)
            {
                d1[e.to] = d1[v] + e.cost;
                que1.push(P(d1[e.to], e.to));
            }
        }
    }

    while (!que2.empty())
    {
        P p = que2.top();
        que2.pop();
        ll v = p.second;
        if (d2[v] < p.first)
        {
            continue;
        }
        rep(i, G2[v].size())
        {
            edge e = G2[v][i];
            if (d2[e.to] > d2[v] + e.cost)
            {
                d2[e.to] = d2[v] + e.cost;
                que2.push(P(d2[e.to], e.to));
            }
        }
    }

    vector<ll> ans(n, INF);

    ll money = pow(10, 15);
    ll val = 0;
    for (ll i = n - 1; i >= 0; i--)
    {
        ll tmp = money - (d1[i] + d2[i]);
        val = max(val, tmp);
        ans[i] = val;
    }

    rep(i, n)
    {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 20088
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

ll modpow(ll a, ll b){
    if(b == 0) return 1;
    else if(b % 2 == 0){
        ll d = modpow(a, b/2) % MOD;
        return (d * d) % MOD;
    }
    else{
        return (a * modpow(a, b-1)) % MOD;
    }
}

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

    int n, c; cin>>n>>c;
    vector<ll> a(n), b(n);
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=0; i<n; i++) cin>>b[i];

    vector<vector<ll>> pre_modpow(410, vector<ll>(410, 0));
    for(int i=0; i<=400; i++){
        for(int j=0; j<=400; j++){
            pre_modpow[i][j] = modpow(i, j);
        }
    }

    vector<vector<ll>> sum(n+1, vector<ll>(c+1, 0));
    for(int i=0; i<n; i++){
        for(int j=0; j<=c; j++){
            for(int k=a[i]; k<=b[i]; k++){
                sum[i][j] += pre_modpow[k][j];
                sum[i][j] %= MOD;
            }
        }
    }

    vector<vector<ll>> dp(n+1, vector<ll>(c+1, 0));
    dp[0][0] = 1;

    for(int i=0; i<n; i++){
        for(int j=0; j<=c; j++){
            for(int k=0; k<=j; k++){
                dp[i+1][j] += dp[i][j-k] * sum[i][k];
                dp[i+1][j] %= MOD;
            }
        }
    }

    cout << dp[n][c] << endl;

    return 0;
}

Measured memory_bytes: 4096
A = []
min_res = 11

for i in range(5):
  a = int(input())
  A.append(a)
  tmp = a%10
  if(tmp == 0): 
    tmp = 10
  if(min_res > tmp):
    min_res = tmp
    min_index = i

ans = 0
for i in range(5):
  a = A[i]
  if(i != min_index):
    if(a%10 == 0):
      ans += a
    else:
      tmp = 10 - a%10
      ans += a + tmp
  else:
    ans += a
print(ans)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	ret := make([]int, 9)
	for i := 0; i < 9; i++ {
		ret[i] = nextInt()
	}
	n := nextInt()
	game := make([]int, n)
	for i := 0; i < n; i++ {
		game[i] = nextInt()
	}

	res := make([]bool, 9)
	for i, r := range ret {
		for _, g := range game {
			if r == g {
				res[i] = true
			}
		}
	}
  fmt.Println(bingo(res))
}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func bingo(res []bool) string {
	b := "No"
	if res[0] && res[1] && res[2] ||
	res[3] && res[4] && res[5] ||
	res[6] && res[7] && res[8] ||
	res[0] && res[3] && res[6] ||
	res[1] && res[4] && res[7] ||
	res[2] && res[5] && res[8] ||
	res[0] && res[4] && res[8] ||
	res[2] && res[4] && res[6] {
		b = "Yes"
	}
	return b
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    string S;
    cin >> S;
    if (S == "Sunny")cout << "Cloudy" << endl;
    else if (S == "Cloudy")cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main()
{
    int n;
 
    while (true)
    {
        cin >> n;
 
        if (n == -1) { break; }
 
        if (n == 0)
        {
            cout << "0" << endl;
        }
        else
        {
            int t = (1 << 20);
 
            for (int i = 0; i < 10; i++)
            {
                t /= 4;
 
                if (n / t)
                {
                    cout << (n / t) % 4;
                }
            }
 
            cout << endl;
        }
    }
 
    return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include "math.h"


using namespace std;

int main()
{
	int n = 0;
	cin >> n;
	int* ike = new int[n+1];
	for (int i = 0; i < n; i++) {
		cin >> ike[i+1];
	}
	int ima = 1;
	int doredake = 0;
	for (int i = 1; i < n+1; i++) {
		ima = ike[ima];
		if (ima == 2) {
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;

	/* c
	int n;
	int m;
	long long int nka = 1;
	long long int mka = 1;
	long long int ans = 0;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		nka = nka * i;
	}
	for (int i = 0; i < m; i++) {
		mka = mka * i;
	}
	ans = ((nka * mka * 2) % 10 ^ 9 + 7);
	cout << ans << endl;*/

	/*
	int n = 0;
	int a = 0;
	int b = 0;
	cin >> n >> a >> b;
	if (0 <= (a - b)) {
		cout << "delicious" << endl;
		return 0;
	}
	if (abs((a - b)) > n) {
		cout << "dangerous" << endl;
		return 0;
	}
	cout << "safe" << endl;
	return 0;*/
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)      //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++) //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)    //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))        //array size
#define SORTD(a) sort(a,a+ASIZE(a),greater<int>()) //sort in descending order for array
#define SORTA(a) sort(a,a+ASIZE(a))                //sort in ascending order for array
#define SORTS(a) sort(a.begin(),a.end())           //sort in ascending order for string type
typedef long long LL;
typedef unsigned int UINT;
 
void SCAN(int *a){scanf("%d",a);}                             //scan for type int
void SCAN(int *a,int n){int i;REP(i,n){scanf("%d",&a[i]);}}   //scan for type int array
void SCAN(UINT *a){scanf("%u",a);}                            //scan for type unsigned int
void SCAN(UINT *a,int n){int i;REP(i,n){scanf("%u",&a[i]);}}  //scan for type unsigned int array
void SCAN(LL *a){scanf("%lld",a);}                            //scan for type long long int
void SCAN(LL *a,int n){int i;REP(i,n){scanf("%lld",&a[i]);}}  //scan for type long long int array
void SCAN(char *c){scanf(" %c",c);}                           //scan for type char
void SCAN(char *c,int n){int i;REP(i,n){scanf(" %c",&c[i]);}} //scan for type char array
 
const int MOD = 1000000007;
const int INF = 1000000000;
 
const int DX4[4]= {-1,0,0,1};
const int DY4[4]= {0,-1,1,0};
 
//fill an N-dimensional array with val
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
	fill((T*)array,(T*)(array+N),val);
}
 
int pascalTri(int n,int r){
	int tri[n+1][n+1];
	int i,j;
	REP(i,n+1){REP(j,n+1){tri[i][j]=0;}}
	REP(i,n+1){
		REP(j,n+1){
			if(j>i){break;}
			if(j==0||j==i){tri[i][j]=1;}else{tri[i][j]=(tri[i-1][j-1]%MOD+tri[i-1][j]%MOD)%MOD;}
		}
	}
	return tri[n][r];
}
 
 
int main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	int n,z,w;
	int i,j;
	
	SCAN(&n);SCAN(&z);SCAN(&w);
	int a[n];
	SCAN(a,n);
	

	if(n==1){
		printf("%d\n",abs(a[0]-w));
	}else{
      	printf("%d\n",max(abs(a[n-1]-w),abs(a[n-2]-a[n-1])));
	}
 	
	return 0;
}

Measured memory_bytes: 256
def solve(s, t):
    n, m = len(s), len(t)
    dp = [[0]*(m+1) for _ in range(n+1)]
    for i in range(n):
        for j in range(m):
            if s[i] == t[j]:
                dp[i+1][j+1] = dp[i][j] + 1
            else:
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
    sol = []
    pr, pc = n, m
    while pr > 0 and pc > 0:
        if dp[pr][pc] > dp[pr-1][pc] and dp[pr][pc] > dp[pr][pc-1]:
            sol.append(s[pr-1])
            pr -= 1
            pc -= 1
        elif dp[pr][pc-1] > dp[pr-1][pc]:
            pc -= 1
        else:
            pr -= 1
    return ''.join(reversed(sol))
  
s = input()
t = input()
print(solve(s, t))

Measured memory_bytes: 111836
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string s;
  cin >> s;
  rep(i, SZ(s)){
    if(s[i] == '7') Pr(1);
  }
  Pr(0);
}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[40]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	int n;
	cin >> n;
	cout << a[n-1] << endl;
	return 0;
}


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

int main(){
  ll n;
  ll p;
  ll ans=1;
  cin >>n>>p;
  vector<pair<ll,ll>>fac;
  for(ll i=2;i*i<=p;i++){
    if(p%i!=0)continue;
    ll ex=0;
    while(p%i==0){
      p/=i;
      ex++;
    }
    fac.push_back({i,ex});
  }
  if(p!=1)fac.push_back({p,1});
  for(auto f:fac){
    for(ll i=0;i<f.second/n;i++)
      ans*=f.first;
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 3632
local N = io.read("*n")
local abc = "abcdefghijklmnopqrstuvwxyz"

local N_to_0_num = N
local str = ""
while N_to_0_num > 0 do
	local index = N_to_0_num%26
	if index == 0 then
		index = 26
	end
	str = str..abc:sub(index, index)
	N_to_0_num = (N_to_0_num - 1) // 26
end

print(str:reverse())


Measured memory_bytes: 2640
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    vector<char> c;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '0') c.push_back('0'); 
        if(s[i] == '1') c.push_back('1');
        if(s[i] == 'B') {
            if(c.empty()){
                continue;
            }
            else c.pop_back();
        }
    }
    for(int i = 0; i < c.size(); i++)
        cout << c[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

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


ll gcd(ll a, ll b)
{
	ll c=0;

	while((c=a%b))
	{
		a=b;
		b=c;
	}
	return b;
}


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


int main(void)
{
	ll a, b, c, d;

	while(scanf("%lld%lld%lld%lld", &a, &b, &c, &d)==4)
	{
		a--;
		ll x=a-a/c-a/d+a/lcm(c, d);
		ll y=b-b/c-b/d+b/lcm(c, d);
		ll ans=y-x;
		printf("%lld\n", ans);
	}
	return 0;
}


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

const int mod = 1000000007;

int dp[110][110];
string POS = "ACGT";

int calc(int mask, int x){
	return (mask << 2 | x) & (1 << 2 * 3) - 1;
}

void add(int &a, int b){
	a = (a + b) % mod;
}

bool check(int len, int mask, int x){
	if (len < 2) return 1;
	mask = mask << 2 | x, len++;
	string s;
	for (int i = 0; i < len; i++){
		s.push_back(POS[mask & 3]);
		mask >>= 2;
	}
	if (s.find("AGC") != -1) return 0;
	for (int i = 0; i < len - 1; i++){
		swap(s[i], s[i + 1]);
		if (s.find("AGC") != -1) return 0;
		swap(s[i], s[i + 1]);
	}
	return 1;
}

int main(){
	int n; scanf("%d", &n);
	dp[0][0] = 1;
	for (int i = 0; i < n; i++){
		for (int mask = 0; mask < (1 << 2 * 3); mask++){
			if (dp[i][mask] == 0) continue;
			for (int x = 0; x < 4; x++){
				if (check(min(i, 4), mask, x)) add(dp[i + 1][calc(mask, x)], dp[i][mask]);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < (1 << 2 * 3); i++){
		add(ans, dp[n][i]);
	}
	printf("%d\n", ans);
	return 0;
}


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

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

	int array[100];
	for (int i = 0; i < n; i++) {
		cin >> array[i];
	}

	int count = 0;
	for (int i = 0; i <= n - 1; i++) {
		for (int j = n - 1; j >= i + 1; j--) {
			if (array[j] < array[j - 1]) {
				int tmp = array[j];
				array[j] = array[j - 1];
				array[j - 1] = tmp;
				count++;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		printf("%d%c", array[i], i != n - 1 ? ' ' : '\n');
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 1148
n, m, x = map(int, input().split())
d = []
for i in range(n):
    l = list(map(int, input().split()))
    d.append(l)

def xcheck(data):
    for i in range(1, m + 1):
        if data[i] < x:
            return False
    return True

def listup(n, m):
    d = []
    c = [i + 1 for i in range(n)]
    while True:
        d.append(tuple(c))
        if c == [m - n + i + 1 for i in range(n)]:
            break
        c[n - 1] += 1
        if c[n - 1] > m:
            for i in range(n - 1):
                if c[n - 2 - i] == m - i - 1:
                    continue
                c[n - i - 2] += 1
                for j in range(i + 1):
                    c[n - i - 1 + j] = c[n - i - 2] + j + 1
                break
    return d

dmin = -1
for i in range(1, n + 1):
    data = listup(i, n)
    for j in range(len(data)):
        cur = data[j]
        sumd = []
        for k in range(m + 1):
            s = 0
            for l in range(len(cur)):
                s += d[cur[l] - 1][k]
            sumd.append(s)
        if xcheck(sumd) == True:
            if (dmin == -1) | (sumd[0] < dmin):
                dmin = sumd[0]

print(dmin)

Measured memory_bytes: 69216
import numpy as np
def main():
    n, k = list(map(int, input().split()))
    S = list(input())
    T = []
    V = []
    a, c = S[0], 0
    for s in S:
        if s == a:
            c += 1
        else:
            T.append(a)
            V.append(c)
            a = s
            c = 1
    T.append(a)
    V.append(c)

    V = np.cumsum(np.array(V))
    max_v = len(V)
    ans = 0
    for i, t in enumerate(np.array(T)):
        if t == '0':
            r = i + 2 * k - 1
        else:
            r = i + 2 * k
        if i == 0:
            ans = max(ans, V[min(max_v - 1, r)])
        else:
            ans = max(ans, V[min(max_v - 1, r)] - V[i - 1])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16392
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

int main(){

	int n = nxt(), k = nxt();
	vector<int> a(n);

	for (int i = 0; i < n; ++i) {
		a[i] = nxt();
	}

	vector<long long> score(n + 1), score_b(n + 1);
	for (itn i = 0; i < n; ++i) {
		score[i + 1] = score[i] + max(a[i], 0);
		score_b[i + 1] = score_b[i] + a[i];
	}

	long long mx = LLONG_MIN;
	for (int i = 0; i + k <= n; ++i) {
		mx = max(mx, score[i] - score[i + k]);
		mx = max(mx, score[i] - score[i + k] + score_b[i + k] - score_b[i]);
	}

	cout << score[n] + mx << "\n";

	return 0;
}

Measured memory_bytes: 2176
import java.io.*;
import java.util.*;

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    private static StringTokenizer st;

    private static int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    private static String readToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public static void main(String[] args) throws IOException {
        pw.println(solve());
        pw.close();
    }

    private static int solve() throws IOException {
        int N = readInt();
        char[] cs = readToken().toCharArray();

        int count = 0;
        int left = 0;
        int right = N - 1;
        while (left < right) {
            while (left < right && cs[left] != 'W') left++;
            while (left < right && cs[right] != 'R') right--;
            if (left >= right) break;
            else {
                count++;
                left++;
                right--;
            }
        }

        return count;
    }
}


Measured memory_bytes: 37004
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N=Integer.parseInt(sc.next());
int K=Integer.parseInt(sc.next());
Set<Integer> num = new HashSet<>();
int[] A=new int[N];
for(int i=0;i<N;i++){
A[i]=sc.nextInt();
num.add(A[i]);
}
Arrays.sort(A);
int[] n=new int[num.size()];
int i=0;

    //個数はn[i]+1
    for(int t=1;t<N;t++){
    if(A[t]==A[t-1]){n[i]++;}else{i++;}
    }

Arrays.sort(n);
int shurui=num.size();
int ans=0;
for(int ii=0;ii<num.size();ii++){
    if(shurui>K){
shurui--;
ans+=n[ii]+1;
}else{
    System.out.println(ans);break;
    }
}



}
}

Measured memory_bytes: 99776
// Copyright 2020 Tsutomu ISHIKAWA
// Author: Tsutomu ISHIKAWA

#include <iostream>
#include <algorithm>

int main() {
    int64_t a, b, c, d;
    std::cin >> a >> b >> c >> d;
    std::cout << std::max(std::max(a*c, a*d), std::max(b*c, b*d)) << std::endl;

    return 0;
}


Measured memory_bytes: 3200
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		String S = sc.next();
		if(S.length() <= K) {
			System.out.println(S);
		}else {
			System.out.println(S.substring(0,K)+ "...");
		}
  }
}

Measured memory_bytes: 38596
#include <stdio.h>
#define N 100
int main(){

  int i,j,n,A[N],temp,count=0,minj;

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

  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    if(i!=minj){
      temp=A[i];
      A[i]=A[minj];
      A[minj]=temp;
      count++;
    }
  }


  for(j=0;j<n;j++){
    printf("%d",A[j]);
    if(j==n-1) break;
    printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2100
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n,i,j,k,x,y,ans,curr,m;
    ll a,b,c,d,e;
    cin >> a >> b;
    cin >> c >> d;
    cin >> e;
    ll need = abs(a-c);
    ll lebih = b - d;
    if(lebih <= 0) cout << "NO";
    else {
        if(lebih*e >= need) cout << "YES";
        else cout << "NO";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3640