akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N;
	int[] P;
	List<Integer> results = new ArrayList<>();

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		String[] tokens = in.readLine().split(" ");
		P = new int[N];
		for (int i = 0; i < N; ++i) {
			P[i] = Integer.parseInt(tokens[i]);
		}
	}

	void calc() {
		// 先頭は条件を満たす
		results.add(P[0]);
		int prevMin = P[0];
		for (int i = 1; i < N; ++i) {
			if (prevMin >= P[i]) {
				results.add(P[i]);
				prevMin = P[i];
			}
		}
	}

	void showResult() {
		System.out.println(results.size());
	}
}


Measured memory_bytes: 52136
def main():
    N, M = map(int, input().split())
    S = list(map(int, input().split()))
    T = list(map(int, input().split()))

    MOD = 10 ** 9 + 7

    dp0 = [[0] * 2005 for _ in range(2005)]
    dp1 = [[0] * 2005 for _ in range(2005)]

    dp0[0][0] = 1
    for i in range(N + 1):
        for j in range(M + 1):
            dp0[i + 1][j] += dp0[i][j]
            dp1[i][j] += dp0[i][j]
            dp1[i][j] %= MOD
            dp1[i][j + 1] += dp1[i][j]
            if i < N and j < M and S[i] == T[j]:
                dp0[i + 1][j + 1] += dp1[i][j]
            dp1[i][j] %= MOD
            dp0[i + 1][j] %= MOD
            dp1[i][j + 1] %= MOD
            dp0[i + 1][j + 1] %= MOD

    ans = dp1[N][M] % MOD
    print (ans)
    return 

if __name__ == '__main__':
    main()

