akhauriyash/Code-Regression huggingface dataset:
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()
{
    long n, m;
    scan(n, m);
    auto g = new long[][](n);
    // writeln(g);
    foreach (_; 0 .. m)
    {
        long a, b;
        scan(a, b);
        g[a - 1] ~= b - 1;
        g[b - 1] ~= a - 1;
    }
    // writeln(g);
    auto dist = new long[](n);
    dist[] = -1;
    // writeln(dist);
    DList!(long) que;
    dist[0] = 0;
    que.insertBack(0);
    // writeln(que);
    // foreach (x; que)
    // {
    //     writeln("que:", x);
    // }
    // foreach (nv; g[1])
    // {
    //     writeln("nv:", nv);
    //     writeln(dist[nv]);
    // }
    auto room_num = new long[](n);
    room_num[] = -1;
    while (!que.empty())
    {
        long v = que.front();
        que.removeFront();
        foreach (nv; g[v])
        {
            if (dist[nv] != -1)
            {
                continue;
            }
            dist[nv] = dist[v] + 1;
            room_num[nv] = v;
            que.insertBack(nv);
        }
    }
    if (func(room_num))
    {
        writeln("No");
        return;
    }
    else
    {
        writeln("Yes");
        foreach (v; 1 .. n)
        {
            writeln(room_num[v] + 1);

            // writeln(dist[v]);
        }
    }
}

auto func(long[] x)
{
    foreach (i; 1 .. (x.length))
    {
        if (x[i] != -1)
        {
            continue;
        }
        else
        {
            return true;
        }
    }
    return false;
}

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: 27180
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  bool flag = true;
  rep(i,0,len(s)){
    if(i%2 == 0){
      if(s[i] == 'L') {
        flag = false;
        break;
      }
    }
    else{
      if(s[i] == 'R'){
        flag = false;
        break;
      }
    }
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
use std::collections::HashMap;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
    n: usize,
    s: [String; n]
    );
    let mut k_ids = HashMap::new();
    let mut v_ids = HashMap::new();
    let mut cs = vec![0; n];
    let mut v = 0;
    for i in &s {
        if !k_ids.contains_key(i) {
            k_ids.insert(i, v);
            v_ids.insert(v, i);
            v += 1;
        }
    }
    for i in &s {
        let id = k_ids[i];
        cs[id] += 1;
    }
    let mc = cs.clone().into_iter().max().unwrap();
    let mut ans = vec![];
    for i in 0..n {
        if cs[i] == mc {
            ans.push(&v_ids[&i]);
        }
    }
    ans.sort();
    for i in ans{
        println!("{}", i);
    }
}



Measured memory_bytes: 31816
a, b = map(int, input().split())
A = str(a)
B = str(b)
for i in range(a-1):
    B = B + str(b)
for j in range(b-1):
    A = A + str(a)

if a > b:
    print(B)
elif a < b:
    print(A)
else:
    print(A)

Measured memory_bytes: 3060
n, d = map(int, input().split())
x = []
for i in range(n):
    x.append(list(map(int, input().split())))
counter = 0
# 出力
for i in range(n):
    for j in range(i+1,n):
        dist = 0
        for k in range(d):
            dist += (x[i][k]-x[j][k])**2
        if dist**0.5%1 == 0:
            counter+=1
print(counter)


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

#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, begin, end) for(int (i) = (begin); (i) < (end); (i)++)

#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())
#define REVERSE(x) reverse( (x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define PW(x) (1LL<<(x))

using namespace std;
using ll = int64_t;
using P = pair<int, int>;

template<class T,class U>
ostream& operator<<(ostream &os, const pair<T, U> &p) {
    os << get_variable_name(p) << " = (" << p.first <<", " << p.second << ")";
    return os;
}

template<class T>
ostream& operator <<(ostream& os, const vector<T> &v){
    cout << get_variable_name(v) << " = [";
    for(auto i : v) 
        os << " " << i;
    os << " ]";
    return os;
}


