akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful
#define var auto
#define MOD 1000000007


typedef long long ll;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;


int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    int w, s; cin>>s>>w;
    cout<<(w>=s?"unsafe":"safe");
	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9+5;
int main()
{
int n;cin>>n;
vector<int> h(n);
for(int &x : h)
scanf("%d",&x);
vector<int> dp(n,INF);
dp[0]=0;
for(int i=0;i<n;i++)
{
	for(int j=i+1;j<=i+2;j++)
	{
		dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]));
	}
}
printf("%d",dp[n-1]);
return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bytes"
	"fmt"
)

const s = "ACL"

func main() {
	var a int
	var buffer bytes.Buffer
	fmt.Scan(&a)
	for i := 0; i < a; i++ {
		buffer.WriteString(s)
	}
	fmt.Println(buffer.String())
}


Measured memory_bytes: 1836
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a[5];
	for(int i=0;i<5;i++){
		cin >> a[i];
		if(a[i]==0){
			printf("%d\n",i+1 );
		}
	}
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long z;
	cin>>z;
	long long ar[z];
	for(int i=0;i<z;i++){
		cin>>ar[i];
	}
	sort(ar,ar+z);
	cout<<ar[z/2]-ar[(z-1)/2]<<endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int H,A;
    cin >> H >> A;
    if((H%A)==0){
        pr(H/A);
    }else{
        pr(H/A+1);
    }
}

Measured memory_bytes: 256
k, x = map(int,input().split())

res = []

for i in range(k):
  Pi = x + i
  Ni = x - i
  if Pi == Ni:
    res.append(Pi)
  elif Pi > 1000000:
    res.insert(0,Ni)
  elif abs(Ni) > 1000000:
    res.append(Pi)
  else:
    res.append(Pi)
    res.insert(0,Ni)


r = [str(i) for i in res]
result = ' '.join(r)
print(result)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,pair<int,int>> iii;
typedef vector<pair<int,int>> vii;
typedef vector<vector<int>> vvi;

