akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define dfor(i,a,b) for(ll i=(a);i>=(b);i--)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define ll long long
#define ull unsigned long long
#define MOD  1000000007
#define MAX  1e9
#define pb   push_back
#define F    first
#define S    second
vector<ll> v[200005];
vector<ll> dist(200005, -1);
ll n,m;

ll dfs(ll k){
	if(dist[k]>-1){
		return dist[k]+1;
	}
	ll s = 0;
	for(auto i: v[k]){
		s = max(s,dfs(i));
	}
	dist[k] = s;
	return dist[k]+1;

}
signed main() {
	ll t=1;
	//cin>>t;
	while(t--){
		
		cin>>n>>m;
		rep(i,m){
			ll a,b;
			cin>>a>>b;
			v[a].push_back(b);
		}	

		ll ans = 0;
		FOR(i,1,n+1){
			ans = max(ans,dfs(i));
			// cout<<dist[i]<<endl;
		}
		ans = 0;
		FOR(i,1,n+1){
			ans = max(ans,dist[i]);
		}
		cout<<ans;
		
	}
	
}

Measured memory_bytes: 14464
#include<stdio.h>
int main(void) {
	int h[301];
	int w[301];
	int i;
	int t;
	int u;
	int v;
	for( i=1;i<=300;i++){

		scanf("%d %d",&h[i],&w[i]);
		if ((h[i] == 0) && (w[i] == 0))break;
	}
	for ( t = 1; t <= 300; t++) {
		if (i==t)break;
		for (v = 1; v <= h[t]; v++) {
			for (u = 1; u <= w[t]; u++) {
				printf("#");
			}
			printf("\n");
		}
			printf("\n");
	}

	return 0;
	}

Measured memory_bytes: 572
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (1LL<<31) - 1;
const ll mod = 1e9 + 7;

