akhauriyash/Code-Regression huggingface dataset:
import java.io.*
import java.util.*

fun main(args: Array<String>) {
    val inputStream = System.`in`
    val outputStream = System.out
    val inp = Main.InputReader(inputStream)
    val out = PrintWriter(outputStream)
    val solver = Main.TaskC()
    solver.solve(inp, out)
    out.close()
}

class Main {
    internal class TaskC {
        fun solve(inp: InputReader, out: PrintWriter) {
            val n = inp.nextInt()
            val set = hashSetOf<Int>()
            var f = true
            for (i in 1..n) {
                val cur = inp.nextInt()
                if (set.contains(cur))
                    f = false
                else
                    set.add(cur)
            }
            if (f)
                out.println("YES")
            else
                out.println("NO")
        }
    }

    internal class InputReader(stream: InputStream) {
        private var reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)
        private var tokenizer: StringTokenizer? = null

        init {
            tokenizer = null
        }

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

        fun nextInt(): Int {
            return Integer.parseInt(next())
        }

        fun nextLong(): Long {
            return next().toLong()
        }
    }
}


Measured memory_bytes: 74192
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq


def solve(A: int, B: int, C: int, K: int):
    if K % 2 == 0:
        print(A - B)
    else:
        print(B-A)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, C, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (int) (1e9+7)
#define INF (int) 2e9

vector<int> edges[100005];

ll dp[100005][2];

void dfs(int v, int p){
    if(edges[v].size()==1 && edges[v][0]==p){
        dp[v][0] = 1;
        dp[v][1] = 1;
    }else{
        for (auto vi : edges[v]){
            if(vi!=p){
                dfs(vi, v);
            }
        }

        ll v0 = 1, v1=1;
        for (auto vi : edges[v]) {
            if(vi!=p){
                v0 *= (dp[vi][0] + dp[vi][1])%MOD;
                v0 %= MOD;

                v1 *= dp[vi][0];
                v1 %= MOD;
            }
        }
        dp[v][0] = v0;        
        dp[v][1] = v1;
        // printf("%d %d %d\n", v, v0, v1);
    }
}

int main(){
    int n;
    cin >> n;
    rep(i, n-1){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        edges[x].emplace_back(y);
        edges[y].emplace_back(x);
    }

    dfs(0, -1);

    cout << (dp[0][0] + dp[0][1])%MOD << endl;
    // printf("%d\n", N);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

const int MAXN = 200010;

int r, c;
map<int, int> to;

int on(int x, int y)
{
	if (y == 0)
		return 1;
	if (x == r)
		return 2;
	if (y == c)
		return 3;
	if (x == 0)
		return 4;
	return 0;
}

int getdis(int x, int y)
{
	int p = on(x, y);
	int d[5] = {0, 0, r, r+c, r+r+c};
	if (p == 1) return d[1]+x;
	if (p == 2) return d[2]+y;
	if (p == 3) return d[3]+r-x;
	if (p == 4) return d[4]+c-y;
}

bool between(int a, int b, int p)
{
	if (a < b)
		return a < p && p < b;
	else
		return a > p || p > b;
}

int main()
{
	
	int n;
	scanf("%d%d%d", &r, &c, &n);
	int flag = 0;
	set<int> H;
	map<int, int> F;
	for (int i = 1; i <= n; ++ i)
	{
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		if (!(on(x1, y1) && on(x2, y2))) continue;
		int d1 = getdis(x1, y1);
		int d2 = getdis(x2, y2);
		if (d1 > d2) swap(d1, d2);
		H.insert(d1);
		H.insert(d2);
		to[d1] = d2;
		to[d2] = d1;
	}
	
	int sum = 0;
	int last = 0;
	vector<int> st;
	st.push_back(0);
	for (auto x : H)
	{
		if (F[x] == 0)
		{
			F[x] = 1;
			F[to[x]] = -1;
		}
		sum += F[x];
		if (F[x] == 1)
			st.push_back(x);
		else
		{
			if (to[x] != st.back())
			{
				puts("NO");
				return 0;
			}
			st.pop_back();
		}
	}
	puts("YES");
	
	return 0;
}


Measured memory_bytes: 28540
#!/usr/bin/env python3

import sys

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    a, b, c, d = read_list(int)
    while True:
        c -= b
        if c <= 0:
            print("Yes")
            break
        a -= d
        if a <= 0:
            print("No")
            break


if __name__ == "__main__":
    main()


Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a1=0,a2=0,a3=0;
  for(int i=0;i<s.size();i++){
    if(s[i]>='A'&&s[i]<='Z')a1++;
    if(isdigit(s[i]))a2++;
    if(s[i]>='a'&&s[i]<='z')a3++;
  }
  if(s.size()>=6&&a1&&a2&&a3)cout<<"VALID"<<endl;
  else cout<<"INVALID"<<endl;
}

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

