akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bitset>
#include<algorithm>
#include<vector>
#include<cstdio>
#define MAX 50001
using namespace std;
struct Query
{
  int A,B,order;
  Query(int A=-1,int B=-1,int order=-1):A(A),B(B),order(order){}
};
int r,c,q;
bool used[2][MAX];

int main()
{
  while(true)
    {
      scanf("%d %d %d",&r,&c,&q);
      if(r+c+q == 0)break;
      for(int i=0;i<MAX;i++)used[0][i] = false;
      for(int j=0;j<MAX;j++)used[1][j] = false;
      Query queries[q];
      for(int i=0;i<q;i++)
	scanf("%d %d %d",&queries[q-(i+1)].A,&queries[q-(i+1)].B,&queries[q-(i+1)].order);
	
      int ru,rd,cu,cd,total;
      ru = rd = cu = cd = total = 0;

      for(int i=0;i<q;i++)
	{
	  Query qw = queries[i];
	  if(used[qw.A][qw.B])continue;
	  used[qw.A][qw.B] = true;

	  if(qw.order)
	    {
	      if(!qw.A)
		{
		  total += c - (ru+rd);
		  cu++;
		}
	      else 
		{
		  total += r - (cu+cd);
		  ru++;
		}
	    }
	  else
	    {
	      if(!qw.A)
		  cd++;
	      else 
		  rd++;
	    }
	}
      cout << total << endl;
    }
  return 0;
}

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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  ll n;
  cin >> n;
  vector<ll> v(n+1);
  cin >> v[0];
  REP(i, n) cin >> v[i+1];

  vector<ll> a(n+1);
  a[0] = v[0];
  FOR(i, 1, n+1) a[i] = min(abs(a[i-1]-v[i]), a[i-1]);

  vector<ll> b(n+2);
  b[n+1] = 1;
  for(ll i=n; i>=1; --i) {
    if(min(abs(b[i+1] - v[i]), b[i+1]) == b[i+1]) {
      b[i] = b[i+1];
    } else {
      b[i] = b[i+1] + v[i];
    }
  }

  // cout << a << endl << b << endl;

  ll q;
  cin >> q;
  REP(test, q) {
    ll p;
    cin >> p;
    if(b[p+1] <= a[p-1]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 14720
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

 int n;
 int cnt [4];
 double dp[330][330][330];

int main(){
    cin >> n;
    rep(i, n){
        int a;
        cin >> a;
        cnt[a]++;
    }
    rep(i, n+1){
        rep(j, n+1){
            rep(k, n+1){
                if (i+j+k == 0) {
                    dp[i][j][k] == 0;
                    continue;
                }
                dp[i][j][k] += (double) n / (i+j+k);
                if (i > 0) dp[i][j][k] += dp[i-1][j+1][k] * i / (i+j+k);
                if (j > 0) dp[i][j][k] += dp[i][j-1][k+1] * j/ (i+j+k);
                if (k > 0) dp[i][j][k] += dp[i][j][k-1] * k / (i+j+k);
            }
        }
    }
    
    cout << fixed << setprecision(10) << dp[cnt[3]][cnt[2]][cnt[1]] << endl;

    return 0;
}


Measured memory_bytes: 238484
#include <iostream>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int T[N + 1];
  for (int i = 1; i <= N; i++)
    cin >> T[i];
  int M;
  cin >> M;
  int P[M], X[M];
  for (int i = 0; i < M; i++)
    cin >> P[i] >> X[i];
  for (int i = 0; i < M; i++)
  {
    int ans = 0;
    for (int j = 1; j <= N; j++)
    {
      if (j == P[i])
        ans += X[i];
      else
        ans += T[j];
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
long long gcd(long long a, long long b) {
  return b != 0 ? gcd(b, a % b) : a;
}
long long lcm(long long a, long long b) {
  return (a / gcd(a, b)) * b;
}
// a x + b y = gcd(a, b)
long long extgcd(long long a, long long b, long long &x, long long &y) {
  long long g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
int main(void){
    ll n;scanf("%lld",&n);
    vector<ll> a(n);
    for(int i = 0;i < n;i++)scanf("%lld",&a[i]);

    ll ans = 1LL;
    for(int i = 0;i < n;i++){
        ans = lcm(ans,a[i]);
    }

    cout << ans << endl;
}


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

using namespace std;

int main(){

	string s;
	cin >> s;
	int cnt=0;
	long long ans=0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='B')
			cnt++;
		else
			ans+=cnt;
	}
	cout << ans;
}

Measured memory_bytes: 640
#include <cstdio>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
//#pragma warning(disable:4996)

using namespace std;


int main(void) {

	int N, X, tmp, min = 100000;
	int result;
	int sum = 0;

	cin >> N;
	cin >> X;

	result = N;

	while (N){
		cin >> tmp;
		X -= tmp;
		if (min > tmp)
			min = tmp;
		N--;
	}

	result += X / min;

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main() {

	int n, t;
	int c = 0;
	int v[100000];
	cin >> n >> t;
	if (t % 2 == 1)t = (t - 1) / 2;
	else t = t / 2;

	rep(i, n) {
		cin >> v[i];
	}

	int d = 0;
	int minv = v[0];
	int maxv = v[0];

	for (int i = 0; i < n; i++) {
		minv = min(v[i], minv);
		if (d < v[i] - minv) {
			c = 1;
			d = v[i] - minv;
		}
		else if (d == v[i] - minv) {
			c++;
		}
	}

	cout << c << endl;

	return 0;
}


Measured memory_bytes: 640
/* long long or int & the MAX_INT or MIN_INT */
/* the size of a[] & inline */
/* xx 396 */

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAX_N=3e2+10;
const ll INF=1e17+10;

ll dist[MAX_N][MAX_N],L;
int dp[MAX_N],ans[MAX_N][MAX_N],N,M,cases;
vector <pair<int,int> > g[MAX_N];
priority_queue <pair<int,ll> > Q;

void dijk(int st){
	while(!Q.empty()) Q.pop();
	for(int i=0;i<MAX_N;i++) dist[st][i]=INF;
	dist[st][st]=0ll; Q.push(make_pair(-dist[st][st],st));
	while(!Q.empty()){
		int at=Q.top().second; ll lenth=-Q.top().first; Q.pop();
		if(dist[st][at]<lenth) continue;
		for(int i=0;i<g[at].size();i++){
			int to=g[at][i].first; ll cost=g[at][i].second;
			if(dist[st][at]+cost<dist[st][to]){
				dist[st][to]=dist[st][at]+cost;
				Q.push(make_pair(-dist[st][to],to));
			}
		}
	}
}

void get_dp(int st){
	while(!Q.empty()) Q.pop();
	for(int i=0;i<MAX_N;i++) dp[i]=ans[st][i]=MAX_N;
	dp[st]=0; Q.push(make_pair(-dp[st],st)); ans[st][st]=0;
	while(!Q.empty()){
		int at=Q.top().second,t=-Q.top().first; Q.pop();
		if(dp[at]<t) continue;
		for(int to=0;to<N;to++) if(L>=dist[at][to]&&dp[to]>dp[at]+1){
			ans[st][to]=dp[at]; dp[to]=dp[at]+1;
			Q.push(make_pair(-dp[to],to));
		}
	}
}

signed main(){
	scanf("%d%d%d",&N,&M,&L);
	for(int i=0;i<M;i++){
		int a,b,c; scanf("%d%d%d",&a,&b,&c); a--; b--;
		g[a].push_back(make_pair(b,c));
		g[b].push_back(make_pair(a,c));
	}
	for(int i=0;i<N;i++) dijk(i);
	for(int i=0;i<N;i++) get_dp(i);
	scanf("%d",&cases);
	while(cases--){
		int s,t; scanf("%d%d",&s,&t); s--; t--;
		if(ans[s][t]==MAX_N) printf("%d\n",-1);
		else printf("%d\n",ans[s][t]);
	}
	return 0;
}


Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;
    int[] as;

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

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
        }
        solve();
    }

    void solve() {
        long[] sums = new long[n];
        sums[0] = as[0];
        for (int i = 1; i < n; i++) {
            sums[i] = sums[i - 1] + as[i];
        }
        long evenCount = 0;
        long evenChange = 0;
        long[] sumsForEven = sums.clone();
        for (int i = 0; i < n; i++) {
            sumsForEven[i] += evenChange;
            if (i % 2 == 0 && sumsForEven[i] <= 0) {
                evenCount += -sumsForEven[i] + 1;
                evenChange += -sumsForEven[i] + 1;
                sumsForEven[i] = 1;
            } else if (i % 2 == 1 && sumsForEven[i] >= 0) {
                evenCount += sumsForEven[i] + 1;
                evenChange -= sumsForEven[i] + 1;
                sumsForEven[i] = -1;
            }
        }
        long oddCount = 0;
        long oddChange = 0;
        for (int i = 0; i < n; i++) {
            sums[i] += oddChange;
            if (i % 2 == 1 && sums[i] <= 0) {
                oddCount += -sums[i] + 1;
                oddChange += -sums[i] + 1;
                sums[i] = 1;
            } else if (i % 2 == 0 && sums[i] >= 0) {
                oddCount += sums[i] + 1;
                oddChange -= sums[i] + 1;
                sums[i] = -1;
            }
        }
        System.out.println(Math.min(evenCount, oddCount));
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

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

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 38252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define ld long double
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
const int N=200005;
int a[N],q[N],top,A[N];
ll f[N],g[N];
int cmp(ll a,ll b,int c){
	if(a>b){
		while(a>b){b<<=2; c+=2;}
		return c;
	}else{
		while(a<=b){a<<=2; c-=2;}
		return c+2;
	}
}
int main(){
	int n=read();
	for(int i=1;i<=n;i++)a[i]=read(); q[0]=n+1;
	ll dq=0;
	for(int i=n;i;i--){
		int t=0;
		while(top){
			int jb=cmp(a[q[top]-1],a[q[top]],t);
			if(jb>0){
				dq+=(ll)jb*(q[top-1]-q[top]); t=jb+A[top]; top--;
			}else break;
		}
		q[++top]=i; 
		A[top]=t;
		f[i]=dq;
	}
	dq=top=q[0]=0;
	for(int i=1;i<=n;i++){
		int t=0;
		a[i]*=2;
		while(top){
			int jb=cmp(a[q[top]+1],a[q[top]],t);
			if(jb>0){
				dq+=(ll)jb*(q[top]-q[top-1]); t=jb+A[top]; top--;
			}else break;
		}
		q[++top]=i; 
		A[top]=t;
		g[i]=dq;
		//cout<<g[i]<<" fjzzq "<<f[i]<<endl;
	}
	ll ans=1e18;
	for(int i=0;i<=n;i++){
		ans=min(ans,g[i]+f[i+1]+i);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

int calci(vec &v, int x){
    int i0 = -1, i1 = SZ(v) - 1;
    while(i1 - i0 > 1){
        int i = (i0 + i1) / 2;
        if(v[i] < x) i1 = i;
        else i0 = i;
    }
    return i1;
}

signed main(){

    int N; cin >> N;
    vec A(N); cin >> A;

    vec v;
    REP(i, N){
        if(SZ(v) == 0) v.pb(A[i]);
        else{
            if(v.back() >= A[i]) v.pb(A[i]);
            else v[calci(v, A[i])] = A[i];
        }
    }
    Out(SZ(v));

    return 0;
}


Measured memory_bytes: 2168
import Control.Monad
import qualified Data.IntMap as IM

main = do
  li <- getLine
  let n = read li
  li <- getLine
  let as = map read $ words li
  let ans = compute n as
  mapM_ print ans

compute :: Int -> [Int] -> [Int]
compute n as = [ sum1 - v + 1 | a <- as, let v = arr IM.! a ]
  where
    arr = IM.fromListWith (+) [(a,1)|a <- as]
    sum1 = sum [ n * pred n | n <- IM.elems arr ] `div` 2

{-
値をキーとして、その値の要素がいくつあるかを配列に納めておき、
それぞれの個数について n(n-1)/2 を求める。
ただし a_i については一つ減らす必要がある。
n(n-1)/2 - (n-1)(n-2)/2 = n-1
-}


Measured memory_bytes: 92540
#include<bits/stdc++.h>
using namespace std;
int res,lst[26],ans[26];
int main()
{
	res=1e9+7;
	string s;
	cin>>s;
	int n=s.size();
	s=" "+s;
	for(int i=0;i<26;i++)ans[i]=-1;
	for(int i=1;i<=n;i++)
	{
		int t=s[i]-'a';
		ans[t]=max(ans[t],i-lst[t]-1);
		lst[t]=i;
	}
	for(int i=0;i<26;i++)if(ans[i]!=-1)res=min(res,ans[i]=max(ans[i],n-lst[i]));
	cout<<res<<endl;
	return 0;
}

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

using namespace std;

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  long long MOD = 1e9+7;
  int h, w; cin >> h >> w;
  string grid[h];
  for(int i = 0; i<h; ++i) {
    cin >> grid[i];
  }

  long long dp[h][w];
  for(int i = 0; i<h; ++i) {
    for(int j = 0; j<w; ++j) {
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  for(int i = 0; i<h; ++i) {
    for(int j = 0; j<w; ++j) {
      if(grid[i][j] == '#') continue;
      if(i != 0) dp[i][j] += dp[i-1][j];
      if(j != 0) dp[i][j] += dp[i][j-1];
      dp[i][j] = dp[i][j] % MOD;
    }
  }
  cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 9088
#include<stdio.h>
#define N 10000
int A[2000001],C[N],B[2000001];
int main()
{
  int i,n;
  
  scanf("%d",&n);
  for(i=1;i<n+1;i++){
    scanf("%d",&A[i]);
  }
 
  for(i=0;i<N;i++){
    C[i]=0;
  }
  for(i=1;i<n+1;i++){
    C[A[i]]+=1;
  }
  for(i=0;i<N;i++){
    C[i]+=C[i-1];
  }
  for(i=n+1;i>0;i--){
    B[C[A[i]]]=A[i];
    C[A[i]]-=1;
  }
 
  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d",B[i]);
  printf("\n");
  return 0;
}

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

int main() {
  int N, K, V[55];
  cin >> N >> K;
  rep(i, N) cin >> V[i];

  int ans = 0;

  for (int L = 0; L <= min(K, N); L++) {
    for (int R = 0; R <= min(K-L, N-L); R++) {

      if (L+R == 0) continue;

      vector<int> tmp;
      rep(i, L) tmp.push_back(V[i]);
      int idx = N - 1;
      rep(i, R) {
        tmp.push_back(V[idx]);
        idx--;
      }

      sort(tmp.begin(), tmp.end());
      reverse(tmp.begin(), tmp.end());
      int cnt = L + R - 1;
      int del = K - (L + R);
      while(tmp[cnt] < 0 && del > 0) {
        tmp.pop_back();
        cnt--;
        del--;
      }

      int tmp_ans = accumulate(tmp.begin(), tmp.end(), 0);
      ans = max(ans, tmp_ans);
    }
  }

  cout << ans << endl;


  return 0;

}

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

#define ll long long
#define rep(i, l, r) for (int i = l; i <= r; ++ i)

using namespace std;

inline int read()
{
	int cnt = 0; bool opt = false; char ch = getchar();
	
	for (; ! isdigit(ch); ch = getchar())
		if (ch == '-') opt = true;
	for (; isdigit(ch); ch = getchar())
		cnt = (cnt << 3) + (cnt << 1) + (ch ^ 48);
		
	return opt ? -cnt : cnt;
}


int main()
{
	long double a, b, n;
	
	cin >> a >> b >> n;
	
	n = min(n, b - 1);
	cout << (floor(a / b * n) - a * floor(n / b))  << endl;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c=getchar();int t=0,f=1;
	while((!isdigit(c))&&(c!=EOF)){if(c=='-')f=-1;c=getchar();}
	while((isdigit(c))&&(c!=EOF)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int a,b,c;
signed main(){
	a=read(),b=read(),c=read();
	swap(a,b);swap(a,c);
	printf("%d %d %d\n",a,b,c);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
struct NODE {
	int x; int y;
}flag[100005];
 
int a[305][305], c[100005];
 
int main()
{
	int h, w, d, q;
	scanf("%d %d %d", &h, &w, &d);
	for(int i = 1; i <= h; i++)
		for(int j = 1; j <= w; j++)
		{
			scanf("%d", &a[i][j]);
			flag[a[i][j]].x = i;
			flag[a[i][j]].y = j;
		}
	int pp = h * w;
	int tt = pp / d;
	for(int i = 1; i <= d; i++)
	{
		int qwe = i;
		while(qwe <= pp)
		{
			qwe += d;
			if(qwe > pp) break;
			c[qwe] = abs(flag[qwe].x - flag[qwe - d].x) + abs(flag[qwe].y - flag[qwe - d].y) + c[qwe - d];
		}
	}
	scanf("%d", &q);
	for(int i = 1; i <= q; i++)
	{
		int l, r;
		scanf("%d %d", &l, &r);
		int p = c[r] - c[l];
		printf("%d\n", p);
	}
}

Measured memory_bytes: 2432
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>

#include<thread>

using namespace std;

using ll = long long;


int main()
{
	int N;
	ll C;

	
	ll x[100002];
	ll v[100002];
	
	cin >> N >> C;

	for (int i = 1; i <= N; i++)
	{
		cin >> x[i] >> v[i];
	}

	ll dpL[100002] = { 0 };
	ll dpR[100002] = { 0 };

	ll eat = 0;

	for (int i = 1; i <= N; ++i)
	{
		eat += v[i];
		ll s = eat - x[i];

		if (dpL[i - 1] < s)
		{
			dpL[i] = s;
		}
		else
		{
			dpL[i] = dpL[i - 1];
		}
	}

	eat = 0;

	for (int i = N; i > 0; --i)
	{
		eat += v[i];
		ll s = eat - (C - x[i]);
		
		if (dpR[i + 1] < s)
		{
			dpR[i] = s;
		}
		else
		{
			dpR[i] = dpR[i + 1];
		}
	}

	ll ans = 0;

	for (int i = 1; i <= N; ++i)
	{
		if (ans < dpL[i]) { ans = dpL[i]; }

		ll s = dpL[i] - x[i] + dpR[i + 1];

		if (ans < s) { ans = s; }
	}

	for (int i = N; i > 0; --i)
	{
		if (ans < dpR[i]) { ans = dpR[i]; }

		ll s = dpR[i] - (C - x[i]) + dpL[i - 1];
		
		if (ans < s) { ans = s; }
	}

	cout << ans << endl;

	return 0;
	
}

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

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int sum = 0;
  for (int i=0; i <= n; ++i) {
    int sumOfDigits = findSumOfDigits(i);
    if (sumOfDigits >= a && sumOfDigits <=b) {
      sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
using VP = vector<P>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int inf = 1e9;
constexpr int mod = 1e9+7;
ll gcd(ll a, ll b) { return b? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

V ab[200010];
V ret;

void dfs(ll v, ll p = -1) {
    for (ll u : ab[v]) {
        if (u == p) continue;
        ret[u] += ret[v];
        dfs(u, v);
    }
}

int main() {
    ll n, q;
    cin >> n >> q;

    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        --a, --b;
        ab[a].pb(b);
        ab[b].pb(a);
    }

    ret.resize(n);

    rep(i, q) {
        ll p, x;
        cin >> p >> x;
        --p;
        ret[p] += x;
    }

    dfs(0);

    rep(i, n) cout << ret[i] << endl; 

    return 0;
}


Measured memory_bytes: 24320
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		int N = Integer.parseInt(scanner.nextLine()); //total
		boolean flg = false;
		loop:for(int a=0; a<=25; a++){
			for(int b=0; b<=14; b++){
				if((4*a + 7*b) == N){
					flg = true;
					System.out.println("Yes");
					break loop;
				}
			}
		}
		if(!flg) System.out.println("No");
	}
}

Measured memory_bytes: 23764
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
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;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H,W;
    cin >> H >> W;
    bool seen[H][W][25];
    ll d[H][W];
    rep(i,H){
        rep(j,W){
            rep(k,25)
            seen[i][j][k]=false;
            d[i][j]=INF;
        }
    }
    int ch,cw,dh,dw;
    cin >> ch >> cw >> dh >> dw;
    ch--;cw--;dh--;dw--;
    deque<P> que;
    que.push_front({ch,cw});
    vvc s(H,vc(W));
    rep(i,H){
        rep(j,W){
            cin >> s[i][j];
        }
    }
    d[ch][cw]=0;
    while(!que.empty()){
        P p=que.front();
        que.pop_front();
        ll x=p.first,y=p.second;
        FOR(dx,-2,3){
            FOR(dy,-2,3){
                int nx=x+dx,ny=y+dy;
                if(!(0<=nx&&nx<H&&0<=ny&&ny<W&&s[nx][ny]=='.')){
                    continue;
                }
                if(dx==0&&dy==0){
                    continue;
                }
                if(seen[nx][ny][(dx+2)+5*(dy+2)])continue;
                if(abs(dx)+abs(dy)==1){
                    que.push_front({nx,ny});
                    chmin(d[nx][ny],d[x][y]);
                }
                else{
                    que.push_back({nx,ny});
                    chmin(d[nx][ny],d[x][y]+1);
                }
                seen[nx][ny][(dx+2)+5*(dy+2)]=true;
            }
        }
    }
    cout << (d[dh][dw]==INF?-1:d[dh][dw]) << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 38384
#include <iostream>

using namespace std;

int main(){
    int x,y;
    cin >> x >> y;
    if(x < y) { 
        int temp = x;
        x = y;
        y = temp;
    }
    int G = y;
    while(G != 1){
        int reminder = x % y;
        x = y;
        y = reminder;
        if(y == 0){
            G = x;
            break;
        }
        G = y;
    }
    cout << G << endl;
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  ll n;
  cin>>n;
  ll a=1; ll b=1; ll c=1;
  rep(i,n){
    a*=10;
    a=a%MOD;
  }  //a=10^n mod 10^9+7
  rep(i,n){
    b*=9;
    b=b%MOD;
  }  //b=9^n mod 10^9+7
  rep(i,n){
    c*=8;
    c=c%MOD;
  } //c=8^n mod 10^9+7
  ll ans=(a-2*b+c)%MOD;
  if (ans < 0) ans+=MOD;
  cout<<ans; //10^9-9^n-9^n+8^n 
return 0;
}


Measured memory_bytes: 3572
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <cstring>
#include <bits/stdc++.h>
#include <iostream>
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define enterarray(a,n) for(int i=0;i<(int)(n);++i)cin>>a[i];
#define ins insert
const int MOD =998244353;
const int MX = int(2e6+9);
using namespace std;
ll f[200004];
int even(ll num){
    if(num%2==0)return 1;
    else return 0;
}
ll gcd(ll x,ll y){
    for(ll i=min(x,y);i>=1;i--){
        if(x%i==0&&y%i==0)return i;
    }
}
void printvector(vector<int> v){
    int i;
    for0(i,v.size())cout<<v[i]<<" ";
}
void solve(){
    ll n,m,i,j,k;
    ll a[200005],b[200005];
    ll ans=0,res=0;
    bool flag=true;
    vector<ll> v;
    string s1,s2;
    set<ll> s;
    cin>>s1;
    n=s1.size();
    if(s1[n-1]=='s')s1+="es";
    else s1+='s';
    cout<<s1;
}
 
int main()
{
    FAST;
   int t;
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

    

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define pb  push_back
#define mod 1000000007
#define INF 1e18
typedef  long long ll;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s;
	cin>>s;
	int maxi=0,curr=0;
	for (int i = 0; i < s.length(); ++i)
	{
		if(s[i]=='R')
			curr++;
		else
			curr=0;
		maxi=max(maxi,curr);
	}
	cout<<maxi;
	return 0;
}

Measured memory_bytes: 3648
// Think twice, Code once
// 1SAC
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
	FIO
	
	int a,b;cin >> a >> b;
	if(a > b){
		forn(i, a)cout << b;
	}
	else forn(i, b)cout << a;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int max = a/4+2;
        int flag = 0;
        int total = 0;

      
      for(int i = 0;i<max;i++){
       for(int j =0;j<max;j++){
         total = i*4+j*7;
         if(total==a){flag = 1;break;}
       }
      }
		if(flag==1){
          System.out.print("Yes");
        }else{
          System.out.print("No");
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  long long sum = 0;
  for(int i=0; i<N; i++){
    if((i+1)%3 != 0 && (i+1)%5 !=0){
      sum += (i+1);
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3632
x_1,y_1,x_2,y_2=tuple(map(int,input().split()))

be=[x_2-x_1,y_2-y_1]
za3=[x_2+(-1)*be[1],y_2+be[0]]
za4=[x_1+(-1)*be[1],y_1+be[0]]

print(za3[0],za3[1],za4[0],za4[1])

Measured memory_bytes: 3060
use std::io::*;

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let x: u64 = itr.next().unwrap().parse().unwrap();
    println!("{}", 360 / gcd(360, x));
}


Measured memory_bytes: 2092
/* ****Tciitb**** */
                     
#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          int long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll ,ll >
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;



int main() {
  io
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k%2==0)
  {
     if(a-b>1e18)
      cout<<"Unfair";
    else
      cout<<(a-b);
     
  }
  else
  {
     if(b-a>1e18)
      cout<<"Unfair";
    else
      cout<<(b-a);

  }
  }
  

  


  




Measured memory_bytes: 256
/*

RFL <3
The Feeling of Happiness

"In dreams begin responsibility"

*/


#include<bits/stdc++.h>

using namespace std;

#define sf scanf
#define pf printf
#define ll long long
#define fr(I,M,N) for(I=M;I<=N;I++)
#define fr_(I,M,N) for(I=M;I>=N;I--)
#define re return
#define sfn cin>>n
#define bal pf("bal\n")
#define pb push_back
#define ins insert
#define sz(X) X.size()
#define xx first
#define yy second
#define skip continue
#define memo(X,N) memset(X,N,sizeof(X))
#define all(X) X.begin(),X.end()
#define mp make_pair
#define pi acos(-1)


/*
#define nMX 5000000
#define pMX 500000
int pr[pMX+1],prnum[nMX+1];

int sieve()
{
    int i,j;
    for(i=1;i<=nMX;i++)
        prnum[i]=i+1;
    for(i=1;i<=nMX;i++)
        if(prnum[i]!=-1)
            for(j=2*prnum[i]-1;j<=nMX;j+=prnum[i])
                    prnum[j]=-1;
    j=0;
    for(i=1;i<=nMX;i++)
        if(prnum[i]!=-1)
            pr[++j]=prnum[i];
    re j;
}*/

/*ll m_ncr[10001][10001];
ll ncr(ll i,ll j)
{
    if(j==1) re i;
    if(i==j) re 1;
    if(m_ncr[i][j]!=-1) re m_ncr[i][j];
    re m_ncr[i][j]=ncr(i-1,j) + ncr(i-1,j-1);
}*/

/*ll m_fact[21];
ll fact(ll i)
{
    if(i==1 || i==0) re 1;
    if(m_fact[i]!=-1) re m_fact[i];
    re m_fact[i]=i*fact(i-1);
}*/


/*#define MX 200005
ll int arr[MX];
ll int tree[MX * 3];
void init(ll int node, ll int b, ll int e)
{
    if (b == e) {
        tree[node] = arr[b];
        return;
    }
    ll int Left = node * 2;
    ll int Right = node * 2 + 1;
    ll int mid = (b + e) / 2;
    init(Left, b, mid);
    init(Right, mid + 1, e);
    tree[node] = max(tree[Left], tree[Right]);
}
ll int query(ll int node, ll int b, ll int e, ll int i, ll int j)
{
    if (i > e || j < b)
        return -1e6;
    if (b >= i && e <= j)
        return tree[node];
    ll int Left = node * 2;
    ll int Right = node * 2 + 1;
    ll int mid = (b + e) / 2;
    ll int p1 = query(Left, b, mid, i, j);
    ll int p2 = query(Right, mid + 1, e, i, j);
    return max(p1, p2);
}
void updateRange(ll int node, ll int start, ll int endd, ll int l, ll int r, ll int val)
{
    // out of range
    if (start > endd or start > r or endd < l)
        return;

    // Current node is a leaf node
    if (start == endd)
    {
        // Add the difference to current node
        tree[node] += val;
        return;
    }

    // If not a leaf node, recur for children.
    ll int mid = (start + endd) / 2;
    updateRange(node*2, start, mid, l, r, val);
    updateRange(node*2 + 1, mid + 1, endd, l, r, val);

    // Use the result of children calls to update this node
    tree[node] = tree[node*2] + tree[node*2+1];
}*/


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll int i,j,x,y,n,m,cnt=0,k,g,flg,t;
    string s;
    cin>>s;
    n=sz(s);
    s="o"+s;
    k=1;
    x=y=0;
    fr(i,1,n)
    {
        if(s[i]-'0'!=k) x++;
        k++;
        k%=2;
    }
    k=0;
    fr(i,1,n)
    {
        if(s[i]-'0'!=k) y++;
        k++;
        k%=2;
    }
    cout<<min(x,y);
}


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

int main(){
    int N; cin >> N;
    vector<int> P, Q, A;
    for(int i = 0; i < N; i++){
        int x; cin >> x; P.push_back(x);
    }
    for(int i = 0; i < N; i++){
        int x; cin >> x; Q.push_back(x);
    }
    for(int i = 1; i <= N; i++) A.push_back(i);
    int cntP = 0;
    int cntQ = 0;
    int ansP, ansQ;

    do{
        //for(int i = 0; i < N; i++) cout << A[i] << " "; cout << endl;
        bool flag = true;
        for(int i = 0; i < N; i++){
            if(P[i] != A[i]){
                flag = false;
                break;
            }
        }
        if(flag) { ansP = cntP; break;}
        cntP++;
    } while( next_permutation(A.begin(), A.end()) );
    sort(A.begin(), A.end());

    do{
        //for(int i = 0; i < N; i++) cout << A[i] << " "; cout << endl;
        bool flag = true;
        for(int i = 0; i < N; i++){
            if(Q[i] != A[i]){
                flag = false;
                break;
            }
        }
        if(flag) { ansQ = cntQ; break;}
        cntQ++;
    } while( next_permutation(A.begin(), A.end()) );
    int ans = ansP - ansQ;
    if(ans < 0) ans *= -1;
    cout << ans << endl;
    //cout << ansP << " " << ansQ << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a;i<(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1000000;
const char ENDL = '\n';

ll N, A[MAX];

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

	cin >> N;
	rep(i, N)
		cin >> A[i];
	sort(A, A + N);

	ll judge = A[0], sub = 1, n = 0;
	rep1(i, N) {
		if (judge == A[i])
			sub += 1;
		else if (sub % 2 != 0) {
			n++;
			judge = A[i];
			sub = 1;
		}
		else {
			judge = A[i];
			sub = 1;
		}			
	}
	if (sub % 2 != 0)
		n++;

	cout << n << ENDL;
	return 0;
}

Measured memory_bytes: 1024
def dis(a, b):
    return np.sqrt((a[0]-b[0])*(a[0]-b[0]) + (a[1]-b[1])*(a[1]-b[1]))
import itertools
import numpy as np
n = int(input())
coor = []
for _ in range(n):
    x, y = map(int, input().split())
    coor.append([x,y])

permutations_lis = itertools.permutations(range(n))# 全ての場合のリストを生成
dis_list = []
for case in permutations_lis:
    dis_sum = 0
    for i in range(n-1):
        dis_sum += dis(coor[case[i]], coor[case[i+1]])
    dis_list.append(dis_sum)

print(np.mean(dis_list))
    

Measured memory_bytes: 14264
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (int)1e5 + 10;

int n, m, dp[N];
VI topo, child[N];
bool vis[N];

void dfs(int v) {
  vis[v] = true;
  for (int x: child[v])
    if (!vis[x])
      dfs(x);
  topo.PB(v);
}

int main() {
  init_ios();
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    child[x].PB(y);
  }
  for (int i = 1; i <= n; ++i)
    if (!vis[i])
      dfs(i);
  reverse(topo.begin(), topo.end());
  while (topo.size()) {
    int v = topo.back();
    topo.pop_back();
    for (int x: child[v])
      dp[v] = max(dp[v], 1+dp[x]);
  }
  int res = 0;
  for (int i = 1; i <= n; ++i)
    res = max(res, dp[i]);
  cout<<res<<"\n";
}

Measured memory_bytes: 7672
h,w = map(int,input().split())
m = []

for i in range(h):
    m.append(list(input()))


#行に着目
dl = []

for i in range(h):
    if all(j =='.' for j in m[i]):
        dl.append(int(i))
# print(dl)
if dl:
    for i in dl:
        del m[i-dl.index(i)]
h = len(m)
# print(m)

dl = []
for i in range(w):
    s = ''
    for j in range(h):
        s = s + m[j][i]
    if all(j == '.' for j in list(s)):
        dl.append(int(i))
# print(dl)
if dl:
    for i in range(h):
        for j in dl:
            del m[i][j-dl.index(j)]

# print(m)
for i in range(h):
    print(''.join(m[i]))

#転置して同様
# m = list(zip(*m)) 
# if m:
#     dl = []
#     for i in range(w):
#         if all(j =='.' for j in m[i]):
#             dl.append(int(i))

#     if dl:
#         for i in range(len(dl)):
#             del m[dl[len(dl)-i-1]]
            


# #転置して元に戻す
# m = list(zip(*m))


# #出力
# for i in range(len(m)):
#     m[i] = ''.join(m[i])
#     print(m[i])

Measured memory_bytes: 3188
import java.io.*;
class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br
		= new BufferedReader(new InputStreamReader(System.in));
		while(true){

			String buf;
			if((buf=br.readLine())==null)break;
			if(buf.length()==0)break;
			String[] buf2=buf.split(" ");
			double[] data=new double[buf2.length];
			for(int i=0;i<data.length;i++){
				data[i]=Double.parseDouble(buf2[i]);
			}
			boolean bool=true;
			if(bool){
				if(suppose(data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7])){
					System.out.println("YES");
				}else{
					System.out.println("NO");
					bool=false;
				}
			}
		}
	}
	private static boolean suppose(double x1,double y1,double x2,double y2,double x3,double y3,double xp,double yp){
		double ABxAP=( (x2-x1)*(yp-y1) ) - ( (y2-y1)*(xp-x1) );
		if(ABxAP<0.0001 && ABxAP>-0.0001)ABxAP=0;
		double BCxBP=( (x3-x2)*(yp-y2) ) - ( (y3-y2)*(xp-x2) );
		if(BCxBP<0.0001 && BCxBP>-0.0001)ABxAP=0;

		double CAxCP=( (x1-x3)*(yp-y3) ) - ( (y1-y3)*(xp-x3) );
		if(CAxCP<0.0001 && CAxCP>-0.0001)ABxAP=0;

		if((ABxAP>0 && BCxBP>0 && CAxCP>0)|| (ABxAP<0 && BCxBP<0 && CAxCP<0))
			return true;
		return false;
	}
}

Measured memory_bytes: 9752
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;


//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int p = 1; p < N; p++) cout << ", " << v[p]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
	


int main() {
	int rank[14] = { 0, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
	int A, B;
	cin >> A >> B;
	if (rank[A] < rank[B]) cout << "Bob";
	else if (rank[A] > rank[B]) cout << "Alice";
	else cout << "Draw";
	cout << endl;

	return 0;
}


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

int main(){
  vector<int> time(5);
  for(int i = 0; i < 5; i++){
    cin >> time[i];
  }
  vector<int> amari(5);

  for(int i = 0; i < 5; i++){
    amari[i] = time[i] % 10; 
  }
  int sum = 0;
  int M = 10;
  for(int i = 0; i < 5; i++){
    if(amari[i] == 0){
      sum += time[i];
    }
    else{
      M = min(M,amari[i]);
      sum += (time[i] + (10 - amari[i]));
    }
  }
  sum -= (10 - M);
  cout << sum << endl;
  
  
  
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $x, $y);
$a = abs(abs($x) - abs($y));
$b = 0;
if ($x * $y > 0) {
	if ($x > $y) $b = 2;
} elseif ($x * $y == 0) {
	if ($x > $y) $b = 1;
} else {
	$b = 1;
}
echo $a + $b;

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

int main(){
  int n;
  int m;
  vector<int> cards;
  int k;
  vector<int> A;
  vector<int> B;
  
  cin>>n;
  
  for(int i=1;i<=2*n;++i)
    cards.push_back(i);
  
  cin>>m;
  
  for(int i=0;i<m;++i){
    cin>>k;
    if(k==0){
      for(int i=0;i<n;++i)
	A.push_back(cards[i]);
      for(int i=n;i<2*n;++i)
	B.push_back(cards[i]);
      cards.clear();
      for(int i=0;i<n;++i){
	cards.push_back(A[i]);
	cards.push_back(B[i]);
      }
      A.clear();
      B.clear();
    }
    else{
      for(int i=0;i<k;++i)
	A.push_back(cards[i]);
      for(int i=k;i<2*n;++i)
	B.push_back(cards[i]);
      cards.clear();
      for(auto p:B)
	cards.push_back(p);
      for(auto q:A)
	cards.push_back(q);
      A.clear();
      B.clear();
    }
  }
  for(auto i:cards)
    cout<<i<<endl;
}
  

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

using namespace std;

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

typedef long long ll;

const ll inf=1000000000000000;

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll n,x;
  cin >> n >> x;
  vector<ll> a(n),b(n);
  rep(i,0,n){
   cin >> a[i];
   b[i]=a[i];
  }
  ll res=inf;
  
  rep(k,0,n){
    ll sum=k*x;
   rep(i,0,n) {
     sum+=b[i];
     b[i]=min(b[i],a[(i-(k+1)+n)%n]);
   }
    res=min(res,sum);
    }
  cout << res << endl;
}

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

int main() {
string s;
cin>>s;
int bnum=0,wnum=0;
int N=s.size();
for(int i=0;i<N;i++){
  if(s[i]=='W') wnum++;
  if(s[i]=='B') bnum++;
}
if(wnum==N||bnum==N){
  cout<<0<<endl;
  return 0;
}
wnum=0;
long ans=0;
for(int i=0;i<N;i++){
  if(s[i]=='W'){
    ans += i-wnum;
    wnum++;
  }
}
cout<<ans<<endl;
}


Measured memory_bytes: 640
N = int(input())
list = list(map(int,input().split()))

mas_num = 1
satisfy_num = 0

for i in list:
  if (mas_num % 2) != 0:
    if  (i % 2) != 0:
      satisfy_num += 1
  mas_num += 1

print(satisfy_num)

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	ll q,h,s,d;
	cin >> q >> h >> s >> d;

	ll n;
	cin >> n;

	ll one = min(4*q,min(2*h,s));
	ll two = min(2*one,d);

	cout << ((n/2)*two + (n%2)*one) << endl;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt(), M = sc.nextInt(), res = 0;
        int[] f = new int[N + 1],degree = new int[N + 1];
        ArrayList[] edges = new ArrayList[N + 1];
        Deque<Integer> q = new ArrayDeque<>();
        for(int i = 0; i <= N; i ++)edges[i] = new ArrayList<Integer>();
        for(int i = 1; i <= M; i ++){
            int v = sc.nextInt(), u = sc.nextInt();
            edges[v].add(u);
            degree[u] ++;
        }
        for(int i = 1; i <= N; i ++)if(degree[i] == 0)q.offer(i);
        while(!q.isEmpty()){
            int cur = q.poll();
            for(Object end : edges[cur]){
                Integer e = (Integer)end;
                f[e] = Math.max(f[cur] + 1,f[e]);
                res = Math.max(res,f[e]);
                degree[e] --;
                if(degree[e] == 0)q.offer(e);
            }
        }

//        f[u] = Math.max(f[u],f[v] + 1);
//        res = Math.max(res,f[u]);
//        for(int i = 1 ; i <= N; i ++) System.out.print(f[i] + " ");
        System.out.println(res);
    }
}

Measured memory_bytes: 102208
#include <stdio.h>
int main(void){
    // Your code here!

    int n = 100;
    scanf("%d",&n);

    int a[n];
    for(int i=0; i<n; i++){
      scanf("%d",&a[i]);
    }
    for(int i=1; i<n; i++){
      printf("%d ",a[n-i]);
    }
    printf("%d\n",a[0]);

}



Measured memory_bytes: 1968
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>

using namespace std;

int main() {
    size_t N;
    scanf("%zu", &N);

    vector<size_t> p(N);
    for (size_t i=0; i<N; ++i) {
        scanf("%zu", &p[i]);
        --p[i];
    }

    vector<size_t> B(N);
    for (size_t i=0; i<N; ++i) {
        printf("%zd%c", N*i+1, i<N-1? ' ':'\n');
        B[N-i-1] = N*i + 1;
    }

    for (size_t i=0; i<N; ++i)
        B[p[i]] += i;

    for (size_t i=0; i<N; ++i)
        fprintf(stderr, "%zd%c", B[i]+N*i+1, i<N-1? ' ':'\n'),
        printf("%zd%c", B[i], i<N-1? ' ':'\n');

    return 0;
}


Measured memory_bytes: 1024