akhauriyash/Code-Regression huggingface dataset:
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n,m = mi()
    a = li()
    s = sum(a)
    kyoukai = s/(4*m)
    cnt = 0
    for i in a:
        if i >= kyoukai:
            cnt+=1
    if cnt>=m:
        print(yes)
    else:
        print(no)

main()





Measured memory_bytes: 5372
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
//if(strcmp(s[i],"AC")==0)
//if(s[l]=='#')
/*小文字判定
if((moji>= 'a') && (moji<='z')){
    printf("a\n");
    return 0;
  }
  */
//文字列中の一文字⇒数字の時は s[i]-'0'
int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(long long int *a, long long int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

long long int cmp( const void *p, const void *q ) {
    return *(long long int*)p - *(long long int*)q;
}//ちいさい順
//qsort(a,n,sizeof(long long int),cmp);


int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);
//char s[n][11]

long long int GCD(long long int a, long long int b){
  long long int L=a,S=b;
  while(1){
    if(S>L){
      L=S+L;
      S=L-S;
      L=L-S;
    }
    if(L%S==0){
      return S;
    }
    L=L%S;
  }
  
}

long long int LCM(long long int a, long long int b){
  return a*b/(GCD(a,b));
}

int main (void)
{
	long long int n,i,min,k,a[210000],max,j=1,count=0;
scanf("%lld",&n);
  scanf("%lld",&a[0]);
  max=a[0];
for(i=1;i<n;i++){
  scanf("%lld",&a[i]);
  if(a[i]>max){
    max=a[i];
    continue;
  }
  count+=max-a[i];
  continue;
}  

  
  printf("%lld",count);
return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vll a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<bool> used(n);
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    int next = -1, now = 0;
    for (int j = 0; j < n; j++) {
      if (used[j]) {
        now++;
        continue;
      }
      if (now == a[j] - 1) {
        next = j;
      }
    }
    if (next >= 0) {
      ans.push_back(a[next]);
      used[next] = true;
    }
  }
  if (ans.size() == n) {
    for (int i = 0; i < n; i++)
      cout << ans[i] << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
import static java.lang.System.*;
public class Main
{
public static void main(String args[])throws Exception
{
     Scanner sc=new Scanner(in);
     long n=sc.nextLong();
      long m=sc.nextLong();
      long sum=Math.min(n,m/2);
      n-=sum;
      m-=2*sum;
      if(m>0)
      sum+=m/4;
      out.println(sum);
     }
}

Measured memory_bytes: 23764
N , D = map ( int , input().strip().split(" ") ) ;
c = 0 ;


e = D * D ;
for z in range ( N )  :
	p , q = map ( int , input().strip().split(" ") ) ;
	x2 =  p * p + q * q  ;
	if x2 <= e :
		c += 1 ; 
print ( c ) ;

Measured memory_bytes: 9188
import java.util.*;
class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt(); //入力数
		int K = sc.nextInt(); //進数	
	
		int count = 0;
		
		while(N > 0){
			N = N / K;
			count++;
		}
		
		System.out.println(count);
	}
}
		

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

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> V(N),C(N),G(N);
  rep(i,N) cin >> V[i];
  rep(i,N) cin >> C[i];
  rep(i,N) G[i] = V[i] - C[i];
  int sum = 0;
  rep(i,N)
  {
    if(G[i]>0)
    {
      sum += G[i];
    }
  }
  cout << sum << endl;
  return 0;
}


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

const int N = 50 + 5, mod = 1e9 + 7;
int n, k;
int a[N], dp[N][N][102];

int solve(int l, int r, int left)
{
    if (l > r)
        return 0;
    if (dp[l][r][left] != -1)
        return dp[l][r][left];
    int ans = 0;
    if (a[l] < 0)
    {
        if (left > 0)
            ans = max(ans, solve(l + 1, r, left - 1) + a[l]);
        if (left > 1)
            ans = max(ans, solve(l + 1, r, left - 2));
    }
    if (a[l] >= 0 && left > 0)
        ans = max(ans, solve(l + 1, r, left - 1) + a[l]);
    if (a[r] < 0)
    {
        if (left > 0)
            ans = max(ans, solve(l, r - 1, left - 1) + a[r]);
        if (left > 1)
            ans = max(ans, solve(l, r - 1, left - 2));
    }
    if (a[r] >= 0 && left > 0)
        ans = max(ans, solve(l, r - 1, left - 1) + a[r]);
    return dp[l][r][left] = ans;
}

int main()
{
    //ios::sync_with_stdio(false);cin.tie(nullptr);ios_base::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0, n - 1, k);
    return 0;
}

Measured memory_bytes: 4812
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int k=sc.nextInt();
    int x=sc.nextInt();
    if((500*k) < x) {
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;


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

    cout << N*(N-1)/2+M*(M-1)/2 << endl;

   
}

Measured memory_bytes: 256
#include <cstdio>

#define max(a, b) ((a) > (b) ? (a) : (b))

int main()
{
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  printf("%d\n", max(a, max(b, c)) * 9 + (a + b + c));
  return 0;
}


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

int main() {
  string S, T, U;
  int A = 0, B = 0;
  cin >> S >> T >> A >> B >> U;

  if (S == U) {
    cout << A - 1 << " " << B;
  }
  else if (T == U) {
    cout << A << " " << B - 1;
  }

}

