akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		sc.close();
		
		long k = (int) Math.sqrt(N);
		while(N%k!=0){
			k--;
		}
		System.out.println(func(k,N/k));

	}
	
	public static int func(long a, long b){
		return Math.max(String.valueOf(a).length(), String.valueOf(b).length());
	}

}

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

int main() {
    int N;
    int p = 0;int w = 0; int g = 0; int y = 0;
    string S;

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> S;
        if (S == "P") {
            p = 1;
        }
        else if (S == "W") {
            w = 1;
        }
        else if (S == "G") {
            g = 1;
        }     
        else {
            y = 1;
        }
    }
    int ans = p+w+g+y;
    if (ans == 4) {
        cout << "Four" << endl;
    }
    else {
        cout << "Three" << endl;
    }
    
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	if(n < 1200) cout << "ABC" << endl;
	else cout << "ARC" << endl;
}


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

signed main(){
    string s,n = "Yes";
    cin >> s;

    for(int i=0;i<s.length();i++){
        string t = s.substr(i,1);
        int r = (i+1) % 2;
        
        if(t == "L" && r == 1) {
          n = "No";
        }else if(t == "R" && r == 0){
          n = "No";
        }
    }

    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
AB = sorted([[int(_) for _ in input().split()] for _ in range(N)],
            key=lambda x: x[1],
            reverse=True)
CD = sorted([[int(_) for _ in input().split()] for _ in range(N)])

for i in range(N):
    p = -1
    for j in range(len(AB)):
        if AB[j][0] < CD[i][0] and AB[j][1] < CD[i][1]:
            p = j
            break
    if p > -1:
        AB.pop(p)
print(N - len(AB))


Measured memory_bytes: 3064
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a,b = inpl()
for i in range(a,b+1):
    if i % n == 0:
        print('OK')
        quit()
print('NG')


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

int main(){
  
  int n;
  cin >> n;
  
  for(int i=1;i<=9;i++){
    int j =n/i;
    if(1<=j&&j<=9&&i*j==n){
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,S=pin()
    A=tupin()#調子にのるな
    mod=998244353
    
    #形式的冪級数を考える
    #普通の部分和ッ->集合内の各アイテムについて、選ぶか選ばないか。O(2^n)の探索
    #これを形式的冪級数でいえば、（1+x^a）を掛ける計算になる　指数時間ではない
    #つまり、集合A,Sに対して、[x^s]PI(1+x^a_i) (f_i)

    #次に、Aの部分集合について考える
    #サンプル1の場合、N==3なので8個の部分集合がある
    #つまり、F3＝1+(f_1+f_2+f_3)+(f1_f2+f2_f3+f3_f1)+f1_f2_f3を考える
    #果たして、一般的なNにたいして多項式時間でにFnをもとめれば指数時間は完全回避できる
    #F3=(1+f1+f2+f1f2)+f3{(1+f1+f2+f1f2)}
    #  =(1+f3)(1+f1+f2+f1f2)
    #  =(f3で追加された新しいところ)(N=2のときのすべての部分集合)

    #これは、f3をSの部分集合にふくめるか、含めないかの探索と同等
    #一般的にFn=F_n-1*(1+fn)=PI(1+fn)とわかる

    #求めるものは[x^S]PI(1+fn)=[x^S]PI(2+x^a)

    from collections import defaultdict #本当は良くないがわかりやすさのためココに置く
    from copy import deepcopy
    
    ans=defaultdict(int)#i
    ans[0]=1 #init ,1=x^0より
    #print(ans)
    for a in A:
        #ans そのものと、ansの係数にx^aをかけたものを足し算    
        temp=defaultdict(int)
        for x in ans:
            if x+a<=S:
                temp[x+a]=ans[x]
            
            ans[x]*=2
            ans[x]%=mod
        for t in temp:
            if t<=S:
                ans[t]+=temp[t]
                ans[t]%=mod
    print(ans[S])    
    
#%%submit!
resolve()
        
    

Measured memory_bytes: 89416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e9 + 7;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll N, M, R;
    cin >> N >> M >> R;
    vector<ll> r(R);
    rep1(i, R){
        cin >> r[i];
        r[i]--;
    }
    vector<vector<ll> > d(201, vector<ll>(201, INF));
    rep1(i, M){
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    for (ll k = 0; k < N; k++){       // 経由する頂点
        for (ll i = 0; i < N; i++) {    // 始点
            for (ll j = 0; j < N; j++) {  // 終点
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    ll ans = INF;
    sort(r.begin(), r.end());
    ll P[R];
    rep1(i, R) P[i] = r[i];
    do {
        ll res = 0;
        rep1(i, R-1) res += d[P[i+1]][P[i]];
        ans = min(ans, res);
    } while(next_permutation(P, P+R));
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3924
#include<bits/stdc++.h>
#define    ll      long long int
#define    Fori(a,b) for (ll i = a ; i<b ;i++ )
#define    Forj(a,b) for (ll j = a ; j<b ;j++ )
#define    Fork(a,b) for (ll k = a ; k<b ;k++ )
#define    W       while
#define    pb      push_back
#define    nl      cout<<endl
#define    mod     1000000007
#define    I       cin>>
#define    Out     cout<<
#define    DOD(i)  cout<<setprecision(i)<<fixed<<
#define    XXX     return 0
#define    Fast    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
bool isPal(string s,string S){
    int n=s.length(),i;
    for(i=0;i<n/2;i++){
        if(s[i]!=S[i]) break;
    }
    if(i>=n/2) return true;
    else return false;
}
int main()
{
   Fast;
   string s;cin>>s;
   int n=s.length();
    int x,y,z,i;
    for(i=0;i<=n/2;i++){
        if(s[i]!=s[n-i-1]) break;
    }
    if(i>n/2){
        x=1;
    }else{
        x=0;
    }
    //cout<<x<<endl;
    i=0;
    int j=(n-1)/2;
    for(;i<=j/2;i++){
        if(s[i]!=s[(n-1)/2-i-1]) break;
    }
    if(i>(n-1)/4) y=1;
    else y=0;
    //cout<<y<<endl;
    i=(n+3)/2;
    for(;i<=(n+1)*3/4;i++){
        if(s[i]!=s[n-i-1]) break;
    }
    if(i>(n+1)*3/4) z=1;
    else z=0;
    //cout<<z<<endl;
   if(x==1 && y==1 && z==1) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   XXX;
}




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

int main(void){
  long long h,w,ans;
  
  cin >> h >> w;
  ans = h*w/2;
  ans += (h%2)*(w%2);
  if (h==1||w==1) ans=1;
  cout << ans << endl;
  return 0;
}


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

int main() {
    ll n;
    cin >> n;
    int m, p;
    ll ans = 0;
    m = 1e6;
    rep(i, n) {
        cin >> p;
        if (m >= p) {
            ans++;
        }
        m = min(m, p);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.main = function (S) {
    var sList = S.split('');
    var res = 0;
    var st = [];
    for (var i = 0; i < sList.length; i++) {
        if (st.length === 0 || st[st.length - 1] === sList[i]) {
            st.push(sList[i]);
        }
        else {
            res += 2;
            st.pop();
        }
    }
    return res;
};
var input = require('fs').readFileSync('/dev/stdin', 'UTF-8');
var lines = input.split('\n');
var res = exports.main(lines[0]);
console.log(res);


Measured memory_bytes: 10700
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    if(a==b) cout<<c<<endl;
    else if(a==c) cout<<b<<endl;
    else if(b==c) cout<<a<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
using namespace std;
const int inf=1e9+10;
const int maxn=110;
const int maxm=5e6+10;
const int mod=1e9+7;
const double pi=acos(-1.0);
int n;
char s[maxn];
int len;
int func(int ch)
{
    int tl=len,tc=0;
    int vis[maxn];
    cls(vis,0);
    for(int i=0;i<tl;i++)
    {
        if(s[i]-'a'==ch)
        {
            tc++;
            vis[i]=1;
        }
    }
    if(tc==0) return inf;
    int ans=0;
    while(tc<tl)
    {
        ans++;
        for(int i=0;i<tl;i++)
        {
            if(vis[i]!=1&&vis[i+1]==1)
            {
                vis[i]=1;
                tc++;
            }
        }
        if(vis[tl-1]==1)
            tc--;
        tl--;
    }
    return ans;
}
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%s",s))
    {
        len=strlen(s);
        int ans=inf;
        for(int i=0;i<26;i++)
        {
            int t=func(i);
            if(t<ans)
                ans=t;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
#include<limits.h>
using namespace std;

const int N=5e5+5;
int n=1,tot;

void failure(char s[],int fail[]){
//	printf("%s\n",s+1);
	fail[1]=0;
	for(int i=2,j=0;i<=n;i++){
		while(j&&s[j+1]!=s[i]) j=fail[j];
		if(s[j+1]==s[i]) j++;
		fail[i]=j;
	}
}

char s[N],rs[N];
int f[N],rf[N];

int main(){
	scanf("%s",s);
	n=strlen(s);
	for(int i=1;i<=n;i++) rs[i]=s[n-i];
	rs[n+1]='\0';
	for(int i=n;i>=1;i--) s[i]=s[i-1];
	s[n+1]='\0';
	failure(s,f);
//	for(int i=1;i<=n;i++) printf("%d ",f[i]);
//	puts("");
	failure(rs,rf);
//	for(int i=1;i<=n;i++) printf("%d ",rf[i]);
//	puts("");
//	printf("%d %d\n",n,f[n]);
	if(f[n]==n-1) printf("%d\n1\n",n);
	else if(f[n]==0||rf[n]==0||n%(n-f[n])!=0||n%(n-rf[n])!=0) puts("1\n1");
	else{
		for(int i=1;i<n;i++) if((i%(i-f[i])!=0||f[i]==0)&&(rf[n-i]==0||(n-i)%(n-i-rf[n-i])!=0)) tot++;
		printf("2\n%d\n",tot);
	}
	return 0;
}

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

int main(){
    int M,D;
    cin >> M >> D;
    int ans = 0;
    for(int i=1;i<=M;i++){
        for(int j=1;j<=D;j++){
            int d1 = j%10,d2 = j/10;
            if(d1>=2 && d2>=2 && d1*d2==i) ans++;
        }
    }   
    cout << ans << endl;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

vector<ll> combi_even(51, 0);
vector<ll> combi_odd(51, 0);

void bfs_even(int i, int n) {
    if (i == n) {
        combi_even[i] = 1;
        return;
    }
    combi_even[i+1] = combi_even[i]*(n-i)/(i+1);
    bfs_even(i+1, n);
}
void bfs_odd(int i, int n) {
    if (i == n) {
        combi_odd[i] = 1;
        return;
    }
    combi_odd[i+1] = combi_odd[i]*(n-i)/(i+1);
    bfs_odd(i+1, n);
}

int main() {
    int n, p;
    cin >> n >> p;
    vector<int> a(n);
    int cnt_even=0, cnt_odd=0;
    rep(i, n) {
        cin >> a[i];
        if (a[i]%2==0) {
            cnt_even++;
        }
        else {
            cnt_odd++;
        }
    }
    combi_even[0] = 1;
    combi_odd[0] = 1;
    bfs_even(0, cnt_even);
    bfs_odd(0, cnt_odd);
    ll out_even = 0;
    ll out_odd = 0;
    rep(i, cnt_even+1) out_even += combi_even[i];
    rep(i, cnt_odd+1) {
        if (p==0 && i%2 == 0) {
            out_odd += combi_odd[i];
        }
        else if (p==1 && i%2 == 1) {
            out_odd += combi_odd[i];
        }
    }
    cout << out_even * out_odd << endl;


    return 0;
}

Measured memory_bytes: 3600
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const inputs = input.trim().split('\n');

const COLORS = ['r','g','b'];
class Worm {
  constructor(id, depth) {
    this.id = id;
    this.depth = depth;
    this.colors = id.split('');
  }
  getNextWormIds() {
    const nextWormIds = [];
    for (let i = 0; i < this.colors.length - 1; i++) {
      const [ current, next ] = this.colors.slice(i, i + 2);
      if (current === next) {
        continue;
      }
      const changed = COLORS.find(s => s !== current && s !== next);
      const changedColors = this.colors.slice(); // copy
      changedColors.splice(i, 2, changed, changed); // 置き換え
      nextWormIds.push(changedColors.join(''));
    }
    return nextWormIds;
  }
}

class Graph {
  constructor() {
    this.map = new Map();
  }
  bfs(wormId) {
    this.queue = [];
    this.map.set(wormId, new Worm(wormId, 0));
    this.queue.push(wormId);
    while(this.queue.length) {
      const wormId = this.queue.shift();
      const worm = this.map.get(wormId);
      const wormIds = worm.getNextWormIds();
      if (!wormIds.length) {
        return worm;
      }
      wormIds.forEach(wormId => {
        if (this.map.has(wormId)) {
          return;
        }
        this.map.set(wormId, new Worm(wormId, worm.depth + 1));
        this.queue.push(wormId);
      })
    }
  }
}

inputs.forEach(wormId => {
  if (wormId === '0') {
    return;
  }
  const graph = new Graph();
  const worm = graph.bfs(wormId);
  console.log(worm ? worm.depth : 'NA');
});



Measured memory_bytes: 62716
import java.util.*;
public class Main {
	static long[] h=new long[212345];
	static long[] dp=new long[212345];
	static boolean check(long H,int i,int j) {
		return dp[i]-dp[j]+h[i]*h[i]-h[j]*h[j]<(h[i]-h[j])*H*2;
	}
	static boolean check(int i,int j,int k) {
		long fi=dp[i]+h[i]*h[i];
		long fj=dp[j]+h[j]*h[j];
		long fk=dp[k]+h[k]*h[k];
		return (fi-fj)*(h[j]-h[k])>(fj-fk)*(h[i]-h[j]);
	}
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		long C=in.nextLong();
		for (int i=0;i<n;++i) h[i]=in.nextLong();
		int[] deq=new int[n];
		int st=0,ed=0;
		deq[ed++]=0;
		for (int i=1;i<n;++i) {
			while (st+1<ed&&check(h[i],deq[st+1],deq[st])) ++st;
			dp[i]=dp[deq[st]]+(h[i]-h[deq[st]])*(h[i]-h[deq[st]])+C;
			while (st+1<ed&&check(deq[ed-2],deq[ed-1],i)) --ed;
			deq[ed++]=i;
		}
		System.out.println(dp[n-1]);
	}
}

Measured memory_bytes: 90568
#include <math.h>
#include <stdio.h>
#define rep(i, n) for ((i) = 0; (i) < (n); (i)++)
#define ld long double

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

    ld x[n];
    ld y;
    ld p1, p2, p3, pinf, absolute;
    p1 = 0; p2 = 0; p3 = 0; pinf = 0;

    rep(i, n) scanf("%Lf", &x[i]);

    rep(i, n) {
        scanf("%Lf", &y);

        absolute = fabs(x[i] - y);

        p1 += absolute;
        p2 += powl(absolute, 2.0);
        p3 += powl(absolute, 3.0);
        
        if (absolute > pinf) pinf = absolute;
    }

    printf("%Lf\n%Lf\n%Lf\n%Lf\n", p1, sqrtl(p2), cbrtl(p3), pinf);

    return 0;
}


Measured memory_bytes: 2096
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (1e9+7)
#define INF (1e9)
#define LLINF (4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename... R> void input(string& f, R&... r) { cin >> f; input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

int main() {
    string s; cin >> s;
    REP(i, 3) {
        if (s[i] == s[i + 1]) {
            puts("Bad");
            return 0;
        }
    }
    puts("Good");
    getchar(); getchar();
}

Measured memory_bytes: 256
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
A = list(map(int, readline().split()))
Q = int(readline())
M = list(map(int, readline().split()))

ans = [False] * Q
for bit in range(1 << N):
    acc = 0
    for i in range(N):
        if (bit & (1 << i)):
            acc += A[i]
    if acc in M:
        for i, m in enumerate(M):
            if acc == m:
                ans[i] = 1

for a in ans:
    if a:
        print("yes")
    else:
        print("no")



Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++)
    {
        cin >> A.at(i);
    }
    sort(A.begin(),A.end());
    cout << A.at((N/2))-A.at(N/2-1) <<endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<vector>
#include<map>
using namespace std;

class UF {
    public:
    vector<pair<int,int> > l;
    UF(int n) {
        for(int i=0; i<n; i++)
            l.push_back(pair<int,int>(i,0));
    }
    pair<int,int> root(int x) {
        if(x == l[x].first) return l[x];
        pair<int,int> t = root(l[x].first);
        l[x].first = t.first ;
        l[x].second+= t.second;
        return l[x];
    }
    void unite(int x, int y, int xMy) {
        pair<int,int> s=root(x),t = root(y);
        x = s.first;
        y = t.first;
        if(x == y) return;
        l[y].first = l[x].first;
        l[y].second= -xMy + s.second - t.second;
    }
    int weight(int x, int y) { // x - y else 123456
        pair<int,int> s,t;
        s = root(x);
        t = root(y);
        if(s.first != t.first) return 123456;
        return s.second - t.second;
    }
};


int main(void) {
    while(1) {
        int n,m;
        scanf("%d%d",&n,&m);
        if(!n) break;
        UF uf(n);
        for(int i=0; i<m; i++) {
            int a,b;
            char s[3];
            scanf("%s%d%d",s,&a,&b);
            a--, b--;
            if(s[0] == '?') {
                int w = uf.weight(b,a);
                if(w == 123456)
                    printf("UNKNOWN\n");
                else
                    printf("%d\n", w);
            }
            else {
                int w;
                scanf("%d",&w);
                uf.unite(b, a, w);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3708
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define mul(a,b) a=a*b%mod;
#define K 100010
#define D 55
ll f[K];
int main(){
  ll k; cin>>k;
  for(int i=0;i<k;i++)f[i]=1e17;
  priority_queue<pair<ll,ll> >Q;
  Q.push(make_pair(-1,1));
  while(!Q.empty()){
      ll y=-Q.top().first,x=Q.top().second;
      Q.pop();
      if(f[x]<=y)continue;
      f[x]=y;
      Q.push(make_pair(-(y+1),(x+1)%k));
      Q.push(make_pair(-y,x*10%k));
  }
  cout<<f[0]<<endl;
  return 0;
}


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

const int INF = 1e9;

int main() {
    string s;
    cin >> s;
    int len = s.size();
    int ans = INF;
    for (int i = 0; i < 26; ++i) {
        char last = 'a' + i;
        int num1 = -1;
        int cnt1 = 0;
        for (int j = len - 1; j >= 0; --j) {
            if (s[j] == last) {
                num1 = cnt1;
                break;
            }
            else {
                cnt1++;
            }
        }
        int num2 = -1;
        int cnt2 = 0;
        for (int j = 0; j < len; ++j) {
            if (s[j] == last) {
                num2 = max(num2, cnt2);
                cnt2 = 0;
            }
            else cnt2++;
        }
        int num = max(num1, num2);
        if (num != -1) ans = min(ans, num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
import numpy as np
bisect_left = np.searchsorted
N = input()
a = np.int32(input().split())
b = np.int32(input().split())
ans = 0
for k in range(29):
    low = pow(2, k)
    high = pow(2, k + 1)
    x = a % high
    y = b % high
    y.sort()
    y = np.hstack((y - high, y))  # 配列を横に連結
    left = bisect_left(y, low - x)
    right = bisect_left(y, high - x)
    if np.sum(right - left) % 2:
        ans += low
print(ans)

Measured memory_bytes: 35884
// Ivan Carvalho
// Problem A - Educational Dynamic Programming Contest - AtCoder
// Link : https://atcoder.jp/contests/dp
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 2*1e9;

int dp[MAXN],N,K,h[MAXN];

int main(){

	scanf("%d",&N);
	K = 2;
	for(int i = 1;i<=N;i++){
		scanf("%d",&h[i]);
	}

	for(int i = 2;i<=N;i++){
		dp[i] = INF;
		for(int j = i-1;j>=max(i - K,1);j--){
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]) );
		}
	}

	printf("%d\n",dp[N]);

	return 0;

}

Measured memory_bytes: 4448
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin>>s;
    if(s[0]!=s[1]&&s[1]!=s[2]&&s[0]!=s[2])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>

int n;
int a[2][100];
int ans=0, ansmax=0;

int main(void){
	scanf("%d", &n);
	for(int i=0;i<n;i++)	scanf("%d", &a[0][i]);
	for(int i=0;i<n;i++)	scanf("%d", &a[1][i]);

	for(int i=0;i<n;i++){
		ans=0;
		for(int j=0;j<=i;j++)	ans += a[0][j];
		for(int j=i;j<n;j++)	ans += a[1][j];
		if(ans>ansmax)	ansmax=ans;
	}
	printf("%d", ansmax);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
using namespace std;

#define bll long long
#define dou double
#define For(i,a,b) for (int i=(a),_##i=(b); i<=_##i; ++i)
#define Rof(i,a,b) for (int i=(a),_##i=(b); i>=_##i; --i)
#define Mem(a,b) memset(a,b,sizeof(a))
#define Cpy(a,b) memcpy(a,b,sizeof(b))

const int maxn=100+10;
int N,dp[5][maxn];
int A[5][maxn];

int main()
{
    for (; scanf("%d",&N)!=EOF; )
    {
        For(i,1,2)
            For(j,1,N) scanf("%d",&A[i][j]);
        Mem(dp,0);
        For(i,1,2)
            For(j,1,N) dp[i][j]=max(dp[i-1][j],dp[i][j-1])+A[i][j];
        printf("%d\n",dp[2][N]);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}
const int INF=1e6;
const ll int MOD=998244353;

main(){
    vec v={in(),in(),in()};
    sort(all(v));
    cout<<(v[0]+v[1] == v[2] ? "Yes" :"No");
}

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

using namespace std;

int ans = 0, n, m, q;
int a[55], b[55], c[55], d[55], answ[12];

void dfs(int v) {
    if (v == n + 1) {
        int cur = 0;
        for (int i = 1; i <= q; ++i) {
            if (answ[b[i]] - answ[a[i]] == c[i]) cur += d[i];
        }
        ans = max(ans, cur);
        return;
    }
    for (int i = answ[v - 1]; i <= m; ++i) {
        answ[v] = i;
        dfs(v + 1);
    }
}

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> q;
    for (int i = 1; i <= q; ++i) cin >> a[i] >> b[i] >> c[i] >> d[i];
    answ[0] = 1;
    dfs(1);
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 3644
#include<stdio.h>
int time[24][60];
int main(void)
{
	int i,j,h,m,f;
	for(i=0; i<2; ++i) {
		scanf("%d",&j);
			for(;j>0;--j) {
				scanf("%d %d",&h,&m);
				time[h][m]=1;
				}
			}
			f=1;
			for(i=0;i<24;i++)
				for(j=0;j<60;j++)
					if(time[i][j]){
						if(!f)printf(" ");
						else f=0;
						printf("%d:%02d",i,j);
						}
					printf("\n");
					return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    string a,b;
    cin>>a>>b;
    if (a.size()>b.size()){
        cout<<"GREATER";
    }else if (b.size()>a.size()){
        cout<<"LESS";
    }else {
        bool ans=false;
        for (int i=0;i<a.size();i++){
            if (a[i]==b[i]){
                continue;
            }else{
                if (a[i]>b[i]){
                    cout<<"GREATER";
                }else cout<<"LESS";
                ans=true;
                break;
            }
        }if (!ans){
            cout<<"EQUAL";
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

static int n, m, a[20] = { };

bool rc(int, int);

int main()
{
	int q;
	
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	scanf("%d", &q);
	for (int i = 0; i < q; i++)
	{
		scanf("%d", &m);
		if (rc(0, 0))
			printf("yes\n");
		else
			printf("no\n");
	}

	return 0;
}

bool rc(int here, int sum)
{
	if (sum > m)
		return false;
	sum += a[here];
	if (sum == m)
		return true;
	else if (here == n - 1)
		return false;
	else if (rc(here + 1, sum) || rc(here + 1, sum - a[here]))
		return true;
	else
		return false;
}


Measured memory_bytes: 2612
function main(input) {
  var inputList = input.split(" ");
  var a = Number(inputList[0]);
  var b = Number(inputList[1]);
  var k = Number(inputList[2]);
  var max = a >= b ? a: b;

  var arr = [];
  for(i=1; i<=max; i++){
    if(a % i===0 && b % i===0){
      arr.push(i);
    }
  }

  var rev = arr.reverse();
  console.log(rev[k-1]);
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
using System;

namespace _076_TreasureHuntII
{
	class Program
	{
		static void Main ( string[] args )
		{
			double[] x = new double[1001];
			double[] y = new double[1001];

			x[2] = y[2] = 1;

			//pre-processing

			double sumRadian = (90 - 45) * Math.PI / 180;

			for (int lp = 3; lp < x.Length; lp++)
			{
				x[lp] = x[lp - 1] - Math.Cos (sumRadian);
				y[lp] = y[lp - 1] + Math.Sin (sumRadian);

				double hypotenuse = GetHypotenuse (x[lp - 1], y[lp - 1]);
				sumRadian -= Math.Atan2 (1, hypotenuse);
			}

			string inputStr;

			while ((inputStr = Console.ReadLine ()) != "-1")
			{
				int index = int.Parse (inputStr);

				Console.WriteLine (x[index]);
				Console.WriteLine (y[index]);
			}
		}

		//??????
		static double GetHypotenuse ( double x, double y )
		{
			return Math.Sqrt (x * x + y * y);
		}
	}
}

Measured memory_bytes: 9432
let md (a, b) (c, d) = abs (a - c) + abs (b - d)

let mind cps (a, b) = snd @@ List.hd @@ List.sort (fun ((c1, d1), i1) ((c2, d2), i2) ->
                                                   let d1 = md (a, b) (c1, d1) in
                                                   let d2 = md (a, b) (c2, d2) in
                                                   if d1 = d2 then compare i1 i2 else compare d1 d2
                                                  ) cps
                                           
let _ =
  let n, m = Scanf.scanf "%d %d\n" (fun x y -> (x, y)) in
  let rec read n = if n <= 0 then []
                   else let x = Scanf.scanf "%d %d\n" (fun x y -> (x, y))
                        in x :: read (n - 1) in
  let sts = read n in
  let cps = List.mapi (fun i p -> (p, i+1)) (read m) in
  List.iter (fun x -> Printf.printf "%d\n" x) (List.map (mind cps) sts)


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(1234567890)

n, *L = map(int, open(0).read().split())
mod = 10 ** 9 + 7
con = [[] for _ in range(n + 1)]
sz = [1] * (n + 1)
par = [0] * (n + 1)

for s, t in zip(*[iter(L)] * 2):
	con[s] += t,
	con[t] += s,


def prepare(m, mod=10 ** 9 + 7):
	fac = [1] * (m + 1)
	inv = [1] * (m + 1)
	for i in range(1, m + 1):
		fac[i] = fac[i - 1] * i % mod
	inv[-1] = pow(fac[-1], mod - 2, mod)
	for i in range(m - 1, -1, -1):
		inv[i] = inv[i + 1] * (i + 1) % mod
	return fac, inv


fac, inv = prepare(n)


def dfs1(cur, pre):
	par[cur] = pre
	for nxt in con[cur]:
		if nxt != pre:
			dfs1(nxt, cur)
			sz[cur] += sz[nxt]
			dp1[cur] *= dp1[nxt] * inv[sz[nxt]] % mod
			dp1[cur] %= mod
	dp1[cur] *= fac[sz[cur] - 1]
	dp1[cur] %= mod


def dfs2(cur, pre):
	dp2[cur] *= dp1[cur] * inv[sz[cur] - 1] % mod
	dp2[cur] %= mod
	dp2[cur] *= fac[n - 1]
	dp2[cur] %= mod
	for nxt in con[cur]:
		if nxt != pre:
			dp2[nxt] = fac[sz[nxt]] * pow(n - sz[nxt], mod - 2, mod) * pow(dp1[nxt], mod - 2, mod) * dp2[cur] * inv[n - 1] % mod
			dfs2(nxt, cur)


dp1 = [1] * (n + 1)
dfs1(1, 0)
dp2 = [1] * (n + 1)
dfs2(1, 0)

print(*dp2[1:], sep="\n")


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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

#include <ext/rope>

 

#define ll long long

#define pb push_back

#define sz(x) (int)(x).size()

#define mp make_pair

#define all(x) x.begin(), x.end()

 

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<ll> stk;
	while(n--)
	{
		ll a;
		cin >> a;
		//cout << a << endl;
		stk.push_back(a);
		int q=stk.size();
		while(q>2&&stk[q-1]<=stk[q-2]&&stk[q-3]<=stk[q-2])
		{
			ll ne=stk[q-1]+stk[q-3]-stk[q-2];
			for(int i=0;i<3;i++)
			stk.pop_back();
			stk.push_back(ne);
			q-=2;
		}
	}
	ll sum=0;
	deque<ll> q;
	for(auto p:stk)
	q.push_back(p);
	int z=1;
	while(q.size())
	{
		if(q.front()>=q.back())
		{
			sum+=q.front()*z;
			q.pop_front();
		}
		else
		{
			sum+=q.back()*z;
			q.pop_back();
		}
		z*=-1;
	}
	cout << sum;
}
    


Measured memory_bytes: 256
x,y = map(int,input().split())
if abs(x) == abs(y):
    print(1)
elif x == 0:
    if y > 0:
        print(y)
    else:
        print(abs(y)+1)
elif y == 0:
    if x > 0:
        print(x+1)
    else:
        print(abs(x))
elif 0 < x < y or x < y < 0:
    print(y-x)
elif 0 < y < x or y < x < 0:
    print(x-y+2)
elif x < 0 < y:
    print(abs(x+y)+1)
elif y < 0 < x:
    print(abs(x+y)+1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  vi d(n);
  rep(i,n){
    cin>>d[i];
  }

  set<int> s;
  rep(i,n){
    int sum=0;
    for(int j=i;j<i+10&&j<n;j++){
      sum*=10;
      sum+=d[j];
      s.insert(sum);
    }
  }

  int i=0;
  while(true){
    if(s.find(i)==s.end()){
      cout<<i<<endl;
      return 0;
    }
    i++;
  }


}


Measured memory_bytes: 3552
//Author: AnandRaj uux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////

int main()
{
	int x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y<<endl;
}		

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int w, a, b;
	cin >> w >> a >> b;
	if ((w + a) < b) { cout << b - (w + a) << endl; return 0; }
	else if ((b >= a&&a+w>=b)||(b+w<=a+w&&b+w>=a)) { cout << "0" << endl; return 0; }
	else cout << a-(w + b)  << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  
  string a, b ; cin >> a >> b ;
  a += b;
  ll A = stoi(a);
  ll B = sqrt(A);
  if(B*B == A) cout << "Yes" << endl;
  else cout <<"No" << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;

  return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "3 4 9 0" ].parse.expand.solve == "5.000000000" );
	assert( [ "3 4 10 40" ].parse.expand.solve == "4.564257194" );
}



import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto abhm = input.front.split.to!( real[] );
	return tuple( abhm[ 0 ], abhm[ 1 ], abhm[ 2 ], abhm[ 3 ] );
}

auto solve( real a, real b, real h, real m )
{
	auto ar = PI * ( h * 60 + m ) / ( 6.0L * 60 );		// 時針は時＋分で動く
	auto br = PI * m / 30.0L;
	auto ay = a * cos( ar );
	auto ax = a * sin( ar );
	auto by = b * cos( br );
	auto bx = b * sin( br );
	auto ans = ( ( ay - by ) ^^ 2.0L + ( ax - bx ) ^^ 2.0L ) ^^ 0.5L;
	return format( "%0.9f", ans );
}


Measured memory_bytes: 3072
import sys
sys.setrecursionlimit(10**9)
from collections import defaultdict

IA = lambda: map(int,input().split())
IAS= lambda: map(str,input().split())

n=int(input())
mp=defaultdict(int)
a=list(IA())
flag=1
for it in a:
    if mp[it]==1:
        flag=0
    mp[it]=1
if flag==1:
    print("YES")
else:
    print("NO")

N=int(100005)
a=[int(0) for i in range(N)]



Measured memory_bytes: 33988
import java.io.IOException;
import java.util.Scanner;

public class Main {
    static double cross(double x1, double x2, double y1, double y2, double xp, double yp){
        return (x2-x1) * (yp-y2) - (y2-y1) * (xp-x2);
    }
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            final double x1 = sc.nextDouble();
            final double y1 = sc.nextDouble();
            final double x2 = sc.nextDouble();
            final double y2 = sc.nextDouble();
            final double x3 = sc.nextDouble();
            final double y3 = sc.nextDouble();
            final double xp = sc.nextDouble();
            final double yp = sc.nextDouble();
            
            double c1 = cross(x1, x2, y1, y2, xp, yp);
            double c2 = cross(x2, x3, y2, y3, xp, yp);
            double c3 = cross(x3, x1, y3, y1, xp, yp);
            /*
            double c1 = (x2-x1) * (yp-y2) - (y2-y1) * (xp-x2);
            double c2 = (x3-x2) * (yp-y3) - (y3-y2) * (xp-x3);
            double c3 = (x1-x3) * (yp-y1) - (y1-y3) * (xp-x1);
            */
            if ((c1 > 0&& c2 > 0 && c3 > 0)||(c1 < 0 && c2 < 0 && c3 < 0)){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }
    }
}

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

typedef long long ll;

using namespace std;

const ll mod=1000000000+7;

int main(){

   ll N;
   cin>>N;
   ll a=1;
   ll b=1;
   ll c=1;
   ll ans=0;

   for(ll i=0;i<N;++i){
       a=(a*10)%mod;
       //cout<<a<<endl;
       b=(b*9)%mod;
       //cout<<b<<endl;
       c=(c*8)%mod;
      // cout<<c<<endl;

   }

   ans=(a-2*b+c+2*mod)%mod;

   cout<<ans<<endl;
}



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

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	int sum=0;
	for(int i=n;i>=0;i--)
	{
		int sum2=0;
		for(int j=i;;sum2+=j%10,j/=10)
		{
			if(j<10)
			{
				sum2+=j%10;
				break;
			}
		}
		if(sum2>=a && sum2 <=b) sum+=i;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void bubbleSort(int A[], const int N)
{
    int i;
    int flag = 1, cnt = 0;

    while( flag ){
    //int j;
    //for( j = 0; flag; ++j ){
        flag = 0;

        for( i = N-1; 0 < i; --i )
        //for( i = N-1; j < i; --i )
            if( A[i] < A[i-1] ){
                int tmp = A[i];
                A[i] = A[i-1];
                A[i-1] = tmp;

                flag = 1;
                ++cnt;
            }
    }

    for( i = 0; i < N; ++i ){
        if( 0 < i ) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", cnt);
}

int main()
{
    int i;

    int N;
    scanf("%d", &N);
    int A[N];
    for( i = 0; i < N; ++i )
        scanf("%d", &A[i]);

    bubbleSort(A, N);

    return 0;
}



Measured memory_bytes: 1964
#include <iostream>

using namespace std;

inline int Sum(int n) {
  return n / 10000 + (n / 1000) % 10 + (n / 100) % 10 + (n / 10) % 10 + n % 10;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  int total = 0;
  for (int i = 1; i <= N; ++i) {
    const int sum = Sum(i);
    if (A <= sum && sum <= B) {
      total += i;
    }
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

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

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

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

  long n, k_;
  cin >> n >> k_;

  mint k = k_;
  mint k1 = k * (k-1) / 2;
  mint k2 = k * (k+1) / 2;

  vector<int> a(n);
  fillInt(a, n);

  // int cnts[2005] = {};

  // rep(i, n) {
  //   cnts[a[i]]++;
  // }

  mint res;
  rep(i, n) {
    mint a1, a2;
    for(int j = 0; j < i; j++) {
      if(a[j] < a[i]) a1 += 1;
    }
    for(int j = i+1; j < n; j++) {
      if(a[j] < a[i]) a2 += 1;
    }

    res += a1 * k1;
    res += a2 * k2;
  }

  cout << res.x << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)

using namespace std;
using ll = long long;

int main() {
	ll X;
	cin >> X;
	ll X0 = X;
	ll sum = 0;
	while (X != 0) {
		ll a = X % (ll)10;
		X = X / (ll)10;
		sum += a;
	}
	if (X0 % sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

int z[5005];

int go(string& s) {
	memset(z, 0, sizeof z);
	for(int i=1, l=0, r=0;i<s.size();i++) {
		if(i <= r) z[i] = min(z[i - l], r - i + 1);
		while(i+z[i]<s.size() && s[z[i]] == s[i+z[i]]) z[i]++;
		if(i + z[i] - 1 > r)
			l = i, r = i + z[i] - 1;
	}
	int ret = 0;
	for(int i=0;i<s.size();i++)
		ret = max(ret, min(z[i], i));
	return ret;
}

int32_t main()
{
	IO_OP;
	
	int n, ans = 0;
	string s;
	cin >> n >> s;
	for(int i=0;i<s.size();i++) {
		string t = s.substr(i);
		ans = max(ans, go(t));
	}	
	cout << ans << endl;
}





Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	
	public static void main (String[] args)  {
	
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = -1;
		for (int i=0;i<=n;i++) {
			if ((int)(1.08*i)==n) {
				ans = i;
			}
		}
		
		System.out.println(ans>=0 ? ans : ":(");
	}
}


Measured memory_bytes: 21844
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

int N;
int cnt1 = 0;

int countDivisors(int n)
{
    int cnt = 0;
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            if (n / i == i)
                cnt++;
 
            else 
                cnt = cnt + 2;
        }
    }
    return cnt;
}

int main() {
	scanf("%d", &N);
	for(int i = 1; i <= N; i += 2) {
		if(countDivisors(i) == 8) {
			cnt1++;
		}
	}
	printf("%d\n", cnt1);
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
	int n,f=0;
	scanf("%d",&n);
	for(int i=0;i<=n/4;i++)
	{
		for(int j=0;j<=n/4;j++)
		{
			if(i*4+j*7==n){printf("Yes\n",i,j);f=1;break;}
		}
		if(f)break;
	}
	if(!f)printf("No\n");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = [0]*n
for i in range(n):
  l[i] = int(input())
ans = 0
b = 1
rireki = set()
while True:
  ans += 1
  b = l[b-1]
  rireki.add(b)
  if b == 2:
    print(ans)
    break
  elif len(rireki) != ans:
    print(-1)
    break

Measured memory_bytes: 13164
#define _LIBCPP_DEBUG 0

#include <iostream>
#include <vector>

using namespace std;

int BubbleSort(vector<int> A, int N)
{
    int j;
    int flag = 1;
    int count = 0;

    while (flag == 1)
    {
        flag = 0;
        for (j = N-1; j > 0; j--)
        {
            if (A.at(j) < A.at(j-1))
            {
                swap(A.at(j), A.at(j-1));
                flag = 1;
                count++;
            }
        }
        
    }

    for (j = 0; j < N; j++)
    {
        if (j > 0)
        {
            cout << " ";
        }
        cout << A.at(j);
    }
    cout << "\n";
    cout << count << "\n";
    
}

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

    vector<int> vec(N);

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

    BubbleSort(vec, N);
}



Measured memory_bytes: 3132