using ll = long long;


int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(m);
    int ans1 = 0, ans2 = 0;
    for(int i = 0; i < m; ++i) {
        cin >> a[i];
        (a[i] < x ? ans1 : ans2) += 1;
    }
    cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<cstring>
using namespace std;
struct point{
	int x,y,sum;
}t,f;
int n,m;
int	vis[55][55]; 
int s[55][55];
int d[4][2]={-1,0,1,0,0,-1,0,1};	//上下左右 
int bfs()
{
	queue<point>q;
	t.x=t.y=t.sum=1;
	q.push(t);
	while(!q.empty())		//只要不为空，一直继续
	{
		t=q.front();		//赋值 
		q.pop();			//删除 
		if(vis[t.x][t.y])		//已经走过，不需要再走了 
			continue;
		vis[t.x][t.y]=t.sum;
		if(t.x==n&&t.y==m)
			return t.sum;
		for(int i=0;i<=3;i++)			//四个方向 
		{
			f.x=t.x+d[i][0];
			f.y=t.y+d[i][1];
			if(f.x>=1&&f.x<=n&&f.y>=1&&f.y<=m&&s[f.x][f.y]=='.')
			{			
				f.sum =t.sum+1;				//赋值给f，压入队列 
				q.push(f);
			}
		}
	} 
	 return -1;
}
int main()
{
	int sum,i,j;
	memset(vis,0,sizeof vis);	
	scanf("%d%d",&n,&m);
	getchar();
	sum=0;				
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			scanf("%c",&s[i][j]);
			if(s[i][j]=='.')
				sum++;
		}
		getchar();
	}
	int x=bfs();
	if(x==-1)
		printf("-1\n");
	else
		printf("%d\n",sum-x);
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c ;
    if(a==b && b==c){
        d=1;
    }else if(a==b || b==c ||a==c){
        d=2;
    }else{
        d=3;
    }
    cout << d << endl;
  


}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

vector<bool>D(10, false);
REP(i, K){
  int x;
  cin >> x;
  D.at(x) = true;
}

int ans = N;