ll N,ans;
ll A[200001];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	FOR(i, 0, N) {
		cin >> A[i];
	}
	sort(A, A + N);
	reverse(A, A + N);

	N--;
	ll now = 0;
	bool judge = true;
	while (N > 0) {
		ans += A[now];
		N--;
		if (judge == false) {
			judge = true;
		}
		else {
			now++;
			judge = false;
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 5216
import java.io.*
import java.util.*

fun solve(N: Long) {
    if (N % 2L == 0L) {
        // N = 2m
        // N!! = 2^m * m!
        val m = N / 2
        val ans = m.powerOfFactorial(5L)
        println(ans)
    } else {
        println(0)
    }
    return
}

fun Long.powerOfFactorial(base: Long): Long {
    // this! がbaseで何回割り切れるか
    // [this / base] + [this/base*base] + ...
    var count = 0L
    var ret = base
    while (ret <= this) {
        count += (this / ret)
        ret *= base
    }
    return count
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    solve(N)
}


Measured memory_bytes: 31404
#include<iostream>
#include<algorithm>
using namespace std;
#include<cmath>
#define int long long int
int32_t main()
{
	int d,n;
	cin>>d>>n;
	int answer=pow(100,d);
	answer*=n;
	if(n==100)
	{
		answer/=100;
		answer*=101;
		cout<<answer<<endl;
		exit(0);
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
void solveA()
{
  long long a,b,tem;
  cin>>a>>b;
  tem=(a+b);
  if(tem%2==0)
  {
    cout<<tem/2<<endl;
  }
  else
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
}
void solveB()
{
  int n,i,j,count;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  j=1;
  count=0;
  for(i=0;i<n;i++)
  {
    if(ar[i]!=j)
    {
      count++;
    }
    if(count>2)
    {
      cout<<"NO"<<endl;
      return;
    }
    j++;
  }
  cout<<"YES"<<endl;
}
void solveC()
{
  int a,b,x,y;
  cin>>a>>b;
  x=max(a,b);
  y=min(a,b);
  if((x-y)>=2)
  {
    cout<<2*x-1<<endl;
  }
  else
  {
    cout<<x+y<<endl;
  }
}
void solveD()
{
  int n,i,j;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  int count=n;
  for(i=n-1;i>=0;i--)
  {
    for(j=i-1;j>=0;j--)
    {
      if(ar[i]<ar[j])
      {
        count--;
        break;
      }
    }
  }
  cout<<count<<endl;
}
void solveE()
{
  int h,w,x,y,H,W;
  cin>>H>>W;
  cin>>h>>w;
  x=h*W;
  y=(H-h)*w;
  cout<<(H*W)-(x+y)<<endl;
}
void solveF()
{
  int n,m,c,i,j;
  cin>>n>>m>>c;
  int b[m];
  int ar[n][m];
  for(i=0;i<m;i++)
  {
    cin>>b[i];
  }
  for(i=0;i<n;i++)
  {
    for(j=0;j<m;j++)
    {
      cin>>ar[i][j];
    }
  }
  int count=0;
  int sum;
  for(i=0;i<n;i++)
  {
    sum=0;
    for(j=0;j<m;j++)
    {
      sum=sum+ar[i][j]*b[j];
    }
    if((sum+c)>0)
    {
      count++;
    }
  }
  cout<<count<<endl;
}
void solveG()
{
  int a,b,c,tem;
  cin>>a>>b>>c;
  tem=b/a;
  if(tem>c)cout<<c<<endl;
  else cout<<tem<<endl;
}
int main()
{
  // solveA();
  //solveB();
  // solveC();
  // solveD();
// solveE();
 //solveF();
 solveG();
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  
  int A, B, C, K;
  int ans = 0;
  cin >> A >> B >> C >> K;
  if (K <= A) {
    ans = K;
  }
  else if (K <= A + B) {
    ans = A;
  }
  else {
    ans = A - (K - (A + B));
  }
  cout << ans << endl;
}
      
      

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int t = scan.nextInt();
        int a = scan.nextInt();

        double[] h = new double[n];
        for(int i = 0; i < n; i++) {
        	h[i] = Math.abs(a - (t - scan.nextDouble() * 6 / 1000));
        }

        int ans = 0;
        double temp = Double.MAX_VALUE;
        for(int i = 0; i < n; i++) {
        	if(temp > h[i]) {
        		temp = h[i];
        		ans = i + 1;
        	}
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 26880
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();
		int n = Integer.parseInt(line1);

		String line2 = sc.nextLine();
		String[] kari = line2.split(" ");
		int[] A = new int[n];
		for (int i = 0; i < n; i++) {
			A[i] = Integer.parseInt(kari[i]);
		}
		
		System.out.println(line2);

		int v = 0;
		int j = 0;

		for (int i = 1; i < n; i++) {
			v = A[i];
			j = i - 1;
			while (j >= 0 && A[j] > v) {
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;

			for (int k = 0; k < n - 1; k++) {
				System.out.print(A[k]);
				System.out.print(" ");
			}
			System.out.println(A[n - 1]);

		}

	}

}

Measured memory_bytes: 31376
N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

if N == 1:
    for i in range(10):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])):
                flag = False
                break
        if flag:
            ans = min(ans, i)
else:
    for i in range(10 ** (N - 1), 10 ** N):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])) or len(num) < pair[0]:
                flag = False
                break
        if flag:
            ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)

Measured memory_bytes: 38384
from sys import stdin, exit

N, M = map(int, stdin.readline().split())
A = list(map(int, stdin.readline().split()))
p = [(A[i], 1) for i in range(N)]
for _ in range(M):
    B, C = map(int, stdin.readline().split())
    p.append((C, B))

p.sort(reverse=True)

ans, cnt = 0, N
for (v, c) in p:
    use = min(c, cnt)
    ans += use * v
    cnt -= use

print(ans)

Measured memory_bytes: 29472
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
#define int long long
#define double long double
 
int gcd(int x, int y){
    if (y == 0)
        return x;
    x = x % y;
    gcd(y, x);
}
 