#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main (void) {
    ios_base::sync_with_stdio(false);

    int a,b,c,x,y;
    int ans = 1e9;

    cin >> a >> b >> c >> x >> y;

    ans = min(ans, a*x+b*y);
    if (x < y) {
        ans = min(ans, 2*c*x+(y-x)*b);
        ans = min(ans, 2*c*y);
    } else {
        ans = min(ans, 2*c*y+(x-y)*a);
        ans = min(ans, 2*c*x);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //   cin >> t;
    while (t--)
    {
        int a, b;
        cin >> a >> b;
        int ans = -1;
        for (int i = 1; i <= 1000; ++i)
        {
            int x = i * 8;
            x /= 100;
            int y = i * 10;
            y /= 100;
            if (x == a && y == b)
            {
                ans = i;
                goto ll;
            }
        }

    ll:
        cout << ans << "\n";
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
const int N = 50, INF = 50 * 3;
int mem[N+1][N+1][N+1];
int opt(int a, int b, int c) {
    int& ans = mem[a][b][c];
    if(ans == -1) {
        if(a == 0 and b == 0 and c == 0) {
            ans = 0;
        } else {
            ans = INF;
            if(a >= 1) ans = min(ans, 1 + opt(a - 1, b, c));
            if(b >= 1) ans = min(ans, 1 + opt(a, b - 1, c));
            if(c >= 1) ans = min(ans, 1 + opt(a, b, c - 1));
            if(a >= 2 and b >= 2) ans = min(ans, 1 + opt(a - 2, b - 2, c));
            if(b >= 2 and c >= 2) ans = min(ans, 1 + opt(a, b - 2, c - 2));
            if(c >= 2 and a >= 2) ans = min(ans, 1 + opt(a - 2, b, c - 2));
            if(a == b and b == c) ans = 0;
        }
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    memset(mem, -1, sizeof mem);
    cout << opt(a, b, c) << endl;
    return 0;
}


Measured memory_bytes: 4064
MOD = 10 ** 9 + 7

n, k = map(int, input().split())

divisor_lst = [i - 1 for i in range(1, k + 1)]
divisor_lst[0] = 1

for i in range(2, k):
    for j in range(2 * i, k + 1, i):
        divisor_lst[j - 1] -= divisor_lst[i - 1]

ans = 0
for num in range(1, k + 1):
    ans += pow(k // num, n, MOD) * divisor_lst[num - 1]
    ans %= MOD
print(ans)

Measured memory_bytes: 12860
// ITP1_4_D:   Min, Max and Sum
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int n;
	int d, min, max;
	long long sum;

	scanf("%d%d", &n, &d);
	sum = min = max = d;
	while (--n > 0) {
		scanf("%d", &d);
		if (d < min) min = d;
		if (d > max) max = d;
		sum += d;
	}
	printf("%d %d %lld\n", min, max, sum);
	return 0;
}

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

using LLI = long long int;
using Pair = pair<LLI, LLI>;

LLI a, b;
LLI m;
bool is_composite[114514];
vector<LLI> primes;

int main() {
  is_composite[1] = true;
  for (int i=2; i<=100000; i++) {
    if (!is_composite[i]) {
      primes.emplace_back(i);
      for (int j=i+i; j<=100000; j+=i) {
        is_composite[j] = true;
      }
    }
  }

  while (1) {
    scanf("%lld%lld%lld", &m, &a, &b);
    if (m == 0 && a == 0 && b == 0) return 0;

    LLI maxd = -1;
    Pair ans;
    for (int i=0; i<primes.size(); i++) {
      LLI p = primes[i];
      int low = i-1;
      int high = primes.size();
      while (high - low > 1) {
        int mid = (low+high)/2;
        LLI q = primes[mid];
        if (p*q <= m && a*q <= p*b) low = mid;
        else high = mid;
      }

      if (low == i-1) continue;
      LLI q = primes[low];
      if (maxd < p*q) {
        maxd = p*q;
        ans = Pair(p, q);
      }
    }
    printf("%lld %lld\n", ans.first, ans.second);
  } 
}

Measured memory_bytes: 3416
n,x=map(int,input().split())
A=list(map(int,input().split()))

cnt=0
for i in range(n-1):
    point=A[i]+A[i+1]
    cnt +=max(0,point-x)
    if point>x:A[i+1]=max(0,A[i+1]-(point-x))

print(cnt)

Measured memory_bytes: 63984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b); for(ll i=(a); i<=ll(b); i++) 
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
const ll MOD = 1e9+7;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}
//int:~2e9   小数:double



int main(){
  ll h;
  cin >>h;
  ll ans=0;
  ll n=1;
  while(h>0){
    h /= 2;
    ans+=n;
    n*=2;
  }

  cout<<ans<<endl;
  return 0;
}


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

struct TXY{
    int t;
    int x;
    int y;
};

int distance(const struct TXY& lhs, const struct TXY& rhs){
    int dx = abs(lhs.x - rhs.x);
    int dy = abs(lhs.y - rhs.y);
    return dx + dy;
}

int main(){
    int N; cin >> N; N++;
    vector<struct TXY> vecTxy(N);
    vecTxy[0].t = 0;
    vecTxy[0].x = 0;
    vecTxy[0].y = 0;
    for(int i=1; i<vecTxy.size(); ++i){
        cin >> vecTxy[i].t;
        cin >> vecTxy[i].x;
        cin >> vecTxy[i].y;
    }
    
    for(int i=1; i<vecTxy.size(); ++i){
        int t = vecTxy[i].t - vecTxy[i-1].t;
        int d = distance(vecTxy[i-1], vecTxy[i]);
        if(t%d!=0){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    
    return 0;
}

Measured memory_bytes: 1408
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC optimize(2)
#include<cstring>
#include<cstdio>
#include<queue>
#define Re register int
using namespace std;
const int N=1e5+5,M=4e5+5,inf=2e9;
int x,y,z,n,m,o,op,dis[N],vis[N],pan[N],head[N];
struct QAQ{int w,to,next;}a[M];queue<int>Q;
inline void add(Re x,Re y,Re z){a[++o].to=y,a[o].w=z,a[o].next=head[x],head[x]=o;}
inline void in(Re &x){
	Re fu=0;x=0;char ch=getchar();
	while(ch<'0'||ch>'9')fu|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	x=fu?-x:x;
}
inline int SPFA(Re st){
	dis[st]=0,pan[st]=1,Q.push(st);
	while(!Q.empty()){
		x=Q.front(),Q.pop();pan[x]=0,vis[x]=1;
		for(Re i=head[x],to;i;i=a[i].next)
			if(dis[to=a[i].to]==inf){
				dis[to]=dis[x]+a[i].w;
				if(!pan[to])pan[to]=1,Q.push(to);
			}
			else if(dis[to]!=dis[x]+a[i].w)return 1;
	}
	return 0;
}
int main(){
	in(n),in(m);
	for(Re i=0;i<=n;++i)dis[i]=inf;
	while(m--)in(x),in(y),in(z),add(x,y,z),add(y,x,-z);//a[y]-a[x]==z: a[y]-a[x]>=z且a[x]-a[y]>=-z 
	for(Re i=1;i<=n;++i)
		if(!vis[i])if(SPFA(i))return !puts("No");
	puts("Yes");
}

Measured memory_bytes: 6912
n = int(input())
h = [int(i) for i in input().split()]
h[0] -= 1
if len(h) == 1:
    print('Yes')
else:
    for i in range(1, n):
        if h[i - 1] < h[i]:
            h[i] -= 1
        elif h[i - 1] > h[i]:
            print('No')
            exit()
    print('Yes')


Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

typedef pair<ll, ll> P;
vec d;
struct edge {
    ll to, cost;
};
vector<vector<edge>> G;

void dijkstra (ll s, ll V) {
    priority_queue<P, vector<P>, greater<P>> que;
    d.assign(V, inf);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;
        for (edge e : G[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

vec ans;
ll N;
vec a;
stack<tuple<ll, ll, ll>> history;

void dfs (ll from, ll v, vec &tmp) {
    auto itr = lower_bound(tmp.begin(), tmp.end(), a[v]);
    history.push({itr - tmp.begin(), *itr, a[v]});
    // cout << "push:" << itr-tmp.begin() << " " << *itr << " " << a[v] << "\n";
    *itr = a[v];
    ans[v] = lower_bound(tmp.begin(), tmp.end(), inf) - tmp.begin();        

    // cout << "v:" << v << "\n";
    // Rep (i, N) {
    //     cout << tmp[i] << " \n"[i==N-1];
    // }
    for (auto nv : G[v]) {
        if (ans[nv.to] != -1) continue;
        dfs (v, nv.to, tmp);
    }

    auto e = history.top();
    history.pop();
    tmp[get<0>(e)] = get<1>(e);
    
    // cout << "kaeri v:" << v << "\n";
    // Rep (i, N) {
    //     cout << tmp[i] << " \n"[i==N-1];
    // }

}

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

    cin >> N;
    a.assign(N, 0);
    Rep (i, N) {
        cin >> a[i];
    }

    G.assign(N, vector<edge>());
    ans.assign(N, -1);

    Rep (i, N-1) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back({v, 1});
        G[v].push_back({u, 1});
    }

    vec tmp(N, inf);
    // tmp[0] = a[0];
    ans[0] = 1;
    dfs(-1, 0, tmp);

    Rep (i, N) {
        cout << ans[i] << "\n";
    }
}

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

int main() {
	string A, B;
  	cin >> A >> B;
  	
  	if(A.size() > B.size()){
      cout << "GREATER" << endl;
      return 0;
    }
  	else if(A.size() < B.size()){
      cout << "LESS" << endl;
      return 0;
    }
  
   for(int i = 0; i < A.size(); i++){
     if(A.at(i) > B.at(i)){
        cout << "GREATER" << endl;
      	return 0;
     }
     else if(A.at(i) < B.at(i)){
        cout << "LESS" << endl;
      	return 0;
     }
     else continue;
   }
  
  cout << "EQUAL" << endl;
  return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
#define MOD 998244353
#define MAX 4000
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
ll dp[MAX][MAX][3]={};
signed main(){
  init_io();
  ll n,s;
  cin >> n >> s;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  dp[0][0][0]=1;
  for(int i=0;i<n;i++){
    for(int j=0;j<=s;j++){
      dp[i+1][j][0] += dp[i][j][0]%MOD;
      dp[i+1][j][0] %=MOD;

      dp[i+1][j][1] += dp[i][j][0]+dp[i][j][1];
      dp[i+1][j][1] %= MOD;

      dp[i+1][j][2] += (dp[i][j][0]+dp[i][j][1]+dp[i][j][2])%MOD;
      dp[i+1][j][2] %= MOD;

      if(j>=a[i]){
        ll v = (dp[i][j-a[i]][0]+dp[i][j-a[i]][1])%MOD;
        dp[i+1][j][1] += v;
        dp[i+1][j][1] %= MOD;

        dp[i+1][j][2] += v;
        dp[i+1][j][2] %= MOD;
      }
    }
  }
  cout << dp[n][s][2]<<endl;
}


Measured memory_bytes: 282368
#include <iostream>
#include <set>
#include <algorithm>
#define int long long
using namespace std;
pair <int,int> a[200005],b[500005];
multiset <int> s;
multiset <int> s2;
int c[500005];
signed main(int argc, char** argv) {
	int n,cnt=0;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i].first >> a[i].second;
		b[++cnt]={a[i].first,i};
		b[++cnt]={a[i].second,i};
		if(a[i].first>a[i].second) swap(a[i].first,a[i].second);
	}
	sort(a+1,a+n+1);
	int mn=2e9,MN=2e9,mx=0,MX=0;
	for(int i=1;i<=n;i++) mn=min(mn,a[i].first);
	for(int i=1;i<=n;i++) MN=min(MN,a[i].second);
	for(int i=1;i<=n;i++) mx=max(mx,a[i].first);
	for(int i=1;i<=n;i++) MX=max(MX,a[i].second);
	int ans=(MX-MN)*(mx-mn);
	sort(b+1,b+cnt+1);
	cnt=0;
	int l=1;
	for(int i=1;i<=n*2;i++)
	{
		if(!c[b[i].second]) ++cnt;
		++c[b[i].second];
		while(cnt==n)
		{
			ans=min(ans,(MX-mn)*(b[i].first-b[l].first));
			--c[b[l].second];
			if(c[b[l].second]==0)
				--cnt;
			++l;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 14592
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,a,b;
	cin>>x>>a>>b;
	if(a>=b){
		cout<<"delicious"<<endl;
	}
	else if(a+x>=b){
		cout<<"safe"<<endl;
	}
	else{
		cout<<"dangerous"<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m;
long long t[100010];
long long p;
struct P
{
    long long x,y;
}a[100010];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>t[i];
    }
    cin>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>a[i].x>>a[i].y;
    }
    for(int i=1;i<=m;i++)
    {
        long long sum=0;
        for(int j=1;j<a[i].x;j++)
        {
            sum+=t[j];
          }
        sum+=a[i].y;
        for(int j=a[i].x+1;j<=n;j++)
        {
            sum+=t[j];
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
/**
    Now you're just somebody that i used to know
**/
#include<bits/stdc++.h>
#define maxN 300005
using namespace std;
priority_queue<int,vector<int>,less<int> > q1;
priority_queue<int,vector<int>,greater<int> > q2;
long long SetSum,dr[maxN],st[maxN],stmax[maxN],drmin[maxN],n,sol;
int v[maxN];
int main()
{
    cin>>n;
    for(int i=1;i<=3*n;i++)
    {
        scanf("%d",&v[i]);
    }
    //
    for(int i=3*n;i>=2*n+1;i--)
    {
        q1.push(v[i]);
        SetSum+=1LL*v[i];
    }

    dr[2*n+1]=SetSum; /**
                            dr[i]-suma minima pe care o putem obtine din n elemente alese din [i,3n]
                        **/
    for(int i=2*n;i>=1;i--)
    {
        if(v[i]<q1.top())
        {
            SetSum-=1LL*q1.top();
            q1.pop();
            q1.push(v[i]);
            SetSum+=1LL*v[i];
            dr[i]=SetSum;
        }
            else dr[i]=dr[i+1];
    }
    //Set.clear();
    SetSum=0;
    for(int i=1;i<=n;i++)
    {
      //  Set.insert(v[i]);
        q2.push(v[i]);
        SetSum+=1LL*v[i];
    }
    st[n]=SetSum;
    for(int i=n+1;i<=3*n;i++)
    {
        if(v[i]>q2.top())
        {
        //    SetSum-=*Set.begin();
            SetSum-=q2.top();
           // Set.erase(Set.begin());
            q2.pop();
         //   Set.insert(v[i]);
            q2.push(v[i]);
            SetSum+=1LL*v[i];
            st[i]=SetSum;
        }
            else st[i]=st[i-1];
    }
    for(int i=1;i<=2*n;i++)
        stmax[i]=max(stmax[i-1],st[i]);
    drmin[2*n+1]=dr[2*n+1];
    for(int i=2*n;i>n;i--)
        drmin[i]=min(drmin[i+1],dr[i]);
    sol=-LLONG_MAX;
    for(int i=n;i<=2*n;i++)
    {
        sol=max(sol,stmax[i]-drmin[i+1]);
    }
    printf("%lld\n",sol);
    return 0;
}


Measured memory_bytes: 10616
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var Xt = ReadSplitInt();
            Println(Max(Xt[0] - Xt[1], 0));
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11220
import Control.Applicative

f :: Int -> Int -> String
f x y
  | x == y    = "Draw"
  | x == 1    = "Alice"
  | y == 1    = "Bob"
  | x > y     = "Alice"
  | x < y     = "Bob"
  | otherwise = "Alice"

main = do
  [a, b]<- map read . words <$> getLine
  putStrLn $ f a b


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
long long n,m,i,j,sum,ans;
string a,b,c;
int main()
{
    cin>>a;
    for(i=0;i<a.size();i++) 
	   b=a[i]+b;
    for(i=0;i<a.size();i++)
    {
        if(a[i]=='b')
          a[i]='d';
    	else
          if(a[i]=='d')
            a[i]='b';
          else
            if(a[i]=='p')
              a[i]='q';
            else 
              if(a[i]=='q')
                a[i]='p';      
    }
    if(a==b)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";
    return 0;
}

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

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;

int n;
int a, t;
vector<int> vec[100003];

int jar[100003][2];
void dfs(int u, int par, int x)
{
	for(int v : vec[u])
	{
		if(v == par) continue;
		jar[v][x] = jar[u][x]+1;
		dfs(v, u, x);
	}
}

int main()
{
	// freopen("input.in", "r", stdin);

	scanf("%d %d %d", &n, &t, &a);
	for(int i = 1; i < n; i++)
	{
		int u, v; scanf("%d %d", &u, &v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	dfs(a, -1, 0);
	dfs(t, -1, 1);
	int mx = 0;
	for(int i = 1; i <= n; i++)
	{
		if(jar[i][0] > jar[i][1]) 
			mx = max(mx, jar[i][0]);
	}
	printf("%d\n", max(mx-1, 0));
}

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

int main(){
    int n,r,pi,i=0,j;
    char p;
    int card[4][13] = {};
    char pattern[4] = {'S','H','C','D'};

    cin >> n;
    for(i=0;i<n;i++){
        cin >> p >> r;
        if(p == 'S'){
            pi = 0;
        }else if(p == 'H'){
            pi = 1;
        }else if(p == 'C'){
            pi = 2;
        }else if(p == 'D'){
            pi = 3;
        }else{
            continue;
        }
        card[pi][r-1] = 1;
    }
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(card[i][j] == 0) cout  << pattern[i] << " " << j + 1 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int n, m, v, p, a[MAXN];
bool check(int pos) {
	int kill = n - p; ll sum = 0;
	for (int i = n; i >= 1 && kill; i--)
		if (i != pos) {
			if (a[pos] - a[i] > m) return false;
			sum += max(a[pos] - a[i], 0), kill--;
		}
	return sum <= 1ll * m * v;
}
int main() {
	read(n), read(m), read(v), read(p), v = n - v;
	for (int i = 1; i <= n; i++)
		read(a[i]), a[i] = 1e9 - a[i];
	sort(a + 1, a + n + 1);
	int l = 1, r = n;
	while (l < r) {
		int mid = (l + r + 1) / 2;
		if (check(mid)) l = mid;
		else r = mid - 1;
	}
	cout << l << endl;
	return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
import bisect

N,Q = (int(x) for x in input().split())

stop_arr = [tuple(map(int, input().split())) for _ in range(N)]
Q_arr = [int(input()) for _ in range(Q)]

stop_arr_ind = list(range(N))
stop_arr_ind.sort(key=lambda x:stop_arr[x][2])

ans_arr = [-1]*Q
skip_arr = [-1]*(Q+1)

def update_skip(skip_arr, x):
    if skip_arr[x] == -1:
        return x
    x_dest = update_skip(skip_arr, skip_arr[x])
    skip_arr[x] = x_dest
    return x_dest

for i in stop_arr_ind:
    s,t,x = stop_arr[i]
    q_start = bisect.bisect_left(Q_arr, s-x)
    q_stop = bisect.bisect_left(Q_arr, t-x)
    l = q_start
    while l < q_stop:
        if skip_arr[l] == -1:
            skip_arr[l] = q_stop
            ans_arr[l] = x
            l += 1
        else:
            l = update_skip(skip_arr, l)

print(*ans_arr, sep="\n")


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

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

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let x = read::<String>();
  let y = read::<String>();
  let x_char: Vec<char> = x.chars().collect();
  let y_char: Vec<char> = y.chars().collect();

  if x_char[0] == y_char[2] && x_char[1] == y_char[1] && x_char[2] == y_char[0] {
    println!("YES");
  } else {
    println!("NO");
  }
}



Measured memory_bytes: 4352
import java.io.*;
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
 
            String[] str = kb.readLine().split( " " );
            int n = Integer.parseInt( str[0] );
            int q = Integer.parseInt( str[1] );
			
			LinkedList<String> ps = new LinkedList<String>();
			LinkedList<Integer> times = new LinkedList<Integer>();
			
            for( int i=0; i<n; i++ ) {
                str = kb.readLine().split( " " );
                ps.offer( str[0] );
                times.offer( Integer.parseInt( str[1] ) );
            }

            StringBuilder output = new	StringBuilder( );	            
            String job;
            int time, t;
            t = 0;
            while( null != ( job = ps.peek() )) {
            	time = times.peek();
            	if( times.peek() <= q ) {
            		output.append( job );
            		output.append( " " );
            		output.append(  t + time );
            		output.append( "\n" );
            		t += time;          		
            	} else {
            		ps.offer( job );
	                times.offer( time - q );
	                t += q;           
            	}
            	ps.poll();
            	times.poll();
            }
            System.out.print( output );
             
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
}

Measured memory_bytes: 64700
ary = []
numbers = []
zyun = []
n = gets.chomp.to_i
n.times do |i|
  tmp = gets.chomp.to_i
  ary << tmp
  numbers[tmp-1] = i
end

(numbers.length-1).times do |j|
  if numbers[j]<numbers[j+1]
    zyun << 1
  else
    zyun << 0
  end
end

# zyunから連続した1の数を数える
max = 0
tmp = 0
zyun.each do |k|
  if k == 1
    tmp+=1
  elsif k == 0
    max = [max,tmp].max
    tmp = 0
  end
end
max = [max,tmp].max

puts(n-max-1)


Measured memory_bytes: 6652
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P_B push_back
#define E_B emplace_back
#define fi first
#define se second

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

int main(){
  string S;
  ll N, ans=0;

  cin >> S;
  N = S.size();

  vector<int> s(N);
  vector<vector<int> > A(2, vector<int> (2019, 0));
  vector<vector<int> > B(2019, vector<int> (10));

  rep(i, N){
    s[i] = S[i] - '0';
  }

  rep(i, 2019){
    rep(j, 10){
      B[i][j] = (i*10 + j) % 2019;
    }
  }

  //A[0].assign(2019, 0);
  A[0][s[0]] = 1;

  rep(i, N-1){
    A[1][s[i+1]] += 1; //'0'があれば if(s[i+1] != 0) が必要
    rep(j, 2019){
      A[1][B[j][s[i+1]]] += A[0][j];
    }
    rep(j,2019){
      A[0][j] = A[1][j];
      A[1][j] = 0;
    }
    ans += A[0][0];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4396
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    vector<string> a(7);
    a={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin >> s;
    rep(i,7){
        if(s==a[i]){
            cout << 7-i;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, k;
    cin >> n >> k;
    int h[n];
    rep(i, 0, n) cin >> h[i];

    vector<int> dp(n + 1000, INF);
    dp[0] = 0;
    rep(i, 1, n) {
        for (int j = 1; j <= k; j++) {
            if (i - j >= 0) {
                dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
            }
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}


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

using namespace std;

void saiki(int now, int damefrom, int dameto, vector<bool> &visited, vector<vector<int>> &edges ){
    visited[now] = true;
    for(auto t: edges[now]){
        if(now == damefrom && t == dameto)
            continue;

        if(visited[t])
            continue;
        saiki(t, damefrom, dameto, visited, edges);
    }
}
int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edges(n);
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    int cnt = 0;
    for(int i=0;i<n;i++){
        for(auto dame: edges[i]){
            vector<bool> visited(n, false);
            saiki(0, i, dame, visited, edges);
            bool flag = false;
            for(int j=0;j<n;j++){
                if(!visited[j]){
                    flag = true;
                    break;
                }
            }
            if(flag)
                cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 5555
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n,m;
ll d[sz];
ll w[sz][sz];
stack<pii>s[sz];

ll a[sz];

int main()
{
	file();
	read(n,m);
	rep(i,2,n) read(d[i]);
	rep(i,1,n) rep(j,1,m) read(w[i][j]);
	rep(i,1,m) s[i].push(MP(n+1,2e9));
	ll ans=-1e18;
	drep(i,n,1)
	{
		a[i+1]-=d[i+1];
		rep(j,1,m) 
		{
			int lst=0;
			while (w[i][j]>s[j].top().sec) a[s[j].top().fir]-=s[j].top().sec-lst,lst=s[j].top().sec,s[j].pop();
			a[s[j].top().fir]-=s[j].top().sec-lst;a[s[j].top().fir]+=s[j].top().sec-w[i][j];
			s[j].push(MP(i,w[i][j]));
			a[i]+=w[i][j];
		}
		ll sum=0;
		rep(j,i,n) sum+=a[j],chkmax(ans,sum);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 223360
#include <iostream>
#include <vector>
using namespace std;
long long gcd(long long x, long long y){
    if(x < y) swap(x, y);
    if(x % y == 0) return y;
    return gcd(y, x % y);
}
int main(){
    long long A, B;
    cin >> A >> B;
    long long g = gcd(A, B);
    cout << A / g * B << endl;
}

Measured memory_bytes: 3564
#include<iostream>
#include<stdlib.h>
#include<cstring>
using namespace std;
int A[20][20];
int B[20];
int main(){
     int N,M,C;
     int sum = 0;
     int counter = 0;
     cin >> N >> M >> C;
     for(int i = 0; i < M; i++){
          cin >> B[i];
     }
     for(int i = 0; i < N; i++){
          sum = 0;
          for(int j = 0; j < M; j++){
               cin >> A[i][j];
               sum += A[i][j] * B[j];
          }
          if(sum + C > 0){
               counter++;
          }
     }

     cout << counter << endl;
     return 0;
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//221
	int a,b;
	string ac,bc;
	cin>>ac>>bc;
	ac+=bc;
	a=stoi(ac);
	b=sqrt(a);
	b*=b;
	if(b==a)cout<<"Yes";
	else cout<<"No";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll mod=1e9+7;
  ll n;
  cin >> n;
  bool used[n+1];
  ll ans=1;
  rep(i,n+1) used[i]=false;
  for(ll i=2; i<=n;i++){    
    if(!used[i]){
      ll t=i;
      ll nt=n;
      ll x=1;
      while(nt/t>0){
	x+=nt/t;
	t*=i;		
      }
      ll ti=i;
      while(ti<=n){
	used[ti]=true;
	ti+=i;
      }
      //      cout << i << " " << x << endl;
      ans=(ans*x)%mod;
    }
    
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {



    int a,b;
    cin >> a >> b;
    
    if(a>b)
        cout << "a > b"  << endl;
    else if(a==b)
        cout << "a == b" << endl;
    else
        cout << "a < b" << endl;

    return 0;
    
}



Measured memory_bytes: 3100
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! flush {
    () => {
        std::io::stdout().flush().unwrap();
    };
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: u64 = sc.cin();
    let m: u64 = sc.cin();
    if 2 * n < m {
        let k = m - 2 * n;
        let a = k / 4;
        // trace!(k, a);
        put!(min!(n + a, (m - 2 * a) / 2));
    } else {
        put!(min!(n, m / 2));
    }
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 4352
x = int(input())
a = [False] * (x + 1)
a[0]=True
for i in range(len(a)):
    if a[i]:
        for j in range(100, 106):
            if i + j > x:
                break
            a[i + j] = True
if a[-1]:
    print(1)
else:
    print(0)

Measured memory_bytes: 3828
while 1:
    x, y = list(map(int,input().split()))
    if x == 0:break

    mx = [1,-1,0,0]
    my = [0,0,1,-1]
    m = []
    for i in range(y):
        m.append(list(input()))
        if '@' in m[-1]:
            sx = m[-1].index('@')
            sy = i
    cnt = 0

    def move(cur_x, cur_y):
        global cnt
        if cur_y >= y or cur_y < 0 or cur_x >= x or cur_x < 0:return
        if m[cur_y][cur_x] == '.' or m[cur_y][cur_x] == '@':
            cnt += 1
            m[cur_y][cur_x] = '0'
            for i in range(4):
                move(cur_x + mx[i],cur_y + my[i])
    move(sx,sy)
    print(cnt)

Measured memory_bytes: 6784
def BC132_E():
    n, m = list(map(int, input().split(' ')))
    e = [[] for _ in range(n)]
    for _ in range(m):
        u, v = list(map(int, input().split(' ')))
        e[u - 1].append(v - 1)
    s, t = list(map(int, input().split(' ')))
    s, t = s - 1, t - 1
    stack, visited = [(s, 0)], set()
    a, b = set(), set()
    while stack:
        i, d = stack.pop(0)
        if i == t: return d
        if i in visited:
            continue
        visited.add(i)
        v = set()
        for j in e[i]:
            if j in a: continue
            a.add(j)
            for k in e[j]:
                if k in b: continue
                b.add(k)
                v.update(e[k])
        if t in v:
            return d + 1
        else:
            stack += [(x, d + 1) for x in list(v)]
    return -1


print(BC132_E())

Measured memory_bytes: 77600
n = int(input())

now = 0
ans = [0] * (n)
CSF = [list(map(int, input().split())) for _ in range(n - 1)]
for i in range(n - 1):
    now = 0
    for j in range(n - i - 1):
        c, s, f = CSF[i + j]
        if now <= s:
            now = s
        else:
            now = f * ((now + f - 1) // f)
        now += c
    ans[i] = now

print("\n".join(map(str, ans)))


Measured memory_bytes: 9200
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int H=Integer.parseInt(sc.next());
int W=Integer.parseInt(sc.next());
char[][] c=new char[H][W];
for(int i=0;i<H;i++){
String s=sc.next();
    for(int j=0;j<W;j++){
    c[i][j]=s.charAt(j);
    }
}
for(int i=0;i<2*H;i++){
    for(int j=0;j<W;j++){
    System.out.print(c[i/2][j]);
    }System.out.println();
}

}}

Measured memory_bytes: 28464
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long ans = 0;
    for(long i = 1;i<=n;i++){
      if(i % 3 != 0 && i % 5 != 0){
        ans += i;
      }
    }
    System.out.println(ans);
  }
}


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

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N;

void prime_factor(int n, map<int, int> &mp)
{
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n != 1) mp[n]++;
}

int num(map<int, int> mp, int num)
{
  int cnt = 0;
  for (auto m : mp) {
    if (m.second >= num - 1) {
      cnt++;
    }
  }
  return cnt;
}

int main(void)
{
  cin >> N;

  map<int, int> mp;
  for (int i = 1; i <= N; i++) {
    prime_factor(i, mp);
  }

  ll ans = (num(mp, 75) + num(mp, 25) * (num(mp, 3) - 1) +
            num(mp, 15) * (num(mp, 5) - 1) +
            num(mp, 5) * (num(mp, 5) - 1) * (num(mp, 3) - 2) / 2);

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 888
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]


N = int(input())
A = [0] + list(map(int, input().split()))


def check(mid, base): # b is max-value
    if mid < base:
        l = imos[mid-1]
        r = imos[base-1] - imos[mid-1]
        return abs(r-l)
    else:
        l = imos[mid] - imos[base-1]
        r = imos[N] - imos[mid]
        return abs(r-l)
        
        

def ternarySearchInt(small, big, i):
    if big - small <= 2:  # 終了条件
        mid = (big + small) // 2
        if check(big, i) <= check(mid, i):
            return big
        else:
            return small if check(small, i) <= check(mid, i) else mid
    else:
        midl = (big + small) // 2
        midr = midl + 1
        if check(midl, i) >= check(midr, i):
            return ternarySearchInt(midl, big, i)
        else:
            return ternarySearchInt(small, midr, i)



imos = [0]*(N+1)
for i in range(1, N+1):
    imos[i] = imos[i-1] + A[i]

ans = int(1e18)
for i in range(3, N):
    l = ternarySearchInt(1, i-1, i)
    r = ternarySearchInt(i, N, i)
    P = imos[l-1]
    Q = imos[i-1] - P
    R = imos[r] - imos[i-1]
    S = imos[N] - imos[r]
    hoge = [P,Q,R,S]
    ans = min(ans, max(hoge) - min(hoge))


print(ans)



Measured memory_bytes: 93432
// AOJ 2069: Greedy, Greedy.
// 2017.11.5 bal4u@uu

#include <stdio.h>
#include <string.h>
#define TM 0
#if TM
#include <time.h>
#endif

int c[52], n;
int dp[2001];

char buf[302], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int greedy(int p)
{
	int i, s = 0;

	i = n; while (i--) {
		if (p == c[i]) { s++; break; }
		if (p < c[i]) continue;
		s += p/c[i];
		p %= c[i];
	}
	return s;
}

int main()
{
	int cno = 0, i, j, k, lim;
#if TM
	clock_t start, end;
	start = clock();
#endif
	while (fgets(p=buf, 300, stdin) && *p != '0') {
		printf("Case #%d: ", ++cno);
		n = getint(), p++;
		c[0] = getint(), p++;
		if (c[0] != 1) { puts("Cannot pay some amount"); continue; }
		if (n <= 2) { puts("OK"); continue; }
		for (i = 1; i < n; i++) c[i] = getint(), p++;
		lim = c[n-1] + c[n-2];

		memset(dp, 0x33, sizeof(dp)), dp[0] = 0;
		for (i = 1; ; i++) {
			if (i == lim) { puts("OK"); break; }
			for (j = 0; j < n; j++) {
				k = i - c[j];
				if (k >= 0 && dp[i] > dp[k]+1) dp[i] = dp[k] + 1;
			}
			if (greedy(i) != dp[i]) { puts("Cannot use greedy algorithm"); break; }
		}
	}
#if TM
	end = clock();
	printf("time %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

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

int main() {
    // 頂点数と辺数
    int N,x,y; cin >>N>> x >> y;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < N-1; ++i) {
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[x-1].push_back(y-1);
    G[y-1].push_back(x-1);

    // BFS のためのデータ構造
    int dist[N][20000]; // 全頂点を「未訪問」に初期化
    for(int i = 0;i<N;i++) for(int j=0;j<20000;j++) dist[i][j]=-1;
    queue<int> que;
    for(int i = 0;i<N;i++){
      // 初期条件 (頂点 0 を初期ノードとする)
      dist[i][i] = 0;
      que.push(i); // 0 を橙色頂点にする

      // BFS 開始 (キューが空になるまで探索を行う)
      while (!que.empty()) {
          int v = que.front(); // キューから先頭頂点を取り出す
          que.pop();

          // v から辿れる頂点をすべて調べる
          for (int nv : G[v]) {
              if (dist[i][nv] != -1) continue; // すでに発見済みの頂点は探索しない

              // 新たな白色頂点 nv について距離情報を更新してキューに追加する
              dist[i][nv] = dist[i][v] + 1;
              que.push(nv);
          }
      }
    }
    int kotae[N];for(int i = 0;i<N;i++) kotae[i] = 0;
    for(int i = 0;i<N;i++){
        for(int j = 0;j<N;j++){
            kotae[dist[i][j]]+=1;
            //cout<<dist[i][j]<<endl;
        }
    }

    for(int i = 1;i<N;i++) cout<<kotae[i]/2<<endl;
    
    
}

Measured memory_bytes: 156672
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll modinv(ll a, ll m) {
    ll x = a, y = m, u = 1, v = 0;
    while (y) {
        ll div = x / y;
        x -= div * y; swap(x, y);
        u -= div * v; swap(u, v);
    }
    return (u % m + m) % m;
}

ll comb(ll n, ll k, ll mod) {
    ll dividend = 1, divisor = 1;
    rep(i, k) {
        dividend = dividend * (n - i) % mod;
        divisor = divisor * modinv(i + 1, mod) % mod;
    }
    return (dividend * divisor) % mod;
}



int main()
{
    ll N, K; cin >> N >> K;
    ll mod = 1e9+7;
    reprr(i, 1, K + 1) {
        cout << comb(N - K + 1, i, mod) * comb(K - 1, i - 1, mod) % mod << endl;
    }
    return 0;
}

Measured memory_bytes: 384