Measured memory_bytes: 256
package main;import "fmt";func main(){var n,q,i,j int;var k int64;fmt.Scan(&n,&q);p:=[]int64{0,int64(n)};for i=0;i<q;i++{fmt.Scan(&k);j=len(p);for k<=p[j-1]{j--};p=append(p[:j],k)};q=len(p)-1;t:=make([]int64,q+1);t[q]=1;a:=make([]int64,n+2);for i=q;i>0;i--{j,k=i,p[i];for k>p[1]{l,r:=1,j;for r-l>1{m:=(l+r)/2;if p[m]>k{r=m}else{l=m}};j=l;t[j]+=k/p[j]*t[i];k%=p[j]};a[k]+=t[i]};for i=n;i>0;i--{a[i]+=a[i+1]};for i=1;i<=n;i++{fmt.Println(a[i])}}

Measured memory_bytes: 8836
s=input()

count=0
for i in range(len(s)):
    if (i+1)%2==1 :
        if s[i] in ["R","U","D"]:
            count+=1
    if (i+1)%2==0:
        if s[i] in ["L","U","D"]:
            count+=1
    
if count==len(s):
    print("Yes")
else:
    print("No")

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

int main(void)
{
    while (1) {
        int n;
        scanf("%d", &n);

        if (!n) break;

        double score[n];
        double avg = 0, var = 0, stdev = 0, sum = 0;

        int i;
        for (i = 0; i < n; i++) {
            double s_i;
            scanf("%lf", &s_i);

            sum += s_i;
            score[i] = s_i;
        }

        avg = sum / n;

        for (i = 0; i < n; i++)
            var += pow(score[i] - avg, 2);

        var /= n;

        stdev = sqrt(var);

        printf("%f\n", stdev);
    }

    return 0;
}

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

static const int SEN = 2000000000;

struct Card {
	char suit;
	int num;
};

void merge(Card A[], int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	Card L[n1 + 1], R[n2 + 1];
	for (int i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}
	L[n1].num = R[n2].num = SEN;
	int i = 0, j= 0;
	for (int k = left; k < right; k++) {
		if (L[i].num <= R[j].num) {
			A[k] = L[i++];
		} else {
			A[k] = R[j++];
		}
	}	
}

void mergeSort(Card A[], int left, int right) {
	if (right - left > 1) {
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int partition(Card A[], int p, int r) {
	int x = A[r].num;
	int i = p - 1;
	for (int j = p; j < r; j++) {
		if (A[j].num <= x) {
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i + 1], A[r]);
	return i + 1;
}

void quicksort(Card A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q - 1);
		quicksort(A, q + 1, r);
	}
}

bool check(Card A[], Card B[], int n) {
	for (int i = 0; i < n; i++) {
		if (A[i].suit != B[i].suit) return false;  //????????????*???????????????????????????==???????????????????????§??????
	}
	return true;
}

int main() {
	int n;
	cin >> n;
	Card A[n], B[n];
	for (int i = 0; i < n; i++) {
		cin >> A[i].suit >> A[i].num;
		B[i].suit = A[i].suit;
		B[i].num = A[i].num;
	}

	quicksort(A, 0, n - 1);
	mergeSort(B, 0, n);

	if (check(A, B, n)) {
		cout << "Stable" << endl;
	} else {
		cout << "Not stable" << endl;
	}

	for (int i = 0; i < n; i++) {
		cout << A[i].suit << " " << A[i].num << endl;
	}
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	vector <ll> arr(n);
	for (int z=0;z<n;z++){
		cin >> arr[z];
	}
	vector <ll> pre(n);
	vector <ll> suf(n);
	pre[0] = arr[0];
	suf[n-1] = arr[n-1];
	for (int z=1;z<n;z++){
		pre[z] = pre[z-1]+arr[z];
	}
	for (int z=n-2;z>-1;z--){
		suf[z] = suf[z+1]+arr[z];
	}
	ll ans = LLONG_MAX;
	for (int z=0;z<n-1;z++){
		ans = min(ans,abs(pre[z]-suf[z+1]));
	}
	cout << ans << endl;
	cin >> n;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
    int F => int.Parse(Str);
    long FL => long.Parse(Str);
    int[] G => Strs.Select(int.Parse).ToArray();
    long[] GL => Strs.Select(long.Parse).ToArray();
    string Str => ReadLine();
    string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    const int MOD = 998244353;
    public K()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        WriteLine(Solve());
        Out.Flush();
    }
    long Solve()
    {
        var N = F;
        var A = new int[N];
        for (var i = 0; i < N; i++) A[i] = F;
        // 0    1    2   3    4
        // null even odd even null (どの区間も長さ 0 になりうる)
        // dp[i,s] = A[0,i) まで見て, 状態 s まで来ているときの最小値
        // 答えは dp[N,4]
        // dp[i,s] => dp[i,s+1]
        // dp[i,s] => dp[i+1,s]
        var dp = new long[N + 1, 5];
        for (var i = 1; i <= N; i++) for (var s = 0; s < 5; s++) dp[i, s] = long.MaxValue / 10;
        for (var i = 0; i <= N; i++)
            for (var s = 0; s < 5; s++)
            {
                if (s < 4) dp[i, s + 1] = Min(dp[i, s + 1], dp[i, s]);
                if (i < N)
                {
                    // dp[i,s] => dp[i+1,s] (A[i] をどうするか)
                    if (s == 0 || s == 4) dp[i + 1, s] = Min(dp[i + 1, s], dp[i, s] + A[i]);
                    else if (s == 2) { dp[i + 1, s] = Min(dp[i + 1, s], dp[i, s] + (A[i] + 1) % 2); }
                    else dp[i + 1, s] = Min(dp[i + 1, s], dp[i, s] + (A[i] == 0 ? 2 : A[i] % 2));
                }
            }
        //for (var i = 0; i <= N; i++) for (var s = 0; s < 5; s++) WriteLine($"dp[{i}, {s}] = {dp[i, s]}");
        return dp[N, 4];
    }
}