const int INF = 1e8;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vector<int> cnt(32, 0);
    for(auto c: s) {
        cnt[c-'a']++;
    }

    for(auto i: cnt) {
        if(i & 1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

}


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

ll gcd(ll a, ll b){
    while(b != 0){
        ll tmp = b;
        b = a % b;
        a = tmp;
    }
    return a;
}


int main(){
    int n;
    cin >> n;
    vector<int> array(n);
    for(int i=0;i<n;i++) cin >> array.at(i);
    ll allg,maxg,g1,g2;
    if( n == 2 ){
        cout << max(array.at(0),array.at(1)) << endl;
        return 0;
    }
    for(int i=1;i<n;i++){
        if(i == 1){
            allg = array.at(0);
            maxg = array.at(1);
            continue;
        }
        g2 = gcd(allg,array.at(i));
        allg = gcd(allg,array.at(i-1));
        g1 = gcd(maxg,array.at(i));
        maxg = max(max(g1,g2),allg);
    }
    cout << maxg << endl;
}

Measured memory_bytes: 3752
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
int main(int argc, char const *argv[])
{
    char N[200001];
    scanf("%s", N);
    int count = 0;
    for (int i = 0; N[i] != '\0'; i++)
    {
        count += N[i] - '0';
    }
    if (count % 9 == 0)
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }
 
    return 0;
}


Measured memory_bytes: 2232
N, T = map(int, input().split())
c = [0]*N
t = [0]*N
for i in range(N):
    c[i], t[i] = map(int, input().split())

ansList = []
for i in range(N):
    if t[i] <= T:
        ansList.append(c[i])

if ansList == []:
    ans = "TLE"
else:
    ans = min(ansList)

print(ans)
    

Measured memory_bytes: 3064
M, D = map(int, input().split())

count = 0
for mi in range(4, M + 1):
    for di in range(2, D + 1):
        d1 = di % 10
        d10 = di // 10
        if d1 >= 2 and d10 >= 2 and mi == d1 * d10:
            count += 1
        # print(mi, di)


print(count)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 10000100
//#define NIL -1

