akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false)
#define ll long long
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF 0x3f3f3f3f

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

signed main() {
  IO;
  int r;
  cin >> r;
   cout << 2 * acos(-1.0) * r << '\n';
  return 0;	
}

Measured memory_bytes: 3804
from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r
    
def solve():
    n,k=mp()
    l=[]
    for i in range(n):
        s=input()
        l.append(s)
    l.sort()
    print(''.join(l))
        

for _ in range(1):
    solve()
    


Measured memory_bytes: 9120
#!/usr/bin/env python3

# from numba import njit

# from collections import Counter
# from itertools import accumulate
# import numpy as np
# from heapq import heappop,heappush
# from bisect import bisect_left

# @njit
def solve(n,m):
  if n == 1 or m == 1:
    return 1
  else:
    return (n*m + 1)// 2



def main():
  N,M = map(int,input().split())
  # a = list(map(int,input().split()))
  print(solve(N,M))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 9148
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
import std.regex;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);
  auto n = s.length;

  auto r = 0L;
  foreach (i; 0..1<<n-1) {
    auto t = "";
    foreach (j; 0..n-1) {
      t ~= s[j];
      if (i.bitTest(j)) t ~= '+';
    }
    t ~= s[$-1];
    auto u = t.matchAll(r"\d+");
    r += u.map!(ui => ui[0].to!long).sum;
  }

  writeln(r);
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }

  pure T bitSet(T)(T n, size_t s, size_t e) { return n | ((T(1) << e) - 1) & ~((T(1) << s) - 1); }
  pure T bitReset(T)(T n, size_t s, size_t e) { return n & (~((T(1) << e) - 1) | ((T(1) << s) - 1)); }
  pure T bitComp(T)(T n, size_t s, size_t e) { return n ^ ((T(1) << e) - 1) & ~((T(1) << s) - 1); }

  import core.bitop;
  pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); }
  pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); }
  pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); }
}


Measured memory_bytes: 380
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;


int main() {
    const long long int mod = 1000000007,INF=50000000000000;
    typedef pair<long long int,long long int>P;
	map<long long int, long long int>mp;
    priority_queue<P,vector<P>,greater<P> >mazuisushi;
    
    priority_queue<P>umaisushi;
	cout << fixed << setprecision(10);
    string str;
    long long int n,k,t,d,a,b,now=-1,tmp=0,typ=2;
    long long int x,res[200005]={};

    cin>>n>>x;
    if(n==2){
        if(x!=2){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes\n1\n2\n3"<<endl;
        }
    }else if(x<=1||x>=2*n-1){
        cout<<"No"<<endl;
    }else{
        //res[n+2]=2;
        res[n+1]=2*n-1;
        res[n]=x;
        res[n-1]=1;
        //res[n-2]=2*n-1;
        cout<<"Yes"<<endl;
        for(int i=1;i<=2*n-1;i++){
            if(res[i]==0){
                if(typ==x){typ++;}
                res[i]=typ;
                typ++;
            }
        }
        for(int i=1;i<=2*n-1;i++){
            cout<<res[i]<<endl;
        }
    }
} 


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl

#define lli long long int
#define ull unsigned long long int
#define mod 1000000007



int main()
{
    IOS;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int dp[n];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
    }
    
    cout<<dp[n-1];

    return 0;
}

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

int main()
{
  long K, A, B;
  long long ans=0;
  cin >> K >> A >> B;
  if((B-A)>2){

    if(K < A){
      ans = K+1;
    }else{
      ans = (K-A+1)%2==0 ? A + (B-A)*(K-A+1)/2 : A+1 + (B-A)*(K-A)/2 ;
    }


  }else{
    ans = K+1;
  }

  cout << ans << endl;

return 0;

}



Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <vector>

enum Act { A, B, C };
using arr3 = std::array<int64_t, 3>;

int main(int argc, char* argv[]) {
  int64_t N;
  std::cin >> N;
  std::vector<arr3> h(N + 1);
  for (int64_t i = 1; i <= N; ++i) {
    std::cin >> h[i][A] >> h[i][B] >> h[i][C];
  }

  std::vector<arr3> dp(N + 1, {0, 0, 0});
  for (size_t i = 1; i <= N; ++i) {
    const auto j{i - 1};
    dp[i][A] = std::max(dp[j][B], dp[j][C]) + h[i][A];
    dp[i][B] = std::max(dp[j][C], dp[j][A]) + h[i][B];
    dp[i][C] = std::max(dp[j][A], dp[j][B]) + h[i][C];
  }
  std::cout << std::max({dp[N][A], dp[N][B], dp[N][C]}) << std::endl;
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890

int main(){
    ll i,j;
    ll a;
    string s;
    cin>>a>>s;
    if(a>=3200) cout<<s<<endl;
    else cout<<"red"<<endl;
    return 0;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int rate = scn.nextInt();
		if(rate < 1200) {
			System.out.println("ABC");
		}else if(rate < 2800) {
			System.out.println("ARC");
		}else {
			System.out.println("AGC");
		}
		scn.close();
	}
}