Measured memory_bytes: 23644
/*input
20
xxzaffeeeeddfkkkkllq
*/
#include "bits/stdc++.h"
using namespace std;
int n; string s;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin >> n >> s;
	int ans = 0;
	for(int i=0,j;i<n;i=j){
		for(j=i;j<n&&s[j]==s[i];++j);
		++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
def all_visitable?(ways)
  start_p = ways.keys.first
  queue = [start_p]
  already_visit = [start_p]
  while !queue.empty?
    ways[queue.shift].each do |next_p|
      unless already_visit.include?(next_p)
        already_visit.push(next_p)
        queue.push(next_p)
      end
    end
  end
  already_visit.count == ways.keys.count
end

N, M = gets.split.map(&:to_i)
arrs = M.times.map { gets.split.map(&:to_i) }
ways = {}
arrs.each do |from, to|
  ways[from] ||= []
  ways[from] << to
  ways[to] ||= []
  ways[to] << from
end

counter = M
arrs.each do |arr|
  next_ways = ways.merge({}) #deep cp
  next_ways[arr[0]] = next_ways[arr[0]] - [arr[1]]
  next_ways[arr[1]] = next_ways[arr[1]] - [arr[0]]
  counter -= 1 if all_visitable?(next_ways)
end
puts counter

Measured memory_bytes: 2044
// 1_8_B
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i, sum;
  string n;

  while(true){
    sum = 0;
    cin >> n;
    if(n == "0") return 0;

    for(i = 0; i < (int)n.length(); i++){
      sum += n[i] - '0';
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 3168
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		long k = sc.nextLong();
		
		// 計算
		int result = 1;
		for(int i = 0; i < s.length(); i++){
		    int m = s.charAt(i) - '0';
		    if(m != 1){
		        result = m;
		        break;
		    }
		    k--;
		    if(k == 0) break;
		}
		
		// 出力
		System.out.println(result);
	}
}


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

int main()
{
    int M, D;
    cin >> M >> D;

    int res=0;
    for(int i=1;i<=M;i++){
        for(int j=1;j<=D;j++){
            if(j%10 < 2) continue;
            if(j/10 < 2) continue;
            if((j/10) * (j%10) == i) res++;
        }
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
def main3():
    n = int(input())
    s = input()

    ans = s.count("R") * s.count("B") * s.count("G")
    for i in range(n):
        for j in range(i, n):
            k = 2 * j - i
            if k >= n: break
            if s[i] != s[j] and s[j] != s[k] and s[i] != s[k]:
                ans -= 1

    print(ans)

if __name__ == '__main__':
    main3()


Measured memory_bytes: 68048
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let v:Vec<i64> = (0..n).map(|_| read()).collect();
    let mx = v.iter().max().unwrap();
    let h = if mx % 2 == 0 {
        mx / 2
    } else {
        (mx+1) / 2
    };
    let mut mn = h;
    let mut e = v.iter().min().unwrap();
    for i in &v {
        if (h-i).abs() < mn {
            mn = (h-i).abs();
            e = i;
        }
    }
    println!("{} {}", mx, e);
}

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

const int maxn=3005;
const double pi=acos(-1);
int n;
long long L;
long long t[maxn];

int main(){
	scanf("%d%lld",&n,&L);
	for(int i=1;i<=n;i++)scanf("%lld",&t[i]);
	double ansx=0,ansy=0;
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++){
		ansx+=(j-i-1)*cos(double(t[i]+t[j]+L)*pi/double(L));
		ansx+=(n+i-j-1)*cos(double(t[i]+t[j])*pi/double(L));
		ansy+=(j-i-1)*sin(double(t[i]+t[j]+L)*pi/double(L));
		ansy+=(n+i-j-1)*sin(double(t[i]+t[j])*pi/double(L));
	}
	double tot=double(n)*double(n-1)*double(n-2)/6.0;
	printf("%.15lf %.15lf\n",ansx/tot,ansy/tot);
	return 0;
}

Measured memory_bytes: 256
from scipy.misc import comb
n , k = map(int, input().split())

mod = 10 ** 9 + 7
red_count = n - k 
for i in range(1, k+1) :
    if red_count + 1 - i < 0 :
        print(0)
        
    else:

        print(comb(red_count+1, i , exact = True)*comb(k-1, i-1, exact=True) % mod)
        

Measured memory_bytes: 14728
#include<iostream>
using namespace std;
int main(){
  int N,M;
  //cout << "?????´???:";
  cin >> N;
  //cout << "?£??¨????:";
  cin >> M;

  //cout << "?£??¨???????:?\n";
  int a[255];

  for(int i=0; i<M; i++){
    cin >> a[i];
  }

  cout << N-M-1 << endl;

}

Measured memory_bytes: 3072
/**
 *
 * AtCoder Beginner Contest 103 - Problem B: String Rotation (https://abc103.contest.atcoder.jp/tasks/abc103_b)
 *
 * Find if the string T is a rotation of the string S.
 *
 * String solution: check all rotations of T. Another solution: let X = S + S. Check if T is a 
 * substring of X.
 */
#include <iostream>

using namespace std;

void solve(const string& S, const string& T)
{
    auto X = S + S;
    auto it = X.find(T);

    cout << (it == string::npos ? "No" : "Yes") << endl;

   /* 
    auto N = T.size();
    auto x = T;

    for (int i = 0; i < N; ++i)
    {
        if (x == S)
        {
            cout << "Yes\n";
            return;
        }

        auto y = x.back() + x.substr(0, N - 1);
        x = y;
    }

    cout << "No" << endl; */
}

int main()
{
    ios::sync_with_stdio(false);

    string S, T;
    cin >> S >> T;

    solve(S, T);

    return 0;
}


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

#define int long long

auto main() -> signed {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; ++i) cin >> v[i];

    int sum = accumulate(v.begin(), v.end(), 0LL);
    int ans = 1e+18;
    int tmp = 0;
    for(int i=0; i<v.size()-1; ++i) {
        tmp += v[i];
        sum -= v[i];
        ans = min(ans, abs(tmp-sum));
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define dec(i, l, r) for (int i = l; i>=r;i--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define ii pair<int,int>
#define max(a, b) (((a)<(b))?b:a)
#define min(a, b) ((a>b)?b:a)
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define pi 3.141592653589793238
#define inf ((ll)1e18)
#define eps 1e-14
#define mod ((int)1e9+7)
#define maxlg 18
#define maxn 200002
#define left(i) ((i)<<1)
#define right(i) (((i)<<1)+1)


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
 
#endif
     int n,m;
    cin>>n>>m;
    int run = 1;
    rep (i,0,m)run = run*2;
    cout<< run*((n-m)*100 + (m )*(1900)) ;

    return 0;
}
























Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <vector>
using namespace std;
int main() {
    int n, m;
    while (scanf("%d%d",&n,&m)) {
        if (n==0&&m==0) break;
        vector<int> friends[n];
        for (int i=0; i<m; i++) {
            int a,b; scanf("%d%d",&a,&b);
            friends[a-1].push_back(b-1);
            friends[b-1].push_back(a-1);
        }
        set<int> s;
        for (int i=0; i<friends[0].size(); i++) {
            s.insert(friends[0][i]);
            for (int j=0; j<friends[friends[0][i]].size(); j++) {
                if (friends[friends[0][i]][j]!=0) s.insert(friends[friends[0][i]][j]);
            }
        }
        printf("%d\n",s.size());
    }
}

Measured memory_bytes: 0
#ifdef loc
    #include "codes/loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 200005;


int gs[N], gv[N], ngv[N], sums[N], gn[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    int mod = 1e9 + 7;
    int tg = 1;
    gs[0] = n;
    while(true) {
        gs[tg] = n / (n / gs[tg - 1] + 1);
        if(gs[tg] == 0) {
            break;
        }
        tg++;
    }
    rep(i, 0, tg) gv[i] = 1;
    gn[0] = tg - 1;
    rep(i, 1, tg) {
        gn[i] = gn[i - 1];
        int x = n / gs[i];
        while(gs[gn[i]] < x) {
            gn[i]--;
        }
    }
    while(k-- > 0) {
        rep(i, tg, 0) {
            sums[i] = int((sums[i + 1] + (gs[i] - gs[i + 1]) * (ll)gv[i]) % mod);
        }
        rep(i, 0, tg) {
            int x = n / gs[i];
            ngv[i] = int((sums[gn[i] + 1] + (x - gs[gn[i] + 1]) * (ll)gv[gn[i]]) % mod);
            /*
            rep(j, tg, 0) {
                if(x > gs[j]) {
                    res = int((res + (gs[j] - gs[j + 1]) * (ll)gv[j]) % mod);
                } else {
                    res = int((res + (x - gs[j + 1]) * (ll)gv[j]) % mod);
                    break;
                }
            }
            */
        }
        rep(i, 0, tg) {
            gv[i] = ngv[i];
        }
    }
    cout << sums[0] << endl;
}

Measured memory_bytes: 1536
#41 A - Shrinking
import collections 
s = list(input())
cnt = collections.Counter(s)
valcnt = list(cnt.values())
M = max(valcnt)
# 出現回数が最多の文字リスト
mkeys = [i for i,v in cnt.items() if v == M]

ans = len(s)
for key in s:
    m = 0
    cnt = 0
    # 最多の文字の区間の最大値がその文字の最小値
    for S in s:
        if S == key: 
            m = max(m,cnt)
            cnt = 0
        else:
            cnt += 1
    m = max(m,cnt)
    ans = min(ans,m)

print(ans)

Measured memory_bytes: 9316
#include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;
const int INF = 1<<29;

// グラフ
using Edge = pair<int,long long>; // {辺の行き先, 重み}
using Graph = vector<vector<Edge> >; // グラフ

// 使われうる辺集合
set<pair<int,int> > use;

// s を始点とする Dijkstra
vector<long long> Dijkstra(const Graph &G, int s) {
    vector<long long> dist((int)G.size(), INF);
    vector<vector<int> > prev((int)G.size()); // prev[v] := v から復元できる辺たち
    dist[s] = 0;
    priority_queue<pair<long long,int>, vector<pair<long long,int> >, greater<pair<long long,int> > > que;
    que.push({0, s});
    while (!que.empty()) {
        auto cur = que.top(); que.pop();
        long long cur_dist = cur.first;
        int v = cur.second;
        //if (cur_dist > dist[v]) continue; // 効く枝刈り
        for (auto e : G[v]) {
            if (dist[e.first] > dist[v] + e.second) {
                dist[e.first] = dist[v] + e.second;
                que.push({dist[e.first], e.first});

                // 復元のための
                prev[e.first].clear();
                prev[e.first].push_back(v);
            }
            else if (dist[e.first] == dist[v] + e.second) {
                prev[e.first].push_back(v);
            }
        }
    }

    // 使われうる辺集合
    for (int v = 0; v < (int)G.size(); ++v) {
        for (auto u : prev[v]) {
            use.insert(make_pair(min(u, v), max(u, v)));
        }
    }
    return dist;
}

int main() {
    int N, M; cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b; long long c;
        cin >> a >> b >> c;
        --a, --b;
        G[a].push_back(Edge(b, c));
        G[b].push_back(Edge(a, c));
    }
    for (int v = 0; v < N; ++v) Dijkstra(G, v);
    cout << M - (int)use.size() << endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
	int N;

	cin >> N;
	char ch;
	bool ans = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> ch;
		if (ch == 'Y')
			ans = 1;
	}

	if (ans == 0) cout << "Three" << endl;
	else cout << "Four" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        int change = 1000 - n;
        int count = 0;
        if (change >= 500) {
            change -= 500;
            count++;
        } 
        if (change >= 100) {
            int coin_100 = change / 100;
            change -= 100 * coin_100;
            count += coin_100;
        } 
        if (change >= 50) {
            change -= 50;
            count++;
        }
        if (change >= 10) {
            int coin_10 = change / 10;
            change -= 10 * coin_10;
            count += coin_10;
        }
        if (change >= 5) {
            change -= 5;
            count++;
        }
        count += change;
        cout << count << endl;
    }
    return 0;
}
            

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