while(true){
int now = ans;
    while(now > 0){
      if(D.at(now % 10)) break;
      now /= 10;
    }

if(now == 0) break;
ans++;
}
print(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    string S, T;
    cin >> S >> T;
    S += T[T.size() - 1];
    cout << (S == T ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
//using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
using pii=pair<ll,ll>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__);


int main(){
    dcl(a,b,c,x);
    int ans=0;
    rep(i,a+1)rep(j,b+1)rep(k,c+1){
        if(500*i+100*j+50*k==x)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

void draw_line(void);

int main(void)
{
    int n, b, f, r, v;
    int i, j;
    int room1[3][10], room2[3][10], room3[3][10], room4[3][10];
    
    /*room1~4[][] = number of people*/
    for (i = 0; i < 3; ++i) {
        for (j = 0; j < 10; ++j) {
            room1[i][j] = 0;
            room2[i][j] = 0;
            room3[i][j] = 0;
            room4[i][j] = 0;
        }
    }

    scanf("%d", &n);
    for (i = 0; i < n; ++i) {
        scanf("%d %d %d %d", &b, &f, &r, &v);
        
        switch (b) {
            case 1:
                room1[f - 1][r - 1] += v;
                break;
            case 2:
                room2[f - 1][r - 1] += v;
                break;
            case 3:
                room3[f - 1][r - 1] += v;
                break;
            case 4:
                room4[f - 1][r - 1] += v;
                break;
        }
    }

    for (i = 0; i < 3; ++ i) {
        for (j = 0; j < 10; ++j) {
            if(j != 10 - 1 ) printf(" %d", room1[i][j]);
            else {
                printf(" %d\n", room1[i][j]);
                if (i == 2 && j == 9) draw_line();
            }
        }
    }
    for (i = 0; i < 3; ++ i) {
        for (j = 0; j < 10; ++j) {
            if(j != 10 - 1 ) printf(" %d", room2[i][j]);
            else {
                printf(" %d\n", room2[i][j]);
                if (i == 2 && j == 9) draw_line();
            }
        }
    }
    for (i = 0; i < 3; ++ i) {
        for (j = 0; j < 10; ++j) {
            if(j != 10 - 1 ) printf(" %d", room3[i][j]);
            else {
                printf(" %d\n", room3[i][j]);
                if (i == 2 && j == 9) draw_line();
            }
        }
    }
    for (i = 0; i < 3; ++ i) {
        for (j = 0; j < 10; ++j) {
            if(j != 10 - 1 ) printf(" %d", room4[i][j]);
            else {
                printf(" %d\n", room4[i][j]);
            }
        }
    }

    return 0;
}

void draw_line(void)
{
    for (int i = 0; i < 20; ++i) {
        printf("#");
    }
    printf("\n");
}

    

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  int N; cin >> N;
  vector<vector<pair<int, int>>> edges(N);
  rep(i, N - 1) {
    int a, b, c; cin >> a >> b >> c;
    a--, b--;
    edges[a].emplace_back(b, c);
    edges[b].emplace_back(a, c);
  }
  int Q, K; cin >> Q >> K;
  K--;
  vi64 dist(N, 1e18);
  dist[K] = 0;
  function<void(int)> dfs = [&](int v) {
    each(p, edges[v]) {
      int u, c;
      tie(u, c) = p;
      if (dist[u] != 1e18) continue;
      dist[u] = dist[v] + c;
      dfs(u);
    }
  };
  dfs(K);
  rep(i, Q) {
    int x, y; cin >> x >> y;
    x--, y--;
    cout << dist[x] + dist[y] << '\n';
  }
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin>>s;
    for(register int i=0;i<s.size();i++)
        if(s[i]=='C')
            for(register int j=i+1;j<s.size();j++)
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Integer res = 0;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        int m =sc.nextInt();
        boolean[] visited = new boolean[n];
        List<List<Integer>> g = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            g.add(new ArrayList<>());
        }

        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            g.get(a).add(b);
            g.get(b).add(a);
        }

        visited[0] = true;
        dfs(g, n, visited, 0);
        System.out.println(res);
    }

    private static void dfs(List<List<Integer>> graph, int n, boolean[] visited, int cur) {
        if (allVisited(n, visited)) {
            res++;
            return;
        }

        List<Integer> next = graph.get(cur);
        for (Integer next1 : next) {
            if (visited[next1]) {
                continue;
            }

            visited[next1] = true;
            dfs(graph, n, visited, next1);
            visited[next1] = false;
        }
    }

    private static boolean allVisited(int n, boolean[] visited) {
        for (int i = 0; i < n; i++) {
            if (!visited[i]) return false;
        }

        return true;
    }
}

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

int n;
int p[200010];

int solve() {
    int mi = 1e9;
    int ans = 0;
    rep(i, n) {
        if (mi > p[i]) ++ans;
        mi = min(mi, p[i]);
    }
    return ans;
}

int main() {
    while (cin >> n) {
        rep(i, n) cin >> p[i];
        cout << solve() << endl;
    }
}


Measured memory_bytes: 1024
/*=================================
# Created time: 2017-04-02 21:34
# Filename: b.cpp
# Description: 
=================================*/
#include <bits/stdc++.h> 
 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define lb lower_bound 
#define ub upper_bound 
#define sqr(x) (x)*(x) 
#define lowbit(x) (x)&(-x) 
#define pii pair<int, int> 
#define ls(a,b) (((a)+(b)) << 1) 
#define rs(a,b) (((a)+(b)) >> 1) 
#define fin(a) freopen(a,"r",stdin); 
#define fout(a) freopen(a,"w",stdout); 
#define FORP(i,a,b) for(int i=(a);i<=(b);i++) 
#define FORM(i,a,b) for(int i=(a);i>=(b);i--) 
 
