akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列配列の入力
            long n = long.Parse(Console.ReadLine());

            List<string> blueList = new List<string>();
            for(int i =0; i < n; ++i) {
                blueList.Add(Console.ReadLine());
            }

            long m = long.Parse(Console.ReadLine());

            List<string> redList = new List<string>();
            for (int i = 0; i < m; ++i) {
                redList.Add(Console.ReadLine());
            }

            List<int> checkCnt = new List<int>();
            foreach(var item in blueList) {
                var blueItemCnt = blueList.Where(x => x == item).Count();
                var redItemCnt = redList.Where(x => x == item).Count();
                checkCnt.Add(blueItemCnt - redItemCnt);
            }

            int ans = checkCnt.Max();
            if(ans < 0) {
                ans = 0;
            }
            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
}

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
//最も遠いマスを答えるbfs
int bfs(const vector<string> &v, int x, int y){
  int H = v.size();
  int W = v[0].size();
  vector<vector<int>> dist(H,vector<int>(W,-1));
  queue<pair<int,int>> que;
  
  int res = 0;
  que.push({x, y});
  dist[x][y] = 0;
  while(!que.empty()){
    int x = que.front().first;
    int y = que.front().second;
    res = max(res, dist[x][y]);
    que.pop();
    for (int dir = 0; dir < 4; ++dir) {
      int nx = x+ dx[dir];
      int ny = y + dy[dir];
      if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
      if (v[nx][ny] == '#') continue;
      if (dist[nx][ny] == -1) {
        dist[nx][ny] = dist[x][y] + 1;
        que.push({nx, ny});
      }
    }
  }
  return res;
}