int main(){
  int n,w;
  cin >>n>>w;
  vector<int> wei(n+1);
  vector<int> val(n+1);
  rep1(i,n) cin >>wei[i]>>val[i];
  vector<vector<ll>> dp(n+1, vector<ll>(w+1));
  rep1(i,n){
    rep1(j,w){
      ll tmp;
      if(j < wei[i]) tmp = 0;
      if(j == wei[i]) tmp = val[i];
      if(j > wei[i]) tmp = dp[i-1][j-wei[i]]+val[i];
      dp[i][j] = max(tmp,dp[i-1][j]);
    }
  }
  cout << dp[n][w] << endl;
}

Measured memory_bytes: 80256
# d日目の終わりの低下する満足度
def cost(c, d, lastdi):
    total = 0
    for i in range(26):
        total += c[i]*(d - lastdi[i])
    return total

# 最終日
D = int(input())
# type毎の満足度の下がりやすさ
c = list(map(int, input().split()))
# [d,i]の満足度
s = [[] for _ in range(D)]
for d in range(D):
    si = list(map(int, input().split()))
    s[d] = si

# type毎の最後に開催された日を管理
lastdi = [0 for _ in range(26)]

for d in range(D):
    typei = s[d].index(max(s[d])) + 1
    print(typei)


Measured memory_bytes: 9508
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  ll n;
  std::cin >> n;

  ll ans = 1e9;
  for (ll num = 1; num*num <= n; num++) {
    if(n%num==0)
      ans = (num - 1) + (n/num -1);
  }

  std::cout << ans << '\n';
  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 A = sc.nextInt();
	int B = sc.nextInt();
	int C = sc.nextInt();

	if(C-A+B>=0) {
	System.out.print(C - A + B);
	}
	else if(C-A+B<0) {
		System.out.print(0);
	}

}
}