#define maxn 100005 
#define maxm 100005 
#define MOD 1000000007 
#define INF 1070000000 
using namespace std; 
typedef long long ll; 
typedef unsigned long long ull; 
 
template<class T> inline   
void read(T& num){   
    num = 0; bool f = 1;char ch = getchar();   
    while(ch < '0' || ch > '9') { if(ch == '-') f = 0;ch = getchar();}   
    while(ch >= '0' && ch <= '9') {num = num * 10 + ch - '0';ch = getchar();}   
    num = f ? num: -num;   
}  
template<class T> inline 
void write(T x,char ch){ 
	int s[100]; 
	if (x==0) {putchar('0'); putchar(ch); return;} 
	if (x<0) {putchar('-'); x=-x;} int num=0; 
	while (x){ s[num++]=(x%10); x=x/10;} 
	FORM(i,num-1,0) putchar(s[i]+'0'); putchar(ch); 
} 
/*==================split line==================*/ 
const double pi = acos(-1); 
const double eps = 1e-8; 
 
int n,m,a[maxn];  
vector<int> e[maxn];  
int vis[maxn], f[maxn][15];  
struct node{  
    int v,d,c;  
}q[maxn];  
void fun(int u,int d,int c){
    if(f[u][d]!=-1) return;  
    if(!a[u]) a[u] = c;  
    if(d == 0) return;  
    for(int i=0;i<e[u].size();i++){  
        int v=e[u][i];  
        fun(v,d-1,c);  
    }  
    f[u][d]=1;  
}  
int main(){
    while(cin>>n>>m){
        int u,v;  
        FORP(i, 1, n) e[i].clear();  
        memset(a, 0, sizeof(a));  
        memset(f, -1, sizeof(f));  
        for(int i=0;i<m;i++){
            read(u); read(v);  
            e[u].push_back(v);  
            e[v].push_back(u);  
        }  
        int Q; read(Q);  
        for(int i=0;i<Q;i++) {read(q[i].v); read(q[i].d); read(q[i].c);}
        for(int i=Q-1;i>=0;i--) fun(q[i].v,q[i].d,q[i].c);  
        for(int i=1;i<=n;i++) cout<<a[i]<<endl;  
    }  
    return 0;  
}

Measured memory_bytes: 14328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

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

int main(){
    string s;
    cin >> s;
    rep(i, s.size()) if(s[i] == '?') s[i] = 'D';
    cout << s <<'\n';
    return 0;
}

Measured memory_bytes: 3724
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include "bits/stdc++.h"
#ifdef FFS
#include "debug.h"
#else
#define debug(args...)
#endif
#define endl '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int p = 1e9 + 7;
ll bigmod(ll a, ll n)
{
    if(n == 0) return 1;
    if(n % 2) return ((a % p) * bigmod(a, n - 1)) % p;
    ll temp = bigmod(a, n/2) % p;
    return (temp * temp) % p;
}
signed main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    ll n; cin >> n;
    ll ans = (bigmod(10, n) + bigmod(8, n) - 2*bigmod(9, n)) % p;
    cout << (ans + p) % p << endl;
}

Measured memory_bytes: 3608
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		long ans = 1;
		for(int i = 0;i < n; ++i){
			long a = Long.parseLong(scan.next());
			if(Math.log10(a) + Math.log10(ans) > 18 || ans*a > 1000000000000000000L){
				ans = -1;
			}else if(a == 0){
				ans = 0;
			}else if(ans != -1){
				ans *= a;
			}
		}
		System.out.print(ans);
	}
}

Measured memory_bytes: 58556
n = int(input())
s = input()
blacks_in_left = [0 for i in range(n+1)]
whites_in_right = [0 for i in range(n+1)]
for i in range(n):
  blacks_in_left[i+1] = blacks_in_left[i] + int(s[i] == '#')
  whites_in_right[n-1-i] = whites_in_right[n-i] + int(s[n-1-i] == '.')

res = n + 1
for i in range(n+1):
  # replace blacks in [0,i] with whites and whites in [i+1,n] with blacks
  res = min(res, blacks_in_left[i] + whites_in_right[i])
  
#print(blacks_in_left)
#print(whites_in_right)
print(res)

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

int func(int x){
    if(x/10==0) return x;
    return x%10 + func(x/10);
}

