akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vvll g(n,vll(0)) ;
	ll sub = n-(n&1) ;
	ll m = 0 ;
	for(int i=0;i<sub;i++){
		for(int j=i+1;j<sub;j++){
			if(i+j==sub-1) continue ;
			g.at(i).emplace_back(j) ;
			m++ ;
		}
	}
	if(n&1){
		for(int i=0;i<sub;i++){
			m++ ;
			g.at(i).emplace_back(n-1) ;
		}
	}
	cout << m << endl ;
	for(int i=0;i<n;i++){
		for(int j=0;j<g.at(i).size();j++){
			cout << i+1 << " " << g.at(i).at(j)+1 << endl ;
		}
	}
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, k; cin >> n >> k;
    vi h(n); rep(i, n) cin >> h[i];
    vi dp(n, INFLL); dp[0] = 0;

    for(ll i=1; i<n; i++){
        for(ll jmp=1; jmp<=k; jmp++){
            if(i-jmp<0) break;
            else chmin(dp[i], dp[i-jmp]+abs(h[i]-h[i-jmp]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
// 2020-09-13 18:25:43
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
const int mod = 1000000007, MX = 100010;
ll dp[MX + 10], p[MX + 10];
void answer() {
  int n, m;
  cin >> n >> m;
  vector<int> s(n);
  rep(i, n) cin >> s[i];
  sort(ALL(s));
  rep(x, MX) dp[x] = x;
  rep(i, n) {
    swap(p, dp);
    rep(x, MX)(dp[x] = p[x % s[i]] + p[x] * i) %= mod;
  }
  cout << dp[m] << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 5172
#include <cstddef>
#include <iostream>
#include <vector>

template <typename T = int>
class SegmentTree {
 private:
  const std::size_t size = 0;
  std::vector<T> tree;

 public:
  explicit SegmentTree(const std::size_t n)
      : size(1 << (32 - __builtin_clz(n))), tree(2 * size, 0) {}

  explicit SegmentTree(const std::vector<T> &vec)
      : size(1 << (32 - __builtin_clz(vec.size()))), tree(2 * size, 0) {
    for (std::size_t i = 0; i < vec.size(); i++) {
      tree[i + size] = vec[i];
    }
    for (std::size_t i = size - 1; i-- > 0;) {
      tree[i] = std::max(tree[2 * i], tree[2 * i + 1]);
    }
  }

  void update(std::size_t idx, const T x) {
    idx += size;
    tree[idx] = std::max(tree[idx], x);
    while (idx > 0) {
      idx /= 2;
      tree[idx] = std::max(tree[2 * idx], tree[2 * idx + 1]);
    }
  }

  T query(std::size_t l, std::size_t r) {
    T x = 0, y = 0;
    for (l += size, r += size; l < r; l /= 2, r /= 2) {
      if (l & 1) x = std::max(x, tree[l++]);
      if (r & 1) y = std::max(tree[--r], y);
    }
    return std::max(x, y);
  }
};

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int N, K;
  std::cin >> N >> K;
  std::vector<int> A(N);
  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
  }
  SegmentTree st(300005);
  for (int i = 0; i < N; i++) {
    int l = std::max(0, A[i] - K), r = std::min(300000, A[i] + K);
    int x = st.query(l, r + 1);
    st.update(A[i], x + 1);
  }
  std::cout << st.query(0, 300001) << '\n';
  return 0;
}


Measured memory_bytes: 8488
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL lpow(LL a,LL n){LL ans=pow(a,n)*10;if(ans%10<5)return ans/10;return ans/10+1;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL N,M,i,ans=0;
  scanf("%lld",&N);

  printf("%lld\n",dup(N,2));
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int n, m, q, a[55] = {}, b[55] = {}, c[55] = {}, d[55] = {}, z = 0;
vector<int> e = {1};

void sol() {
    if (e.size() == n + 1) {
        int y = 0;
        for (int i = 0; i < q; i++) if (e[b[i]] - e[a[i]] == c[i]) y += d[i];
        z = max(z, y);
        return;
    }
    for (int i = e.back(); i <= m; i++) {
        e.push_back(i);
        sol();
        e.pop_back();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
    sol();
    cout << z;
}


Measured memory_bytes: 3660
#include <iostream>
#include<stdio.h>
int main(){
	long double a, b, c, d, e, f,x,y;
	while (std::cin >> a >> b >> c >> d >> e >> f) {
		x = (b*f - e * c) / (d*b - a * e);
		y = (a*f - d * c) / (a*e - d * b);
		if (x < 0)
			x = (double)((int)(1000 * x - 0.5)) / 1000;
		else
			x = (double)((int)(1000 * x + 0.5)) / 1000;
		if (y < 0)
			y = (double)((int)(1000 * y - 0.5)) / 1000;
		else
			y = (double)((int)(1000 * y + 0.5)) / 1000;
		printf("%.3llf %.3llf\n", x, y);
	}
	return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <cstdint>

using namespace std;

int main() {
    int32_t n;

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

    vector<int32_t> sorted(w);
    sort(sorted.begin(), sorted.end());

    unordered_map<int32_t, int32_t> index;
    for (int32_t i = 0; i < n; i++) {
        index[sorted[i]] = i;
    }

    int32_t cost = 0;
    for (int32_t i = 0; i < n; i++) {
        if (w[i] != sorted[i]) {
            int32_t size = 1, sum = w[i], minval = INT32_MAX;
            int32_t j = index[w[i]], j_new;
            while (j != i) {
                size++;
                sum += w[j];
                minval = min(minval, w[j]);
                j_new = index[w[j]];
                w[j] = sorted[j];
                j = j_new;
            }

            cost += min(sum + minval * (size - 2), 2 * (sorted[0] + minval) + (sum - minval + sorted[0]) + sorted[0] * (size - 2));
        }
    }

    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>
   
int main(void){   
    int m, f, r;
    while(1){
        scanf("%d %d %d", &m, &f, &r);
        if(m == -1 && f == -1 && r == -1) break;
        else if(m == -1 || f == -1) printf("F\n");
        else if(80 <= (m+f)) printf("A\n");
        else if(65 <= (m+f)) printf("B\n");
        else if(50 <= (m+f)) printf("C\n");
        else if(30 <= (m+f)){
            if(50 <= r) printf("C\n");
            else printf("D\n");
        }
        else printf("F\n");
    }
    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int main(){
	int n;	cin >> n;	vector<int> vec;	vec.push_back(2);
	map<int, long long int> mp;    mp[2]++;
	if(n==1 or n==2){
		cout << n;	return 0;
	}
	for(int i=3;n>=i;i++){
		int k=i;	bool flag=1;
		for(int j=0;vec.size()>j;j++){
			if(k%vec[j]){
				continue;
			}
			flag=0;
			while(k%vec[j]==0){
				k/=vec[j];	mp[vec[j]]++;
			}
		}
		if(flag){
			vec.push_back(i);	mp[i]++;	continue;
		}
	}
	long long int ans=1;
	for(auto it=mp.begin();it!=mp.end();it++){
		ans*=((it->second)+1);	ans=(ans+MOD)%MOD;
	}
	cout << ans;
}

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

int main() {
	vector<vector<int>> A(3, vector<int>(3));
	vector<vector<bool>> a(3, vector<bool>(3));
	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < 3; j++) {
			a.at(i).at(j) = false;
			cin >> A.at(i).at(j);
		}
	}
	int N;
	cin >> N;
	vector<int> b(N);
	for(int i = 0; i < N; i++)
		cin >> b.at(i);

	for(int i = 0; i < N; i++) {
		for(int j = 0; j < 3; j++) {
			for(int k = 0; k < 3; k++) {
				if(b.at(i) == A.at(j).at(k))
					a.at(j).at(k) = true;
			}
		}
	}

	bool ans = false;
	for(int i = 0; i < 3; i++) {
		if(a.at(0).at(i) && a.at(1).at(i) && a.at(2).at(i))
			ans = true;
		if(a.at(i).at(0) && a.at(i).at(1) && a.at(i).at(2))
			ans = true;
	}
	if(a.at(0).at(0) && a.at(1).at(1) && a.at(2).at(2))
		ans = true;
	if(a.at(2).at(0) && a.at(1).at(1) && a.at(0).at(2))
		ans = true;

	if(ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    COMinit();
    long n,k;
    cin >> n >> k;
    /*if(k >= n-1){
        cout << COM(2*n-1,n) << endl;
        return 0;
    }*/
  k = min(k,n-1);
    long ans = 1;
    for(int i=1;i<=k;i++){
        long tmp1 = COM(n,i);
        long tmp2 = COM(n-1,i);
        ans += tmp1*tmp2;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
char s[5];
int main(){
  scanf("%s",&s);
  int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';

  if (a-b-c-d==7) printf("%d-%d-%d-%d=7\n",a,b,c,d);
  else if (a-b-c+d==7) printf("%d-%d-%d+%d=7\n",a,b,c,d);
  else if (a-b+c-d==7) printf("%d-%d+%d-%d=7\n",a,b,c,d);
  else if (a-b+c+d==7) printf("%d-%d+%d+%d=7\n",a,b,c,d);
  else if (a+b-c-d==7) printf("%d+%d-%d-%d=7\n",a,b,c,d);
  else if (a+b-c+d==7) printf("%d+%d-%d+%d=7\n",a,b,c,d);
  else if (a+b+c-d==7) printf("%d+%d+%d-%d=7\n",a,b,c,d);
  else if (a+b+c+d==7) printf("%d+%d+%d+%d=7\n",a,b,c,d);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <regex>
#include<ext/numeric>
#include<ext/hash_map>
using namespace std;
using namespace __gnu_cxx;

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v)  (int)v.size()
#define WHITE -1
#define GREY   0
#define BLACK  1
#define CLR(a,v) memset(a,v,sizeof a)
#define PC(x) __builtin_popcount(x)
#define MP make_pair

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
//typedef unsigned int ui;

typedef complex<double> point;
//#define X real()
#define Y imag()
#define vec(a,b) ((b)-(a))
#define dot(a,b) ((conj(a)*(b)).real())
#define cross(a,b) ((conj(a)*(b)).imag())
#define colliner pointOnLine
#define same(a,b) (lengthSqr(vec(a,b))<EPS)
#define lengthSqr(v) (dot(v,v))

const double PI = acos(-1.0);

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

int DX[] = { 1, 1, -1, -1, 2, 2, -2, -2 };
int DY[] = { 2, -2, 2, -2, 1, -1, 1, -1 };

const int MAX = 1e5 + 5, MOD = 1e9 + 7, oo = (1 << 30);
const ll OO = 1ll << 60, MAXN = 1e15;
const double EPS = 1e-9;

int n, c, k, t[MAX];

int main() {

	scanf("%d%d%d", &n, &c, &k);
	for (int i = 0; i < n; ++i)
		scanf("%d", &t[i]);
	sort(t, t + n);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int j = i + 1;
		for (; j < n && t[j] - t[i] <= k && j - i + 1 <= c; ++j)
			;
		++ans, i = j - 1;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 640
main :: IO ()
main = do
  n <- readLn :: IO Int
  a <- getLine :: IO String
  b <- getLine :: IO String
  c <- getLine :: IO String
  print $ solve a b c

solve :: String -> String -> String -> Int
solve [] _ _ = 0
solve (a:as) (b:bs) (c:cs) = i + solve as bs cs
  where
    i = if a == b && b == c
        then 0
        else if a == b || b == c || c == a
              then 1
              else 2

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int[] x = new int[n];
		for (int i = 0; i < n; i++) x[i] = sc.nextInt();
		long[] dp = new long[n];
		dp[0] = 0;
		for (int i = 1; i < n; i++) {
			long min = Long.MAX_VALUE;
			for (int j = 1; j <= k && i - j >= 0; j++) {
				long t = dp[i - j] + Math.abs(x[i - j] - x[i]);
				if (t < min) min = t;
			}
			dp[i] = min;
		}
		System.out.println(dp[n-1]);
	}
}


Measured memory_bytes: 51096
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>

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

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

ll A[200001];
ll T[200001];

int main(int argc, const char * argv[]) {
    int N, K;
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    
    for(int i=0; i+K<N; i++){
        if(A[i] < A[i+K]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
        
    return 0;
}


Measured memory_bytes: 4628
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 1010;
int n;
LL x[maxn],y[maxn],u[maxn],v[maxn],bs[35];

void work() {
cin >> n;
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
    LL sum = (x[0] + y[0]) % 2;
    for (int i = 0; i < n; i++) if ((x[i] + y[i] - sum) % 2 != 0) {cout<<"-1"<<endl;return;}

    if (sum == 0) {
        cout << 32 << endl;
        for (int i = 30; i > -1; i--) cout<<bs[i]<<" ";
        cout << 1 << endl;
        for (int i = 0; i < n; i++) x[i]++;
    }else {
        cout << 31 << endl;
        for (int i = 30; i > -1; i--) cout<<bs[i]<<" ";
        cout << endl;
    }

    for (int i = 0; i < n; i++) u[i] = x[i] + y[i], v[i] = x[i] - y[i];

    for (int i = 0; i < n; i++) {
        for (int j = 30; j > -1; j--) {
            if (u[i] > 0 && v[i] > 0) {cout << 'R'; u[i] -= bs[j]; v[i] -= bs[j]; }
            else if (u[i] > 0 && v[i] < 0) { cout << 'U'; u[i] -= bs[j]; v[i] += bs[j]; }
            else if (u[i] < 0 && v[i] > 0) { cout << 'D'; u[i] += bs[j]; v[i] -= bs[j]; }
            else { cout << 'L'; u[i] += bs[j]; v[i] += bs[j];}
        }
        if (sum == 0) cout << 'L';
        cout << endl;
    }
}
int main(){
    bs[0] = 1;
    for (int i=1;i<32;i++) bs[i] = bs[i-1] << 1;
    work();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;
typedef long long LL;
const int MAXN = 100100;
const int MOD7 = 1e9 + 7;
const int MOD9 = 1e9 + 9;
const int INF = 2e9;
const double EPS = 1e-6;
const double PI = 3.14159265358979;
const int dir_4r[] = { -1, 1, 0, 0 };
const int dir_4c[] = { 0, 0, -1, 1 };
const int dir_8r[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
const int dir_8c[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int n;
int a[MAXN];
int b[MAXN];
int c[MAXN];
int big[MAXN];
int sml[MAXN];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", a + i);
	for (int i = 1; i <= n; ++i)
		scanf("%d", b + i);
	for (int i = 1; i <= n; ++i)
		scanf("%d", c + i);
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	sort(c + 1, c + n + 1);
	memset(big, 0, sizeof(big));
	memset(sml, 0, sizeof(sml));

	int j = 1;
	for (int i = 1; i <= n; ++i)
	{
		sml[i] += sml[i - 1];
		while (j <= n && a[j] < b[i])
		{
			sml[i]++;
			j++;
		}
	}
	j = n;
	for (int i = n; i > 0; --i)
	{
		big[i] += big[i + 1];
		while (j > 0 && c[j] > b[i])
		{
			big[i]++;
			j--;
		}
	}

	LL ans = 0;
	for (int i = 1; i <= n; ++i)
		ans += (LL)sml[i] * (LL)big[i];
	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)
int main(){
    ll t,i,j,l,h,n,x,k,y;
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>x>>n;
    map<ll,ll> m;
    rep(i,1,n){
    	cin>>y;
    	m[y]=1;
	}
	i = x;
	j = x;
	while(1){
		if(m[i] == 0){
			cout<<i;
			return 0;
		}else{
			i--;
		}
		if(m[j] == 0){
			cout<<j;
			return 0;
		}else{
			j++;
		}	
	}
}

Measured memory_bytes: 3632
#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>

size_t bsrch(int64_t ary[], size_t sz, int64_t v)
{
  size_t low = 0;
  size_t high = sz - 1;

  while (low < high) {
    size_t mid = low + (high - low) / 2;
    if (ary[mid] < v) {
      low = mid + 1;
    } else {
      high = mid;
    }
  }

  return low;
}

int main(void)
{
  const int64_t inf = 100000000000;
  int64_t a, b, q;
  scanf("%" SCNd64 "%" SCNd64 "%" SCNd64, &a, &b, &q);
  int64_t s[a + 2], t[b + 2], x[q];
  for (size_t i = 1; i <= a; i++) scanf("%" SCNd64, &s[i]);
  for (size_t i = 1; i <= b; i++) scanf("%" SCNd64, &t[i]);
  for (size_t i = 0; i < q; i++) scanf("%" SCNd64, &x[i]);
  s[0] = t[0] = -inf;
  s[a + 1] = t[b + 1] = inf;
  for (size_t i = 0; i < q; i++) {
    int64_t ans = inf;
    int64_t d[4];
    size_t si = bsrch(s, a + 2, x[i]);
    size_t ti = bsrch(t, b + 2, x[i]);
    int64_t s_east = s[si] - x[i];
    int64_t s_west = x[i] - s[si - 1];
    int64_t t_east = t[ti] - x[i];
    int64_t t_west = x[i] - t[ti - 1];
    d[0] = s_east > t_east ? s_east : t_east;
    d[1] = s_west > t_west ? s_west : t_west;
    d[2] = s_west > t_east ? s_west + t_east * 2 : s_west * 2 + t_east;
    d[3] = t_west > s_east ? t_west + s_east * 2 : t_west * 2 + s_east;
    for (size_t j = 0; j < 4; j++) {
      if (ans > d[j]) ans = d[j];
    }
    printf("%" PRId64 "\n", ans);
  }
}


Measured memory_bytes: 3584
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P, X = [], []
for _ in [0]*M:
    p, x = map(int, input().split())
    P.append(p)
    X.append(x)
total = sum(T)
for i in range(len(P)):
    print(total + X[i] - T[P[i]-1])


Measured memory_bytes: 3064
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	printf(abs(x - a) < abs(x - b) ? "A\n" : "B\n");
}

Measured memory_bytes: 256
for i in range(0, 10000):
    num = input().split(" ")
    
    x = int(num[0])
    y = int(num[1])
    if x == 0 and y == 0:
        break
    if x > y:
        print("{1} {0}".format(x, y))
    else:
        print("{0} {1}".format(x, y))




Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
// #define int long long
struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

using Int = __int128_t;
using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}


signed main() {
    
	int64_t n, x, m;
	cin >> n >> x >> m;

	map<int, int> s;

	vector<int64_t> sum;

	int64_t a = x;
	sum.bash(x);

	for(int i = 0; i < n - 1; i++) {
		int64_t t = a * a % m;

		if(s.find(t) != s.end()) {
			int64_t ans = sum[s[t]];
			int l = i - s[t];
			int64_t lo = sum[i] - sum[s[t]];
			n -= s[t] + 1;

			ans += lo * (n / l);
			n %= l;
			a = t;


			for(int k = 0; k < n; k++) {
				ans += a;
				a = a * a % m;
			}
			cout << ans << endl;
			return 0;
		}
		else {
			s[t] = i;
			a = a * a % m;
			sum.bash(sum.back() + a);
		}
	}

	cout << sum.back() << endl;

    return 0;
}


Measured memory_bytes: 5912
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        int[][] A = new int[n][m];
        int[] b = new int[m];
        
        int[] sum = new int[n];
        int[] product = new int[m];
        int[] ans = new int[n];
        
        for (int i = 0; i < A.length; i++) {
            for (int j = 0; j < A[i].length; j++) {
                A[i][j] = sc.nextInt();
            }
        }
        for (int j = 0; j < b.length; j++) {
            b[j] = sc.nextInt();
        }
        for (int i = 0; i < A.length; i++) {
            for (int j = 0; j < A[i].length; j++) {
                product[j] = A[i][j] * b[j];
                sum[i] += product[j];
            }
            ans[i] = sum[i];
        }
        for (int i = 0; i < ans.length; i++) {
            System.out.println(ans[i]);
        }
    }
}


Measured memory_bytes: 40808
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    if (N == 1) {
      System.out.println(1);
      return;
    }
    System.out.println((double)((N+1)/2)/N);
  }
}

Measured memory_bytes: 23764
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll l,r,d;
    cin >> l >> r >> d;
    cout << r/d-(l-1)/d << endl;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

ll N, M;

int main(void) {

    cin >> N >> M;

    ll ans;
    if ((N == 1 && M == 1)) {
        ans = 1;
    }
    else if (N == 1 || M == 1) {
        ans = N * M - 2;
    }
    else if (N <= 2 || M <= 2) {
        ans = 0;
    }
    else {
        ans = (N - 2) * (M - 2);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
class Dice:
    def __init__(self):
        self.state =[1, 2, 3, 4, 5, 6]

    def setState(self, li):  # [top, S, E, W, N, under]
        self.state = li

    def move(self, str_direction):
        if str_direction == "N":
            self.state = [self.state[1], self.state[5],self.state[2],
                          self.state[3], self.state[0], self.state[4]]
        if str_direction == "W":
            self.state = [self.state[2], self.state[1], self.state[5],
                          self.state[0], self.state[4], self.state[3]]
        if str_direction == "E":
            self.state = [self.state[3], self.state[1], self.state[0],
                          self.state[5], self.state[4], self.state[2]]
        if str_direction == "S":
            self.state = [self.state[4], self.state[0], self.state[2],
                          self.state[3], self.state[5], self.state[1]]

    def rotate(self):
        self.state = [self.state[0], self.state[2], self.state[4],
                      self.state[1], self.state[3], self.state[5]]

    def sameDice1(self, dice1):
        set1 = list()
        for _ in range(4):
            for __ in range(4):
                set1.append(self.state)
                self.rotate()
            self.move("N")
        self.move("E")
        for _ in range(4):
            set1.append(self.state)
            self.rotate()
        self.move("E")
        self.move("E")
        for _ in range(4):
            set1.append(self.state)
            self.rotate()
        if dice1.state in set1:
            return "Yes"
        return "No"


def main():
    n = int(input())
    dices = []
    for i in range(n):
        dices.append(Dice())
        dices[i].setState(list(map(int, input().split())))
    bl = False
    result = "Yes"
    for i in range(n):
        for j in range(n):
            if i == j:
                break
            if dices[i].sameDice1(dices[j]) == "Yes":
                result = "No"
                bl = True
                break
        if bl:
            break
    print(result)

if __name__ == "__main__":
    main()

Measured memory_bytes: 7852
import sys

input = sys.stdin.readline
M = 10 ** 9 + 7

n = int(input())
a = list(map(int, input().split()))
assert len(a) == n + 1

b = [None] * (n + 1)
d1, d2 = -1, -1
for i in range(n + 1):
    if b[a[i]] is None:
        b[a[i]] = i
    else:
        d1 = b[a[i]]
        d2 = i
        break
assert d1 >= 0 and d2 >= 0 and a[d1] == a[d2]


a, b, ik = n + 1, 1, 1
for k in range(1, n + 2):
    ans = (a - b) % M
    print(ans)
    b = b * (n + 1 - d2 + d1 - k) * ik % M
    ik = pow(k + 1, M - 2, M)
    a = a * (n + 1 - k) * ik % M


Measured memory_bytes: 56924
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] AB = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            Console.WriteLine(AB[0]*AB[1]);
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}

Measured memory_bytes: 17824
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long long ll;
typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("amusing.in", "r", stdin);
    //freopen("amusing.out", "w", stdout);
}

void solve() {
    char c;
    cin >> c;
    if (c >= 'a' && c <= 'z') cout << "a\n"; else cout << "A\n";
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

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



int main(){
  int n,i,sum=0,count=0;
  double mean;
  int a[10000];

  
  while(1){
    cin >> n;
    if(n==0){
      break;
    }
    count=0;
    sum=0;
    for(i=0;i<n;i++){
      cin >> a[i];
      sum += a[i];
    }
    mean=sum/n;
    for(i=0;i<n;i++){
      if(a[i]<=mean){
	count++;
      }
    }
    cout << count << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3140
from fractions import gcd
from functools import reduce

mod = 10 ** 9 + 7

def lcm(a,b):
    return a * b//gcd(a,b)

n = int(input())
lis = list(map(int,input().split()))
now = reduce(lcm,lis)

print(sum(list(map(lambda x:now//x,lis)))%mod)

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

int N;
std::vector<int> A;
std::vector<std::vector<int>> x;
std::vector<std::vector<int>> y;
int ans = 0;

void rec(std::vector<bool> v, int ind)
{
    // ベースケース
    // 最後まで行ったら判定
    if (ind == N)
    {
        // std::cout << std::endl;
        // std::cout << "======" << std::endl;
        // for (int i = 0; i < N; i++) std::cout << v[i] << " ";
        // std::cout << std::endl;

        // 成り立つか判定
        bool flag = true;
        int cnt = 0;
        // 正直者の証言が合っているか見たいので全員チェック
        for (int i = 0; i < N; i++)
        {
            // 証言が合わない場合は終了
            if (flag == false) break;

            // std::cout << i << "人目" << std::endl;
            // 正直者がいればそいつの証言をすべてチェック
            if (v[i] == true)
            {
                // std::cout << "in" << std::endl;
                // 正直者の数をカウント
                cnt++;

                // 正直者の証言をチェック
                for (int j = 0; j < A[i]; j++)
                {
                    // std::cout << v[ x[i][j]-1 ] << ", " << y[i][j] << std::endl;
                    if (v[ x[i][j]-1 ] != y[i][j])
                    {
                        flag = false;
                        break;
                    }
                }
            }
        }
        
        // 成立すれば格納
        if (flag == true)
        {
            if (ans < cnt) ans = cnt;
        }
    }
    else
    {
        std::vector<bool> v_t = v;
        v_t.push_back(true);
        std::vector<bool> v_f = v;
        v_f.push_back(false);

        rec(v_t, ind+1);
        rec(v_f, ind+1);
    }
}

int main ()
{
    // 入力
    std::cin >> N;
    A = std::vector<int>(N);
    x = std::vector<std::vector<int>>(N);
    y = std::vector<std::vector<int>>(N);

    for(int i = 0; i < N; i++)
    {
        int tgt_x;
        int tgt_y;
        std::cin >> A[i];

        for (int j = 0; j < A[i]; j++)
        {
            std::cin >> tgt_x >> tgt_y;
            x[i].push_back(tgt_x);
            y[i].push_back(tgt_y);
        }
    }

    // 問題を解く
    std::vector<bool> v;
    rec(v, 0);

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;
/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

int main(){
  ll A,B;
  cin >> A >> B;
  auto odd = [](ll a){
    return (a+1)/2 % 2;
  };
  auto sol = [&](ll a){
    if(a%2 == 1) return odd(a);
    else return odd(a+1) ^ (a+1);
  };
  cout << (sol(B) ^ sol(A-1)) << endl;
}

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

long long solve(){
    long long a=0, b=0, c=0, d=0, p1=0, p2=0, p3=0, p4=0, p=0;

    cin >> a >> b >> c >> d;

    p1 = a*c;
    p2 = a*d;
    p3 = b*c;
    p4 = b*d;

    p = max(max(p1, p2), max(p3, p4));

    return p;
}

int main(){

    cout << solve() << "\n";

    return 0;
}



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

int H, W;
vector<vector<char>> grid(2000, vector<char>(2000));
vector<vector<int>> yoko(2000, vector<int>(2000, 0));
vector<vector<int>> tate(2000, vector<int>(2000, 0));

int x(int i, int j) {
  if (grid[i][j] == '#') return 0;
  if (yoko[i][j] != 0) return yoko[i][j];
  if (j == W - 1) return 1;
  
  int a = j + 1;
  while (grid[i][a] == '.') {
    ++a;
    if (a >= W) break;
  }
  for (int X = j; X < a; ++X) {
    yoko[i][X] = a - j;
  }
  return yoko[i][j];
}

int y(int i, int j) {
  if (grid[i][j] == '#') return 0;
  if (tate[i][j] != 0) return tate[i][j];
  if (i == H - 1) return 1;
  
  int a = i + 1;
  while (grid[a][j] == '.') {
    ++a;
    if (a >= H) break;
  }
  for (int Y = i; Y < a; ++Y) {
    tate[Y][j] = a - i;
  }
  return tate[i][j];
}

int main() {
  cin >> H >> W;
  for (int i = 0; i < H; ++i) for (int j = 0; j < W; ++j) cin >> grid[i][j];
  
  vector<vector<int>> lamp(H, vector<int>(W));
  for (int i = 0; i < H; ++i) for (int j = 0; j < W; ++j) {
    lamp[i][j] = x(i, j) + y(i, j);
  }
  
  int MAX = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      MAX = max(MAX, lamp[i][j]);
    }
  }
  
  cout << MAX - 1 << endl;
  return 0;
}

Measured memory_bytes: 51328
from scipy.sparse import*
f=csgraph.floyd_warshall
def main():
  n,m,l,*t=map(int,open(0).read().split())
  d=[[0]*(n+1)for _ in range(n+1)]
  for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c
  d=f(f(d,0)<=l)-1
  d[d>n]=-1
  d=d.astype('U')
  print('\n'.join(d[i]for i in zip(*[iter(t[m*3+1:])]*2)))
main()

Measured memory_bytes: 41796
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n, k;
	long long ans;
	
	cin >> n >> k;
	
	ans = k;
	
	for(int i = 1; i < n; i ++){
		ans *= (k-1);
	}
	
	cout << ans;	
	
	return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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() {
    ll X, Y; cin >> X >> Y;

    vector<ll> A;
    while(X <= Y) {
        A.emplace_back(X);
        X *= 2;
    }
    cout << A.size() << endl;
}

Measured memory_bytes: 3612
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

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

    int A[n] = {};

    int a, b;
    REP(i, m){
        cin >> a >> b;
        A[a - 1]++;
        A[b - 1]++;
    }
    REP(i, n) cout << A[i] << endl;

    return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	//var a = parseInt(input[0], 10);
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
	
	
	if(a>=b*2){c=a-b*2;
	           console.log(c);}
	else{console.log('0'); }
	  

	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        char[] c = {'#', '.'};

        Scanner sc = new Scanner(System.in);
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0) {
                break;
            }

            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    System.out.print(c[(i + j) & 1]);
                }
                System.out.println("");
            }
            System.out.println("");
        }

    }

}


Measured memory_bytes: 39404
#include<bits/stdc++.h>
using namespace std;
    int n, m, ans, temp1, temp2, temp3;
    int h[1510], w[1510];
    int cnth[1510000], cntw[1510000];
int main(){

    while(true){

        ans = 0;
         memset(cnth, 0, sizeof(cnth));
         memset(cntw, 0, sizeof(cntw));

        cin >> n >> m;
        if(!n && !m)
            break;
        for(int i = 0; i < n; i++){
            scanf("%d", h + i);
        }
        for(int i = 0; i < m; i++){
            scanf("%d", w + i);
        }
        temp1 = 0;
        for(int i = 0; i < n; i++){
            temp1 += h[i];
            cnth[temp1]++;
            temp2 = temp1;
            for(int j = i + 1; j < n; j++){
                temp2 += h[j] - h[j - i - 1];
                cnth[temp2]++;
            }
        }
        temp3 = 0;
        for(int i = 0; i < m; i++){
            temp3 += w[i];
            cntw[temp3]++;
            temp2 = temp3;
            for(int j = i + 1; j < m; j++){
                temp2 += w[j] - w[j - i - 1];
                cntw[temp2]++;
            }
        }
        for(int i = 1; i <= min(temp1, temp3); i++){
            ans += cnth[i] * cntw[i];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 14952
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

constexpr int mod = 1000000007;

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

  int n, W;
  cin >> n >> W;
  vector<int> w(n + 1, 0);
  vector<ll> v(n + 1, 0);
  rep(i, n) cin >> w[i+1] >> v[i+1];
  int v_max = 1000 * n;

  vector<vector<ll>> dp(n+1, vector<ll>(v_max + 1, INFLL));

  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= v_max; j++) {
      if (j-v[i] >= 0) dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]);
      else dp[i][j] = dp[i-1][j];
    }
  }

  int ans = 0;
  for (int i = 0; i <= v_max; i++) {
    if (dp[n][i] <= W) chmax(ans, i);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 83164
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long x;
    cin >> x;

    long p = 100;
    int y = 0;
    while (p < x)
    {
        p *= 1.01;
        y++;
    }

    cout << y << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <ctype.h>
 
int main(void) {
     
    char c;
     
    for(;;){    
         
        scanf("%c",&c);
        if (0x61 <= c && c<= 0x7a) 
            printf("%c",c-0x20);
        else if (0x41 <= c && c<= 0x5a)
            printf("%c",c+0x20);
        else if (c == '\n') 
            break;
        else
            printf("%c",c);
    }
     
    printf("\n");
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
using namespace std;
int main() {
    int n,t;
    cin>>n>>t;
    int l=1000000;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(b<=t && a<l) l=a;
    }
    if(l==1000000) cout<<"TLE";
    else
    cout<<l;
}


Measured memory_bytes: 256