Measured memory_bytes: 21844
from collections import defaultdict
dd = defaultdict(lambda:False) # 作れる数はTrue

n = int(input())
li_a = list(map(int, input().split()))
q = int(input())
li_m = list(map(int, input().split()))

for i in range(1<<len(li_a)):
    sum_ = 0
    # j 桁目が１のときその商品を数字をたす
    for j in range(len(li_a)):
        if (i >> j) & 1:
            sum_ += li_a[j]
    dd[sum_] = True
    
for i in li_m:
    if dd[i]:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 6092
import sys


def resolve():
    N_BILLS, YEN_TOTAL = [int(x) for x in sys.stdin.readline().split()]

    is_answer_found = False
    for i_ten in range(N_BILLS + 1):
        for i_five in range(N_BILLS + 1 - i_ten):
            i_one = N_BILLS - i_ten - i_five
            if i_ten * 10000 + i_five * 5000 + i_one * 1000 == YEN_TOTAL:
                is_answer_found = True
                print("{} {} {}".format(i_ten, i_five, i_one))
                break
        if is_answer_found:
            break
    if not is_answer_found:
        print("-1 -1 -1")


if __name__ == "__main__":
    resolve()

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """9 45000"""
        output = """4 0 5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """20 196000"""
        output = """-1 -1 -1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1000 1234000"""
        output = """14 27 959"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """2000 20000000"""
        output = """2000 0 0"""
        self.assertIO(input, output)


Measured memory_bytes: 51056
import java.util.Scanner;

public class Main {
	long c[];
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum =0;
		int min =1000;
		for (int i =0;i<N;i++) {
			int a= sc.nextInt();
			sum +=a;
			if (a%10!=0&&min>a) {
				min =a;
			}
		}
		if (sum %10!=0) {
			System.out.println(sum);
		} else if (min==1000){
			System.out.println(0);
		} else {
			System.out.println(sum-min);
		}
	}
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s; cin >> s;
  cout << s.substr(0, 3) << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N - 1), b(N - 1);
  rep(i, N - 1) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }

  vector<int> cnt(N);
  rep(i, N - 1) {
    cnt[a[i]]++;
    cnt[b[i]]++;
  }

  int K = 0;
  rep(i, N) {
    chmax(K, cnt[i]);
  }

  cout << K << endl;

  vector<vector<int>> G(N);
  rep(i, N - 1) {
    G[a[i]].pb(b[i]);
  }


  vector<int> color(N);
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int now = q.front();
    int now_c = color[now];
    q.pop();
    for (int to : G[now]) {
      now_c++;
      if (now_c > K)
        now_c -= K;
      color[to] = now_c;
      q.push(to);
    }
  }

  rep(i, N - 1) {
    cout << color[b[i]] << endl;
  }
}


Measured memory_bytes: 6016
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()
    
    s = input()
    n = (len(s)-1)//2
    ans = 0
    for i in range(1,n+1):
        if (s[:i] == s[i:2*i]):
            ans = 2*i
    print(ans)




if __name__ == '__main__':
    main()

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

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

    vector<int> roads(n);
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        roads[a] += 1;
        roads[b] += 1;
    }

    for(int i=0; i<n; i++){
        cout << roads[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main()
    {
        string S = Console.ReadLine();
        int ans = 0;
        char Q = S[0];
        for (int i = 1; i < S.Length; i++)
            if (S[i] != Q)
            {
                ans++;
                Q = S[i];
            }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 3032
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = list(input())
L = len(S)

c = 0
t = 0
md = [0] * 2019
md[0] += 1
for i in range(L - 1, -1, -1):
    t += int(S[i]) * pow(10, c, 2019)
    c += 1
    md[t % 2019] += 1

ans = 0
for i in range(2019):
    m = md[i]

    if m == 0:
        continue

    ans += m * (m - 1) // 2

print(ans)


Measured memory_bytes: 10572
#include <iostream>
#include <string>

using namespace std;

int main(void){
    string str;
    string judge;
    int n;
    int count=0;

    cin>>judge;
    cin>>n;
    while(n--){
        cin>>str;
        str.append(str.begin(),str.end());
        if(str.find(judge)!=string::npos)count++;
    }
    cout<<count<<endl;
    return(0);
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;

int main()
{
    ll n,m,i,a=0,b=0,k;
    cin>>n>>m>>k;
    a=n-k;
    cout<<max((ll)0,a)<<" ";
    k-=n;
    if(k>0) 
    {
        a=m-k;
        cout<<max((ll)0,a);
    }
    else cout<<m;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;

int main()
{
    ll n,m;
    cin>>n>>m;
    ll mi=0;
    ll k=m/2-n;
    if(k<=0){
        cout<<min(n,m/2)<<endl;
        return 0;
    }
    for(ll i=max(0ll,k-2);i<min(m+1,k+2);i++){
        mi=max(mi,min(n+i/2,(m-i)/2));
    }
    cout<<mi<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#define llint long long

using namespace std;

llint n;
llint a[100005], d[100005];

int main(void)
{
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	
	llint sum = 0;
	for(int i = 0; i < n; i++) sum += a[i];
	llint div = n * (n+1) / 2;
	
	if(sum % div){
		cout << "NO" << endl;
		return 0;
	}
	llint num = sum / div;
	
	for(int i = 0; i < n; i++){
		d[i] = -(a[(i+1)%n] - a[i] - num);
	}
	llint cnt = 0;
	for(int i = 0; i < n; i++){
		if(d[i] < 0 || d[i] % n){
			cout << "NO" << endl;
			return 0;
		}
		cnt += d[i] / n;
	}
	
	if(cnt == num) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define int long long

#define sz(c) c.size()
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define ppb  pop_back
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,n)   for( int i=a ; i<n ; i++)
#define U 1000000007
#define N 100005
#define ins insert
using namespace std;
signed main()
{
  ios_base::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  int w[n+1],v[n+1],dp[n+1][m+1];
  rep(i,1,n+1) cin>>w[i]>>v[i];

  rep(i,0,n+1)
  {
    rep(j,0,m+1)
    {
      if(i==0||j==0) dp[i][j]=0;
      else if(w[i]<=j)
        dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
      else dp[i][j]=dp[i-1][j];
    }
  }
  cout<<dp[n][m];
  
 



}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B;
	
	ll ret=N/(A+B)*A;
	N%=(A+B);
	ret+=min(A,N);
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair < ll, int > PLI;


#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

#define fname ""

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 1e6 + 6;

int n;
int a[N], cnt[N];

bool check() {
    bool res = 0;
    forn(i, 1, n) {
        if (cnt[n - 1] == cnt[n - i] + cnt[i - 1])
            res ^= (a[i] == 1);
    }
    return res;
}

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

    #ifdef krauch
        freopen("input.txt", "r", stdin);
    #else
        //freopen(fname".in", "r", stdin);
        //freopen(fname".out", "w", stdout);
    #endif

    cin >> n;
    forn(i, 1, n) {
        char c;
        cin >> c;
        a[i] = c - '1';
    }

    forn(i, 1, n) {
        cnt[i] = cnt[i - 1] + __builtin_ctz(i);
    }

    if (check()) {
        cout << "1\n";
        return 0;
    }

    forn(i, 1, n) {
        if (a[i] == 1) {
            cout << "0\n";
            return 0;
        }
        if (a[i] == 2) a[i] = 1;
    }

    if (check()) {
        cout << "2\n";
        return 0;
    }

    cout << "0\n";

    return 0;
}


Measured memory_bytes: 8192
package main
import(
  "fmt"
)
func main(){
  var n, i int
  fmt.Scan(&n)
  a:=make([]int, n)
  for i=0;i<n;i++{
    fmt.Scan(&a[i])
  }
  ans:=0
  l:
  for{
    for i=0;i<n;i++{
      if a[i]%2==0{
        a[i]/=2
      }else{
        break l
      }
    }
    ans++
  }
  fmt.Println(ans)
}


Measured memory_bytes: 512
#include<stack>
#include<map>
#include<set>
#include<cstdio>
#include<vector>
#include<iostream>
#include<string>
#include<algorithm> 
using namespace std;
int main(){
	int a,b,c,k,ans;
	cin>>a>>b>>c;
	k=max(max(a,b),c);
	ans=k*3-a-b-c;
	while(ans%2){
		ans+=3;
	}
	cout<<ans/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  bool L=true;
  cin>>N;
  vector<long long>vec(N);
  for(int X=0;X<N;X++){
    cin>>vec.at(X);
  }
  for(int X=N-1;X>=0;X--){
    if(X<N-1 && vec.at(X+1)<vec.at(X)){
      if(vec.at(X)-1!=vec.at(X+1)){
        L=false;
      }
      else{
        vec.at(X)--;
      }
    }
  }
  if(L==true){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 4016
num = input().split()
num=[int(i) for i in num]

if num[1]!=0:
  line = input().split()
  line=[int(i) for i in line]

  m=0
  while m>=0:
    if num[0]-m not in line:
      print(num[0]-m)
      break
    elif num[0]+m not in line:
      print(num[0]+m)
      break
    else:
      m+=1

else:
  print(num[0])

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define INF (1e9)
#define MAX_V 2010
#define MAX_N 1010
using namespace std;
struct edge{int to, cap, rev;};
vector<edge> G[MAX_V]; //??°???????????£??\?????????
bool used[MAX_V];      //DFS??§?????§??????????????????????????°
//from??????to??????????????????cap???????????°?????????????????????
void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});  
}

//?¢?????????????DFS??§??¢???
int dfs(int v,int t,int f){
  if(v == t)return f;
  used[v]=true;
  for(int i=0; i<G[v].size() ;i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to ,t , min(f,e.cap));
      if(d > 0){
	e.cap -= d;
	G[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

//s??????t???????????§???????±???????
int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s, t, INF);
    if(f == 0)return flow;
    flow += f;
  }
}

bool can[MAX_N][MAX_N]; //can[i][j]:=???????????\??????i?????????j??????????????????
int Biparite_Matching(int N,int K){
  int s = N+K, t = s+1;
  for(int i=0; i<N; i++) add_edge(s,i,1);
  for(int i=0; i<K; i++) add_edge(N+i,t,1);
  
  for(int i=0;i<N;i++)
    for(int j=0;j<K;j++)
      if(can[i][j]) add_edge(i, N+j , 1);
  return max_flow(s,t);
}



int main(){
  int n,m,l;
  while(1){
    cin>>n>>m>>l;
    if(!n&&!m&&!l)break;
    vector<vector<int> >g(n,vector<int>(n,INF));
    for(int i=0;i<n;i++) g[i][i]=0;
    for(int i=0;i<MAX_V;i++)G[i].clear();
    
    for(int i=0,a,b,c;i<m;i++)cin>>a>>b>>c,g[a][b]=g[b][a]=c;
    
    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
    
    vector<int>idx(l),tl(l);
    for(int i=0,a,b;i<l;i++)cin>>a>>b,tl[i]=b,idx[i]=a;
    
    
  memset(can,0,sizeof(can));
  for(int i=0;i<l;i++)
    for(int j=0;j<l;j++)
      if(i!=j&&tl[i]+g[idx[i]][idx[j]]<=tl[j])can[i][j]=1;
  cout <<l-Biparite_Matching(l,l)<<endl;
  }
  return 0;
}

Measured memory_bytes: 28804
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,b,a) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<#x" = "<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nex)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int rd() {
	int x=0,c=0,f=1;
	for(; c<'0'||c>'9'; c=getchar())f=c!='-';
	for(; c>='0'&&c<='9'; c=getchar())x=x*10+c-'0';
	return f?x:-x;
}
const int N=1e5+11;
int n,A[N];
const char AN[2][123]={"First","Second"};
int main(){
	n=rd();
	rep(i,1,n)A[i]=rd();
	for(int ttt=0;;ttt^=1){
		bool flag=0;
		rep(i,1,n)if(A[i]==1)flag=1;
		if(flag){
			ll tot=0;
			rep(i,1,n)tot+=A[i]-1;
			return puts(tot%2?AN[ttt]:AN[ttt^1]),0;
		}else{
			int t=0;
			rep(i,1,n)t+=A[i]%2;
			if((n-t)%2)return puts(AN[ttt]),0;
			else if((n-t)%2==0&&t>=2)return puts(AN[ttt^1]),0;
			int d=0;
			rep(i,1,n)if(A[i]%2){
				A[i]--;break;
			}
			rep(i,1,n)d=__gcd(d,A[i]);
			rep(i,1,n)A[i]/=d;
		}
	}
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int X[1010];
int main()
{
  int N;
  cin>>N;
  for(int i=0;i<N;i++)
    cin>>X[i];
  int Ans=1000000000;
  for(int i=1;i<=100;i++)
  {
    int Cnt=0;
    for(int j=0;j<N;j++)
      Cnt+=(X[j]-i)*(X[j]-i);
    Ans=min(Ans,Cnt);
  }
  cout<<Ans<<endl;
  return 0;
}

Measured memory_bytes: 256
/*
    In the name of Allah

    MohammadErfan Gooneh

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define endl                        '\n'
#define all(a, n)                   for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define IOS                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
int main() {
    IOS ;
    ll a , b ;
    cin >> a >> b ;
    if(a%2 == 0||b%2 == 0)cout << "Even" ;
    else cout << "Odd" ;




















return 0 ;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        long Y = sc.nextLong();

        long ans = 0;
        long tmp = X;
        for (int i = 0; i < Y; i++) {
            if (tmp > Y) {
                break;
            }
            ans++;
            tmp *= 2;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200015
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int par[2][SIZE]; //親
int rnk[2][SIZE]; //木の深さ

//初期化(n要素0オリジン)
void init(int n,int t){
	for(int i=0;i<n;i++){
		par[t][i] = i;
		rnk[t][i] = 0;
	}
}

//xの根を求める
int find(int x,int t){
	if(par[t][x] == x){
		return x;
	}else{
		return par[t][x] = find(par[t][x],t);
	}
}

//x,yの属する集合を併合
void unite(int x,int y,int t){
	x = find(x,t);
	y = find(y,t);
	if(x == y)return;

	if(rnk[t][x] < rnk[t][y]){
		par[t][x] = y;
	}else{
		par[t][y] = x;
		if(rnk[t][x] == rnk[t][y])rnk[t][x]++;
	}
}

//xとyが同じ集合に属するか
bool same(int x,int y,int t){
	return find(x,t) == find(y,t);
}

int N,K,L;
P w[SIZE];
P wo[SIZE];

int ps[SIZE];

int main()
{
	scanf("%d%d%d",&N,&K,&L);
	init(N+3,0);
	init(N+3,1);
	int p,q;
	for(int i=0;i<K;i++){
		scanf("%d%d",&p,&q);
		unite(p,q,0);
	}
	for(int i=0;i<L;i++){
		scanf("%d%d",&p,&q);
		unite(p,q,1);
	}
	for(int i=1;i<=N;i++){
		//w[i] = P(par[0][i],par[1][i]);
		//wo[i] = P(par[0][i],par[1][i]);
		w[i] = wo[i] = P(find(i,0),find(i,1));
	}

	sort(w+1,w+1+N);
	int c=1;
	//ps[i] : w[i]の両連結頂点数
	for(int i=1;i<=N;i++){
		if(w[i] == w[i+1]){ //次と同じ
			c++;
		}else{//今回でおわり
			ps[i-c+1] = c;
			c=1;
		}
	}

	for(int i=1;i<=N;i++){
		if(i!=1)printf(" ");
		//iのペアを探す
		int n = lower_bound(w+1,w+1+N,wo[i]) - w;
		printf("%d",ps[n]);
	}
	printf("\n");
	return 0;
}


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

using ll = long long;

const ll mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<vector<bool>> A(3, vector<bool>(3, false));
    vector<int> a(9);
    for (int i = 0; i < 9; ++i) cin >> a[i];
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int b;
        cin >> b;
        int id = -1;
        for (int j = 0; j < 9; ++j) {
            if (a[j] == b) {
                id = j;
                break;
            }
        }
        if (id == -1) continue;
        A[id / 3][id % 3] = true;
    }
    bool ok = false;
    if (A[0][0] && A[0][1] && A[0][2]) ok = true;
    if (A[1][0] && A[1][1] && A[1][2]) ok = true;
    if (A[2][0] && A[2][1] && A[2][2]) ok = true;
    if (A[0][0] && A[1][0] && A[2][0]) ok = true;
    if (A[0][1] && A[1][1] && A[2][1]) ok = true;
    if (A[0][2] && A[1][2] && A[2][2]) ok = true;
    if (A[0][0] && A[1][1] && A[2][2]) ok = true;
    if (A[0][2] && A[1][1] && A[2][0]) ok = true;
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256