akhauriyash/Code-Regression huggingface dataset:
//
// author  : Abhishek
//
#include <bits/stdc++.h>
#include<chrono>

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;
using namespace chrono;

const ll mod = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t;
    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    }
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif

    auto start = high_resolution_clock::now();

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;

    ll w;
    cin >> n >> w;

    vector<ll> wt(n), val(n);

    fo(i, n) {
        cin >> wt[i] >> val[i];
    }

    ll dp[n + 1][w + 1];

    fo(i, n + 1) {
        fo(j, w + 1) {
            dp[i][j] = 0;
        }
    }

    Fo(i, 1, n + 1) {
        Fo(j, 1, w + 1) {
            dp[i][j] = dp[i - 1][j];
            if (j - wt[i - 1] >= 0) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - wt[i - 1]] + val[i - 1]);
            }
        }
    }

    cout << dp[n][w];

    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
#ifndef ONLINE_JUDGE
    cerr << "Time: " << duration.count() / 1000.0 << endl;
#endif


    return 0;
}




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

Measured memory_bytes: 256
def palindrome(string): 
    return 0 if string==string[::-1] else 1

s = input()
n = len(s)
a = s[0:int((n-1)/2)]
b = s[int((n+1)/2):n]

check = palindrome(s) + palindrome(a) + palindrome(b)

if check:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {

  const int INF = 1e9 - 1;

  int mini = INF;

  string s = in;
  rep(i, 'a', 'z' + 1) {
    string tmp = s;
    rep(k, 200) {
      if (string(tmp.size(), i) == tmp) {
        amin(mini, k);
        break;
      }
      string a;
      rep(j, (int)tmp.size() - 1) {
        if (tmp[j] == i || tmp[j + 1] == i) {
          a.push_back(i);
        }
        else a.push_back(tmp[j]);
      }
      tmp = a;
    }
  }
  cout << (mini) << endl;


}


Measured memory_bytes: 256
let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let a_ss = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ fun k -> Array.init k @@ fun _ -> Scanf.scanf " %d" @@ fun a -> a - 1
let cs = Array.make m 0
let f a_s = Array.iter (fun a -> cs.(a) <- cs.(a) + 1) a_s
let _ = Array.iter f a_ss; Array.fold_left (fun ans c -> ans + if c = n then 1 else 0) 0 cs |> Printf.printf "%d\n"

Measured memory_bytes: 640
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e12;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------

struct edge {
  int to;
  ll cost;
};

int N,
    Q, K;
vector<vector<edge>> tree(100010);
vector<ll> dis(100010);
VB visited(100010, false);

void dfs(int a, ll c) {
  dis[a] = c;
  visited[a] = true;
  // cout << "dis[" << a << "] = " << c << endl;

  for (edge e : tree[a]) {
    if (!visited[e.to]) {
      dfs(e.to, c + e.cost);
    }
  }
}

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

  cin >> N;
  REP(i, N - 1) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    tree[a].push_back({b, c});
    tree[b].push_back({a, c});
  }

  cin >> Q >> K;
  dfs(K, 0);

  REP(i, Q) {
    int x, y;
    cin >> x >> y;
    cout << dis[x] + dis[y] << endl;
  }

  return 0;
}