int main() {
    int N;
    cin >> N;
    
    int Mi=1e9;
    for(int i=1; i<=N/2; i++){
        int add;
        add = func(i)+func(N-i);
        Mi = min(Mi, add);
    }
    
    cout << Mi << endl;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1, n-1):
    if p[i-1]<p[i]<p[i+1]:
        ans+=1
    elif p[i-1]>p[i]>p[i+1]:
        ans+=1
print(ans)
    

Measured memory_bytes: 2940
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	s := readString()
	var t string
	for _, r := range s {
		switch r {
		case '0':
			t = t + "0"
		case '1':
			t = t + "1"
		case 'B':
			if len(t) > 0 {
				t = t[:len(t)-1]
			}
		}
	}
	println(t)
}


Measured memory_bytes: 640
// #include<bits/stdc++.h>
#include<iostream>
#include<string>
//マップ使う
using namespace std;
int main(){
    string s;
    char a,b;
    int q=0;
    cin >> s;
    const char* x= s.c_str();

    for(int i=0; i<3; i++){
        for(int j=i+1; j<4; j++){
            if(x[i]==x[j]) q++;
        }
    }
    if(q==2) cout<< "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>
using ll = long long;
using namespace std;
vector<int> v;
ll N, X;
ll ans = 0;
ll a[51], p[51];
ll dfs(ll t, ll s)
{
    if (t == 0)
        return 1;

    if (s == 1)
        return 0;
    else if (s > 1 && s <= a[t - 1] + 1)
        return dfs(t - 1, s - 1);
    else if (s == a[t - 1] + 2)
        return p[t - 1] + 1;
    else if (s > a[t - 1] + 2 && s <= 2 + 2 * a[t - 1])
        return p[t - 1] + 1 + dfs(t - 1, s - 2 - a[t - 1]);
    else if (s == 3 + 2 * a[t - 1])
        return 2 * p[t - 1] + 1;
}

int main(void)
{

    cin >> N >> X;
    if (X == 1)
    {
        cout << 0 << endl;
        return 0;
    }

    a[0] = 1;
    p[0] = 1;
    for (int i = 1; i <= N; ++i)
    {
        a[i] = a[i - 1] * 2 + 3;
        p[i] = p[i - 1] * 2 + 1;
    }

    ans = dfs(N, X);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*input
4
141421356 17320508 22360679 244949
*/
 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
#include <tgmath.h>
 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define ar array
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define tests int r; cin >> r; while(r--)
#define MP make_pair
#define PI acos(-1)
typedef pair<long long, long long> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define godspeed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
 
#define M(x) ((x)%(1000000007))
 
vector<int> adj_list[100010];
bool visited[10010];

void dfs(int node){
	visited[node] = true;
	for(int n: adj_list[node]){
		if(!visited[n]){
			dfs(n);
		}
	}
}



int main() {
 	int n;
 	cin>>n;
 	int64 count = 0;
 	int64 s = 0;
 	int64 pre[n];
 	int64 arr[n];
 	rep(i,n){
 		int64 a;
 		cin>>a;
 		count += a;
 		count = M(count);
 		arr[i] = a;
 		pre[i] = count;
 	}
 	int64 ans = 0;
 	int cum = pre[n-1];
 	rep(i,n){
 		int64 gg = M(cum-pre[i]);
 		if(gg<0){
 			gg+=1000000007;
 		}
 		int64 g = arr[i] * gg;
 		g = M(g);
 		ans = ans + g;
 		ans = M(ans);
 	}
 	cout<<ans<<endl;
}



 


Measured memory_bytes: 9060
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<ll,ll>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////

void solve(){
  ini(N);
  int ans = -1 , val = inf;
  rep(i , N){
    ini(x);
    if(amin(val , x)) ans = i + 1;
  }
  out(ans);
}


Measured memory_bytes: 3184
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNextInt()) {
            Integer sum = s.nextInt() + s.nextInt();
            String str = sum.toString();
            System.out.println(str.length());
        }
    }
}

Measured memory_bytes: 20412
//
//  A - キャンディーと2人の子供.cpp
//  Practice
//
//  Created by Hajime Sakamoto on 2020/05/29.
//  Copyright © 2020 Hajime Sakamoto. All rights reserved.
//