Measured memory_bytes: 106716
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    int cnt=1;
    while((cnt-1)*cnt/2<n){cnt++;}
    if(cnt*(cnt-1)!=2*n){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    cout << cnt << endl;
    vector<vector<int>> S(cnt,vector<int>());
    int num=1;
    rep(i,cnt){
        repr(j,i+1,cnt){
            S[i].push_back(num);
            S[j].push_back(num);
            num++;
        }
    }
    rep(i,cnt){
        cout << cnt-1 << " ";
        rep(j,cnt-1){
            cout << S[i][j];
            if(j!=cnt-2){
                cout << " ";
            }else{
                cout << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>

#define INF (1<<29)
 
using namespace std;
 
int main(void){
  
  int n,m,p,a,b,x,y,z,in;
  double dp[(1<<8)][31],graph[31][31];
  vector<int>t;
  
  while(cin >> n >> m >> p >> a >> b){
    if(!(n|m|p|a|b))break;
    
    t.clear();
    
    fill(graph[0],graph[31],-1);
    fill(dp[0],dp[(1<<8)],INF);

    for(int i=0;i<31;i++)graph[i][i]=0;
    

    for(int i=0;i<n;i++){
      cin >> in;
      t.push_back(in);
    }
    
    for(int i=0;i<p;i++){
      cin >> x >> y >> z;
      graph[x][y]=graph[y][x]=z;
    }
    
    dp[0][a]=0;
    double res=INF;
    for(int S=0;S<(1<<8);S++){
      res=min(res,dp[S][b]);
      for(int v=1;v<=m;v++){
	for(int i=0;i<n;i++){
	  if(!(S>>i & 1)){
	    for(int u=1;u<=m;u++){
	      if(graph[v][u]>=0){
		dp[S|(1<<i)][u]=min(dp[S|(1<<i)][u],dp[S][v]+graph[v][u]/t[i]);
	      }
	    }
	  }
	}
      }
    }
    if(res==INF)printf("Impossible\n");
    else printf("%.3f\n",res);
  }
  
  return 0;
}

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

string w;

int main (){
  	int flag = 0;
    cin >> w;
 	for (int i=0;i<w.size();i++){
        if ((i+1)%2==0){
        	if (w[i] == 'L' || w[i] == 'U' || w[i] == 'D')
				flag = 1;
          	else {
            	flag = 0;
              	break;
            }
        }
        else if ((i+1)%2!=0){
        	if (w[i] == 'R' || w[i] == 'U' || w[i] == 'D')
				flag = 1;
          	else {
            	flag = 0;
              	break;
            }
        }
    }
  	if (flag == 1) cout << "Yes" << '\n';
  	else cout << "No" << '\n';
    return 0;
}


Measured memory_bytes: 256
N = int(input())
*A, = map(int,input().split())
D = [0]*(N+1)
ans = []
for i in range(N,0,-1):
    if D[i]%2 != A[i-1]:
        ans.append(i)
        for j in range(1,int(i**0.5)+1):
            if i%j==0:
                D[j] += 1
                if i//j != j:D[i//j] += 1
print(len(ans))
print(*ans)

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

int isCat(string& s, int i){
    if(s[i]!='m') return -1;
    i++;
    if(s[i]!='e'){
        i = isCat(s, i);
        if(i==-1 || s[i]!='e') return -1;
    }
    i++;
    if(s[i]!='w'){
        i = isCat(s,i);
        if(i==-1 || s[i]!='w') return -1;
    }
    i++;
    return i;
}

int main(){
    string s;
    cin >> s;
    if(isCat(s, 0) == (int)s.length()){
        cout << "Cat" << endl;
    }else{
        cout << "Rabbit" << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
    int W,H;cin>>W>>H;
    vector<ll> P(W),Q(H),sumP(W+1,0),sumQ(H+1,0);
    for(int i=0;i<W;i++){
        cin>>P[i];
    }
    for(int i=0;i<H;i++){
        cin>>Q[i];
    }
    sort(all(P));
    sort(all(Q));

    for(int i=1;i<W+1;i++){
        sumP[i]=sumP[i-1]+P[i-1];
    }
    for(int i=1;i<H+1;i++){
        sumQ[i]=sumQ[i-1]+Q[i-1];
    }

    ll ans=sumP[W]+sumQ[H];

    for(int i=0;i<W;i++){
        auto it=lower_bound(all(Q),P[i]);
        int a=distance(Q.begin(),it);
        ans+=sumQ[a]+(H-a)*P[i];
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
int main()
{
    int N, arr[3][3];
    for(int i=0; i<3; i++)
    {
        for(int j=0; j<3; j++)
            scanf("%d", &arr[i][j]);
    }
    scanf("%d", &N);
    int no[N];
    for(int i=0; i<N; i++)
        scanf("%d", &no[i]);
    for(int k=0; k<N; k++)
    {
        for(int i=0; i<3; i++)
        {
            for(int j=0; j<3; j++)
            {
                if(no[k]==arr[i][j])
                    arr[i][j]=0;
            }
        }
    }
    if(arr[0][0]==0 && arr[0][1]==0 && arr[0][2]==0)
        printf("Yes");
    else if(arr[1][0]==0 && arr[1][1]==0 && arr[1][2]==0)
        printf("Yes");
    else if(arr[2][0]==0 && arr[2][1]==0 && arr[2][2]==0)
        printf("Yes");
    else if(arr[0][0]==0 && arr[1][1]==0 && arr[2][2]==0)
        printf("Yes");
    else if(arr[0][2]==0 && arr[1][1]==0 && arr[2][0]==0)
        printf("Yes");
    else if(arr[0][0]==0 && arr[1][0]==0 && arr[2][0]==0)
        printf("Yes");
    else if(arr[0][1]==0 && arr[1][1]==0 && arr[2][1]==0)
        printf("Yes");
    else if(arr[0][2]==0 && arr[1][2]==0 && arr[2][2]==0)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

template <typename T> T gcd(T a, T b) {if(b == 0) return a;return gcd(b,a%b);}
template <typename T> T lcm(T a, T b) {return a*b/gcd(a,b);}
template <typename T> T extgcd(T a, T b, T& x, T& y){
    T d = a;
    if(b != 0){
        d = extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }
    else x=1,y=0;
    return d;
}
template <typename T> T modpow(T x, T n, T m) {
    if(n==0) return 1;
    T resp = modpow(x*x%m,n/2,m);
    if(n&1) resp = resp*x%m;
    return resp;
}
template <typename T> T modinverse(T a, T m) {
    T x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
struct combination {
    ll M = mod;
    vector<ll> fact,ifact;
    combination(ll n):fact(n+1),ifact(n+1){
        fact[0]=1;ifact[0]=1;
        for (ll i = 0; i<n; i++) {
            fact[i+1] = fact[i]*(i+1) % M;
            ifact[i+1] = ifact[i]*modpow(i+1, M-2, M) % M;
        }
    }
    ll com(ll a, ll b){
        if(a == 0 && b == 0)return 1;
        if(a < b || a < 0)return 0;
        ll tmp = ifact[a-b] * ifact[b] % M;
        return tmp * fact[a] % M;
    }
};



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

    ll K;
    cin >> K;
    string S;
    cin >> S;
    ll N = ll(S.length());
    
    combination C(2000003);
    ll ans = 0;
    
    for (ll i = 0; i <= K; i++) {
        ll an = 1;
        an *= modpow<ll>(26,i,mod);
        an %= mod;
        an *= C.com(N+K-i-1,N-1);
        an %= mod;
        an *= modpow<ll>(25,K-i,mod);
        an %= mod;
        
        //cout << an << endl;
        
        ans += an;
        ans %= mod;
    }
    
    cout << ans << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 35656
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>

using namespace std;

int main(){
	int d,l;
	int sum=0,temp=0;
	scanf("%d %d",&d,&l);
	while(d>0){
		d-=l;
		sum++;
	}
	if(d<0){
		sum--;
		temp=l+d;
		sum+=temp;
	}
	printf("%d\n",sum);
}


Measured memory_bytes: 2744
/* Ajay Jadhav */
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve()
{
    int x,n;
    cin>>x>>n;
    vi a(1001);
    
    rep(i,0,n)
    {
        int p;
        cin>>p;
        a[p]++;
    } 
    int ans=-1;
    int diff=1e9;
    rep(i,0,1001)
    {
        if(a[i]==0)
        {
            if(abs(x-i)<diff)
            {
                diff=abs(x-i);
                ans=i;
            }
        }
    }
    cout<<ans;
}
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> rnd(n);
    for (int i = 0;i < n;i++){
        cin >> rnd.at(i);
    }
    sort(rnd.begin(),rnd.end());
    int cnt = 1;
    for (int i = 0;i < n - 1;i++){
        if (rnd.at(i) < rnd.at(i+1)){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
int main(){
  string s, t; 
  cin>>s>>t; 
  int cnt=0;
  for(int i=0;i<(int)s.length();i++){
    if(s[i]!=t[i]) cnt++;
  }
  cout<<cnt;
  }

Measured memory_bytes: 3924
#include<bits/stdc++.h>
#define N 100005
using namespace std;
char ans[2005]="011";

int ask(int x,int y){
	if(x==y) return 1;
	cout<<"? "<<x-1<<" "<<y-1<<endl;
	char c[5];cin>>c;
	return c[0]=='Y'? 1:0;
	//return ans[x-1]==ans[y-1];
}
int bcj[N],dis[N],sz[N];//0-same 1-dif
int ff(int x){
	return bcj[x]==x? x:ff(bcj[x]),dis[x]^=dis[bcj[x]],bcj[x]=bcj[bcj[x]];
}
void con(int f,int t,int d){
	if(ff(f)==ff(t)) return;
	d^=dis[f]^dis[t];
	f=bcj[f],t=bcj[t];
	bcj[t]=f;dis[t]^=d;
}
int a,b,n;
int main(){
	/*cin>>ans;
	n=strlen(ans);
	for(int i=0;i<n;i++) if(ans[i]=='1') a++;
	b=n-a;*/
	cin>>a>>b;n=a+b;
	if(b>=a) return cout<<"Impossible"<<endl,0;
	queue<int> q,oth;
	for(int i=1;i<=n;i++) q.push(i),bcj[i]=i,sz[i]=1;
	int x;
	while(q.size()>=2){
		int u=q.front();q.pop();
		int v=q.front();q.pop();
		if(sz[u]!=sz[v]){
			q.push(sz[u]>sz[v]?u:v);
			oth.push(sz[u]>sz[v]?x=v:x=u);
			continue;
		}
		if(ask(u,v)==1&&ask(v,u)==1){
			con(u,v,0);
			q.push(u);
			sz[u]+=sz[v];
		}else{
			oth.push(u),oth.push(v);
		}
	}
	if(q.size()==1) x=q.front();
	while(!oth.empty()){
		int u=oth.front();oth.pop();
		con(x,u,ask(x,u)^1);
	}
	for(int i=1;i<=n;i++) ff(i);
	for(int i=1;i<=n;i++) assert(bcj[i]==bcj[1]);
	
	cout<<"! ";
	for(int i=1;i<=n;i++) cout<<(dis[i]^dis[x]^1);
	cout<<endl;
	return 0;
} 

Measured memory_bytes: 852
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;

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

int main(void){
  int n;
  cin >> n;
  vi t(n), x(n), y(n);
  REP(i, n) cin >> t[i] >> x[i] >> y[i];

  int st = 0, sx = 0, sy = 0;
  int f = 1;
  REP(i, n) {
    int xx = abs(x[i] - sx);
    int yy = abs(y[i] - sy);
    int tt = t[i] - st;

    if(xx + yy > tt) f = 0;
    else if((xx + yy - tt) % 2) f = 0;

    st = t[i];
    sx = x[i];
    sy = y[i];
  }

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


Measured memory_bytes: 1408
// luogu-judger-enable-o2
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<map>
#include<queue>
#define For(i,j,k)	for(int i=j;i<=k;++i)
#define Dow(i,j,k)	for(int i=k;i>=j;--i)
#define ll long long
#define inf 1e9
#define int ll
using namespace std;
inline int read()
{
	int t=0,f=1;char c=getchar();
	while(!isdigit(c))	{if(c=='-')	f=-1;c=getchar();}
	while(isdigit(c))	t=t*10+c-'0',c=getchar();
	return t*f;
}
inline void write(int x){if(x<0){putchar('-');write(-x);return;}if(x>=10)	write(x/10);putchar(x%10+'0');}
inline void writeln(int x){write(x);puts("");}
inline void write_p(int x){write(x);putchar(' ');}
int n,a[1005],b[1005],ans[1005];
bool cmp(int x,int y){return a[x]>a[y];}
inline void out(int beg){
	int cnt=0;
	for (int i=beg;i<=n;i+=2)	b[++cnt]=i;
	sort(b+1,b+cnt+1,cmp);
	int r=1,tot=0;
	while (r<cnt&&a[b[r+1]]>0) r++;
	ll s=0;
	For(i,1,r)	s+=a[b[i]];writeln(s);
	sort(b+1,b+r+1);
	for (int i=r-1;i>0;i--){
		int mid=(b[i]+b[i+1])/2;
		for (;mid>b[i];mid--) ans[++tot]=mid;
	}
	for (int i=1;i<b[1];i++) ans[++tot]=1;
	for (int i=n;i>b[r];i--) ans[++tot]=i-b[r]+1;
	writeln(tot);
	For(i,1,tot) writeln(ans[i]);
}
inline ll calc(int beg){
	if (beg>n) return -1e18;
	int cnt=0;
	for (int i=beg;i<=n;i+=2)
		b[++cnt]=i;
	sort(b+1,b+cnt+1,cmp);
	int r=1;
	for (;r<cnt&&a[b[r+1]]>0;r++);
	ll s=0;
	for (int i=1;i<=r;i++)
		s+=a[b[i]];
	return s;
}
signed main(){
	n=read();
	For(i,1,n)	a[i]=read();
	if (calc(1)>calc(2)) out(1);	else out(2);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();

		System.out.println(f(A-1) ^ f(B));

	}

	public static long f(long A) {
		long n = A/4;
		switch((int)(A%4)) {
		case 0:
			return 4*n;
		case 1:
			return 1;
		case 2:
			return 4*n + 3;
		case 3:
			return 0;
		default:
			return 0;
		}
	}

}


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

int main () {
    int N, res;
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            int M = 4 * i + 7 * j;
            if (M == N) res++;
        }
    }
    if (res > 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <memory>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iomanip>
#include <sstream>  
#include <deque>
#include <unordered_set>
#include <stack>
#include <functional>

using namespace std;


//#define int long long

int calc(int n) {
    int ans = 0;
    while (n) {
        ans += n % 10;
        n /= 10;
    }
    return ans;
}
int tup(int n) {
    int ans = 1234567890;
    for (int i = 1; i <= n - 1; ++i) {
        int j = n - i;
        ans = min(ans, calc(i) + calc(j));
    }
    return ans;
}
int smart(int n) {
    int nn = n;
    while (nn) {
        if (nn % 10 >= 1 && nn != 1) {
            return calc(n);
        }
        nn /= 10;
    }
    return 10;
}
signed main() {
    int n;
    cin >> n;
    cout << smart(n) << endl;

}

Measured memory_bytes: 256
s = list(input())
t = list(input())
ans = len(t)
for i in range(len(s) - len(t) + 1):
    val = len(t)
    for j in range(len(t)):
        if s[i + j] == t[j]:
            val -= 1
    ans = min(ans, val)
print(ans)


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

using namespace std;

int main(){
  int n; cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  int k=0;
  for(int i=0;i<n;i++){
    if(p[i]!=i+1){
      k++;
    }
  }
  if(k==2 || k==0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
      
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>

using namespace std;

int maxflow(vector<vector<int>> E_, vector<vector<int>> F_, int s, int t)
{
    int n = (int)E_.size();

    vector<vector<int>> E(n), F(n), R(n);
    for (int i=0; i<n; i++)
    for (int j=0; j<(int)E_[i].size(); j++)
    {
        int v = E_[i][j];
        R[i].push_back(int(E[v].size()));
        R[v].push_back(int(E[i].size()));
        E[i].push_back(v);
        E[v].push_back(i);
        F[i].push_back(F_[i][j]);
        F[v].push_back(0);
    }
    vector<bool> U(n);
    function<int (int, int)> dfs = [&](int p, int f)
    {
        if (p==t)
            return f;
        U[p] = true;
        for (int i=0; i<(int)E[p].size(); i++)
        if (!U[E[p][i]] && F[p][i]>0)
        {
            int t = dfs(E[p][i], min(f, F[p][i]));
            if (t>0)
            {
                F[p][i] -= t;
                F[E[p][i]][R[p][i]] += t;
                return t;
            }
        }
        return 0;
    };
    
    int flow = 0;
    while (true)
    {
        for (int i=0; i<n; i++)
            U[i] = false;
        int f = dfs(s, 0x7fffffff);
        if (f==0)
            break;
        flow += f;
    }

    return flow;
}

int main()
{
    int H, W;
    cin>>H>>W;
    vector<string> a(H);
    for (string &t: a)
        cin>>t;

    int sx, sy, tx, ty;
    vector<vector<int>> E(H*W*2), F(H*W*2);
    for (int y=0; y<H; y++)
    for (int x=0; x<W; x++)
    if (a[y][x] != '.')
    {
        if (a[y][x] == 'S')
            sx = x, sy = y;
        if (a[y][x] == 'T')
            tx = x, ty = y;
        E[(y*W+x)*2].push_back((y*W+x)*2+1);
        F[(y*W+x)*2].push_back(1);

        for (int tx=0; tx<W; tx++)
        if (tx != x && a[y][tx] != '.')
            E[(y*W+x)*2+1].push_back((y*W+tx)*2),
            F[(y*W+x)*2+1].push_back(W*H);
        for (int ty=0; ty<H; ty++)
        if (ty != y && a[ty][x] != '.')
            E[(y*W+x)*2+1].push_back((ty*W+x)*2),
            F[(y*W+x)*2+1].push_back(W*H);
    }

    if (sx==tx || sy==ty)
        cout<<-1<<endl;
    else
        cout<<maxflow(E, F, (sy*W+sx)*2+1, (ty*W+tx)*2)<<endl;
}


Measured memory_bytes: 106112
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long int ll;

struct fuck{
    int y;
    int p;
    int rank;
};

int main(){
    int N, M;cin >> N >> M;
    vector<vector<pair<int, int>>> a(N);
    vector<fuck> F(M);
    rep(i, M){
        cin >> F[i].p >> F[i].y;
        --F[i].p;
        a[F[i].p].push_back(pair<int, int>(F[i].y, i));
    }
    rep(i, N){
        if(!a[i].empty())
            sort(a[i].begin(), a[i].end());
    }
    rep(i, N){
        if(!a[i].empty()){
            int k = 1;
            for(pair<int, int> j : a[i]){
                F[j.second].rank = k;
                ++k;
            }
        }
    }
    rep(i, M){
        cout << setw(6) << setfill('0') << F[i].p + 1 << setw(6) << setfill('0') << F[i].rank << endl;
    }
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    ll N;
    cin >> N;
    for(ll i = 1; i <= N; i++){
        if(i*(i+1)/2 >= N){
            for(; i > 0; i--){
                if(i <= N){
                    cout << i << "\n";
                    N -= i;
                }
            }
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
abc = sorted(list(map(int,input().split())))
dsta = abc[2]-abc[0]
dstb = abc[2]-abc[1]
if dsta%2 == dstb%2 :
    print((dsta+dstb)//2)
else:
    print(1+(dsta+dstb+1)//2)
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int n;
    cin >> n;
    vector<ll> a(n,0);
    rep(i,n)cin >> a[i];
    ll have = 1000;
    rep(i,n-1){
        ll kabu = 0;
        if (a[i] < a[i + 1]) kabu = have / a[i];
        have += (a[i + 1] - a[i]) * kabu;
    }
    cout << have << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    
    for(int i = 1; i<=n; i++){
        int m = sqrt(i)+1;
        int cnt = 0;
        for(int x = 1; x<= m; x++) {
            for(int y = x; y<=m; y++) {
                for(int z = y; z<=m; z++){
                    int t = x*x+y*y+z*z+x*y+z*y+z*x;
                    if(t == i && x == y && y == z) cnt++;
                    else if(t == i && x == y) cnt += 3;
                    else if(t == i && y == z) cnt += 3;
                    else if(t == i && x != y && y != z) cnt += 6;
                }
            }
        }
        cout << cnt << endl;
    }
    
    
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    string s, t;
    cin >> s;
    rep(i, 0, s.size()){
        if (s.at(i) == '0') t = t + '0';
        if (s.at(i) == '1') t = t + '1';
        if (s.at(i) == 'B'){
            if (t.size() == 0) continue;
            else t = t.erase(t.size() - 1);
        }
    }
    cout << t << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
		}
	if(a>b){
		printf("a > b\n");
		}
	if(a==b){
		printf("a == b\n");
		}
  	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define in1(n) cin>>n;
#define in2(n, k) cin>>n>>k;
#define in3(n, k, s) cin>>n>>k>>s;
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (int i = j; i < k; i += in)
#define rloop(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define inar(n, a) \
    rep(i, n)\
        cin>>a[i];
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)\
{\
return (a.second < b.second);\
}
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast  \
    ios_base::sync_with_stdio(false);\
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

int main()
{
    fast
    int64 n;
    cin>>n;
    vector<int64> v(n);
    inar(n, v)
    vector<int64> sum(n, 0);
    sum[n-1] = v[n-1];
    for(int i = n-2; i>=0; i--) sum[i] = (sum[i+1] + v[i])%MOD;
    int64 ans = 0;
    for(int i = 0; i < n-1; i++) ans += v[i]*sum[i+1]%MOD;
    cout<<ans%MOD;
    return 0;
}

Measured memory_bytes: 6356
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

fn main() {
    input! {
        n: usize,
        d: u64,
        x: u64,
        a: [u64;n],
    }

    let ans = x + a
        .iter()
        .map(|&x| {
            (0..)
                .map(move |n| n * x + 1)
                .take_while(|&t| t <= d)
                .count() as u64
        })
        .sum::<u64>();

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<iostream>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  // ここでストリームに obj を書き込みます。
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}


int main(){
  int a,b; cin >>a >>b;
  print((3*a+b)/2);
}




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

int main()
{

//入力

	int a,b,ans=-1;
	cin >> a>>b;

//処理
	
	for (int i = 0;i < 10010;i++) {
		if (int((double)i * 0.08) == a && int((double)i * 0.1) == b) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;

}

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

#define ll long long
#define fr first
#define se second

using namespace std;

const long long N = 1e9;


int res;
int main()
{
    /// freopen( "input.txt", "r", stdin );
    /// freopen( "output.txt", "w", stdout );
    string s;
    cin >> s;
    if ( s[2] == s[3] and s[4] == s[5] )
        cout << "Yes";
    else
        cout << "No";
}


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

public class Main {
	
	public static long gcd(long x, long y){//only when x>0,y>0
		if(x>y) return gcd(y,x);
		//x<=y
		if(y%x==0) return x;
		else return gcd(x,y%x);
	}
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        long[] a = new long[N];
        long max = 0L;
        for(int i=0;i<N;i++){
        	a[i]=sc.nextLong();
        	if(a[i]>max) max=a[i];
        }
        if(max<K){
        	System.out.println("IMPOSSIBLE");	
        	System.exit(0);
        }
        long min = a[0];
        for(int i=1;i<N;i++){
        	if(min>a[i]) min=a[i];
        	if(min>gcd(min,a[i])) min = gcd(min,a[i]);
        }
        
        if(K%min==0) System.out.println("POSSIBLE");
        else System.out.println("IMPOSSIBLE");
    }
}

Measured memory_bytes: 49812
#include <bits/stdc++.h>
// L - Deque

using namespace std;

int a[3003];
long long dp[3003][3003][2];

int main() {
    int N,i,j,k;

    scanf("%d",&N);

    for (i = 0;i < N;i++) {
        scanf("%d",&a[i]);
        dp[i][i][0] = a[i];
        dp[i][i][1] = a[i];
    }

    for (i = 0;i < N;i++) {
        for (j = 0;(j + i) < N;j++) {
            for (k = 0;k < 2;k++)
                dp[j][j + i][k] = max(a[j + i] - dp[j][j + i - 1][1 - k],a[j] - dp[j + 1][j + i][1 - k]);
        }
    }

    printf("%lld\n",dp[0][N - 1][0]);

    return 0;
}


Measured memory_bytes: 139648
s = input()

# 大文字チェック
count = 0
for c in s:
    if c.isupper():
        count += 1

if count != 2:
    print("WA")
    exit()

if s[0] != "A":
    print("WA")
    exit()

if s[2:len(s) - 1].count("C") != 1:
    print("WA")
    exit()

print("AC")


Measured memory_bytes: 8968
#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; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, t, a;
    cin >> n >> t >> a;
    vector<int> h(n);
    cin >> h;
    auto avetemp = [&](int i) { return t - h[i] * 0.006; };
    int best = 0;
    for(int i = 1; i < n; i++) {
        if(abs(avetemp(i) - a) < abs(avetemp(best) - a)) {
            best = i;
        }
    }
    cout << best + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import product
N = int(input())
strN = str(N)
lenN = len(strN)
num = ['7','5','3']
count = 0
if N < 357:
    print(0)
else:
    for i in range(3,lenN+1):
        for j in product(num,repeat = i):
            num2 = [str(i) for i in j]
            num2 = ''.join(num2)
            if ('7' in num2) and  ('5' in num2) and  ('3' in num2) and int(num2) <= N:
                count += 1
    print(count)

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000007LL
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(i=a;i<=b;i++)

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

ll mypow(ll a, ll b) { if(b == 0) return 1; ll temp=mypow(a,b/2); temp=(temp*temp)%INF; if(b%2 == 1) temp=(a*temp)%INF; return temp; }
int mygcd(int a, int b) { if(b==0) return a; return mygcd(b,a%b); }
int cntBits(ll a) { int ret=0; while(a>0) { ret++; a/=2; } return ret; }

int main()
{
	ios::sync_with_stdio(0);
	int tt=1,tcase; 
	//cin >> tt;
	rep(tcase,1,tt)
	{
		string s; cin >> s;
		int v1=(s[0]-'0')*10 + (s[1]-'0'), v2=(s[2]-'0')*10 + (s[3]-'0');
		if(v1>0 && v1<13)
		{
			if(v2>0 && v2<13) cout << "AMBIGUOUS\n";
			else cout << "MMYY\n";
		}
		else
		{
			if(v2>0 && v2<13) cout << "YYMM\n";
			else cout << "NA\n";
		}

	}
	return 0;
}


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

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

int main(){
    ll a,b;cin >>a>>b;
    vector<bool>ch(3,true);
    a--;b--;
    ch[a]=false;
    ch[b]=false;
    for (int i = 0; i < 3; ++i) {
        if(ch[i])cout <<i+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
N,*B=map(int, open(0).read().split())
res=[]
while B:
    C=[i-b for i,b in enumerate(B,1)]
    if any(c<0 for c in C):
        print(-1)
        break
    D=[i for i,c in enumerate(C) if c==0]
    if D:
        res.append(D[-1]+1)
        B=B[:D[-1]]+B[D[-1]+1:]
    else:
        print(-1)
        break
else:
    print(*res[::-1], sep="\n")

Measured memory_bytes: 3188
N, M = map(int, input().split())
tab = []
for i in range(N):
    tab.append([int(x) for x in input().split()])

set_ = [set(tab[i][1:]) for i in range(N)]
for i in range(N):
    if i==0:
        new_set = set_[i]
    if i == N:
        break
    new_set = new_set & set_[i]

print(len(new_set))
    

Measured memory_bytes: 3060
n,m = map(int, input().split())
ps = [input().split() for i in range(m)]
al = [0] * (n+1)
pe = [0] * (n+1)
ans_a, ans_p = 0,0
for p,s in ps:
  p = int(p)
  if al[p]:
    continue
  if s == "AC":
    al[p] = 1
    ans_p += pe[p]
    ans_a += 1
  else:
    pe[p] += 1
print(ans_a, ans_p)
    

Measured memory_bytes: 33700
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();

    if(N%2 == 0)
      System.out.println(N/2-1);
    else
      System.out.println(N/2);
    }
}


Measured memory_bytes: 23380
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = np.array(read().split(), np.int64).reshape(-1,2)
for x in range(n-1):
    if a[x][0] > a[x][1] :
        a[x][0], a[x][1] = a[x][1], a[x][0]

v = 0
for x in range(n):
    v += (x+1)*(n-x)    # 0-indexed

e = 0
for x in range(n-1):
    e += a[x][0]*(n-a[x][1]+1)  # 1-indexed

print(v-e)


Measured memory_bytes: 52288
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
#include<ctime>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>

using namespace std;
typedef long long ll;
#define MP make_pair

int main(void) {
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;

    if(s==u)a--;
    if(t==u)b--;

    cout<<a<<" "<<b<<"\n";
    
    
    return 0;
}

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

using namespace std;

int main(void) {
  
  string ans = "Yes";
  int N;
  cin >> N;
  
  vector<string> W(N);
  string w1;
  cin >> w1;
  W[0] = w1;
  
  for (int i = 0; i < N-1; i++) {
    string w;
    cin >> w;
    string wp = W[i];
    if (wp[wp.size()-1] != w[0]) {
     ans = "No";
     break;
    } else {
      for (int j = 0; j < W.size(); j++) {
        if (W[j] == w) {
          ans = "No";
          break;
        }
      }
      if (ans == "No") {
        break;
      }
    }
    W[i+1] = w;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
x = [int(input()) for _ in range(5)]

res = []
diff = []
for i in range(5):
    tmp = 0
    if(x[i] % 10 == 0):
        tmp = (x[i] // 10) * 10
    else:
        tmp = (x[i] // 10 + 1) * 10
    res.append(tmp)
    diff.append(tmp - x[i])

print(sum(res) - max(diff))


Measured memory_bytes: 3060
n = int(input())
cnt = [[0] * 10 for i in range(10)]
for i in range(1,n+1):
    cnt[int(str(i)[0])][int(str(i)[-1])] += 1
    
ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    ll d, a;
    cin >> n >> d  >> a;
    vector<P> x(n);
    rep(i, n) {
        cin >> x[i].first >> x[i].second;
    }
    sort(all(x));
    ll ans = 0;
    map<int, ll> mp;
    rep(i, n) {
        mp[x[i].first];
    }
    ll damage = 0;
    for(auto nn:mp) {
        damage += nn.second;
        P now = *(upper_bound(all(x), P(nn.first, LINF))-1);
        int dam = (now.second - damage + a - 1)/a;
        if(dam < 0) dam = 0;
        ans += dam;
        damage += dam*a;
        auto itr = upper_bound(all(x), P(now.first+2*d, LINF));
        if(itr != x.end()) {
            mp[(*itr).first] -= dam*a;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 15872
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数
int n[1000][1000];
int v[1000][1000];

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int n,k;
	scanf("%d%d", &n, &k);

	int ans = n-k+1;
	PRINTD(ans);

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int h = a / 3600;
    int m = (a - h * 3600) / 60;
    int s = a - h * 3600 - m * 60;
    System.out.println(h + ":" + m + ":" + s);
  }
}



Measured memory_bytes: 26376
#include<stdio.h>
#ifdef DEBUG
#include<conio.h>
#endif // DEBUG

int main () {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif // DEBUG

    int num;
    scanf("%d", &num);
    int i = 1;
    while(i <= num) {
        int x = i;
        if(0 == x % 3) { 
            printf(" %d", i);
        } else {
            while(x) {
                if (3 == x % 10) {
                    printf(" %d", i);
                    break;
                } else x /= 10;
            }
        }
        ++i;
    }
    printf("\n");

#ifdef DEBUG
    getch();
#endif // DEBUG
    return 0;
}



Measured memory_bytes: 2128
n, m = map(int, input().split())

Mat = []

for i in range(n):
	row = list(map(int, input().split()))
	Mat.append(row)

b = []

for j in range(m):
	b.append(int(input()))

c = [0 for k in range(n)]

for l in range(n):
	for l2 in range(m):
		c[l] += (Mat[l][l2] * b[l2])
	print(c[l])

Measured memory_bytes: 7988
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,a,b,l=0;
    cin >> k;
    cin >> a>> b;
    for(int i=a; i<=b; i++)
    {
        if(i%k==0)
        {
            l++;
            cout<< "OK"<<endl;
            break;
        }
        else
            continue;
    }
    if(l==0)
        cout<< "NG"<<endl;
}


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

int main() {
    int N;
    cin >> N;
    long long ans = 0;
    long long sum = 0;
    for (int i = 1; i <= N; i++) {
    	for (int j = 1; j <= sqrt(i); j++) {
    		if (i % j == 0) {
    			if (j != i / j) sum += 2;
    			else sum++;
    		}
    	}
    	if (sum == 8 && i % 2 != 0) ans++;
    	sum = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <string>
#include <queue>
#include <math.h>
#define ll long long
using namespace std;
//int main()
//{
//    int a[1005];
//    int n;
//    scanf("%d",&n);
//    for(int i=0;i<n;i++)
//        scanf("%d",&a[i]);
//    sort(a,a+n);
//    int l=0,r=n-1;
//    int flag=0;
//    while(l<r)
//    {
//        //printf("***");
//        int mx=0,mn=0;
//        int m=a[l]+a[r];
//        for(int i=0;i<n;i++)
//        {
//            if(i==r||i==l)
//                continue;
//           // printf("***");
//            if(a[i]+m==0)
//            {
//                flag=1;
//                printf("%d %d %d\n",a[l],a[i],a[r]);
//            }
//            mx=abs(a[i]+m);
//            if(a[i]+m>0)
//                mn=1;
//            else if(a[i]+m<0)
//                mn=-1;
//        }
//        if(mn==-1)
//            l++;
//        if(mn==1)
//            r--;
//    }
//    if(flag==0)
//    {
//        printf("No Solution\n");
//    }
//    return 0;
//}


int main()
{
   int n;
   ll sum=0,sum1=0;
   scanf("%d",&n);
   for(int i=1;i<=n;i++)
   {
       sum+=i;
       if(i%3==0||i%5==0)
        sum1+=i;

   }
   printf("%lld\n",sum-sum1);
   return 0;
}


Measured memory_bytes: 3864
x=[1,3,5,7,8,10,12]
y=[4,6,9,11]
a=list(map(int,input().split()))
if 2 in a:
    print("No")
elif a[0] in x and a[1] in x:
    print("Yes")
elif a[0] in y and a[1] in y:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
S = input()
T = input()

ret = float('inf')
for i in range(len(S) - len(T) + 1) :
  c = 0
  for j in range(len(T)) :
    if S[i + j] != T[j] :
      c += 1
  ret = min(ret, c)
  
print(ret)

Measured memory_bytes: 67576
import Control.Arrow
import qualified Data.ByteString.Char8 as B
import qualified Data.Set as S
import Data.List
import Text.Printf

readInt :: B.ByteString -> Int
readInt = maybe undefined fst . B.readInt

readIntPair :: B.ByteString -> [(Int, Int)]
readIntPair = map (pair . map readInt . B.words) . B.lines

pair :: [t] -> (t, t)
pair [x, y] = (x, y)
pair _ = undefined

main = do
  [x1,y1,x2,y2] <- map read . words <$> getLine
  _ <- getLine
  xys <- readIntPair <$> B.getContents
  printf "%.12f" (walk x1 y1 x2 y2 xys :: Double)

walk x1 y1 x2 y2 xys = 100*s - (20 - 5*pi)*p + (10*pi - 20)*q
  where
    [xmin,xmax] = sort [x1,x2]
    [ymin,ymax] = sort [y1,y2]
    cand = filter (\(x,y) -> xmin<=x && x<=xmax && ymin<=y && y<=ymax) xys
    s = fromIntegral $ abs (x2-x1) + abs (y2-y1)
    k = genericLength $ lis $ (if signum ((x2-x1) * (y2-y1)) == -1 then map negate else id) $ map snd $ sort cand
    (p, q) = (fromIntegral *** fromIntegral) $ if k < min (abs (x2-x1)) (abs (y2-y1)) + 1 then (k, 0) else (k - 1, 1)

lis :: Ord a => [a] -> [a]
lis = S.toList . snd . foldl go (S.empty, S.empty)
  where
    go (acc, acc0) x = case S.lookupGT x acc of
      Nothing -> let acc1 = S.insert x acc in (acc1, acc1)
      Just g -> (S.insert x (S.delete g acc), acc0)


Measured memory_bytes: 90492
#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)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

ll n;

int rec(ll x, int bit) {
    if (x > n) return 0;
    int res = 0;
    if (bit == 0b111) res++;
    res += rec(10*x + 3, bit | 0b001);
    res += rec(10*x + 5, bit | 0b010);
    res += rec(10*x + 7, bit | 0b100);
    return res;
}

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

    cin >> n;
    cout << rec(0, 0) << endl;
}


Measured memory_bytes: 3632
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <functional>
 
using namespace std;

int main() {
    int n;
    cin >> n;
    while (n > 0) {
        if (n%10==7){
            cout<<"Yes";
            return 0;
        }
        n/=10;
    }
    cout << "No";
}

Measured memory_bytes: 3636