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

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        String[] s = sc.next().split("");

        long r = 0;
        int g = 0;
        int b = 0;

        for (String v: s
             ) {
            switch (v) {
                case "R":
                    r++;
                    break;
                case "G":
                    g++;
                    break;
                case "B":
                    b++;
                    break;
            }
        }

        long ans =  r * g * b;

        for (int i = 0; i < n - 2; i++) {
            for (int j = i + 1; j < n - 1; j++) {
                if (s[i].equals(s[j])) {
                    continue;
                }
                int v = 2 * j - i;
                if (v >= n) {
                    break;
                }
                if (s[j].equals(s[v]) || s[i].equals(s[v])) {
                    continue;
                }
                ans--;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 37680
import collections
import math
n, m = [int(item) for item in input().split()]

def trial_division_sqrt(n):
    prime_count = collections.Counter()
    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1
    return prime_count

cnt = trial_division_sqrt(m)

ans = 1
for item in cnt:
  h = 1
  k_fact = 1
  for i in range(cnt[item]):
    h *= n + cnt[item] - 1 - i
    k_fact *= (i+1)
  ans *= h
  ans = ans // k_fact
  ans = ans % (1000000000 + 7)
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<ll> A(N + 1, 1);
    rep(i, N) cin >> A[i + 1];
    if(A[N] != 2) {
        output(-1);
        return 0;
    }
    ll mi = 2, ma = 2;
    for(int i = N; i >= 1; i--){
        ll mit = mi, mat = ma + A[i] - 1;
        mit = ((mit + A[i - 1] - 1) / A[i - 1]) * A[i - 1];
        mat = (mat / A[i - 1]) * A[i - 1];
        mi = mit, ma = mat;
//        cout << mit << "," << mat << endl;
        if(mit > mat){
            output(-1);
            return 0;
        }
    }
    cout << mi << " " << ma << endl;
    
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				int s = sc.nextInt();
				if(x==0&&y==0&&s==0)break;
				int max = 0;
				for(int i=1;i<1000;i++) {
					for(int j=1;j<1000;j++) {
						if(Math.floor((i*(100+x)/100 + j*(100+x)/100))==s){ //切り捨て
							if(i+j > s)break;
							max = Math.max((int)Math.floor((i*(100+y)/100+j*(100+y)/100)),max);
						}
						
					}
				}
				System.out.println(max);
			}
		}
	}

}



Measured memory_bytes: 29156
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
//#define mod 998244353
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll pow(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modinv(ll a){
	return powm(a,mod-2)%mod;
}
int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    t=1;
    //cin>>t;
    while(t--){
    	int n,i,j;
    	
    	cin>>n;
    	int a[n+1];
    	mem(a,0);
    	
    	for(i=0;i<n-1;i++)
    	{
    		int x;
    		cin>>x;
    		a[x]++;
    		
		}
		for(i=1;i<n+1;i++)
		{
			cout<<a[i]<<"\n";
		}
    	
    }}
    	