Measured memory_bytes: 22740
import java.io.*;
import java.util.*;

public class Main {
  private static int solve(long[] as) {
    Arrays.sort(as);
    
    long sum = 0;
    for (long a : as) {
      sum += a;
    }
    
    sum -= as[as.length - 1];
    for (int i = as.length - 2; i >= 0; i--) {
      if (as[i] < as[i+1] && sum * 2 < as[i+1]) {
        return as.length - 1 - i;
      }
      sum -= as[i];
    }
    return as.length;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    long[] as = reader.nextLongArray(n);
    out.println(solve(as));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
}

class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
}



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s; int k; cin>>s>>k;
	vector<string>v;
	for(int i=0;i<s.size();++i){
		for(int j=1;j<=min((size_t)k,s.size()-i);++j){
			v.emplace_back(s.substr(i,j));
		}
	}
	sort(v.begin(),v.end());
	int i,cnt=0;
	for(i=0;i+1<v.size();++i){
		if(v.at(i)==v.at(i+1))continue;
		if(k==++cnt)break;
	}
	cout<<v.at(i)<<"\n"s;
}

Measured memory_bytes: 1660
N = int(input())
A = [int(_) for _ in input().split()]

def check():
    cs = []
    for i in range(N):
        if A[i] != i + 1:
            cs.append(i)
    if len(cs) == 0:
        return True
    if len(cs) != 2:
        return False
    return True

if check():
    print("YES")
else:
    print("NO")


Measured memory_bytes: 38384
import math
h,w = map(int,input().split())
if h%2 == 0:
    print(h//2 * w)
elif h==1 or w == 1:
    print(1)
else:
    tmp1 = math.floor(h/2)
    tmp2 = math.ceil(h/2)
    buf = math.floor(w/2)
    print(tmp2 * (w-buf) + tmp1 * (buf))


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long llint;
typedef long double ldouble;
int compare(const void *a, const void *b){return *(llint *)a - *(llint *)b;}
/*aのb進数時の桁数*/
llint digits(llint a, llint b){return a/b?1+digits(a/b,b):1;}
/*nをa進数にしたときの、i桁目の数*/
llint placenai(llint n, llint a, llint i){return i==1?n%a:placenai(n/a,a,i-1);}

llint distributeA3(llint a){
    return pow(3,a)-3-3*(pow(2,a)-2);
}

llint replace357(llint a, llint n){
    // llint n = digits(a,3);
    if(n==1) return a==0?3:(a==1?5:7);
    if(a%3==0) return 3+10*replace357(a/3,n-1);
    if(a%3==1) return 5+10*replace357(a/3,n-1);
    return 7+10*replace357(a/3,n-1);
}

int main(void){
    llint n,i,j,k,l;
    scanf("%lld",&n);
    if(digits(n,10)<3){
        printf("0\n");
        return 0;
    }
    k=digits(n,10);
    // printf("%lld\n",k);
    llint count = pow(3,k)-1,nums=0,c357[8];
    for(i=k;i>=3;i--){
        if(i!=k){
            nums += distributeA3(i);
            continue;
        }
        for(j=count;j>=0;j--){
            if(n>=replace357(j,k)){
                // printf("%lld ",replace357(j,k));
                c357[3]=0;
                c357[5]=0;
                c357[7]=0;
                for(l=0;l<k;l++){
                    c357[placenai(replace357(j,k),10,l+1)]++;
                }
                if(c357[3]>0 && c357[5]>0 && c357[7]>0) nums++;
            }
        }
    }
    


    printf("%lld\n",nums);
    return 0;
}


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

int main(){
  string str;
  cin >> str;
  for(int i=0; i<5; i++) cout << str[i];
  cout  << " ";
  for(int i=6; i<13; i++) cout << str[i];
  cout << " ";
  for(int i=14; i<19; i++) cout << str[i];
   cout <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,a,b,ans;
  cin>>n>>a>>b;
  vector<long> vec(n);
  for(long i=0; i<n; i++){
    cin>>vec.at(i);
  }
  ans=0;
  for(long i=1; i<n; i++){
    ans=ans+min(b,a*(vec.at(i)-vec.at(i-1)));
  }
  cout<<ans;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    private static long getSum(int l, int r, long[] sum) {
        long ans = r >= 0 ? sum[r] : 0;
        ans -= l >= 0 ? sum[l] : 0;
        return ans;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long mod = 998244353L;
        int n = scan.nextInt();
        int k = scan.nextInt();
        int[] l = new int[n];
        int[] r = new int[n];
        for (int i = 0; i < k; i++) {
            l[i] = scan.nextInt();
            r[i] = scan.nextInt();
        }
        long[] sum = new long[n];
        long[] dp = new long[n];
        sum[0] = dp[0] = 1;
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < k; j++) {
                dp[i] = (dp[i] + getSum(i - r[j] - 1, i - l[j], sum)) % mod;
            }
            sum[i] = sum[i - 1] + dp[i];
        }
        System.out.println(dp[n - 1]);
    }
}


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

