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

#define fr first
#define sc second

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int NMAX = 2e5 + 1, INF = 1e9 + 19, MOD = 1e9;
ll LINF = 1e18;
const double EPS = 1e-8;

char cc[NMAX];

string getString() {
    scanf("%s", cc);
    return string(cc);
}

ll getManac1(string &s, int n) {
    vector<int> d1(n);
    int l=0, r=-1;
    for (int i=0; i<n; ++i) {
        int k = (i>r ? 0 : min (d1[l+r-i], r-i)) + 1;
        while (i+k < n && i-k >= 0 && s[i+k] == s[i-k])  ++k;
        d1[i] = k--;
        if (i+k > r)
            l = i-k,  r = i+k;
    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += d1[i];
    }
    return ans;
}

ll getManac2(string &s, int n) {
    vector<int> d2(n);
    int l=0, r=-1;
    for (int i=0; i<n; ++i) {
        int k = (i>r ? 0 : min (d2[l+r-i+1], r-i+1)) + 1;
        while (i+k-1 < n && i-k >= 0 && s[i+k-1] == s[i-k])  ++k;
        d2[i] = --k;
        if (i+k-1 > r)
            l = i-k,  r = i+k-1;
    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += d2[i];
    }
    return ans;
}
ll let[26];

main() {
//    freopen("input.txt", "r", stdin);
    string s = getString();
    int n = s.size();
    for (char c : s) {
        ++let[c - 'a'];
    }
    ll ans = 1ll * n * (n + 1) / 2;
    for (int i = 0; i < 26; ++i) {
        ans -= let[i] * (let[i] - 1) / 2;
    }
    printf("%lld", ans + 1- n);
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[][] grid = new int[3][3];
		for(int i =0; i < 3;i++){
			for(int j =0;j<3;j++){
				grid[i][j] = sc.nextInt();
			}
		}
		boolean b = true;
		for(int i =0; i < 3; i++){
			int x = 0;
			int y = 0;
			for(int j =0;j<3;j++){
				int bX = grid[j][i] - grid[j][((i+1) % 3)];
				int bY = grid[i][j] - grid[((i+1) % 3)][j];
				if(j ==0){
					x = bX;
					y = bY;
				}else{
					b &= x == bX;
					b &= y == bY;
				}
				if(!b) break;
			}
			if(!b) break;
		}
		System.out.println(b ? "Yes" : "No");
	}
}

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