Measured memory_bytes: 14336
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (na, nb, m) = (v[0], v[1], v[2]);
    let a = read_vec::<i64>();
    let b = read_vec::<i64>();
    let mut ans = a.iter().min().unwrap() + b.iter().min().unwrap();
    for i in 0..m {
        let v = read_vec::<i64>();
        let (x, y, c) = (v[0] as usize - 1, v[1] as usize - 1, v[2]);
        ans = min(ans, a[x] + b[y] - c);
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, ll>P;
int N;
ll A[202020];

ll dp[202020][2][3];

int main() {
	string s;
	
	cin>>N;
	rep(i,N+1){ rep(x,2){ rep(y,3) dp[i][x][y]=-1e16;}}
	dp[0][1][0]=0;
	
	rep(i,N) {
      	ll x;
		cin>>x;
		rep(j,2) {
          rep(k,3) {
			// not take
			if(k+j<3) dp[i+1][1][k+j]=max(dp[i+1][1][k+j],dp[i][j][k]);
			// take
			if(j==1) dp[i+1][0][k]=max(dp[i+1][0][k],dp[i][j][k]+x);
		  }
        }
	}
	
	if(N%2==0) cout<<max(dp[N][1][0],dp[N][0][1])<<endl;
	else cout<<max(dp[N][0][2],dp[N][1][1])<<endl;
}

Measured memory_bytes: 12976
import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    a = list(map(int,ipti().split()))
    ans = sum(a) - n
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38768
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second   
#define mit mii::iterator
#define vit vi::iterator
#define all(a) a.begin(),a.end()
#define min3(a, b, c) min(a, min(b, c))
#define mod 1000000007
#define inf 1000000000
#define limit 200001
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/ 

void input()
{
    int n;
    cin >> n;
    

    int w = 0, r = 0;
    vi c(n);
    rep(i,n)
    {
        char x;
        cin >> x;
        if(x == 'W')
            c[i] = 0, w++;
        else
            c[i] = 1, r++;
    }

    int ans = min(w, r);
    w = 0;
    rep(i,n-1)
    {
        if(c[i] == 0)
            w++;
        else
            r--;
        ans = min(ans, max(w,r));
    }
    cout << ans << '\n';

}
 
int main()
{
    

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}

Measured memory_bytes: 3972
#include <cstdio>
#include <vector>

using namespace std;
vector<int> vls;
vector<int> cts;
void add(int vl) {
	for(int i=0;i<vls.size();i++) {
		if(vls[i] == vl) {
			cts[i]++;
			return;
		}
	}
	vls.push_back(vl);
	cts.push_back(1);
}
int main() {
	int N;
	scanf("%d", &N);
	for(int i=0;i<N;i++) {
		int as;
		scanf("%d", &as);
		add(as);
		if(vls.size() > 3) {
			printf("No\n");
			return 0;
		}
	}
	if(vls[0] == 0 && vls.size() == 1) {
		printf("Yes\n");
		return 0;
	}
	if(vls.size() == 2) {
		if(vls[0] == 0 && cts[0] * 2 == cts[1]) {
			printf("Yes\n");
			return 0;
		}
		if(vls[1] == 0 && cts[1] * 2 == cts[0]) {
			printf("Yes\n");
			return 0;
		}
	}
	if(vls.size() == 3) {
		if((vls[0] ^ vls[1]) == vls[2]) {
			if(cts[0] == cts[1] && cts[0] == cts[2]) {
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

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

int main(){
  int i = 1;
  int a,b;

  scanf("%d %d", &a, &b);

  while(1){
    if(a == i*8/100 && b == i/10){
      printf("%d\n", i);
      break;
    }
    i++;

    if(i == 2000000){
      printf("-1\n");
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int M = GetInt();
		var A = GetInts(N);
		int S = A.Sum();
		WriteLine(A.Count(x => 4 * M * x >= S) >= M ? "Yes" : "No");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13396
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
    #define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
    #define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a%b);
}




int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.precision(10); cout << fixed;
#ifdef LOCAL
    freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
    LL n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    int k = gcd(n, m);
    for (int i = 0; i < k; i++) {
        if (s[n/k*i] != t[m/k*i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << n*m/k << endl;






/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
    return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 640
n = list(input())
a,b = int(n[0]+n[1]),int(n[2]+n[3])
if (a==0 or a>12) and (b==0 or b>12):
  print("NA")
elif 1<=a<=12 and (b>12 or b==0):
  print("MMYY")
elif 1<=b<=12 and (a>12 or a==0):
  print("YYMM")
else:
  print("AMBIGUOUS")
  

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,a[200005],h[200005],b[200005],f[200005];
inline int lowbit(int x){return x&(-x);}
void add(int x,ll y){
    for(;x<=n;x+=lowbit(x)) b[x]=max(b[x],y);
}
ll que(int x){
    ll ret=-9999;
    for(;x;x-=lowbit(x)) ret=max(ret,b[x]);
    return ret;
}
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++) scanf("%lld",h+i);
    for(int i=1;i<=n;i++) scanf("%lld",a+i);
    for(int i=1;i<=n;i++){
        f[i]=que(h[i])+a[i];
        add(h[i],f[i]);
    }
    printf("%lld\n",que(n));
    return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
long MOD = 1e9+7;
int main(){
    long n,k,cnt=0;
    cin >> n >> k;
    for(int i=k;i<=n+1;i++){
        cnt += (i*(n-i+1))%MOD+1;
        cnt %= MOD;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3636
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define p push
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/
int ans = 0;
int n;
void dfs(ll now, ll nowcolour, vector<vector<pair<int, int>>>& graph, vector<bool>& visited) {
	int newcolour = 1;
	visited[now] = true;
	int i = 0;
	for(auto a : graph[now]) {
			if (a.second == 0) {
				if (visited[a.first] == false) {
					if (nowcolour == newcolour)++newcolour;
					graph[now][i].second = newcolour;
					dfs(a.first, newcolour, graph, visited);
					++newcolour;
					}
			}
			++i;
	}
	ans = max(ans, newcolour);
}

int main() {

	scanf("%d", &n);
	vector<vector<pair<int, int>>> graph(n);
	vector<bool> visited(n);
	vector<pair<int, int>> anss(n - 1);
	int a, b;
	rep(i, n - 1) {
		scanf("%d%d", &a, &b);
		graph[a - 1].pb(make_pair(b - 1, 0));
		graph[b - 1].pb(make_pair(a - 1, 0));
		anss[i] = make_pair(a - 1, b - 1);
	}
	dfs(0, 0, graph, visited);
	printf("%d\n", ans - 1);
	for (auto a : anss) {
		ll ansa = -1;
		for (auto b : graph[a.first]) {
			if (b.first == a.second)ansa = b.second;
		}
		if(ansa == -1)for (auto b : graph[a.second]) {
			if (b.first == a.first)ansa = b.second;
		}
		if (ansa == -1)continue;
		else printf("%lld\n", ansa);
	}

	Please AC;
}


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

int main() {
    int N,M;
    cin >> N >> M;
    vector<int>a(N);
    vector<int>b(N);
    vector<int>c(M);
    vector<int>d(M);
    for(int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
    }
    for(int i = 0; i < M; i++) {
        cin >> c[i] >> d[i];
    }
    for(int i = 0; i < N; i++) {
        int cnt = 1e9;
        int ans = 0;
        for(int j = 0; j < M; j++) {
            if(abs(a[i]-c[j])+abs(b[i]-d[j]) < cnt) {
                ans = j+1;
                cnt = abs(a[i]-c[j])+abs(b[i]-d[j]);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;
	int mx = max(A, max(B, C));
	int res = 10 * mx + (A + B + C - mx);
	cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int md;
struct mat{
	int a[3][3],h,w;
	mat(){memset(a,0,sizeof(a));h=w=0;}
	mat operator*(mat u)const
	{
		mat res;
		res.h=h;res.w=u.w;
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<u.w;j++)
			{
				for(int k=0;k<w;k++)
				{
					res.a[i][j]=(res.a[i][j]+1LL*a[i][k]*u.a[k][j]%md)%md;
				}
			}
		}
		return res;
	}
};
mat qmul(mat x,long long p)
{
	mat res;
	res.h=x.h;
	res.w=x.w;
	for(int i=0;i<x.h;i++)res.a[i][i]=1;
	for(;p;p>>=1,x=x*x)if(p&1)res=res*x;
	return res;
}
long long l,a,b;
long long pw[19];
int ans;
int main()
{
	scanf("%lld%lld%lld%d",&l,&a,&b,&md);
	int s=0;
	long long t=a;
	do
	{
		t/=10;
		s++;
	}
	while(t);
	pw[0]=1;
	for(int i=1;i<=18;i++)pw[i]=pw[i-1]*10;
	long long st=0;
	for(int i=s;i<=18 && st<l;i++)
	{
		long long L=st,R=l-1;
		while(L<=R)
		{
			long long mid=(L+R)>>1;
			if(a+mid*b<pw[i])L=mid+1;else R=mid-1;
		}
		mat tmp;
		tmp.h=1;tmp.w=3;
		tmp.a[0][0]=ans;tmp.a[0][1]=(a+st*b)%md;tmp.a[0][2]=b%md;
		mat dp;
		dp.h=dp.w=3;
		dp.a[0][0]=pw[i]%md;
		dp.a[1][0]=1;
		dp.a[1][1]=1;
		dp.a[2][1]=1;
		dp.a[2][2]=1;
		tmp=tmp*qmul(dp,L-st);
		ans=tmp.a[0][0];
		st=L;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
program main;
var n,i,ac,wa,tle,re : integer;
    s : array[1..100000] of string;
begin 
  readln(n);
  for i := 1 to n do 
    readln(s[i]);
  for i := 1 to n do begin 
    if (s[i] = 'AC') then inc(ac);
    if (s[i] = 'WA') then inc(wa);
    if (s[i] = 'TLE') then inc(tle);
    if (s[i] = 'RE') then inc(re);
  end;
  writeln('AC x ',ac);
  writeln('WA x ',wa);
  writeln('TLE x ',tle);
  writeln('RE x ',re);
end.

Measured memory_bytes: 29316
#include <iostream>
using namespace std;
int cnt[100005];
int main(int argc, char** argv) {
	int n,m;
	cin >> n >> m;
	for(int i=1;i<=n;i++)
	{
		int k;
		cin >> k;
		for(int j=1;j<=k;j++)
		{
			int x;
			cin >> x;
			++cnt[x];
		}
	}
	int ans=0;
	for(int i=1;i<=m;i++) ans+=cnt[i]==n;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

LL ec = 0,hed[100005] = {0},nxt[200005],to[200005];
void add_edge(LL f,LL t){
	++ ec; to[ec] = t; nxt[ec] = hed[f]; hed[f] = ec;
}

LL n,N,a,b;
LL dp[100005] = {0},ans[100005] = {0};
LL p[100005];
LL pre[100005],suf[100005],sum[100005];

void dfs1(LL u,LL f){
	LL tot = 0;
	dp[u] = 1 % N;
	for(LL i = hed[u];i;i = nxt[i]){
		LL v = to[i];
		if(v == f) continue;
		dfs1(v,u);
		dp[u] = dp[u] * dp[v];
		dp[u] %= N;
	}
	for(LL i = hed[u];i;i = nxt[i]) if(to[i] != f) p[++ tot] = to[i];
	dp[u] ++; dp[u] %= N;
	pre[0] = 1LL; suf[tot + 1] = 1LL;
	for(LL i = 1;i <= tot;i ++) pre[i] = (pre[i - 1] * dp[p[i]]) % N;
	for(LL i = tot;i >= 1;i --) suf[i] = (suf[i + 1] * dp[p[i]]) % N;
	for(LL i = 1;i <= tot;i ++) sum[p[i]] = (pre[i - 1] * suf[i + 1]) % N;
}

void dfs2(LL u,LL f){
	if(u == 1) ans[u] = 1LL;
	else ans[u] = (ans[f] * sum[u] + 1) % N;
	for(LL i = hed[u];i;i = nxt[i]){
		LL v = to[i];
		if(v == f) continue;
		dfs2(v,u);
	}
}

int main(){
	scanf("%lld %lld",&n,&N);
	for(LL i = 1;i < n;i ++){
		scanf("%lld %lld",&a,&b);
		add_edge(a,b);
		add_edge(b,a);
	}
	dfs1(1,0);
	dfs2(1,0);
	for(LL i = 1;i <= n;i ++) printf("%lld\n",ans[i] * (dp[i] - 1 + N) % N);
	return 0;
}

Measured memory_bytes: 11904
A = int(input())
B = int(input())
C = int(input())
X = int(input())
#500a + 100b + 50c = 50m = X
m = X / 50
count = 0
for a in range(A+1):
    z = m - 10*a
    if z < 0:
        break
    else:
        for b in range(B+1):
            y = z - 2*b
            if y >= 0 and C >= y :
                count += 1
            elif y < 0:
                break
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
using namespace std;

ll N;
ll dif(vector<ll>& card, ll odd) {
  ll res = 0;
  vector<ll> temp = card;
  vector<bool> used(N, false);
  sort(temp.begin(), temp.end());
  for (ll i = 0; i < N; ++i) {
    ll want = temp.at(i);
    bool not_found = true;
    ll cnt = -1;
    for (ll j = 0; j < N; ++j) {
      if (used.at(j)) {
        continue;
      }
      cnt += 1;
      if (card.at(j) != want) {
        continue;
      }
      if ((odd & (ll)pow(2, j)) != 0) {
        if (abs(i - j) % 2 == 1) {
          // cout << "odd" << i << ' ' << j << "\n";
          // cout << "cnt" << cnt << "\n";
          res += cnt;
          used.at(j) = true;
          not_found = false;
          break;
        }
      }
      else {
        if (abs(i - j) % 2 == 0) {
          // cout << "even" << i << ' ' << j << "\n";
          // cout << "cnt" << cnt << "\n";
          res += cnt;
          used.at(j) = true;
          not_found = false;
          break;
        }
      }
    }
    if (not_found) {
      // cout << "not found" << "\n";
      return INF;
    }
  }
  // cout << res << "\n";
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N;
  vector<ll> A(N), B(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  for (ll i = 0; i < N; ++i) {
    cin >> B.at(i);
  }
  ll ans = INF;
  for (ll i = 0; i < (pow(2, N)); ++i) {
    if (__builtin_popcountll(i) % 2 != 0) {
      continue;
    }
    vector<ll> card = A;
    for (ll j = 0; j < N; ++j) {
      if ((i & (ll)pow(2, j)) != 0) {
        card.at(j) = B.at(j);
      }
    }
    // for (ll j = 0; j < N; ++j) {
    //   cout << card.at(j) << " ";
    // }
    // cout << "\n";
    ans = min(ans, dif(card, i));
    // cout << ans << "\n";
  }
  if (ans == INF) {
    cout << -1 << "\n";
  }
  else {
    cout << ans << "\n";
  }
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define int long long
// using ii = pair<int, int>;
using namespace std;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
vector<int> tbl[] = {
    {},
    {4, 2, 3, 5},
    {4, 6, 3, 1},
    {1, 2, 6, 5},
    {6, 2, 1, 5},
    {4, 1, 3, 6},
    {4, 5, 3, 2},
};

void solve() {
    int n; cin >> n;
    if (n == 0) exit(0);
    vector<int> t(n), f(n);
    for (int i = 0; i < n; i++) cin >> t[i] >> f[i];

    vector<vector<int>> num(100, vector<int>(100));
    vector<vector<int>> top(100, vector<int>(100));
    for (int i = 0; i < n; i++) {
        int x = 50, y = 50;
        int ct = t[i], cf = f[i];
        while (1) {
            // cout << x << " " << y << endl;
            int face = find(tbl[ct].begin(), tbl[ct].end(), cf) - tbl[ct].begin();
            bool no = true;
            for (int k = 6; k >= 4; k--) {
                int tmp = find(tbl[ct].begin(), tbl[ct].end(), k) - tbl[ct].begin();
                if (tmp >= 4) continue;
                int dif = (tmp - face + 4) % 4;
                int nx = x + dx[dif], ny = y + dy[dif];
                if (num[x][y] > num[nx][ny]) {
                    x = nx, y = ny;
                    if (dif == 0) cf = ct;
                    if (dif == 2) cf = 7 - ct;
                    ct = tbl[ct][(tmp + 2) % 4];
                    no = false;
                    break;
                }
            }
            if (no) break;
        }
        num[x][y]++;
        top[x][y] = ct;
    }

    vector<int> ans(7);
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            ans[top[i][j]]++;
        }
    }
    for (int i = 1; i < 7; i++) {
        cout << ans[i] << (i == 6 ? "" : " ");
    }
    cout << endl;
}

signed main() {
    while (1) solve();
}


Measured memory_bytes: 3288
#include <stdio.h>
#include <math.h>


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

    int i,j;

    int ans=0;

    // c  i
    for(i=1;i<N;i++){
        //N-iの約数の数
        //N-iを素因数分解
        /*
        int t = N-i;
        int prime[100000][2] ={0};
        j=0;
        while(t>1){
            if(j > sqrt(t)) break;
            if((t%j) == 0){
                for(int k=0;k<100000;k++){
                    if(prime[k][0] == j){
                        prime[k][1]++;
                    }
                    if(!(prime[k][0])){
                        prime[k][0] = j;
                        prime[k][1]++;
                    }
                }
                t = t/j;
            }
            j++;
        }
        j=0;
        int T=1;
        while( prime[j][0] ){
            T = T * (prime[j][1]+1);
            j++;
        } 
        ans = ans + T;
        */
       int T =  sqrt(N-i);
        for(j=1; j<=T; j++){
            //printf("i:%d, j:%d, ans:%d",i,j,ans);
            if( ((N-i) % j) ==0){
                if( j == ((N-i)/j) ){
                    ans++;
                    continue;
                }
                ans = ans+2;
            }
        }
        //printf("i = %d", i);
    }    
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 2156
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
A = list(map(int, input().split()))
cnt = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [0] * (N+1) # the max number using i matches
for i in range(N):
    if i > 0 and dp[i] == 0:
        continue
    for a in A:
        if i + cnt[a] > N:
            continue
        dp[i+cnt[a]] = max(dp[i+cnt[a]], dp[i]*10 + a)
print(dp[N])

Measured memory_bytes: 51036
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			double x1=sc.nextDouble();
			double y1=sc.nextDouble();
			double x2=sc.nextDouble();
			double y2=sc.nextDouble();
			double x3=sc.nextDouble();
			double y3=sc.nextDouble();
			double xp=sc.nextDouble();
			double yp=sc.nextDouble();
			double z1=(x3-x2)*(yp-y2)-(y3-y2)*(xp-x2);
            double z2=(x1-x3)*(yp-y3)-(y1-y3)*(xp-x3);
            double z3=(x2-x1)*(yp-y1)-(y2-y1)*(xp-x1);
            if(z1>=0&&z2>=0&&z3>=0||z1<=0&&z2<=0&&z3<=0){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
		}
	}
}

Measured memory_bytes: 23136
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	int T, H, S;
	
	while (true) {
		cin >> T >> H >> S;
		if ( T==-1 && H==-1 && S==-1 ) break;
		
		int rest = 7200 - 3600*T - 60*H - S;
		int triple_rest = 3 * rest;
		
		cout << setfill('0') << setw(2) << rest/3600 << ":"; rest %= 3600;
		cout << setfill('0') << setw(2) << rest/60 << ":";   rest %= 60;
		cout << setfill('0') << setw(2) << rest << endl;
		
		cout << setfill('0') << setw(2) << triple_rest/3600 << ":"; triple_rest %= 3600;
		cout << setfill('0') << setw(2) << triple_rest/60 << ":";   triple_rest %= 60;
		cout << setfill('0') << setw(2) << triple_rest << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3008
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    ll A;
    double B;
    cin >> A >> B;
    ll ans = A * ll(B * 100 + 0.5) / 100;
    cout << ans << endl;

    return 0;
}

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

static const int N = 1000;

int lcs(string x, string y) {
    int c[N + 1][N + 1];
    int m = x.size();
    int n = y.size();
    x = ' ' + x;
    y = ' ' + y;
    for (int i = 0; i <= m; i++) c[i][0] = 0;
    for (int j = 0; j <= n; j++) c[0][j] = 0;

    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (x[i] == y[j]) {
                c[i][j] = c[i - 1][j - 1] + 1;
            } else {
                c[i][j] = max(c[i - 1][j] , c[i][j - 1]);
            }
        }
    }

    return c[m][n];
}

int main() {
    int q;
    cin >> q;
    string s1, s2;
    for (int i = 0; i < q; i++) {
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }
}



Measured memory_bytes: 6960
//package abc136;
import java.io.*;
import java.util.*;

public class Main {
	// ------------------------
	
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		// ------------------------
		char[] s = sc.nextLine().toCharArray();
		int[] ans = new int[s.length];
		int r = 0, lastRL = -1;
		for(int i = 0; i < s.length; i++) {
			if(i + 1 < s.length && s[i] == 'R' && s[i + 1] == 'L') {
				ans[i] = 1 + r / 2;
				ans[i + 1] = 1 + (r + 1) / 2;
				r = 0;
				lastRL = i;
				i++;
			} else if (s[i] == 'R')
				r++;
			else if (s[i] == 'L')
				ans[lastRL + (i - lastRL) % 2]++;
		}
		for(int i : ans)
			out.print(i + " ");
		// ------------------------
		out.close();
	}
	//------------------------
	
	public static PrintWriter out;
	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 35796
#include <bits/stdc++.h>
using namespace std;
void solve(){
    int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;cin>>K;
    cout<<arr[K-1]<<"\n";
    return;
}

int main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans = 0;
	cin >> n;
	int x[n];
	for(int i=0;i<n;i++){
		cin >> x[i];
	}
	if (n%2 == 1)
	{
		cout << 0 << "\n";
		return 0; 
	}
	sort(x,x+n);
	ans = x[n/2]-x[n/2-1];
	cout << ans <<endl;
	return 0 ;	
}



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

static const long long mod = 1000000007;

int main(){
  vector<int> TensMod13{1, 10, 9, 12, 3, 4};
  string str;
  cin >> str;
  int n = (int)(str.length());
  vector<vector<long long>> dp(n, vector<long long>(13, 0));
  int start = (n - 1) % 6;
  if(str[0] == '?'){
    for(int j=0; j<=9; j++){
      dp[0][(j * TensMod13[start]) % 13] = 1;
    }
  }else{
    dp[0][((str[0] - '0') * TensMod13[start]) % 13] = 1; 
  }
  for(int i=1; i<n; i++){
    char c = str[i];
    if(c == '?'){
      for(int j=0; j<=9; j++){
        int move = (j * TensMod13[(n - 1 - i) % 6]) % 13;
        for(int k=0; k<=12; k++){
          dp[i][(k+move)%13] += dp[i-1][k];
          dp[i][(k+move)%13] %= mod;
        }
      }
    }else{
      c = c - '0';
      int move = (c * TensMod13[(n - 1 - i) % 6]) % 13;
      for(int k=0; k<=12; k++){
        dp[i][(k+move)%13] += dp[i-1][k];
      }
    }
  }
  cout << dp[n-1][5] << endl;
  return 0;
}

Measured memory_bytes: 13696
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define mset(x) memset(x, 0, sizeof(x))
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int l, r, n;
    cin >> l >> r >> n;
    cout << (r / n) - ((l-1) / n) << endl;
}


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

using namespace std;
typedef long long ll;
const ll mod=1e9+7;

int main(){
ll n,d;cin>>n>>d;
ll x,y,count=0;
while(n--){
  cin>>x>>y;
  x=pow(x,2);y=pow(y,2);
  if(sqrt(x+y)<=d){
    count++;
  }
}
cout<<count;
return 0;

  
}


Measured memory_bytes: 3496
while True:
    n,x=map(int, input().split())
    if n==x==0:break
    count=0
    for nmin in range(1,n+1):
        for nmed in range(nmin+1,n+1):
            if n+1>x-nmin-nmed>nmed:
                count+=1
    print(count)


Measured memory_bytes: 5592
n = gets.to_i
g = Array.new(n){[]}

(n-1).times do
  a,b,c = gets.split.map &:to_i
  a -= 1; b -= 1;
  g[a] << [b,c]
  g[b] << [a,c]
end

q,k = gets.split.map &:to_i
k -= 1
seen = Array.new(n,-1)

que = [k]
seen[k] = 0
while !que.empty?
  v = que.shift
  g[v].each do |nv,c|
    next if seen[nv] != -1
    seen[nv] = seen[v] + c
    que << nv
  end
end

q.times do
  x,y = gets.split.map &:to_i
  x -= 1; y -= 1
  puts seen[x] + seen[y]
end


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

int main(void) {
	string day[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	string S;
	int ans;
	cin >> S;
	for (int i = 0; i < 7; i++ ) {
		if (S == day[i]) {
			ans = i;
		}
	}
	printf("%d", 7 - ans);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>

//by Skeef79

//НЕ ИСПОЛЬЗУЙ endl, есть свой en!!
//Иногда нужно не просто придумывать решение, а метматически расписать систему уравнений
//для задач с cin/cout в большом кол-ве - gnu , иначе вижуалки. А ваще пробуй два если TL

//для интерактивок - cout<<flush
// cin.tie и sync_with_stdio убирать для интерактивок

typedef long long ll;
typedef long double ld;

#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 1e9 + 1233;
const ll LINF = 1e18 + 1233;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
}

template <typename T> void Input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}


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

	ll a, b;
	cin >> a >> b;
	ll k = (a + b) / 2;
	if (abs(a - k) == abs(b - k))
		cout << k;
	else
		cout << "IMPOSSIBLE";
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t Q,H,S,D,N;
  cin >> Q >> H >> S >> D >> N;
  int64_t one = min(Q*4,H*2);
  one = min(one, S);
  int64_t two = min(one*2,D);
  if(one*2 <= two){
    cout << one*N << endl;
  }
  else{
    if(N %2 == 0){
      cout << two*N/2 << endl;
    }
    else{
      cout << two*(N-1)/2 + one << endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
int main(){
    ll n;cin >> n;
    set<ll> st;
    map<ll,ll> mp;
    vl v(n);rep(i,n)cin >> v[i],st.ins(v[i]),mp[v[i]]++;
    ll res=0;
    rep(i,n){
        vl x=divisor(v[i]);
        bool check=false;
        for(auto p:x){
            if(st.count(p)){
                if(p==v[i]&&mp[v[i]]>=2){
                    check=true;
                    break;
                }
                if(p!=v[i]){
                    check=true;
                    break;
                }
            }
        }
        if(check)res++;
    }
    cout << n-res <<endl;
} 

Measured memory_bytes: 26760
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
    cin>>a>>b;
    
    if(a%2) a++;
    if(a/2>=b){
        cout1("YES")
    }else{
        cout1("NO")
    }
}

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

//int a[100002];

int main(){
    long long ans=1;
    int N, M;
    cin >> N >> M;

    rep(i, M) ans *=2;

    ans *= (N-M)*100 + 1900*M; 

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

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

using namespace std;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  set<int> S;
  S.insert(A);
  S.insert(B);
  S.insert(C);

  if (S.size() == 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
N, Y = inpl()

for x in range(2001):
    if 10000*x > Y:
        print(-1, -1, -1)
        break
    y = (Y-9000*x-1000*N)//4000
    z = N - x - y
    if 10000*x + 5000*y + 1000*z == Y and y >= 0 and z >= 0:
        print(x, y, z)
        break
else:
    print(-1, -1, -1)


Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, t = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(n)]
    AB.sort()

    res = 0
    dp = [[0] * (t + 1) for _ in range(n + 1)]
    for i in range(1, n + 1):
        a, b = AB[i - 1]
        for j in range(1, t + 1):
            if j - a >= 0:
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - a] + b)
            else:
                dp[i][j] = dp[i - 1][j]
        for k in range(i, n):
            _, b = AB[k]
            res = max(res, dp[i][j - 1] + b)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 139800
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int D, T, S; cin >> D >> T >> S;
  if (D <= T*S) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3068
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  ll n; cin >> n;
  string s;
  while(n>0){
    char c='a'+(n-1)%26;
    s+=c;
    n-=(n-1)%26;
    n/=26;
  }
  reverse(all(s));
  cout << s << endl;
}

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

int main(){
  int a,b,c;
  
  cin >> a >> b >> c ;
  
  if (a >= b) {
    int tmp1 = a;
    a = b;
    b = tmp1;
  }
  if (b >= c) {
    int tmp2 = b;
    b = c;
    c = tmp2;
  }
  if (a >= b) {
    int tmp3 = a;
    a = b;
    b = tmp3;
  }
  
  cout << a << " " << b << " " << c << endl;
  
}


Measured memory_bytes: 3068