akhauriyash/Code-Regression huggingface dataset:
use std::fmt::Debug;
use std::str::FromStr;

#[allow(dead_code)]
#[allow(deprecated)]
fn read_line_from_stdin() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    buffer.trim_right().to_owned()
}

#[allow(dead_code)]
#[allow(deprecated)]
fn parse_line_to_single<T>() -> T
where
    T: FromStr,
    T::Err: Debug,
{
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    T::from_str(buffer.trim_right()).unwrap()
}

#[allow(dead_code)]
#[allow(deprecated)]
fn parse_line_to_multiple<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    buffer
        .trim_right()
        .split_whitespace()
        .flat_map(|s| T::from_str(s))
        .collect()
}

#[allow(unused_macros)]
macro_rules! parse_line {
    [$( $x:tt : $t:ty ),+] => {
        //declare variables
        $( let $x: $t; )+
        {
            use std::str::FromStr;
            // read
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            #[allow(deprecated)]
            let mut splits = buf.trim_right().split_whitespace();
            // assign each variable
            $(
                $x = splits.next().and_then(|s| <$t>::from_str(s).ok()).unwrap();
            )+
            // all strs should be used for assignment
            assert!(splits.next().is_none());
        }
    };
}

fn main() {
    parse_line![a: u64, s: String];

    let mut split = s.split('.');
    let b = {
        let integer = u64::from_str(split.next().unwrap()).unwrap();
        let under_dot = u64::from_str(split.next().unwrap()).unwrap();

        integer * 100 + under_dot
    };

    // 整数部
    //let b_mul100 = (b * 100.0) as u64;

    println!("{}", a * b / 100);

    //let b_int = b as u64;
    //let b_per100 = (b * 100.0) as u64 - b_int * 100;
}


Measured memory_bytes: 2144
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const double inf=1e8;
int main(){
	int n;
	while(cin>>n,n){
		vvi dp(n+1,vi(4,inf));//hav=out
		dp[0][0]=0;
		vp in(n);
		rep(i,n)cin>>in[i].first>>in[i].second;
		bool h;
		rep(i,n){
			h=false;
			rep(j,4)if(dp[i][j]!=inf){
				pii bpos=(i?in[i-1]:pii(0,0));
				int t=dp[i][j]+bpos.first+in[i].first;
				int tim=bpos.second+bpos.first*(j+1)+in[i].first;
				if(tim<=in[i].second)dp[i+1][1]=min(dp[i+1][1],t),h=true;
				if(j!=3){
					t=dp[i][j]+abs(in[i].first-bpos.first);
					tim=bpos.second+abs(in[i].first-bpos.first)*(j+1);
					if(tim<=in[i].second)dp[i+1][j+1]=min(dp[i+1][j+1],t),h=true;
				}
			}
			if(!h){
				cout<<"NG "<<i+1<<endl;
				break;
			}
		}
		if(h){
			int out=inf;
			rep(i,4)if(dp[n][i]!=inf)out=min(out,dp[n][i]+in[n-1].first);
			cout<<"OK "<<out<<endl;
		}
	}
}

Measured memory_bytes: 3056
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
V = sorted(iil())

ans = V[0]

for i in V:
    ans = (ans+i)/2

print(ans)

