akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class abc162_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long N = in.nextLong();
            long fizzsum = 0;
            long buzzsum = 0;
            long fizzbuszsum = 0;
            long sum = 0;

            for (long i = 0; i <= N; i++) {
                if ((i % 3 == 0) && (i % 5 == 0)) {
                    fizzbuszsum += i;
                } else if (i % 3 == 0) {
                    fizzsum += i;
                } else if (i % 5 == 0) {
                    buzzsum += i;
                } else {
                    sum += i;
                }
            }

        /*
        for (long i = 3; i <= N; i+=3) {
            if(i%15!=0) {
                fizzsum += i;
            }
        }
        for (long i = 5; i <= N; i+=5) {
            if(i%15!=0) {
                buzzsum += i;
            }
        }
        for (long i = 15; i <= N; i+=15) {
            fizzbuszsum+=i;
        }

         */
            out.println(sum);
        }

    }
}



Measured memory_bytes: 35892
import sys
sys.setrecursionlimit(300000)
from collections import defaultdict

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N = I()
S = input()

d = defaultdict(int)
for c in S:
    d[c] += 1
plus = d['R'] * d['G'] * d['B']

minus = 0
for j in range(1, N - 1):
    for l in range(1, N):
        i, k = j - l, j + l
        if i < 0 or k > N - 1:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            minus += 1

print(plus - minus)


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


const int INF = 1001001001;

int main() {

    // N<=2000なのでO(n^2)ぐらいはOK
    // BFSを使って最短経路
    int n, x, y;
    cin >> n >> x >> y;
    --x; --y; // １からだと扱いにくいので0からにする

    // グラフを陽に持たない
    vector<int> ans(n);
    rep(sv, n){
        vector<int> dist(n, INF);
        queue<int> q;

        // [&]でキャプチャは参照とする（デフォルトで環境にある変数を参照して、ラムダ式のなかで使用する）
        auto push = [&](int v, int d){
            if(dist[v] != INF) return; //探索済み
            dist[v] = d;
            q.push(v);
        };
        push(sv, 0);
        while(!q.empty()) {
            int v = q.front(); q.pop(); // front : queue の最初の要素への参照。 pop : 最初の要素を除去して詰める
            int d = dist[v];
            if(v-1 >= 0) push(v-1, d+1);
            if(v+1 < n) push(v+1, d+1);
            if(v == x) push(y, d+1);
            if(v == y) push(x, d+1);
        }
        rep(i,n) ans[dist[i]]++;
    }
    rep(i,n) ans[i] /= 2;

    for (int i = 1; i <= n-1; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
int main()
{
    ios;
    ll k ,a , b ;
    cin >> k >> a >> b ;
    if(k ==1){
        cout << 2 <<endl;
        return 0;
    }
    if(a >=b){
        cout << k+1 <<endl;
        return 0;
    }
    if(k<=a){
        cout << k+1 <<endl;
        return 0;
    }
    if(b-a == 1){
        cout << k+1 <<endl;
        return 0;
    }

    ll ans  = 0 ;
    ll jump = a - 1;
    ans = 1 + jump;
    k = k - jump;
    ///cout << k <<endl;
    ll tobeadded = 0;
    if(k&1){ /// k odd
        k = k-1;
        tobeadded = 1;
    }
    ans = ans - (k/2 * a) + (k/2 * b) + tobeadded;
    cout << ans <<endl;
    return 0;

}








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

vector<int> p;

int main() {
	int n, res = 0;
	cin >> n;
	p = vector<int> (n);
	for(int &i : p) cin >> i;
	for(int i = 1; i < n - 1; i++){
		if(p[i - 1] < p[i] && p[i] < p[i + 1]) res++;
		if(p[i - 1] > p[i] && p[i] > p[i + 1]) res++;
	}
	cout << res << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <assert.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
using namespace std;

// #define __DEBUG__

#ifdef __DEBUG__
bool debug_disabled = false;
#else
bool debug_disabled = true;
#endif

#define dbg if (debug_disabled) {} else cerr

int heights[100010];
set<int> nbrs[100010];

void solve() {
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < N; ++i) {
        cin >> heights[i];
    }
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        nbrs[a - 1].insert(b - 1);
        nbrs[b - 1].insert(a - 1);
    }
    int res = 0;
    for (int i = 0; i < N; ++i) {
        dbg << "here " << i << endl;
        bool good = true;
        set<int>& nbr = nbrs[i];
        for (int c : nbr) {
            if (heights[c] >= heights[i]) good = false;
        }
        if (good) ++res;
    }
    cout << res << endl;
}

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int T = 1;
    // cin >> T;
    for (int i = 1; i <= T; ++i) {
        solve();
    }

    return 0;
}


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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		
		var l = p[0] + p[1];
		var r = p[2] + p[3];
		if(l == r)
		{
			Console.WriteLine("Balanced");
		}
		else if( l < r)
		{
			Console.WriteLine("Right");
		}
		else
		{
			Console.WriteLine("Left");
		}
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 11092
import sys,math,collections,itertools
input = sys.stdin.readline

N,K=list(map(int,input().split()))
m=10**9+7

