akhauriyash/Code-Regression huggingface dataset:
a, b = map(int,input().split())
if a<= 0 <=b:
   print("Zero")   
elif a > 0:
    print("Positive")
elif a==b:
    print("Positive")
elif (b-a)%2 == 0:
    print("Negative")
elif (b-a)%2 == 1:
    print("Positive")

Measured memory_bytes: 3060
s=input()
import numpy as np
dp=np.zeros((len(s)+1,4),dtype=np.int64)
dp[0][0]=1
mod=10**9+7
for i in range(len(s)):
    if s[i]=='?':
        dp[i+1]=dp[i]*3
        dp[i+1][1:]+=dp[i][:3]
        dp[i+1]%=mod
    else:
        dp[i+1]=dp[i]
        j=ord(s[i])-ord('A')
        dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod
print(dp[-1][3])

Measured memory_bytes: 15756
from math import cos, sin, pi
x1, y1, x2, y2 = map(int, input().split())
def rot(x1, y1, x2, y2):
    x = (x2 - x1) * cos(pi / 2) - (y2 - y1) * sin(pi / 2) + x1
    y = (x2 - x1) * sin(pi / 2) + (y2 - y1) * cos(pi / 2) + y1
    return x, y
x4, y4 = rot(x1, y1, x2, y2)
x3, y3 = rot(x4, y4, x1, y1)
print(*(round(s) for s in (x3, y3, x4, y4)))

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 305;
typedef long long ll;
int f[MAXN][MAXN][MAXN],n,k,MOD;
inline void add(int &x,int a)
{
    x+=a;
    if(x>=MOD)x-=MOD;
}
inline int mul(int x,int a)
{
    return (ll)x*a%MOD;
}
int main()
{
    scanf("%d%d%d",&n,&k,&MOD);
    f[0][1][0]=1;
    for(int i=0;i<=n;++i)
        for(int j=1;j<=k;++j)
            for(int p=i;p>=0;--p){
                if(p==0)add(f[i][j+1][i],f[i][j][p]);
                else add(f[i][j][p-1],f[i][j][p]);
                add(f[i+1][j][p],mul(f[i][j][p],p+1));
            }
    printf("%d\n",f[n][k+1][n]);
    return 0;
}


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

#define LL long long
#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define MID(l, r) (((l)+(r))>>1)
#define fi first
#define se second

typedef pair<int, int> pii;

const int maxn = (int) 1e7 + 20;
//const int MOD = 1e9 + 7;
const int MOD = 998244353;
const double eps = 1e-8;


template < typename T > inline void read(T &x)
{
    static bool f;
    static char ch;

    f = 0;
    x = 0;
    ch = getchar();

    while(ch < '0' || '9' < ch) {if(ch == '-') f = 1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = (x << 3) + (x << 1) + (ch & 15); ch = getchar();}

    if(f) x = -x;
}

LL gcd(LL a, LL b) {if(!b) return a; return gcd(b, a % b);}
LL fp(LL a, LL n, LL m = MOD) {LL res; for(res = 1; n; a = a * a % m, n >>= 1) if(n & 1) res = res * a % m; return res;}

template <typename T> inline T minx(T a, T b) {if(a < b) return a; return b;}
template <typename T> inline T maxx(T a, T b) {if(a < b) return b; return a;}

int n;
LL pow2[maxn];
LL fac[maxn], ifac[maxn];

LL comb(int n, int m)
{
    return fac[n] * ifac[n - m] % MOD * ifac[m] % MOD;
}

void work()
{
    cin >>n;
    pow2[0] = 1;
    fac[0] = 1;
    for(int i = 1; i <= n; i++)
    {
        pow2[i] = pow2[i - 1] << 1;
        if(pow2[i] >= MOD) pow2[i] -= MOD;

        fac[i] = fac[i - 1] * i % MOD;
    }
    ifac[n] = fp(fac[n], MOD - 2, MOD);
    for(int i = n - 1; i >= 0; i--)
    {
        ifac[i] = ifac[i + 1] * (i + 1) % MOD;
    }

    LL tmp = 0;
    for(int i = n / 2 + 1; i <= n; i++)
    {
        tmp += comb(n, i) * pow2[n - i] % MOD;
        if(tmp >= MOD) tmp -= MOD;
    }

    LL ans = fp(3, n, MOD) - tmp * 2;
    cout <<(ans % MOD + MOD) % MOD <<endl;
}


int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
#endif // yukihana0416

    int tc = 1;
//    read(tc);

    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 234624
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define vi vector<int>
#define mod 10000000
using namespace std;
ll dp[101][100001];
ll getans(int*w,int*v,int n,int W)
{
if(n==0||W==0)
return 0;
if(dp[n][W]!=0)
return dp[n][W];	
ll ans=getans(w+1,v+1,n-1,W);
if(W>=w[0])
ans=max(ans,v[0]+getans(w+1,v+1,n-1,W-w[0]));	
	dp[n][W]=ans;
	return ans;
}

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
int n,v[100],w[100],W;
cin>>n>>W;
for(int i=0;i<n;i++)
{
	cin>>w[i]>>v[i];
}
cout<<getans(w,v,n,W)<<endl;
return 0;
}