int main() {
  int H,W;
  cin >> H >> W;
  vector<string> v(H);
  for (int i = 0; i < H; ++i) cin >> v[i];
  int res = 0;
  for (int x = 0; x < H; ++x) {
    for (int y = 0; y < W; ++y) {
      if (v[x][y] == '#') continue;
      res = max(res, bfs(v, x, y));
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main{

    static char[][] ans;
    static int N;
    static int M;

    static boolean evenSolver(int n,int m,int a,int b,int sy,int sx){
        if(n*m<2*(a+b))return false;
        if(n*m==2*(a+b) && a%2==1)return false;
        int i=0,j=0;
        while(a>0){
            ans[sy+i][sx+j]='<';
            ans[sy+i][sx+1+j]='>';
            --a;
            if(a>0){
                ans[sy+1+i][sx+j]='<';
                ans[sy+1+i][sx+1+j]='>';
            }
            --a;
            j+=2;
            if(j>=m){
                j=0;
                i+=2;
            }
        }

        while(b>0){
            ans[sy+i][sx+j]='^';
            ans[sy+i+1][sx+j]='v';
            --b;
            if(b>0){
                ans[sy+i][sx+j+1]='^';
                ans[sy+1+i][sx+1+j]='v';
            }
            --b;
            j+=2;
            if(j>=m){
                j=0;
                i+=2;
            }
        }
        return true;
    }


    static void printSolve(boolean t){
        if(t){
            System.out.println("YES");
            for(char[] carray : ans){
                System.out.println(String.valueOf(carray));
                System.out.println();
            }
        }else{
            System.out.println("NO");
        }

    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        N = scan.nextInt();
        M = scan.nextInt();
        int A=scan.nextInt();
        int B=scan.nextInt();
        ans = new char[N][M];
        for(char[] c : ans)Arrays.fill(c, '.');
        
        if(N%2 == 0 && M%2 == 0)printSolve(evenSolver(N, M, A, B, 0, 0));
        else if(N%2==0 || M%2==0){
            if(N%2==0){
                for(int i=0;i<N;i+=2)if(B>0){
                    --B;
                    ans[i][0]='^';
                    ans[i+1][0]='v';
                }
                printSolve(evenSolver(N, M-1, A, B, 0, 1));
            }else{
                for(int j=0;j<M;j+=2)if(A>0){
                    --A;
                    ans[0][j]='<';
                    ans[0][j+1]='>';
                }
                printSolve(evenSolver(N-1, M, A, B, 1, 0));
            }
        }else{
            char ans_[][] = {{'<','>','^'},
            {'^','.','v'},
            {'v','<','>'}};
            for(int i=0;i<N-1;i+=2)if(B>0){
                --B;
                ans[i][M-1]='^';
                ans[i+1][M-1]='v';
            }
            for(int j=0;j<M-1;j+=2)if(A>0){
                --A;
                ans[N-1][j]='<';
                ans[N-1][j+1]='>';
            }
            if(A>0 && B>0 && A%2==1){
                for(int i=0;i<3;++i)for(int j=0;j<3;++j)ans[N-3+i][M-3+j]=ans_[i][j];
                A-=1;B-=1;
                printSolve(2*(A+B)<=(N-1)*(M-1)-4 && evenSolver(N-1,M-1,A,B,0,0));
            }else{
                printSolve(evenSolver(N-1,M-1,A,B,0,0));
            }
        }


    }
}

Measured memory_bytes: 27700
#include<stdio.h>
int main(){
    int a,b;
    scanf("%d",&a);
    scanf("%d",&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: 2580
#include <iostream>
#include <algorithm>
using namespace std;


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

}




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

int main() {
  int N;
  cin >> N;
  priority_queue<int> A;
  vector<ll> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  int count = 0;
  for (int i = 0; i < N-1; i++) {
    if (H[i] >= H[i+1]) {
      count++;
    }
    else {
      A.push(count);
      count = 0;
    }
  }
  A.push(count);
  cout << A.top() << endl;
}


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

char cn( char c, int dif ){
  int r = c+dif;

  while( r>'z' ) r-=26;
  while( r<'a' ) r+=26;
  return (char) r;
}

int main(){
  int n;
  string s;
  int a,b,c;
  int dif;
  int d[100][2];

  while( cin>>n && n ){
    cin >> s;
    for( int i=0;i<n;i++ )
      cin >> d[i][0] >> d[i][1];
     
    for( int i=n-1;i>=0;i-- ){
      a=d[i][0]; b=d[i][1];

      a--; b--; // 0 startÂÃ
      dif = b-a;

      s[a] = cn( s[a],dif );
      s[b] = cn( s[b],dif );
      c=s[a]; s[a]=s[b]; s[b]=c;
    }
    cout << s << endl;
  }

  return 0;
}

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

#define PI 3.14159265359

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = K; i < N; i++){
    if (A[i] > A[i - K]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  ll n; cin>>n;
  //ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  //string s,t; cin >> s >> t;
  ll result = 0;
  ll buf = 0;
  ll buf2 = 0;
  ll buf3 = 0;
  bool judge = true;

  
  map<ll,ll> a;
  for(i=0;i<n;i++){
    cin>>buf;
    if(a.find(buf)==a.end()){
      a.insert({buf,1});
    }
    else {
      a[buf]++;
    }
  }
  for(auto itr=a.begin();itr!=a.end();itr++){
    ll p=itr->first,q=itr->second;
    if(p<=q)result+=q-p;
    else result+=q;
  }
  cout<<result<<endl;

  return 0;
}

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

ll n, a, b;

int main() {
    cin >> n >> a >> b;
    if (a > b) swap(a, b);
    if ((b - a) & 1) {
        cout << ((b - a - 1) >> 1) + min(a - 1, n - b) + 1; 
    } else cout << ((b - a) >> 1);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

void sit(vector<int>&seats, int who) {
	if (who == 1) {
		for (int i = 0; i < seats.size(); ++i) {
			if (!seats[i]) {
				seats[i] = who;
				return;
			}
		}
	}
	else if (who == 2) {
		for (int i = seats.size()-1; i >= 0; --i) {
			if (!seats[i]) {
				bool ok = true;
				for (int k = i+1; k >= i-1; k -= 2) {
					if (k >= 0 && k < seats.size()) {
						if (seats[k] == 1)ok = false;
					}
				}
				if (ok) {
					seats[i] = who;
					return;
				}
			}
		}
		for (int i = 0; i < seats.size(); ++i) {
			if (!seats[i]) {
				seats[i] = who;
				return;
			}
		}
	}
	else if (who == 3) {
		for (int i = 0; i < seats.size(); ++i) {
			if (seats[i]) {
				if (i!=seats.size()-1&&!seats[i+1]) {
					seats[i+1] = who;
					return;
				}
				else if (i != 0 && !seats[i - 1]) {
					seats[i - 1] = who;
					return;
				}
			}
		}
		seats[seats.size() / 2] = who;
		return;
	}
	else {
		vector<int>diss(seats.size(), 1000);
		for (int i = 0; i < seats.size(); ++i) {
			if (seats[i]) {
				diss[i] = 0;
				for (int j = i - 1; j >= 0; --j) {
					diss[j] = min(diss[j], i-j);
				}
				for (int j = i + 1; j < seats.size(); ++j) {
					diss[j] = min(diss[j], j - i);
				}
			}
		}
		int maxdis = -1;
		int ans = -1;
		for (int i = 0; i < seats.size(); ++i) {
			if (maxdis < diss[i]) {
				maxdis = diss[i];
				ans = i;
			}
		}
		seats[ans] = who;
		return;
	}
	assert(false);
}

int main() {
	while (1) {
		int N, M; cin >> N >> M;
		if (!N)break;
		vector<int>seats(N);
		for (int i = 0; i < M; ++i) {
			char c; cin >> c;
			int num = c - 'A' + 1;
			sit(seats, num); 
			
		}
		for (int i = 0; i < N; ++i) {
			if (seats[i]) {
				cout << char('A' + seats[i] - 1);
			}
			else {
				cout << '#';
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2960
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef complex<int> cli;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ut,VI> PQ;
const int SIZE=2*1e5;
const LL INF=1<<30;
const LL p=7+1e9;
LL umax[SIZE],umin[SIZE],u[SIZE],dmax[SIZE],dmin[SIZE],d[SIZE],r[SIZE],sums[SIZE];
LL X,K,Q;
LL solve(LL t,LL a){

	LL s=0,e=K;
	while(s<=e){
		LL f=(s+e)/2;
		if(r[f]>t){
			e=f-1;
		}else{
			s=f+1;
		}
	}

	LL diff=(t-r[e]);
	s=e;
	//cout << e<<" "<< diff <<" "<<a << endl;
	if(s%2==0){
		if(umin[s]<=a){
			return max(0LL,u[s]-diff);
		}
		if(dmax[s]>=a){
			return max(0LL,d[s]-diff);
		}
		return max(0LL,sums[s]+a-diff);
	}
	else{
		if(umin[s]<=a){
			return min(X,u[s]+diff);
		}
		if(dmax[s]>=a){
			return min(X,d[s]+diff);
		}
		return min(X,sums[s]+a+diff);
	}
}
int main(){
	LL t,a;
	cin >> X >> K;
	umax[0]=umin[0]=u[0]=X;
	dmax[0]=dmin[0]=d[0]=0;
	sums[0]=0;
	FOR(i,1,K+1){
		cin >> r[i];
		dmax[i]=dmax[i-1];
		umin[i]=umin[i-1];
		if(i%2==1){
			sums[i]=sums[i-1]-r[i]+r[i-1];
			u[i]=max(0LL,u[i-1]-r[i]+r[i-1]);
			d[i]=d[i-1]-r[i]+r[i-1];
			if(d[i]<0){
				dmax[i]=dmax[i-1]-d[i];
				d[i]=0;
			}
		}
		else{
			sums[i]=sums[i-1]+r[i]-r[i-1];
			u[i]=u[i-1]+r[i]-r[i-1];
			d[i]=min(X,d[i-1]+r[i]-r[i-1]);
			
			if(u[i]>X){
				umin[i]=umin[i-1]-(u[i]-X);
				u[i]=X;
			}
		}
		//cout   << umin[i] << " " << u[i] << " " << dmax[i] << " "<< d[i] <<" " <<sums[i]<< endl;
	}
	cin >> Q;
	REP(j,Q){
		cin >> t >>a;
		cout << solve(t,a) << endl;
	}


	return 0;
}

Measured memory_bytes: 12672
#include <iostream>
#include <stdlib.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(void){
	int N;
	cin>>N;
	int W[N], sum[N];
	cin>>W[0];
	sum[0] = W[0];
	rep(i,N-1){
	  cin>>W[i+1];
	  sum[i+1] = sum[i]+W[i+1];
	}

	int ans = abs(sum[N-1]-2*sum[0]);
	rep(i,N-1){
	  if(ans > abs(sum[N-1]-2*sum[i+1]))ans = abs(sum[N-1]-2*sum[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())

int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}
using namespace std;
int main(){
    int a,b,ans=0;
    cin >> a >> b;

    if(a == b && a== 1){
        cout << 1000000 <<endl;
    }else{


        if(a == 1){
            ans += 300000;
        }else if(a==2){
            ans += 200000;
        }else if(a == 3){
            ans += 100000;
        }

         if(b == 1){
            ans += 300000;
        }else if(b==2){
            ans += 200000;
        }else if(b == 3){
            ans += 100000;
        }

        cout << ans <<endl;
    }

}





Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 998244353
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n;
	cin >> n;
	Array d(n, 0);
	REP(i, n) {
		cin >> d[i];
	}

	if (d[0] != 0) {
		cout << 0 << endl;
		return 0;
	}
	
	sort(all(d));

	if (d[1] == 0) {
		cout << 0 << endl;
		return 0;
	}

	Array b(1e5 + 10, 0);
	
	b[0] = 1;
	ll ans = 1;
	for (ll i = 1; i < n; i++) {
		if (b[d[i] - 1] == 0) {
			cout << 0 << endl;
			return 0;
		}

		(ans *= b[d[i] - 1]) %= MOD;
		b[d[i]]++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int i,j,a[3],b[3],c,d,w,x;
	scanf("%d %d %d",&w,&a[1],&b[1]);
	a[2]=a[1]+w;
	b[2]=b[1]+w;
	x=100000;
	if(a[1]<=b[1] && a[2]>=b[1] || a[1]>=b[1] && a[1]<=b[2]){
		x=0;
	}
	else {
		for(i=1;i<=2;i++){
			for(j=1;j<=2;j++){
				c=a[i]-b[j];
				if(x>c && c>=0){
					x=c;
				}
				d=b[i]-a[j];
				if(x>d && d>=0){
					x=d;
				}
			}
		}
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MAX 131072
using namespace std;

pair<pair<int, int>, int> edge[MAX];
map<int, long long> val;

int main(void)
{
	int N, M;
	cin >> N >> M;
	val[1] = 0LL;
	val[N] = 1LL * 998244353 * 998244353;
	for (int i = 0; i < M; i++) cin >> edge[i].first.first >> edge[i].first.second >> edge[i].second;
	sort(edge, edge + M);
	for (auto e : edge)
	{
		if (!e.second) break;
		auto lr = val.lower_bound(e.first.first);
		auto ee = val.lower_bound(e.first.second);
		if (ee->second > lr->second + e.second)
		{
			val[e.first.second] = lr->second + e.second;
			ee = val.upper_bound(e.first.second - 1);
			while (ee->second >= lr->second + e.second && ee != lr)
			{
				auto eee = ee;
				ee--;
				if (eee->first != e.first.second) val.erase(eee);
			}
		}
	}
	if (val[N] < 1LL * 998244353 * 998244353) cout << val[N] << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;
int main(void){
    IOS;
    int k, a, b; cin >> k >> a >> b;
    int flag = 0;
    for (int i = a; i <= b; ++i){
        if (i%k == 0){
            flag = 1; break;
        }
    }
    if (flag) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	// writer  = bufio.NewWriterSize(os.Stdout, 1000000)
)

const (
	wall = "#"
	road = "."
)

var (
	di = []int{-1, 0, 1, 0}
	dj = []int{0, -1, 0, 1}
)

type point struct {
	x, y int
}

// 解説見た
func main() {
	scanner.Split(bufio.ScanWords)
	// scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	// defer writer.Flush()
	h, w := scanInt(), scanInt()
	maze := make([][]string, h)
	for i := 0; i < h; i++ {
		maze[i] = make([]string, w)
		s := scanString()
		for j := 0; j < w; j++ {
			maze[i][j] = string(s[j])
		}
	}

	createDist := func() [][]int {
		d := make([][]int, h)
		for i := 0; i < h; i++ {
			d[i] = make([]int, w)
			for j := 0; j < w; j++ {
				d[i][j] = math.MaxInt64
			}
		}
		return d
	}

	q := CreateQueue(1000000)

	ans := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if maze[i][j] == wall {
				continue
			}
			d := createDist()

			upd := update(d, q)
			upd(i, j, 0)
			for !q.Empty() {
				qt, _ := q.Deq()
				qq := qt.(*point)
				x, y := qq.x, qq.y

				for dir := 0; dir < 4; dir++ {
					ni, nj := y+di[dir], x+dj[dir]
					if ni < 0 || ni >= h || nj < 0 || nj >= w {
						continue
					}
					if maze[ni][nj] == wall {
						continue
					}
					upd(ni, nj, d[y][x]+1)
				}
			}

			for ii := 0; ii < h; ii++ {
				for jj := 0; jj < w; jj++ {
					if d[ii][jj] == math.MaxInt64 {
						continue
					}
					ans = max(ans, d[ii][jj])
				}
			}
		}
	}

	fmt.Println(ans)
}

func update(d [][]int, q *Queue) func(i, j, x int) {

	return func(i, j, x int) {
		if d[i][j] != math.MaxInt64 {
			return
		}
		d[i][j] = x
		q.Enq(&point{x: j, y: i})
	}
}

func scanInt() int {
	i, _ := strconv.Atoi(scanString())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanString(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

func scanStrings(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanString()
	}
	return s
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

type Queue struct {
	ele []interface{}
}

func CreateQueue(cap int) *Queue {
	return &Queue{
		ele: make([]interface{}, 0, cap),
	}
}

func (q *Queue) Empty() bool {
	return len(q.ele) == 0
}

func (q *Queue) Enq(e interface{}) {
	q.ele = append(q.ele, e)
}

func (q *Queue) Deq() (interface{}, bool) {
	if q.Empty() {
		return nil, false
	}
	r := q.ele[0]
	q.ele = q.ele[1:]
	return r, true
}


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

next=[[] for i in range(n)]
for i in range(n):
	l=list(map(int,input().split()))
	u=l[0]
	k=l[1]
	for j in range(2,k+2):
		next[u-1].append(l[j]-1)

stk=[]
stk.append(0)
time=1
d=[0 for i in range(n)]
f=[0 for i in range(n)]
know=[0 for i in range(n)]

def dfs(x):
	global time
	know[x]=1
	d[x]=time
	time+=1
	for n in next[x]:
		if know[n]==0:
			dfs(n)
	f[x]=time
	time+=1
	
for i in range(n):
	if know[i]==0:
		dfs(i)

for i in range(n):
	out=[]
	out.append(i+1)
	out.append(d[i])
	out.append(f[i])
	print(*out)


Measured memory_bytes: 5668
import java.util.Scanner;
class Main{


	static char[][] map;
	static final int MOD = 1000000007;


	static long[][] c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力

		int a = sc.nextInt();
		int ans = 0;
		for(int i = 1;i <= a;i++){
			if(String.valueOf(i).length() % 2 == 1){
				ans++;
			}
		}
		System.out.println(ans);




	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}








}






Measured memory_bytes: 28372
#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)
#define all(v) v.begin(), v.end()
const int INF = 1<<30;
const long long LINF = 1LL << 60;
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() {
    cin.tie(nullptr) ;
    ios::sync_with_stdio(false) ;

    string s;
    cin >> s;
    if (s.back() == 's') cout << s + "es\n";
    else
        cout << s + "s\n";
    return 0;
}

Measured memory_bytes: 3652
// ABC067_A.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	char a, b;
	cin >> a >> b;
	if (a == b) {
		cout << 'H' << endl;
		return 0;
	}
	cout << 'D' << endl;
	return 0;
}



Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())

data = []
for i in range(2):
    input_data = input().split()
    tmp = [int(n) for n in input_data]
    data.append(tuple(tmp))

perm = list(itertools.permutations(range(1, n+1)))

index_d0 = -1
index_d1 = -1

for i in range(len(perm)):
    if perm[i] == data[0]:
        index_d0 = i+1
    if perm[i] == data[1]:
        index_d1 = i+1
    if index_d0 > -1 and index_d1 > -1:
        break

smaller_num = min(index_d0, index_d1)
larger_num = max(index_d0, index_d1)

ans = abs(smaller_num - larger_num)
print(ans)


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

int main(){
  int N;
  cin >> N;
  if(N<10)
    cout << N;
  else if(N<100)
    cout << 9;
  else if(N<1000)
    cout << 9+N-99;
  else if(N<10000)
    cout << 909;
  else if(N<100000)
    cout << 909+N-9999;
  else if(N=100000)
    cout << 909+90000;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

struct A
{
  long money;
  long kabu;
};

long solve(int n, const std::vector<int>& prices)
{
  A sisan{1000, 0};

  for (int i = 0; i < n; ++i) {
    const auto p = prices[i];
    sisan.money += p * sisan.kabu;
    sisan.kabu = 0;
    if (i < n - 1 && p < prices[i + 1]) {
      const auto c = sisan.money / p;
      sisan.money -= p * c;
      sisan.kabu += c;
    }
  }

  return sisan.money;
}

int main()
{
  int n;
  std::cin >> n;
  std::vector<int> prices(n);
  for (auto& p : prices) {
    std::cin >> p;
  }

  std::cout << std::setprecision(20);
  std::cout << solve(n, prices) << std::endl;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int X; cin >> X;
	vector<ll> dp(X + 1);
	dp[0] = 1;
	for (int i = 0; i < X; i++) {
		for (int j = 0; j <= 5; j++) {
			if (i + 100 + j > X)break;
			dp[i + 100 + j] += dp[i];
		}
	}
	cout << (dp[X] ? 1 : 0) << endl;
}


Measured memory_bytes: 3896
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n, k;
bool e[100][100];

int main() {
    cin >> n >> k;
    if (k > (n-1)*(n-2)/2) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 1; i < n; i++) {
        e[0][i] = 1;
        e[i][0] = 0;
    }
    int cnt = (n-1)*(n-2)/2;
    for (int i = 1; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            if (cnt == k) break;
            cnt--;
            e[i][j] = 1;
            e[j][i] = 1;
        }
    }
    int M = 0;
    rep(i,n) for (int j = i+1; j < n; j++) M += e[i][j];
    cout << M << endl;
    rep(i,n) for (int j = i+1; j < n; j++) {
        if (e[i][j]) cout << i+1 << " " << j+1 << endl;
    }
}

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

#define fastIO ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);
#define endl '\n'
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MP make_pair
#define inf INT_MAX
#define minf INT_MIN

typedef long long int lli;

ofstream outfile;
ifstream infile;
int main()
{
	infile.open("input.txt");
	outfile.open("output.txt");

	int n, t = 0, i;
	cin >> n;
	i = n;
	while(n){
		t = t*10+n%10;
		n/=10;
	}

	if(t == i){
		cout << "Yes\n";
	}
	else
		cout << "No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,h=0,w=0;cin>>n;
  long long ans=0;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i+=2){
    if(a[i]==a[i+1]){w=h;h=a[i];}
    else{i--;}
  }
  cout<<(long long)h*w;
}

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

long long n,T,A,t,a,p,q;

int main()
{
    while(scanf("%lld",&n) != EOF)
    {
        T = A = 1;
        while(n--)
        {
            scanf("%lld%lld",&t,&a);
            if(t == 1 && a == 1)
            {
                T = max(T,A);
                A = max(T,A);
            }
            else if(t >= T && a >= A)
            {
                T = t;
                A = a;
            }
            else
            {
                p = T / t;
                if(T % t != 0) p++;
                q = A / a;
                if(A % a != 0) q++;
                long long k = max(p,q);
                T = t * k;
                A = a * k;
            }
        }
        printf("%lld\n",T + A);
    }
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp

ans = 0

[*'0'..'9'].repeated_permutation(3) do |i, j, k|
  x = s.index(i, 0)
  y = s.index(j, x + 1) if x
  z = s.index(k, y + 1) if y

  ans += 1 if x && y && z
end

puts ans


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
const long long NINF = (long long) -1;

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

    int h, w, items;
    cin >> h >> w >> items;
    vector<vector<long long>> grid(h, vector<long long>(w, (long long) 0));

    while (items--){
    	int r, c;
    	long long val;
    	cin >> r >> c >> val;
    	--r, --c;
    	grid[r][c] = val;
    }

    vector<vector<vector<long long>>> dp(h, vector<vector<long long>>(w, vector<long long>(4, NINF)));
    for (int row = 0; row < h; ++row){
    	for (int col = 0; col < w; ++col){
    		if (row == 0 && col == 0){
    			dp[row][col][0] = 0;
    			dp[row][col][1] = grid[row][col];
    		}
    		else{
    			if (row){
    				dp[row][col][0] = *max_element(dp[row - 1][col].begin(), dp[row - 1][col].end());
    				dp[row][col][1] = dp[row][col][0] + grid[row][col];
    			}
    			for (int k = 0; k <= 3; ++k){
    				if (col){
    					dp[row][col][k] = max(dp[row][col][k], dp[row][col - 1][k]);
    					if (k && dp[row][col - 1][k - 1] != NINF){
    						dp[row][col][k] = max(dp[row][col][k],
    							dp[row][col - 1][k -1] + grid[row][col]);
    					}
    				}
    			}
    		}
    	}
    }

    cout << *max_element(dp[h - 1][w - 1].begin(), dp[h - 1][w - 1].end()) << '\n';
    return 0;
}

Measured memory_bytes: 706652
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0; i != N; ++i)
#define co(o) cout << o << endl;
using namespace std;
typedef long int li;
typedef long long ll;

int N;

void dfs(string str, char used){
    if(str.length()==N){
        cout << str << endl;
    }else{
        for(char c='a'; c<=used+1; ++c){
            dfs(str+c, max(used,c));
        }
    }
}

int main(void){
    cin >> N;       
    dfs("a",'a');
}


Measured memory_bytes: 1536
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,t,dp[200010][110],all=0,ans;//dp[val][used items' numbers]=real_val>=val,min_weight
pii vw[110];

int main()
{
	rep(i,100005) rep(j,105) dp[i][j]=1e18;
	cin>>n>>t;
	repn(i,n) cin>>vw[i].se>>vw[i].fi,all+=vw[i].fi;
	sort(vw,vw+n);
	dp[0][0]=0;
	rep(i,all+1)
	{
		repn(j,n)
		{
			dp[i][j]=min(dp[i][j],dp[i][j-1]);
			dp[i+vw[j].fi][j]=dp[i][j-1]+vw[j].se;
		}
	}
	rep(i,all+1) if(dp[i][n]<=t) ans=i;
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 88320
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int cnt = sc.nextInt();
        int[] a = new int[cnt];
        int[] b = new int[cnt];
        for(int i = 0; i < cnt; i++){
            a[i] = sc.nextInt();
        }
        for(int i = 0; i < cnt; i++){
            b[i] = sc.nextInt();
        }
        int[] sum = new int[cnt];
        int k = 0;
        for(int i = 0; i < cnt; i++){
            sum[i] += k;
            sum[i] += a[i];
            for(int j = i; j < cnt; j++){
                sum[i] += b[j];
            }
            k += a[i];
        }
        int max = sum[0];
        for(int i = 0; i < sum.length; i++){
            max = Math.max(max, sum[i]);
        }
        System.out.println(max);
    }
}

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

int main(){
  int result=0;
  string s;
  int n;
  cin >> n;
  cin >> s;
  
  for(int i=0;i<n-2;i++){
  	if(s[i]!='A') continue;
  	if(s[i+1]!='B') continue;
  	if(s[i+2]!='C') continue;
    result++;
  }
  
  cout << result;
  return 0;
}

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

int main()
{
    int S;
    cin >> S;
    int h = S / 3600, m= S % 3600 / 60, s = S % 3600 % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3108
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;


int main() {

	int n,c;
	
	cin >> n>>c;
	string a[100],b[100];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < c; i++)
		cin >> b[i];

	
	for (int i = 0; i <= n - c; i++) {
		for (int j = 0; j <= n - c; j++) {
			bool f = 0;
			for (int t = i; t < i + c; t++) {
				for (int r = j; r < j + c; r++) {
					if (a[t][r] != b[t - i][r - j])f = 1;
				}
			}
			if (!f) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;

}




Measured memory_bytes: 256
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    n, k = mi()
    a = li()

    for i in range(k, n):
        if a[i] > a[i - k]:
            print(yes)
        else:
            print(no)


main()


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

int main(void)
{
	string str;

	while(cin >> str)
	{
		if(str[0] == 'S')
			cout << "Cloudy\n";
		else if(str[0] == 'C')
			cout << "Rainy\n";
		else if(str[0] == 'R')
			cout << "Sunny\n";
			
	}
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 1500000;
const int K = 20 ;
int p[N], sz[N], f[N];
vector < pair < int, pair < int, int > > > e;
int gt(int x){
    if (x == p[x]) return x;
    return p[x] = gt(p[x]);
}
void unite(int x, int y){
    x = gt(x);
    y = gt(y);
    if (sz[x] < sz[y]) swap(x, y);
    p[y] = x;
    sz[x] += sz[y];
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n; i++) f[i] = 1e12;
    for (int i = 1; i <= q; i++){
        int a, b, c;
        cin >> a >> b >> c;
        e.pb({c, {a, b}});
        e.pb({c, {b, a}});
        f[a] = min(f[a], c + 1);
        f[b] = min(f[b], c + 2);
    }
    int x = 1e12;
    for (int i = 0; i < 5 * n; i++){
        int v = i % n;
        f[v] = min(f[v], x);
        x = f[v] + 2;
    }
    for (int i = 0; i < n; i++){
        e.pb({f[i], {i, (i + 1) % n}});
        e.pb({f[i], {(i + 1) % n, i}});
    }
    sort(e.begin(), e.end());
    for (int i = 0; i < n; i++){
        p[i] = i;
        sz[i] = 1;
    }
    int ans = 0;
    for (auto i: e){
        int u = i.S.F;
        int v = i.S.S;
        if (gt(u) == gt(v)) continue;
        ans += i.F;
        unite(u, v);
    }
    cout << ans;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;

int S(int x) {
	string s = to_string(x);
	int sum = 0;
	inc(i, s.size()) { sum += s[i] - '0'; }
	return sum;
}

int main() {
	cin >> n;
	
	cout << (n % S(n) == 0 ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;

#define LL long long

inline LL read(){
	LL x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const LL INF=1e18;
const LL MAXN=300010;
LL N,K; LL x[MAXN+1];
LL t=1;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(),K=read();
	for(LL i=1;i<=N;i++) x[i]=read();
	while(x[t]<0&&t<=N) ++t;
	if(t==N+1) {
		printf("%lld\n",-x[N-K+1]);
		return 0;
	} if(t==1){
		printf("%lld\n",x[K]);
		return 0;
	} else{
		LL ans=INF;
		for(LL i=t;i<=min(t+K-1,N);i++){
			if(t-(K-(i-t+1))>=1) ans=min(ans,2*x[i]-x[t-(K-(i-t+1))]);
		}
		for(LL i=t-1;i>=max(1LL,t-K-1);i--){
			if(t+(K-(t-i))-1<=N) ans=min(ans,-2*x[i]+x[t+(K-(t-i))-1]);
		}
		if(t>K) ans=min(ans,-x[t-K]);
		if(t+K-1<=N) ans=min(ans,x[t+K-1]);
		printf("%lld\n",ans);
		return 0;
	}
	return 0;
}


Measured memory_bytes: 1024
S = list(input())
ans = 0

if len(S) > 1:
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            if S[i+1] == "0":
                S[i+1] = "1"
                ans += 1
            else:
                S[i+1] = "0"
                ans += 1
    print(ans)
else:
    print(0)


Measured memory_bytes: 3956
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>


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

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N, C, p, sum = 0;
  cin >> N >> C;
  for(int i = 0; i < C; i++){
    cin >> p;
    sum += p;
  }
  cout << ceil((double)sum / (N + 1)) << endl;
  return 0;
}


Measured memory_bytes: 3232
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>
 
using namespace std;
typedef int status;
typedef long long ll;
typedef unsigned long long ull;
const ull base = 343;
const int INF = int(1e9);
const int MAX = 200002;
 
int N;
 
int a[200][20],b[200][20];
 
int main()
{
    scanf("%d",&N);
    for(int i = 1;i<=N;i++)
    for(int j = 1;j<=10;j++)
        scanf("%d",&a[i][j]);
    for(int i = 1;i<=N;i++)
    for(int j = 0;j<=10;j++)
        scanf("%d",&b[i][j]);
 
    int max1 = -INF;
    for(int i = 0;i<1024;i++)
    {
        int max2 = 0;
        int ii = i,flag = 0;
        for(int k = 1;k<=10;k++){
             if(ii&1==1){flag = 1;break;}
             ii = ii>>1;
        }
        if(flag==0)continue;
 
        for(int j = 1;j<=N;j++)
        {
            int ti = i,num = 0;
            for(int k = 10;k>=1;k--)
            {
                if(a[j][k]==1&&(ti&1==1))
                    num++;
                ti = ti>>1;
            }
            max2 += b[j][num];
        }
        max1 = max(max1,max2);
    }
 
    printf("%d\n",max1);
 
    return 0;
}

Measured memory_bytes: 256
# atcoder では WAになる。なんで。
n = int(input())
a = list(map(int,input().split()))
a = sorted(a,reverse =True)
#
alice = []
bob = []
alice_total = 0
bob_total = 0
ans = 0
#
if n%2 == 0:
    for i in range(int(n/2)):
        alice.append(a[2*i])
        bob.append(a[2*i + 1])
elif n!=1:
    for j in range(int((n - 1)/2)):
        alice.append(a[2*j])
        bob.append(a[2*j + 1])
    alice.append(a[n - 1])
else:
    alice = a
#
alice_total = sum(alice)
bob_total = sum(bob)
ans = alice_total - bob_total
#
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int x2 = sc.nextInt();
        int x3 = sc.nextInt();
        int x4 = sc.nextInt();
        int x5 = sc.nextInt();
        if ( x1 == 0) {
            System.out.println("1");
        }
        if ( x2 == 0) {
            System.out.println("2");
        }
        if ( x3 == 0) {
            System.out.println("3");
        }
        if ( x4 == 0) {
            System.out.println("4");
        }
        if ( x5 == 0) {
            System.out.println("5");
        }
    }
}

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

int main(){
	int d, n;
	cin >> d >> n;
	if(n == 100) n = 101;
	int ans = n*pow(100, d);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import time
start = time.time()
import random
D = int(input())
*c, = map(int, input().split())
S = []
for _ in [None] * D:
    *s, = map(int, input().split())
    S += s,
INF = float("inf")

def Tread(D):
    return [int(input()) for i in [None] * D]

def check(T):
    M = 0
    MM = []
    last = [-1] * 26
    for d, t in enumerate(T):
        M += S[d][t] - sum((d - last[i]) * c[i] for i in range(26) if i != t)
        last[t] = d
        # MM += M,
    return M # MM

def 貪欲():
    M = 0
    T = []
    last = [-1] * 26
    for d in range(D):
        m = -INF
        for j in range(26):
            Q = S[d][j] - sum((d - last[i]) * c[i] for i in range(26) if i != j)
            if m < Q:
                t, m = j, Q
        T += t,
        last[t] = d
        M += m
        # print(M)
    return T, M

def 局所探索():
    T, M = 貪欲()
    # print(T, M)
    while time.time() - start < 1.9:
        d, q = random.randrange(D), random.randrange(26)
        Check = T[:]
        Check[d] = q
        if (C := check(Check)) > M:
            M, T = C, Check
    for s in T:print(s + 1)
    # print(M)

def C():
    T = Tread(D)
    for i in range(int(input())):
        d, q = map(int, input().split())
        T[d - 1] = q - 1
        print(check(T))
局所探索()

Measured memory_bytes: 9948
#include<iostream>
#include <string>
using namespace std;
int main()
{
    int n,chika;
    cin>>n;
    chika=0;
    if(n%2==0){
        chika=n;
    }else{
        chika=2*n;
    }
    cout<<chika<<endl;
    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s", $tap);

$easyTap = true;

for($i = 0; $i < strlen($tap); $i++) {
  if($i % 2 == 0 && $tap[$i] == "L") {
    $easyTap = false;
} else if ($i % 2 == 1 && $tap[$i] == "R") {
    $easyTap = false;
  }
}

if ($easyTap) {
  echo "Yes"; 
  } else {
    echo "No";
  }


Measured memory_bytes: 3828
#include<iostream>

using namespace std;

int main(){
	int H, W, ans[100][100];
	int i, j, flag = 0, num = 0, count = 0;
	char field[100][100];

	cin >> H >> W;
	for(i = 0; i < H; i++){
		flag = 0;
		for(j = 0; j < W; j++){
			cin >> field[i][j];
			if(field[i][j] == 'c'){
				ans[i][j] = 0;
				if(flag == 0){
					flag = 1;
					for(int k = 0; k < j; k++){
						ans[i][k] = -1;
					}
				}
			}
		}
		if(flag == 0){
			for(j = 0; j < W; j++){
				ans[i][j] = -1;
			}
		}
	}
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			count = 0;
			if(field[i][j] == 'c'){
				for(int k = j; k < W; k++){
					ans[i][k] = count;
					count++;
				}
			}
		}
	}
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			if(field[i][j] == 'c')  ans[i][j] = 0;
		}
	}
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			if(j != W - 1) cout << ans[i][j] << " ";
			else cout << ans[i][j] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define PRINT(s) cout << s << endl;
#define FOR(i, n) for (int i = 0; i < (n); i++)

int main() {

    int napN, napW;
    cin >> napN >> napW;
    vector<int> value(napN);
    vector<int> weight(napN);
    vector<vector<int> > valueInNap(napN + 1, vector<int>(napW + 1, 0));

    FOR(i, napN) {
        cin >> value[i] >> weight[i];
    }

    FOR(i, napN) {
        FOR(j, napW + 1) {
            int v = value[i];
            int w = weight[i];

            if (j < w) { 

                valueInNap[i + 1][j] = valueInNap[i][j]; 
            } else {
                valueInNap[i + 1][j] = max(valueInNap[i][j], valueInNap[i][j - w] + v);
            }
        }
    }
    int maxValue = 0;
    FOR(i, valueInNap.size()) {
        FOR(j, valueInNap[i].size()) {
            maxValue = max(maxValue, valueInNap[i][j]);
        }
    }
    PRINT(maxValue);
}



Measured memory_bytes: 6772
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n; cin >> n;
    if(n == 0){
        cout << 0 << endl; return 0;
    }
    string bin = "";
    while(n != 0){
        ll foo = n%((ll)-2);
        n /= ((ll)-2);
        if(foo < 0){
            foo += abs((ll)-2);
            n++;
        }
        bin = to_string(foo)+bin;
    }
    cout << bin << endl;
    return 0;
}


Measured memory_bytes: 3684