int main(){
	int n,A[101]={},ans=0,d;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>d;
		A[d]=1;
	}
	for(int i=0;i<=100;i++){
		if(A[i]==1)ans++;
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3588
# encoding:utf-8
import copy
import numpy as np
import random
#
# n,m = map(int,input().split())
# a = [int(i) for i in input().split()]
#
# translate_match=[2,5,5,4,5,6,3,7,6]
# match = []
# for i in range(m):
#     match.append(translate_match[a[i]-1])
#
# # def dp(amari,memory):
# #     for i in range(len(match)):
# #         if amari==match[i]:
# #             print(memory)
# #             break
# #         elif amari>match[i]:
# #             next = amari-match[i]
# #             memory[i] += 1
# #             dp(next,memory)
#
# # ちょうど i 本のマッチ棒を使って、条件を満たす整数を作るときの最大桁数
#
# dp = [0]+[-1]*n
#
#
# for left_match in range(1,n+1):
#     # print(dp)
#     for j in range(len(match)):
#         if match[j]<=left_match:
#             dp[i] = max(dp[i],dp[left_match-match[j]]*10+a[j])
#             print(dp)
#
#
# print(dp[1])

def solve():
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    L = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    A.sort(reverse = True)
    #print(A)
    dp = [0] + ([-1]*N)
    #print(dp)
    for i in range(1, N+1):
        for a in A:
            if L[a] <= i:
                # print(dp)
                dp[i] = max(dp[i], dp[i-L[a]] * 10 + a)
    # print(dp)
    print(dp[-1])


if __name__=="__main__":
    solve()


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

int main() {
    int x = 0, y = 0;
    cin >> x >> y;

    for (int i = 0; i <= x; i++) {
        if (2 * i + 4 * (x - i) == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int w, a, b;
  cin >> w >> a >> b;
  int ma, mi;
  ma = max(a, b);
  mi = min(a, b);
  ma -= (mi+w);
  dump(max(ma, 0));
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

int main(){
  long long int N;
  std::string S;
  scanf("%lld", &N);
  std::cin >> S;
  
  if(N%2 == 1){
    std::cerr << "Answer:" << std::endl;
    std::cout << "No" << std::endl;
    return 0;
  }
  
  long long int N2 = N/2, flag = 1;
  for(long long int i = 0; i < N2; i++){
    if(S[i] != S[i+N2]){
      flag = 0;
      break;
    }
  }
  
  if(flag == 1){
    std::cerr << "Answer:" << std::endl;
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cerr << "Answer:" << std::endl;
    std::cout << "No" << std::endl;
  }
  

  return 0;
}


Measured memory_bytes: 384
s = str(input())

year = int(s[0:4])
month = int (s[5:7])
day = int(s[8:10])

if year == 2019:
    if month >= 5:
        print('TBD')
    else:
        print('Heisei')
elif year > 2019:
    print('TBD')
else:
    print('Heisei')

Measured memory_bytes: 3064
#include <complex>
#include <iostream>
#include <vector>

using namespace std;

struct complex_triangle{
    complex<double> a,b,c;

    complex_triangle(complex<double> &_a, complex<double> &_b, complex<double> &_c){
        a = _a;b = _b;c = _c;
    }
    
    double edge_lenth(int x){ //x= 0->bc, 1->ca, 2->ab  
        if(x==0) return abs(b-c);
        else if(x==1) return abs(c-a);
        else if(x==2) return abs(a-b);
    }

    double area(){
        complex<double> A = b - c, B = c - a;
        return abs(A.real()*B.imag() - A.imag()*B.real())/2;
    }

    double o_radi(){
        double ret = 1;
        for(int i=0;i<3;i++) ret *= edge_lenth(i);
        return ret/(4*area());
    }

    complex<double> o_cent(){ //外心
        complex<double> B = b - a, C = c - a,ret;
        double ss = (B.real()*C.imag() - B.imag()*C.real())*2;
        ret.real((C.imag()*norm(B) - B.imag()*norm(C))/ss);
        ret.imag((B.real()*norm(C) - C.real()*norm(B))/ss);
        ret += a;
        return ret;
    }
};

void solve(){
    double x1,x2,y1,y2,z1,z2;
    cin >> x1 >> x2 >> y1 >> y2 >> z1 >> z2;
    complex<double> x(x1, x2),y(y1, y2), z(z1, z2);
    complex_triangle da(x, y, z);
    complex<double> p = da.o_cent();
    //cout << da.area() << endl;
    printf("%.03f %.03f %.03f\n", p.real(), p.imag(), da.o_radi());
}

int main(){
    int n;cin >> n;
    for(int i = 0; i< n;i++) solve();
}



Measured memory_bytes: 3356
L = int(input())
n = 2
es = [(1,2,0), (1,2,1)]
limit = 2

def double():
    global es,limit,n
    _es = []
    for a,b,w in es:
        _es.append((a,b,2*w))
    _es.append((n,n+1,0))
    _es.append((n,n+1,1))
    n += 1
    es = _es
    limit *= 2

def add_bypass():
    global es,limit
    es.append((1,n,limit))
    limit += 1

for c in str(bin(L))[3:]: #skip prefix '0b1'
    if c == '1':
        add_bypass()
    if limit == L:
        break
    double()
else:
    assert(False)

print(n,len(es))
for e in es:
    print(*e)

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

N = INT()
a = LIST()

A = Counter(a)
#print(A)
ans = 0
for key, value in A.items():
	if key > value:
		ans += value
	else:
		ans += value - key

print(ans)



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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .
/// Start using lower bound !!

void solve ( int test_case )
{
    ll m ;
    cin >> m ;

    ll f = 1 ;
    ll sum = 0 ;

    for ( ll ans = 1 ; ans < m + m ; ans ++ )
    {
        ll temp = f * 7LL ;
        temp %= m ;

        sum += temp ;
        sum %= m ;

        if ( sum == 0 )
        {
            cout << ans ; line ;
            return ;
        }

        f *= 10LL ;
        f %= m ;
    }

    cout << -1 ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

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


int solve( int x ){
    if( x == 0 )return 1;
    if( x < 0 )return 0;

    rep(i,6){
        return solve( x - 100 - i );
    }
}

int dp[ 100000 ];
int main(){
    int x;
    cin >> x;
    rep(i, 6)dp[100 + i] = 1;


    REP(i, 1, 100000){

        if( dp[i] == 1 ){

            rep(j, 6){
                dp[i + 100 + j] = 1;
            }
        }
    }
    cout << (dp[x] ? 1 : 0 ) << endl;
}

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vll>;
df data(n, vll(m));
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/range/algorithm.hpp> // boost::sort(arr)
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
using boost::algorithm::join; // string s = join(arr, "");
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, t;
    cin >> n >> t;
    t--;

    vector<P> p(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }
    sort(all(p));

    vl weight(n), value(n);
    rep(i, n) {
        weight[i] = p[i].first;
        value[i] = p[i].second;
    }

    vvl dp(n+1, vl(t+1));  // dp[i+1][j] : i番目の品物までで重さの総和j以下のときの価値の総和の最大値
    rep(i, n) {
        exrep(j, 0, t) {
            chmax(dp[i+1][j], dp[i][j]);
            if(j >= weight[i]) {
                chmax(dp[i+1][j], dp[i][j - weight[i]] + value[i]);
            }
        }
    }

    ll ans = 0;
    rep(i, n) {
        chmax(ans, dp[i][t] + value[i]);
    }

    out(ans);
    re0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
using namespace std;

int main() {
	string str;
	int n=-1; int a[100][100];
	while(getline(cin,str)){
		int j=0; n++;
		for(int i=0;i<str.size();i++){
			char ch; ch=str[i]; string tmp="";
			while(ch!=',') {tmp+=ch; i++;if(i>=str.size()) break; ch=str[i]; }
			a[n][j++]=atoi(tmp.c_str());
		}
	}
	int dp[100][100]={0};
	dp[0][0]=a[0][0];
	for(int i=1;i<=n;i++){
		if(i<=n/2){
			for(int j=0;j<i+1;j++){
				if(!j) dp[i][j]=dp[i-1][j]+a[i][j];
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-1])+a[i][j];
			}
		}
		else {
			for(int j=0;j<n/2+1-(i-n/2);j++){
				if(j==n/2-(i-n/2)) dp[i][j]=dp[i-1][j]+a[i][j];
				dp[i][j]=max(dp[i-1][j],dp[i-1][j+1])+a[i][j];
			}
		}
	}
	cout << dp[n][0] << '\n' ;
}

Measured memory_bytes: 1288
using System;
    class Program
    {
      static int[] a = new int[100001];
      static long sum;
      static void Main()
      {
        int n = int.Parse(Console.ReadLine());
        var line = Console.ReadLine();
        var _line = line.Split(" ");
        for (int i = 0; i < n; i++)
        {
          int num = int.Parse(_line[i]);
          sum += num;
          a[num]++;
        }
        int q = int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++)
        {
          _line = Console.ReadLine().Split(" ");
          int b = int.Parse(_line[0]);
          int c = int.Parse(_line[1]);
          sum += (c - b) * a[b];
          Console.WriteLine(sum);
          a[c] += a[b];
          a[b] = 0;
        }
      }
    }

Measured memory_bytes: 45676
def main():
  n, k, q = map(int, input().split(' '))
  al = [int(input()) for _ in range(q)]
  ks = [k - q for _ in range(n)]
  for a in al:
    ks[a-1] += 1
  ans = list(map(convert, ks))
  print('\n'.join(ans))


def convert(k):
  return 'Yes' if k > 0 else 'No'


if __name__ == '__main__':
  main()

Measured memory_bytes: 12844
#include<stdio.h>
#include<math.h>

int main(void){
    int i,j,x[10000],n,count=0;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
        count++;
        for(j=2;j<=sqrt(x[i]);j++){
            if(x[i]%j==0){
                count--;
                break;
            }
        }
    }

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


Measured memory_bytes: 2040
A, B, C = 0, 1, 2
N = int(input())
H =[[0 for _ in range(3)] for _ in range(N)]
H[0] = list(map(int, input().split()))
for i in range(1, N):
    a, b, c = map(int, input().split())
    H[i][A] = a + max(H[i-1][B], H[i-1][C])
    H[i][B] = b + max(H[i-1][C], H[i-1][A])
    H[i][C] = c + max(H[i-1][A], H[i-1][B])
print(max(H[N-1]))

Measured memory_bytes: 24308
#include <bits/stdc++.h>
using namespace std;
int main(){

    int N,A,B,i;
    cin >> N >> A >> B;
    long long int X[N],a,count = 0;
    for(i = 0; i < N; i++) {
        cin >> X[i];
    }

    for(i = 0; i < N-1; i++) {
        a = (X[i+1] - X[i]) * A;
        if(a < B) {
            count += a;
        }else{
            count += B;
        }
    }

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


Measured memory_bytes: 1024
/***********************************************
	Author：		StupidTurtle
	Date：		2017.12.05
	Email：		31601359@std.zucc.edu.cn 
***********************************************/ 

#include <iostream>
#include <algorithm>

using namespace std;

int n , k , num ;

int main (void){
	cin >> n ;
	num = 0 ; k = n ;
	while ( k ){
		num += k % 10 ;
		k /= 10 ;
	}
	if ( n % num == 0 )	cout << "Yes" << endl ;
	else	cout << "No" << endl ;
	return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll x;cin>>x;
    ll ans;
    if(x%11==0){
        ans=(x/11)*2;
    }else if(x%11<=6){
        ans=(x/11)*2+1;
    }else{
        ans=(x/11)*2+2;
    }
    cout<<ans<<endl;
    
    return 0;
}




Measured memory_bytes: 256
n,m=map(int,input().split())
l=[]
for i in range(m):
  p,y=map(int,input().split())
  l.append([y,i,p])
l=sorted(l)
l1=[0 for i in range(n+1)] #県
l2=[[] for i in range(m)] #shi
for i in range(m):
  l1[l[i][2]]+=1
  l2[l[i][1]]=[l1[l[i][2]],l[i][2]]#何番めかとどの市か
for i in range(m):
  w=""
  w+="0"*(6-len(str(l2[i][1])))+str(l2[i][1])+"0"*(6-len(str(l2[i][0])))+str(l2[i][0])
  print(w)

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

typedef long long ll;

int n, C, L[6], P[6];
ll dp[305][32], ans;

int main() {
	scanf("%d%d", &n, &C);
	for (int i = 0; i < n; ++i)
		scanf("%d", L + i), P[i] = i;
	sort(L, L + n, greater<int>());
	ll cnt = 0;
	do {
		memset(dp, 0, sizeof dp);
		dp[L[0] * n][0] = 1;
		for (int i = 0; i < C * n; ++i)
			if (i % n) for (int j = i; j <= C * n; ++j)
				for (int all = (1 << n - 1) - 1 - (1 << i % n - 1), s = all; ; s = s - 1 & all) {
					if (dp[j][s])
						dp[min(C * n, max(j, i + L[P[i % n]] * n))][s | 1 << i % n - 1] += dp[j][s];
					if (!s)
						break;
				}
		ans += dp[C * n][(1 << n - 1) - 1];
		++cnt;
	} while (next_permutation(P + 1, P + n));
	for (int i = 0; i < n - 1; ++i)
		cnt *= C;
	printf("%.16lf\n", 1.0 * ans / cnt);
	return 0;
}


Measured memory_bytes: 384
N=int(input())
C=list(input())

white=[0]*(N+1)
red=[0]*(N+1)

for i in range(N):
    if C[i]=="W":
        white[i+1]=white[i]+1
        red[i+1]=red[i]
    else:
        white[i+1]=white[i]
        red[i+1]=red[i]+1

if white[-1]==N or red[-1]==N:
    print(0)
    exit()

ans=float("inf")
for i in range(1,N):
    wcnt=white[i]
    rcnt=red[-1]-red[i]
    m=max(wcnt,rcnt)
    ans=min(m,ans)

print(ans)

Measured memory_bytes: 20164
#include <stdio.h>

int main(void){
    int n,x,max,min;
    long int sum;
    max=-10000000;
    min=10000000;
    sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        if(x>max){max=x;}
        if(x<min){min=x;}
        sum+=x;
    }
    printf("%d %d %ld\n",min,max,sum);
}


Measured memory_bytes: 2140
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
using namespace std;

bool judge(string s, string p)//s???p????????????????????????
{		
	if(s.find(p) == string::npos){
		return false;
	}
	else{
		return true;
	}
	/*
	int size_s = s.size();
	int size_p = p.size();
	
	for(int i = 0; i < size_s; i++){
		for(int j = 0; j < size_p; j++){
			if(s[i + j] != p[j]){
				break;
			}
			if(j + 1 == size_p){
				return true;
			}
		}
	}
	return false;*/
}
void print_answer(bool judge)
{
	if(judge == true){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
}
int main(void)
{
	string s;
	string p;
	
	getline(cin, s);//??????????????????
	getline(cin, p);
	
	s = s + s;
	
	print_answer(judge(s, p));
	
	return 0;
}

Measured memory_bytes: 3192
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

long long pare(vector<long long> &tree, long long i) {
    if (tree.at(i) == i) {
        return i;
    }
    else {
        return tree.at(i) = pare(tree, tree.at(i));
    }
}

void unite(vector<long long> &tree, long long i, long long j) {
    int x = pare(tree, i);
    int y = pare(tree, j);
    if (i == j) return;
    
    tree.at(y) = x;
}

int main() {
    long long n = 0, m = 0;
    cin >> n >> m;
    vector<long long> ans(m);
    vector<pair<long long, long long>> in(m);
    long long a = 0, b = 0;
    for (int i=0; i<m; i++) {
        cin >> a >> b;
        a--;
        b--;
        in.at(i) = make_pair(a, b);
    }
    reverse(in.begin(), in.end());
    vector<long long> tree(n);
    for (long long i=0; i<n; i++) {
        tree.at(i) = i;
    }
    vector<long long> count(n, 1);
    ans.at(0) = n*(n-1)/2;
    for (long long i=1; i<m; i++) {
        long long buf1 = pare(tree, in.at(i-1).first);
        long long buf2 = pare(tree, in.at(i-1).second);
        if (buf1 == buf2) {
            ans.at(i) = ans.at(i-1);
        }
        else {
            ans.at(i) = ans.at(i-1) - count.at(buf1) * count.at(buf2);
            count.at(buf1) += count.at(buf2);
            unite(tree, buf1, buf2);
        }
    }
    reverse(ans.begin(), ans.end());
    for (long long x : ans) {
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    string s;
    int q;
    cin >> n >> s >> q;
    int sl = s.length();
    vector<set<int>> st(26);

    rep(i, sl) {
        st[s[i]-'a'].insert(i);
    }

    rep(i, q) {
        int a;
        cin >> a;
        if (a == 1) {
            int b;
            char c;
            cin >> b >> c;
            --b;
            st[s[b]-'a'].erase(b);
            st[c-'a'].insert(b);
            s[b] = c;
        }
        else {
            int l, r;
            cin >> l >> r;
            --l;
            int ans = 0;
            // for (auto sti : st) {
            //     auto id = sti.lower_bound(l);
            //     if (sti.end() != id && *id < r) ans++;
            // }
            rep(j, 26) {
                auto id = st[j].lower_bound(l);
                if (st[j].end() != id && *id < r) ans++;
            }
            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 24196
def bb
	s = gets.chomp

    aa = s[0..1].to_i
    bb = s[2..3].to_i

    fmt = 0
    fmt = 1 if bb >= 1 and bb <= 12 # YYMM
    fmt += 2 if aa >= 1 and aa <= 12 # MMYY

    case fmt
    when 0; puts 'NA'
    when 1; puts 'YYMM'
    when 2; puts 'MMYY'
    when 3; puts 'AMBIGUOUS'
    else puts 'NA'
    end
end

bb

Measured memory_bytes: 1788
n,y = map(int, input().split())
resa, resb, resc = -1, -1, -1
for i in range(n+1):
	for j in range(n+1-i):
		c = n - i - j
		total = 10000*i + 5000*j + 1000*c
		if total == y:
			resa = i
			resb = j
			resc = c
print(resa,resb,resc)

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

signed main(){
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  int odd=0,even=0;
  for(int i=0;i<n;i++)(i&1?odd:even)+=max(v[i],0LL);
  if(!odd&&!even){
    int a=-1e10,idx;
    for(int i=0;i<n;i++)if(a<v[i])a=v[i],idx=i;
    for(int j=n-1;j>idx;j--)ans.push_back(j);
    while(idx--)ans.push_back(0);
    cout<<a<<endl;
    cout<<n-1<<endl;
    for(int p:ans)cout<<p+1<<endl;
    return 0;
  }
  int l=0,r=n-1;
  if(odd>even){
    cout<<odd<<endl;
    while(!(l&1&&v[l]>0))ans.push_back(0),l++;
    while(!(r&1&&v[r]>0))ans.push_back(r--);
  }
  else{
    cout<<even<<endl;
    while(!(!(l&1)&&v[l]>0))ans.push_back(0),l++;
    while(!(!(r&1)&&v[r]>0))ans.push_back(r--);
  }
  while(r>l){
    if(v[r-2]<0)ans.push_back(r-2);
    else ans.push_back(r-1);
    r-=2;
  }
  sort(ans.rbegin(),ans.rend());
  cout<<ans.size()<<endl;
  for(int p:ans)cout<<p+1<<endl;
}


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

int main()
{
	int H, W;
	cin >> H >> W;

	char S[H + 2][W + 2];
	for (int j = 0; j <= W + 1; j++)
	{
		S[0][j] = '.';
		S[H + 1][j] = '.';
	}

	for (int i = 1; i <= H; i++)
	{
		string S_in;
		cin >> S_in;
		S[i][0] = '.';
		for (int j = 1; j <= W; j++)
		{
			S[i][j] = S_in[j - 1];
		}
		S[i][W + 1] = '.';
	}

	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			if (S[i][j] == '#')
				cout << '#';
			else
			{
				int bombs = 0;
				for (int ii = i - 1; ii <= i + 1; ii++)
				{
					for (int jj = j - 1; jj <= j + 1; jj++)
					{
						if (ii == i && jj == j)
							continue;
						else if (S[ii][jj] == '#')
							bombs++;
					}
				}
				cout << bombs;
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 384
while True:
	try:
		list = [1, 2, 6, 5, 4, 3]
		list2 = [0, 0, 0, 0, 0, 0]
		judge = 1
		n = input()
		if n == 0:
			break
		else:
			for i in range(n):
				order = raw_input()
				if order == 'North':
					list2[0] = list[1]
					list2[1] = list[2]
					list2[2] = list[3]
					list2[3] = list[0]
					list2[4] = list[4]
					list2[5] = list[5]
				if order == 'East':
					list2[5] = list[0]
					list2[4] = list[2]
					list2[0] = list[4]
					list2[2] = list[5]
					list2[1] = list[1]
					list2[3] = list[3]
				if order == 'West':
					list2[4] = list[0]
					list2[5] = list[2]
					list2[2] = list[4]
					list2[0] = list[5]
					list2[1] = list[1]
					list2[3] = list[3]
				if order == 'South':
					list2[1] = list[0]
					list2[2] = list[1]
					list2[3] = list[2]
					list2[0] = list[3]
					list2[4] = list[4]
					list2[5] = list[5]
				if order == 'Right':
					list2[4] = list[1]
					list2[5] = list[3]
					list2[3] = list[4]
					list2[1] = list[5]
					list2[0] = list[0]
					list2[2] = list[2]
				if order == 'Left':
					list2[5] = list[1]
					list2[4] = list[3]
					list2[1] = list[4]
					list2[3] = list[5]
					list2[0] = list[0]
					list2[2] = list[2]
				list = [list2[0], list2[1], list2[2], list2[3], list2[4], list2[5]]
				judge += list[0]
		print judge
	except EOFError:
		break


Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll num[15][15];
void math(int n)
{
    int end = n % 10;
    while (n >= 10)
    {
        if (n == 10)
        {
            n = 1;
            break;
        }

        n /= 10;
    }
    num[n][end]++;
}
int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        math(i);
    }
    ll ans = 0;
    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            ans += num[i][j] * num[j][i];
        }
    }
    cout << ans << endl;
}


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

int main()
{
    long long k,a,b;
    cin >> k >> a >> b;
    if(b-a <= 2){
        cout << k+1 << endl;
    }else{
        if(a+1 > k){
            cout << k+1 << endl;
        }else{
            long long ans = b;
            k -= a+1;
            ans += (k/2)*(b-a)+k%2;
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val AB = (0 until N).map {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        a to b
    }.sortedByDescending { it.first + it.second }

    var s_a = 0L; var s_b = 0L
    for (i in 0 until N) when (i % 2) {
        0 -> s_a += AB[i].first
        1 -> s_b += AB[i].second
    }
    println(s_a - s_b)
}

Measured memory_bytes: 82648
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }


int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    for(int i=0; i<K; i++){
        vector<int> B(N+1);
        for(int j=0; j<N; j++){
            B[max(0, j-A[j])]++;
            B[min(N, j+A[j]+1)]--;
        }
        for(int j=1; j<N; j++) B[j] += B[j-1];
        for(int j=0; j<N; j++) A[j] = B[j];
        bool ok = true;
        for(auto x : A)
            if(x != N){
                ok = false;
                break;
            }
        if(ok) break;
    }
    REP(i, N){
        cout << A[i] << " ";
    }
    cout << endl;
    return 0;
}

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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v, T) for_each((v).begin(), (v).end(), [](T& a) { cout << a << " "; }); cout << "\n";

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

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int N;
V<LL> a;
V<LL> s;

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) {
        LL c;
        cin >> c;
        a.push_back(c);
    }

    LL pn = (a[0] > 0) ? a[0] :   1;
    LL cost1 = (a[0] > 0) ? 0 : -a[0]+1;
    LL np = (a[0] < 0) ? a[0] :  -1;
    LL cost2 = (a[0] < 0) ? 0 :  a[0]+1;

    for(int i = 1; i < N; i++) {
        if(i % 2 == 0) {
            cost1 += (pn+a[i] > 0) ? 0 : -(pn+a[i])+1;
            pn = (pn+a[i] > 0) ? pn + a[i] : +1;
            cost2 += (np+a[i] < 0) ? 0 :  np+a[i]+1;
            np = (np+a[i] < 0) ? np + a[i] : -1;
        } else {
            cost1 += (pn+a[i] < 0) ? 0 :  pn+a[i]+1;
            pn = (pn+a[i] < 0) ? pn + a[i] : -1;
            cost2 += (np+a[i] > 0) ? 0 : -(np+a[i])+1;
            np = (np+a[i] > 0) ? np + a[i] : +1;
        }
    }

    cout << ((cost1 < cost2) ? cost1 : cost2) << "\n";

    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
#define ifaxb(a, x, b) if (a < x && x < b)
#define toInt(x) (x - '0')
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vvs vector<vs>
#define all(x) x.begin(), x.end()
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

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

  int S = 1;
  rep(i, 0, D) { S *= 100; }
  if (N <= 99) {
    cout << S * N << endl;
  } else {
    cout << S * 101 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
s=io.read()
keyence="keyence"
iskeyence=false
for i=0,7 do
    x=keyence:sub(1,i).."(%l*)"..keyence:sub(i+1,7)
    y=s:match(x)
    if y and s:gsub(y,"",1):match("%l+")=="keyence" then
        iskeyence=true
    end
end
if iskeyence then
    print("YES")
else
    print("NO")
end

Measured memory_bytes: 760
#include <cstdio>
#include <algorithm>
#include <cmath>

using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
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; }
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)

int main() {
	int n;
	scanf("%d", &n);
	int p[50];
	REP(i, n) {
		scanf("%d", &p[i]);
	}
	int cnt = 0;
	REP(i,n) {
		if(p[i] != i+1){
			cnt++;
		}
	}
	if (cnt == 0 || cnt == 2) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
}

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

int main()
{
    int N;
    cin>>N;
    vector<int> arr;
    map<int,int> mp;
    for(int i=0;i<N;i++)
    {
        int a;
        cin>>a;
        arr.push_back(a);
        if(mp.find(a)==mp.end())
         mp[a]=1;
        else
          mp[a]=0;
    }
    int a=0;
    sort(arr.begin(),arr.end());
    for(int i=0;i<N;i++)
    {
        if(mp[arr[i]]==1)
            a++;
        if(arr[i]!=arr[i-1])
        {
            for(int j=2*arr[i];j<=arr[N-1];j+=arr[i])
                if(mp.find(j)!=mp.end())
                  mp[j]=0;
        }
    }
    cout<<a;
    return 0;
}


Measured memory_bytes: 13312
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define frst first
#define sec second
#define fast cin.tie(0) , ios_base :: sync_with_stdio(0)
#define db double
#define mod 1000000007
void online_judge()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}


ll lpp(string s)
{
	string rev = s;
	reverse(rev.begin() , rev.end());
	s = s + '#' + rev;
	////cout << s << " ";
	vector<ll> z(s.size() , 0);
	ll l = 0 , r = 0;
	for (int i = 1; i < s.size(); ++i)
	{
		if (i > r) {
			l = r = i;
			while (s[r] == s[r - l]) {
				r++;
			}
			z[i] = (r - l);
			r--;
		}
		else {
			if (z[i - l] + i <= r)z[i] = z[i - l];
			else {
				l = i;
				while (s[r] == s[r - l])r++;
				z[i] = (r - l);
				r--;
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		if (z[i] + i == s.size()) {
			ans = max(ans , z[i]);
		}
	}
	return ans;
}

string binary(ll n)
{
	string s;
	while (n) {
		if ((n & 1))s += '1';
		else s += '0';
		n >>= 1;
	}
	reverse(s.begin() , s.end());
	return s;
}

bool pos(vector<ll> &v , ll val , ll painters)
{
	ll cur = 0;
	ll k = 1;
	for (int i = 0; i < v.size(); ++i)
	{
		if (v[i] > val)return 0;
		if (cur + v[i] <= val)cur += v[i];
		else {
			k++;
			cur = v[i];
		}
	}
	cout << k << endl;
	return (k <= painters);
}

class node {
	node* next;
	node* random;
	ll val;
	node(ll x)
	{
		next = random = NULL;
		val = x;
	}
};

ll dp[101][101][1001];

ll cal(ll a[] , ll cur , ll n , ll sum , ll c , ll tot)
{
	if (n == 0)
	{
		///cout << cur << " " << sum << " " << c << endl;
		if (cur == tot / 2)return abs((sum - c) - c);
		return 1e8;
	}
	if (dp[n][cur][c] != 1e8) {
		///cout << dp[n][cur][c] << " ";
		return dp[n][cur][c];
	}
	///cout << dp[n][cur][c] << " ";
	dp[n][cur][c] = cal(a , cur , n - 1 , sum , c , tot);
	dp[n][cur][c] = min(dp[n][cur][c] ,
	                    cal(a , cur + 1 , n - 1 , sum, c + a[n - 1] , tot));
	//cout << ans << endl;
	return dp[n][cur][c];
}


void go() {
	ll n;
	cin >> n;
	ll a[n];
	for (int i = 0; i < n; ++i)cin >> a[i];
	ll dp[3];
	//memset(dp , 0, sizeof dp);
	for (int i = 0; i < 3; ++i)dp[i] = 1e8;
	dp[0] = 0;
	for (int i = 1; i < n; ++i)
	{
		dp[i % 3] = min(dp[(i - 1 + 3) % 3] + abs(a[i] - a[i - 1]) , (i >= 2) ? dp[(i - 2 + 3) % 3] + abs(a[i - 2] - a[i]) : (ll)1e8);
	}
	cout << dp[(n - 1) % 3];
}


int main() {
	fast;
	//online_judge();
	go();
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	
		public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int result = 0;
	        int[] array = new int[5];
	        for(int i = 0; i<5; i++) {
	        	array[i] = sc.nextInt();
	            if(array[i]==0) result = i+1;
	        
	        }
	        
	        
	        
	        
 
	        System.out.println(result);
	}
}

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

#define INF ((int)1e9)

struct Edge {
  int to, cost;
  Edge(int t, int c) : to(t), cost(c) {}
};

typedef pair<int, int> Pii;
typedef pair<int, Pii> Piii; // cost, cnum, node

vector<Edge> G[100];
int memo[100][10];

int dijkstra(int src, int dst, int cnum) {
  
  fill(memo[0], memo[0]+1000, INF);
  
  priority_queue<Piii> pq;
  memo[src][cnum] = 0;
  pq.push(Piii(0, Pii(-cnum, src)));
  while(!pq.empty()) {
    const Piii get = pq.top(); pq.pop();
    int cost = get.first;
    int cn = -get.second.first;
    int now = get.second.second;
    
    for(int i=0; i<G[now].size(); i++) {
      int next = G[now][i].to;
      int add_c = G[now][i].cost;
      if(memo[next][cn] > cost + add_c) {
	pq.push(Piii(cost+add_c, Pii(-cn, next)));
	memo[next][cn] = cost + add_c;
      }
      if(cn-1<0) continue;
      add_c /= 2;
      if(memo[next][cn-1] > cost + add_c) {
	pq.push(Piii(cost+add_c, Pii(-(cn-1), next)));
	memo[next][cn-1] = cost + add_c;
      }
    }
  }
  
  return *min_element(memo[dst], memo[dst]+10);
}

int main() {
  int C, N, M, S, D;
  while(cin >> C >> N >> M >> S >> D && (N|M)) {
    for(int i=0; i<N; i++) {
      G[i].clear();
    }
    for(int i=0; i<M; i++) {
      int a, b, c; cin >> a >> b >> c; a--, b--;
      G[a].push_back(Edge(b, c));
      G[b].push_back(Edge(a, c));
    }
    
    S --, D --;
    cout << dijkstra(S, D, C) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
//#include <unordered_map>
//#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>
#define LL long long
#define N 100100
#define M 110
#define MOD 1000000007
#define FOR(i,l,r) for (int i = (l); i <= (r); i ++)
#define CLR(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define X first
#define Y second
using namespace std;
const int inf=0x3f3f3f3f;
int dis[205][205];
int gg[10];
int main()
{
    int n,m,z;
    cin>>n>>m>>z;
    for(int i=0;i<=n;++i)
        for(int j=0;j<=n;++j) dis[i][j]=inf;
    for(int i=0;i<=n;++i) dis[i][i]=0;
    for(int i=0;i<z;++i) cin>>gg[i];
    int u,v,w;
    for(int i=0;i<m;++i)
    {
        cin>>u>>v>>w;
        dis[u][v]=dis[v][u]=min(dis[u][v],w);
    }
    for(int k=1;k<=n;++k)
        for(int i=1;i<=n;++i)
        for(int j=1;j<=n;++j)
        dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
    int su=0,ma=inf;
    sort(gg,gg+z);
    do
    {
        su=0;
        for(int i=1;i<z;++i)
        su+=dis[gg[i-1]][gg[i]];
        ma=min(ma,su);
    }while(next_permutation(gg,gg+z));
    cout<<ma<<endl;
	return 0;
}


Measured memory_bytes: 384
//109 B - Shiritori 2018/09/08
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int N; cin >> N;
    string W[N];
    rep(i ,N){
        cin >> W[i];
    }
    rep(i ,N-1){
        for(int j=i+1;j<N;++j){
            if(W[i]==W[j]) { cout << "No" << endl; return 0;}
        }
    }
    rep(i ,N-1){
        if(W[i][W[i].size()-1]!=W[i+1][0]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import sys

r, c = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
csums = [0]*c
rsum = 0
output = []
for k in range( r ):
	matrix = [ int( val ) for val in sys.stdin.readline().split( " " ) ]

	rsum = 0
	for i in range( c ):
		rsum += matrix[i]
		output.append( "{:d} ".format( matrix[i] ) )	
		csums[i] += matrix[i]
		
	output.append( "{:d}\n".format( rsum ) )

rsum = 0
for val in csums:
	rsum += val
	output.append( "{:d} ".format( val ) )	
	
output.append( "{:d}".format( rsum ) )
print( "".join( output ) )

Measured memory_bytes: 4740
#include<stdio.h>

int main(){
    long a,b,x;
    scanf("%ld",&x);
    for(long i=-200;i<200;i++){
        for(long j=-200;j<200;j++){
            if((i*i*i*i*i)-(j*j*j*j*j)==x){
                a=i;b=j;
            }
        }
    }
    printf("%ld %ld",a,b);
}

Measured memory_bytes: 1696
import numpy as np

N, K, Q = map(int, input().split())
#A_point = np.full((N, 1), K)
A_zero  = np.zeros((N, 1))


for i in range(Q):

        Ai = int(input())
        A_zero[Ai-1][0] += 1

for i in range(N):

        print("Yes" if K-(Q-A_zero[i][0])>=1 else "No")


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

int main() {
	int n;
	cin >> n;
	queue<int> v;
	v.push(3);
	v.push(5);
	v.push(7);
	int num, ans = 0;
	while (v.front() <= n) {
		int c3 = 0, c5 = 0, c7 = 0;
		num = v.front();
		v.push(10 * num + 3);
		v.push(10 * num + 5);
		v.push(10 * num + 7);
		while (num != 0) {
			if (num % 10 == 3)
				c3++;
			if (num % 10 == 5)
				c5++;
			if (num % 10 == 7)
				c7++;
			num /= 10;
		}
		if (c3 >= 1 && c5 >= 1 && c7 >= 1)
			ans++;
		v.pop();
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;


using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

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

	cstr(str);

	if (str[2] == str[3] && str[4] == str[5]) cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;
}


Measured memory_bytes: 3636
r,c = gets.split.map {|s| s.to_i}
  ary = Array.new(r+1){ Array.new(c+1,0) }

  for i in 1..r
     a = gets.split.map {|s| s.to_i}
    for j in 1..c
      ary[i-1][j-1] = a[j-1]
      ary[i-1][c] += a[j-1]
      ary[r][j-1] += a[j-1]
      ary[r][c] += a[j-1]
    end
  end

  for i in 0..r
    for j in 0..c
      print " " unless j == 0
      print ary[i][j]
    end
    print "\n"
  end


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

int main()
{
   long long int i,j,n,t,k,m;
  cin>>n;
  long long a[n],b[n];
  j=0;
  k=-1;
  for(i=0;i<n;i++)
  {
      cin>>a[i];
      cin>>b[i];
      if(a[i]==b[i])
      {
          j++;
      }
      else{
        j=0;
      }
      if(j==3)
      {
          k=0;
      }
  }
  if(k==0)
  {
      cout<<"Yes"<<endl;
  }
  else{cout<<"No"<<endl;}



    return 0;

}


Measured memory_bytes: 3628
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int Max = 10 + 1e8;
int main()
{
	int n, m;
	cin >> n >> m;
	vector<bool> drn(n,false);
	int ac = 0;
	int wa = 0;
	vector<int> miss(n);
	rep(i, m) {
		int a;
		string s;
		cin >> a >> s;
		a--;
		if (s == "AC") {
			if (drn[a] == false) {
				drn[a] = true;
				ac++;
				wa += miss[a];
			}
		}
		if (s == "WA") {
			if (drn[a] == false) {
				miss[a]++;
			}
		}
		
	}
	cout << ac << " " << wa;
}

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

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

const int MAXN = 1e5;

struct Line { int L, R; };

int N;
Line A[MAXN+10];
int ans;
Line val1[MAXN+10], val2[MAXN+10];

int main()
{
    int i, j;

    scanf("%d", &N);
    for(i=1; i<=N; i++) scanf("%d%d", &A[i].L, &A[i].R);

    int l=-1, r=1e9+1;
    for(i=1; i<=N; i++) l=max(l, A[i].L), r=min(r, A[i].R);

    sort(A+1, A+N+1, [&](const Line &p, const Line &q)
         {
             if(p.R==q.R) return p.L<q.L;
             return p.R>q.R;
         });

    int nl=-1, nr=1e9+1;
    val1[0]={nl, nr};
    for(i=1; i<=N; i++)
    {
        nl=max(nl, A[i].L);
        nr=min(nr, A[i].R);
        val1[i]={nl, nr};
    }

    nl=-1, nr=1e9+1;
    val2[N+1]={nl, nr};
    for(i=N; i>=1; i--)
    {
        nl=max(nl, A[i].L);
        nr=min(nr, A[i].R);
        val2[i]={nl, nr};
    }

    for(i=1; i<N; i++) ans=max(ans, max(0, val1[i].R-val1[i].L+1)+max(0, val2[i+1].R-val2[i+1].L+1));
    for(i=1; i<=N; i++) ans=max(ans, A[i].R-A[i].L+1+max(0, min(val1[i-1].R, val2[i+1].R)-max(val1[i-1].L, val2[i+1].L)+1));
    printf("%d", ans);
}


Measured memory_bytes: 2560