int main()
{
	int n,d;
	cin>>n>>d;
	int h[n+1];
	for(int i=0;i<n;i++)
	cin>>h[i+1];
	vector<int> v[n+1];
	for(int i=0;i<d;i++)
	{
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int f=0;
		for(int j=0;j<v[i].size();j++)
		{
			if(h[v[i][j]]>=h[i])
			{
				f=1;
				break;
			}
		}
		if(f==0)
		ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 9152
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			long A = scan.nextLong();
			long B= scan.nextLong();
			
			ArrayList<Long>a = enum_div(A);
			ArrayList<Long>C = new ArrayList<Long>();
			Set<Long> D = new TreeSet<Long>();
			//ArrayList<Long>D = new ArrayList<Long>();
			ArrayList<Long>E = new ArrayList<Long>();
			StringBuffer sb = new StringBuffer();
			
			for(Long i:a) {//Aの約数の数分チェック
				if(B%i==0) {
					C.add(i);
					D.add(i);
					
				}
			}
			
			
			for(Long i:C) {
				//System.out.println(i);
				//D.add((long)1);
				sb.append(1);
			}
			//System.out.println(COM(170,85));
			
			if(C.size()==1) {
				System.out.println(1);
				return;
			}
			
			
			for(int i = 1;i<C.size()-1;i++) {
				long ki = C.get(i);
				for(int j = i+1;j<C.size();j++) {
					long che = C.get(j);
					if(che%ki==0) {
						//sb.replace(j, j+1, "0");
						D.remove(che);
					}
				}
			}
			/*
			int count = 0;
			
			for(int i=0;i<sb.toString().length();i++) {
				String s = sb.toString().substring(i, i+1);
				if(s.equals("1")) {
					count++;
				}
			}
			*/
			
				System.out.println(D.size());
				
			
			
			
			
			
			
		}
		
		
	}
	
	
	private static ArrayList<Long> enum_div(long n){//数字１〜ｎまでの約数を全部Allaylistに詰め込むメソッド
		ArrayList<Long> ret = new ArrayList<Long>();
		for(long i = 1;i*i<=n;i++) {
			if(n%i==0) {
				ret.add(i);
				if(i*i!=n){
					ret.add(n/i);
				}
			}
		}
		
		//ただここまでだと格納した約数はソートされてない
		
		Collections.sort(ret);//int型、Sting型くらいの格納した奴ならコレクションクラスのソートが使える。
		//ソートしてからcollections.reverseつかえば降順にもできる
		return ret;
		
		
		
	}
	
	//エラストステネスのふるい 配列の要素数で個数、値をSetで格納されてる
		private static Set<Integer> eraststenes(int n){
			//１~nまでの素数をエラストステネスのふるいというアルゴリズムで O(nloglogn)という高速な方法で配列に格納する
			Set<Integer> aray = new TreeSet<Integer>();
			for(int i = 2;i<=n;i++) aray.add(i);//とりあえず全部ふるい入れる
			for(int i = 2;i<=n;i++) {
				if(isprime(i)) {
					for(int j = 2*i;j<=n;j+=i) {
						aray.remove(j);
					}
				}
			}
			return aray;
		}
		
		private static boolean isprime(int x) {//素数判定、入力xが素数かtrue,falseで返す
			int i;
			if(x<2)return false;//まず２より小さいのは素数じゃない
			if(x==2)return true;//２は素数
			if(x%2==0)return false;//２で割り切れたら素数じゃない
			for(i =3;i*i<=x;i = i+2) {//それ以降iで割り切れたら素数じゃない
				if(x%i==0)
					return false;
			}
			return true;//for文回しても割り切れなかったらそれは素数
		}
	
	

}


Measured memory_bytes: 44468
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut a: Vec<i64> = (&mut iter).take(n).map(|x| x.parse().unwrap()).collect();
    let mut cnt = 0;
    let mut abs_min = 1i64 << 60;
    for i in 0..n {
        if a[i] < 0 {
            cnt += 1;
            a[i] = -a[i];
        }
        abs_min = std::cmp::min(a[i], abs_min);
    }
    let ret = if cnt % 2 == 0 {
        a.iter().fold(0, |acc,x| acc + x)
    } else {
        a.iter().fold(0, |acc,x| acc + x) - abs_min * 2
    };
    println!("{}", ret);
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