Measured memory_bytes: 77312
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

ll a[100001],ans;

int main(void){


    ll n;
    ll b  = 0;
    scanf("%lld",&n);
    REP(i,n){
        scanf("%lld",&a[i]);
    }

    FOR(i,1,n){
        if(b == 0){
            b = a[i] - a[i - 1];
        }else if(b > 0){
            if(a[i] - a[i - 1] < 0){
                ans++;b = 0;
            }
        }else
        {
            if(a[i] - a[i - 1] > 0){
                ans++;b = 0;
             }
        }
    
    }
    printf("%lld\n",ans + 1);
    return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    ll n;
    cin >> n;

    ll c = n / 11;
    ll t = n % 11;

    if (t > 6) {
        cout << 2 * c + 2 << endl;
    } else if(t>0){
        cout << 2 * c + 1 << endl;
    }else{
        cout << 2 * c << endl;
    }
}

Measured memory_bytes: 3652
def main():

    N = int(input())
    S = input()
    count = 0

    for i in range(N):
        attributeNum = len(set(S[0:i]) & set(S[i:]))
        
        if attributeNum > count and count<= N//2:
            count = attributeNum

    print(count)


if __name__== "__main__":
    main() 






Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int ans = gcd(x, y);
		System.out.println(ans);
	}

	public static int gcd(int x, int y) {
		int temp;
		int r;
		if (y > x) {
			temp = x;
			x = y;
			y = temp;
		}
		while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> X(M);
  for(int i=0; i<M; i++){
    cin >> X.at(i);
  }
  sort(X.begin(), X.end());
  vector<int> Dif(M-1);
  for(int i=0; i<M-1; i++){
    Dif.at(i)=X.at(i+1)-X.at(i);
  }
  sort(Dif.begin(), Dif.end());
  int Ans=0;
  for(int i=0; i<M-N; i++){
    Ans+=Dif.at(i);
  }
  cout << Ans << endl;
}

Measured memory_bytes: 1024
using System;
class aoj
{
    static void Main()
    {
        int all = 0;
        while (true)
        {
            string a = Console.ReadLine();
            if (String.IsNullOrEmpty(a)) break;
            if (a.Length == 1)
                all++;
            else
            {
                if (a.Length % 2 == 0)
                {
                    int c = a.Length;
                    string e = a.Substring((c / 2), (c / 2));
                    string d = a.Substring(0, (c / 2));
                    char[] f = e.ToCharArray();
                    Array.Reverse(f);
                    string h = new string(f);
                    if (d == h)
                        all++;
                }
                else
                {
                    int c = a.Length;
                    int g = (c - 1) / 2;
                    string d = a.Substring(0, g);
                    string e = a.Substring(g + 1, g);
                    char[] f = e.ToCharArray();
                    Array.Reverse(f);
                    string h = new string(f);
                    if (d == h)
                        all++;
                }
            }
        }
        Console.WriteLine(all);
    }
}

Measured memory_bytes: 8980
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define MAX_DIGIT 15000
int n,k,m,r;
struct Double
{
	int a[MAX_DIGIT+1];
	Double()
	{
		memset(a,0,sizeof(a));
	}
	void set_integer(int p)//a=p
	{
		a[0]=p;
	}
	void add(Double b)//a+=b
	{
		int res=0;
		for(int i=MAX_DIGIT;i>=0;i--)
		{
			
			int k=(a[i]+b.a[i]+res)/10;
			a[i]=(a[i]+b.a[i]+res)%10;
			res=k;
		}
	}
	Double copy()
	{
		Double t;
		for(int i=0;i<=MAX_DIGIT;i++)
		{
			t.a[i]=a[i];
		}
		return t;
	}
	Double divide(int p)
	{
		Double b=copy();
		int res=0;
		for(int i=0;i<=MAX_DIGIT;i++)
		{
			int k=(b.a[i]+res)%p;
			b.a[i]=(b.a[i]+res)/p;
			res=k*10;
		}
		return b;
	}
	void print()//print stdout
	{
		cout << a[0];
		cout << '.';
		for(int i=0;i<r;i++)cout << a[i+1];
		cout << endl;
		return;
	}
};
Double reciprocal(int p)// return the reciprocal of p
{
	Double d;
	d.set_integer(1);
	return d.divide(p);
}
int main()
{
	while(1)
	{
		cin >> n >> k >> m >> r;
		if(n==0&&k==0&&m==0&&r==0)break;
		if(m==0)
		{
			reciprocal(n).print();
		}
		else
		{
			Double ans = reciprocal(n);
			for(int i=1;i<n;i++)
			{
				ans.add(reciprocal(n).divide(i));
			}
			ans.print();
		}
	}
	return 0;
}