int main() {
    LL n;
    LL ans=0;
    cin >> n;

    for(LL i=1; i<=n; i++){
        LL tmp=n/i;
        ans=ans+(tmp*(tmp+1)/2)*i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        s:chars,
        t:chars
    }

    let mut ans = 0;
    for i in 0..3 {
        if s[i] == t[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const ll md = 1000000007;

const int N = 100005;

ll arr[N], arr1[N];

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    string s;
    cin >> s;
    ll acc = 1, acc1 = 1;
    FORD(i, SZ(s) - 1, 0) {
        acc = (acc * 3) % md;
        arr[i] = acc;
    }
    arr[SZ(s)] = 1;
    ll ans = 0;
    FORD(i, SZ(s) - 1, 0) {
        ll a = ans;
        if (s[i] == '1') {
            ans = (2 * max(a, (ll) 1)) % md;
            ans = (ans + arr[i + 1]) % md;
        }         
    }
    cout << ans << endl;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define INF 1e18
#define NINF INT_MIN

#define nax 200005


void solve(){
	
	char a;
	cin>>a;
	if(a>='a' && a<='z'){
		cout<<"a"<<endl;
	}
	else
		cout<<"A"<<endl;
	
}	

signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3604
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
    string S;

    cin >> S;

    if(S=="AAA" || S=="BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

}

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

using namespace std;
const int N = 210;
int _w;

int n;

namespace G {
	int head[N], nxt[N*N], to[N*N], eid;
	void init() {
		eid = 0;
		memset(head, -1, sizeof head);
	}
	void link( int u, int v ) {
		to[eid] = v, nxt[eid] = head[u], head[u] = eid++;
	}
}

int color[N], ccn;
vector<int> cc[N];

bool bfs_bipartite( int s ) {
	++ccn;
	queue<int> q;
	color[s] = 0, q.push(s);
	while( !q.empty() ) {
		int u = q.front(); q.pop();
		cc[ccn].push_back(u);
		using namespace G;
		for( int i = head[u]; ~i; i = nxt[i] ) {
			int v = to[i];
			if( color[v] == -1 ) {
				color[v] = 1 - color[u];
				q.push(v);
			} else if( color[v] == color[u] ) {
				return false;
			}
		}
	}
	return true;
}

bool bipartite() {
	memset(color, -1, sizeof color);
	for( int i = 1; i <= n; ++i )
		if( color[i] == -1 )
			if( !bfs_bipartite(i) )
				return false;
	return true;
}

int dis[N];

int bfs_solve( int s ) {
	memset(dis, -1, sizeof dis);
	queue<int> q;
	dis[s] = 1, q.push(s);
	while( !q.empty() ) {
		int u = q.front(); q.pop();
		using namespace G;
		for( int i = head[u]; ~i; i = nxt[i] ) {
			int v = to[i];
			if( dis[v] == -1 ) {
				dis[v] = dis[u] + 1;
				q.push(v);
			}
		}
	}
	return *max_element(dis, dis+N);
}

int solve( const vector<int> &nod ) {
	int ans = 0;
	for( int u : nod )
		ans = max(ans, bfs_solve(u));
	return ans;
}

int main() {
	cin >> n;
	G::init();
	for( int i = 1; i <= n; ++i ) {
		char str[N];
		cin >> (str+1);
		for( int j = 1; j <= n; ++j )
			if( str[j] == '1' )
				G::link(i, j);
	}
	if( !bipartite() ) {
		puts("-1");
	} else {
		int ans = 0;
		for( int i = 1; i <= ccn; ++i )
			ans += solve( cc[i] );
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3828
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int count = 0;
        for (char c : S.toCharArray()) {
            if (c == 'W') {
                count++;
            }
        }
        int ans = 0;
        for (int i = 0; i < count; i++) {
            if (S.charAt(S.length()-1-i) == 'R') {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 40780
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int s = sc.nextInt();
		int[] data = new int[1000000];
		data[0] = s;
		int min = 100;

		for (int i = 1;i<1000000 ;i++ ) {
			if (data[i-1]%2==0) {
				data[i]=data[i-1]/2;
			}else{
				data[i]=3*data[i-1]+1;
			}
		}

		for (int i = 0;i<1000000 ;i++ ) {
			for (int j = i+1;j<1000000 ;j++ ) {
				if (data[i]==data[j]) {
					System.out.println(j+1);
					System.exit(0);
				}
			}
		}
		}
}


Measured memory_bytes: 26068
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,m; cin >> n >> m;
    vector<string> a(n),b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    // 左上(i,j)
    for (int i = 0; i <= n-m; i++) {
        for (int j = 0; j <= n-m; j++) {
            //printf("(%d,%d)\n", i,j);
            bool flag = true;
            for (int s = 0; s < m; s++) {
                if (strncmp(&a[i+s][j], &b[s][0], m) != 0) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

ll A[1000], B[1000],C[1000];

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


	int X, Y, Z, K; cin >> X >> Y >> Z >> K;
	for (int i = 0; i < X; i++) cin >> A[i];
	for (int i = 0; i < Y; i++) cin >> B[i];
	for (int i = 0; i < Z; i++) cin >> C[i];

	vector<ll> V1;
	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			V1.push_back(A[i] + B[j]);
		}
	}
	sort(V1.begin(), V1.end(), greater<ll>());

	vector<ll> V2;
	// mp1のうち先頭3000個だけ
	for (int i = 0; i < 3000 && i < V1.size();i++) {
		for (int j = 0; j < Z; j++) {
			V2.push_back(V1[i] + C[j]);
		}
	}

	sort(V2.begin(), V2.end(),greater<ll>());

	for (int i = 0; i < K; i++) {
		cout << V2[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 43236
#include<iostream>
#include<string>

int main() {
	std::string S, T;
	int count = 0;
	std::cin >> S >> T;

	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] != T[i])
			count++;
	}
	std::cout << count << std::endl;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int n, k;
    cin >> n >> k;

    int ans = k;
    for(int in=0;in<n-1;in++) {
        ans *= k-1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
n = int(input())
words = []
for i in range(n):
  words.append(input())
words_set = list(set(words))
ans = 'Yes'
if len(words) == len(words_set):
  b = words[0][-1]
  for i in range(1, n):
    if b == words[i][0]:
      b = words[i][-1]
    else:
      ans = 'No'
      break
else:
  ans = 'No'
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

namespace CsTest
{

    public class Program
    {
        static void Main(string[] args)
        {
            int[] NM = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int L = 1;
            int R = NM[0];
            for (int i = 0; i < NM[1]; ++i)
            {
                int[] LR = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                L = Math.Max(LR[0], L);
                R = Math.Min(LR[1], R);
            }
            if (R < L)
                Console.WriteLine(0);
            else
                Console.WriteLine(R - L + 1);
        }
    }
}

Measured memory_bytes: 17488
a = []
for i in range(6):
    n = int(input())
    a.append(n)
A = a[:4]
c = sorted(A, reverse=True)
x = c[0]
y = c[1]
z = c[2]
if a[4] > a[5]:
    w = a[4]
else:
    w = a[5]
print(x+y+z+w)


Measured memory_bytes: 5600
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>

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

int main(){
   int N;
   cin >> N;
   int P[N];
   for(int i = 0; i < N; i++) cin >> P[i];
   int ans = 1;
   int min = P[0];
   for(int i = 1; i < N; i++){
       if(P[i] < min){
           ans++;
           min = P[i];
       }
   }
   cout << ans << endl;

}


Measured memory_bytes: 1024
function main(input){
  //初期条件（入力値を取り出し、N,A,Bを数値化した）
  var val = input;
  val = val.split(' ');
  var con = [];
  for(var i=0;i<val.length;i++){
    con.push(Number.parseInt(val[i]));
  }
  //今回求める総和の初期条件を設定
  var totalSum = 0;
  for(let j=1;j<=con[0];j++){
    //一つの数字に対しての各桁の和と整数A,B内に含まれているかの確認
    var example_spl = (j+'').split('');
    var int = [];
    var sum = 0;
    for(let k=0;k<example_spl.length;k++){
      int.push(Number.parseInt(example_spl[k]));
      sum += int[k];
    }
    if(sum >= con[1] && sum <= con[2]){
      totalSum += j;
    }
  }
  console.log(totalSum);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 34216
#include <stdio.h>
#define N_MAX 10000
#define Q_MAX 500
int main(){
  int n;
  int S[N_MAX];
  int q;
  int T[Q_MAX];
  int i,j;
  int key;
  int cont=0;

  //---read---------
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&T[i]);
  }

  for(i=0; i<q; i++){
    for(j=0; j<n; j++){
      if(T[i]==S[j]){
	cont++;
	break;
      }
    }
  }

  printf("%d\n",cont);
  return 0;
}



Measured memory_bytes: 2144
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;

}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll n,i,j,l,m,h,w,c,q,f,k,need,cur,b,ans;
    	cin>>k>>n;
    	ll a[n];
    	rep(i,0,n)
    	cin>>a[i];
    	ans=mod;
    	ans=a[n-1]-a[0];
    	rep(i,1,n)
    	ans=min(ans,(k-(a[i]-a[i-1])));
    	cout<<ans;
    	
	}
	return 0;
}

Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	var n int
	var s,t string
	fmt.Scan(&n,&s,&t)
	var ans string

	for i := 0; i < n; i++ {
		ans += string(s[i])
		ans += string(t[i])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAX_N = 1000;
int main()
{
    int n, a[MAX_N], b, m, l = 0, s = 0;
    scanf("%d", &n);
    for (int i = 1; i < n + 1; i++)
    {
        scanf("%d", &a[i - 1]);
    }
    for (int i = 0; i < n; i++)
    {
        s += a[i];
    }
    for (b = 0; b < n; b++)
    {
        l = 0;
        for (int j = 0; j < b + 1; j++)
        {
            l += a[j];
        }
        m = s - l;
        if (l >= m)
        {
            break;
        }
    }
    (l - m > m - l + 2 * a[b]) ? printf("%d\n", m - l + 2 * a[b]) : printf("%d\n", l - m);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a,b,x,y;
int main(){
    cin>>a;
    for(int i=0;i<a;i++){
        cin>>b>>x>>y;
        if(!(x+y<=b&&(b-x-y)%2==0)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
//It is made by Awson on 2018.1.21
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define Abs(a) ((a) < 0 ? (-(a)) : (a))
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
#define writeln(x) (write(x), putchar('\n'))
#define lowbit(x) ((x)&(-(x)))
#define y1 yy
using namespace std;
const int N = 500000;
void read(int &x) {
    char ch; bool flag = 0;
    for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1); ch = getchar());
    for (x = 0; isdigit(ch); x = (x<<1)+(x<<3)+ch-48, ch = getchar());
    x *= 1-2*flag;
}
void write(int x) {
    if (x > 9) write(x/10);
    putchar(x%10+48);
}

int n, t1, x1, y1, t2, x2, y2;

void work() {
    read(n);
    while (n--) {
	read(t2), read(x2), read(y2);
	if (t2-t1 < Abs(x2-x1)+Abs(y2-y1)) {printf("No\n"); return; }
	if ((t2-t1-Abs(x2-x1)+Abs(y2-y1))%2) {printf("No\n"); return; }
	t1 = t2, x1 = x2, y1 = y2;
    }
    printf("Yes\n");
}
int main() {
    work();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*b);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



int main(){
	ll N,X,M;
	cin >> N >> X >> M;

	//今iにいて2^j個先に行ったとき

	ll pla[M][35]={},bal[M][35]={};

	FOR(i,0,M){
		pla[i][0] = i*i % M;
		bal[i][0] = i*i % M;
	}
	FOR(j,1,35)FOR(i,0,M){
		pla[i][j] = pla[ pla[i][j-1] ][j-1];
		bal[i][j] = bal[i][j-1] + bal[ pla[i][j-1] ][j-1];
	}

	ll ans = X;
	N--;
	FOR(i,0,35){
		if(N&(1LL<<i)){
			ans += bal[X][i];
			X = pla[X][i];
		}
	}
	cout << ans << endl;

}


Measured memory_bytes: 58220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)

        {
            int N = int.Parse(Console.ReadLine());
            string[] sequence = Console.ReadLine().Split(' ');
            var counter = 0;
            for(var i = 0; i < N; i++){
                int a_i = int.Parse(sequence[i]);
                while (a_i % 2 ==0)
                {
                    a_i = a_i / 2;
                    counter++;
                }
            }
            Console.WriteLine(counter);
        }
    }
}


Measured memory_bytes: 13792
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b;
  char op;
  while (cin >> a >> op >> b) {
    if (op == '?')
      break;
    if (op == '+')
      cout << a + b << endl;
    else if (op == '-')
      cout << a - b << endl;
    else if (op == '*')
      cout << a * b << endl;
    else if (op == '/')
      cout << a / b << endl;
  }
}



Measured memory_bytes: 3176
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	rs := []rune(s)
	cnt := 0
	for i := range rs {
		if i%2 != 0 && (string(rs[i]) == "L" || string(rs[i]) == "U" || string(rs[i]) == "D") {
			cnt++
		}
		if i%2 == 0 && (string(rs[i]) == "R" || string(rs[i]) == "U" || string(rs[i]) == "D") {
			cnt++
		}
	}
	if cnt == len(s) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int getTail(long long v){
	return int (v % 10);
}

int getHead(long long v){
	long long ret = v;
	while(true){
		long long tmp = ret / 10;
		if(tmp == 0){
			return ret;
		}
		ret = tmp;
	}
}

long long pow10[7] = {1, 10, 100, 1000, 10000, 100000, 1000000};
long long N;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	long long ans = 0;
	for(int i=1; i<=N; i++){
		if((i % 10) == 0) continue;
		int a = getHead(i);
		int b = getTail(i);
		int next = 1;
		//iのペアが1桁 (i, a) をカウントする
		if(a == b && a <= N){
			ans++;
		}
		//iのペアが2桁以上の場合 2桁から6桁
		for(int j=2; j<=6; j++){
			long long v = pow10[j - 1] * b + a;
			if(v > N){
				continue;
			}
			int mid = j - 2;
			for(int k=0; k < pow10[mid] ; k++){
				long long w = v + 10 * k;
				if(w <= N){
					ans++;
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3716
sa = gets.strip.chars
sb = gets.strip.chars
sc = gets.strip.chars

s = { 'a' => [sa, 'a'], 'b' => [sb, 'b'], 'c' => [sc, 'c'] }

cur = s['a']
while not cur[0].empty?
  card = cur[0].shift
  cur = s[card]
end

puts cur[1].upcase


Measured memory_bytes: 1788
import math

n = int(input());
s = [0]*n;
for i in range(n) :
	s_pre = list(input());
	s_pre.sort();
	s[i] = s_pre;


s.sort(key=lambda x:(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]));

ans = 0;
ren = 0;
for i in range(1,n) :
	ok = 1;
	if s[i-1]==s[i]:
		ans += 1;
		ans += ren;
		ren += 1;
	else :
		ren = 0;

print(ans);

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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
//#define MOD 1000000007
#define MOD 998244353
#define INF LLONG_MAX/2
#define int long long

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int atcoder(){
    int n;
  	cin>>n;
  	map<string,int> m;
  	REP(i,0,n){
    	string t;
      	cin>>t;
      	m[t]++;
    }
  	int M;
  	cin>>M;
  	REP(i,0,M){
    	string t;
      	cin>>t;
    	m[t]--;
    }
  	int ans=0;
  	for(auto x : m){
    	if(ans<x.second) ans=x.second;
    }
  	cout<<ans<<endl;
    return 0;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 256
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
h, n = map(int, input().split())

a = readints()
sum_x = 0
for i in range(n):
    sum_x += a[i]
if sum_x >= h:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 78316
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <set>
#include <fstream>
#include <cstring>
#include <climits>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

#define ll long long
#define mod 1000000007

ll dp[101][100001];

ll solve_ite(int* a, int n, int total_candies) {

	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j <= total_candies; j++) {
			if (j == 0)
				dp[i][j] = dp[i + 1][j];
			else {
				dp[i][j] = dp[i + 1][j] + dp[i][j - 1];
				if (j > a[i])
					dp[i][j] += mod - dp[i + 1][j - a[i] - 1];
			}
			dp[i][j] %= mod;
		}
	}
	return dp[0][total_candies];
}

int main() {

	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < 101; ++i)
		for (int j = 0; j < 100001; ++j)
			dp[i][j] = 0;
	// for (int j = 0; j <= k; ++j)
	// 	dp[n][j] = 1;
	dp[n][0] = 1;
	cout << solve_ite(a, n, k);

	return 0;
}

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

template<class T>
T ceil(T a, T b) {
    return (a+b-1)/b;
} 

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    int ans = t * ceil(n,x);
    cout << ans << endl;
}

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

int main(int argc, char *argv[]) {
	uint32_t num_of_city;
	uint32_t num_of_road;

	std::cin >> num_of_city;
	std::cin >> num_of_road;

	std::map<int, int> city_road_count_map;
	for (int i = 1; i <= num_of_city; i++) {
		city_road_count_map.insert(
			std::make_pair(i, 0)
		);
	}

	int from_city = 0;
	int to_city = 0;
	for (int j = 0; j < num_of_road; j++) {
		std::cin >> from_city;
		std::cin >> to_city;

		city_road_count_map[from_city] += 1;
		city_road_count_map[to_city] += 1;
	} 

	for (auto city_road_count: city_road_count_map) {
		std::cout << city_road_count.second << std::endl;
	}
	return 0;
}


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

i=0
A=[int(i) for i in input().split()]


A.sort()
A.reverse()

Alice=0
Bob=0

for j in range(N):
    if j%2==0:
        Alice=Alice+A[j]
    else:
        Bob=Bob+A[j]

        
gap=Alice-Bob
print(gap)


Measured memory_bytes: 3060
/*input
46979
*/
fn main() {
    let mut input = format!("");
    std::io::stdin().read_line(&mut input).ok();
    let mut number: u32 = input.trim().parse().unwrap();
    let h: u32 = number / 3600;
    number = number % 3600;
    let m: u32 = number / 60;
    number = number % 60;
    let s: u32 = number;
    println!("{}:{}:{}", h, m, s);
}



Measured memory_bytes: 5028
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <string.h>
#define inf 0x7fffffff
using namespace std;

int a,b,c,n,i,m,k,l[1000][100],o[4000010],d,e[1010][1000],dx[10]={0,-1,1,0,0,-1,-1,1,1},dy[10]={0,0,0,-1,1,-1,1,-1,1};
long long x,y,z;
stack<int> s;
struct P
{
    int x,y,z;
    bool operator<(const P &a)const
    {
        return z>a.z;
    }
};
priority_queue<P> q;
string r1,r2,p,h;
vector<P> v[50010];



int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;t++)
    {
        scanf("%d",&b);
        o[b]=t-1;
    }
    for(int t=1;t<=a;t++)
        printf("%d ",o[t]+20000*t);
    puts("");
    for(int t=a;t>=1;t--)
        printf("%d ",20000*t);
    return 0;
}

