akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: [String;3]
    }
    println!("{}",
        s.iter().map(|x| x.chars().next().unwrap())
        .collect::<String>());
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 3010
int a[N];
int main()
{
    int i,j,k,n,s;
    scanf("%d",&n);
    s=0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        s=s+a[i];
    }
    printf("%d\n",s-n);
    return 0;
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

int a[100];
int cells[100][100]; // r * c

int main() {
  int N;
  cin >> N;

  vector<ll> A(N);
  vector<ll> B(N);

  rep0(i, N - 1) cin >> B[i];

  rep0(i, N) {
    if (i == 0) A[i] = B[0];
    else if (i == N - 1) A[i] = B[N - 2];
    else A[i] = min(B[i-1], B[i]);
  }

  ll ans = 0;
  rep0(i, N) {
    ans += A[i];
  }

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[] S = sc.next().toCharArray();
		int count = 0,ans=0;

		for (char c : S) {
			if(c == 'I') count++;
			else count--;
			if(ans < count) ans = count;
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 21588
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
a,b,c = readInts()
print(b + min(c, a + b + 1))


Measured memory_bytes: 10300
#include<bits/stdc++.h>
#define INFTY 10000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};

int main(){
   string s,t;cin>>s>>t;
   int cnt=0;
   rep(i,s.size()){
       if(s[i]!=t[i])cnt++;
   }
   cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3872
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Fenwick{
  vector<int> tr;
  int get(int in){
    in++;
    int res = 0;
    while(in){
      res += tr[in];
      in -= in & -in;
    }
    return res;
  }
  void add(int in, int v){
    in++;
    while(in < tr.size()){
      tr[in] += v;
      in += in & -in;
    }
  }
};
ll count_inv(int inv[], int n){
  Fenwick F;
  F.tr.resize(n + 10);
  ll res = 0;
  for(int i = 0;i < n;i++){
    res += i - F.get(inv[i]);
//    cout << inv[i] << ' ' << r<< endl;
    F.add(inv[i], 1);
  }
  return res;
}
int main() {
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  string s;
  cin >> s;
  int n = s.size();
  vector<pair<int, int>> p;
  vector<int> poss[26];
  for(int i = 0;i < s.size();i++){
    poss[s[i] - 'a'].push_back(i);
  }
  int cnt_odd = 0;
  for(int i = 0;i < 26;i++){
    cnt_odd += poss[i].size() & 1;
  }
  if(cnt_odd > 1){
    cout << -1;
    return 0;
  }

  int inv[n];
  for(int i = 0;i < 26;i++){
    if(poss[i].size() & 1){
      inv[n / 2] = poss[i][poss[i].size() / 2];
      poss[i].erase(poss[i].begin() + poss[i].size() / 2, poss[i].begin() + poss[i].size() / 2 + 1);
    }
  }
  for(int i = 0;i < 26;i++){
    for(int j = 0;j < poss[i].size() / 2;j++){
      p.push_back({poss[i][j], poss[i][poss[i].size() - j - 1]});
    }
  }
  sort(p.begin(), p.end(), [](const pair<int, int>& a, const pair<int, int>& b){
    return a.first < b.first;
  });

  for(int i = 0;i < p.size();i++){
    inv[i] = p[i].first;
    inv[n - 1 - i] = p[i].second;
  }
//  for(int i = 0;i < n;i++){
//    cout << inv[i] << endl;
//  }
  cout << count_inv(inv, n);
  return 0;
}


Measured memory_bytes: 4088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const long double PI = (acos(-1));

bool isPalindrome(string s){
  string _s = s;
  reverse(_s.begin(), _s.end());

  return s == _s;
}

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

  string s;
  cin >> s;

  string t = s.substr(0, s.size()/2);
  if (isPalindrome(s) && isPalindrome(t)){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから

void solve(){
  int n;
  cin>>n;
  vector<int>h(n);
  rep(i,n)cin>>h[i];
  int cnt=0,maxv=0;
  rep(i,n){
    if(maxv<=h[i])++cnt;
    chmax(maxv,h[i]);
  }
  cout<<cnt;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <math.h>

int main() {

    int n, divisores = 0, num=0;

    scanf("%d", &n);

    for (int i=1; i<=n; ++i) {

        for (int j=1; j<=i; ++j) {

            if(divisores>8) {

                divisores = 0;

                break;

            }

            if(i%j==0 && j%2!=0)

                ++divisores;

            if(j==i && divisores==8)

                ++num;

            //printf("%d %d %d %d\n", num, i, j, divisores);

            if (j==i)

                divisores = 0;

        }

    }

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

    return 0;

}



Measured memory_bytes: 128
k, n = map(int, input().split())
a = [int(x) for x in input().split()]
max_length = 0
for i in range(n-1):
    tmp_length = a[i+1] - a[i]
    max_length = max(max_length, tmp_length)
tmp_length = a[0] + k-a[-1]
max_length = max(max_length, tmp_length)
print(k-max_length)

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

int main(){
    int n;
    cin >> n;
    vector<int> lr(n * 2);
    for (int i = 0; i < n * 2;i++){
        cin >> lr.at(i);
    }
    int sum = 0;
    for (int i = 0; i < n * 2; i++){
        sum += lr.at(i + 1) - lr.at(i) + 1;
        i++;
    }
    cout << sum;
}

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

int main()
{
    int n;
    cin>>n;
    vector<long long>v(n+2);
    int i,j,k,T,flag,l,r;
    for(i=0;i<n;i++)
    {
        cin>>v[i];
    }
    cin>>T;
    while(T--)
    {

       cin>>flag>>l>>r;
       if(flag==0)
       {
           long long Min=10000000000;
           for(i=l;i<r;i++)
           {
               Min=min(Min,v[i]);
           }
           cout<<Min<<endl;
       }
       else
       {
           long long Max=-10000000000;
           for(i=l;i<r;i++)
           {
               Max=max(Max,v[i]);
           }
           cout<<Max<<endl;
       }
    }
    return 0;
}



Measured memory_bytes: 3116
a, op, b = input().split()
while op != "?":
    a = int(a)
    b = int(b)
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    a, op, b = input().split()


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  I n;
  cin >> n;
  if (n==1){
    cout << 0 << endl;
    return 0;
  }
  cout << n * (n-1) / 2 << endl;
  return 0;
}



Measured memory_bytes: 256
n, m = map(int, input().split(' '))

ns = [i for i in range(n)]

for i in range(m):
  ha = int(input())
  ns[ha] = None

#print(n, m)
#print(ns)

count = 0
while True:
  size = len(ns)
  ns2 = []
  for j in range(0, size, 2):
    flag = ns[j] is not None and ns[j+1] is not None
    if flag:
      ns2.append( 0 )
      count += 1
    elif ns[j] is not None or ns[j+1] is not None:
      ns2.append( 0 )
    else:
      ns2.append( None)
  #print(ns2)
  ns = ns2
  if len(ns) == 1:
    break
print(count)


Measured memory_bytes: 5604
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;

int main(void) {

  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  int ans = 0;
  if( a < 0 ){
    ans += c * -a;
    ans += d;
    a = 0;
  }
  ans += (b-a) * e;
  cout << ans << endl;

  return 0;
}


// EOF

Measured memory_bytes: 3092
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	tlist := make([]int, n)
	for i := 0; i < n; i++ {
		tlist[i] = nextInt()
	}

	osum := 0
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if i == j {
				continue
			}
			osum += tlist[i] * tlist[j]
		}
	}

	fmt.Println(osum / 2)
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1776
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst int T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define ll long long int
#define vt vector
#define pb push_back
int main()
{
    vite;
    ll h1,m1,h2,m2,n;
    cin >> h1 >> m1 >> h2 >> m2 >> n;
    cout << 60*(h2 - h1) +  (m2 - m1) - n;

    return 0;
}

Measured memory_bytes: 3568
# https://atcoder.jp/contests/abc067/tasks/abc067_b

import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    N, K = map(int, input().split())
    L = list(map(int, input().split()))
    L.sort(reverse=True)
    print(sum(L[:K]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long int
#define s(x)	cin>>x
#define p(x)	cout<<x<<"\n"
#define goog(x, y)  cout<<"Case #"<<x<<": "<<y<<"\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 100000000000
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpi;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
typedef long double ld;

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);
int gcd(int a, int b) ;

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];



void solve() {
  int n;cin>>n;
  ll a[n];
  fo(i,n) cin>>a[i];
  ll cont[n];
  cont[0]=a[0];
  Fo(i,1,n)
  cont[i]=(cont[i-1]+a[i])%mod;
  ll res[n];
  res[0]=0;
  Fo(i,1,n)
  { res[i]=(res[i-1]+a[i]*cont[i-1])%mod;}
  p(res[n-1]);
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    //u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

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

Measured memory_bytes: 15356
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 100000000000000;
const double PI = acos(-1);

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	if (n > m)swap(n, m);
	for (int i = 0; i <= m; i++) {
		for (int j = 0; j <= n; j++) {
			int num = 0;
			num += n*i;
			num += (m - i)*j;
			num -= i*j;
			//cout <<i<<" " <<j<<" "<<num << endl;
			if (num == k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
long long p = 1000000007;
long long s, i, x, a;
long long rui(long long rui_a, long long rui_b) {
	if (rui_b == 0)return 1;
	if (rui_b == 1)return rui_a % p;
	long long rui_c;
	rui_c = rui(rui_a, rui_b / 2);
	rui_c = rui_c * rui_c % p;
	if (rui_b % 2) {
		return rui_c * rui_a % p;
	}
	return rui_c;
}
int main() {
	scanf("%lld", &s);
	i = 1;
	x = 1;
	while (s - 3 * i >= 0) {
		a += x;
		a %= p;
		x *= s - 3 * i;
		x %= p;
		x *= s - 3 * i - 1;
		x %= p;
		x *= s - 3 * i - 2;
		x %= p;
		x *= rui(s - 2 * i - 1, p - 2);
		x %= p;
		x *= rui(s - 2 * i - 2, p - 2);
		x %= p;
		x *= rui(i, p - 2);
		x %= p;
		i++;
	}
	printf("%lld\n", a);
}

Measured memory_bytes: 1720
#include <stdio.h>

int main(void)  {
  int x, y, r, tmp;
  scanf("%d %d", &x, &y);

  if (x < y){
      tmp = x;
      x = y;
      y = tmp;
  }
 
  r = x % y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }

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

  return 0;
}

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

#define END 0

//双方向リスト用構造体
typedef struct _list_struct {
	struct _list_struct* pstBefor;
	struct _list_struct* pstAfter;
	long int iNumber;
}LIST_STRUCT;

//プロトタイプ宣言

//インサート関数
void vdInsertList(LIST_STRUCT** pstNow, int iNumber);

//移動関数
void vdMoveList(LIST_STRUCT** pstNow, int iMove);

//削除関数
void vdRemoveList(LIST_STRUCT** pstNow, int iDummy);


int main()
{
	int iControlNumber;		//操作の際に使用される値
	int iOperand;			//操作する関数
	LIST_STRUCT* pstNow;
	long int liCount;
	long int liOpelandMax;
	void (*apfControlList[3])(LIST_STRUCT * *pstNow, int iControlNum);

	apfControlList[0] = vdInsertList;
	apfControlList[1] = vdMoveList;
	apfControlList[2] = vdRemoveList;

	pstNow = (LIST_STRUCT*)malloc(sizeof(LIST_STRUCT));
	if (pstNow == NULL)
	{
		printf("Error: Can't Get Memory!\n");
		return 1;
	}
	pstNow->pstBefor = NULL;
	pstNow->pstAfter = NULL;
	
	scanf("%ld\n", &liOpelandMax);
	for (liCount = 0; liCount < liOpelandMax; liCount++)
	{
		scanf("%d", &iOperand);
		if (iOperand != 2)
		{
			scanf("%d\n", &iControlNumber);
		}
		(*apfControlList[iOperand])(&pstNow, iControlNumber);
	}
	while (pstNow->pstBefor != NULL)
	{
		pstNow = pstNow->pstBefor;
	}
	while (pstNow->pstAfter != NULL)
	{
		printf("%ld\n", pstNow->iNumber);
		pstNow = pstNow->pstAfter;
		free(pstNow->pstBefor);
	}
	free(pstNow);
	return 0;
}


//インサート関数
void vdInsertList(LIST_STRUCT** pstNow, int iNumber)
{
	LIST_STRUCT* pstSet;
	pstSet = (LIST_STRUCT*)malloc(sizeof(LIST_STRUCT));
	if (pstSet == NULL)
	{
		printf("Error: Can't Get Memory!\n");
		exit(1);
	}
	pstSet->iNumber = iNumber;
	//対象リストの前後との相互リンクを記述
	pstSet->pstAfter = *pstNow;
	pstSet->pstBefor = (*pstNow)->pstBefor;
	(*pstNow)->pstBefor = pstSet;
	//対象リストが先頭でないときは前からのリンクを記述
	if (pstSet->pstBefor != NULL)
	{
		(pstSet->pstBefor)->pstAfter = pstSet;
	}
	//現在カーソルを更新
	*pstNow = pstSet;
}

//移動関数
void vdMoveList(LIST_STRUCT** pstNow, int iMove)
{
	int iCountMove;
	if (iMove > 0)
	{
		//後ろに移動
		for (iCountMove = 0; iCountMove < iMove; iCountMove++)
		{
			*pstNow = (*pstNow)->pstAfter;
		}
	}
	else
	{
		//前に移動
		for (iCountMove = 0; iCountMove > iMove; iCountMove--)
		{
			*pstNow = (*pstNow)->pstBefor;
		}
	}
}

//削除関数
void vdRemoveList(LIST_STRUCT** pstNow, int iDummy)
{
	LIST_STRUCT* pstSet = *pstNow;
	*pstNow = pstSet->pstAfter;
	(*pstNow)->pstBefor = pstSet->pstBefor;
	if(pstSet->pstBefor != NULL)
		(pstSet->pstBefor)->pstAfter = *pstNow;
	free(pstSet);
}



Measured memory_bytes: 17236
from collections import deque


n, q = map(int, input().split())
graph = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    graph[a - 1] += [b - 1]
    graph[b - 1] += [a - 1]


cost = [0] * n
for j in range(q):
    p, x = map(int, input().split())
    cost[p - 1] += x



par = [0] * n
que = deque([0])

while que:
    cur = que.popleft()
    for nxt in graph[cur]:
        if nxt == par[cur]:
            continue
        cost[nxt] += cost[cur]
        que.append(nxt)
        par[nxt] = cur





print(*cost)

Measured memory_bytes: 101140
n=int(input())
m=[0]*101
for i in range(1,n+1):
  for j in range(2,n+1):
    while i%j==0:
      a=i//j
      while (a+1)*j<=i:
        a+=1
      i=a
      m[j]+=1
counter75=0
counter25=0
counter15=0
counter5=0
counter3=0
for i in range(101):
  if m[i]>=74:
    counter75+=1
  if m[i]>=24:
    counter25+=1
  if m[i]>=14:
    counter15+=1
  if m[i]>=4:
    counter5+=1
  if m[i]>=2:
    counter3+=1
a=(counter5*(counter5-1)*(counter3-2))//2
while (a+1)*2<=(counter5*(counter5-1)*(counter3-2)):
  a+=1
print(counter75+counter25*(counter3-1)+counter15*(counter5-1)+a)


Measured memory_bytes: 38512
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int fc(int num) {
    int ans = 0;
    for(int i = 1; i <= num; i++) {
        ans += i;
    }
    return ans;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    rep(i, N) {
        int tmp;
        cin >> tmp;
        p[i] = tmp + 1;
    }
    vector<int> a(N + 1, 0);
    int now = 0;
    rep(i, N) {
        now += p[i];
        a[i + 1] = now;
    }
    int maxi = 0;
    rep(i, N - K + 1) {
        int now = a[i + K] - a[i];
        maxi = max(maxi, now);
    }

    double ans = maxi / double(2);
    cout << fixed << setprecision(7) << ans << endl;
}


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

int n, temp, minans, maxans;
bool valid[10];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> temp;
        if(temp<=399) {
            if(!valid[0]) {
                minans++;
                maxans++;
            }
            valid[0] = true;
        } else if(temp<=799) {
            if(!valid[1]) {
                minans++;
                maxans++;
            }
            valid[1] = true;
        } else if(temp<=1199) {
            if(!valid[2]) {
                minans++;
                maxans++;
            }
            valid[2] = true;
        } else if(temp<=1599) {
            if(!valid[3]) {
                minans++;
                maxans++;
            }
            valid[3] = true;
        } else if(temp<=1999) {
            if(!valid[4]) {
                minans++;
                maxans++;
            }
            valid[4] = true;
        } else if(temp<=2399) {
            if(!valid[5]) {
                minans++;
                maxans++;
            }
            valid[5] = true;
        } else if(temp<=2799) {
            if(!valid[6]) {
                minans++;
                maxans++;
            }
            valid[6] = true;
        } else if(temp<=3199) {
            if(!valid[7]) {
                minans++;
                maxans++;
            }
            valid[7] = true;
        } else maxans++;
    }

    minans = max(1, minans);
    cout << minans << ' ' << maxans << '\n';

    return 0;
}

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

int main() {
	int N, A;
  	cin >> N >> A;
  
	if (N % 500 > A) {
    	cout << "No" << endl;
    }
    else if (N % 500 <= A) {
    	cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
while True:
  try:
    n,m = map(int,input().split())
    l = [0 for i in range(n)]

    for i in range(3):
      s = list(map(int,input().split()))
      for j in s[1:]:
        l[j - 1] = i
    ans = 100000000
    for pos in [0,2]:
      count = 0
      for i in range(n):
        if abs(l[i] - pos) == 2:
          count += 2 * 3 ** (n - i - 1)
        elif pos == 1 and l[i] == 0:
          count += (3 ** (n - i - 1) - 1) // 2
          pos = 2
        elif pos == 1 and l[i] == 2:
          count += (3 ** (n - i - 1) - 1) // 2
          pos = 0
        elif pos == 0 and l[i] == 1:
          count += 3 ** (n - i - 1)
          pos = 2
        elif pos == 2 and l[i] == 1:
          count += 3 ** (n - i - 1)
          pos = 0
      ans = min(count,ans)
    if (ans <= m):
      print(ans)
    else:
      print(-1)
  except EOFError:
    break


Measured memory_bytes: 5608
n,c=map(int,input().split())
sushi=[]
for i in range(n):
    x,v=map(int,input().split())
    sushi.append([x,v])
sushi.sort()
cw=[0]
cw_s=[]
cw_sum=0
for i in range(n):
    x=sushi[i][0]
    v=sushi[i][1]
    cw_sum=cw_sum+v
    cw.append(max(cw[-1],cw_sum-x))
    cw_s.append(cw_sum-2*x)
acw=[0]
acw_s=[]
acw_sum=0
for i in range(n):
    x=c-sushi[n-1-i][0]
    v=sushi[n-1-i][1]
    acw_sum=acw_sum+v
    acw.append(max(acw[-1],acw_sum-x))
    acw_s.append(acw_sum-2*x)
ans=max(cw[n],acw[n])
for i in range(n):
    ans=max(ans,acw_s[i]+cw[n-1-i],cw_s[i]+acw[n-1-i])
print(ans)


Measured memory_bytes: 78808
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vi vector<int>

int main(){


  ll n;
  cin>>n;
  
  ll rootn=1;
  
  while ((rootn+1)*(rootn+1)<=n){
    rootn++;
  }
  

  ll answer=-1;
  
  for (ll i=1;i<=rootn;i++){
    if (n%i==0){
      ll tmp;
      tmp=i+n/i-2;
      if (answer==-1){
        answer=tmp;
      }
      else {
        answer=min(answer,tmp);
      }
    }
  }
  
  cout<<answer<<endl;
  
      
  
  
   
  
  


  
}



Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
	static void Main(string[] args)
    {
    	int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Console.WriteLine(input[0]*input[1] >= input[2]*input[3] ? input[0]*input[1] : input[2]*input[3]);
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;
using namespace std;

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


int main(){
    int a, b;
    cin>>a>>b;
    int ans=0;
    for(int i=a; i<=b; i++){
        if(ispa(i)) ans++;
    }
    cout<<ans<<endl;
}


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

int main(){
  int array[3][3],a[3],b[3];
  bool judge=true;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>array[i][j];
    }
  }
  b[0]=array[0][0];
  b[1]=array[0][1];
  b[2]=array[0][2];
  a[1]=array[1][0]-b[0];
  if(array[1][1]!=a[1]+b[1]||array[1][2]!=a[1]+b[2]){
    judge=false;
  }
  a[2]=array[2][0]-b[0];
  if(array[2][1]!=a[2]+b[1]||array[2][2]!=a[2]+b[2]){
    judge=false;
  }
  cout<<(judge?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=200005;
vector<int> v[N];
ll ans[N];
void dfs(int x, ll add, int p)
{
    if(x)
        ans[x]+=add;
    for(int i=0;i<v[x].size();i++)
        if(v[x][i]!=p)
            dfs(v[x][i],ans[x],x);
}
int main()
{
    int n,q;
    cin>>n>>q;
    for(int i=1;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        x--; y--;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    while(q--)
    {
        int par,val;
        cin>>par>>val;
        ans[par-1]+=val;
    }
    dfs(0,ans[0],-1);
    for(int i=0;i<n;i++)
        cout<<ans[i]<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 27392
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 16;
const int K = 100000;
const int mod = 1e9 + 7;
int mask1, mask2, d1[1 << 15][16], d2[1 << 15][16], ans[16], x[N], p[N], y[N];
int n, z;
void rec(int k){
    if (k == -1){
        int res = 0;
        for (int i = 0; i < n; i++){
            res += min(d1[mask1][i], d2[mask2][i]);
        }
        ans[z] = min(ans[z], res);
        return;
    }
    rec(k - 1);
    mask1 ^= (1 << k);
    z++;
    rec(k - 1);
    mask1 ^= (1 << k);
    mask2 ^= (1 << k);
    rec(k - 1);
    z--;
    mask2 ^= (1 << k);
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> p[i];
    }
    for (int i = 0; i < (1 << n); i++){
        for (int j = 0; j < n; j++){
            d1[i][j] = min(abs(x[j]), abs(y[j])) * p[j];
            d2[i][j] = min(abs(x[j]), abs(y[j])) * p[j];
            for (int l = 0; l < n; l++){
                if (i & (1 << l)){
                    d1[i][j] = min(d1[i][j], abs(x[j] - x[l]) * p[j]);
                    d2[i][j] = min(d2[i][j], abs(y[j] - y[l]) * p[j]);
                }
            }
        }
    }
    for (int i = 0; i <= n; i++) ans[i] = 1e15;
    rec(n - 1);
    for (int i = 0; i <= n; i++) cout << ans[i] << " ";
}


Measured memory_bytes: 11784
using System;
using System.Collections.Generic;

namespace C___Typical_Stairs
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            var N = read[0];
            var M = read[1];
            var MOD = 1000000007;
            
            var broken = new bool[N+1];
            for(int i = 0 ; i < N+1 ; i++) broken[i] = false;
            for(int i = 0 ; i < M ; i++)
            {
                var A = int.Parse(Console.ReadLine());
                broken[A] = true;
            }      

            var steps = new long[N+1];
            steps[0] = 1;
            steps[1] = broken[1] ? 0 : 1;
            for(int i = 2 ; i < N+1 ; i++)
            {
                if(broken[i])
                {
                    steps[i] = 0;
                }else
                {
                    steps[i] = (steps[i-1]+steps[i-2]) % MOD;
                }
            }

            Console.WriteLine(steps[N]);
        }
    }
}


Measured memory_bytes: 13664
#include<bits/stdc++.h>
using namespace std;
int main(){
    char a[3],b[3];
    b[0]='d'; b[1]='f'; b[2]='g';
    cin>>a;
    for(int i=0;i<3;i++){
        if(a[i]=='a') b[0]='a';
        if(a[i]=='b') b[1]='b';
        if(a[i]=='c') b[2]='c';
    }
    if(b[0]=='a'&&b[1]=='b'&&b[2]=='c') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
typedef long long ll;

ll mod = 1e9+7;  // 1e9+9

ll add(ll x,ll y){return (x+y)%mod;}
ll mul(ll x,ll y){return (x*y)%mod;}

ll mpow(ll x,ll y){
  ll v=1;
  for(;y;x=mul(x,x),y>>=1)
    if(y&1)v=mul(v,x);
  return v;
}

ll ncr[5000][5000];

ll nCr(ll n,ll r){
  if(n<r)return 0;
  if(n==r)return 1;
  if(r==0)return 1;
  if(ncr[n][r])return ncr[n][r];
  ncr[n][r]=(nCr(n-1,r-1)+nCr(n-1,r))%mod;
  return ncr[n][r];
}

ll nHr(ll n,ll r){
  return nCr( n+r-1 , n );
}

int main(){
  ll n,k;
  cin>>n>>k;
  cout<<nCr(k,n)<<endl;
  return 0;
}



Measured memory_bytes: 7152
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 2010
#define offset 50000
using namespace std;
typedef long long  ll;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
const ll MOD=1e9+7;
int n,m;

int dp[5200][5200];
void mod(int &tot)
{
    while(tot>=MOD)
        tot-=MOD;
}
int go(int pos,int acarreo)
{
    if (pos==n)
    {
        if (acarreo==m)
            return 1;
        return 0;
    }
    if (dp[pos][acarreo]!=-1)
        return dp[pos][acarreo];
    int tot=0;
    tot+=go(pos+1,acarreo+1)*2;
    mod(tot);
    tot+=go(pos+1,max(0,acarreo-1));
    mod(tot);
    return dp[pos][acarreo]=tot;
}
ll pot(ll base,ll exp)
{
    base%=MOD;
    ll res=1;
    while(exp>0)
    {
        if (exp&1)
            res*=base,res%=MOD;
        base*=base;base%=MOD;
        exp/=2;
    }
    return res;
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    
    cin>>n;
    string txt;
    cin>>txt;
    m=txt.size();
    memset(dp,-1,sizeof dp);
    ll ans=go(0,0);
    //cout<<ans<<endl;
    //return 0;
    //cout<<ans<<endl;
    //cout<<pot(2,m)<<" "<<pot(pot(2,m),MOD-2)<<endl;
    ans*=pot(pot(2,m),MOD-2);ans%=MOD;
    cout<<ans<<endl;

}   


Measured memory_bytes: 106112
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> vvecA(n, vector<int> (m)), vvecb(m, vector<int> (1)), vvecc(n, vector<int> (1));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
                cin >> vvecA[i][j];
        }
    }
    for(int i=0;i<m;i++){
        cin >> vvecb[i][1];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            vvecc[i][1] += vvecA[i][j]*vvecb[j][1];
        }
    }
    for(int i=0;i<n;i++){
        cout << vvecc[i][1] << endl;
    }
}


Measured memory_bytes: 3180
import sys
if sys.version_info[0]>=3: raw_input=input

def judge(n):
  ma=0
  mi=1000
  s=0
  for i in range(0,n):
    x=int(raw_input())
    if x<mi:
      mi=x
    if x>ma:
      ma=x
    s+=x
  print((s-ma-mi)//(n-2))

while 1:
  n=int(raw_input())
  if n==0:
    break
  judge(n)

Measured memory_bytes: 6720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,K;
    cin >>N>>K;
    ll ans=0;
    rep(i,N){
        ll x;
        cin>>x;
        ans+=min(x,K-x);
    }
    cout << ans*2 << endl;


    return 0;
    

}

Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using AtCoderBeginnerContest161.Questions;
using AtCoderBeginnerContest161.Extensions;

namespace AtCoderBeginnerContest161
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

namespace AtCoderBeginnerContest161.Questions
{
    // ここにQuestionクラスをコピペ
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<string> Solve(TextReader inputStream)
        {
            var nk = inputStream.ReadLongArray();
            var n = nk[0];
            var k = nk[1];

            var diff = Math.Abs(n - k);

            if (diff > n)
            {
                yield return n.ToString();
                yield break;
            }

            n %= k;
            yield return Math.Min(n, Math.Abs(n - k)).ToString();
        }
    }


    #region Base Classes

    public interface IAtCoderQuestion
    {
        IEnumerable<string> Solve(string input);
        IEnumerable<string> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<string> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<string> Solve(TextReader inputStream);
    }

    #endregion
}