Measured memory_bytes: 1520
#!/usr/bin/python3
import math
import copy

def getp(qs, cl):
    p = 0
    for (a, b, c, d) in qs:
        if cl [b - 1] - cl[a - 1] == c:
            p += d
    return p

def maxp(qs, idx, cl, n, m):
    p = 0    
    if idx == n - 1:
        for i in range(cl[idx - 1], m + 1):
            cl[idx] = i
            p = max(p, getp(qs, cl))
    else:
        for i in range(cl[idx - 1], m + 1):
            cl[idx] = i
            p = max(p, maxp(qs, idx + 1, cl, n, m))
    return p        
    
(n, m, q) = map(int, input().split())

qs = []
for i in range(q):
    qs.append(tuple(map(int, input().split())))

qs.sort()
         
l = [ 0 for i in range(n) ]
l[0] = 1
cache = {}

print(maxp(qs, 1, l, n, m))
    





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

const int MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll c = 0, c2 = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a[i] > a[j]) {
        c++;
      } else if (a[i] < a[j]) {
        c2++;
      }
    }
  }
  k = k % MOD;
  ll ans = c * k;
  ll kk = (k * (k - 1) / 2) % MOD;
  ans += (c + c2) * kk;
  ans = ans % MOD;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
// Frog 2 https://atcoder.jp/contests/dp/tasks/dp_b
#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9 + 5;

int n, k;
vector<int> h;
vector<int> memo;
vector<bool> computed;

// rec(x) is best score to get to position x

int rec(int pos) {
	if(pos == 0) {
		return 0;
	}
	if(computed[pos]) {
		return memo[pos];
	}
	int best = INF;
	for(int jump = 1; jump <= k && pos - jump >= 0; ++jump) {
		best = min(best, rec(pos - jump) + abs(h[pos] - h[pos-jump]));
	}
	computed[pos] = true;
	return memo[pos] = best;
}

int solve1() {
	return rec(n-1);
}

int main() {
	cin >> n >> k;
	h.resize(n);
	memo.resize(n, 0);
	computed.resize(n, false);
	for(int& x : h) {
		cin >> x;
	}
	cout << solve1();
}


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

typedef long long ll;

int main () {
	string S, T;
	int dp[1000][1000];
	cin >> S;
	cin >> T;
	int slen = S.length(), tlen = T.length();
	int max = 0;
	for (int i=0; i<slen; i++) {
		if (S[i] == T[0]) {
			dp[i][0] = 1;
			max = 1;
		}
		for (int j=1; j<tlen; j++) {
			dp[i][j] = 0;
		}
	}

	for (int i=1; i<slen; i++) {
		for (int j=1; j<tlen && j<=i; j++) {
			if (i-j > slen-tlen)
				continue;
			if (S[i] == T[j])
				dp[i][j] = dp[i-1][j-1] + 1;
			else
				dp[i][j] = dp[i-1][j-1];

			if (max < dp[i][j])
				max = dp[i][j];
		}
	}
	/*
	for (int i=0; i<slen; i++) {
		for (int j=0; j<tlen; j++) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	*/
	cout << (tlen - max) << endl;
	return 0;
}

Measured memory_bytes: 7548
#include <stdio.h>

#define inf 200000
#define NIL -1000000
#define WHITE 9999999
#define BLACK 8888888

int prim(int, int(*)[], int[], int[], int[]);

int main(){
  int i,j,n,ans;
  scanf("%d", &n);

  int w[n][n];
  int d[n];
  int pi[n];
  int color[n];

  for(i = 0; i < n; i++)
    for(j = 0; j < n; j++)
      scanf("%d", &w[i][j]);

  ans = prim(n, w, d, pi, color);
  printf("%d\n", ans);
  return 0;
}

int prim(int n, int w[n][n], int d[n], int pi[n], int color[n]){
  int i,j,u,ans = 0;
  int mincost;
  for(u = 0; u < n; u++){
    d[u] = inf;
    pi[u] = NIL;
    color[u] = WHITE;
  }
  d[0] = 0;
  while(1){
    mincost = inf;
    for(i = 0; i < n; i++){
      if(color[i] != BLACK && d[i] < mincost){
        mincost = d[i];
        u = i;
      }
    }
    if(mincost == inf)
      break;

    color[u] = BLACK;

    for(j = 0; j < n; j++){
      if(color[j] != BLACK && w[u][j] < d[j] && w[u][j] != -1){
        pi[j] = u;
        d[j] = w[u][j];
      }
    }
  }

  for(i = 0; i < n; i++)
    ans += d[i];

  return ans;
}