ll n,m;vector<vector<ll>>d;
vector<vector<bool>>ch;
vector<vector<ll>>via;
ll ans=0;
void solve(ll s,ll g){
    if(s==g)return;
    if(via[s][g]==s){
        if(ch[s][g]){
//            cout <<s<<" "<<g<<endl;
//            cout <<d[s][g]<<endl;
//            cout <<via[s][g]<<endl;
            ans++;
        }
        ch[s][g]=false;
        return;
    }
//    cout <<"!"<<endl;
    solve(s,via[s][g]);
    solve(via[s][g],g);
}

int main(){
    cin >>n>>m;
    d.assign(n,vector<ll>(n,INF));
    ch.assign(n,vector<bool>(n,false));
    via.assign(n,vector<ll>(n));
    for (int i = 0; i < m; ++i) {
        ll a,b,c;cin >>a>>b>>c;
        a--;b--;
        d[a][b]=c;
        d[b][a]=c;
        ch[a][b]=true;
    }
    for (int i = 0; i < n; ++i) {
        d[i][i]=0;
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            via[i][j]=i;
        }
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if(d[i][j]>d[i][k]+d[k][j]){
//                    if(i==1&&j==2){
//                        cout <<k<<" "<<d[i][j]<<" "<<d[i][k]<<" "<<d[k][j]<<endl;
//                    }
                    d[i][j]=d[i][k]+d[k][j];
                    via[i][j]=k;
                }
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
//            cout <<i<<" "<<j<<" "<<via[i][j]<<endl;
            solve(i,j);
//            cout <<ans <<endl;
        }
    }
    cout<<m-ans<<endl;
    return 0;
}



Measured memory_bytes: 384
from collections import deque
H,W=map(int,input().split())
s=[list(input()) for _ in range(H)]
dflt_cnt=0
for i in range(H):
    dflt_cnt+=s[i].count(".")
que=deque([(0,0)])
step=[[-1]*W for _ in range(H)]
step[0][0]=0
move_h=[1,0,-1,0]
move_w=[0,1,0,-1]
cnt=1
while que:
    v=que.popleft()
    if v[0]==H-1 and v[1]==W-1:
        cnt+=step[H-1][W-1]
        break
    for i in range(4):
        next_h=v[0]+move_h[i]
        next_w=v[1]+move_w[i]
        if 0<=next_h<H and 0<=next_w<W and s[next_h][next_w]=="." and step[next_h][next_w]==-1:
            que.append((next_h,next_w))
            step[next_h][next_w]=step[v[0]][v[1]]+1
print(dflt_cnt-cnt if cnt!=1 else -1)

Measured memory_bytes: 40560
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	private Scanner in = new Scanner(System.in);
	
	private Main() {
		int n = in.nextInt();
		
		for(int i=0;i<n;i++) {
			ArrayList<Integer> dataset = new ArrayList<Integer>();	
			for(int j=0;j<10;j++) {
				 dataset.add(in.nextInt());
			}
			int[] cylinders = new int[2]; //筒(の最後の要素)
			solve(dataset, cylinders); 
		}
		
	}
	
	private void solve(ArrayList<Integer> data,int[] cylinders) {
		if(data.isEmpty()) {
			System.out.println("YES");
			return;
		}
		
		int head = data.remove(0);
		if(head > cylinders[0]) {
			cylinders[0] = head;
		} else if(head > cylinders[1]) {
			cylinders[1] = head;
		} else {
			System.out.println("NO");
			return;
		}
		solve(data,cylinders);
	}

	public static void main(String[] args) {
		new Main();
	}

}

Measured memory_bytes: 12000
module Main where

    import Data.List
    import Control.Monad
    import Debug.Trace
    import qualified Data.Vector.Mutable as MV
    import Control.Monad.ST (runST)
    import qualified Data.ByteString.Char8 as BC
    import Data.Maybe (fromJust)
    
    readTuple2 :: IO (Int, Int)
    readTuple2 = do
        [a, b] <- words <$> getLine
        return (read a, read b)
    
    readTuple3 :: IO (Int, Int, Int)
    readTuple3 = do
        [a, b, c] <- fmap (fst. fromJust . BC.readInt) . BC.words <$> BC.getLine
        return (a, b, c)
    
    main = do
        n <- readLn
        distantVec <- MV.replicate n []
        let root = 0
        replicateM_ (n - 1) $ do
            (from, to, distance) <- readTuple3
            MV.modify distantVec (((to-1), distance `mod` 2):) (from  -1)
            MV.modify distantVec (((from-1), distance `mod` 2):) (to  -1)
        distanceFromRootVec <- MV.replicate n (Nothing :: Maybe Int)
        let search point distAccum = do
                MV.write distanceFromRootVec point (Just distAccum)
                routes <- MV.read distantVec point
                forM_ routes $ \(nextPoint, distance) -> do
                    dist <- MV.read distanceFromRootVec nextPoint 
                    case dist of
                        Just n -> pure ()
                        Nothing -> search nextPoint ((distAccum + distance) `mod` 2)
        search root 0
        forM [0..(n - 1)] $ \point -> do
            dist <- MV.read distanceFromRootVec point
            case dist of
                Nothing -> putStrLn "-1"
                Just n -> putStrLn $ if even n then "0" else "1"

