akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

fn solve() {
	let (s,w) = read!(i64,i64);
	if w>=s {
		println!("unsafe");
	}
	else{
		println!("safe");
	}
}

fn run() {
    solve();
}


Measured memory_bytes: 2236
import sys

from collections import deque
# q = deque(); q.append(x); q.appendleft(x); q.pop() -> x; q.popleft() -> x
from collections import defaultdict
# d = defaultdict(lambda: []); d[key] -> []
import heapq
# hq = []; heapq.heappush(hq, x); heapq.heappop(hq) -> x; heapq.heappushpop(hq, x) -> x
import bisect
# i = bisect.bisect_left([1,2,3,4], 1.5); i = bisect.bisect_right([4,3,2,1], 1.5)

#import numpy as np
#from scipy.misc import comb

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    W = i2nn()
    n = 1e+9
    for i in range(N):
        a = sum(W[:i])
        b = sum(W[i:])
        c = abs(a - b)
        if c < n:
            n = c
    print(n)

main()


Measured memory_bytes: 38384
def partition(A, p, r):
    x = A[r]
    i = p
    for j in range(p, r):
        if A[j] <= x:
            A[i], A[j] = A[j], A[i]
            i += 1

    A[i], A[r] = A[r], A[i]
    return i


n = int(input())
A = [int(i) for i in input().split()]
r = partition(A, 0, n - 1)

ans = [str(a) for a in A]
ans[r] = "[{}]".format(ans[r])

print(" ".join(ans))



