akhauriyash/Code-Regression huggingface dataset:
def dfs(s,l):
  if s!="":
    if len(s)>10 or s[0]=="0":
      return
  if s!="":
    l.append(int(s))
  for c in "0123456789":
    if s!="":
      if abs(int(s[-1])-int(c))<=1:
        dfs(s+c,l)
    else:
      if c!="0":
        dfs(s+c,l)

k=int(input())
l=[]
dfs("",l)
l.sort()
print(l[k-1])

Measured memory_bytes: 11400
use std::io;


fn main() {
    let (n, t) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let tn = read::<usize>();
    let mut total: usize = t;

    for i in 1..n {
        if tn[i - 1] + t > tn[i] {
            total -= tn[i - 1] + t - tn[i];
        }
        total += t;
    }
    println!("{}", total);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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


int main() {
int N;
cin >> N;
int ans = -1;
for(int i = 0; i < 50000; i++){
if (floor(i * 1.08) == N) ans = i;
}
if(ans == -1) cout << ":(" << endl;
else cout << ans << endl;
}


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

int main() {
    vector<int> to[100000];
    int N, M;
    cin >> N >> M;

    rep(i, M) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        to[a].pb(b);
        to[b].pb(a);
    }

    queue<int> q;
    vector<int> dist(N, INF);
    vector<int> pre(N, -1);
    q.push(0);

    while (!q.empty()) {
        int f = q.front();
        q.pop();
        for (int t : to[f]) {
            if (dist[t] != INF) continue;
            dist[t] = dist[f] + 1;
            pre[t] = f;
            q.push(t);
        }
    }

    cout << "Yes" << endl;
    rep(i, N) {
        if (i == 0) continue;
        cout << ++pre[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 10628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct Union_Find_Tree{
    vector<int> par, rank, num, p;
    
    Union_Find_Tree(int N){
        par.assign(N, -1);
        rank.assign(N, 0);
        num.assign(N, 1);
        p.assign(N, 0);
    }
    
    int root(int x){
        if(par[x] < 0 || par[x] == x) return x;
        int ret = root(par[x]);
        p[x] += p[par[x]];
        return par[x] = ret;
    }

    int weight(int x){
        root(x);
        return p[x];
    }
    
    bool unite(int x, int y, int w){
        w += weight(x), w -= weight(y);
        x = root(x), y = root(y);
        if(x == y) return false;
        if(rank[x] < rank[y]) swap(x, y), w *= -1;
        if(rank[x] == rank[y]) rank[x]++;
        par[y] = x, num[x] += num[y];
        p[y] = w;
        return true;
    }
    
    int size(int x) {return num[root(x)];}
    
    bool same(int x, int y){
        return root(x) == root(y);
    }
    
    void clear(){
        fill(all(par), -1);
        fill(all(rank), 0);
        fill(all(num), 1);
        fill(all(num), 0);
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    Union_Find_Tree uf(N);
    bool ans = true;
    rep(i, M){
        int u, v, d; cin >> u >> v >> d; u--, v--;
        if(!uf.unite(u, v, d)){
            ans &= (uf.weight(v)-uf.weight(u) == d);
        }
    }
    cout << (ans? "Yes" : "No") << endl;
}

Measured memory_bytes: 4772
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define foreach(c,itr) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define INF 1e9;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
int main(){
	char a,b;
	cin>>a>>b;
	if(a==b){
		cout<<"=";
	} 
	else if(a>b){
		cout<<">";
	}
	else{
		cout<<"<";
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define _ << " " <<
#define db(x) //cout << "OK" << x << endl

#define int ll

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

const int MOD = 1e9 + 7;

vector<int> p(1001010, 1);

ll add(ll a, ll b) {
    return (((a + b) % MOD + MOD) % MOD);
}
ll sub(ll a, ll b) {
    return (((a + b) % MOD + MOD) % MOD);
}
ll mul(ll a, ll b) {
    return (((a * b) % MOD + MOD) % MOD);
}

int power(int x, int y) {
    if (y == 0) {
        return 1;
    }
    if (y & 1) {
        return mul(x, power(x, y - 1));
    }
    else {
        int j = power(x, y / 2);
        return mul(j, j);
    }
}

ll divide(ll a, ll b) {
    return (((a * power(b, MOD - 2)) % MOD + MOD) % MOD);
}
ll mod(ll a) {
    return ((a % MOD + MOD) % MOD);
}

void solve() {
    for (int i = 1; i < 1001010; ++i) {
        p[i] = mul(i, p[i - 1]);
    }
    int x, y;
    cin >> x >> y;
    if ((x + y) % 3) {
        cout << 0 << endl;
        return;
    }
    ///x = n + 2m
    ///y = 2n + m
    int n, m;
    m = x - (x + y) / 3;
    n = x - 2 * m;
    if (m < 0 || n < 0) {
        cout << 0 << endl;
        return;
    }
    cout << divide(p[n + m], mul(p[n], p[m])) << endl;
}

signed main() {
///#define TASK ""
#if !defined(LOCAL) && defined(TASK)
    freopen(TASK".in", "r", stdin);
    freopen(TASK".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int tests = 1;
    // cin >> tests;
    while (tests--) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    string s;cin>>s;
    vector<ll> cnt(26,0);
    for(ll i=0;i<s.size();i++)cnt[s[i]-'a']++;
    for(ll t=1;t<n;t++){
        cin>>s;
        vector<ll> tmp(26,0);
        for(ll i=0;i<s.size();i++)tmp[s[i]-'a']++;
        for(ll i=0;i<26;i++)cnt[i]=min(cnt[i],tmp[i]);
    }
    for(ll i=0;i<26;i++)while(cnt[i]-->0)cout<<char('a'+i);
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

X, N = map(int,input().split())

if( N == 0 ):
  #print("N=0")
  print(X)

else:
  P = list(map(int,input().split()))
  P_set = list(set(P))
  
  
  ans_chk = 0
  
  if ( X < P_set[0] or X > P_set[N-1] ):
    #print("X < P_set[0] or X > P_set[N-1]")
    print(X)
    ans_chk = 1
  
  if ( ans_chk==0 ):
    for i in range(N):
      if ( P_set[i] == X ):
        X_i = i
        break
      elif ( P_set[i] > X ):
        #print("P_set[i] > X")
        print(X)
        ans_chk = 1
        break
  
  if ( ans_chk==0 ):
    
    if ( X_i > N-(X_i+1) ): # 上の数が少ない → 下は1回多くする
      M = N-(X_i+1)
      temp_ans = X + N-(X_i+1) +1
      #print("temp_ans =",temp_ans)
      
      for i in range(1,M+1):
        if ( P_set[ X_i -i ] != X-i ):
          print(X-i)
          ans_chk = 1
          break
        elif ( P_set[ X_i +i ] != X+i ):
          print(X+i)
          ans_chk = 1
          break
      
      if ( ans_chk==0 ):
        if ( P_set[ X_i -(M+1) ] != X-(M+1) ):
          print( X-(M+1) )
          ans_chk = 1
  
  
    else: # 下の数が少ないor同数 → そのまま
      M = X_i
      temp_ans = X - X_i -1
      #print("temp_ans =",temp_ans)
    
      for i in range(1,M+1):
        if ( P_set[ X_i -i ] != X-i ):
          print(X-i)
          ans_chk = 1
          break
        elif ( P_set[ X_i +i ] != X+i ):
          print(X+i)
          ans_chk = 1
          break
  
  if ( ans_chk==0 ):
    print(temp_ans)

Measured memory_bytes: 9324
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

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

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

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

int main() {

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

	int N, K;
	cin >> N >> K;

	string s;
	cin >> s;

	int ans = 0;
	for (int i = 0; i < N - 1; i++) if (s[i] == s[i + 1])ans++;
	
	cout << min(ans + 2 * K, N - 1) << endl;

	return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
C - GeT AC
https://atcoder.jp/contests/abc122/tasks/abc122_c
AC
"""
import sys


def main(args):
    N, Q = map(int, input().split())
    S = input()
    ans = [0] * (N + 1)
    for i, a, c in zip(range(2, N), S, S[1:]):
        ans[i] = ans[i-1] + (a == 'A' and c == 'C')
    ans[-1] = ans[-2] + (S[-2:] == 'AC')

    # ans_d = {i:n for i, n in enumerate(ans)}
    for _ in range(Q):
        l, r = map(int, input().split())
        print(ans[r] - ans[l])


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 7668
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication19
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            double x1 = double.Parse(str[0]);
            double y1 = double.Parse(str[1]);
            double x2 = double.Parse(str[2]);
            double y2 = double.Parse(str[3]);

            double x = (double)x2 - x1;
            double y = (double)y2 - y1;

            double kyori = Math.Sqrt((x * x) + (y * y));

            Console.WriteLine("{0:f8}",kyori);
        }
    }
}

Measured memory_bytes: 5776
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
c = read().decode("utf-8").strip()
l = list("abcdefghijklmnopqrstuvwxyz")
 
if c == "z":
    print("a")
    quit()
 
f = False
for a in l:
    if a == c:
        f = True
        continue
    if f:
        ans = a.strip()
        print(ans)
        quit()

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int c[n-1];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        cin >> b[i];
    }
    for(int i=0; i<n-1; i++){
        cin >> c[i];
    }
    int p = -2;
    int s = 0;
    for(int i=0; i<n; i++){
        s += b[a[i]-1];
        if(p+1 == a[i]){
            s += c[p-1];
        }
        p = a[i];
    }
    cout << s << endl;
}

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

int main(){
  vector<char> num(4);
  for(char &x:num){
    cin>>x;
  }
  for(int i=0;i<3;i++){
    if(num[i+1]==num[i]){
      cout<<"Bad"<<endl;;
      return 0;
    }
  }
  cout<<"Good"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n;
    cin>>n;
    ll a[n];
    rep(i,n){cin>>a[i];}
    sort(a,a+n);
    deque<ll> que;
    ll cur1=0,cur2=n-1;
    que.push_back(a[cur1]);
    cur1++;
    bool nxt=true;
    while(cur2>=cur1){
        if(cur2 == cur1){
            if(abs(que.front()-a[cur2])>abs(que.back()-a[cur2])){
                que.push_front(a[cur2]);
            }
            else{
                que.push_back(a[cur2]);
            }
            cur2--;
        }
        else if(nxt){
            if(que.front()>que.back()){
                que.push_back(a[cur2]);
            }else{
                que.push_front(a[cur2]);
            }
            nxt=false;
            cur2--;
        }else{
            if(que.front()>que.back()){
                que.push_front(a[cur1]);
            }else{
                que.push_back(a[cur1]);
            }
            nxt=true;
            cur1++;
        }
    }
    ll res=0;
    ll prev = que.front();
    while(!que.empty()){
        res += abs(que.front()-prev);
        prev = que.front();
        que.pop_front();
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
using namespace std;
int main(){
	int n;
	string s("0123456789");
	while(cin>>n){
		if(n==0) break;
		int x[n+1],da[n+1],noneflg=0;
		x[0]=0;
		string a[n+1];
		for(int i=1;i<=n;i++){
			x[i]=0;
			da[i]=0;
			cin>>a[i];
			if(a[i]=="x"){
				x[i]=1;
				if(x[i-1]==1){
					noneflg=1;
				}
			}
			else{
				int len=a[i].size();
				for(int j=0;j<len;j++){
					for(int k=0;k<10;k++){
						if(a[i][len-1-j]==s[k]){
							da[i]=da[i]+pow(10,j)*k;
							break;
						}
					}
				}
				if(a[i][0]=='-'){
					da[i]=-da[i];
				}
			}
		}
		for(int i=1;i<=n-1;i++){
			if(da[i]!=0&&da[i+1]!=0){
				if(i%2==0){
					if(da[i]<=da[i+1]){
						noneflg=1;
					}
				}
				else{
					if(da[i]>=da[i+1]){
						noneflg=1;
					}
				}
			}
		}
		int ue=pow(10,9)+2,shita=-ue;
		for(int i=2;i<=n-1;i++){
			if(x[i]==1){
				if(i%2==0){
					if(x[i-1]==0) shita=max(shita,da[i-1]+1);
					if(x[i+1]==0) shita=max(shita,da[i+1]+1);
				}
				else{
					if(x[i-1]==0) ue=min(ue,da[i-1]-1);
					if(x[i+1]==0) ue=min(ue,da[i+1]-1);
				}
			}
		}
		if(x[1]==1&&x[2]==0){
			ue=min(ue,da[2]-1);
		}
		if(x[n]==1&&x[n-1]==0){
			if(n%2==0){
				shita=max(shita,da[n-1]+1);
			}
			else{
				ue=min(ue,da[n-1]-1);
			}
		}
		if(noneflg==1){
			cout<<"none"<<endl;
		}
		else if(ue==shita){
			cout<<ue<<endl;
		}
		else if(ue>shita){
			cout<<"ambiguous"<<endl;
		}
		else if(ue<shita){
			cout<<"none"<<endl;
		}
	}
    return 0;
}

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

int main() {
  string n;
  int cnt = 0;
  cin >> n ;
  for(int i=0;i<3;i++){
    if(n[i] == n[i+1]){
      cnt++;
    }else if(cnt < 2){
      cnt = 0;
    }  
  }
  if(cnt >= 2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
using System;

class Program
	{
		static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			int	x=int.Parse(input[1]);
			int y=int.Parse(input[2]);
			int c=0;
			int n=int.Parse(input[0]);
			int d=0;
			if(x>=y)
			{
				c=y;
				if(n-c-x >0)
				{
				d=0;
				}
				else
				{
					d=(n-c-x)*-1;
				}
			}
			else
			{
				c=x;
				if(n-c-y >0)
				{
					d=0;
				}
				else
				{
					d=(n-c-y)*-1;
				}
			}
 
			Console.WriteLine(c + " " + d);
			
		}
	}


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

int main()
{
    int a, b, c;
    int k;
    cin >> a >> b >> c;
    cin >> k;
    int count = 0;
    while( b <= a ) 
    {
        count++;
        b *= 2;
    }
    while( c <= b ) 
    {
        count++;
        c *= 2;
    }

    if( count <= k )
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 3588
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
INF = 10**9


def dfs(pos, a_tmp, b_tmp, c_tmp):
    if pos == n:
        if min(a_tmp, b_tmp, c_tmp) > 0:
            return abs(a-a_tmp)+abs(b-b_tmp)+abs(c-c_tmp)-30
        else:
            return INF
    res0 = dfs(pos+1, a_tmp, b_tmp, c_tmp)
    res1 = dfs(pos+1, a_tmp+l[pos], b_tmp, c_tmp)+10
    res2 = dfs(pos+1, a_tmp, b_tmp+l[pos], c_tmp)+10
    res3 = dfs(pos+1, a_tmp, b_tmp, c_tmp+l[pos])+10
    return min(res0, res1, res2, res3)


print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
def examA():
    K = I()
    A, B = LI()
    for i in range(A,B+1):
        if i%K==0:
            print("OK")
            return
    print("NG")
    return

def examB():
    X = I()
    now = 100
    ans = 0
    while(now<X):
        ans += 1
        now += now//100
    print(ans)
    return

def examC():
    N, M, Q = LI()

    ans = 0
    print(ans)
    return

def examD():
    A, B, N = LI()
    if N>=B-1:
        ans = (A*(B-1))//B
    else:
        ans = (A*N)//B
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examD()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 76560
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() { int r;
  cin >> r;
  cout << r * r * 3 << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                String[] a = new String[n];
                for(int i = 0 ; i < n ; i++){
                        a[i] = sc.next();
                }
                sc.close();
                Arrays.sort(a);
                int yono = 1;
                for(int i = 1 ; i < n ; i++){
                        if(!a[i - 1].equals(a[i])) yono++;
                }
                System.out.println(yono);
        }
}

Measured memory_bytes: 70844
#pragma GCC optimize("Ofast")
#include<stdio.h>
int main(void)
{
    switch(getchar_unlocked())
    {
      case '2': puts("14"); return 0;
      case '3': puts("39"); return 0;
      case '4': puts("84"); return 0;
      case '5': puts("155"); return 0;
      case '6': puts("258"); return 0;
      case '7': puts("399"); return 0;
      case '8': puts("584"); return 0;
      case '9': puts("819"); return 0;
      default: switch(getchar_unlocked())
      {
        case '0': puts("1110"); return 0;
        default: puts("3");
      }
    }
    return 0;
}


Measured memory_bytes: 1472
#include<cstdio>
#include<cassert>
#define debug(...) fprintf(stderr,__VA_ARGS__)
const int maxp = 8000 + 10;
typedef long long ll;

bool notprime[maxp];
ll prime[maxp] , prime_cnt;
void sieve(){
	for(int i = 2;i < maxp;i++){
		if(!notprime[i]) prime[prime_cnt++] = i;
		for(int j = 0;i * prime[j] < maxp && j < prime_cnt;j++){
			ll t = i * prime[j]; notprime[t] = 1;
			if(i % prime[j] == 0) break;
		}
	}
}


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

const int maxn = 500 + 10;
ll a[maxn][maxn];
int cnt,n;

int main(){
	sieve();
	scanf("%d",&n);
	if(n == 2) return !printf("4 7\n23 10");
	for(int i = 0;i <= n + 1;i++){
		for(int j = 0;j <= n + 1;j++){
			a[i][j] = 1;
		}
	}
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++){
			if((i + j) % 2 ==  0){
				a[i][j] = prime[(i + j >> 1) - 1] * prime[(i - j) / 2 + n / 2 + n];
			}
		}
	}
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++){
			if((i + j) & 1){
				a[i][j] = lcm(a[i][j - 1] , lcm(a[i][j + 1],lcm(a[i - 1][j],a[i + 1][j]))) + 1;
				assert(a[i][j] <= 1e15);
			}
		}
	}
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++){
			printf("%lld%c",a[i][j]," \n"[j == n]);
		}
	}	
}

Measured memory_bytes: 5120
while True:
    n = int(input())
    sumlist=[]
    sum=0
    max=-100000
    if n==0:
        break
    for i in range(n):
         sumlist.append(int(input()))
    for i in range(n):
        sum=0
        for j in range(0,n-i):
            sum=sumlist[i+j]+sum
            if max<sum:
                max=sum

    print(max)

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

typedef long long LL;
typedef pair<LL, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;

LL a[500][500];
LL b[500][500];
LL u[500][500];


int used[500];
int x[500];
int n;
void check(int V)
{
	set<PII> foo;
	x[V] = V;
	foo.insert(MP(0,V));
	while(SZ(foo))
	{
		int v = foo.begin()->Y;
		int fr = x[v];
//		cout << v << " " << fr << endl;
		u[fr][v] = 1;
		u[v][fr] = 1;
		foo.erase(foo.begin());
		FOR(i,0,n)
		{
			if(i!=v && a[V][i] == a[V][v] + a[v][i])
			{
				if(foo.find(MP(a[V][i], i))!=foo.end())
					foo.erase(MP(a[V][i], i));
				x[i] = v;
				foo.insert(MP(a[V][i], i));
			}
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	FOR(i,0,n)
		FOR(j,0,n)
		{
			cin >> a[i][j];
			b[i][j] = a[i][j];
		}

	FOR(i,0,n)
		FOR(j,0,n)
			FOR(k,0,n)
				b[i][j] = min(b[i][j], b[i][k] + b[k][j]);

	FOR(i,0,n)
		FOR(j,0,n)
			if(a[i][j] != b[i][j])
			{
				cout << -1;
				return 0;
			}
	FOR(i,0,n)
	{
		check(i);
	}
	LL ans = 0;
	FOR(i,0,n)
		FOR(j,0,n)
			if(u[i][j] || u[j][i])
			{
				ans += a[i][j];
			}

	cout << ans/2;

	return 0;
}


Measured memory_bytes: 4608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I,k=0;
		StringBuilder sb=new StringBuilder();
		if(n%2==0){
			for(int i = 1;i<=n/2;i++) {
				for(int j = i+1;j<=n-i;j++) {
					sb.Append(i+" "+j+"\n");
					sb.Append(n-i+1+" "+j+"\n");
					k+=2;
				}
			}
		}
		else{
			for(int j = 1;j<n;j++) {
				sb.Append(n+" "+j+"\n");
				k++;
			}
			for(int i = 1;i<=n/2;i++) {
				for(int j = i+1;j<n-i;j++) {
					sb.Append(i+" "+j+"\n");
					sb.Append(n-i+" "+j+"\n");
					k+=2;
				}
			}
		}

		Console.WriteLine("{0}",k);
		Console.Write(sb);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 13272
abc=list(map(chr,range(97,123)))

s=input()
t=input()
for x in abc:
    if x in t and x not in s:
        print(-1)
        exit()
l=[[0]*len(s) for _ in [0]*26]
j=0
for x in abc:
    if x in s and x in t:
        f=s.find(x)
        k=-1
        for i in range(len(s)-1,-1,-1):
            l[j][i]=k if k>=0 else f
            if s[i]==x:k=i
    j+=1
c=0
i=-1
j=0
while j<len(t):
    k=l[abc.index(t[j])][i]
    if k<=i:c+=1
    i=k
    j+=1
print(c*len(s)+k+1)

Measured memory_bytes: 26880
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    int A,B,C;
    cin >> A>>B>>C;
    int MAX = max({A, B, C});
    cout << MAX*10+A+B+C-MAX << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {

		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int a = n % 10;
			int b = n / 100;
			if(a==b){
				out.println("Yes");
			}else{
				out.println("No");
					
			}
		}

	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextFloat() {
			return Double.parseDouble(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
}

Measured memory_bytes: 20308
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vs = vector<string>;
using ii = vector<vector<long long>>;
//#define int long long
int main() {
    ll n;
    cin >> n;
    vl a(n);
    bool x = true;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n - 1; i++) {
        if (a[i] == a[i + 1]) {
            x = false;
        }
    }
    if (x) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 4860
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI               \
   ios_base::sync_with_stdio(false); \
   cin.tie(NULL);                    \
   cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double
#define endl "\n"

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int32_t main()
{
   AB_BHI_NI_DEGI
   //freopen("input.txt", "r", stdin);
   //freopen("output.txt", "w", stdout);
   //cout.precision(20);
   //cout << fixed;
   int T = 1;
   //cin >> T;
   int cnt = 1;
   while (T--)
   {
      int n;
      cin >> n;
      int a[n];
      int sum = 0;
      for (int i = 0; i < n; i++)
         cin >> a[i], sum += a[i];
      int ans = 0;
      for (int i = 0; i < n - 1; i++)
      {
         sum -= a[i];
         ans += ((a[i] % mod) * (sum % mod)) % mod;
         ans %= mod;
      }
      cout << ans << "\n";
   }
   return 0;
}

Measured memory_bytes: 5112
def func(s,sz):
    a = int(sz/2)
    for i in range(int(sz/2)):
       if s[i]!=s[a]:
           return 0
       a+=1
    return 1
n = int(input())
if n%2!=0:
    print("No")
else:
    s = input()
    if(func(s,n) == 1):
        print("Yes")
    else:
        print("No")



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

#define SIZE 250

int main(){
  int i,n;
  int heap[SIZE];

  scanf("%d",&n);

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

  for(i = 1; i <= n; i++){
    printf("node %d: key = %d,",i ,heap[i]);
    if(i != 1){
      printf(" parent key = %d,",heap[i/2]);
    }
    if(2*i <= n){
      printf(" left key = %d,",heap[2*i]);
    }
    if(2*i+1 <= n){
      printf(" right key = %d,",heap[2*i+1]);
    }
    printf(" \n");
  }

  return 0;
}

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

int main(){
int a;
cin>>a;
int a1=a%10;
int a2=(a%100-a1)/10;
int a3=(a%1000-a1-a2)/100;
int a4=(a-a1-a2-a3)/1000;
     if(a4+a3+a2+a1==7)
  cout<<a4<<"+"<<a3<<"+"<<a2<<"+"<<a1<<'='<<7;
else if(a4+a3+a2-a1==7)
  cout<<a4<<"+"<<a3<<"+"<<a2<<"-"<<a1<<'='<<7;
else if(a4+a3-a2+a1==7)
  cout<<a4<<"+"<<a3<<"-"<<a2<<"+"<<a1<<'='<<7;
else if(a4+a3-a2-a1==7)
  cout<<a4<<"+"<<a3<<"-"<<a2<<"-"<<a1<<'='<<7;
else if(a4-a3+a2+a1==7)
  cout<<a4<<"-"<<a3<<"+"<<a2<<"+"<<a1<<'='<<7;
else if(a4-a3+a2-a1==7)
  cout<<a4<<"-"<<a3<<"+"<<a2<<"-"<<a1<<'='<<7;
else if(a4-a3-a2+a1==7)
  cout<<a4<<"-"<<a3<<"-"<<a2<<"+"<<a1<<'='<<7;
else if(a4-a3-a2-a1==7)
  cout<<a4<<"-"<<a3<<"-"<<a2<<"-"<<a1<<'='<<7;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    int mn = 10000000, mx = -10000000;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        int t; cin >> t;
        if (t < mn) mn = t;
        if (t > mx) mx = t;
        sum += t;
    }
    cout << mn << " " << mx << " " << sum << endl;
}


Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
    long int n,a,b,c,count,i;
    scanf("%ld %ld %ld\n",&n,&a,&b);
    count=0;
    for(i=0;i<n;i++)
    {
        scanf("%ld",&c);
        if(c<a ||  c>=b)
        {
            count++;
        }
    }
    printf("%ld\n",count);

    return 0;
}

Measured memory_bytes: 128
#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[i];

    for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 0) {
            if (A[i] % 3 == 0 || A[i] % 5 == 0) {

            } else {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (int)n;i++)
#define repb(i,n) for(int i = (int)n;i >= 0;i--)
#define reps(i,m,n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i,m,n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v,n) sort(v,v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
    int a,b,n;
    cin>>n>>a>>b;

    cout<<(n-a+1)*(n-b+1)<<endl;
    return 0;
}


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

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int> 
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define eps 1e-9

ll C[100005], A[100005];

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

	ll n, i, j, k, x, y, z;
	cin >> n;
	for (i = 1; i <= n; ++i) cin >> A[i];
	A[0] = -MOD;
	for (i = 2; i <= n; ++i) {
		C[i] = min(C[i-1] + abs(A[i] - A[i-1]), C[i-2] + abs(A[i] - A[i-2]));
	}
	cout << C[n] << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main(){
  int n ;cin>>n ;
  vector<ll> A(n) ;rep(i,n) cin>>A[i] ;
  int w=0 ;
  int ans=0 ;
  rep(i,n-1){
   if((w==1&&A[i]<A[i+1])
   ||(w==-1&&A[i]>A[i+1])) {
      ans++ ;
      w=0 ;
      }
   else if(A[i]>A[i+1] ) w=1 ;
   else if(A[i] <A[i+1] ) w= -1 ;
   
  }
  cout<< ans+1 <<endl ;
     return 0;
  }

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,x,y,ans[202020];
int main()
{
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			ans[min(j-i,abs(x-i)+1+abs(y-j))]++;
		}
	}
	for(int i=1;i<n;i++)
	{
		cout<<ans[i]<<endl;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
X, K, D = map(int,input().split())

Abs_X = abs(X)
step  = Abs_X // D

if step < K:
    if (K - step) % 2 == 0:
        answer = min(abs(X + step*D), abs(X - step*D))
    else:
        answer = min(abs(X + (step+1)*D), abs(X - (step+1)*D))
else:
    answer = min(abs(X + D*K), abs(X - D*K))

print(answer)

Measured memory_bytes: 9204
n,m=map(int,input().split())
s1=set()
s2=set()
for _ in range(m):
  a,b=map(int,input().split())
  if a==1:
    s1.add(b)
  if b==n:
    s2.add(a)
if len(s1&s2)!=0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

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

using namespace std;

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

    int n,k,sum=0;
    cin>>n>>k;

    int arr[n]={};

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

    sort(arr,arr+n);

    for(int i=0;i<min(n,k);i++){
        sum+=arr[i];
    }

    cout<<sum<<"\n";


    return 0;
}


Measured memory_bytes: 3688
#include<iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int a,b,m1,m2;
    cin >> a >> b;
    m1 = max(a+b,a-b);
    m2 = max(m1,a*b);
    cout << m2;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
using namespace std;
 
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;
 
int main() {
    auto time = clock();
    int n; cin >> n;
    vll f(n + 1);
    FOR(i, 1, n) {
        for (int j = i; j <= n; j += i) {
            f[j]++;
        }
    }
    ll sum = 0;
    FOR(i, 1, n) sum += i * f[i];
    cout << sum << endl;
}

Measured memory_bytes: 81460
package main

import (
	"fmt"
)

func main() {
	//strs := "rng"
	//a := "yakinku"
	//b := "unagi"
	//c := "iushi"
	var a, b, c string
	fmt.Scanf("%s%s%s", &a, &b, &c)

	//fmt.Println(a, b, c)
	//fmt.Println(len(a), len(b), len(c))

	if a[len(a)-1] == b[0] && b[len(b)-1] == c[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512
fun main(args:Array<String>) {
    val (h,w) = readLine()!!.split(" ").map { it.toInt() }
    val dp = Array(h+1){Array(w+1){Int.MAX_VALUE / 2} }
    val board = Array(h){CharArray(w)}
    val dirs = arrayOf(1 to 0, 0 to 1)

    for(i in 0 until h) {
        board[i] = readLine()!!.toCharArray()
    }

    dp[0][0] = if(board[0][0] == '#') 1 else 0


    for(y in 0 until h) {
        for(x in 0 until w) {
            val cur = board[y][x]
            for((dy, dx) in dirs) {
                val ny = dy + y
                val nx = dx + x
                if(ny >= h || nx >= w) continue
                val next = board[ny][nx]
                if(cur == '#') {
                    if(dp[ny][nx] > dp[y][x]) {
                        dp[ny][nx] = dp[y][x]
                    }
                } else {
                    if(next == '#') {
                        if(dp[ny][nx] > dp[y][x] + 1) {
                            dp[ny][nx] = dp[y][x] + 1
                        }
                    } else {
                        if(dp[ny][nx] > dp[y][x]) {
                            dp[ny][nx] = dp[y][x]
                        }
                    }
                }
            }
        }
    }
    print(dp[h-1][w-1])
}

Measured memory_bytes: 38076
#include<stdio.h>

int temp[300001];

void MergeSort(int x[],int left,int right);

int main(void){
  int N,i,j,sizeof_a;
  int a[300001];
  long long sum=0;
  scanf("%d",&N);
  sizeof_a=3*N;
  for(i=0;i<sizeof_a;i++) scanf("%d",&a[i]);
  MergeSort(a,0,sizeof_a-1);
  //for(i=0;i<sizeof_a;i++) printf("%d",a[i]);
  //putchar('\n');
  for(i=sizeof_a-2,j=0;j<N;i-=2,j++){
    sum+=a[i];
  }
  printf("%lld\n",sum);
  return 0;
}

void MergeSort(int x[],int left,int right){
  int mid,i,j,k;
  if(left >= right) return;
  mid = (left+right)/2;
  MergeSort(x,left,mid);
  MergeSort(x,mid+1,right);

  for(i=left;i<=mid;i++) temp[i] = x[i];
  for(i=mid+1,j=right;i<=right;i++,j--) temp[i]=x[j];

  i=left;
  j=right;

  for(k=left;k<=right;k++){
    if(temp[i] <= temp[j]) x[k] = temp[i++];
    else x[k] = temp[j--];
  }
}


Measured memory_bytes: 2560
while(True):
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    else:
        pass

    for i in range(h):
        for j in range(w):
            if (i + j)%2 == 0:
                print("#", end = "")
            else:
                print(".", end= "")
        print()
    print()


Measured memory_bytes: 7004
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
dp = [1 for i in range(10**6+10)]
for i in range(n):
    if dp[a[i]] == 1:
        dp[a[i]] = 2
        for j in range(2*a[i], 10**6+10, a[i]):
            dp[j] = 0
    elif dp[a[i]] == 2:
        dp[a[i]] = 0
res = 0
for i in range(n):
    if dp[a[i]] == 2:
        res += 1
print(res)    

Measured memory_bytes: 32296
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def main():
    N = int(input())
    for i in range(int(N ** 0.5), 0, -1):
        if N % i == 0:
            print(len(str(N // i)))
            break


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define io freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define lli long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fi(a,n) for(lli i=a; i<=n; i++)
const int M=1000000007;
using namespace std;
const lli NINF=-1e18;
const int mxn=1e5;

int main(){
	
	fast
	lli d,s,t;
	cin>>d>>t>>s;
	
		
		if(t*s<d)cout<<"No"<<endl;
		else cout<<"Yes"<<endl;


  
    // cout<<nd(s)<<endl<<endl; 
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>

int main(void)
{
    char A[11], B[11], C[11];
    scanf("%s%s%s", A, B, C);
    if (A[strlen(A)-1]==B[0] && B[strlen(B)-1]==C[0]) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}

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

using namespace std;

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	
	set<int> s;
	
	s.insert(a);
	s.insert(b);
	s.insert(c);
	
	printf("%d\n", s.size());
	
	return 0;
}

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

int insert(int *,int,int);
void shell(int *,int);
int gizi(int *,int);
int main(){
	int n,i,*a;
	scanf("%d",&n);
	a=(int *)malloc(sizeof(int)*n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	shell(a,n);
	free(a);
	return 0;
}

int insert(int *a,int n,int g){
	int i,j,key,cnt=0;
	for(i=g;i<n;i++){
		key=a[i];
		j=i-g;
		while(j>=0 && key<a[j]){
		a[j+g]=a[j];
		j=j-g;	
		cnt++;
		}
		a[j+g]=key;
	}
	
	return cnt;
}
void shell(int *a,int n){
	int m,i,cnt=0;
	int *g;
	g=(int *)malloc(sizeof(int)*n);
	m=gizi(g,n);
	for(i=m-1;i>=0;i--){
		cnt+=insert(a,n,g[i]);
	}
	printf("%d\n",cnt);
	for(i=0;i<n;i++){
		printf("%d\n",a[i]);
	}
	
}
int gizi(int *g,int n){
	int i=0,j;
	g[i]=1;
	while(n>=g[i]){
		i++;
		g[i]=3*g[i-1]+1;
	}
	printf("%d\n",i);
	for(j=i-1;j>=0;j--){
		if(j==0)printf("%d\n",g[j]);
		else printf("%d ",g[j]);
	}
	return i;
}




Measured memory_bytes: 5436
#include<cctype>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
#define N 6000010
using namespace std;int n,m,a[300010],res;
inline LL read()
{
	char c;LL d=1,f=0;
	while(c=getchar(),!isdigit(c)) if(c=='-') d=-1;f=(f<<3)+(f<<1)+c-48;
	while(c=getchar(),isdigit(c)) f=(f<<3)+(f<<1)+c-48;
	return d*f;
}
struct xds
{
	#define lson k<<1
	#define rson k<<1|1
	int maxn[N<<2];
	inline int Query(int ql,int qr,int k=1,int l=0,int r=N-10) 
	{
		if(ql<=l&&r<=qr) return maxn[k];
		int mid=l+r>>1,res=0;
		if(ql<=mid) res=max(res,Query(ql,qr,lson,l,mid));
		if(qr>mid) res=max(res,Query(ql,qr,rson,mid+1,r));
		return res;
	}
	inline void Modify(int x,int d,int k=1,int l=0,int r=N-10)
	{
		if(l==r) {maxn[k]=d;return;}
		int mid=l+r>>1;
		if(x<=mid) Modify(x,d,lson,l,mid);
		else Modify(x,d,rson,mid+1,r);
		maxn[k]=max(maxn[lson],maxn[rson]);
		return;
	}
}T;
signed main()
{
	n=read();m=read();
	for(register int i=1;i<=n;i++) a[i]=read()+m;
	T.Modify(a[1],1);res=1;
	for(register int i=2;i<=n;i++)
	{
		int now=T.Query(a[i]-m,a[i]+m)+1;
		T.Modify(a[i],now);
		res=max(res,now);
	}
	printf("%d",res);
}

Measured memory_bytes: 6104
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ASC(v) sort(v.begin(), v.end());
#define DESC(v) sort(v.begin(), v.end(), greater<int>());
#define REVERSE(v) reverse(v.begin(), v.end());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];

	bool can = true;

	map<ll, ll> M;
	REP (i, N) {
		if (M.find(A[i]) != M.end()) {
			can = false;
			break;
		}
		else M[A[i]] = 1;
	}

	if (can) cout << "YES" << "\n";
	else cout << "NO" << "\n";
}


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

typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<bool> > vvb;
typedef map<int, bool> mib;

typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vpll;

typedef vector<string> vs;

typedef long double ld;

#define _GLIBCXX_DEBUG

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n-1); i >= 0; --i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << '\n'
#define debug3(x, y, z) cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << '\n'
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

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

#define fst first
#define snd second
#define pb push_back
#define mp(x,y) make_pair((x),(y))

const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

// Sieve of Eratosthenes
vi get_primes(int input) {
    int N = max(input, 100);

    vb Alive(N, true);
    Alive.at(0) = false;
    Alive.at(1) = false;

    // i番目の素数が分かる (0-origin)
    vi Ps;

    FORE(smallest, 2, (int)(sqrt(N)+1)) {
        if (!Alive.at(smallest)) {
            continue;
        }

        for(int i = smallest * 2; i < N; i += smallest) {
            Alive.at(i) = false;
        }
    }

    REP(i, N) {
        if (Alive.at(i)) {
            Ps.pb(i);
        }
    }

    return Ps;
}


signed main() {
    int N, K;

    cin >> N >> K;

    string yes = "POSSIBLE";
    string no = "IMPOSSIBLE";

    int max_a = 0;
    vector<int> As(N);
    REP(i, N) {
        int A;
        cin >> A;
        As.at(i) = A;

        if (A == K) {
            cout << yes << endl;
            return 0;
        }

        if (A > max_a) {
            max_a = A;
        }
    }

    if (K > max_a) {
        cout << no << endl;
        return 0;
    }

    if (N == 1) {
        if (As.at(0) == K) {
            cout << yes << endl;
            return 0;
        } else {
            cout << no << endl;
            return 0;
        }
    }

    vi primes = get_primes(N);
    // 全てが共通の素因数を持っていたらNG
    // p < 10^5 まで調べればOK

    for (auto p : primes) {
        if (p > 100000) {
            break;
        }

        bool has_common = true;
        REP(i, N) {
            int A = As.at(i);
            // debug2(p, A);

            if (!(A % p == 0)) {
                // 次のprimeへ
                has_common = false;
                break;
            }
        }

        if (has_common) {
            if (K % p == 0) {
                cout << yes << endl;
            } else {
                cout << no << endl;
            }
            return 0;
        } else {
            continue;
        }
    }

    cout << yes << endl;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int d[5], k;
    for(int i=0;i<5;i++)
        cin >> d[i];
    cin >> k;

    // 昇順ソート
    sort(d, d + 5);

    if(d[4] - d[0] <= k){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int f[5009];
int a[5009];
ll sum=0;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        sum+=min(a[i],k);
        a[i]=min(a[i],k);
    }
    sort(a+1,a+2+n);
    f[0]=1;
    for(int i=n+1;i>=1;--i)
    {
        int flag=1;
        for(int j=k-1;j>=k-sum&&j>=0;j--)
        {
            if(f[j])
            {
                flag=0;
            }
        }
        if(flag)
        {
            cout<<i-1<<endl;
            return 0;
        }
        for(int j=k-1;j>=a[i];j--)f[j]|=f[j-a[i]];
        sum-=a[i];
    }
}


Measured memory_bytes: 256