Measured memory_bytes: 59772
my $N = <>;
my $s=<>;chomp $s;
my @dat = split(/ /,$s);
my %DB;

for($i=0;$i<=$#dat;$i++){
  $DB{$dat[$i]}++;
}
my $sum=0;
foreach $x (sort {$a <=> $b} keys(%DB) ){
#print "$x\n";
  foreach $y (sort {$a <=> $b} keys(%DB) ){
    if($y<=$x){ next;}
    foreach $z (sort {$a <=> $b} keys(%DB) ){
        if($z<=$x){ next;}
        if($z<=$y){ next;}
        if($z>=($x+$y)){next;}
        $sum = $sum + $DB{$x}*$DB{$y}*$DB{$z};
        #print "sum\ $DB{$x}*$DB{$y}*$DB{z} n";
    } 
  }
}
print "$sum\n";

Measured memory_bytes: 4768
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[] cs = S.toCharArray();
        int count = 0;
        for (int i = 0; i < S.length() / 2; i++) {
            if (cs[i] != cs[S.length()-1-i]) {
                count++;
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 21972
from math import gcd


def main():
    K = int(input())

    ans = 0
    for a in range(1, K + 1):
        for b in range(1, K + 1):
            for c in range(1, K + 1):
                ans += gcd(gcd(a, b), c)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 69580
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

int H, W;
int A[200005], B[200005];

int C[200005];
set<int > S;

int ans[200005];

multiset<int> M;

int p = 0;
int E[200005];

void ADD(int k) {
	E[k]++;
}
void DEL(int k) {
	E[k]--;
	
	while (E[p] == 0) { p++; }
}

int main(void) {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		cin >> A[i] >> B[i];
	}

	for (int i = 1; i <= W; i++) { S.insert(i); M.insert(0); /*ADD(0);*/ }
	
	/*if (A[1] == 1 && B[1] == W) { for (int i = 1; i <= H; i++) { cout << -1 << endl; } return 0; }

	if (A[1]==1) {}
	else if (A[1] == 2) { S.insert(1); M.insert(0); }
	else { S.insert(1); M.insert(0);  S.insert(A[1] - 1); M.insert(0); }

	if (B[1] < W) {
		S.insert(B[1] + 1); M.insert(0);
	}
	ans[1] = 1;*/
	
	for (int i = 1; i <= H; i++) {
		
		//cout << "i= " << i << endl;

		//-----------------
		auto it = S.upper_bound(B[i] + 1);
		//auto  it = upper_bound(S.begin(), S.end(), B[i] + 1);
		if (it != S.begin()) { --it; }
		if (it!=S.end() && *it <= B[i] + 1 && ( B[i]+1<=W)) {
			C[B[i] + 1] = C[*it] + B[i] + 1 - (*it); 

			if (S.find(B[i] + 1) != S.end()) {
				auto itr = M.find(C[B[i] + 1]);  M.erase(itr);
			}
			S.insert(B[i] + 1);  M.insert(C[B[i] + 1]); 
		}

		//cout << "S: "; for (auto y : S) { cout << " " << y; }cout << endl;
		//cout << "M: "; for (auto y : M) { cout << " " << y; }cout << endl;

		//--------------------------------------------------------
		
		it = S.upper_bound(A[i] - 1);
		//it = upper_bound(S.begin(), S.end(), A[i] - 1);
		if (it != S.begin()) { --it; }
		if (it!=S.end() && *it <= A[i] - 1  &&  A[i]-1>=1) {
			C[A[i] - 1] = C[*it] + A[i] - 1 - (*it);
			if (S.find(A[i] - 1) != S.end()) { 
				auto itr = M.find(C[A[i]-1]);  M.erase(itr);                              
			}
			S.insert(A[i] - 1); M.insert(C[A[i] - 1]);
		}

		//cout << "S: "; for (auto y : S) { cout << " " << y; }cout << endl;
		//cout << "M: "; for (auto y : M) { cout << " " << y; }cout << endl;
		
		//--------------------------------

		it = S.lower_bound(A[i]);
		//it = lower_bound(S.begin(), S.end(), A[i]);
		while (it!=S.end() && *it <= B[i]) {
			auto itr = M.find(C[*it]); //cout << *itr << " 消去" << endl;
			M.erase(itr); 
			//DEL(C[*it]);
			 S.erase(it++);
		}

		//cout << "S: "; for (auto y : S) { cout << " " << y; }cout << endl;
		//cout << "M: "; for (auto y : M) { cout << " " << y; }cout << endl;

		//cout << "i= " << i << endl;
		//cout << "E:"; for (int i = 0; i <= 10; i++) { cout << " " << E[i]; } cout << " p= " << p << endl;

		if (S.size() == 0) { ans[i] = -1; }
		else { ans[i] = i + *M.begin()/*p*/; }

	}

	
	for (int i = 1; i <= H; i++) {
		printf("%d\n", ans[i]);
		//cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 25620
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ADarkerAndDarker solver = new ADarkerAndDarker();
        solver.solve(1, in, out);
        out.close();
    }

    static class ADarkerAndDarker {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            char[][] c = new char[n][m];
            for (int i = 0; i < n; i++) {
                c[i] = in.next().toCharArray();
            }
            int[] q = new int[2 * n * m];
            int[][] dist = new int[n][m];
            int tail = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (c[i][j] == '#') {
                        q[tail++] = i;
                        q[tail++] = j;
                    } else {
                        dist[i][j] = -1;
                    }
                }
            }
            int head = 0;
            int[] dx = {0, 1, 0, -1};
            int[] dy = {1, 0, -1, 0};
            int last = 0;
            while (head < tail) {
                int i = q[head++], j = q[head++];
                last = dist[i][j];
                for (int d = 0; d < 4; d++) {
                    int ni = i + dx[d], nj = j + dy[d];
                    if (0 <= ni && ni < n && 0 <= nj && nj < m && dist[ni][nj] == -1) {
                        dist[ni][nj] = last + 1;
                        q[tail++] = ni;
                        q[tail++] = nj;
                    }
                }
            }
            out.println(last);
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public FastScanner(String fileName) {
            try {
                br = new BufferedReader(new FileReader(fileName));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 51220
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m; cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
typedef unsigned long long ull;
ull power(ull a, ull b, ull n) {
	ull tmp = 1;
	if (b > 0) {
		tmp = power(a, b / 2, n);
		if (b % 2 == 0) {
			tmp = (tmp*tmp) % n;
		}
		else {
			tmp = (((tmp*tmp) % n)*a) % n;
		}

	}
	return tmp;
}
int main() {
	ull m, N;
	cin >> m >> N;
	cout << power(m, N, 1000000007) << endl;
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int N;
    cin >> N;
    vector<int> a(N+1);
    rep(i,N) cin >> a[i];
    ll ans = 1000;
    ll now = 1000;
    int state = 0;
    ll kabu = 0;
    rep(i,N){
        if(i == N-1){
            now += kabu * a[N-1];
            break;
        }
        if(state == 0 && a[i] < a[i+1]){
            kabu = now / a[i];
            now %= a[i];
            state = 1;
        }else if(state == 1 && a[i] > a[i+1]){
            now += kabu * a[i];
            kabu = 0;
            ans = now;
            state = 0;
        }
    }
    cout << max(now,ans) << endl;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

int main(){
    int n;
    cin>>n;
    string s;cin>>s;
    int ans=0,num=0;
    rep(i,n){
        if(s[i]=='D'){
            num--;
        }
        else{
            num++;
        }
        ans=max(ans,num);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int N=0;
	cin>>N;//区画の数
	vector<int> A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];//
	}
	vector<bool> sea(N+2);
	sea[0]=sea[N+1]=true;
	for(int i=0;i<N;i++){
		sea[i+1]=(A[i]<=0);
	}
	int current=0;
	for(int i=1;i<=N;i++){
		if(!sea[i]&&sea[i-1]){
			current++;
		}
	}
	vector<pair<int,int> >AandID;
	for(int i=0;i<N;i++){
		if(A[i]>0){
			AandID.push_back(make_pair(A[i],i+1));
		}
	}
	sort(AandID.begin(),AandID.end());
	int answer=current;
	for(int t=0;t<AandID.size();t++){
		int i=AandID[t].second;
		sea[i]=true;
		if(sea[i-1]&&sea[i+1]){
			current--;
		}
		else if(!sea[i-1]&&!sea[i+1]){
			current++;
		}
		if(t+1==AandID.size()||AandID[t].first<AandID[t+1].first){
			answer=max(answer,current);
		}
	}
	cout<<answer<<endl;
	return 0;
}


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

using namespace std;

#define TC ll t; cin >> t; while(t--)
typedef long long ll;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll a,b,k;
    cin >> a >> b >> k;
    a-=k;
    if(a<0)
    {
        b+=a; a=0;
    }
    if(b<0) b=0;
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 3628
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();
        StringBuilder sb1 = new StringBuilder();
        for (int i = 0 ; i < B; i++)
            sb1.append(A);
        String a = sb1.toString();
        sb1 = new StringBuilder();
        for (int i = 0 ; i < A; i++)
            sb1.append(B);
        String b = sb1.toString();
        int compare = a.compareTo(b);
        if (compare > 0){
            System.out.println(b);
        } else {
            System.out.println(a);
        }
        sc.close();
    }
}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef long long LL;
typedef pair<int , int > P;
const int maxn=3005;
const LL INF=1e13+5;

int main()
{
    LL N , X , T;
    cin >> N >> X >> T;
    if(N%X)
        cout << ((N/X)+1)*T;
    else
        cout << N/X*T;

}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <thread>
#include <chrono>
#include <queue>

using namespace std;

int main(void){
	string s;
	cin >> s;
	cout << s.at(0) << s.length() - 2 << s.at(s.length() - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
	long long n;int l,t,c,i;scanf("%lld",&n);
	t=c=63-__builtin_clzll(n+1),n-=(1ll<<c)-1;
	printf("%d\n",(l=c+=__builtin_popcountll(n))<<1);
	for(i=0;i<t;printf("%d ",++i))
		if(n>>i&1)printf("%d ",c--);
	for(i=0;i<l;printf("%d ",++i));
}

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


int main() {
  int a,b;
  cin>>a>>b;
  for(int i=0;i<=1250;i++){
    int k=i*0.08;int l=i*0.1;
    if(k==a&&l==b){cout<<i<<endl;exit(0);}

  }
  cout<<"-1"<<endl;
}


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

using namespace std;

#define rep(i, n) for (long long i = 0; i < n; i++)
#define reps(i, n, m) for (long long i = n; i < m; i++)

int N;
long long A[200000];
long long sum[200001];

inline long long cu(long long x)
{
	int pos = lower_bound(A, A + N, x) - A;
	long long t = pos * x - sum[pos];
	t += sum[N] - sum[pos] - (N - pos) * x;
	return t;
}



int main()
{
	cin >> N;
	rep (i, N) {
		cin >> A[i];
		A[i] -= i - N;
	}
	sort(A, A + N);
	reps(i, 1, N + 1) {
		sum[i] = sum[i-1] + A[i-1];
	}
	long long mi = LLONG_MAX;
	long long i = 1;
	for (;;i+=100000) {
		long long t = cu(i);
		long long t2 = cu(i - 1);
		if (t2 < t) break;
		if (mi > t) mi = t;
		else break;
	}
	i-=100000;
	for (;;i++) {
		long long t = cu(i);
		if (mi >= t) mi = t;
		else break;
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

bool is_month(int num);

int main(void)
{
    string str;

    cin >> str;

    istringstream former(str.substr(0, 2));
    istringstream latter(str.substr(2, 2));
    int f;
    int l;
    former >> f;
    latter >> l;

    if(is_month(f)){
        if(is_month(l)){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if(is_month(l)){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }

    return 0;
}

bool is_month(int num)
{
    if(num <= 0 || num > 12){
        return false;
    }

    return true;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){ 
    y = x;
    if(z->key < x->key){ 
      x = x->left; 
    } 
    else { 
      x = x->right; 
    } 
  } 
  z->parent = y; 

  if(y == NIL){ 
    root = z; 
  } 
  else if(z->key < y->key){ 
    y->left = z; 
  }else { 
    y->right = z;
  }  

}
  
Node treeSearch(Node u, int k){
  while (u != NIL){
    if(k == u->key){
      return u;
    }
    else if(k < u->key){
	u = u->left;
      } else u = u->right;
    }
    return NIL;
}

void inorder(Node u){
if(u->left!=NULL) inorder(u->left);
printf(" %d",u->key);
if(u->right!=NULL) inorder(u->right);
}

void preorder(Node u){ 
printf(" %d",u->key);
if(u->left!=NULL) preorder(u->left);
if(u->right!=NULL) preorder(u->right);
 } 


int main(){
  int n, i, x, k;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com); 
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } 
    else if ( com[0] == 'i' ){
      scanf("%d", &k);
      insert(k);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }
  return 0;
}

Measured memory_bytes: 19360
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int n, x;
    cin >> n >> x;

    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    int ans = 0;
    int sum = 0;
    rep(i, n){
        if(sum + a[i] <= x){
            ans++;
        }
        sum += a[i];
    }
    if(sum < x){
        ans--;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
from collections import defaultdict

N, T = map(int, input().split())
A = tuple(map(int, input().split()))

B = defaultdict(int)
am = A[0]
for i in range(1, N):
    B[A[i] - am] += 1
    am = min(am, A[i])

print(B[max(B)])


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

using namespace std;

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

  int n;
  cin >> n;
  vector<int> a(n);
  int max_val = 0;
  for (auto& e : a) {
    cin >> e;
    max_val = max(max_val, e);
  }
  vector<int> v(max_val + 1);
  for (auto& e : a) {
    if (0 < e) v[e-1]++;
    v[e]++;
    v[e+1]++;
  }
  int ans = 0;
  for (auto& e : v) {
    ans = max(ans, e);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 1024
#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 REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
#define pw(x) (1LL<<(x))
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define NEWL EVAL({cout << '\n';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 998244353;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
//------------------------------------------------------------------------------------------------------

const int N = 205;
const int MAX = 1e4 + 10;

LL n, x[N], y[N];

bool collinear(int i, int j, int k) {
    return (y[j] - y[i]) * (x[k] - x[j]) == (y[k] - y[j]) * (x[j] - x[i]);
}

int main() {
    cin >> n;
    REP(i, n) cin >> x[i] >> y[i];
    LL ans = mpow(2, n);
    ans = mdif(ans, n+1);
    REP(i, n) {
        FOR(j, i+1, n) {
            int this_set = 2;
            bool already_done = false;
            REP(k, n) {
                if(k == i or k == j) continue;
                if(collinear(i, j, k)) {
                    if(k < j) already_done = true;
                    this_set++;
                }
            }
            if(already_done) continue;
            // subsets of this_set of size at least 2
            int cur = mpow(2, this_set);
            cur = mdif(cur, 1 + this_set);
            ans = mdif(ans, cur);
        }
    }
    cout << ans << '\n';
}






























Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int s;
    static int t;
    static int q;
    static long[] shrines;
    static long[] temples;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        s = sc.nextInt();
        t = sc.nextInt();
        q = sc.nextInt();

        shrines = new long[s];
        temples = new long[t];

        for (int i = 0; i < s; i++) {
            shrines[i] = sc.nextLong();
        }

        for (int i = 0; i < t; i++) {
            temples[i] = sc.nextLong();
        }

        for (int i = 0; i < q; i++) {
            long query = sc.nextLong();

            int shrineIdx = Arrays.binarySearch(shrines, query);
            int templeIdx = Arrays.binarySearch(temples, query);

            if (shrineIdx < 0) {
                shrineIdx = -shrineIdx - 1;
            }
            if (templeIdx < 0) {
                templeIdx = -templeIdx - 1;
            }
            long ans = getClosest(query, shrineIdx, templeIdx);
            System.out.println(ans);
        }
    }

    private static long getClosest(long query, int shrineIdx, int templeIdx) {
        long min = Long.MAX_VALUE;
        for (int i = shrineIdx-1; i <= shrineIdx; i++) {        // shrines
            for (int j = templeIdx-1; j <= templeIdx; j++) {      // temples
                if (i >= 0 && i < s && j >= 0 && j < t) {
                    long diff1 = Math.abs(query - shrines[i]);
                    long diff2 = Math.abs(query - temples[j]);
                    long diff3 = Math.abs(shrines[i] - temples[j]);
                    min = Math.min(min, diff1 < diff2 ? diff1 + diff3 : diff2 + diff3);
                }
            }
        }
        return min;
    }
}


Measured memory_bytes: 96920
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll mod = 1e9+7;

int main(){

	ll n;
	cin>>n;
	
	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		if(i%3!= 0 && i%5!=0)
			ans += i;
	}

	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"

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

ll mx = -1;
map<pi, ll> memo;
vector<ll > ans;
vector<bool > seen;
vector<vector<pi > > G;

void dfs(ll idx, ll from = -1){

    seen[idx] = true;

    if(from == -1){
        memo[make_pair(from, idx)] = -1;
    }

    ll cn = 1;
    for(ll i = 0; i < G[idx].size(); i++){
        //次の行き先は？
        ll to = G[idx][i].first;
        ll num = G[idx][i].second;
        //探査済み
        if(seen[to] == true){
            continue;
        }
        
        if(memo[make_pair(from, idx)] == cn){
            cn++;
        }

        memo[make_pair(idx, to)] = cn;
        ans[num] = cn;

        cn++;
        dfs(to , idx);
        
    }
    mx = max(cn-1, mx);
}

int main(){
    ll N;
    cin >> N;
    //初期化
    G.assign(N, vector<pi >());
    seen.assign(N, false);
    ans.assign(N-1, 0);

    //グラフ入力
    for(ll i = 0; i < N-1; i++){
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        //双方向に貼りましょうね
        G[u].push_back(make_pair(v, i));
        G[v].push_back(make_pair(u, i));
    }

    dfs(0);

    cout << mx << endl;

    for(ll i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }


}

Measured memory_bytes: 16128