Measured memory_bytes: 3064
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  const items = input[0].split("")
  const length = items.length
  const judgement = (arr) => {
    var judge = false
    const reversed = arr.slice().reverse()
    for (i = 0; i < arr.length; i++) {
      if (i === Math.floor(arr.length / 2)) {
        break
      }
      if (arr[i] === reversed[i]) {
        judge = true
      } else {
        judge = false
        break
      }
    }
    return judge
  }

  const result1 = judgement(items)
  if (length > 3) {
    const zenhan = items.slice(0, (length - 1) / 2)
    const result2 = judgement(zenhan)
    const kohan = items.slice((length + 3) / 2 - 1)
    const result3 = judgement(kohan)

    if (result1 && result2 && result3) {
      console.log('Yes')
    } else {
      console.log('No')
    }
  } else {
    if (result1) {
      console.log('Yes')
    } else {
      console.log('No')
    }
  }




  //文字列から10進数に変換するときはparseIntを使います
  // const a = parseInt(input[0], 10);
  //出力
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_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(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define INF 10000000000

ll a, b, c, n, m, x, y, k, w, h, ans = 0, mx = 0, mn = INF;
string s;

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

    cin >> n >> k;
    vector<ll> cnt(n + 1);
    rep(i, n){
        cin >> a;
        cnt[a]++;
    }
    sort(all(cnt));
    rep(i, 1, n - k + 1){
        ans += cnt[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 1792
a,b,c,d = map(int,input().split())

takahashi_turn=0
aoki_turn=0

while a>0:
    a-=d
    takahashi_turn+=1 #高橋君の生き残るターン数

while c>0:
    c-=b
    aoki_turn+=1 #青木君の生き残るターン数

if takahashi_turn>=aoki_turn:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61868
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double x1, x2, y1, y2, a;
  cin >> x1 >> y1 >> x2 >> y2;
  
  a = (x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2);
  a = sqrt(a);
  printf("%.6lf\n", a);
}


Measured memory_bytes: 3284
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int a,b,c,d,e,p,j;
	cin>>a>>b>>c>>d>>e;
	p=a;
	if(p > b)p=b;
	if(p > c)p=c;
    j=d;
	if(d > e)j=e;
    cout<< p+j-50<<endl;
    return 0;
    }

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
const int maxn = 20000 + 10;
const int limt = 30000;
int ans[maxn],vis[limt];
long long gcd(int a,int b)
{
	return b == 0 ? a : gcd(b,a%b);
}
int main()
{
		int n;
		scanf("%d",&n);
		memset(vis,0,sizeof(vis));
		int sum = 0 ,cnt = 0;
		for(int i = 1 ; i < limt ;i ++)
		{
			if(i % 2 == 0 || i % 3 == 0)
			{
				cnt++;
				printf("%d ",i);
				vis[i] = 1;
				sum += i;
			}
			if(cnt == n-1) break;
		}
		int sum1 = sum%2;
		int sum2 = sum%3;
		for(int i = 1 ; i <= limt;i++)
		{
			if((sum1+i)%2==0&&(sum2+i)%3==0 && !vis[i] && gcd(sum,i)!=1)
			{
				printf("%d ",i);
				break;
			}
		}
		puts("");
	}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vector<bool> used(26, false);
    REP(i,(signed)s.size()){
        int32 c = s[i] - 'a';
        if(used[c]){
            cout << "no" << endl;
            return 0;
        }
        used[c] = true;
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define FORR(i, a, b) for(long long i=(a);i>=(b);i--)
#define REPR(i, N) for(long long i=n;i>=0;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ALL(s) (s).begin(),(s).end()
#define pb(a) push_back(a)

#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    int cnt_5 = 0;
    int cnt_7 = 0;
    if(A == 5) cnt_5++;
    if(B == 5) cnt_5++;
    if(C == 5) cnt_5++;
    if(A == 7) cnt_7++;
    if(B == 7) cnt_7++;
    if(C == 7) cnt_7++;

    if(cnt_5 == 2 && cnt_7 == 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
import sys

s = input()

for i in range(2**3):
    localsum = s[0]
    for j in range(3):
        if (i >> j) & 1:
            localsum += "+"
        else:
            localsum += "-"
        localsum += s[j+1]
    sum = eval(localsum)
    if sum == 7:
        localsum += "=7"
        print(localsum)
        sys.exit()

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;
#define MAX 3001

int main()
{
  char s[MAX], t[MAX];
  cin >> s >> t;

  int dp[MAX][MAX];
  memset(dp, 0, sizeof dp);

  const int sn = strlen(s);
  const int tn = strlen(t);

  FOR(i, 0, sn-1) {
    FOR(j, 0, tn-1) {
      if(s[i]==t[j]) dp[i+1][j+1] = dp[i][j] + 1;
      else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
    }
  }

  vector<char> res;
  int i = sn-1;
  int j = tn-1;
  while( i>=0 && j>=0 ) {
    if( s[i] == t[j] ) {
      res.push_back(s[i]);
      i--; j--;
    }
    else if( dp[i+1][j+1] == dp[i][j+1] ) i--;
    else j--;
  }

  reverse(res.begin(), res.end());
  for(auto it:res) cout << it;
  cout << endl;

}


Measured memory_bytes: 35456
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

S = input()

def check(S):
	if len(S)%2 == 1:
		return False
	else:
		L = len(S)//2
		return S[:L] == S[L:]

while S:
	S = S[:-1]
	if check(S):
		print(len(S))
		break


Measured memory_bytes: 3824
public class Main {


  private static void solve() {
    int n = ni();
    int t = ni();
    int ret = Integer.MAX_VALUE;
    for (int i = 0; i < n; i ++) {
      int c = ni();
      int tt = ni();
      if (tt <= t) {
        ret = Math.min(ret, c);
      }
    }
    if (ret == Integer.MAX_VALUE) {
      System.out.println("TLE");
    } else {
      System.out.println(ret);
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;


int main() {
  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  rep(i,n) cin >> m[i];
  sort(m);
  int sum = 0;
  rep(i,n) sum += m[i];
  cout << n + (x - sum) / m[0] << endl;
}
  

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var nm=Arr.shift();
   if(nm=="0 0")break;
   nm=nm.split(" ").map(Number);
   var n=nm[0];
   var m=nm[1];
   var N=[];
   var M=[];
   for(var i=0;i<n;i++)N.push(Arr.shift()-0);
   for(var i=0;i<m;i++)M.push(Arr.shift()-0);
   var sumN=N.reduce(function(a,b){return a+b;});
   var sumM=M.reduce(function(a,b){return a+b;});
   var arr=[];
   for(var i=0;i<n;i++){
      for(var j=0;j<m;j++){
         var a=sumN-N[i]+M[j];
         var b=sumM+N[i]-M[j];
         if(a==b)arr.push([N[i]+M[j],N[i],M[j]]);
      }
   }
   if(arr.length==0){console.log(-1);continue;}
   arr.sort(function(a,b){return a[0]-b[0];});
   console.log(arr[0][1]+" "+arr[0][2]);
}

Measured memory_bytes: 10880
#include<map>
#include<set>
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;

int dp[42][410][410];
int a[42],b[42],c[42];
int n,ma,mb;

int main()
{
	scanf("%d%d%d",&n,&ma,&mb);
	memset(dp,0x3f,sizeof(dp));
	for(int i=0; i<n; i++)
	{
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	dp[0][0][0]=0;
	for(int i=0; i<n; i++)
	{
		for(int j=0; j<=400; j++)
		{
			for(int k=0; k<=400; k++)
			{
				if(dp[i][j][k]==inf)
				{
					continue;
				}
				dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k]);
				dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
			}
		}
	}
	int ans=inf;
	for(int i=1;i<=400;i++)
	{
		for(int j=1;j<=400;j++)
		{
			if(i*ma==j*mb)
			{
				ans=min(ans,dp[n][j][i]);
			}
		}
	}
	printf("%d\n",ans>=inf?-1:ans);
}

Measured memory_bytes: 27776
from collections import defaultdict
from collections import deque
INF = 10 ** 10
edges = defaultdict(dict)


def add_edge(frm, to, capacity):
    edges[frm][to] = capacity
    edges[to][frm] = 0


def bfs(start, goal):
    """
    update: distance_from_start
    return bool: can reach to goal
    """
    global distance_from_start
    distance_from_start = [-1] * len(edges)
    queue = deque()
    distance_from_start[start] = 0
    queue.append(start)
    while queue and distance_from_start[goal] == -1:
        frm = queue.popleft()
        for to in edges[frm]:
            if edges[frm][to] > 0 and distance_from_start[to] == -1:
                distance_from_start[to] = distance_from_start[frm] + 1
                queue.append(to)

    return distance_from_start[goal] != -1


def dfs(current, goal, flow):
    """
    make flow from `current` to `goal`
    update: capacity of edges, iteration_count
    return: flow (if impossible: 0)
    """
    if current == goal:
        return flow
    i = itertion_count[current]
    while itertion_count[current] < len(edges[current]):
        to = edges_index[current][i]
        capacity = edges[current][to]
        if capacity > 0 and distance_from_start[current] < distance_from_start[to]:
            d = dfs(to, goal, min(flow, capacity))
            if d > 0:
                edges[current][to] -= d
                edges[to][current] += d
                return d
        itertion_count[current] += 1
        i += 1
    return 0


def max_flow(start, goal):
    """
    return: max flow from `start` to `goal`
    """
    global itertion_count, edges_index
    flow = 0
    edges_index = {
        frm: list(edges[frm]) for frm in edges
    }
    while bfs(start, goal):
        itertion_count = [0] * len(edges)
        f = dfs(start, goal, INF)
        while f > 0:
            flow += f
            f = dfs(start, goal, INF)
    return flow


def main():
    # Verified: https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/6/GRL_6_A
    V, E = map(int, input().split())
    for _i in range(E):
        v1, v2, capacity = map(int, input().split())
        add_edge(v1, v2, capacity)
    print(max_flow(0, V - 1))


main()



Measured memory_bytes: 6080
#include <iostream>
#include <algorithm>
#pragma gcc optimize("O3")
#pragma gcc optimize("unroll-loops")
#pragma gcc target("avx2,see4")
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  long long x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  long long p[a], q[b], r[c+x+y];
  for(long long i = 0; i < a; i++)cin >> p[i];
  sort(p, p+a);
  for(long long i = 0; i < a; i++)if(i<a-x)p[i]=-1;
  for(long long i = 0; i < b; i++)cin >> q[i];
  sort(q, q+b);
  for(long long i = 0; i < b; i++)if(i<b-y)q[i]=-1;
  for(long long i = 0; i < c; i++)cin >> r[i];
  for(long long i = 0; i < x; i++)r[i+c]=p[a-1-i];
  for(long long i = 0; i < y; i++)r[i+c+x]=q[b-1-i];
  sort(r, r+c+x+y);
  long long sum=0;
  for(long long i = 0; i < x+y; i++)sum+=r[c+x+y-1-i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3968
#include <stdio.h>

int Con(int n, int k, int s){
	if(s < 0) return 0;
	if(k > n) return 0;
	if(k == 0) return s == 0 ? 1 : 0;
	return Con(n - 1, k - 1, s - n) + Con(n - 1, k, s);
}

int main (){
	int n, k, s;

	while (1) {
		scanf("%d %d %d", &n, &k, &s);
		if(n == 0 && k == 0 && s == 0)
			return 0;
		printf("%d\n", Con(n, k, s));
	}
}



Measured memory_bytes: 2568
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut ite = s.trim().split_whitespace();
    let r = ite.next().unwrap().to_string();
    let g = ite.next().unwrap().to_string();
    let b = ite.next().unwrap().to_string();
    let ss = r + &g + &b;
    let ret: i32 = ss.parse().unwrap();
    if ret % 4 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
l,r = map(int, input().split())
n = r - l + 1
if 2019<=n:
    print(0)
else:
    mod = 2019
    for i in range(l,r):
        for j in range(l+1,r+1):
            mod_new = (i*j)%2019
            mod = min(mod,mod_new)
    print(mod)                         

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

int main() {
	string S;
	cin >> S;
	while(!S.empty())
	{
	    if(S.substr(0,5)=="dream")
	    {
	        S.erase(S.begin() + 0, S.begin() + 5);
	        if(S.substr(0,2)=="er" && S[2]!='a') S.erase(S.begin() + 0, S.begin() + 2);
	    }
	    else if(S.substr(0,5)=="erase")
	    {
	        S.erase(S.begin() + 0, S.begin() + 5);
	        if(S[0]=='r') S.erase(S.begin() + 0);
	    }
	    else break;
	}
	if(S.empty()) cout << "YES" << endl;
	else cout << "NO" <<endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000;
const int MOD = (int)1e9 + 7;


signed main()
{
    int l, r;
    cin >> l >> r;
    int L = l % 2019;
    int R = r % 2019;
    int minV = INF;
    if (r - l >= 2019) {
        cout << 0 << "\n";
        return 0;
    }
    if (L >= R) R += 2019;
    for (int i = L; i < R + 1; i++)
    {
        for (int j = i + 1; j < R + 1; j++)
        {
            int mod = (i * j) % 2019;
            minV = min(minV, mod);
        }
    }
    cout << minV << "\n";
}

Measured memory_bytes: 256
package main

/*
深さ優先探索
*/

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

func main() {
	scanner := makeScanner(8192)
	n := eGetInt(scanner)
	g := make([][]int, n+1)
	for i := 1; i < n+1; i++ {
		ints := eGetInts(scanner)
		num, vcount := ints[0], ints[1]
		g[i] = make([]int, vcount)
		for j := 0; j < vcount; j++ {
			g[num][j] = ints[j+2]
		}
	}
	hist := make([]struct{ d, f int }, n+1)
	t := 0
	var visit func(int)
	visit = func(num int) {
		if hist[num].d == 0 {
			stack := []int{}
			t++
			hist[num].d = t
			stack = append(stack, num)
			for len(stack) > 0 {
				// トップを訪問する
				top := stack[len(stack)-1]
				for i := 0; i < len(g[top]); i++ {
					if hist[g[top][i]].d == 0 {
						t++
						hist[g[top][i]].d = t
						stack = append(stack, g[top][i])
						goto endloop
					}
				}
				// 訪問場所がなくなったら
				// pop
				stack = stack[0 : len(stack)-1]
				t++
				hist[top].f = t
			endloop:
			}
		}
	}
	for i := 1; i < n+1; i++ {
		visit(i)
	}
	for i := 1; i < n+1; i++ {
		fmt.Println(i, hist[i].d, hist[i].f)
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}



Measured memory_bytes: 1144
Q=[]
A=->*x{Q<<[?+,*x]*" "}
C=->*x{Q<<[?<,*x]*" "}

C[2,0,403]
0.upto(30){|i|
 A[403+i,403+i,404+i]
}

def to_b(x,s)
 A[x,403,x]
 31.downto(0){|i|
  A[403+i,s+33,s+32]
  C[s+32,x,s+i]
  A[s+i,2,s+32]
  i.times{A[s+32,s+32,s+32]}
  A[s+32,s+33,s+33]
 }
end

to_b(0,67)
to_b(1,195)

30.times{|i|
 30.times{|j|
  A[67+i,195+j,324]
  C[403,324,325]
  A[2+i+j,325,2+i+j]
 }
}

57.downto(0){|i|
 2.times{A[2+i,3+i,2+i]}
}

puts Q.size,Q

Measured memory_bytes: 14820
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

bool pc1(const P& firstElof, const P& secondElof)
{//first降順
	return firstElof.first > secondElof.first;
}
bool pc2(const P& firstElof, const P& secondElof)
{//first昇順
	return firstElof.first < secondElof.first;
}
bool pc3(const P& firstElof, const P& secondElof)
{//second降順
	return firstElof.second > secondElof.second;
}
bool pc4(const P& firstElof, const P& secondElof)
{//second昇順
	return firstElof.second < secondElof.second;
}
int main() {
	ll A, B;
	cin >> A >> B;
	ll ans = A;
	if (B - A < 8) {
		FOR(i, A+1, B + 1) {
			ans=ans xor i;
		}
	}
	else {
		for(ll i=A+1; i%4!=0; i++) {
			ans = ans xor i;
		}
		for(ll i=B; i%4!=3; i--) {
			ans = ans xor i;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];
	int ans = 0;
	while (1) {
		bool F = 1;
		REP(i, N) {
			if (A[i] >= N) {
				int tmp = A[i] / N;
				ans += tmp;
				A[i] %= N;
				REP(j, N) if (i != j) {
					A[j] += tmp;
				}
				F = 0;
			}
		}
		if (F)break;
	}

	cout << ans << endl;




	return 0;
}



Measured memory_bytes: 256
N, U, V = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N - 1)]

graph = [[] for _ in range(N + 1)]
for A, B in AB:
  graph[A].append(B)
  graph[B].append(A)

INF = 10 ** 15
dist_U = [INF] * (N + 1)
dist_V = [INF] * (N + 1)

def dfs(start, dist):
  stack = [start]
  dist[start] = 0
  
  while stack:
    s = stack.pop()
    for g in graph[s]:
      if dist[g] > dist[s] + 1:
        dist[g] = dist[s] + 1
        stack.append(g)

dfs(U, dist_U)
dfs(V, dist_V)
#print("dist_U", dist_U)
#print("dist_V", dist_V)

answer = []
for i in range(1, N + 1):
  if dist_U[i] < dist_V[i]:
    answer.append(dist_V[i] - 1)
print(max(answer))

Measured memory_bytes: 80984
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	string s;
	cin>>s;
	long long a=0,b=0,c=0,count=0;
	for(int i=0;i<n;i++){
		if(s[i]=='R')
		a++;
		else if(s[i]=='G')
		b++;
		else if(s[i]=='B')
		c++;
	}
	count=a*b*c;
	long long k;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i<j){
				k=2*j-i;
			}
			if(s[i]!=s[j] && s[i]!=s[k] && s[j]!=s[k] && k<n)
            count--;
		}
	}
	cout<<count<<endl;
	return 0;
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int base[70];
int a[207];

int32_t main()
{
    IOS
    int t;
    cin>>t;
    while (t--)
    {
        int n;
        cin>>n;
        for (int i=1;i<=n;i++) cin>>a[i];
        string s;
        cin>>s;

        memset(base,0,sizeof(base));
        int ok=0;
        for (int i=n;i>=1;i--)
        {
            int used=0;
            for (int j=61;j>=0;j--)
            {
                if ((1ll<<j)&a[i])
                {
                    if (base[j]==0)
                    {
                        base[j]=a[i];
                        used=1;
                        for (int k=j-1;k>=0;k--)
                            if (base[k]&&(base[j]&(1ll<<k))) base[j]^=base[k];
                        for (int k=j+1;k<=61;k++)
                            if (base[k]&(1ll<<j)) base[k]^=base[j];
                        break;
                    }
                    else a[i]^=base[j];
                }
            }
            if (used&&s[i-1]=='1') ok=1;
        }
        cout<<ok<<endl;
    }
}


Measured memory_bytes: 3564
import fractions

A, B =list(map(int, input().split()))
D = fractions.gcd(A,B)
arr = []
temp = D
if D == 1:
  pass
else:
  for i in range(2, int(-(-D**0.5//1)+1)):
    if temp%i == 0:
      while temp%i == 0:
        temp //= i
      arr.append(i)
  if temp != 1:
    arr.append(D)
print(len(arr)+1)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  int N,L;
  cin>>N>>L;
  vector<string>s(N);
  for(int i=0;i<N;i++){
    cin>>s[i];
  }
  sort(s.begin(),s.end());
  for(int i=0;i<N;i++){
    cout<<s[i];
  }cout<<endl;
  return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<queue>
#include<map>
using namespace std;
bool b[100005];
int main(){
	int n,l;
	int i,j,k;
	int a,c;
	int s=0;
	cin>>n>>l;
	for(i=0;i<n;i++){
		a=c;
		cin>>c;
		if(i==0)continue;
		if(a+c>=l){
			b[i-1]=true;
			s++;
		}
	}
	if(s==0){
		cout<<"Impossible"<<endl;
		return 0;
	}
	cout<<"Possible"<<endl;
	i=0;
	while(1){
		if(b[i]){
			s--;
		}
		if(s==0)break;
		cout<<i+1<<endl;
		i++;
		if(i==n)break;
	}
	for(j=n-1;j>i;j--){
		cout<<j<<endl;
	}
	return 0;
}
	
			
		

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define N 400000
#define int ll
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct edge
{
	int v,next;
}vs[N<<1];
int n,m,ee,st[N],tmp,tot,x,y,z,vis[N],col[N];
inline void addedge(int u,int v)
{
	vs[++ee].v=v;vs[ee].next=st[u];st[u]=ee;
}
void dfs(int x,int pr)
{
	tot++; vis[x]=1;
	for(int i=st[x];i;i=vs[i].next)
	{
		if(vs[i].v==pr) continue;
		if(vis[vs[i].v])
		{
			if(col[vs[i].v]==col[x]) tmp=1;
		}
		else col[vs[i].v]=-col[x],dfs(vs[i].v,x);
	}
}
signed main()
{
	n=read(); m=read();
	for(int i=1;i<=m;i++)
	{
		int u=read(),v=read();
		addedge(u,v); addedge(v,u);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			tot=0; tmp=0; col[i]=1; dfs(i,0);
			if(tmp) z++;
			else if(tot==1) x++;
			else y++;
		}
	cout<<1ll*2*x*(n-x)+1ll*x*x+1ll*2*y*y+1ll*2*y*z+1ll*z*z<<endl;
}

Measured memory_bytes: 15104
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll,ll>

using namespace std;
typedef long long ll;



int main(void) {
	int n; cin >> n;
	int m=1e9,cnt=0;
	rep(i, n) {
		int x;
		cin >> x;
		if (m > x) {
			cnt++;
		}
		m = min(x, m);;
	}
	cout << cnt<< endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < n; i++ ) {
			h[i] = scanner.nextInt();
		}
		int highest = 0;
		int result = 0;
		for (int i = 0; i < n; i++) {
			if (h[i] >= highest) {
				result++;
				highest = h[i];
			}
		}
		
		System.out.println(result);
		
	}

}

Measured memory_bytes: 21460
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int main() {
	int n;
	vector<PII> ret;
	cin >> n;
	int rem = n;
	int s = (n / 2) * 2 + 1;
	set<int> si;
	REP(i, n)si.insert(i + 1);
	REP(i, n/2) {
		int x = i + 1;
		int y = s - x;
		si.erase(x);
		si.erase(y);
		for (auto z : si) {
			ret.PB(MP(x, z));
			if(x!=y)ret.PB(MP(y, z));
		}
	}
	printf("%d\n", ret.size());
	REP(i, ret.size()) {
		printf("%d %d\n", ret[i].first, ret[i].second);
	}
	return 0;
}

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

#define ll long long
const int MOD = 1e9+7;
ll mod(ll x) {
	return (x%MOD + MOD) %MOD;
}
ll mul(ll a,ll b) {
	return mod(mod(a) * mod(b));
}

int n,m,K;

bool issafe(int x,int y) {
	return (x>=0 && x < n) && (y>=0 && y<m);
}

int main() {
	
	cin >> n >> m >> K;
	int sx,sy,ex,ey;
	cin >> sx >> sy >> ex >> ey;
	--sx,--sy,--ex,--ey;
	vector<string> grid(n);
	for(int i = 0;i<n;i++)
		cin >> grid[i];
	vector<vector<int>> dis(n,vector<int>(m,-1));
	dis[sx][sy] = 0;
	int dx[4] = {-1,1,0,0};
	int dy[4] = {0,0,1,-1};
	queue<pair<int,int>> q;
	q.push({sx,sy});
	while(!q.empty()) {
		auto c = q.front();
		q.pop();
		auto cx = c.first,cy = c.second;
		//cout << cx << " " << cy << " " << dis[cx][cy] << endl;
		for(int i = 0;i < 4; i++) {
			for(int k = 1; k <= K;k++) {
				int nx = cx + (dx[i] * k);
				int ny = cy + (dy[i] * k);
				if(!issafe(nx,ny) || grid[nx][ny] == '@') break;
				else
				{
					if(dis[nx][ny] == -1 ) 
					{
						dis[nx][ny] = 1 + dis[cx][cy];
						q.push({nx,ny});
					}	
					else if(dis[nx][ny] >= dis[cx][cy]+1) {
					    	dis[nx][ny] = 1 + dis[cx][cy];
					}
					else
						break;	
				}
			}
		}
	}
/*	for(int i = 0;i<n;i++)
	{
		for(int j = 0;j <m;j++)
			cout << dis[i][j] << " ";
		cout << endl;
	}*/
	if(dis[ex][ey] == -1) 
		cout << -1 << endl;
	else
		cout << dis[ex][ey] << endl;
	return 0;
}

Measured memory_bytes: 12028
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N; cin >> N;
    vec A(N); readvec(A);

    int ans = 0;

    if(A[0] > 0){
        cout << -1;
        return 0;
    }

    int z = N;
    N--;
    while(N >= 0){
        if(A[N] > N || N - A[N] > z){
            cout << -1;
            return 0;
        }
        z = N - A[N];
        int n = N, a = A[N];
        ans += a;
        REP(i, n + 1){
            if(A[n - i] != a - i) break;
            N--;
        }
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
int a[101], n;
ll found(int x)
{
    ll sum = 0;
    for(int i=1; i<=n; i++)
        sum += (a[i] - x) * (a[i] - x);
    return sum;
}
int main()
{
    ll sum = 1e9;
    scanf("%d", &n);
    for(int i=1; i<=n; i++)
        scanf("%d", &a[i]);
    for(int i=1; i<=100; i++)
        if(sum > found(i))
            sum = found(i);
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1e9+7;


ll dp[100001][13]={0};
int main(){
    int N,H; cin>>N>>H;
    vector<int> a(N),b(N);
    for (int i = 0; i < N; ++i) {
        cin>>a[i]>>b[i];
    }
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    int maxa=a[0];
    int ans=0;
    for(int i=0;i<N;i++){
        if(b[i]<maxa) break;
        ans++;
        if(b[i]>=H){
            cout<<ans<<endl;
            return 0;
        }
        H-=b[i];
    }

    ans+=(H-1)/maxa+1;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

int main(){
  int N, T;
  cin >> N >> T;
  vector<int> A(N);
  REP(i, 0, N) cin >> A[i];
  int cnt = 0;
  int dis = 0;
  int m = A[0];
  REP(i, 1, N) {
    if (m < A[i]) {
      if (dis == A[i] - m) {
	cnt++;
      } else if (dis < A[i] - m) {
	cnt = 1;
	dis = A[i] - m;
      }
    }
    m = min(m, A[i]);
  }
  cout << cnt << endl;
  return 0;
}


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

main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,k,l,m,n,p;
 while(cin>>n){
       int x[100000]={0};
       for(i=1;i<=100;i++){
        for(j=1;j<=100;j++)
        for(k=1;k<=100;k++){
            int a=i*i+j*j+k*k;
            a+=(i*j)+(i*k)+(j*k);
           
            x[a]++;
        }
       }
       for(i=1;i<=n;i++)
        cout<<x[i]<<endl;

 }


    return 0;

}


Measured memory_bytes: 3892
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    k, x = map(int, input().split())
    print("Yes" if k * 500 >= x else "No")


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 28908
#include<bits/stdc++.h>
#define panjang pair<long long, long long>
using namespace std;
long long n, m, a, ans, cost[10], Distance[10][10], banyak = 9 * (1e18 + 7);
int main()
{
    cin>> n >> m;
    for(int i = 0; i <= 9; i++)
        for(int j = 0; j <= 9; j++) cin>> Distance[i][j];

    vector<int> v;

    for(int s = 0; s <= 9; s++)
    {
        for(int i = 0; i <= 9; i++) cost[i] = banyak;

        cost[s] = 0;

        priority_queue< panjang, vector< panjang >, greater< panjang > > Pq;
        Pq.push(make_pair(0, s));
        while(!Pq.empty())
        {
            long long jarak = Pq.top().first;
            long long ind = Pq.top().second;
            Pq.pop();

            if(jarak > cost[ind]) continue;

            for(int i = 0; i <= 9; i++)
            {
                long long wrap = jarak + Distance[ind][i];
                if(wrap < cost[i])
                {
                    cost[i] = wrap;
                    Pq.push(make_pair(wrap, i));
                }
            }
        }
        v.push_back(cost[1]);
    }
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
        {
            cin>> a;
            if(a != -1) ans+= v[a];
        }
    cout<< ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

const int MAXN = (int)1e5 + 1;
const int P = (int)1e9 + 7;

int a[MAXN];
int num[MAXN];

int64_t solve(int n) {
  int64_t res = 1;
  num[0] = 3; 
  for (int i = 0; i < n; ++i) {
    res = res * num[a[i] - 1] % P;
    --num[a[i] - 1];
    ++num[a[i]];
  }
  return res;
}

int main() {
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
    ++a[i];
  }
  std::cout << solve(n) << std::endl;
  return 0;
}


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

int main(){
    int n,d,human,h;

    scanf("%d",&n);
    scanf("%d",&d);
    human=d*2+1;

    h=n%human;

    if(h==0){
        printf("%d",n/human);
    }else{
        printf("%d",n/human+1);
    }

}


Measured memory_bytes: 128
s=0
j=0
a=[]
k=[]
l=[]
for i,x in enumerate(input()):
    if x=='\\':
        a+=[i]
    elif x=='/' and a:
        j=a.pop()
        y=i-j;s+=y
        while k and k[-1]>j:
            y+=l.pop()
            k.pop()
        k+=[j]
        l+=[y]
print(s)
print(len(k),*(l))


Measured memory_bytes: 6244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;
const double pi = acos(-1);
const int mod = 998244353;
const double eps = 1e-8;
void bfs(int n){
	int cnt = 0;
	priority_queue <ll,vector<ll>,greater<ll> > q;
	for(int i = 1;i <= 9;i++) q.push(i);
	while(!q.empty()){
		ll x = q.top();
		q.pop();
		cnt++;
		if(cnt == n){
			printf("%lld\n",x);
			return ;
		}
		ll tmp = x %10;
		if(tmp-1ll >= 0ll) q.push(x*10ll+tmp-1ll);
		if(tmp >= 0) q.push(x*10ll+tmp);
		if(tmp+1ll <= 9ll) q.push(x*10ll+tmp+1ll);
	}
	return;
}
int main(){
	int n;
	scanf("%d",&n);
	bfs(n);
    return 0;
}

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

vector<vector<int>> g(100001);
vector<int> d_corbeau(100001, -1), d_saba(100001, -1);

void dfs1(int now, int depth){
    d_corbeau[now] = depth;
    rep(i, g[now].size()){
        int next = g[now][i];
        if(d_corbeau[next] == -1) dfs1(next,depth+1);
    }
}

void dfs2(int now, int depth){
    d_saba[now] = depth;
    rep(i, g[now].size()){
        int next = g[now][i];
        if(d_saba[next] == -1) dfs2(next,depth+1);
    }
}

int main(){
    int n, corbeau, saba; cin >> n >> corbeau >> saba;
    corbeau--; saba--; // なんかさばって人がめっちゃ追いかけてくるんですけど！
    int a,b;
    rep(i,n-1){
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs1(corbeau,0);
    dfs2(saba,0);
    int max=-1, max_node;
    rep(i,n){
        if(d_corbeau[i] < d_saba[i] && d_saba[i] > max){
            //max_node = i;
            max = d_saba[i];
        }
    }
    //int dis = d_corbeau[saba];
    cout << max-1 << "\n";
}


Measured memory_bytes: 9088