#region Extensions

namespace AtCoderBeginnerContest161.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include<cstdio>
char s[1005][1005];
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int vis[1005][1005];
int dis[1005][1005];
int fix[1005][1005];
struct Point{
    int x,y;
    Point(){}
    Point(int x,int y):x(x),y(y){}
};
Point queue[2000005];

int main(){
    int n,m;
    int x0,y0,x1,y1;
    scanf("%d%d%d%d%d%d",&n,&m,&x0,&y0,&x1,&y1);
    for(int i = 1; i <= n; i++) scanf("%s",s[i]+1);
    int h = 1000002, t = 1000001;
    vis[x0][y0] = 1; dis[x0][y0] = 0;
    queue[++t] = Point(x0,y0);
    while(h<=t){
        Point u = queue[h++];
        int x = u.x, y = u.y;
        if(fix[x][y]) continue;
        else fix[x][y] = 1;
        //printf("x = %d, y = %d\n",x,y);
        for(int i = 0; i < 4; i++){
            int r = x+dx[i], c = y+dy[i];
            if(r>=1 && r<=n && c>=1 && c<=m && s[r][c]=='.'){
                if(!vis[r][c] || (vis[r][c] && dis[r][c]>dis[x][y])){
                    vis[r][c] = 1;
                    dis[r][c] = dis[x][y];
                    queue[--h] = Point(r,c);
                }
            }
        }
        for(int i = -2; i <= 2; i++){
            for(int j = -2; j <= 2; j++){
                if(i==0 && j==0) continue;
                int r = x+i, c = y+j;
                if(r>=1 && r<=n && c>=1 && c<=m && s[r][c]=='.'){
                    if(!vis[r][c] || (vis[r][c] && dis[r][c]>dis[x][y]+1)){
                        vis[r][c] = 1;
                        dis[r][c] = dis[x][y]+1;
                        queue[++t] = Point(r,c);
                    }
                }
            }
        }
    }
    if(vis[x1][y1]) printf("%d\n",dis[x1][y1]);
    else printf("-1\n");
    return 0;
}