Measured memory_bytes: 636
import sys
import  math
from statistics import *
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b, c, d = input()
li = ["+", "-"]
def calc(a, b, c, d):
    for i in range(2):
        if i == 0:
            e = a + b
        else:
            e = a - b
        for j in range(2):
            if j == 0:
                f = e + c
            else:
                f = e - c
            for k in range(2):
                if k == 0:
                    g = f + d
                else:
                    g = f - d
                if g == 7:
                    print(str(a) + li[i] + str(b) + li[j] + str(c) + li[k] + str(d) + "=7")
                    return
calc(int(a),int(b), int(c), int(d))


Measured memory_bytes: 5148
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            #divisors.append(i)
            divisors.append(n//i)
    #divisors.sort()
    return divisors
divisors = make_divisors(N)
if N // divisors[-1]  < (divisors[-1] - 1):
    print(sum(divisors) - len(divisors))
else:
    print(sum(divisors[:-1]) - len(divisors[:-1]))

Measured memory_bytes: 3060
package main

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

func main() {

	//スキャナーの生成
	scanner := bufio.NewScanner(os.Stdin)

	//コマンドからの入力をスキャンする(ついでに整数変換)
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())

	//整数変換のエラー処理
	if err != nil {
		panic(err)
	}

	answer := i + i*i + i*i*i

	fmt.Println(answer)

}


Measured memory_bytes: 1772
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n;
char str[100];
map<pair<string, string>, int> mp;
int main() {
    cin >> n >> str;
    for (int i = 0; i < (1 << n); ++i) {
        string x, y;
        for (int j = 0; j < n; ++j) {
            if ((i >> j) & 1) x += str[j];
            else y += str[j];
        }
        
        ++mp[{ x, y }];
    }
    reverse(str, str + (n << 1));
    llong ans = 0;
    for (int i = 0; i < (1 << n); ++i) {
        string x, y;
        for (int j = 0; j < n; ++j) {
            if ((i >> j) & 1) x += str[j];
            else y += str[j];
        }
        
        ans += mp[{ x, y }];
    }
    printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 91904
import java.util.*;

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

    int a = sc.nextInt();
    int b = sc.nextInt();

    int ans = 0;
    if (a >= 13) {
      ans = b;
    } else if (a >=6) {
      ans = b / 2;
    }
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 23124
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class MultipleOf2019 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            char[] chars = in.next().toCharArray();
            long[] count = new long[2019];

            int base = 1;
            int pre = 0;
            for (int i = chars.length - 1; i >= 0; i--) {
                int a = Character.getNumericValue(chars[i]);
                int current = (a * base + pre) % 2019;
                count[current]++;
                pre = current;
                base = (base * 10) % 2019;
            }
            long ans = 0;
            for (long c : count) {
                ans += (c * (c - 1) / 2);
            }
            if (count[0] > 0) {
                ans += count[0];
            }
            out.append(String.valueOf(ans));
        }

    }
}



Measured memory_bytes: 40764
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define UI unsigned int
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF 0x3f3f3f3f3f3f3f3f
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
#define lb(x) ((x)h & (-(x)))
#define dbg(x) cout<<#x<<" = "<<x<<endl;
using namespace std;

const int N = 1e6 + 5;
const LL mod = 998244353;

char a[N], b[N];

void solve() {

    scanf("%s", a);

    scanf("%s", b);

    int len = strlen(a);

    rep(i, 0, len - 1) if(a[i] != b[i]) { puts("No");return ; }

    puts("Yes");

}

int main() {

//    int _; scanf("%d", &_);
//    while(_--) solve();

    solve();

    return 0;
}