int check(int i,int ans){
    if(i<2) return ans;
    ans=i*check(i-2,ans);
}
main(){
    int a,b;
    cin>>a>>b;
    if(a*500>=b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	S = inputStr()
	T = inputStr()

	ans = 0
	for i,val in enumerate(S):
		if val == T[i]:
			pass
		else:
			ans += 1

	print(ans)



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 77812
s = input()
n = len(s)
a = int((n-1)/2)
aa = s[:a]
b = int((n+3)/2-1)
bb = s[b:]

if s == s[::-1] and aa == aa[::-1] and bb == bb[::-1]:
  print("Yes")
else:
  print("No")
  

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

int main()
{
    int n, k; cin>>n>>k;
	vector<int> x(n), y(n);
	for(int i=0; i<n; ++i) cin>>x[i]>>y[i];

    long res=LONG_MAX;
#define rep(i, a, b) for(int i=a; i<b; ++i)
	rep(a, 0, n) rep(b, a, n) rep(c, b, n) rep(d, c, n) {
		auto ax=minmax({x[a], x[b], x[c], x[d]});
		auto ay=minmax({y[a], y[b], y[c], y[d]});
		long minx=ax.first, maxx=ax.second;
		long miny=ay.first, maxy=ay.second;
		int cnt=0;
		rep(e, 0, n)
			cnt+=(minx<=x[e]&&x[e]<=maxx)&&(miny<=y[e]&&y[e]<=maxy);
		if (cnt>=k)
			res=min(res, (maxx-minx)*(maxy-miny));
	}
    cout<<res<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (void)
{
	int a, b;
	cin >> a >> b;
	long long h[a];
	for (int i = 0; i < a; i++){
			cin >> h[i];
	}
	//sorting elements of h
	sort(h, h+a);
	if ( b > a){
		cout << 0;
		return 0;
	}
	//use of single power
	long long sum = 0;
	for (int i = 0; i < a-b; i++){
		sum += h[i];
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 1792
from bisect import bisect_left
N, K = map(int, input().split())
V = list(map(int, input().split()))

act = min(N, K)

ans = - 10 ** 19
for i in range(act + 1):
  for a in range(i + 1):
    for b in range(i - a + 1):
      itm = []
      itm += V[:a]
      itm += V[N-b:]
      itm.sort()
      idx = bisect_left(itm, 0)
      prize = sum(itm[min(idx, K - a - b):])
      ans = max(ans, prize)
print(ans)

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


int main(){
    int N;
    cin >> N;
    ll a[3*N];
    for (int i = 0; i < 3*N; i++)
    {
        cin >> a[i];
    }
    sort(a,a+3*N);
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += a[N+2*i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

int solve(const string& s) {
    int n = sz(s);
    int ans = 0, cnt = 0;
    rrep(i, 1, n) {
        char c = s[i - 1];
        if(c == 'A') {
            ans += cnt;
        } else if(c == 'B') {
            cnt++;
        }
    }
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(sz(s) < 3) {
        cout << 0 << endl;
        return 0;
    }
    if(s[sz(s) - 1] == 'B') {
        s = s.substr(0, sz(s) - 1);
    } else if(s[sz(s) - 1] == 'C' && s[sz(s) - 2] != 'B') {
        s = s.substr(0, sz(s) - 2);
    }
    string t;
    int n = sz(s), ans = 0;
    rep(i, 1, n - 1) {
        char c = s[i - 1], cc = s[i];
        if(c == 'A') {
            t += c;
        } else if(c == 'B') {
            if(cc == 'C') {
                t += "BC";
                i++;
            } else {
                ans += solve(t);
                t = "";
            }
        } else if(c == 'C') {
            ans += solve(t);
            t = "";
        }
    }
    ans += solve(t);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 916
N = int(input())
S = str(input())
Z = [0,1,2,3,4,5,6,7,8,9]
ans = 0
for i in range(10):
    x = S.find(str(i),0,N-2)
    if x >= 0:
        s = S[x + 1:]
        for j in range(10):
            y = s.find(str(j),0,N-1)
            if y >= 0:
                s_2 = s[y+1:]
                for k in Z:
                    if str(k) in s_2:
                        ans += 1
print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++) 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ld x[2], y[2], r[2];
	ll n;
	cin >> n;
	roop(i, n) {
		roop(lp, 2) {
			cin >> x[lp] >> y[lp] >> r[lp];
		}
		ld ab = sqrt((x[0] - x[1])*(x[0] - x[1]) + (y[0] - y[1])*(y[0] - y[1]));
		if (r[0] + r[1] < ab) { cout << 0 << endl; continue; }
		else if (r[0] + r[1] == ab) { cout << 1 << endl; continue; }
		else {
			if (r[0] > r[1]) {
				if (r[0] > r[1] + ab) { cout << 2 << endl; continue; }
			}
			else {
				if (r[1] > r[0] + ab) { cout << -2 << endl; continue; }
			}
		}cout << 1 << endl;

	}
	return 0;
}


Measured memory_bytes: 3088
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  REP(i, N) {
    if (A[i] % 2 == 0) {
      if (A[i] % 3 != 0 && A[i] % 5 != 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;


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

    int sum = 0;
    for (int i = 0;; i++) {
        sum += i;
        if (sum >= X) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int n;
    string s;
    cin >> n >> s;
    int x = 0;
    int res = 0;
    rep(i,n){
        if(s[i] == 'I'){
            x++;
            res = max(x,res);
        }else{
            x--;
        }
    }
    cout << res << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
abc = list(map(int, input().split()))
ans = 0
for i in range(10 ** 6):   
    if abc[0] % 2 != 0:
        print(ans)
        quit()
        break
    else:
        tmp1 = abc[1] // 2 + abc[2] // 2

    if abc[1] % 2 != 0:
        print(ans)
        quit()
        break
    else:
        tmp2 = abc[0] // 2 + abc[2] // 2
        
    if abc[2] % 2 != 0:
        print(ans)
        quit()
        break
    else:
        tmp3 = abc[0] // 2 + abc[2] // 2
        
    abc[0] = tmp1
    abc[1] = tmp2
    abc[2] = tmp3
    ans += 1

print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;


int main(){
    int abc[160][160];
    for(int i=0;i<17;i++){
        for(int j=0;j<17;j++){
            abc[i][j]=-1;
        }
    }
    int n;
    cin >> n;
    
    int kazu;//証言の数
    int x,y;
    
    //証言の代入
    for(int i=1;i<=n;i++){
        cin >> kazu;
        for(int j=0;j<kazu;j++){
            cin >> x >> y;
            if(y==1) abc[i][x]=1;
            else abc[i][x]=0;
        }
    }
    
    ll count=1;
    for(int i=0;i<n;i++){
        count*=2;
    }
    
    vector<ll> a(100);//0と1で表したもの
    
    int m;
    int total=1;
    int kotae=0;
    int total2=0;
    
    for(ll i=0;i<count;i++){
        m=i;
        for(ll j=1;j<=n;j++){
            a[j]=m%2;
            m/=2;
        }
        
        
        for(ll k=1;k<=n;k++){
            if(a[k]==0){ 
                continue;
            }
            total2++;
            for(ll l=1;l<=n;l++){
                if(abc[k][l]==-1) continue;
                if(abc[k][l]!=a[l]){
                    total=0;
                    break;
                }
            }
        }
        if(total) kotae=max(kotae,total2);
        total=1;
        total2=0;
    }
    
    cout << kotae << endl;
    
    //cout << abc[3][2] << endl;


    return 0;
}












Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define ret return 0
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int NUM = 2e5 + 5;
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        ll l,r; cin>>l>>r;
        if((l-1)/2019 != r/2019){
            // If there is a factor of 2019 in the given range
            cout<<0; return 0;
        }
        int ans = 2018;
        for(ll i=l;i<=r;i++){
            for(ll j=i+1;j<=r;j++){
                int cnt = ((i%2019)*(j%2019))%2019;
                ans = min(ans,cnt);
            }
        }
        cout<<ans;
    }   
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

//連結成分の個数を求める。

vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true;
    for(auto next_v : G[v]){
        if(seen[next_v]) continue;
        dfs(G, next_v);
    }
}

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

    Graph G(N + 1);
    for(int i = 0; i < M; i++){
        int x,y,z;
        cin >> x >> y >> z;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    int count = 0;
    seen.assign(N, false);
    for(int v = 1; v < N + 1; v++){
        if(seen[v]) continue;
        dfs(G,v);
        count ++;
    }
    cout << count << endl;
}

Measured memory_bytes: 10368
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
a,b = gi

puts ((a+b).to_f/2).ceil


Measured memory_bytes: 2300
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

void solve() {
    int n;
    std::cin >> n;
    std::vector<std::pair<std::string, int>> songs(n);
    rep(i, n) {
        std::cin >> songs[i].first >> songs[i].second;
    }
    std::string x;
    std::cin >> x;
    int cnt;
    rep(i, n) {
        if(songs[i].first == x) {
            cnt = i;
            break;
        }
    }
    i64 ans = 0;
    repeat(i, cnt + 1, n) {
        ans += songs[i].second;
    }
    std::cout << ans << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int H,A;
    cin >> H >> A;
    if(H%A >0){
        cout << H/A+1 << endl;
    }
    else
    {
        cout << H/A << endl;
    }

    return 0;    
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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

	string s;cin>>s;

	map<char ,int> mp;

	for(int i=0; i<s.length(); i++){
		mp[s[i]]++;
	}

	for(auto e: mp){
		if(e.second !=2){
			writeln("No");
			return 0;
		}
	}
	writeln("Yes");



}




Measured memory_bytes: 256
use whiteread::parse_line;

fn main() {
    let _n: usize = parse_line().unwrap();
    let s: String = parse_line().unwrap();
    let mut x: i32 = 0;
    let mut max_x = 0;

    for c in s.as_str().chars() {
        match c {
            'I' => x += 1,
            'D' => x -= 1,
            _ => unreachable!(),
        }
        max_x = max_x.max(x);
    }
    println!("{}", max_x);
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m,n;
        ll a,b;
        cin>>a>>b>>n;
        ll ans=0;
        if(n>=b-1)
        {
            ans=(a*(b-1))/b;
        }
        else
            ans=(a*n)/b;
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll a[105][105]={{}};
  ll b[105][105]={{}};
  int n,m,l;
  int i,j,k;
  cin >> n >> m >> l;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
      cin >> b[i][j];
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      ll o=0;
      for(k=0;k<m;k++){
	o+=a[i][k]*b[k][j];
      }
      if(j==0) cout << o;
      else cout << " " << o; 
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  sort(v.begin(),v.end());
  int sum=0;
  for(int i=0;i<n;){
    int c=0;
    for(int j=i;;j++){
      if(v[i]==v[j]) c++;
      if(v[i]!=v[j]) break;
    }
    if(c%2==1) sum++;
    i+=c;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  cout << setprecision(10) << fixed;
  ll n, m, d;
  cin >> n >> m >> d;
  if (d==0) cout << (double)(m-1)/n << endl;
  else cout << 2.0*(n-d)/(n*n)*(m-1) << endl;
  return 0;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
int h,w;
int main(){
    std::cin >> h>>w;
    string s[50];
    for (int i = 0; i < h; i++) {
        std::cin >> s[i];
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if(s[i].at(j)=='.'){
                int counter=0;
                char dum;
                for (int ii = max(0,i-1); ii <=min(h-1,i+1) ; ii++) {
                    for (int jj = max(0,j-1); jj <=min(w-1,j+1) ; jj++) {
                        if(s[ii].at(jj)=='#')counter++;
                    }   
                }
                dum=char(counter);
                std::cout << counter;
            }else{
                std::cout << '#';
            }
        }
        std::cout << endl;
    }
}



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

int main(){
  int64_t from,to;
  cin >> from >> to;
  const int64_t absfrom= abs(from);
  const int64_t absto= abs(to);

  int64_t ans= (absfrom <= absto) ? ( (from >= 0 && to >= 0) ? absto- absfrom
                                     :(from <  0 && to <  0) ? absto- absfrom+ 2
                                                             : absto- absfrom+ 1)
                                  : ( (from > 0 && to >  0) ? absfrom- absto+ 2
                                     :(from < 0 && to <= 0) ? absfrom- absto
                                                            : absfrom- absto+ 1);

  cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    int p[n];
    rep(i,n) cin>>p[i];

    int ans=0;
    for(int i=2; i<n; i++){
        if( (p[i-2]<p[i-1]) && (p[i-1]<p[i]) ){
            ans++;
        }
        else if( (p[i]<p[i-1]) && (p[i-1]<p[i-2]) ){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#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;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x[5];
    rep(i,5) cin>>x[i];
    rep(i,5) if(x[i]==0){
        cout<<i+1;
        return 0;
    }
}

Measured memory_bytes: 3604
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

int main() {
  long long A, B, K;
  cin >> A >> B >> K;

  if (K > A) {
    cout << 0 << " " << max((long long)0, B-(K-A)) << endl;
  } else {
    cout << A-K << " " << B << endl;
  }
  
  return 0;
}


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


int main() {

int n,x;
cin >> n >> x;
vector<int> l(n);
rep(i,n) cin >> l[i];

int now = 0;
int ans = 0;

rep(i,n){
    if(now <= x) ans++;
    now += l[i];
}

if(now <= x) ans++;

cout << ans << endl;


 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

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


int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    ll pre=A[0];
    bool flag=true;
    for(int i=0; i<N-1; i++){
        if(pre==A[i+1])flag=false;
        pre=A[i+1];
    }

    if(flag)cout << "YES";
    else cout << "NO";

    cout << endl;




    return 0;
}

Measured memory_bytes: 1792
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g,ko;
    ll x,y;
    char hoge;
    cin>>str;
    rep(i,str.length()){
        if(str[i]==',') cout<<" ";
        else cout<<str[i];
    }
    ln;
    return 0;
}


Measured memory_bytes: 3628
while True:
    X = input().split()
    a = int(X[0])
    b = int(X[2])
    op = X[1]

    if op == "+":
        print(a + b)
    elif op =="-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    elif op == "?":
        break
    


Measured memory_bytes: 5592
N,M=gets.split.map(&:to_i)
a1=[]
an=[]
M.times{
    a,b=gets.split.map(&:to_i)
    if a==1
        a1 << b
    end
    if a==N
        an << b
    end
    if b==1
        a1 << a
    end
    if b==N
        an << a
    end
}
if (a1 & an).empty?
    puts "IMPOSSIBLE"
else
    puts "POSSIBLE"
end


Measured memory_bytes: 19228
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll mod = 1e9+7;

int main() {
    ll n, m;
    cin >> n >> m;
    vector<string> as(n), bs(m);
    rep(i, n) cin >> as[i];
    rep(i, m) cin >> bs[i];
    rep(i, n-m+1) {
        rep(j, n-m+1) {
            bool check = true;
            rep(k, m) {
                if (as[i+k].compare(j, m, bs[k]) != 0) {
                    check = false; 
                    break;
                }
            }
            if (check) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    } 
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)

// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll N, T;
	cin >> N >> T;
	ll c[N], t[N];
	for (ll i = 0; i < N; ++i) cin >> c[i] >> t[i];
 
	// 解法
	ll ans = 1100;
	for (ll i = 0; i < N; ++i){
		if (t[i]<=T & c[i]<ans) ans = c[i];
	}
	if (ans==1100) printf("TLE\n");
	else printf("%lld\n", ans);
}
 


Measured memory_bytes: 256
n = int(input())
 
h = list(map(int,input().split()))
 
height = h[0]
 
q = 0
 
for i in h:
    if i < height:
        q = 1
        break
    elif i > height:
        height = i-1
    else:
        height = i
        
if q == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 20640
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

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

    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }

    int ans = 0;
    for (int i = 1; i < n - 1; i++) {
        if (((p[i] < p[i - 1]) && (p[i] > p[i + 1])) || ((p[i] < p[i + 1]) && (p[i] > p[i - 1]))) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import collections
from functools import lru_cache

sys.setrecursionlimit(10 ** 6)
xy = []
d = collections.defaultdict(list)

@lru_cache(maxsize=None)
def alg_memoization_recursion(f):
    mt = 0
    for v in d[f]:
        mt = max(mt, alg_memoization_recursion(v) + 1)
    return mt


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    for i in range(m):
        x, y = list(map(int, readline().split()))
        d[x-1] += [y-1]
    mt = 0
    for i in range(n):
        mt = max(mt, alg_memoization_recursion(i))
    print(mt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 655092
n = int(input())
A = list(map(int, input().split()))
for i in range(1, n):
    print(' '.join(map(str, A)))
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
else:
    print(' '.join(map(str, A)))

Measured memory_bytes: 6724
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let mut line = read_as_vec::<u64>();
    line.sort();

    if line.iter().any(|x| *x%2 == 0){
        println!("0");
    }else{
        println!("{}", line[0]*line[1]);
    }
}


Measured memory_bytes: 4352
import numpy as np

def frog():
    N = int(input())
    h = list(map(int, input().split()))
    dp = np.zeros(N, dtype=int)
    dp[1] = abs(h[1] - h[0])
    for i in range(2, N):
        dp[i] = min([abs(h[i] - h[i-1])+dp[i-1], abs(h[i] - h[i-2])+dp[i-2]])
    print(dp[N-1])

if __name__ == "__main__":
    frog()



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

int stones[51];

int main(){
	while(true){
		for(int i = 0;i<=50;i++)stones[i]=0;
		int wanposi = 0;
		int n,p;
		cin >> n;
		cin >> p;
		if(n==0)break;
		int wan = p;
	
		while(true)
		{
			if(wan!=0){wan--;stones[wanposi]++;}
			else{wan=stones[wanposi];stones[wanposi]=0;}
		
			if(stones[wanposi]==p){break;}
			else if(wanposi<n-1){wanposi++;}
				else wanposi = 0;
		
		}
	cout << wanposi << endl;
	}
	return 0;
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
ll MOD=1000000007;

int main(){
  int n,d; cin>>n>>d;
  int ans = 0;
  rep(i,n){
    ll x,y; cin>>x>>y;
    double dis = sqrt((x*x)+(y*y));
    if (dis <= d) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3676
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>
#include<iomanip>

#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define MOD 1000000007

using namespace std;
using ll=long long int;

int H,W;
vector<string> S;

int main(){
    cin >> H >> W;
    S = vector<string>(H);
    for(int i=0;i<H;i++){
        cin >> S[i];
    }
    vector<vector<int>> L(H,vector<int>(W));
    vector<vector<int>> R(H,vector<int>(W));
    vector<vector<int>> D(H,vector<int>(W));
    vector<vector<int>> U(H,vector<int>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(S[i][j]=='.'){
                if(j>0&&L[i][j-1]!=0){
                    L[i][j]=(L[i][j-1]+1);
                }
                else{
                    L[i][j]=1;
                }
            }
        }
    }
    for(int i=0;i<H;i++){
        for(int j=W-1;j>=0;j--){
            if(S[i][j]=='.'){
                if(j+1<W&&R[i][j+1]!=0){
                    R[i][j]=(R[i][j+1]+1);
                }
                else{
                    R[i][j]=1;
                }
            }
        }
    }
    for(int j=0;j<W;j++){
        for(int i=0;i<H;i++){
            if(S[i][j]=='.'){
                if(i>0&&U[i-1][j]!=0){
                    U[i][j]=(U[i-1][j]+1);
                }
                else{
                    U[i][j]=1;
                }
            }
        }
    }
    for(int j=0;j<W;j++){
        for(int i=H-1;i>=0;i--){
            if(S[i][j]=='.'){
                if(i+1<H&&D[i+1][j]!=0){
                    D[i][j]=(D[i+1][j]+1);
                }
                else{
                    D[i][j]=1;
                }
            }
        }
    }
    vector<int> ans;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(S[i][j]=='.'){
                ans.pb(L[i][j]+R[i][j]+D[i][j]+U[i][j]-3);
            }
        }
    }
    sort(ans.rbegin(),ans.rend());
    cout << ans[0] << endl;
    return 0;
}


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

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

const int CASES = 2;

// vector v において、x の前方と後方の index を求める
template<class T> int former(const vector<T> &v, T x) {
    return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
template<class T> int latter(const vector<T> &v, T x) {
    return lower_bound(v.begin(), v.end(), x) - v.begin();
}

void solve(){
    int A, B, Q; cin >> A >> B >> Q;

    vector<ll> s(A), t(B);
    for (int i = 0; i < A; ++i) cin >> s[i];
    for (int i = 0; i < B; ++i) cin >> t[i];

    // sential
    s.push_back(INF64); s.push_back(-INF64); sort(s.begin(), s.end());
    t.push_back(INF64); t.push_back(-INF64); sort(t.begin(), t.end());

    for (int _ = 0; _ < Q; ++_) {
        ll x; cin >> x;
        ll res = INF64;

        // 最初に s (前方に行くか後方に行くか場合分け)
        for (int i = 0; i < 2; ++i) {
            ll first = (i ? s[former(s, x)] : s[latter(s, x)]);
            // 次に t (現在地の前後を見る)
            for (int j = 0; j < 2; ++j) {
                ll second = (j ? t[former(t, first)] : t[latter(t, first)]);
                res = min(res, abs(x - first) + abs(first - second));
            }
        }
        // 最初に t (前方に行くか後方に行くか場合分け)
        for (int i = 0; i < 2; ++i) {
            ll first = (i ? t[former(t, x)] : t[latter(t, x)]);
            // 次に t (現在地の前後を見る)
            for (int j = 0; j < 2; ++j) {
                ll second = (j ? s[former(s, first)] : s[latter(s, first)]);
                res = min(res, abs(x - first) + abs(first - second));
            }
        }
        cout << res << endl;
    }
    return;
}

int main() {
    #ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
    #else

    solve();

    #endif
    return 0;
}



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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());
 
signed main()
{
    gearup;
    ll n,d; cin >> n >> d;
    ll res = 0;
    rep(i,n){
        ll x,y; cin >> x >> y;
        if(x*x + y*y <= d*d)res++;
    }
    out(res);
}

Measured memory_bytes: 3640
K, N = map(int, input().split())
A = list(map(int, input().split()))

ans_sub = 0
for i in range(N - 1):
    ans_sub = max(ans_sub, A[i + 1] - A[i])
else:
    ans_sub = max(ans_sub, (K + A[0]) - A[-1])

print(K - ans_sub)

Measured memory_bytes: 26420
N = int(raw_input())
a = map(int, raw_input().split())

min = 4000001

for i in range(-100, 101):
	sum = 0
	for j in range(0, N):
		sum = sum + (a[j] - i) * (a[j] - i)
	if sum < min: min = sum

print min

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int MAX = 1 << 17;

vector<int> g[MAX];
bool used[MAX];
bool cnt[MAX];
vector<PII> ans;
int dep[MAX];

void dfs(int v, int p)
{
	used[v] = true;
	for(int to: g[v])
	{
		if(used[to] && to != p && dep[to] < dep[v])
		{
			ans.PB(MP(v, to));
			cnt[v] ^= 1;
		}
		if(!used[to])
		{
			dep[to] = dep[v] + 1;
			dfs(to, v);
			if(cnt[to])
				ans.PB(MP(to, v));
			else
			{
				ans.PB(MP(v, to));
				cnt[v] ^= 1;
			}
		}
	}
}

int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m;
	cin >> n >> m;
	if(m & 1)
	{
		cout << -1;
		return 0;
	}
	FOR(i, 0, m)
	{
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].PB(v);
		g[v].PB(u);
	}
	dfs(0, -1);
	assert(SZ(ans) == m);
	for(auto e: ans)
		cout << e.first + 1 << " " << e.second + 1 << "\n";
	return 0;
}

Measured memory_bytes: 18420
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

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

	vector<int> A(N), B(N);
	rep(i, N)
	{
		cin >> A[i];

		B[i] = A[i];
	}

	sort(all(A));
	int m1 = A[N - 1], m2 = A[N - 2];

	rep(i, N)
	{
		if (B[i] == m1)
		{
			cout << m2 << endl;
		}
		else
		{
			cout << m1 << endl;
		}
	}
	

	return 0;
}

Measured memory_bytes: 3200