#include <stdio.h>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <iterator>

using namespace std;


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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define For(i, a, b) for (int i = (a); i <= (b); ++i)
#define Ford(i, a, b) for(int i = (a); i >=(b); --i)
typedef long long ll;
const ll limit=1e6;

ll a[limit],b[limit];
ll ans=0,res=0,sum=0;
ll n;

int main()
{
    cin >> n;
    cout << n * 2 * 3.14;

}
    

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

int n, x, y, a[2004][2004], b[2004][2004], ans[2004];

int main() {
	cin>>n>>x>>y;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			a[i][j] = abs(i - j);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++){
			b[i][j] = min(a[i][j], min(a[i][x] + a[y][j] + 1, a[i][y] + a[x][j] + 1));
			if(i < j)
				ans[b[i][j]]++;
		}
	for(int i = 1; i < n; i++)	cout<<ans[i]<<'\n';
	return 0;
}

Measured memory_bytes: 31616
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
int n,m;
struct node{
  int l;
  int r;
  int x;
}a[310];
long long f[310][310][310];//当前到i,前一个不同颜色是j,再前一个是k,方案数
bool com(const node &A,const node &B){
  return A.r<B.r;
}
int main(){
  scanf("%d%d",&n,&m);
  for(int i=1;i<=m;i++){
    scanf("%d%d%d",&a[i].l,&a[i].r,&a[i].x);
  }
  sort(a+1,a+m+1,com);
  f[1][0][0]=3;
  int now=1;
  for(int i=1;i<=n;i++){
    while(now<=m&&a[now].r==i){
      for(int j=0;j<i;j++){
	for(int k=0;k<=j;k++){
	  if(a[now].x==1&&a[now].l<=j)f[i][j][k]=0;
	  else if(a[now].x==2&&(a[now].l>j||a[now].l<=k))f[i][j][k]=0;
	  else if(a[now].x==3&&a[now].l>k)f[i][j][k]=0;
	}
      }
      now++;
      //cout<<f[3][0][0]<<endl;
    }
    for(int j=0;j<i;j++){
      for(int k=0;k<=j;k++){
	if(j!=0&&j==k)continue;
	//cout<<i<<" "<<j<<" "<<k<<" "<<f[i][j][k]<<endl;
	f[i+1][j][k]=(f[i+1][j][k]+f[i][j][k])%mod;
	//cout<<f[i+1][k][k]<<endl;
	f[i+1][i][j]=(f[i+1][i][j]+f[i][j][k])%mod;
	f[i+1][i][k]=(f[i+1][i][k]+f[i][j][k])%mod;
      }
    }
  }
  long long ans=0;
  for(int j=0;j<n;j++){
    for(int k=0;k<=j;k++){
      ans=(ans+f[n][j][k])%mod;
    }
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 114668
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String N = scanner.next();
        String judge = "No";

       int N0 = Integer.parseInt(N.substring(0, 1));
       int N1 = Integer.parseInt(N.substring(1, 2));
       int N2 = Integer.parseInt(N.substring(2, 3));
       int N3 = Integer.parseInt(N.substring(3, 4));

       if (N1 == N2 && (N0 == N1 || N2 == N3)) {
           judge = "Yes";
       }
       System.out.println(judge);
    }

}

Measured memory_bytes: 21716
# 参考にした提出:https://atcoder.jp/contests/abc168/submissions/16604668 #
from collections import deque
n,m = map(int,input().split())
l = [[] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    l[a].append(b)
    l[b].append(a)
d = [-1] * (n+1)
d[0],d[1] = 0,0
queue = deque()
queue.append(1)
while queue:
    x = queue.popleft()
    for i in l[x]:
        if d[i] == -1:
            d[i] = x
            queue.append(i)
if -1 in d:
    print('No')
else:
    print('Yes')
    for i in d[2:]:
        print(i)

Measured memory_bytes: 35024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b,t;
    cin >> a >> b >> t;
    ll generate = t/a;
    ll ans = generate * b;
    
    cout << ans << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }

int mat[20][20];

bool isValid(int x,int y,int n,int m){
  if(x>=0&&x<=n-1&&y>=0&&y<=m-1&&mat[x][y]==1) return true;
  else return false;
}