def arrange(red,blue,m):
    if red+1<blue:
        return 0
    a = (math.factorial(red+1))%m
    b = pow(math.factorial(blue),m-2,m)
    c = pow(math.factorial(red+1-blue),m-2,m)

    return (a*b*c)%m

def bluegroup(blue,group,m):
    a = (math.factorial(blue-1))%m
    b = pow(math.factorial(group-1),m-2,m)
    c = pow(math.factorial(blue-group),m-2,m)

    return (a*b*c)%m

for i in range(1,K+1):
    print((arrange(N-K,i,m)*bluegroup(K,i,m))%m)


Measured memory_bytes: 9500
#include<iostream>
using namespace std;
int main(){
    int n;
    long long a;
    long long max = -1000000;
    long long min = 1000000;
    long long sum = 0;
    cin >> n;
    for (int i = 0;i < n;i++){
        cin >> a;
        if (max < a) max = a;
        if (min > a) min = a;
        sum += a;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>

int main(void) {
	int n, narabi1[1227], narabi2[1227], count = 0;

	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &narabi1[i]);
	}

	for (int j = 1; j <= n; j++) {
		narabi2[j-1] = j;
	}

	for (int k = 0; k < n; k++) {
		if (narabi1[k] != narabi2[k]) {
			count++;
		}
	}

	if (count == 0 || count == 2) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
using namespace std;
int main()
{
	string a,b,c;
	int x,y;
	cin>>a>>b>>x>>y>>c;
	if(c==a)x--;
	else y--;
	cout<<x<<' '<<y<<endl;
	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> grid(H);
  for (int i=0; i < H; i++) {
    cin >> grid.at(i);
  }
  vector<int> allow;
  for (int i=0; i < H; i++) {
    int dotc = 0;
    for (int j=0; j < W; j++) {
      if (grid.at(i).at(j) == '.') {
        dotc++;
      }
    }
    if (dotc != W) {
      allow.push_back(i);
    }
  }
  vector<string> grid2(allow.size());
  for (int i=0; i < allow.size(); i++) {
    grid2.at(i) = grid.at(allow.at(i));
  }
  vector<int> allow2;
  for (int i=0; i < W; i++) {
    int dotc = 0;
    for (int j=0; j < grid2.size(); j++) {
      if (grid2.at(j).at(i) == '.') {
        dotc++;
      }
    }
    if (dotc != grid2.size()) {
      allow2.push_back(i);
    }
  }
  vector<vector<char>> grid3(grid2.size(),vector<char>(allow2.size()));
  for (int i=0; i < grid2.size(); i++) {
    for (int j=0; j < allow2.size(); j++) {
      grid3.at(i).at(j) = grid2.at(i).at(allow2.at(j));
    }
  }
  for (int i=0; i < grid2.size(); i++) {
    for (int j=0; j < allow2.size(); j++) {
    cout << grid3.at(i).at(j);
      if (j == allow2.size() - 1) {
        cout << endl;
      }
    }
  }
}

Measured memory_bytes: 256
n, m = gets.chomp.split.map(&:to_i)
a = Array.new(n)
m.times do
  a[gets.chomp.to_i] = 0
end
a[0] = 1
a[1] ||= 1
 
(2..n).each do |i|
  a[i] ||= (a[i-2] + a[i-1]) % (10**9 + 7)
end
puts a[n]

Measured memory_bytes: 2812
use io::*;

fn main() {
    let con =read_string();
    let mut sc =Scanner::new(&con);

    let mut n:i64 = sc.next();
    if n%2!=0{
        n*=2;
    }
    println!("{}",n);
}

pub mod io {
    use std;
    use std::str::FromStr;
 
    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }
 
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }
 
        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }
 
        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }
 
        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }
 
    pub fn read_string() -> String {
        use std::io::Read;
 
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
 
    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}

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

# input
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

# solve
ans = [0] * N
for i in range(M):
    ans[ab[i][0] - 1] += 1
    ans[ab[i][1] - 1] += 1

# output
for i in range(N):
    print(ans[i])


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  int A,B,T; cin >> A >> B >> T;
  cout << T/A*B << endl;
  return 0;
}


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

#define gc getchar()
inline int read(){
	int x=0;int f=0;char c=gc;
	for(;c<48||c>57;c=gc)
		if(c=='-')f=1;
	for(;c>47&&c<58;c=gc)
		x=x*10+c-48;
	return f?-x:x;
}
#define io read() 

char s[200005];

inline void init(){
	gets(s);
	ll ans=0,b=0,w=0;
	for(int i=0;s[i];++i){
		if(s[i]=='B')++b;
		else ans+=b;
	}
	cout<<ans<<'\n';
}

inline void solve(){
	
}

int main(){
	init();
	solve();
	return 0;
} 

Measured memory_bytes: 384
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    string s;
    string t;
    scan(s, t);
    // writeln(s, t);
    foreach (i; 0 .. n)
    {
        write(s[i], t[i]);
    }
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3544
//#pragma GCC target ("avx2")
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;
using namespace __gnu_pbds;

template <class T> using ordered_set =
tree<T, null_type, less<T>,
rb_tree_tag, tree_order_statistics_node_update>;