Measured memory_bytes: 1920
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

ll c[maxn];
ll pmod(int x, int n){
  ll base = x;
  ll ret = 1;
  while(n){
    if(n&1)ret = ret * base %mod;
    n>>=1;
    base = base * base % mod;
  }
  return ret;
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,m;
  cin>>n>>m;
  ll ret = 0;
  for(int i=m;i>=1;i--){
    int mx = m/i;
    ll cc = pmod(mx, n);
    for(int j=2;j*i<=m;j++){
      cc = (cc+mod-c[j*i])%mod;
    }
    c[i] = cc;
  }
  for(int i=1;i<=m;i++)ret=(ret+c[i]*i%mod)%mod;
  cout<<ret<<endl;
  return 0;
}

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

int main()
{
    std::string input;
    cin >> input;
    int digit = 0;
    for (auto c : input) {
        digit += c - '0';
    }
    cout << (digit % 9 == 0 ? "Yes" : "No")<< endl;
    return 0;
}

Measured memory_bytes: 3492
//#pragma GCC optimize(2)
// Happy TLE and WA every day!
// by: zxb the vegetable chicken
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define pb              push_back
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
//#define usingFiles
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool Read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool Write(int x){
	if(x >= 10) Write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

int n, m;
vector<int> v[100100];
bool has[100100];
int dp[100100];
int ans = 0;

int dfs(int now){
	if(dp[now] >= 0) return dp[now];
	if(v[now].empty()) return dp[now] = 0;
	int cnt = 0;
	rep(i, v[now].size()){
		cnt = max(cnt, dfs(v[now][i]) + 1);
	}
	return dp[now] = cnt;
}

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	memset(dp, -1, sizeof(dp));
	cin >> n >> m;
	rep(i, m){
		int a, b;
		cin >> a >> b;
		a--, b--;
		v[a].pb(b);
		has[b] = 1;
	}
	rep(i, n){
		if(!has[i]){
			ans = max(ans, dfs(i));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10880
score=[]
min=100
total=0

for i in range(4):
    score.append(int(input()))
    if min>score[i]:
        min = score[i]
    total+=score[i]
total-=min
min=100
for i in range(4,6):
    score.append(int(input()))
    if min>score[i]:
        min=score[i]
    total+=score[i]
total-=min
print(str(total))

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

int main(){
   char alfa;
  cin >> alfa;
  char ans = 'a';
  if(alfa-'a'<0)ans='A';
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x, y;
  bool operator < (const P &a )const{
    //if(x!=a.x)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[2122];
int l[21];
int j[21];


long long x,y,z,mod=1000000007;
//string r;
char r[22][22];

P u[1];
queue<int> q;
stack<int> s;
//set<P> s;
map<int,int> p;

vector<int> v;

bool as(P a,P b)
{
  //if(a.x!=b.x)
  //return a.x<b.x;
  return a.x<b.x;
}

void f(int k)
{
  q.push(k);
  if(k==1)
  {
    swap(x,y);
    for(int t=2;t<=n;t++)
      o[t-1]=o[t];
    n--;
    return;
  }
  if(k==n)
  {
    n--;
    return;
  }
  o[k-1]+=o[k+1];
  n-=2;
  for(int t=k;t<=n;t++)
  {
    o[t]=o[t+2];
  }
}

int main()
{
  scanf("%d",&a);
  for(int t=1;t<=a;t++)
  {
    scanf("%d",&o[t]);
    if(t%2&&o[t]>=0) x+=o[t],e=1;
    else if(o[t]>=0) y+=o[t],e=1;
  }
  if(!e)
  {
    k=-mod;
    for(int t=1;t<=a;t++)
      k=max(k,o[t]);
    printf("%d\n%d\n",k,a-1);
    int t=a;
    for(;o[t]!=k;t--)
    {
      printf("%d\n",t);
    }
    t--;
    for(;t;t--)
    puts("1");
    return 0;
  }
  n=a;
  printf("%lld\n",max(x,y));
  for(int t=n;t;t--)
  {
    if(t%2&&x>y&&o[t]<0) f(t);
    else if(t%2==0&&x<=y&&o[t]<0) f(t);
  }
  for(int t=n;t;t--)
  {
    if(x>y&&t%2==0) f(t);
    else if(x<=y&&t%2) f(t);
  }
  printf("%d\n",q.size());
  for(;q.size();q.pop())
    printf("%d\n",q.front());
}
//0
//13
//20



Measured memory_bytes: 384
def main():
    called = [0] * (100 + 1)  # 読み上げられた番号

    a = []
    for _ in range(3):
        *row, = map(int, input().split())
        a.append(row)

    n = int(input())
    for _ in range(n):
        b = int(input())
        called[b] = 1

    for r in range(3):
        for c in range(3):
            number = a[r][c]
            if not called[number]:
                break
        else:
            print('Yes')
            return

    for c in range(3):
        for r in range(3):
            number = a[r][c]
            if not called[number]:
                break
        else:
            print('Yes')
            return

    for i in range(3):
        number = a[i][i]
        if not called[number]:
            break
    else:
        print('Yes')
        return

    for i in range(3):
        number = a[i][2 - i]
        if not called[number]:
            break
    else:
        print('Yes')
        return

    print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

ll N, M;

int main()
{
    cin >> N >> M;
    if (N == 1) {
        N = 3;
    }
    if (M == 1) {
        M = 3;
    }

    cout << (N - 2) * (M - 2) << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

input1 = [int(x) for x in input().split()]
lake = input1[0]
homes = input1[1]
input2 = [int(x) for x in input().split()]

result = 1000000
last = homes - 1
for x in range(homes):
    forward = 0
    backward = 0
    start = input2[x]

    # forward
    if x == 0:
        forward = input2[last] - start
    else:
        forward = (lake - start) + input2[x - 1]
    
    # backward
    if x == last:
        backward = (start) - input2[0]
    else:
        backward = (start) + lake - (input2[x + 1])

    #print("forward: {}, backward: {}".format(forward, backward))
    result = min(result, forward, backward)

print(result)


Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 169, task c, 2020/05/31
//ms,
/*
*/

int main(void){
  int64_t A;
  double B;

  cin >>A >>B;
  int64_t Bint = (int64_t) floor(B*100+0.1);
  int64_t ans =A*Bint/100;
  cout <<ans<<endl;
  return 0;
}
/*
*/


Measured memory_bytes: 3832
def solve():
  n = int(input())
  maxi = -10
  maxi2 = -10
  place = -1
  for i in range(n):
    a = int(input())
    if a>maxi:
      maxi2 = maxi
      maxi = a
      place = i
    else:
      maxi2 = max(maxi2,a)
  for j in range(n):
    if place == j:
      print(maxi2)
    else:
      print(maxi)
  
solve()

Measured memory_bytes: 4540
#include <stdio.h>

int rep = 0;

void selectionSort(int *A, int N) {
    int i, j, minj, temp;
    for (i = 0; i < N-1; i++) {
        minj = i;

        for (j = i; j < N; j++) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }
        if (A[i] != A[minj])    rep++;

        temp = A[i];
        A[i] = A[minj];
        A[minj] = temp;
    }
}

int main(void) {
    int i, N;
    int A[100] = {0};

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

    selectionSort(A, N);

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

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

    return 0;
}

Measured memory_bytes: 604
def isKaibun(s):
  for i in range(len(s)//2+1):
    if s[i] != s[-(i+1)]:
      return False
  
  return True

S = input()
flag = 0

if isKaibun(S):
  flag += 1
if isKaibun(S[:(len(S)-1)//2]):
  flag += 1
if isKaibun(S[(len(S)+3)//2-1:]):
  flag += 1

if flag == 3:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3188
#include<iostream>

using namespace std;

int main(){

  int n,m;
  int a[100][100];
  int b[100];
  int c[100]={0};

  cin>>n>>m;

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

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

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      c[i]+=a[i][j]*b[j];
    }
    cout<<c[i]<<endl;
  }
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>

#define ll long long
using namespace std;
int main()
{
	string s;
	cin >> s;
	int year = stoi(s.substr(0, 4));
	int month = stoi(s.substr(5, 2));
	int day = stoi(s.substr(8, 2));
	if (year < 2019) {
		cout << "Heisei";
		return 0;
	}
	else if(year == 2019) {
		if (month < 5) {
			cout << "Heisei";
			return 0;
		}
		else {
			cout << "TBD";
			return 0;
		}
	}
	else {
		cout << "TBD";
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256