Measured memory_bytes: 18332
N,M,X = map(int,input().split())
cost_spot = [int(d) for d in input().split()]

right_cost = 0
left_cost = 0

for i in range(1,N):
	location = i + X

	if location in cost_spot:
		#print("ATACK",location)
		right_cost = right_cost + 1
	else:
		pass
		#print("NONOO",location)

	if location == N:
		break

for i in range(1,N):
	location = X - i

	if location in cost_spot:
		#print("ATACK",location)
		left_cost = left_cost + 1
	else:
		pass
		#print("NONOO",location)

	if location == 0:
		break

#print('right_cost  ',right_cost)
#print('left_cost   ',left_cost)
print(min(right_cost,left_cost))


Measured memory_bytes: 3060
N=int(input())
T=[list(map(int,input().split())) for i in range(N)]
X=0
c=1
for i in range(N):
  for j in range(N):
    X=X+((abs(T[i][0]-T[j][0]))**2+(abs(T[i][1]-T[j][1]))**2)**0.5
for r in range(1,N+1):
  c=c*r
print(X/N)

Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    D, T, S = [int(x) for x in input().split()]
    if T * S >= D:
        print("Yes")
    else:
        print("No")

    

if __name__ == '__main__':
    main()



Measured memory_bytes: 9104
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll s[55];
int main()
{
  ll n, m;
  scanf("%lld%lld", &n, &m);
  for (int i = 0; i < m; i++)
  {
    ll a, b;
    scanf("%lld%lld", &a, &b);
    s[a]++;
    s[b]++;
  }
  for (int i = 1; i <= n; i++)
  {
    printf("%lld\n", s[i]);
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        double sum = 0;
        double result;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                sum += Math.sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
            }
        }
        result = (sum * 2) / n;
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define LL long long
#define db double
using namespace std;