const int N = (int)(1e6 + 5);
const int M = (int)(1e9 + 7);
const int INF = (int)(1e18 + 9);
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};

signed main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  for (int i = 0; i < (int)s.size(); ++i) {
    if (i % 2 == 0) {
      if (!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) {
        cout << "No";
        return 0;
      }
    }
    else {
      if (!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) {
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] A = sc.next().toCharArray();
		char[] B = sc.next().toCharArray();
		
		if ( A[0] == B[2] && A[1] == B[1] && A[2] == B[0] ) 
			System.out.println("YES");
		else System.out.println("NO");
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int ctoi(char);

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> list;

    rep(i, H)
    {
        string w;
        cin >> w;
        list.push_back(w);
    }

    string header = string(W + 2, '#');
    vector<string> ans;
    ans.push_back(header);
    rep(i, H)
    {
        string w = '#' + list.at(i) + "#";
        ans.push_back(w);
    }
    string footer = string(W + 2, '#');
    ans.push_back(footer);

    rep(i, H+2)
    {
        cout << ans.at(i) << endl;
    }
}


int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c -'0';
    }
    return -1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;


int main()
{
    ll m;
    cin >> m;

    ll tmpmut = 0;
    ll ans = 0;
    rep(i, m){
        ll tmpc, tmpd;
        cin >> tmpd >> tmpc;
        tmpmut += tmpd * tmpc;
        ans += tmpc;
    }
    ans -= 1;

    ll amari = 0;
    while (tmpmut >= 10){
        amari = (tmpmut % 10);
        tmpmut /= 10;
        ans += tmpmut;
        tmpmut += amari;
    }

    printf("%lld\n",ans);

}



Measured memory_bytes: 256
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv,
    std.typecons, std.math, std.container, std.format, std.numeric;

void main(string[] args)
{
    long n, m, k;
    readf("%d %d %d\n", &n, &m, &k);
    auto as = readln.strip.split(" ").to!(long[]);
    auto bs = readln.strip.split(" ").to!(long[]);

    long ai = 0, bi = 0;
    // aを読めるところまで読む
    long sumt = 0;
    while (ai < n)
    {
        if (sumt + as[ai] > k)
        {
            break;
        }
        sumt += as[ai];
        ai++;
    }

    // aを読むのをやめながらbをよめるところまで読む
    long ans = ai;
    while (true)
    {
        while (bi < m)
        {
            if (sumt + bs[bi] > k)
            {
                break;
            }
            sumt += bs[bi];
            bi++;
        }
        ans = max(ans, ai + bi);
        if (ai == 0)
        {
            break;
        }
        sumt -= as[--ai];
    }
    writeln(ans);

}