Measured memory_bytes: 3700
/**
 *   author: Shubham Srivastava
 *   created: 04 February 2019  18:24:54
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
vector <long long> nodes[100005];
bool visited[100005] = {0};
vector <long long> dp(100005);
vector <long long> v;
ll maxi = -1;
ll dfs(ll s)
{
	if(dp[s])
		return dp[s];
	dp[s] = 0;
	for(auto i : nodes[s])
	{
		dp[i] = dfs(i);
		dp[s] = max(dp[s],dp[i]+1);
	}
	return dp[s];
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    long long n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
    	int a,b;
    	cin>>a>>b;
    	nodes[a].push_back(b);
    }
    ll ans = -1;
	for(ll p = 1; p <= n; p++)
		ans = max(ans, dfs(p));
    cout<<ans;
return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <vector>
#include <cstdlib>

typedef long long ll;
const ll MAX = 1e9+7;

using namespace std;

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

    int a;
    vector<int> bre(n+1, true);

    for(int i=0; i<m; i++) {
        cin >> a;
        bre[a] = false;
    }

    vector<ll> dp(n+1);
    dp[0]=1;
    if(bre[1]) dp[1] = 1;
    else dp[1] = 0;

    for(int i=2; i<n+1; i++) {
        if(bre[i]) {
            dp[i] = dp[i-1] + dp[i-2];
            dp[i] %= MAX;
        } else {
            dp[i] = 0;
        }
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		Node T = null;
		for(int i = 0; i < n; ++i) {
			String[] str = br.readLine().split(" ");
			if(str[0].equals("insert")){
				T = Node.insert(T, new Node(Integer.parseInt(str[1])));
			}else if(str[0].equals("find")){
				if(Node.find(T, Integer.parseInt(str[1]))){
					System.out.println("yes");
				}else{
					System.out.println("no");
				}
			}else{
				Node.printInOrder(T);
				Node.printPreOrder(T);
			}
		}
	
	}
}

class Node{
	public int key;
	public Node left;
	public Node right;
	public Node p;
	public Node(int key){
		this.key = key;
	}
	public static Node insert(Node T, Node z){
		Node y = null;
		Node x = T;
		while(x != null){
			y = x;
			if(z.key < x.key){
				x = x.left;
			}else{
				x = x.right;
			}
		}
		z.p = y;
		
		if(y == null){
			T = z;
		}else if(z.key < y.key){
			y.left = z;
		}else{
			y.right = z;
		}
		return T;
	}
	public static boolean find(Node T, int key){
		Node x = T;
		while(x != null){
			if(key == x.key){
				return true;
			}else if(key < x.key){
				x = x.left;
			}else{
				x = x.right;
			}
		}
		return false;
	}
	public static void printInOrder(Node T){
		StringBuilder sb = new StringBuilder();
		sb.append(' ');
		inOrder(T, sb);
		System.out.println(sb);
	}
	public static void inOrder(Node z, StringBuilder sb){
		if(z == null){
			return;
		}

		if(z.left != null){
			inOrder(z.left, sb);
			sb.append(' ');
		}
		sb.append(z.key);
		if(z.right != null){
			sb.append(' ');
			inOrder(z.right, sb);
		}
	}
	public static void printPreOrder(Node T){
		StringBuilder sb = new StringBuilder();
		sb.append(' ');
		preOrder(T, sb);
		System.out.println(sb);
	}
	public static void preOrder(Node z, StringBuilder sb){
		if(z == null){
			return;
		}
		sb.append(z.key);
		if(z.left != null){
			sb.append(' ');
			preOrder(z.left, sb);
		}
		if(z.right != null){
			sb.append(' ');
			preOrder(z.right, sb);
		}
	}
}

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

typedef long long LL;
const LL MOD = 1e9+7;

LL dmod(LL x){
	return x%MOD;
}

int n,x,y,z;
int mx,my,mz;
int tmask;

int ilang(int mask,int &pan){
	if(mask == 0) return mask;
	while(!(mask&1)){
		mask >>= 1;
		pan--;
	}
	pan--;
	return mask>>1;
}

int destroy(int mask,int &pan){
	while(mask >= mx && !(mask&mx)){
		mask = ilang(mask,pan);
	}
	while(mask >= my && !(mask&my)){
		mask = ilang(mask,pan);
	}
	while(mask >= mz && !(mask&mz)){
		mask = ilang(mask,pan);
	}
	return mask;
}

LL memo[45][(1<<17)];

LL dp(int id, int mask, int pan){
//	cout << id << " " << mask << " " << pan << endl;
	if((mask&tmask) == tmask) return 0LL;
	if(id >= n) return 1LL;
	LL &ret = memo[id][mask];
	if(ret!=-1) return ret;
	ret = 0LL;
	for(int i=1;i<=10;i++){
		LL tma = mask|(1<<(pan+i));
		int tpan = pan+i;
		tma = destroy(tma,tpan);
		ret = dmod(ret+dp(id+1,tma,tpan));
	}
	return ret;
}

int main(){
	memset(memo,-1,sizeof(memo));
	scanf("%d%d%d%d",&n,&x,&y,&z);
	x--;
	y+=x;
	z+=y;
	mx = (1<<x);
	my = (1<<y);
	mz = (1<<z);
	tmask = mx|my|mz;
	LL ans = dp(0,0,-1);
	LL semua = 1LL;
	for(int i=1;i<=n;i++){
		semua*=10LL;
		semua%=MOD;
	}
	printf("%lld\n",(semua-ans+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 46336
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n,k;
	cin>>n>>k;
	ll ans = 0;
	if(k&1) {
		ans = pow(n/k,3);
	} else {
		ans = pow(n/k,3);
		int cnt = 0;
		for(int i=k/2;i<=n;i+=k)cnt++;
		ans+=pow(cnt,3);
	}
	cout<<ans;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main ()
{
	ll a, b, c, z;
	cin>>a>>b>>c;
	z = min(b-1 , c);
	cout<<floor(a*z/b)-a*(z/b)<<endl;
	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <stack>

using namespace std;

bool order[30][30];

stack<int> sta;

int main(){
	
	int m, n;
	
	bool checker;
	
	bool check[30];
	
	cin >> m >> n;
	
	int a, b;
	
	for(int i = 0; i <= m; i++){
		for(int j = 0; j <= m; j++){
			order[i][j] = false;
		}
		check[i] = false;
	}
	
	for(int i = 0; i < n; i++){
		cin >> a >> b;
		order[a][b] = true;
	}
	
	for(int loop = 0; loop < m; loop++){
		for(int i = 1; i <= m; i++){
			checker = false;
			for(int j = 1; j <= m; j++){
				if(order[i][j]){
					break;
				}
				if(j == m && !check[i]){
					sta.push(i);
					check[i] = true;
					for(int k = 1; k <= m; k++){
						order[k][i] = false;
					}
					checker = true;
				}
			}
			if(checker){
				break;
			}
		}
	}
	
	while(!sta.empty()){
		printf("%d\n", sta.top());
		sta.pop();
	}
	
	return 0;
}

Measured memory_bytes: 1180
# include <iostream>
# include <cmath>
# include <string>
# include <vector>

using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if (a==b && b ==c) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

const int MOD = 1000000007;
const int N = 200005;

int h, w;

int solve() {
  scanf("%d %d", &h, &w);
  set<pair<int, int>> positions;
  multiset<int> values;

  for (int i = 0; i < w; ++i) {
    positions.insert({i, 0});
    values.insert(0);
  }

  for (int i = 0; i < h; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    --a, --b;

    int minimum = -1;
    while (true) {
      set<pair<int, int>>::iterator it = positions.lower_bound({a, -1});
      if (it != positions.end() && it->first <= b) {
        values.erase(values.find(it->second));
        int val = it->second + (b - it->first + 1);
        if (minimum == -1 || val < minimum) {
          minimum = val;
        }
        positions.erase(it);
      } else {
        break;
      }
    }

    if (minimum != -1 && b + 1 != w) {
      set<pair<int, int>>::iterator it = positions.lower_bound({b+1, -1});
      if (it != positions.end() && it->first == b+1) {
        minimum = min(minimum, it->second);
        values.erase(values.find(it->second));
        positions.erase(it);
      }

      values.insert(minimum);
      positions.insert({b+1, minimum});
    }

    if (values.size() == 0) printf("-1\n");
    else printf("%d\n", *values.begin() + i + 1);
  }
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    // printf("Case #%d: ", tc+1);
    solve();
  }
  return 0;
}


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

#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cout<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#define debug2(x, y) cout<<__LINE__<<": "<<#x<<" = "<<x<<\
                                     "  "<<#y<<" = "<<y<<endl;
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define UNIQUE(c) \
    sort(all(c)); \
    (c).resize(unique(all(c))-c.begin());

#define PI 3.1415926535897932384626433832795028841971

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;

const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;

inline int cmp(double x, double y = 0, double tol = EPS){
  return ((x <= y+tol) ? (x+tol < y) ? -1:0:1);
}

bool palin(string s){
  string r = s;
  reverse(r.begin(), r.end());

  return s == r;
}

int main() {

  string s;
  while (cin >> s){
    int len = s.size();
    string L = s.substr(0, len/2);

    string R = s.substr(len/2 + 1, len/2);

    if (palin(L) && palin(R) && palin(s)){
      cout << "Yes\n";
    } else
      cout << "No\n";

  }

	return 0;
}


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

using namespace std;

int gcd(int a,int b){
	if(a<b){swap(a,b);}

	int r = a % b;
	while(r!=0){
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

vector<int>vec;
vector<int>D;
int x[100005];

int main(){

	int N,X;

	scanf("%d %d",&N,&X);

	vec.push_back(X);

	int i;

	for(i=0;i<N;i++){
		scanf(" %d",&x[i]);
		vec.push_back(x[i]);
	}
	sort(vec.begin(),vec.end());

	for(i=0;i<N;i++){
		D.push_back(vec[i+1]-vec[i]);
	}

	int ans;

	if(N==1){ans=max(x[0]-X,X-x[0]);}
	else if(N==2){ans=gcd(D[0],D[1]);}
	else{
		ans=D[0];
		for(i=1;i<N;i++){
			ans=gcd(ans,D[i]);
		}
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 1784
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int h=sc.nextInt();
		int c=1;
		for(int i=1;i<n;i++) {
			int a=sc.nextInt();
			if(h>=a)
				c++;
			h=Math.min(a, h);
		}
		System.out.println(c);



	}

}


Measured memory_bytes: 63336
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

string a[505];

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

    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++) cin >> a[i];

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w-1; j++) {
            if (i % 2 == 0 || j == 0 || a[i][j] == '#') cout << '#';
            else cout << '.';
        }
        cout << ".\n";
    }
    cout << '\n';

    for (int i = 0; i < h; i++) {
        cout << '.';
        for (int j = 1; j < w; j++) {
            if (i % 2 == 1 || j == w-1 || a[i][j] == '#') cout << '#';
            else cout << '.';
        }
        cout << '\n';
    }

    return 0;
}

Measured memory_bytes: 1152
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

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

int main() {
	int N, A;
	cin >> N >> A;
	cout << N * N - A << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		String[] S=sc.next().split("");
		long ans=0;

		for(int i=0;i<Math.pow(2,S.length-1);i++) {

			StringBuilder sb=new StringBuilder();

			for(int j=0;j<S.length;j++) {

				sb.append(S[j]);

				if((1&i>>j)==1) {

					ans+=Long.parseLong(sb.toString());
					sb.setLength(0);
				}
			}
			if(sb.length()!=0) {
				ans+=Long.parseLong(sb.toString());
			}
		}

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 21972
b,w=map(int,input().split())
MOD=10**9+7
class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )
factorial=[ModInt(1)]*(b+w+1)
for i in range(1,b+w+1):
    factorial[i]=factorial[i-1]*i
power_of_two=ModInt(1)
def comb(count, BorW):
    if count < BorW:return 0
    return factorial[count]/factorial[BorW]/factorial[count-BorW]
Black_doesnt_exist=[0]*(w+1)
White_doesnt_exist=[0]*(b+1)
Black_doesnt_exist[0]=ModInt(1)
White_doesnt_exist[0]=ModInt(1)
for i in range(b):
    Black_doesnt_exist[0]*=2
for i in range(w):
    White_doesnt_exist[0]*=2
Black_doesnt_exist[0]-=1;White_doesnt_exist[0]-=1
#Blackdoesn'texist[i]:=b+i個から0~b-1個を選ぶ選び方の総数
for i in range(1,w+1):
    Black_doesnt_exist[i]=Black_doesnt_exist[i-1]*2-comb(b+i-1,b-1)
for i in range(1,b+1):
    White_doesnt_exist[i]=White_doesnt_exist[i-1]*2-comb(w+i-1,w-1)
for i in range(b+w):
    B=0;W=0
    #B:前回までに黒いチョコを食べきっているような選び方
    #W:前回までに白いチョコを食べきっているような選び方
    if i>=b:
        B=power_of_two-Black_doesnt_exist[i-b]
    if i>=w:
        W=power_of_two-White_doesnt_exist[i-w]
    Both_exist=power_of_two-B-W
    print(W/power_of_two+Both_exist/power_of_two/2)
    power_of_two*=2

Measured memory_bytes: 106460
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
// #define int long long
#define first fi
#define second se
using namespace std;
typedef pair<int, int> P;

int d[30][300010];

signed main(){
    int n, m, k;
    while(1){
        cin >> n >> m >> k;
        if(n + m + k == 0) break;
        rep(i, 0, 30) rep(j, 0, 300010) d[i][j] = 0;
        d[0][0] = 1;
        rep(i, 0, n){
            rep(j, i, 300000){
                if(d[i][j] == 0) break;                
                rep(l, 1, m + 1){
                    d[i + 1][j + l] += d[i][j];
                }
            }
        }
        double sum = 0;
        rep(i, 0, 300000){
            if(i <= k) sum += d[n][i];
            else sum += d[n][i] * (i - k);
        }
        rep(i, 0, n) sum /= (double)m;
        printf("%.14lf\n", sum);
    }
}

Measured memory_bytes: 38252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String word = null;
		int count = 0;
		try {
			word = br.readLine();
			while(true) {
				String sentence = br.readLine();
				
				if ("END_OF_TEXT".equals(sentence)) {
					break;
				}
				
				String[] tmpArr = sentence.split("\\s");
				for (int i = 0; i < tmpArr.length; i++) {
					if (tmpArr[i].equalsIgnoreCase(word)) {
						count++;
					}
				}
			}
			
			
			
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		System.out.println(count);
		
	}

}



Measured memory_bytes: 24428
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
                                                                                                
  
int main(){
                                                                                                
   
    long long i;

    string a, b;

         
    cin >> a >> b;


    if( a.size() > b.size() ){

        cout << "GREATER" << endl;

        return 0;

        }

    if( a.size() < b.size() ){

        cout << "LESS" << endl;

        return 0;

        }


    if( a > b ){

        cout << "GREATER" << endl;

        return 0;

        }

    if( a < b ){

        cout << "LESS" << endl;

        return 0;

        }


    cout << "EQUAL" << endl;


    return 0;
                                                          
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N, K;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    int ans = 0;
    while(N--) {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}


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

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



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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

ll func(ll A, ll B){
	string a = to_string(A);
	string b = to_string(B);

	return max(a.length(), b.length());
}

int main(void){

	ll N; cin >> N;

	ll ans = 100;
	for(ll i=1;i*i <=N;++i){
		if(N%i == 0) ans = min(ans, func(i, N/i));
	}

	cout << ans << endl;


	return 0;

}


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

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(a => long.Parse(a)).ToArray();
        long count = Min(n[1] - 1, n[2]);
        long before = 0, current = 0, after = 0;
        long max = 0;
        current = (long)((n[0] * count) / (double)n[1]) - n[0] * (long)(count / (double)n[1]);
        WriteLine($"{current}");
    }
}


Measured memory_bytes: 19024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin>>n;
int s[n+1]={0};
for(int i=1;i<=n;++i)
{
    int j=i;
    while(j)
    {
        s[i]+=j%10;
        j/=10;
    }
   
}
int max=100000000;
for(int i=1;i<n;++i)
{
    if(s[i]+s[n-i]<max)
        max=s[i]+s[n-i];
}
cout<<max;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using G = vector<vector<int>>;
const long long INF = 1LL << 60;

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

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

int main(){
  int n,w;
  cin >> n >> w;
  vector<int> weight(n,0);
  vector<int>  value(n,0);
  vector<vector<ll>> dp(n+1,vector<ll>(101000,INF));
  rep(i,n) cin>> weight[i] >> value[i];
  int V_MAX = 100100;
  dp[0][0] = 0;
  for(int i=0;i<n;i++){
      for(int sum_v=0;sum_v < V_MAX;sum_v++){
        if(sum_v - value[i] >= 0){
            chmin(dp[i+1][sum_v],dp[i][sum_v-value[i]] + weight[i]);
        }
        chmin(dp[i+1][sum_v], dp[i][sum_v]);
      }
  }
  ll ans = 0;
  rep(i,V_MAX){
      if(dp[n][i] <= w) ans = i;
  }
  cout << ans << endl;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

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

    string n;
    cin >> n;

    int ans;
    bool nine = true;

    for(int i = 1; i < n.size(); ++i){
        if(n[i] != '9') {
            nine = false;
            break;
        }
    }

    ans = (n.size()-1) * 9 + (n[0] - '0') - 1 + nine;
    ppp(ans);




    return 0;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::io::*;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let input = stdin();
    let input = input.lock();
    let token: String = input
            .bytes()
            .map(|c| c.expect("conversion error") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();

    token.parse().ok().expect("read error")
}

fn main() {
    // 各文字の登場回数を記録するハッシュテーブルを作成
    let mut cnt = HashMap::new();

    //文字を入力し、順にcntに格納していく
    let w: String = read();
    let cs: Vec<char> = w.chars().collect();
    for i in 0..w.chars().count() {
        *cnt.entry(cs[i]).or_insert(0) += 1;
    }

    // valuesに奇数があればNo
    if cnt.values().all(|v| v % 2 == 0) {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4476
#include <iostream>
#include <cstring>
#include <cstdio>
#include<algorithm>
#include <queue>
#include <cmath>
#include <limits>
#include <map>
using namespace std;

int main(){
  int n;
  cin >> n;
 int monst[n+1];
 int defeat[n];
  long long int def = 0;
  for(int i = 0;i<=n;i++){
    cin >> monst[i];
  }
  for(int i = 0;i<n;i++){
    cin >> defeat[i];
  }
  
  for(int i = 0;i<n;i++){
    if(monst[i]<defeat[i]){
      int pow =  defeat[i] - monst[i];
      def += monst[i];
      if(monst[i+1]<pow){
         def += monst[i+1];
      monst[i+1] = 0;
      }else{
        monst[i+1] -= pow;
        def += pow;
      }
    }else{
      monst[i] = monst[i] - defeat[i];
      def += defeat[i];
    }
    
  }
  cout << def << endl;
return 0;
}

Measured memory_bytes: 1024
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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

bool ok(long long index,vector<long long> &retu,int border){
    int cutCount = 0;
    for(int i = 0;i<retu.size();i++){
        cutCount += (retu.at(i)-1)/index;
    }
    if(cutCount <= border) return true;
    else return false;
}
long long binary_search(long long size,vector<long long> &retu,int border){
    //left,right,midはいずれもindex
    long long left = 0,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        bool hantei = ok(mid,retu,border);
        if(hantei) right = mid;
        else left = mid;
        //cout << left << " " << right << endl;
    }
    if(left == -1)return 0;
    return right;
}

//leftは条件を満たさない最大の値、rightは条件を満たす最小の値になっている

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

    int N;cin >> N;int K;cin >> K;
    vector<long long> retu(N);
    long long maxi = 0;
    for(int i = 0;i<N;i++) cin >> retu.at(i),maxi = max(maxi,retu.at(i));
    long long ans = binary_search(1000000000,retu,K);
    cout << ans << endl;
}

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

int main() {
    ll N;
    string S;
    cin >> N >> S;
    ll ans = 0;
    rep(i, N - 2) {
        if (S[i] == 'A') {
            if (S[i + 1] == 'B') {
                if (S[i + 2] == 'C') {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256