Measured memory_bytes: 4440
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int cnt = 0;
		String ans = "No";
		for(int i = 0; i < n; i++) {
			int a = in.nextInt();
			int b = in.nextInt();
			if(a == b) cnt += 1;
			else cnt = 0;
			if(cnt >= 3) {
				ans = "Yes";
				break;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 36044
package main

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

func solve(sc *scanner, wr *bufio.Writer) {
	n, k := sc.getInt2()
	as := sc.getInts(n)

	dp := make([][]int, 45)
	for i := range dp {
		dp[i] = make([]int, 2)
		dp[i][0], dp[i][1] = -1, -1
	}
	dp[0][0] = 0

	for i := 1; i < len(dp); i++ {
		cnt1 := 0
		for _, a := range as {
			ab := (a >> (len(dp) - 1 - i)) & 1
			cnt1 += ab
		}
		sum0 := (n - cnt1) << (len(dp) - 1 - i)
		sum1 := cnt1 << (len(dp) - 1 - i)

		if kb := (k >> (len(dp) - 1 - i)) & 1; kb > 0 {
			dp[i][0] = max(dp[i][0], dp[i-1][0]+sum0)
			dp[i][1] = max(dp[i][1], dp[i-1][0]+sum1)
		} else {
			dp[i][0] = max(dp[i][0], dp[i-1][0]+sum1)
		}
		if dp[i-1][1] >= 0 {
			dp[i][1] = max(dp[i][1], dp[i-1][1]+max(sum0, sum1))
		}
	}

	ans := max(dp[len(dp)-1][0], dp[len(dp)-1][1])
	fmt.Fprintln(wr, ans)
}

func main() {
	sc := newScanner()
	wr := bufio.NewWriter(os.Stdout)
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)

	solve(sc, wr)
	wr.Flush()
}

// input ------------------------
type scanner struct {
	*bufio.Scanner
}

func newScanner() *scanner {
	sc := bufio.NewScanner(os.Stdin)
	return &scanner{sc}
}
func (sc *scanner) getInt() int {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getInt2() (int, int) {
	return sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt3() (int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt4() (int, int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInts(n int) []int {
	ret := make([]int, n)
	for i := range ret {
		ret[i] = sc.getInt()
	}
	return ret
}
func (sc *scanner) getString() string {
	sc.Scan()
	return sc.Text()
}
func (sc *scanner) getRunes() []rune {
	return []rune(sc.getString())
}
func (sc *scanner) getFloat() float64 {
	sc.Scan()
	ret, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := range ret {
		ret[i] = sc.getFloat()
	}
	return ret
}

// math ----------------------------
func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func pow(a, b int) int {
	ret := 1
	for b > 0 {
		if b&1 > 0 {
			ret = ret * a
		}
		a = a * a
		b >>= 1
	}
	return ret
}


Measured memory_bytes: 4236
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

ll n, q, k, d[100010];
bool taken[100010];
vector<pair<ll, ll>> G[100010];

void dfs(int par) {
    taken[par] = true;
    for (int i = 0; i < G[par].size(); i++) {
        if (!taken[G[par][i].first]) {
            d[G[par][i].first] = d[par] + G[par][i].second;
            dfs(G[par][i].first);
        }
    }
}

int main(void){
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;  b--;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
        taken[i] = false;
    }
    
    cin >> q >> k;
    
    k--;
    d[k] = 0;
    dfs(k);
    
    for (int i = 0; i < q; i++) {
        ll x, y;
        cin >> x >> y;
        x--;  y--;
        cout << d[x] + d[y] << endl;
    }
    
    //for (int i = 0; i < n; i++) cout<< i << " " << d[i] << endl;
}


Measured memory_bytes: 14336
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 2e9+7;

int main() {
    int s;
    cin >> s;
    vi l(1000001);
    l[0] = s;
    rrep(i, 1000000) {
        int val;
        if (l[i - 1] % 2 == 0) {
            val = l[i - 1] / 2;
        } else {
            val = (3 * l[i - 1]) + 1;
        }
        if (find(all(l), val) != l.end()) {
            cout << i + 1 << endl;
            return 0;
        }
        l[i] = val;
    }
    return 0;
}

Measured memory_bytes: 4096
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

const int MaxN = 200000;

int n, m;
int a[MaxN];

char s[MaxN + 1];

int all_xor = 0;
int sv = 0;

inline void simulate()
{
	if (a[sv] ^ all_xor ^ 1)
		a[sv] ^= 1;
	else
	{
		all_xor ^= 1;
		++sv %= n;
	}
}

int main()
{
	cin >> n >> m >> s;

	for (int i = 0; i < n; ++i)
		a[i] = s[i] - 'A';

	int turns = min((n << 1) + (m & 1), m);
	while (turns--)
		simulate();

	for (int i = 0; i < n; ++i)
		putchar((a[(sv + i) % n] ^ all_xor) + 'A');
	putchar('\n');

	return 0;
}

Measured memory_bytes: 1408
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int x, y,i,j;
    cin >> x >> y;
    bool isend = false;
    for(i = 0; i <= x; i++){
        j = x - i;
        if (i * 2 + j * 4 == y){
            isend = true;
          	cout << "Yes" << endl;
          	break;
        }
    }
    if (!isend)
        cout << "No" << endl;
}

Measured memory_bytes: 3640
#include <queue>
#include <iostream>
#include <algorithm>
using namespace std;
const int N_MAX = 100;

int n;
// adj[from][to] from->toの辺があるか
bool adj[N_MAX + 1][N_MAX + 1];
int visited[N_MAX + 1];

void bfs(int src, int dst, int limit) {
	queue<int> que;
	fill(visited, visited + n + 1, -1);
	que.push(src);
	visited[src] = 1;
	while (!que.empty()) {
		int current = que.front();
		que.pop();
		if (current == dst) {
			if (visited[dst] > limit) break;
			cout << visited[dst] << endl;
			return;
		}
		for (int next = 1; next <= n; next++) {
			if (adj[current][next] && visited[next] == -1) {
				que.push(next);
				visited[next] = visited[current] + 1;
			}
		}
	}
	cout << "NA" << endl;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int r, k;
		cin >> r >> k;
		fill(adj[r], adj[r] + n, false);
		for (int j = 0; j < k; j++) {
			int t;
			cin >> t;
			adj[r][t] = true;
		}
	}
	int p;
	cin >> p;
	for (int i = 0; i < p; i++) {
		int s, d, v;
		cin >> s >> d >> v;
		bfs(s, d, v);
	}
	return 0;
}

Measured memory_bytes: 1208
// atcoder/agc031/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  int n;
  str s;
  while (cin >> n >> s) {
    lli x = 1;
    for (char c = 'a'; c <= 'z'; ++c) {
      x *= count(s.begin(), s.end(), c) + 1;
      x %= mod;
    }
    cout << (x - 1 + mod) % mod << endl;
  }

  return 0;
}


Measured memory_bytes: 512
from sys import stdin, setrecursionlimit
input = stdin.readline

setrecursionlimit(10**6)

N,Q = map(int, input().split())
neighborlist = [[] for _ in range(N+1)]

for _ in range(N-1):
    a, b = map(int, input().split())
    neighborlist[a].append(b)
    neighborlist[b].append(a)

pointlist = [0]*(N+1)
for _ in range(Q):
    p, x = map(int, input().split())
    pointlist[p] += x

def DFS(v):
    if not checkedlist[v]:
        checkedlist[v] = True
        
        global point
        point += pointlist[v]
        for neighbor in neighborlist[v]:
            DFS(neighbor)
        
        totallist[v] = point
        point -= pointlist[v]
        
totallist = [0]*(N+1)
checkedlist = [False]*(N+1)
point = 0
for i in range(1,N+1):
    if not checkedlist[i]:
        DFS(i)

print(*totallist[1:])

Measured memory_bytes: 223208
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>; using vvi = vector<vector<int>>;
using vl = vector<ll>; using vvl = vector<vector<ll>>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
//#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
pair<vl,vb> eratosthenes_sieve(ll n){
  vb is_prime(n+1,true);
  vl prime;
  is_prime[0] = false;
  is_prime[1] = false; 
  FOR(i,2,n+1){
    if(!is_prime[i]) continue;
    for(ll j=2*i;j<=n;j+=i) is_prime[j] = false;
    prime.eb(i);
  }
  return {prime,is_prime};
}
signed main(){
  vl prime;
  vb is_prime;
  tie(prime,is_prime) = eratosthenes_sieve(50000);
  ll n;
  while(cin>>n,n){
    ll ans = 0;
    for(ll i=0;prime[i]<=n/2;++i){
      if(is_prime[n-prime[i]]) ++ans;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <algorithm>
#include <tuple>

// #define int long は変なところでハマる可能性がるのでやらない。

struct Node {
	int nparents;
	int parent;
	std::vector<int> children;
	Node() : nparents(0), parent(), children() {}
};

int main()
{
	int N, M;
	std::vector<std::pair<int, int>> E; // edge
	std::vector<int> parent; // i番目のノードの親（答えとして出力するものから１を引いたもの）
	std::vector<int> subroots; // サブツリーのroot
	std::vector<Node> nodes;

	std::cin >> N >> M;
	for (int i = 0; i < N + M - 1; ++i) {
		int a, b;
		std::cin >> a >> b;
		E.emplace_back(a-1, b-1);
	}
	nodes.resize(N);
	for (auto& e : E) {
		nodes[e.first].children.push_back(e.second);
		++(nodes[e.second].nparents);
	}
	for (int i = 0; i < N; ++i) {
		if (nodes[i].nparents == 0) {
			nodes[i].parent = -1;
			subroots.push_back(i);
		}
	}

	while (!subroots.empty()) {
		auto subroot = std::move(subroots.back());
		subroots.pop_back();
		for (auto child : nodes[subroot].children) {
			if (--nodes[child].nparents == 0) {
				nodes[child].parent = subroot;
				subroots.push_back(child);
			}
		}
	}

	for (int i = 0; i < N; ++i) {
		std::cout << (nodes[i].parent+1) << "\n";
	}
}


Measured memory_bytes: 7924
using System;

class Program
{
    static void Main()
    {
        var str = Console.ReadLine();
        var a = int.Parse(str.Split()[0]);
        var b = int.Parse(str.Split()[1]);
        
        if(a < b){
            Console.WriteLine("a < b");
        }else if(a > b){
            Console.WriteLine("a > b");
        }else {
            Console.WriteLine("a == b");
        }
    }
}



Measured memory_bytes: 15916
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

bool f(int n){
    vector<int> v;
    while(n > 0){
        v.push_back(n % 10);
        n /= 10;
    }
    vector<int> rv = v;
    reverse(rv.begin(), rv.end());

    return v == rv;
}

signed main(){
    
    int a, b; cin >> a >> b;
    int ans = 0;
    for(int x = a; x <= b; x++){
        ans += f(x);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int L0 = 2;
  int L1 = 1;
  long Li;
  long Li1 = L1;
  long Li2 = L0;
  
  cin >> N;
  
  if (N == 1) {
    cout << L1 << endl;
  }
  else {
    for (int i = 0; i < N - 1; i++) {
      Li = Li1 + Li2;
      Li2 = Li1;
      Li1 = Li;
    }
    cout << Li << endl;
  }
}

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

count = 0
colors = [0]*8
cList = list(map(int,input().split()))

for i in cList:
  if i >= 3200:
    count += 1
  else:
    colors[(i//400)] = 1

if sum(colors) != 0: 
  print(sum(colors),sum(colors)+count)
else:
  print(1,sum(colors)+count)
  

Measured memory_bytes: 3060
#include <stdio.h>

char hantei(double, double);

int main()
{
  double fi;
  double thou;
  char rank;

  while(scanf("%lf %lf",&fi, &thou) != EOF)
    {
      rank = hantei(fi, thou);
      if(rank == 'W') printf("AAA\n");
      else if(rank == 'S') printf("AA\n");
      else if(rank == 'N') printf("NA\n");
      else printf("%c\n",rank);
    }
  return 0;
}

char hantei(double x, double y)
{
  char rank;

  if(x < 35.50 && y < 71.00) rank = 'W';
  else if(x < 37.50 && y < 77.00) rank = 'S';
  else if(x < 40.00 && y < 83.00) rank = 'A';
  else if(x < 43.00 && y < 89.00) rank = 'B';
  else if(x < 50.00 && y < 105.00) rank = 'C';
  else if(x < 55.00 && y < 116.00) rank = 'D';
  else if(x < 70.00 && y < 148.00) rank = 'E';
  else rank = 'N';

  return rank;
}

Measured memory_bytes: 0
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int k;
    string s;
    cin >> k >> s;
    if ( (int)s.size() <= k ) {
        cout << s << endl;
    }
    else {
        cout << s.substr(0, k) + "..." << endl;
    }

    return 0;
}


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

using namespace std;


int main(){
  long n;
  cin >> n;
 
  long num[n][26]={0};
  
  for(int i=0;i<n;i++){
   string s;
    cin >> s;
    for(int j=0;j<s.length();j++){
     num[i][s[j]-'a']++;
    }
  }
  
  string res="";
  for(char c='a';c<='z';c++){
     long cnt=51;
    for(int i=0;i<n;i++){
      cnt=min(cnt,num[i][c-'a']);
    }
    
    for(int i=0;i<cnt;i++) res+=c;
    
  }
  
  
  cout << res << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1,-1,-1):
  if sum(ans[i::i+1])%2!=a[i]:
    ans[i]=1
ans=[i+1 for i in range(n) if ans[i]==1]
print(len(ans))
ans=list(map(str,ans))
ans=" ".join(ans)
print(ans)

Measured memory_bytes: 74972
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int A = sc.nextInt();
      int B = sc.nextInt();
      if(B % A == 0){
        System.out.println(A + B);
      }else{
        System.out.println(B - A);
      }
	}
}


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


int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    vector<ll> sum(m+10, 0), a(m+10, 0), move(1);
    a[1] = x;
    sum[1] = x;
    move.push_back(a[1]);
    map<ll, ll> check;
    check[a[1]]++;
    ll s, e;
    for (ll i=2; i<m+10; i++){
        a[i] = (a[i-1]*a[i-1])%m;
        sum[i] = sum[i-1] + a[i];
        if (i==n){
            cout << sum[i] << endl;
            return 0;
        }
        if (a[i]==0){
            cout << sum[i] << endl;
            return 0;
        }
        if (check[a[i]]>0){
            e = i - 1;
            for (ll j=1; j<(move.size()); j++) if (a[i]==move[j]){
                s = j - 1;
                break;
            }
            break;
        }
        check[a[i]] = 1;
        move.push_back(a[i]);
    }
    ll sho = (n - s) / (e - s);
    ll res = (n - s) % (e - s);
    ll ans = (sho)*(sum[e]-sum[s]) + sum[s+res];
    cout << ans << endl;
    //printf("%.12f", ans);
}

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

int main(){
  int a,b,c,x;
  int count=0;
  cin >> a >> b >> c >> x;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(500*i+100*j+50*k==x){
          count ++;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
// template {{{

#include <bits/stdc++.h>
using namespace std;

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second

using ll = long long;
using ull = unsigned long long;

template<typename T, size_t H, size_t W>
using matrix = std::array<std::array<T, W>, H>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

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

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline void chmax(T &x, U y){ x = std::max<T>(x, y); }

template<typename T, typename U>
inline void chmin(T &x, U y){ x = std::min<T>(x, y); }

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ std::sort(c); c.erase(std::unique(std::begin(c), std::end(c))); }

// }}}

int n, m;
string s[10], t[10];

int main()
{
	while (cin >> n >> m, n){
		rep(i, n) cin >> s[i];
		rep(i, m) cin >> t[i];
		
		set<int> r[10];
		r[0].insert(0);
		loop(a, 1, 21) loop(b, 1, 21) loop(c, 1, 21){
			bool f = true;
			int x = 0, y = 0, z = 0;
			rep(i, n){
				int w = s[i].find_first_not_of('.');
				if (w != a * x + b * y + c * z) f = false;
				x += count(begin(s[i]), end(s[i]), '(');
				y += count(begin(s[i]), end(s[i]), '{');
				z += count(begin(s[i]), end(s[i]), '[');
				x -= count(begin(s[i]), end(s[i]), ')');
				y -= count(begin(s[i]), end(s[i]), '}');
				z -= count(begin(s[i]), end(s[i]), ']');
			}
			if (!f) continue;
			x = y = z = 0;
			rep(i, m){
				int w = a * x + b * y + c * z;
				if (w >= 0) r[i].insert(w);
				x += count(begin(t[i]), end(t[i]), '(');
				y += count(begin(t[i]), end(t[i]), '{');
				z += count(begin(t[i]), end(t[i]), '[');
				x -= count(begin(t[i]), end(t[i]), ')');
				y -= count(begin(t[i]), end(t[i]), '}');
				z -= count(begin(t[i]), end(t[i]), ']');
			}
		}

		rep(i, m){
			int t = r[i].size() == 1 ? *r[i].begin() : -1;
			cout << t << "\n "[i < m - 1];
		}
	}
}

Measured memory_bytes: 3160
import java.util.Scanner;

public class Main {
	 public static void main(String[] args) {
	        StringBuilder count=new StringBuilder();
	        Scanner sc=new Scanner(System.in);
	        int n=sc.nextInt();
	        for (int i=1;i<=n;i++){
	            int x=i;
	            if (x%3==0){
	                count.append(" "+i);
	                continue;}
	            do{
	                if(x%10==3){
	                    count.append(" "+i);
	                    break;}
	                x/=10;
	            }while(x!=0);
	        }
	        System.out.println(count);
	    }
	}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int n, snuke[2], fnuke[2];
    string s;
    cin >> n >> snuke[0] >> fnuke[0] >> snuke[1] >> fnuke[1] >> s;
    s = '#' + s + '#';
    for(int i = snuke[0]; i <= max(snuke[1], fnuke[1]); i++){
        if(s[i] == '#' && i-1 > 0){
            if(s[i-1] == '#'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    if(snuke[1] < fnuke[1]){
        cout << "Yes" << endl;
        return 0;
    }else{
        for(int i = fnuke[0]; i <= fnuke[1]; i++){
            if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }
}


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

int main() {
    string s;
    int sum = 0;
    while (true) {
        cin >> s;
        if (s == "0") break;
        sum = 0;
        for (int i = 0; i < s.size(); i++) {
            sum += s[i] - '0';
        }
        cout << sum << endl;
    }
}


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

# time complexity: O(√n)
def enumerate_divisors(n):
    divisors = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            divisors.add(i)
            if n % (n // i) == 0:
                divisors.add(n // i)
        i += 1
    return divisors


ans = 0
divisors = enumerate_divisors(N)
# print(divisors)
for divisor in divisors:
    num = N // divisor - 1
    if N - divisor * num < num:
        ans += N // divisor - 1
print(ans)


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

int main(){
  string a;
  cin >>a;
  if(a.at(2)==a.at(3)&&a.at(4)==a.at(5)){
  cout <<"Yes"<<endl;
  }
  else {
  cout <<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  ll dp[101][4][4][4];
  fill(dp[0][0][0], dp[101][0][0], 0);
  dp[0][3][3][3] = 1;
  for (int i = 0; i < n; i++) {
    for (int c1 = 0; c1 < 4; c1++) {
      for (int c2 = 0; c2 < 4; c2++) {
        for (int c3 = 0; c3 < 4; c3++) {
          bool b[4] = {true, true, true, true};
          if (c1 == 0 && c2 == 2) b[1] = false;
          if (c1 == 0 && c3 == 2) b[1] = false;
          if (c2 == 0 && c3 == 2) b[1] = false;
          if (c2 == 2 && c3 == 0) b[1] = false;
          if (c2 == 0 && c3 == 1) b[2] = false;
          for (int j = 0; j < 4; j++) {
            if (!b[j]) continue;
            dp[i + 1][c2][c3][j] += dp[i][c1][c2][c3];
            dp[i + 1][c2][c3][j] %= mod;
          }
        }
      }
    }
  }
  ll r = 0;
  for (int c1 = 0; c1 < 4; c1++) {
    for (int c2 = 0; c2 < 4; c2++) {
      for (int c3 = 0; c3 < 4; c3++) {
        r += dp[n][c1][c2][c3];
        r %= mod;
      }
    }
  }
  cout << r << endl;
}


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

#define MAX_N (100000)
#define MAX_M (100000)

int main() {
  // read inputs
  int N, M, as[MAX_M], bs[MAX_M];
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++) {
    scanf("%d %d", &as[i], &bs[i]);
  }

  // count occurence of each node
  int ns[MAX_N + 1] = {};
  for (int i = 0; i < M; i++) {
    ns[as[i]]++;
    ns[bs[i]]++;
  }

  // check if all the nodes occured an even number of times
  int is_possible = 1;
  for (int i = 0; i < N; i++) {
    if (ns[i] % 2 == 1) {
      is_possible = 0;
    }
  }
  if (is_possible) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
}

Measured memory_bytes: 1280
#include <stdio.h>

main() {
  char a, b, c, x, y, z;
  int joi=0, ioi=0, status, i=0;
  while(scanf("%c%c%c", &a, &b, &c) != EOF) {

      while(1) {
	if(b == c && y == z) scanf("%c", &c);
	if(c == '\n') break;
	x=a;
	y=b;
	z=c;

	if(a == 'J' && b == 'O' && c == 'I') joi++;
	  a=b;
	  b=c;

	  if(x == 'I' && y == 'O' && z == 'I') ioi++;
	  x=y;
	  y=z;
  }
	printf("%d\n%d\n", joi, ioi);
	joi = ioi = 0;
}
  return 0;
}

Measured memory_bytes: 540
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
	int A, B, C;	cin >> A >> B >> C;
	int X;	cin >> X;
	int answer = 0;
	
	// 500, 100, 50
	for (int i = 1; i <= A; ++i) {
		for (int j = 1; j <= B; ++j) {
			for (int k = 1; k <= C; ++k) {
				if (k * 50 + j * 100 + i * 500 == X) {
					++answer;
				}
			}
		}
	}
	// 100, 50
	for (int j = 1; j <= B; ++j) {
		for (int k = 1; k <= C; ++k) {
			if (k * 50 + j * 100 == X) {
				++answer;
			}
		}
	}
	// 500, 50
	for (int j = 1; j <= A; ++j) {
		for (int k = 1; k <= C; ++k) {
			if (k * 50 + j * 500 == X) {
				++answer;
			}
		}
	}
	// 500, 100
	for (int j = 1; j <= A; ++j) {
		for (int k = 1; k <= B; ++k) {
			if (k * 100 + j * 500 == X) {
				++answer;
			}
		}
	}
	// 500
	for (int k = 1; k <= A; ++k) {
		if (k * 500 == X) {
			++answer;
		}
	}
	// 100
	for (int k = 1; k <= B; ++k) {
		if (k * 100 == X) {
			++answer;
		}
	}
	// 50
	for (int k = 1; k <= C; ++k) {
		if (k * 50 == X) {
			++answer;
		}
	}
	cout << answer << endl;
	cin >> A;
}

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

using namespace std;

typedef long ll;

int main(int, char**)
{
	ll a, b;
	cin >> a >> b;

	if (a >= 13) cout << b << endl;
	else if (a >= 6) cout << (b / 2) << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
A, B, M = map(int, input().split())

A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))

# 割引券使わない
ans = min(A_list) + min(B_list)

# 割引券読み込み
for i in range(1, M + 1):
    x, y, c = map(int, input().split())
    price = A_list[x - 1] + B_list[y - 1] - c
    ans = min(ans, price)

print(ans)


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

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> gate(N+2, 0);

    rep(i,M) {
        int L,R;
        cin >> L >> R;
        gate[L]++;
        gate[R+1]--;
    }

    int ans = 0;
    for(int i=0;i<N+2;i++) {
        gate[i] += gate[i-1];
        if(gate[i] == M) ans++;
    }

    cout << ans << endl;
}


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

int main() {
    int n, T;
    cin >> n >> T;
    int t[n];
    rep(i, n) cin >> t[i];

    ll ans = T;
    rep(i, n - 1) {
        int dt = t[i + 1] - t[i];
        if (dt >= T)
            ans += T;
        else
            ans += dt;
    }

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


Measured memory_bytes: 4376
#include<iostream>
using namespace std;
long long n,sum1,sum2,sum3,sum4,sum5,ans;
char a[100006][200];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		if(a[i][0]=='M')sum1++;
		if(a[i][0]=='A')sum2++;
		if(a[i][0]=='R')sum3++;
		if(a[i][0]=='C')sum4++;
		if(a[i][0]=='H')sum5++;
	}
	ans+=sum1*sum2*sum3;
	ans+=sum1*sum2*sum4;
	ans+=sum1*sum2*sum5;
	ans+=sum1*sum3*sum4;
	ans+=sum1*sum3*sum5;
	ans+=sum1*sum4*sum5;
	ans+=sum2*sum3*sum4;
	ans+=sum2*sum3*sum5;
	ans+=sum2*sum4*sum5;
	ans+=sum3*sum4*sum5;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
cin>>n;
   int i,j,k=0,c=0,l=0;
   if(n==1)
{
    cout<<"1"<<endl;return 0;
}
   for(i=1;i<=n;i++)
   {
     j=i;c=0;
       while(1)
         {
             if(j%2>0)break;
             j=j/2;
             c++;
         }

     if(c>k)
     {
         k=c;
      l=i;
     }
  }
 cout<<l<<endl;
    return 0;
}

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

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

    int N;
    cin >> N;
    vector<double> x(N), y(N);
    REP(i, N) cin >> x[i] >> y[i];
    double ans = 0;
    REP(i, N) {
        REP(j, N) {
            if (i == j) continue;
            double dx = x[j] - x[i], dy = y[j] - y[i];
            ans += sqrt(dx * dx + dy * dy);
        }
    }
    ans /= N;
    cout << setprecision(8) << ans << endl;
}

Measured memory_bytes: 256
def prison(n, m, lrli):

    rmin = 10**5
    lmax = 0

    for i in lrli:
        rmin = min(rmin, i[1])
        lmax = max(lmax, i[0])

    return rmin-lmax+1 if rmin >= lmax else 0

def main():
    n, m = map(int, input().split())
    lrli = [list(map(int, input().split()))for i in range(m)]
    print(prison(n, m, lrli))

if __name__ == '__main__':
    main()

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

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    copy_n(istream_iterator<int>(cin), n, A.begin());
    map<int, int> M;
    for (const auto &a: A)
        M[a]++;
    vector<int> B;
    for (auto &m: M){
        while (m.second >= 2){
            B.push_back(m.first);
            m.second -= 2;
        }
    }
    
    if (B.size() < 2){
        puts("0");
        return 0;
    }
    nth_element(B.begin(), B.begin() + 2, B.end(), greater<int>());
    cout << int64_t(B[0]) * B[1] << endl;
}

Measured memory_bytes: 5376
n = int(input())

nodes = []
for _ in range(n):
    x = list(map(int, input().split()))
    nodes.append(x)
    
class Tree:
    def __init__(self, n):
        # n : ノード数
        # sibling : 兄弟
        self.nodes = {node: {'parent': None, 'children': [], 'depth': None, 'height': None, 'sibling': None} for node in range(n)}
        
    def add_node_with_child(self, node, childlen):
        for c in childlen:
            self.nodes[node]['children'].append(c)
            self.nodes[c]['parent'] = node
    
    def get_parent(self, node):
        return self.nodes[node]['parent']
    
    def get_children(self, node):
        return self.nodes[node]['children']
        
    def get_depth(self, node):
        if self.nodes[node]['depth'] != None:
            return self.nodes[node]['depth']
        elif self.nodes[node]['parent'] == None:
            self.nodes[node]['depth'] = 0
            return 0
        else:
            depth = self.get_depth(self.nodes[node]['parent']) + 1
            self.nodes[node]['depth'] = depth
            return depth
        
    def get_height(self, node):
        if self.nodes[node]['height'] != None:
            return self.nodes[node]['height']
        elif len(self.nodes[node]['children']) == 0:
            self.nodes[node]['height'] = 0
            return 0
        elif self.nodes[node]['height'] == None:
            children = self.nodes[node]['children']
            children_h = [self.get_height(c)+1 for c in children]
            self.nodes[node]['height'] = max(children_h)
            return self.nodes[node]['height']
        
    def get_sibling(self, node):
        if self.nodes[node]['sibling'] != None:
            return self.nodes[node]['sibling']
        elif self.nodes[node]['parent'] == None:
            self.nodes[node]['sibling'] = []
            return self.nodes[node]['sibling']
        else:
            p = self.nodes[node]['parent']
            sibling = set(self.get_children(p))
            sibling.remove(node)
            self.nodes[node]['sibling'] = list(sibling)
            return self.nodes[node]['sibling']
        
RootedTree = Tree(n)
for t in nodes:
    node = t[0]
    childlen = []
    if t[1] != -1:
        childlen.append(t[1])
    if t[2] != -1:
        childlen.append(t[2])
    RootedTree.add_node_with_child(node, childlen)
    
for node in range(n):
    parent = RootedTree.get_parent(node)
    if parent == None:
        parent = -1
    depth = RootedTree.get_depth(node)
    height = RootedTree.get_height(node)
    childlen = RootedTree.get_children(node)
    degree = len(childlen)
    childlen = ', '.join(list(map(str, childlen)))
    sibling = RootedTree.get_sibling(node)
    if len(sibling) == 0:
        sibling = -1
    else:
        sibling = sibling[0]
    
    if parent == -1:
        node_type = 'root'
    elif childlen == '':
        node_type = 'leaf'
    else:
        node_type = 'internal node'
    
    print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(node, parent, sibling, degree, depth, height, node_type))


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

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n -1);

    rep(i, n) cin >> a.at(i);
    rep(i, n) cin >> b.at(i);
    rep(i, n -1) cin >> c.at(i);

    int ans = 0;
    rep(i, n) {
        ans += b.at(a.at(i)-1);
        if (i>0) {
            if (a.at(i) == a.at(i-1) +1) {
                ans += c.at(a.at(i-1)-1);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

int main(void) {
	long long a, b, c, i, j, n;
	string aa, bb, cc;
	cin >> aa >> bb >> cc;
	if (aa[aa.size()-1]==bb[0]&&bb[bb.size()-1]==cc[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

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

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
const ll mod=MOD;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll a,b,c;cin>>a>>b>>c;
  ll k;cin>>k;
  ll cnt=0;
  swap(a,c);
  while(b<=c){
    b*=2;
    cnt++;
  }

  while(a<=b){
    a*=2;
    cnt++;
  }

  if(cnt<=k)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3660
#include <iostream>

using namespace std;

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

int main(){
	int n, k, m = (int)1e9;
	cin >> n >> k;
	rep(i,n) {
		int c, t;
		cin >> c >> t;
		if(t <= k) m = min(m, c);
	}
	if(m == (int)1e9) {
		cout << "TLE" << endl;
	} else {
		cout << m << endl;
	}
	return 0;
}


Measured memory_bytes: 384
x = sorted(list(map(int, input().split())))
ans = 0
if x[0]%2==x[1]%2:
    ans += (x[1] - x[0])//2
    ans += (x[2] - x[1])
else:
    ans += 1
    ans += (x[1] - x[0] + 1)//2
    ans += (x[2] - x[1])
print(ans)

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 100000

vector<vector<pll>> ga(MAXN);
vector<vector<pll>> gb(MAXN);

int main(){
  int n, m, s, t;cin>>n>>m>>s>>t; s--;t--;
  ll l,r,a,b;
  rep(i, m){
    cin>>l>>r>>a>>b; l--;r--;
    ga[l].push_back( {a, r} );
    ga[r].push_back( {a, l} );

    gb[l].push_back( {b, r} );
    gb[r].push_back( {b, l} );
  }

  vector<ll> da(n, INF);
  da[s]=0;
  priority_queue<pll, vector<pll>, greater<pll>> pq;
  pq.push( {0, s} );
  while(pq.size()){
    auto p = pq.top(); pq.pop();

    if(da[p.second] < p.first)continue;
    for(auto np: ga[p.second]){
      if(da[np.second] <= p.first+np.first)continue;

      da[np.second] = p.first+np.first;
      pq.push( {da[np.second], np.second} );
    }
  }

  vector<ll> db(n, INF);
  db[t]=0;
  pq.push( {0, t} );
  while(pq.size()){
    auto p = pq.top(); pq.pop();

    if(db[p.second] < p.first)continue;
    for(auto np: gb[p.second]){
      if(db[np.second] <= p.first+np.first)continue;

      db[np.second] = p.first+np.first;
      pq.push( {db[np.second], np.second} );
    }
  }

  vector<pll> c_y;
  rep(i, n) c_y.push_back( {da[i]+db[i], i+1} );
  sort(c_y.begin(), c_y.end());

  int c=0;
  vector<ll>results;
  rep(y, n){
    while(y>=c_y[c].second)c++;
    results.push_back(c_y[c].first);
  }

  for(auto u: results)cout << (ll)(pow(10LL, 15)-u) << endl;

  return 0;
}

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

const int MAX = 999999;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}




int main() {
  
  COMinit();
  
  int X, Y;
  cin >> X >> Y;
  int n, m;
  
  if ((2 * X - Y) % 3 != 0 || (2 * X - Y) < 0 || (2 * Y - X) % 3 != 0 || (2 * Y - X) < 0) {
    cout << 0 << endl;
  } else {
    n = (2 * X - Y) / 3;
    m = (2 * Y - X) / 3;
    cout << COM(n+m, m) << endl;
  }
}

Measured memory_bytes: 23680
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
const ll N=11000,M=1001001;
ll n,m,T,cnt,f[N][N],p[M],col[N][N],ans[N],x,y,z,k;
string s;
int main() 
{
	scanf("%lld%lld%lld",&n,&x,&y);
	for (int i=1;i<n;i++)
		for (int j=i+1;j<=n;j++)
		{
			ll mi=(j-i);
			mi=min(mi,1+abs(i-x)+abs(j-y));
			mi=min(mi,1+abs(i-y)+abs(j-x));
			ans[mi]++;
		}
	for (int i=1;i<n;i++) printf("%lld\n",ans[i]);
}

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

def BFS(adj, start):
    n = len(adj)
    d = [n] * n
    flag = [0] * n
    Q = []

    Q.append(start)
    d[start] = 0

    while len(Q) != 0:
        u = Q.pop(0)
        v = [i for i, x in enumerate(adj[u]) if (x == 1) and (flag[i] == 0)] # v <= ??£??\???????????????????????¢?´¢??????????????????
        
        for i in v:
            Q.append(i)
            d[i] = min(d[u] + 1, d[i])
            flag[u] = 1
    
    for i in range(n):
        if d[i] == n:
            d[i] = -1

    return d

def main():
    n = int(input())
    adj = [[0 for i in range(n)] for j in range(n)]
    
    for i in range(n):
        tmp = list(map(int, input().split()))
        u = tmp[0]
        u = u -1
        k = tmp[1]
        v = tmp[2:]
        for j in range(k):
            adj[u][v[j]-1] = 1
    
    d = BFS(adj, 0)
    for i in range(n):
        print(i+1, d[i])


if __name__ == "__main__":
    main()

Measured memory_bytes: 8136