Measured memory_bytes: 16596
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
using namespace std;
int main()
{
 	speed_up
    ll n;cin>>n;
    ll v[n];
    for(ll i=0;i<n;i++)
     cin>>v[i];
     sort(v,v+n);
     double sum=0,curr=((double)v[0]+(double)v[1])/2.0;
     for(ll i=2;i<n;i++)
     {
     	curr=(curr+(double)v[i])/2.0;
	 }
	 printf("%.12f",curr);
    
	
	
	
 return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;

int sum[200005],pr[200005],pr2[200005];

int main()
{
	int n,k,a,i;
	
	while(scanf("%d %d",&n,&k)!=EOF)
	{
		for(i=0;i<n;++i)
		{
			scanf("%d",&a);
			sum[a]++;
			pr[i]=a;
		} 
	sort(pr,pr+n);
	pr2[0]=sum[pr[0]];
	for(i=1;i<n;++i)
	{
		if(pr[i]!=pr[i-1])
		pr2[i]=sum[pr[i]];
		//printf("%d\n",sum[i]);
	} 
	sort(pr2,pr2+n);
	int sss=0;
	
	for(i=0;i<n-k;++i)
	{
			sss+=pr2[i];

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

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void){
    string s;
    cin >> s;
    if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) cout << "Yes" << endl;
    else if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) cout << "Yes" << endl;
    else if (s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

mod = 1000000007
INF = 110110110
_INFL = -INF * INF

N, K = list(map(int, input().split()))
ans = 0

for i in range(K, N+2):
    add = (N-i+1+N) * i // 2 - (i-1) * i // 2 + 1
    add %= mod
    ans += add
    ans %= mod
print(ans)


Measured memory_bytes: 9192
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//M 77 || //A 65 || //R 82 || //C 67 || //H 72 || 
		int N=sc.nextInt();
		
		int v[]=new int[N+1];
		int ans=0;
		for(int i=0;i<N;i++) {
			int a=sc.nextInt();
			if(a>N)ans++;
			else v[a]++;
		}
		
		
		
		for(int i=0;i<=N;i++) {
			if(v[i]==i)continue;
			else if(v[i]>i)ans+=v[i]-i;
			else if(v[i]<i)ans+=v[i];
		}
		p(ans);
		
		
		
	}

	

	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int A[511][511];
void rec(int L, int R, int depth) {
    if (L+1 >= R) return;
    int mid = (L+R)/2;
    for (int i=L; i<mid; i++) for (int j=mid; j<R; j++) {
	A[i][j] = A[j][i] = depth;
    }
    rec(L, mid, depth+1);
    rec(mid, R, depth+1);
}

int N;

void MAIN() {
    scanf("%d", &N);
    rec(0, N, 1);
    REP (i, N-1) {
	rprintf("%d", A[i]+i+1, A[i]+N);
    }

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

int main(){
  int n, m, A[100][100], b[100], c[100];

  cin >> n >> m;
  for ( int i = 0; i < n; i++ )
    for ( int j = 0; j < m; j++ ) cin >> A[i][j];
  for ( int i = 0; i < m; i++ ) cin >> b[i];

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

for ( int i = 0; i < n; i++ ) cout << c[i] << endl;

return 0;
} 


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

int main() {

  long long int A, B;
  cin >> A >> B;
  for (int i = 1; i <= B; i++) {
    if (A * i % B == 0) {
      cout << A * i << endl;
      break;
    }
  }
  
    
}


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

int main(){
	int dp[51];
	int amo[6] = { 2, 3, 5, 10, 12, 15 };
	int pri[6] = { 380, 550, 850, 1520, 1870, 2244 };
	dp[0] = 0;
	for( int i=1; i<=50; i++ ){
		dp[i] = (1<<30);
	}
	for( int i=0; i<6; i++ ){
		for( int j=0; j+amo[i]<51; j++ ){
			dp[j+amo[i]] = min( dp[j+amo[i]], dp[j]+pri[i] );
		}
	}
	int n;
	while( cin >> n, n ){
		cout << dp[n/100] << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
const int N= 1e5 + 10;
inline void fastio()
{ 
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}


int main()
{
    int A, B, C, D;
    int turnA, turnC;
    cin >> A >> B >> C >> D;
    turnA = C / B;
    turnA += (C % B) ? 1 : 0;
    turnC = A / D;
    turnC += (A % D) ? 1 : 0;
    if(turnA<=turnC)
    {
        cout << "Yes";
    }
    else
        cout << "No";
    return 0;
}



Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int number = sc.nextInt();
		sc.close();

		String str = String.valueOf(number);
		String result = "No";
		for(char ch : str.toCharArray()) {
			if ('7' == ch) {
				result = "Yes";
				break;
			}
		}

		System.out.print(result);
	}

}


Measured memory_bytes: 35832
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    string A,B,C;cin>>A>>B>>C;
    const int up='A'-'a';
    cout<<char(A[0]+up)<<(char)(B[0]+up)<<char(C[0]+up)<<endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
//template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int n;
  cin>>n;
  cout<<n*n*n<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int n, x, max, min,  i;
    long int sum=0;
    scanf("%d", &n);
    for (i=0; i<n; i++){
        scanf("%d", &x);
        sum+=x;
        if(i==0) max=x;
        else if (x>max) max=x;
        if(i==0) min=x;
        else if (x<min) min=x;
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
    
}



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

int main(void) {
    char word[32];
    char str[100];
    int count;
    
    cin >> word;
    count = 0;
    while(cin >> str) {
        for(int i = 0; i < strlen(str); ++i) {
            if(isupper(str[i])) {
                str[i] = tolower(str[i]);
            }
        }
        if(strstr(str, "END_OF_TEXT"))   break;
        if(strstr(str, word) && strlen(str) == strlen(word))   ++count;
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 3072
def factor(n):
    l = []
    for i in range(1,n+1):
        if n%i == 0:
            l.append(i)
    return l

c = 0
n = int(input())

for i in range(1,n+1,2):
    if len(factor(i)) == 8:
        c += 1
print(c)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int keta(int64_t S){
  string str = to_string(S);
  return str.size();
}
int main(){
  int64_t S;
  cin >> S;
  int64_t sum = 0;
  int counter = 0;
  bool flag = false;
  for(int tmp = 0; tmp < (1 << 9); tmp++){
    counter++;
    bitset<9> a(tmp);
    int64_t N = S;
    int sep = 10;
    int k = keta(S);
    for(int i = 0; i < k-1; i++){
      if(a.test(i)){
        sum += N % sep;
        N -= N % sep;
        N /= sep;
        sep = 10;
      }
      else sep *= 10;
    }
    sum += N;
    if(counter == 1 << (k-1)) flag = true;
    if(flag) break;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	long N, K;
	string S;

	cin >> N >> K;
	cin >> S;

	int A[N];

	char now = S[0];
	long count=1, a=0;

	for(long i = 1; i < N; i++){
		if(now == S[i]){
			count++;
		} else {
			A[a++] = count;
			count=1;
			now = S[i];
		}
	}
	if(count != 0) A[a++] = count;

	long mans = 0, idx=0, ans=0, odd=0;
	if(S[0] == '1'){
		ans += A[0];
		idx = 1;
		odd=1;
	}

	for(;idx < a; idx+=2){
		ans += A[idx];
		if(idx+1 < a) ans += A[idx+1];
		if(idx-odd >= 2*K) ans -= A[idx - 2*K];
		if(idx-odd+1 >= 2*K) ans -= A[idx - 2*K-1];
		mans = max(mans, ans);
	}
	mans = max(mans, ans);

	cout << mans << endl;

	return 0;
}


Measured memory_bytes: 896
N, M = map(int, input().split())
kaidan = [True] * (N+2)
for i in range(M):
    kaidan[int(input())] = False

dp = [0]*(N+2)
dp[0] = 1
for i in range(N):
    if kaidan[i+2]:
        dp[i+2] += dp[i]
        dp[i+2] %= 1000000007
    if kaidan[i+1]:
        dp[i+1] += dp[i]
        dp[i+1] %= 1000000007

print(dp[N])


Measured memory_bytes: 47192
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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;
}

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) {
        cout << 1 << endl;
    } else if (a == b || b == c || c == a) {
        cout << 2 << endl;
    } else {
        cout << 3 << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int s,m,h;

	scanf("%d",&s);
	h=s/3600;
	s=s-h*3600;

	m=s/60;
	s=s-m*60;

	printf("%d:%d:%d\n", h,m,s);
	return 0;
}

Measured memory_bytes: 592
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

int main() {
  string s, t;
  cin >> s >> t;
  ll ans = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != t[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3836
r, g, b, n = [ int(v) for v in input().split() ]
r, g, b = sorted([r, g, b],reverse = True)

ans = 0
for i in range((n+r)//r):
    n1 = n - r * i
    for j in range((n1+g)//g):
        n2 = n1 - g * j
        if n2 % b == 0:
            ans += 1
print(ans)

Measured memory_bytes: 41436
#include <iostream>

using namespace std;

int main()
{
  int A ,B,num;
  cin>>A>>B;
  num=A*B;
if ( A < 10 &&  B < 10 )
  {
    cout<<num;
  }
else
   {
    cout<<"-1";
   }

    return 0;
}


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

using namespace std;
typedef long long ll;

struct edge {
  int to, cost;
  edge() {}
  edge(int t, int c) : to(t), cost(c) {}
};

int n, m;
vector<edge> g[100010];
vector<int> d(100010);
vector<bool> used(100010);

bool dfs(int v) {
  bool res = true;
  for (auto &e : g[v]) {
    if (used[e.to]) {
      if (d[e.to] == d[v] + e.cost) continue;
      return false;
    }
    used[e.to] = true;
    d[e.to] = d[v] + e.cost;
    res &= dfs(e.to);
  }
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--, r--;
    g[l].push_back(edge(r, d));
    g[r].push_back(edge(l, -d));
  }

  for (int i = 0; i < n; i++) {
    if (used[i]) continue;
    used[i] = true;
    d[i] = 0;
    if (!dfs(i)) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";

  return 0;
}

Measured memory_bytes: 12032
fun main(args: Array<String>) {
    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    var array = IntArray(n){0}
    for(i in 0 until k){
        val d = readLine()!!.toInt()
        val a = readLine()!!.split(" ").map { it.toInt() }
        for(el in a){
            array[el-1]++
        }
    }
    val ans = array.filter { it == 0 }.size
    println(ans)
}

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

using namespace std;

typedef long long ll;

int readint(){
	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;
}

const int cys=1000000007;
int n,k,m;
ll d[25005][405],s[25005][405],a[25005],cnt[405],pw[25005],fac[405],inv[405];
bool vis[405];

ll mod(ll x){return x>=cys?x-cys:x;}

ll qpow(ll x,ll p){
	ll ret=1;
	for(;p;p>>=1,x=x*x%cys) if(p&1) ret=ret*x%cys;
	return ret;
}

int main(){
	n=readint(); k=readint(); m=readint();
	for(int i=1;i<=m;i++) a[i]=readint();
	d[0][k]=s[0][k]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<k;j++) d[i][j]=(d[i-1][j+1]*(k-j)+s[i-1][j])%cys;
		d[i][k]=d[i-1][k]*k%cys;
		for(int j=1;j<=k;j++) s[i][j]=mod(s[i][j-1]+d[i][j]);
	}
	if(m>=k){
		int num=0,fl=0;
		for(int i=1;i<=k;i++){
			cnt[a[i]]++;
			if(cnt[a[i]]==1) num++;
			else if(cnt[a[i]]==2) num--;
		}
		if(num==k) fl=1;
		for(int i=k+1;i<=m;i++){
			cnt[a[i]]++;
			if(cnt[a[i]]==1) num++;
			else if(cnt[a[i]]==2) num--;
			cnt[a[i-k]]--;
			if(cnt[a[i-k]]==1) num++;
			else if(cnt[a[i-k]]==0) num--;
			if(num==k) fl=1;
		}
		if(fl){
			printf("%lld\n",qpow(k,n-m)*(n-m+1)%cys);
			return 0;
		}
		int lf=k,rg=m-k+1;
		for(int i=1;i<=m;i++){
			if(vis[a[i]]){
				lf=i-1;
				break;
			}
			vis[a[i]]=1;
		}
		for(int i=1;i<=k;i++) vis[i]=0;
		for(int i=m;i>=1;i--){
			if(vis[a[i]]){
				rg=i+1;
				break;
			}
			vis[a[i]]=1;
		}
		ll ans=0;
		for(int i=1;i<=n-m+1;i++){
			ans=(ans+qpow(k,n-m)-(qpow(k,i-1)-d[i-1][lf])*(qpow(k,n-(i+m-1))-d[n-(i+m-1)][m-rg+1]))%cys;
			ans=mod(ans+cys);
		}
		printf("%lld\n",ans);
	}
	else{
		int lf=m,rg=1;
		for(int i=1;i<=m;i++){
			if(vis[a[i]]){
				lf=i-1;
				break;
			}
			vis[a[i]]=1;
		}
		for(int i=1;i<=k;i++) vis[i]=0;
		for(int i=m;i>=1;i--){
			if(vis[a[i]]){
				rg=i+1;
				break;
			}
			vis[a[i]]=1;
		}
		pw[0]=1;
		for(int i=1;i<=n;i++) pw[i]=pw[i-1]*k%cys;
		fac[0]=inv[0]=1;
		for(int i=1;i<=k;i++) fac[i]=fac[i-1]*i%cys;
		inv[k]=qpow(fac[k],cys-2);
		for(int i=k-1;i>=1;i--) inv[i]=inv[i+1]*(i+1)%cys;
		if(lf==m&&rg==1){
			ll ans=0;
			for(int i=1;i<=n-m+1;i++){
				for(int j=0;j<=min(k-m,n-(i+m-1));j++){
					ll tmp;
					if(m+j==k) tmp=pw[n-m-j];
					else if(j<n-(i+m-1)) tmp=(pw[n-m-j-1]*(m+j)-(pw[i-1]-d[i-1][m+j])*(pw[n-(i+m-1)-j-1]*(m+j)%cys-s[n-(i+m-1)-j-1][m+j]))%cys;
					else tmp=d[i-1][m+j];
					tmp=tmp*fac[k-m]%cys*inv[k-m-j]%cys;
					ans=(ans+cys+tmp)%cys;
//					cout<<"test "<<i<<' '<<j<<' '<<ans<<endl;
				}
			}
			printf("%lld\n",ans);
		}
		else{
			ll ans=0;
			for(int i=1;i<=n-m+1;i++){
				ans=(ans+qpow(k,n-m)-(qpow(k,i-1)-d[i-1][lf])*(qpow(k,n-(i+m-1))-d[n-(i+m-1)][m-rg+1]))%cys;
				ans=mod(ans+cys);
			}
			printf("%lld\n",ans);
		}
	}
	return 0;
}

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

#define pb push_back
#define fst first
#define snd second
#define ALL(s) s.begin(),s.end()
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define SZ(x) ((int)(x).size())
#define PI 3.1415926535897932384626433832795
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
using namespace std;

int main() {FIN;
    int n; cin>>n;
    vector<int> v(n+1), ans(n+1, 0);
    fore(i,1,n+1) cin>>v[i];
    int res = 0;
    for(int i = n; i > 0; i--){
        int last = (n/i)*i;
        int cnt = 0;
        for(int j = last; j > i; j-=i){
            if(ans[j]) cnt++;
        }
        if((v[i]==0&&cnt%2==0)||(v[i]==1&&cnt%2)) continue;
        ans[i]++;
        res++;
    }
    cout<<res<<"\n";
    fore(i,1,n+1) if(ans[i]) cout<<i<<" ";
    return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
#define int long long

signed main(){
    int N; cin >> N;
    for(int n = 1; n <= N; n++){
        int cnt = 0;
        for(int x = 1; x * x <= n; x++){
            for(int y = 1; y * y + x * x + x * y <= n; y++){
                int b = x + y;
                int c = x * x + y * y + x * y - n;
                int tmp = sqrt(b * b - 4 * c) + 0.05;
                int z = (-b + tmp) / 2;
                for(int p = z - 10; p <= z + 10; p++){
                    if(p < 1) continue;
                    ll sum = x * x + y * y + p * p + x * y + y * p + p * x;
                    if(sum == n) cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

long long calc_digit(long long n, int& num) {
    long long sum = 0;
    num = 0;
    while(n > 0) {
        ++num;
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

void solve() {
    ll a, b; cin >> a >> b;
    int bnum = 0;
    calc_digit(b, bnum);
    ll target = b + a * std::pow(10, bnum);
    ll sq = sqrt(target);
    if (sq * sq == target) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
    solve();
    return 0;
}

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

const int maxn(2e5 + 5);
const int maxm(1 << 19);
const int mod(924844033);

inline void Inc(int &x, int y) {
	if ((x += y) >= mod) x -= mod;
}

inline int Pow(ll x, int y) {
	register ll ret = 1;
	for (x %= mod; y; y >>= 1, x = x * x % mod)
		if (y & 1) ret = ret * x % mod;
	return ret;
}

int a[maxm], b[maxm], w[2][maxm], r[maxm], l, deg;

inline void Init(int n) {
	register int i, x, y;
	for (deg = 1, l = 0; deg < n; deg <<= 1) ++l;
	for (i = 0; i < deg; ++i) r[i] = (r[i >> 1] >> 1) | ((i & 1) << (l - 1));
	w[1][0] = w[0][0] = 1, x = Pow(5, (mod - 1) / deg), y = Pow(x, mod - 2);
	for (i = 1; i < deg; ++i) w[0][i] = (ll)w[0][i - 1] * x % mod, w[1][i] = (ll)w[1][i - 1] * y % mod;
}

inline void NTT(int *p, int opt) {
	register int i, j, k, t, wn, x, y;
	for (i = 0; i < deg; ++i) if (r[i] < i) swap(p[r[i]], p[i]);
	for (i = 1; i < deg; i <<= 1)
		for(t = i << 1, j = 0; j < deg; j += t)
			for (k = 0; k < i; ++k) {
				wn = w[opt == -1][deg / (i << 1) * k];
				x = p[j + k], y = (ll)wn * p[i + j + k] % mod;
				p[j + k] = x + y, p[i + j + k] = x - y;
				if (p[j + k] >= mod) p[j + k] -= mod;
				if (p[i + j + k] < 0) p[i + j + k] += mod;
			}
	if (opt == -1) {
		for (wn = Pow(deg, mod - 2), i = 0; i < deg; ++i) p[i] = 1LL * p[i] * wn % mod;
	}
}

int n, first[maxn], cnt, size[maxn], num[maxn], fac[maxn], inv[maxn];

struct Edge {
	int to, next;
} edge[maxn << 1];

inline int Add(int u, int v) {
	edge[cnt] = (Edge){v, first[u]}, first[u] = cnt++;
	edge[cnt] = (Edge){u, first[v]}, first[v] = cnt++;
}

void Dfs(int u, int ff) {
	register int e, v;
	for (size[u] = 1, e = first[u]; ~e; e = edge[e].next)
		if ((v = edge[e].to) != ff) Dfs(v, u), size[u] += size[v], ++num[size[v]];
	++num[n - size[u]];
}

inline int C(int x, int y) {
	if (y > x) return 0;
	return (ll)fac[x] * inv[y] % mod * inv[x - y] % mod;
}

int main() {
	register int i, u, v, ret;
	memset(first, -1, sizeof(first)), scanf("%d", &n);
	for (i = 1; i < n; ++i) scanf("%d%d", &u, &v), Add(u, v);
	Dfs(1, 0), fac[0] = inv[0] = inv[1] = fac[1] = 1;
	for (i = 2; i <= n; ++i) fac[i] = (ll)fac[i - 1] * i % mod, inv[i] = (ll)(mod - mod / i) * inv[mod % i] % mod;
	for (i = 2; i <= n; ++i) inv[i] = (ll)inv[i] * inv[i - 1] % mod;
	for (Init(n + n + 1), i = 0; i <= n; ++i) a[i] = (ll)num[i] * fac[i] % mod, b[i] = inv[n - i];
	for (NTT(a, 1), NTT(b, 1), i = 0; i < deg; ++i) a[i] = (ll)a[i] * b[i] % mod;
	for (NTT(a, -1), i = 1; i <= n; ++i) ret = (ll)n * C(n, i) % mod, Inc(ret, mod - (ll)inv[i] * a[n + i] % mod), printf("%d\n", ret);
    return 0;
}

Measured memory_bytes: 27392
process.stdin.resume()
process.stdin.setEncoding("utf8")

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
})

const lines = []

reader.on("line", (line) => {
  lines.push(line)
})

reader.on("close", () => {
  const n = lines[0] - 0
  const hm = new HM()
  for (let i = 1; i <= n; i++) {
    const [method, arg] = lines[i].split(" ")
    if (method === "insert") {
      hm.insert(arg)
    } else if (method === "find") {
      console.log(hm.find(arg) ? "yes" : "no")
    }
  }
})

const m = 1000003

const strToNumber = (str) => {
  let numWeight = 1
  let numWeightPerDigit = 4
  let ret = 0
  str
    .split("")
    .reverse()
    .forEach((c) => {
      let num = 0
      switch (c) {
        case "A":
          num = 1
          break
        case "C":
          num = 2
          break
        case "G":
          num = 3
          break
        case "T":
          num = 4
          break
      }
      ret += num * numWeight
      numWeight *= numWeightPerDigit
    }, 0)

  return ret
}

function h1(key) {
  return key % m
}

function h2(key) {
  return 1 + (key % (m - 1))
}

function h(key, i) {
  return (h1(key) + i * h2(key)) % m
}

class HM {
  constructor() {
    this.T = Array(m)
  }

  insert(str) {
    let i = 0,
      j
    const key = strToNumber(str)
    const T = this.T
    while (true) {
      j = h(key, i)
      if (T[j] == null) {
        T[j] = key
        return j
      } else {
        i++
      }
    }
  }

  find(str) {
    let i = 0,
      j
    const key = strToNumber(str)
    const T = this.T
    while (true) {
      j = h(key, i)
      if (T[j] === key) {
        return true
      } else if (T[j] == null || i >= m) {
        return false
      } else {
        i++
      }
    }
  }
}



Measured memory_bytes: 200976
from collections import deque
H, W = map(int, input().split())
k=[0]*200000
for i in range(W):
    ta,tb = map(int, input().split())
    if ta == 1:
        k[tb-1]+=1
    if tb == H:
        k[ta-1]+=1
s = 0
for i in range(len(k)):
    if k[i]>=2:s=1
if s ==1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int main(){
	
	int n;cin >> n;
	vector<ll> A(n);REP(i,n)cin >> A[i];sort(ALL(A));
	vector<ll> B(n);REP(i,n)cin >> B[i];sort(ALL(B));
	vector<ll> num(n);
	
	ll ans = 1;
	ll AA = 0;
	ll cou = 0;
	
	REP(i,n){
		if(cou == 0 && A[cou] > B[i]){
			AA++;
			continue;
		}
		while(cou < n - 1 && A[cou+1] < B[i])cou++;
		num[cou]++;
	}
	
	//SHOW1d(num,n);
	
	cou = 0;
	REP(i,n){
		//cout << " " << i << " " << AA << endl;
		bool flag = true;
		cou++;
		if(AA > 0){
			ans *= AA;
			ans %= MOD;
			cou--;
			AA--;
			flag = false;
		}
		if(flag && num[i] > 0){
			ll tmp = 1;
			while(cou > 0 && num[i] > 0){
				tmp *= cou;
				tmp %= MOD;
				cou--;
				num[i]--;
			}
			ans *= tmp;
			ans %= MOD;
		}
		AA += num[i];
	}
			
	cout << ans << endl;
	
	return 0;
}



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

int main() {
    int N, count = 0, i, num = 0;

    cin >> N;

    vector<int> H(N);

    for(i = 0; i < N; i++)
        cin >> H.at(i);

    for(i = 0; i < N - 1; i++){
        if(min(H.at(i), H.at(i + 1)) == H.at(i + 1) || H.at(i) == H.at(i + 1))
            count++;
        else{
            num = max(count, num);
            count = 0;
        }
    }

    num = max(count, num);

    cout << num << endl;
}

Measured memory_bytes: 640
/***
 ** "Figure out how to distract yourself."
 **
***/

/**
  *  Author: dhruv_gheewala
  *  Problem: Popular Vote
  *  Date:   05.04.2020
  *  Time:   03:03:40
**/

#if __has_include("debug.h")
    #include "debug.h"
#else
    #include<bits/stdc++.h>
    using namespace std;

    #define p(str) 7
    #define o(str) 42
    #define fundri 108
    #define d(...) 1729
#endif


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

const bool testcases = 0;
#define ff first
#define ss second
#define endl '\n'
#define all(s) s.begin(),s.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define test int T = 1;if(testcases)cin >> T;for(int tc = 1 ; tc <= T ; tc++)
#define make_unique(vec) sort(all(vec));vec.erase(unique(all(vec)),vec.end())
#define sort_by(cont,expr) sort(all(cont),[&](const auto &lhs,const auto &rhs){return expr;})

ll seed;mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l=0,int r=INT_MAX){return uniform_int_distribution<int>(l,r)(rng);}

template<typename T>bool isPrime(T n){for(T i=2;i*i<=n;i++)if(n%i==0)return 0;return 1;}
template<typename T>inline bool in_range(T a,T l,T r){return (a>=l&&a<=r);}

template<typename T,typename U>inline istream& operator >>(istream& in,pair<T,U> &a)
{in>>a.ff>>a.ss;return in;}
template<typename T>inline istream& operator >>(istream& in,vector<T> &a)
{for(auto &x : a)in>>x;return in;}
template<typename TAIL>inline void inp(TAIL& T){cin>>T;}
template<typename HEAD,typename... TAIL>inline void inp(HEAD &H,TAIL&... T){cin>>H;inp(T...);}

int main(int argc, char **argv)
{
    std::chrono::time_point<std::chrono::high_resolution_clock> start_time, end_time;
    start_time = std::chrono::high_resolution_clock::now();

    #ifdef DHRUV_GHEEWALA
        freopen("INPUT.txt","r",stdin);
        freopen("OUTPUT.txt","w",stdout);
        freopen("DEBUG.txt","a",stderr);
    #endif
    
    fast;
    int n, m;
    test
    {
        cin >> n >> m;
        int sum = 0;
        vi a(n);
        for(int i = 0 ; i < n ; i++)
        {
        	cin >> a[i];
        	sum += a[i];
        }

        int c = 0;
        sum = ceil(1.00 * sum / (4 * m));
        for(int i = 0 ; i < n ; i++)
        	if(a[i] >= sum)
        		c++;

        puts(c >= m ? "Yes":"No");

        fundri;
    }

    end_time = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
    o("\n\n");
    if(elapsed_time<10000)
        o("Elapsed Time: "<<elapsed_time<<" ms\n");
    else
        o("Elapsed Time: "<<elapsed_time/1000<<" s\n");

    return 0;
}

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

using namespace std;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
 	long long n,a,b;
  cin>>n>>a>>b;
  long long res=n/(a+b);
  n-=(a+b)*res;
  cout<<min(a,n)+a*res<<endl;
}

Measured memory_bytes: 256
void main() {
	auto N = ri;
	auto a = readAs!(int[]);
	int tmp, old, res;
	foreach(i; a) {
		if(old != i) {
			old = i;
			res += tmp / 2;
			tmp = 0;
		}
		tmp++;
		debug writefln("%d %d %d", tmp, old, res);
	}
	res += tmp / 2;
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  string S;
  cin >> S;

  const ll N = S.size();
  vec<ll> L(N + 1, 0);
  for (ll i = 0; i < N; i++) {
    if (S[i] == '<') {
      L[i + 1] = L[i] + 1;
    }
  }
  vec<ll> R(N + 1, 0);
  for (ll i = N - 1; i >= 0; i--) {
    if (S[i] == '>') {
      R[i] = R[i + 1] + 1;
    }
  }
  ll res = 0;
  REP(i, N + 1) res += max(L[i], R[i]);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 11652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,l;
	cin>>n>>l;
	ll sa=inf;
	bool ch=true;
	ll sum=0;
	for(ll i=0;i<n;i++){
		ll now=l+i;
		sum+=now;
		if(abs(now)<=sa){
			if(now<0){
				ch=false;
				sa=abs(now);
			}
			else{
				ch=true;
				sa=abs(now);
			}
		}
	}
	if(ch==false){
		sa*=-1;
	}
	sum-=sa;
	cout <<sum;
	// your code goes here
	return 0;
}

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

int main()
{
  long long n;
  cin >> n;
  unordered_map<int, int> m;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i != 0) {
      continue;
    }
    while (n % i == 0) {
      m[i]++;
      n = n / i;
    }
  }
  if (n != 1) {
    m[n]++;
  }
  long long res = 0;
  for (auto p : m) {
    int cnt = 1;
    int val = p.second;
    //cout << val << '\n';
    while (cnt <= val) {
      val = val - cnt;
      res++;
      cnt++;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,v;
	cin>>s>>v;
	int ans=INT_MAX;
	for(int i=0;i<=s.size()-v.size();i++){
		int cnt=0;
		for(int j=i;j<i+v.size();j++){
			if(v[j-i]!=s[j])
				cnt++;
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int h1, m1, h2, m2, k;
	cin>>h1>>m1>>h2>>m2>>k;
	int a=h1*60+m1, b=h2*60+m2;
	cout<<b-a-k;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const double INF = 1e12;
typedef complex<double> P;

int main(){
    for(int rep=1; ; rep++){
        int n;
        cin >> n;
        if(n==0) break;

        vector<vector<P> > seg(n, vector<P>(2));
        double sum = 0;
        for(int i=0; i<n; i++){
            for(int j=0; j<2; j++){
                double x,y;
                cin >> x >> y;
                seg[i][j] = P(x, y);
            }
            sum += abs(seg[i][0] -seg[i][1]);
        }

        vector<vector<vector<double> > > dp(1<<n, vector<vector<double> >(n, vector<double>(2, INF)));
        for(int i=0; i<n; i++){
            dp[1<<i][i][0] = dp[1<<i][i][1] = 0;
        }
        for(int i=0; i<(1<<n); i++){
            for(int j=0; j<n; j++){
                if((i & 1<<j) == 0) continue;
                for(int k=0; k<n; k++){
                    if((i & 1<<k) != 0) continue;
                    for(int s=0; s<2; s++){
                        for(int t=0; t<2; t++){
                            dp[i | 1<<k][k][t] = min(dp[i | 1<<k][k][t], dp[i][j][s] + abs(seg[j][1-s] -seg[k][t]));
                        }
                    }
                }
            }
        }

        double ans = INF;
        for(int i=0; i<n; i++){
            for(int j=0; j<2; j++){
                ans = min(ans, dp[(1<<n)-1][i][j]);
            }
        }
        ans += sum;
        cout << fixed << setprecision(5);
        cout << "Case " << rep << ": " << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 16176
#!/usr/bin/env python

def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))

    lim = sum(a) / (4 * m)
    count = 0

    for i in range(n):
        if a[i] >= lim:
            count += 1

    if count >= m:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n],b[n];
  vector<int> g[n];
  rep(i,n-1){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
    g[a[i]].pb(b[i]);
    g[b[i]].pb(a[i]);
  }
  int c[n];
  rep(i,n) cin >> c[i];
  int vmax=0;
  int vmi;
  rep(i,n){
    if(vmax<g[i].size()){
      vmax=g[i].size();
      vmi=i;
    }
  }
  //  cout << " "<< endl;
  sort(c,c+n,greater<int>());
  int ans[n];
  bool used[n];
  rep(i,n) used[i]=false;
  queue<int> q;
  q.push(vmi);
  int k=0;
  while(!q.empty()){
    int ind=q.front();q.pop();
    if(used[ind]) continue;
    used[ind]=true;
    ans[ind]=c[k];
    k++;
    for(auto i : g[ind]){
      q.push(i);
    }
  }
  ll res=0;
  rep(i,n-1){
    int t=min(ans[a[i]],ans[b[i]]);
    res+=t;

  }
  cout << res << endl;
  rep(i,n) cout << ans[i] << " ";
  cout << "" << endl;

  return 0;
    

}


Measured memory_bytes: 1152
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
d = 0

if sum(a) < sum(b):
    res = -1
else:
    c = [a[i] - b[i] for i in range(n)]
    c1 = [i if i > 0 else 0 for i in c]
    c2 = sum([i if i < 0 else 0 for i in c])
    c3 = sum([1 if i < 0 else 0 for i in c])
    if c2 < 0:
        c4 = sorted(c1, reverse=True)
        for i in range(n):
            d = d + c4[i]
            if d + c2 > 0:
                res = c3 + i + 1
                break

print(res)


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

signed main(){
	string S;
	cin >> S;
	if(S == "SUN"){
		printf("7\n");
	}
	else if(S == "MON"){
		printf("6\n");
	}
	else if(S == "TUE"){
		printf("5\n");
	}
	else if(S == "WED"){
		printf("4\n");
	}
	else if(S == "THU"){
		printf("3\n");
	}
	else if(S == "FRI"){
		printf("2\n");
	}
	else{
		printf("1\n");
	}
	return 0;
}

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

int N, M;
int P[5000];
vector<int> G[5000];

int main() {
  cin >> N >> M;
  for (int i=0; i<M; i++) {
    int a, b;
    cin >> a >> b;
    G[a-1].push_back(b-1);
    P[b-1]++;
  }
  vector<int> s;
  for (int i=0; i<N; i++) s.push_back(i);

  int ex = 0;
  while (!s.empty()) {
    int k = -1, mi = -1, mc = N+1;
    for (int j=0; j<s.size(); j++) {
      int i = s[j];
      if (P[i] < mc) mi = i, mc = P[i], k = j;
    }
    int c = 0;
    for (int j=0; j<s.size(); j++) {
      if (P[s[j]] == mc) c++;
    }
    if (c > 1) ex = 1;

    for (int i : G[mi]) P[i]--;
    cout << mi+1 << "\n";
    s.erase(next(s.begin(), k));
  }
  cout << ex << "\n";
  return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define cont continue  
#define rep(i, n) for(int i = 0 ; i < (n) ; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 2147483646;
const double pi = 3.141592653589793;


int par[100001] = {};

int find(int n) {
  if(par[n] < 0) return n;

  else {
    return par[n] = find(par[n]);
  }
}

void merge(int a, int b) {
  a = find(a);
  b = find(b);
  if(a == b) return;
  else {
    par[b] = a;
  }
}

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

  int N, M;
  cin >> N >> M;
  int arr[100001] = {};
  memset(par, -1, sizeof(par));

  for(int i = 1 ; i <= N ; i++) {
    cin >> arr[i];
  }

  for(int i = 0 ; i < M ; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    merge(a, b);
  }
  int cnt = 0;
  for(int i = 1 ; i <= N ; i++) {
    if(find(i) == find(arr[i])) {
      cnt++;
    }
  }
  cout << cnt << endl;
} 

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int n,s=0,i,a[105];
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(i=1;i<=n;i++){
		if(i%2==1 && a[i]%2==1)
		s++;
	}
	printf("%d",s);
}

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

int main() {
	int a;
	cin >> a;
	if (a == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
	else if (a == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (a == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (a == 25) {
		cout << "Christmas" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

const int MOD = 998244353;

int mul(int a, int b) {
	return (a * b) % MOD;
}

int add(int a, int b) {
	return (a + b) % MOD;
}

const int N = 2e5 + 7;

int dp[N];
int dg[N];
vector<int> g[N];

int solve(int v) {
	if (dp[v] == -1) {
		int pdp = 1;
		for (auto t : g[v]) {
			pdp = mul(pdp, solve(t));
		}
		dp[v] = add(pdp, 1);
	}
	return dp[v];
}

int n;

int ans = 1;

void run() {
	fill(dp, dp + n, -1);
	for (int i = 0; i < n; i++) {
		if (dg[i] == 0) {
			ans = mul(ans, solve(i));
		}
	}
}

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

	cin >> n;
	vector<pair<int, int>> a(n);
	for (auto &t : a) {
		cin >> t.first >> t.second;
	}
	sort(a.begin(), a.end());
	vector<pair<int, int>> st;
	for (int i = 0; i < n; i++) {
		// for (int j = i - 1; j >= 0; j--) {
		// 	if (a[j].first + a[j].second > a[i].first) {
		// 		g[j].push_back(i);
		// 		// cout << j << ' ' << i << endl;
		// 		dg[i]++;
		// 		break;
		// 	}
		// }
		if (!st.empty() && st.front().first > a[i].first) {
			int l = 0;
			int r = (int)st.size();
			while (r - l > 1) {
				int m = (r + l) / 2;
				if (st[m].first > a[i].first) l = m;
				else r = m;
			}
			g[st[l].second].push_back(i);
			dg[i]++;
		}
		while (!st.empty() && st.back().first <= a[i].first + a[i].second) {
			st.pop_back();
		}
		st.push_back({a[i].first + a[i].second, i});
	}
	run();
	cout << ans << endl;
}


Measured memory_bytes: 26880