#define MAXN 200200
#define MAXE 400400

typedef pair<int, int> pii;
#define X first
#define Y second
const LL INF = (1LL << 62) | 3;
#define Debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> inline void read(T &x) {
    int ch = getchar();
    bool fg = false;
    for (x = 0; !isdigit(ch); ch = getchar()) {
        if (ch == '-') {
            fg = true;
        }
    }
    for (; isdigit(ch); ch = getchar()) {
        x = x * 10 + ch - '0';
    }
    if (fg) {
        x = -x;
    }
}

template <typename T> inline bool chkmin(T& x, const T& y) { return y < x ? (x = y, true) : false; }
template <typename T> inline bool chkmax(T& x, const T& y) { return x < y ? (x = y, true) : false; }

int a[6], k;

signed main() {
	for(int i = 1; i <= 5; i++) read(a[i]); read(k);
	if(a[5] - a[1] > k) cout << ":(";
	else cout << "Yay!";
	return 0;
}

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

WHITE = 0
GRAY = 1
BLACK = 2

INF = 2000000000

def dijkstra(s):
    while True:
        u = 0
        mincost = INF
        for i in range(n):
            if color[i] != BLACK and d[i] < mincost:
                mincost = d[i]
                u = i
                
        if mincost == INF:
            break
    
        color[u] = BLACK
        
        for v in range(n):
            if color[v] != BLACK and m[i][v] != -1:
                if d[u] + m[u][v] < d[v]:
                    d[v] = d[u] + m[u][v]
                    p[v] = u
                    color[v] = GRAY