Measured memory_bytes: 16756
import java.util.Scanner;

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

		int k = scan.nextInt();
		String s = scan.next();

		if(k >= s.length()) {
			System.out.println(s);
		}else {
			System.out.println(s.substring(0 , k) + "...");
		}
	}
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] dp = new int[N];
		dp[1] = 1;
		int now = 0;
		for(int i=0;i<Q;i++){
			if(A[i] == now){
				now = B[i];
			}else if(B[i] == now){
				now = A[i];
			}
			var t = dp[A[i]];dp[A[i]]=dp[B[i]];dp[B[i]] = t;
			if(now>0) dp[now-1] = 1;
			if(now<N-1) dp[now+1] = 1;
		}
		
		dp[now] = 1;
		Console.WriteLine(dp.Sum());
		
		
		
	}
	
	
	
	int N,Q;
	int[] A,B;
	public Sol(){
		var d =ria();
		N = d[0];
		Q = d[1];
		A = new int[Q];
		B = new int[Q];
		for(int i=0;i<Q;i++){
			d = ria();
			A[i] = d[0] -1;
			B[i] = d[1] -1;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 7976
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>

using namespace std;

#define A 0
#define C 1
#define G 2
#define T 3
#define N_MAX 110
#define MOD 1000000007

int N;
long long int memo[101][4][4][4];

long long int func(int index, int p, int q, int r)
{
	if (A == p && G == q && C == r){
		return 0;
	}
	else if (A == p && C == q && G == r){
		return 0;
	}
	else if (G == p && A == q && C == r){
		return 0;
	}

	if (N == index + 3){
		return 1;
	}

	if (-1 != memo[index][p][q][r]){
		return memo[index][p][q][r];
	}

	long long int ret = 0;
	if (A == p && G == q){
		ret = (ret + func(index + 1, q, r, A)) % MOD;
		ret = (ret + func(index + 1, q, r, G)) % MOD;
		ret = (ret + func(index + 1, q, r, T)) % MOD;
	}
	else if (A == p && G == r){
		ret = (ret + func(index + 1, q, r, A)) % MOD;
		ret = (ret + func(index + 1, q, r, G)) % MOD;
		ret = (ret + func(index + 1, q, r, T)) % MOD;
	}
	else{
		ret = (ret + func(index + 1, q, r, A)) % MOD;
		ret = (ret + func(index + 1, q, r, C)) % MOD;
		ret = (ret + func(index + 1, q, r, G)) % MOD;
		ret = (ret + func(index + 1, q, r, T)) % MOD;
	}

	return memo[index][p][q][r] = ret;
}

void solv()
{
	scanf("%d", &N);

	for (int i = 0; i <= N; i++){
		for (int j = 0; j < 4; j++){
			for (int k = 0; k < 4; k++){
				fill(memo[i][j][k], memo[i][j][k] + 4, -1);
			}
		}
	}

	long long int ret = 0;
	for (int i = A; i <= T; i++){
		for (int j = A; j <= T; j++){
			for (int k = A; k <= T; k++){
				ret = (ret + func(0, i, j, k)) % MOD;
			}
		}
	}

	printf("%lld", ret);
	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //d
  int n;
  cin >> n;
  long long cnt[10][10] = {};
  for (int i = 1; i <= n; i++) {
    long long x = i;
    int fi = 0, la = 0;
    for (int j = 0; x > 0; j++, x /= 10) {
      if (j == 0) fi = x % 10;
      if (x < 10) la = x;
    }
    cnt[fi][la]++;
  }
  long long ans = 0;
  for (int i = 1; i < 10; i++) for (int j = 1; j < 10; j++) {
    ans += cnt[i][j] * cnt[j][i];
  }
  cout << ans << '\n';
  return 0;
}

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int n;
string s;

int isPos(int u, int sv) {
  int l = sv, h = sv, il = 0, ih = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0')
      l--, h--;
    else if (s[i] == '1')
      l++, h++;
    else
      l--, h++;
    if (l < 0)
      l += 2, il++;
    if (h > u)
      h -= 2, ih++;
    if (l > h)
      return il >= ih ? 1 : 2;
  }
  return 0;
}

bool isPos(int u) {
  int l = -1, r = u;
  while (l + 1 < r) {
    int m = (l + r) / 2;
    int a = isPos(u, m);
    if (a == 0)
      return true;
    if (a == 1)
      l = m;
    else
      r = m;
  }
  return isPos(u, r) == 0;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> s;
  n = sz(s);
  int l = -1, r = n;
  while (l + 1 < r) {
    int m = (l + r) / 2;
    if (isPos(m))
      r = m;
    else
      l = m;
  }
  cout << r << "\n";
}


Measured memory_bytes: 4220
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<vector>
using namespace std;
long long  mod = 1000000007;
vector<char> s;
int main()
{
	int N, K;
	char S[100010];
	cin >> N >> K >> S;
	int i = 0;
	int max = 0;
	int count = 0;
	if (S[i] == '0') {
		count++;
	}
	int flag = 0;
	while (S[i] != '\0') {
		s.push_back(S[i]);
		if (S[i] == '1' && S[i + 1] == '0') {
			count++;
		}
		if (count == K + 1) {
			if (s.size() > max) {
				max = s.size();
			}
			count--;
			flag = 0;
			while (true) {
				if (s.front() == '0') {
					flag = 1;
				}
				if (s.front() == '1' && flag == 1) {
					break;
				}
				s.erase(s.begin());
			}
		}
		i++;
	}
	if (s.size() > max) {
		max = s.size();
	}
	cout << max;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    char s[200005],t[200005];
    for(int i=0;i<200005;i++){
        s[i]='A';
    }
    scanf(" %s %s",s,t);
    int e=0;
    for(int i=0;i<200005;i++){
        if(e==0&&s[i]=='A')e=i;
    }
    int x=1;
    e--;
    char a;
    char f;
    int y;
    int r[26];
    for(int i=0;i<26;i++)r[i]=0;
    for(int i=0;i<26;i++){
        a='a'+i;
        y=0;
        for(int j=0;j<e;j++){
            if(s[j]==a){
                f=t[j];
                y=1;
            }
        }
        if(y){
            r[f-'a']++;
            for(int j=0;j<e;j++){
                if(s[j]==a&&t[j]!=f)x=0;
            }
        }
    }
    for(int i=0;i<26;i++){
        if(r[i]>1)x=0;
    }
    if(x)printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef multiset<int> MS;
typedef queue<int> Q;

int main(){
    ll x; cin>>x;
    ll ans = x/11 * 2;
    x %= 11;
    for(ll i=0; x>0; i++){
        if(i%2 == 0)
            x -= 6;
        else
            x -= 5;
        ans++;
    }
    OUT(ans);
}

Measured memory_bytes: 256
N = int(input())
alpha = list('zabcdefghijklmnopqrstuvwxy')
ans = ''


def dfs(n):
    global ans
    if n <= 26:
        ans += alpha[n%26]
        return ans[::-1]
    else:
        ans += alpha[n % 26]
        if n % 26 == 0:
            nn = n // 26 - 1
        else:
            nn = n // 26
        return dfs(nn)

print(dfs(N))

Measured memory_bytes: 9208
n = int(input())
b = list(map(int, input().split()))
a = [-1]*n
for i in range(n):
    if i == 0:
        a[i] = b[i]
    elif i < n-1:
        a[i] = min(b[i],b[i-1])
    else:
        a[i] = b[i-1]

print(sum(a))

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

long pow10(int n){
    long ans = 1;
    for(int i = 0; i < n; i++){
        ans *= 10;
    }
    return ans;
}

int main(){
    long cur = 1;
    int nd;
    char in;
    bool isPow10 = false;
    for(int i = 0; i <= 10; i++){
        cout << "? " << cur << endl;
        cin >> in;
        if(in == 'N'){
            nd = i;
            break;
        }
        cur *= 10;
        if(i == 10) isPow10 = true;
    }
    if(isPow10){
        for(int i = 0; i <= 10; i++){
            cout << "? " << pow10(i+1)-1 << endl;
            cin >> in;
            if(in == 'Y'){
                cout << "! " << pow10(i) << endl;
                return 0;
            }
        }
    }else{
        long l = pow10(nd-1);
        long r = pow10(nd)-1;
        long c;
        while(r-l > 1){
            c = (l+r)/2;
            cout << "? " << c*10 << endl;
            cin >> in;
            if(in == 'N') l = c;
            else r = c;
        }
        cout << "! " << r << endl;
    }
}

Measured memory_bytes: 720
#include <iostream>
#include <vector>

using namespace std;

long long int MOD = 1000000007;

int main(){
  int M, D;
  cin >> M >> D;
  if(abs(M - D) > 1){
    cout << 0;
//    return 1;
  }else if(abs(M - D) == 0){
    long long int ans = 1LL;
    for(int i = M; i >=1; i--){
      ans *= i;
      ans %= MOD;
    }
    
    for(int i = D; i >=1; i--){
      ans *= i;
      ans %= MOD;
    }
    ans *=2;
    ans %= MOD;
    cout << ans;
  }else if(abs(M - D) == 1){
    long long int ans = 1LL;
    for(int i = M; i >=1; i--){
      ans *= i;
      ans %= MOD;
    }
    
    for(int i = D; i >=1; i--){
      ans *= i;
      ans %= MOD;
    }
    cout << ans;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
void TaskSchedulingProblem() {
	int A1, A2, A3;
	vector<int> v(3,0);
	cin >> v[0] >> v[1] >> v[2];
	sort(v.begin(), v.end());
	cout << ((v[1] - v[0]) + (v[2] - v[1])) << "\n";

}
int main() {
	TaskSchedulingProblem();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> p;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;
int dp[105][4][2]; // i桁数, jが0でない個数 ,kが0で完全に一致

int main(){
  string s;
  cin >> s;
  int n, K;
  cin >> K;
  n = s.size();
  dp[0][0][0] = 1;
  rep(i, n)rep(j, 4)rep(k, 2) {
    int nd = s[i] - '0';
    rep(d, 10) {
      int ni = i + 1, nj = j, nk = k;
      if(d != 0) ++nj;
      if(nj > K) continue;
      if(k == 0) {
        if(d > nd) break;
        if(d < nd) nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }
  int ans = dp[n][K][0] + dp[n][K][1];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int A, B, C;
	cin >> A >> B >> C;

	if( C < A && C < B ) {
		cout << "No" << endl;
	}
	else if( C > A && C > B ) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> Type igcd(Type x,Type y){if(y==0)return x;return igcd(y,x%y);}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n,a,b;
	string s;
	cin>>n>>a>>b>>s;
	
	int sum=0;	//参加確定者人数
	int o=0;	//海外人数
	bool ans[n]={};
	REP(i,n){
		if(s[i]=='a'){
			if(sum<a+b){
				ans[i]=true;
				sum++;
			}
		}else if(s[i]=='b'){
			o++;
			if(sum<a+b and o<=b){
				ans[i]=true;
				sum++;
			}
		}
	}
	
	REP(i,n) cout<<((ans[i])?"Yes":"No")<<endl;
}

Measured memory_bytes: 896
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    public static IO IO = new IO();
    static void Main(string[] args)
    {
        int[] n = IO.INT(' ');
        int a = Math.Max(n[0], n[1]);
        int b = Math.Min(n[0], n[1]);
        while (b != 0)
        {
            a %= b;
            if (b > a) { int buf = a; a = b; b = buf; }
        }
        IO.WRITE(a);
        IO.FLUSH();
    }
}

namespace LIB
{
    public class IO
    {
        private const int WMAX = 1000;
        private StringBuilder S = new StringBuilder();
        private T R<T>(Func<string, T> f) { return f(Console.ReadLine()); }
        private T[] R<T>(Func<string, T> f, char c) { return STRING().Split(c).Select(f).ToArray(); }
        private T[] R<T>(Func<string, T> f, int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = R(f); } return r; }
        private T[][] R<T>(Func<string, T> f, int l, char c) { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = R<T>(f, c); } return r; }
        private void W<T>(Func<T, string> f, T v, bool lf = true) { S.Append(f(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { FLUSH(); } }
        public string STRING() { return R(s => s); }
        public string[] STRING(char c) { return R(s => s, c); }
        public string[] STRING(int l) { return R(s => s, l); }
        public string[][] STRING(int l, char c) { return R(s => s, l, c); }
        public int INT() { return R(int.Parse); }
        public int[] INT(char c) { return R(int.Parse, c); }
        public int[] INT(int l) { return R(int.Parse, l); }
        public int[][] INT(int l, char c) { return R(int.Parse, l, c); }
        public long LONG() { return R(long.Parse); }
        public long[] LONG(char c) { return R(long.Parse, c); }
        public long[] LONG(int l) { return R(long.Parse, l); }
        public long[][] LONG(int l, char c) { return R(long.Parse, l, c); }
        public double DOUBLE() { return R(double.Parse); }
        public double[] DOUBLE(char c) { return R(double.Parse, c); }
        public double[] DOUBLE(int l) { return R(double.Parse, l); }
        public double[][] DOUBLE(int l, char c) { return R(double.Parse, l, c); }
        public void WRITE(string s, bool lf = true) { W(v => v, s, lf); }
        public void WRITE(int s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(long s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(double s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void FLUSH() { Console.Write(S); S.Length = 0; }
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	string s;
	cin>> s;

	rep(i, (int)s.size()){
		if(s[i]=='?') s[i]='D';
	}

	cout<< s <<endl;
 
	return 0;
}

Measured memory_bytes: 3760
k =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(k[K-1])

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <string.h>
#include <stdio.h>
#include <queue>
#include <limits.h>
#include <stack>
#include <set>
#include <map>

#define P pair
#define MP make_pair

typedef long long int llint ;

using namespace std;

int n,a,b;

bool moze(int x)
{
	int sum=0;
	while(x>0)
	{
		sum+=x%10;
		x/=10;
	}
	return (sum>=a && sum<=b);
}

int main()
{
	cin>>n>>a>>b;
	llint sol=0;
	for(int i=1;i<=n;i++)
	{
		if(moze(i))
		sol+=i;
	}
	cout<<sol;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>

using namespace std;

long long cnt = 0;
int A[1000000];
vector<int> G;


void shellSort(int A[], int n) {
    int h = 1;
    G.push_back(1);
    while(h < n) {
        G.push_back(h);
        h = h * 3 + 1;
    }
    //int h = 1;
    //while(h < n/3) h = 3*h + 1;



    for(int m = G.size()-1; m >= 0; m--) {
        int h = G[m];
        for(int i = h; i < n; i++) {
            for(int j = i; j >=h && A[j] < A[j-h]; j = j-h) {
                int temp = A[j];
                A[j] = A[j-h];
                A[j-h] = temp;
                cnt++;
            }
        }
    }

}

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    cnt = 0;
    shellSort(A, n);

    cout << G.size() << endl;

    for(int i = G.size()-1; i >=0; i--) {
        printf("%d", G[i]);
        if(i) printf(" ");
    }
    printf("\n");

    printf("%d\n", cnt);

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

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

#define int long long

main(){
	int a,b,c;
	cin>>a>>b>>c;
	int cnt=0;
	int f=0;
	map<pair<pair<int,int> ,int> ,int>mp;

	while(!(a%2) && !(b%2) && !(c%2)){
	//	cout<<cnt<<endl;
	//	cout<<a<<" "<<b<<" "<<c<<endl;
		if(mp.count(make_pair(make_pair(a,b),c))){f=1;break;}
		mp[make_pair(make_pair(a,b),c)]=1;
		int aa=a,bb=b,cc=c;
		a=(bb/2)+(cc/2);
		b=(aa/2)+(cc/2);
		c=(aa/2)+(bb/2);
		cnt++;
	}

	if(f)cout<<"-1"<<endl;
	else cout<<cnt<<endl;
	return(0);

}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
using namespace std;

typedef long long ll;

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

int n;
int x[102][102],y[102][102];
int used[102][102];

bool draw(int xx,int yy,int id){
  while(1){
    used[yy][xx] = id;
    int nx = x[yy][xx];
    int ny = y[yy][xx];

    if(used[ny][nx] != -1){
      return used[ny][nx] == id;
    }

    xx = nx;
    yy = ny;
  }

  return false;
}

int main(){
  while(scanf("%d",&n),n){
    rep(i,n){
      rep(j,n){
        scanf("%d%d",&x[i][j],&y[i][j]);
      }
    }

    int id = 0, ans = 0;
    memset(used,-1,sizeof(used));

    rep(i,n){
      rep(j,n){
        if(used[i][j] != -1) continue;
        ans += draw(j,i,id);
        id++;
      }
    }

    printf("%d\n",ans);
  }
}

Measured memory_bytes: 0
s = input()
s_1 = int(s[:2])
s_2 = int(s[2:])
if 0<s_1<=12 and (s_2>12 or s_2==0):
    print("MMYY")
elif (s_1>12 or s_1==0) and 0<s_2<=12:
    print("YYMM")
elif s_1<=12 and s_2<=12 and (s_1!=s_2 or min(s_1,s_2)>0):
    print("AMBIGUOUS")
else:
    print("NA")

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

#define ll long long
#define pb push_back
#define mp make_pair


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
  ll  int a[n],s=0;
   map<ll int,ll int>m;
    for(int i=0;i<n;i++)
    {
		cin>>a[i];
		m[a[i]]++;
		s+=a[i];
	}
    int tt;
    cin>>tt;
    while(tt--)
    {
		ll b,c;
		cin>>b>>c;
		ll q=m[b];
		s=s-q*b+q*c;
		m[b]=0;
		m[c]+=q;
		cout<<s<<"\n";
	}
	}
   

 


   

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

int main(){
  string s;

  cin >> s;

  int aindex;
  int zindex;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') {
      aindex = i;
      break;
    }
  }

  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == 'Z') {
      zindex = i;
      break;
    }
  }

  int ans = zindex - aindex + 1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

const long mod = 1000000007;
const long indlim = 5368709119;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	string res;
	long N, K; cin >> N >> K;
	string S; cin >> S;
	S[K - 1] = (char)((int)S[K - 1] + (int) 'a' - (int) 'A');

	cout << S << endl;
}

Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int64_t n, m, d;
  cin >> n >> m >> d;
  double answer;
  if (d == 0) {
    answer = (double)(m - 1) * (1.0 / (double)(double)n);
  } else {
    answer = (double)(m - 1) * ((double)(2 * (n - d)) / (double)(n * n));
  }
  cout << setprecision(20) << answer << endl;
  return 0;
}


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

int main()
{
    long long n,a[100001],b[100001],an=0;
    cin>>n;
    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; i++)
    {
        if(a[i]>=b[i])
            an+=b[i];
        else
        {
            an+=a[i];
            b[i]-=a[i];
            if(a[i+1]>=b[i])
                {an+=b[i];a[i+1]-=b[i];}
             else
                    {an+=a[i+1];a[i+1]=0;}
        }
    }
    cout<<an<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#define INT_MAX 2147483647

struct Process{
  std::string name;
  int time;
};

class Queue {
private:
  Process Table[1000000];
  int head;
  int top;
public:
  Queue(){ head=0; top=0; };
  void Enqueue(Process P){ Table[top++] = P; };
  Process Dequeue(){ return Table[head++]; };
  bool isEmpty(){return head==top; };
  void show(){
    std::cout << "head : " << head << '\n';
    std::cout << "top : " << top  << '\n';
  };
};

int main(int argc, char const *argv[]) {
  int n;
  int q;
  int cumtime=0;
  Process P;
  Queue queue = Queue();
  std::cin >> n >> q;

  for (size_t i = 0; i < n; i++) {
    std::cin >> P.name;
    std::cin >> P.time;
    queue.Enqueue(P);
  }

  while (!queue.isEmpty()) {
    P = queue.Dequeue();
    P.time -= q;
    if (P.time>0) {
      queue.Enqueue(P);
      cumtime += q;
    } else {
      cumtime += (q + P.time);
      std::cout << P.name << ' ' << cumtime << '\n';
    }
  }

  return 0;
}



Measured memory_bytes: 21076
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let N = lines.shift() - 0;
    let Ln = lines[0].split(" ").map((v) => v - 0);
    Ln.sort(function(a,b) { return b - a; });
    let max = Ln.shift();
    let sum = 0;
    Ln.forEach(function(value, index, array) { sum += value; });

    console.log(max < sum ? "Yes" : "No");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main()
{
    int n;
    cin>>n;
    long long a[n],dp[n]={0};
    for(int i=0; i<n; i++)
        cin>>a[i];
    dp[n-1]=0;
    for(int i=n-2; i>=0; i--)
    {
        if(a[i]>=a[i+1]) dp[i]=dp[i+1]+1;
        else dp[i]=0;
    }
    long long ans=0;
    for(int i=0; i<n; i++)
        ans=max(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  ll N;

  cin >> N;

  unordered_map<ll, int> um;
  for (int i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    um[tmp]++;
  }

  ll ans = 0;
  for (auto& kv : um) {
    if (kv.second % 2 == 1) ans++;
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  constexpr int MARK_NUM = 4;
  constexpr int MARK_LENGTH = 13;
  int size, num;
  string mark;
  vector<vector<int> > cards{
    {0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0}};
  cin >> size;
  for(int i = 0; i < size; i++){
    cin >> mark;
    cin >> num;
    if (mark == "S")
      cards[0][num-1] = 1;
    else if(mark == "H")
      cards[1][num-1] = 1;
    else if(mark == "C")
      cards[2][num-1] = 1;
    else
      cards[3][num-1] = 1;
  }
  for(int i = 0; i < MARK_NUM; i++){
    for(int j = 0; j < MARK_LENGTH; j++){
      if(!cards[i][j]){
	switch(i){
	case 0:
	  cout << "S " << j + 1 << endl;
	  break;
	case 1:
	  cout << "H " << j + 1<< endl;
	  break;
	case 2:
	  cout << "C " << j + 1<< endl;
	  break;
	case 3:
	  cout << "D " << j + 1<< endl;
	  break;
	default: break;
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1220
s = str(input())
if (int(s[0])+int(s[1])+int(s[2])+int(s[3]) == 7):
    print(s[0],"+",s[1],"+",s[2],"+",s[3],"=7",sep = "")
elif (int(s[0])+int(s[1])+int(s[2])-int(s[3]) == 7):
    print(s[0],"+",s[1],"+",s[2],"-",s[3],"=7",sep = "")
elif (int(s[0])+int(s[1])-int(s[2])+int(s[3]) == 7):
    print(s[0],"+",s[1],"-",s[2],"+",s[3],"=7",sep = "")
elif (int(s[0])+int(s[1])-int(s[2])-int(s[3]) == 7):
    print(s[0],"+",s[1],"-",s[2],"-",s[3],"=7",sep = "")
elif (int(s[0])-int(s[1])+int(s[2])+int(s[3]) == 7):
    print(s[0],"-",s[1],"+",s[2],"+",s[3],"=7",sep = "")
elif (int(s[0])-int(s[1])+int(s[2])-int(s[3]) == 7):
    print(s[0],"-",s[1],"+",s[2],"-",s[3],"=7",sep = "")
elif (int(s[0])-int(s[1])-int(s[2])+int(s[3]) == 7):
    print(s[0],"-",s[1],"-",s[2],"+",s[3],"=7",sep = "")
else:
    print(s[0],"-",s[1],"-",s[2],"-",s[3],"=7",sep = "")

Measured memory_bytes: 3192
dp = [[0] * 101 for _ in range(11)]

def dfs(n, p, s):
	if p == 10:
		return
	for i in range(n, 10):
		dp[p][s + i] += 1
		dfs(i + 1, p + 1, s + i)

dfs(0, 0, 0)

while True:
	l = map(int, raw_input().split())
	if l[0] == 0 and l[1] == 0:
		break

	print dp[l[0] - 1][l[1]]

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	int l,i,j;
	cin>>s;
	l=s.size();
	if(l%2)
	{
		cout<<"No";
		return 0;
	}
	for(i=0,j=l-1;i<j;i++,j--)
	{
		if(s[i]=='b'&&s[j]!='d')
		{
			cout<<"No";
			return 0;
		}
		else
		{
			if(s[i]=='d'&&s[j]!='b')
			{
				cout<<"No";
				return 0;
			}
			else
			{
				if(s[i]=='p'&&s[j]!='q')
				{
					cout<<"No";
					return 0;
				}
				else
				{
					if(s[i]=='q'&&s[j]!='p')
					{
						cout<<"No";
						return 0;
					}
				}
			}
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
int64_t N, A, B ;
int64_t k, l, p ;
cin >> N >> A >> B;
k = N /(A + B) ;
l = N - (A + B) * k ;
if ( l < A ){
p = l + k * A;}
else { p = A + k*A;}
cout << p << endl;      
}


Measured memory_bytes: 256
N=int(input())
S=input()

ruir=[0]*N
ruil=[0]*N


for i in range(1,N):
    nowr=ruir[i-1]
    if S[i-1]=="W":
        nowr+=1
    ruir[i]=nowr

    nowl=ruil[-i]
    if S[-(i)]=="E":
        nowl+=1
    ruil[-(i+1)]=nowl

ans=10**6
for i in range(N):
    ans=min(ans, ruir[i]+ruil[i])
#print(ruil,ruir)
print(ans)



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

int main() {
    int K; cin >> K;
    set<int64_t> st;
    auto f = [&](auto &&f, int64_t n, int p, int len) -> void {
        if(len == 11) return;
        st.insert(n);
        n *= 10;
        if(p + 1 < 10) f(f, n + p + 1, p + 1, len + 1);
        f(f, n + p, p, len + 1);
        if(p - 1 >= 0) f(f, n + p - 1, p - 1, len + 1);
    };
    for(int i = 1; i < 10; ++i) f(f, i, i, 1);
    int i = 0;
    for(auto &e : st) {
        if(i == K - 1) {
            cout << e << '\n';
            return 0;
        }
        i++;
    }
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    if(a&1&&b&1){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
    
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        
        if (r < 1200) System.out.println("ABC");
        else if (r < 2800) System.out.println("ARC");
        else System.out.println("AGC");
    }
}


Measured memory_bytes: 35580
n, m = map(int, input().split())
listH = list(map(int, input().split()))
tL = [0]*n
tMap = {}
for i in range(m):
    a, b = map(int, input().split())
    tL[a-1] = 1
    tL[b-1] = 1
    if a-1 in tMap:
        tMap[a-1].append(listH[b-1])
    else:
        tMap[a-1] = [listH[b-1]]
    if b-1 in tMap:
        tMap[b-1].append(listH[a-1])
    else:
        tMap[b-1] = [listH[a-1]]

count = 0
for key in tMap:
    if listH[key] > max(tMap[key]):
        count+=1
for t in tL:
    if t == 0:
        count+=1
print(count)

Measured memory_bytes: 29000
from math import factorial as fac

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

if abs(N-M) > 1:
  print(0)
elif abs(N-M) == 1:
  print((fac(N)*fac(M))%1000000007)
else:
  print((2*fac(N)*fac(M))%1000000007)

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

int main(){
    int n,x;
    cin>>n;
    
    for(int i=3;i<=n;i++){
        x=i;
        if(x%3==0){
            cout<<" "<<i<<flush;
        }else{ 
            while(x!=0){
                if(x%10==3){
                    cout<<" "<<i<<flush;
                    break;
                }
                 x/=10;
            }
        }
    }
    cout<<endl;
}


Measured memory_bytes: 3092