int bfs(pair<int,int> src,int n,int m){

  queue<pair<int,int>> qu;
  qu.push(src);

  int cost[n][m];
  bool vis[n][m];

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      vis[i][j] = false;
      cost[i][j] = 0;
    }
  }

  int maxx = 0;
  vis[src.first][src.second] = true;

  while(!qu.empty()){ 

    pair<int,int> p = qu.front();
    int x = p.first , y = p.second;
    qu.pop();
    maxx = max(maxx,cost[x][y]);
    
    if(isValid(x,y-1,n,m)&&!vis[x][y-1]){
      qu.push({x,y-1});
      cost[x][y-1] = cost[x][y] + 1;
      vis[x][y-1] = true;
    }
    
    if(isValid(x,y+1,n,m)&&!vis[x][y+1]){
      qu.push({x,y+1});
      cost[x][y+1] = cost[x][y] + 1;
      vis[x][y+1] = true;
    }
    
    if(isValid(x-1,y,n,m)&&!vis[x-1][y]){
      qu.push({x-1,y});
      cost[x-1][y] = cost[x][y] + 1;
      vis[x-1][y] = true;
    }
    
    if(isValid(x+1,y,n,m)&&!vis[x+1][y]){      
      qu.push({x+1,y});
      cost[x+1][y] = cost[x][y] + 1;
      vis[x+1][y] = true;
    }
  }

  return maxx;
}


int32_t main(){
    
  fast;
  int n,m; cin >> n >> m;
  
  vector<pair<int,int>> vp;

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      char c; cin >> c;
      if(c=='.'){
        vp.pb({i,j});
        mat[i][j] = 1;
      }else{
        mat[i][j] = 0;
      } 
    }
  }

  int ans = 0;

  for(int i=0;i<vp.size();i++){
    int ct = bfs({vp[i].fi,vp[i].se},n,m);
    ans = max(ans,ct);
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 256
// +build ignore
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	X := sc.nextInt()
	Y := sc.nextInt()
	Z := sc.nextInt()
	fmt.Println(Z, X, Y)
	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


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

using namespace std;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
typedef long long ll;
typedef unsigned long long ull;
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

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

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define possible(n) cout<<((n)?"possible":"impossible")<<endl
#define Possible(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    string a,b,c;
    cin>>a>>b>>c;
    YES(a[sz(a)-1]==b[0]&&b[sz(b)-1]==c[0]);
    return 0;
}

Measured memory_bytes: 256
import sys

N = int(input())
A = list(map(int, sys.stdin.readline().strip().split()))
A = sorted(A)

maxA = A[-1]
halfA = maxA // 2

ans = [False] * maxA
for i in range(N):
    if i != N - 1 and A[i + 1] == A[i]:
        continue
    if i != 0 and A[i - 1] == A[i]:
        continue
    ans[A[i] - 1] = True

for i in A:
    if i > halfA:
        break
    j = i + i
    while j <= maxA:
        ans[j - 1] = False
        j += i

print(sum(ans))



Measured memory_bytes: 98316
n = int(input())
ListL = [int(i) for i in input().split()]

ListL.sort()
ans = 0

for i in reversed(range(2, n)):
	a = ListL[i]
	b = ListL[i-1]
	c = a - b + 1
	indexb = i - 1
	indexc = 0
	while(indexb > indexc):
		if (ListL[indexb] + ListL[indexc] > a):
			ans += indexb - indexc
			indexb -= 1
		else:
			indexc += 1

print(ans)