n = int(input())

m = [[INF for i in range(n)] for j in range(n)]
for i in range(n):
    nums=list(map(int,input().split()))
    for j in range(nums[1]):
        m[i][nums[2*j+2]] = nums[2*j+3]

color = [WHITE] * n
d = [INF] * n 
d[0] = 0
p = [-1] * n

dijkstra(0)
for v in range(n):
    print(v, d[v])












Measured memory_bytes: 5728
int main(void){
	int a[10000];
	int n;
	int i;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%d",&a[i]);
	}
	
	int min = 1000001;
	int max = -1000001;
	long sum = 0;
	
	for(i = 0;i < n;i++){
		sum += a[i];
		if(min > a[i])min = a[i];
		if(max < a[i])max = a[i];
	}
	
	printf("%d %d %ld\n",min,max,sum);
	
	return 0;
}

Measured memory_bytes: 640
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

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

reader.on('close', () => {
 var n = Number(lines[0]);
 var stock = new Set();
 for(i=1; i<=n; i++){
   stock.add(lines[i]);
 }

 console.log(stock.size);


 
});

Measured memory_bytes: 58072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int N;
    vi A;
    cin >> N;
    A.resize(N);
    REP(i, N)
    cin >> A[i];

    sort(A.begin(), A.end(), greater<int>());

    while (true)
    {
        if (A.size() == 1)
            break;
        REP(i, A.size() - 1)
        A[i] %= A[A.size() - 1];

        sort(A.begin(), A.end(), greater<int>());
        while (true)
        {
            if (A[A.size() - 1] == 0)
                A.pop_back();
            else
                break;
        }
    }
    cout << A[0] << endl;
    //system("pause");
}

Measured memory_bytes: 1024