Measured memory_bytes: 3188
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = ll(1e9)+7;
const ll inf = ll(5e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

class debug
{
public:
    typedef long long ll;
    template<typename T> void vd(vector<T> vec);
    template<typename T> void vd2(vector<vector<T>> vec);
    template<typename T> void ad(T *arr, ll n);
    template<typename T, size_t N> void ad2(T (&arr)[N], ll n);
    template<typename T> void md(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vd(vector<T> vec)
{
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T> void debug::vd2(vector<vector<T>> vec)
{
    for(auto vv : vec) for(auto vvv : vv) cout << vvv << " ";
    cout << endl;
}

template<typename T> void debug::ad(T *arr, ll n)
{
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T, size_t N> void debug::ad2(T (&arr)[N], ll n)
{
    for(int i=0; i<=N; i++) for(int j=0; j<=n; j++) cout << arr[i][j] << " ";
    cout << endl;
}

template<typename T> void debug::md(T mp)
{
    cout << "key : value" << endl;
    for(auto const& m : mp) cout << m.first << " : " << m.second << endl;
    cout << endl;
}
debug debug;

class ABeginner {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n, r;
	    in >> n >> r;
        if(n >= 10) out << r << endl;
        else out << r+(10-n)*100 << endl;
	}
};


int main() {
	ABeginner solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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


Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for( i = 0;i < n;i++ )
using namespace std;
  
long long n,k;
long long rui[100000];
long long ans = 0;
  
int main(){
int i;
cin >> n >> k;
rep(i,n-1){
cin >> rui[i+1];
rui[i+1] += rui[i];
}
  
int bef=0,now;
rep(i,k){
cin >> now;
now += bef;
ans += rui[ max(now,bef) ] - rui[ min(now,bef) ];
bef = now;
}
cout << ans%100000 << endl;
return 0;
}

Measured memory_bytes: 1948
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    scanf("%d",&N);
    char S[N+1],T[N+1],U[N+N+1];
    scanf("%s%s",S,T);
    int l=0,m=0,n=0;
    while(S[l]!='\0'){
       U[n]=S[l];
       n++;
       U[n]=T[m];
       l++; m++; n++;
    }
    U[n]='\0';
    printf("%s\n",U);
    return 0;
}

Measured memory_bytes: 128
from functools import reduce

def extended_euclid(a, b):
    x1, y1, m = 1, 0, a
    x2, y2, n = 0, 1, b
    while m % n != 0:
        q, r = divmod(m, n)
        x1, y1, m, x2, y2, n = x2, y2, n, x1 - q * x2, y1 - q * y2, r
    return x2, y2, n

def modular_inverse(a, mod):
    x, _, g = extended_euclid(a, mod)
    if g != 1:
        return None # Modular inverse of a does not exist
    else:
        return x % mod

MOD = 10**9 + 7
N, K = map(int, input().split())
*A, = map(int, input().split())
A = sorted(A, key=abs, reverse=True)
cand = []
minus = False
last_plus, last_minus = None, None
for a in A[:K]:
    cand.append(a)
    if a < 0: minus = not minus; last_minus = a
    elif a > 0: last_plus = a
    else: minus = False
ans = reduce(lambda x, y: x * y % MOD, cand)
if minus and K != N:
    non_neg, neg = None, None
    for a in A[K:]:
        if a >= 0 and non_neg is None: non_neg = a
        elif a < 0 and neg is None: neg = a
        if non_neg is not None and neg is not None: break
    if non_neg is None:
        if last_plus:
            ans *= modular_inverse(last_plus, MOD) * neg; ans %= MOD
        else:
            ans = reduce(lambda x, y: x * y % MOD, A[::-1][:K])
    elif neg is None:
        ans *= modular_inverse(last_minus, MOD) * non_neg; ans %= MOD
    else:
        if last_plus and abs(last_plus * non_neg) < abs(last_minus * neg):
            ans *= modular_inverse(last_plus, MOD) * neg; ans %= MOD
        else:
            ans *= modular_inverse(last_minus, MOD) * non_neg; ans %= MOD
print(ans)

Measured memory_bytes: 32320
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<deque>
#include<string>
#include<stack>
#define P pair<int,int>
using namespace  std;

int s;
vector<P>V;
bool used[50];
void DFS(int a) {
	for (int i = 0; i < V.size(); i++) {
		if (V[i].first == a&&i != s && !used[V[i].second]) {
			used[V[i].second] = true;
			DFS(V[i].second);
		}
		if (V[i].second == a&&i != s && !used[V[i].first]) {
			used[V[i].first] = true;
			DFS(V[i].first);
		}
	}
}
signed main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b; a--; b--;
		V.push_back({ a,b });
	}
	int ans = 0;
	for (; s < m;s++) {
		memset(used, false, sizeof(used));
		used[0] = true;
		bool OK = true;
		DFS(0);
		for (int i = 0; i < n; i++) {
			if (!used[i]) {
				OK = false;
			}
		}
		if (!OK)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256