akhauriyash/Code-Regression huggingface dataset:
//by yjz
#include<bits/stdc++.h>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
typedef long long ll;
using namespace std;

namespace Flow
{
	const int maxn = 211, maxe = 30011*2;
	int head[maxn],to[maxe],nxt[maxe],cap[maxe],tot=1;
	void init()
	{
		memset(head,0,sizeof(head));tot=1;
	}
	void adde(int x,int y,int c)
	{
//		cerr<<"adde:"<<x<<","<<y<<" "<<c<<endl;
		nxt[++tot]=head[x];
		head[x]=tot;
		to[tot]=y;
		cap[tot]=c;
		nxt[++tot]=head[y];
		head[y]=tot;
		to[tot]=x;
		cap[tot]=0;
	}
	void adde_2(int x,int y,int c,int c2)
	{
		nxt[++tot]=head[x];
		head[x]=tot;
		to[tot]=y;
		cap[tot]=c;
		nxt[++tot]=head[y];
		head[y]=tot;
		to[tot]=x;
		cap[tot]=c2;
	}
	int lv[maxn],q[maxn],qn;
	void bfs(int S,int N)
	{
		for(int i=0;i<=N;i++)lv[i]=-1;
		qn=0;
		q[qn++]=S;lv[S]=0;
		for(int i=0;i<qn;i++)
		{
			int u=q[i];
			for(int j=head[u];j;j=nxt[j])
			{
				if(cap[j]&&lv[to[j]]==-1)
				{
					lv[to[j]]=lv[u]+1;
					q[qn++]=to[j];
				}
			}
		}
	}
	int it[maxn];
	int dfs(int x,int T,int f)
	{
		if(x==T)return f;
		int of=f;
		for(int &i=it[x];i&&f;i=nxt[i])
		{
			int u=to[i];
			if(cap[i]&&lv[u]==lv[x]+1)
			{
				int d=dfs(u,T,min(f,cap[i]));
				if(d)
				{
					cap[i]-=d;
					cap[i^1]+=d;
					f-=d;
					if(f==0)return of;
				}
			}
		}
		return of-f;
	}
	int max_flow(int S,int T,int N=-1)
	{
		if(N==-1)N=maxn-1;
		int ans=0;
		while(true)
		{
			bfs(S,N);
			if(lv[T]==-1)return ans;
			for(int i=0;i<=N;i++)it[i]=head[i];
			ans+=dfs(S,T,2147483647);
		}
	}
};

int n, m;
int a[111][111];
int b[111][111];
int c[111][111];
void solve(int col)
{
	Flow::init();
	int S = n+n+1, T = n+n+2;
	for (int i=1; i<=n; i++)
	{
		Flow::adde(S, i, 1);
		Flow::adde(i+n, T, 1);
	}
	for (int i=1; i<=n; i++)
	{
		for (int j=1; j<=n; j++)
		{
			if (b[i][j])
			{
				Flow::adde(i, n+j, b[i][j]);
			}
		}
	}
	int f = Flow::max_flow(S, T, T);
	assert(f==n);
	for (int i=1; i<=n; i++)
	{
		for (int j=Flow::head[n+i]; j; j=Flow::nxt[j])
		{
			int u = Flow::to[j];
			if (Flow::cap[j]&&u<=n)
			{
				b[u][i]--;
				c[u][col] = i;
//				cerr<<u<<"-"<<i<<endl;
			}
		}
	}
}
int main()
{
	scanf("%d%d", &n, &m);
	for (int i=1; i<=n; i++)
	{
		for (int j=1; j<=m; j++)
		{
			scanf("%d", &a[i][j]);
			b[i][(a[i][j]-1)/m+1]++;
		}
	}
	for (int i=1; i<=m; i++)
	{
		solve(i);
	}
	/*
	for (int i=1; i<=n; i++)
	{
		for (int j=1; j<=m; j++)
		{
			cerr<<(a[i][j]-1)/m+1<<" ";
		} cerr<<endl;
	}
	cerr<<endl;
	
	for (int i=1; i<=n; i++)
	{
		for (int j=1; j<=m; j++)
		{
			cerr<<c[i][j]<<" ";
		} cerr<<endl;
	}
	cerr<<endl;
 */
	for (int i=1; i<=n; i++)
	{
		for (int j=1; j<=m; j++)
		{
			for (int k=j; k<=m; k++)
			{
				if ((a[i][k]-1)/m+1==c[i][j])
				{
					swap(a[i][j], a[i][k]);
					break;
				}
			}
			printf("%d ", a[i][j]);
		}
		puts("");
	}
	for (int i=1; i<=m; i++)
	{
		vector<int> v;
		for (int j=1; j<=n; j++) v.PB(a[j][i]);
		sort(v.begin(), v.end());
		for (int j=1; j<=n; j++) a[j][i] = v[j-1];
	}
	for (int i=1; i<=n; i++)
	{
		for (int j=1; j<=m; j++)
		{
			printf("%d ", a[i][j]);
		}
		puts("");
	}
	return 0;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

typedef pair<int, int> P; 


int main(){
    string s;
    cin >> s;
    if(s.length()%2==1) {
        cout << "No" << endl;
        return 0;
    }
    REP(i, s.length()/2) {
        if(s[i] != 'h' || s[i+1] != 'i') {
            cout << "No" << endl;
            return 0;            
        }
        i++;
    }

    cout << "Yes" << endl;
    return 0;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){ int i,n,b,c=0,a=0;
scanf("%d",&n);for(i=0;i<n;i++){scanf("%d",&b);if(b%2==0){c++;if(b%3==0||b%5==0){a++;}}}
puts(c==a?"APPROVED":"DENIED");              
}

Measured memory_bytes: 1624
N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort(reverse=True)
count=0
for i in range(N):
    while(1):
        if H[i]==0:
            break
        else:
            if K>0:
                H[i]=0
                K-=1
            else:
                count+=H[i]
                H[i]=0
print(count)

Measured memory_bytes: 25508
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define lint long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807

bool prime_check(int A)
{
  if( A < 2) return 0;
  for (int i = 2; i <= sqrt(A); i++)
  {
    if(A%i == 0)return 0;
  }
  return 1;
}
void solve()
{
  int N;
  cin>>N;
  vector<int> vec(N,0);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  int count = 0;
  for (int i = 0; i < N; i++)
  {
    for (int j = N - 1; j > i; j--)
    {
      if(vec[j] <vec[j-1])
      {
        swap(vec[j],vec[j-1]);
        count++;
      }
    }
  }

  for (int i = 0; i < N; i++)
  {
    cout<<vec[i];
    if(i != N -1) cout<<" ";
  }

  cout<<endl<<count<<endl;
  
  
  return;
}

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

  solve();

  return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const double INF=1e9;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

LL gcd(LL a,LL b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main(){
	LL N,X;cin>>N>>X;
	if(gcd(N,X)==1LL){
		if(X*2LL!=N)cout<<(N-1LL)*3LL<<endl;
		else cout<<X*3LL<<endl;
	}else{
		LL t=gcd(N,X);
		N/=t;
		X/=t;
		if(X*2LL!=N)cout<<(N-1LL)*3LL*t<<endl;
		else cout<<X*3LL*t<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cnt(string a,string b){
  int ans=0;
	for(int i=0;i<a.length();i++)  if(a[i]!=b[i]) ++ans;
  return ans;
}
int main(){
  string a;
  cin>>a;
  string b="",c="";
  for(int i=0;i<a.length();i++){
   if(i%2==0){
	b.push_back('1');
     c.push_back('0');
   }
    else{
      b.push_back('0');
     c.push_back('1');
    }
  }
  cout<<min(cnt(a,b),cnt(a,c));
}

Measured memory_bytes: 1024
from collections import deque
n=int(input())

que=deque([3,5,7])
x=0
ans=0
while True:
    x=que.popleft()
    if x>n:
        break
    s=str(x)
    if s.count('3')>0 and s.count('5')>0 and s.count('7')>0:
        ans+=1
    que.append(10*x+3)
    que.append(10*x+5)
    que.append(10*x+7)
print(ans)

Measured memory_bytes: 6260
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<ctime>
#include<functional>
#define int long long
#define INT INT_MAX
#define LONG LLONG_MAX
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
typedef long long ll;
using namespace std;

signed main() {
	int n, a[100000], b[100000], x = 0;
	cin >> n;
	f(i, n) cin >> a[i] >> b[i];
	for (int i = n - 1; i >= 0; i--) {
		if ((a[i] + x) % b[i]) x = ((a[i] + x - 1) / b[i] + 1)*b[i] - a[i];
	}
	cout << x << endl;
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  
  if(S == "AAA"|| S == "BBB"){
    cout << "No" << endl;
  }
    
    else{
      cout << "Yes" << endl;
    }
  
}


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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> xpos(N);
	rep(i, N) cin >> xpos.at(i);

	int ans = 0;
	rep(i, N) {
		ans += min(xpos.at(i), K - xpos.at(i)) * 2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
  int n,a[21],b[21],c[20],i,j,k,ans;
  cin>>n;
  ans=0;
  
  for(i=1;i<=n;i++){cin>>a[i];}
  
  for(i=1;i<=n;i++){cin>>b[i];}
  for(i=1;i<n;i++){cin>>c[i];}
  ans=0;
  for(i=1;i<n;i++)
  {
   ans+=b[a[i]];
   if(a[i+1]-a[i]==1){ans+=c[a[i]];}
  }
  ans+=b[a[n]];
  cout<<ans<<endl;
}

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

const int mod = 1e9 + 7;
int mat[1005][1005];

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  char a;
  int n, m, x, y;
  cin>>n>>m;

  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
    {
      cin>>a;
      mat[i][j] = ((a == '.') ? 0 : -1);
    }

  mat[0][0] += 1;
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
    {
      if(mat[i][j] > 0)
      {
        if(mat[i+1][j] != -1)
          mat[i+1][j] = (mat[i+1][j] + mat[i][j]) % mod;
        if(mat[i][j+1] != -1)
          mat[i][j+1] = (mat[i][j+1] + mat[i][j]) % mod;
      }
    }

  cout<<mat[n-1][m-1]<<endl;

  return 0;
}


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

int main()
{
    string S;
    cin >> S;
    int N = (int)(S.length()), c = 0;
    for (int i = 0; i < (N - 1) / 2; i++)
    {
        if (S.at(i) != S.at(N - 1 - i))
        {
            c++;
        }
        else if (S.at(i) != S.at((N + 1) / 2 + i))
        {
            c++;
        }
    }
    if (c == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstring>
#include <stdlib.h>
int main()
{
	int a,b,r=0;
	scanf("%i%i",&a,&b);
	if(a==1)
	{
		r=r+300000;
		if(b==1)
		{
			r+=300000+400000;
		}
		else if(b==2)
		{
			r+=200000;
		}
		else if(b==3)
		{
			r+=100000;
		}
	}
	else if(a==2)
	{
		r=r+200000;
		if(b==1)
		{
			r+=300000;
		}
		else if(b==2)
		{
			r+=200000;
		}
		else if(b==3)
		{
			r+=100000;
		}
	}
	else if(a==3)
	{
		r=r+100000;
		if(b==1)
		{
			r+=300000;
		}
		else if(b==2)
		{
			r+=200000;
		}
		else if(b==3)
		{
			r+=100000;
		}
	}
	else if(a>3)
	{
		if(b==1)
		{
			r+=300000;
		}
		else if(b==2)
		{
			r+=200000;
		}
		else if(b==3)
		{
			r+=100000;
		}
	}
	printf("%i",r);
    return 0;
}


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

int main()
{
	int a = 0, b = 0;
	cin >> a >> b;
	int n = 0;



	for (n = 0; n < 100; n++) {
		if (((a - 1) * (n - 1) + a) >= b) {
			break;
		}
	}
	cout << n << "\n";

	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    agc008a()
}

fun agc008a() {
    val (x, y) = readLine()!!.split(" ").map { it.toLong() }

    val answer = (0..3).map { calc(x, y, it) }.min()

    println(answer)
}

fun calc(x1: Long, y1: Long, i: Int): Long {
    var x = x1
    var y = y1
    var cnt = 0L

    if (i % 2 == 0) {
        y *= -1
        cnt++
    }
    if (i shr 1 % 2 == 0) {
        x *= -1
        cnt++
    }

    return if (x <= y) y - x + cnt else Long.MAX_VALUE / 2
}


Measured memory_bytes: 37868
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
vector<int> height;
int a;
while(cin>>a){
height.push_back(a);
}
sort(height.begin(), height.end(), greater<int>());
for(int i = 0; i < 3; i++)
cout << height[i] << endl;
}

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

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);
vcL fac(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if (a < b) return 0;

	MUL(ans, inv[fac[a - b]]);
	MUL(ans, inv[fac[b]]);
	MUL(ans, fac[a]);

	return ans;
}

lli Lucas(lli n, lli m) {
	if (m == 0) return 1;
	return cm(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas(n, m);
}

/// coding area ///

const lli maxn = 1E5;

void precal() {

	return;
}

void solve() {
	lli n;
	cin >> n;
	
	lli ans = 0, p;
	for (p = 10; p < n; p *= 100) {
		ans += p * 9 / 10;
	}
	
	if (n != p) ans += max(0LL, n - (p / 10) + 1);
	else ans += max(0LL, n - (p / 10));

//	for (int i = 1; i <= n; ++i) {
//		int j = i, cnt = 0;
//		while (j > 0) {
//			j /= 10;
//			++cnt;
//		}
//		
//		if (cnt % 2 == 1) ++ans;
//	}
	
	cout << ans << '\n';
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include<stdio.h>
using namespace std;
int main(void) {
	int R0, W0, C, R;
	int x=0;
	while (1) {
	    scanf("%d %d %d %d",&R0,&W0,&C,&R);
		if (R0==0||W0==0||C==0||R==0) {
			break;
		}
		if (R0 < W0 * C) {
			if ((W0 * C- R0) % R == 0) {
				x = (W0 * C- R0) / R;
			}
			else {
				x = (W0 * C- R0) / R + 1;
			}			
		}
		else{
		    x=0;
		}
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 3148
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_bakc
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)
int n;
int cnt[1000010];
int main() {
	IO;
	cin>>n;
	int all_gcd=0;
	for(int i=0;i<n;++i) {
		int x;
		cin>>x;
		cnt[x]++;
		all_gcd=gcd(all_gcd, x);
	}
	
	bool ok=true;
	for(int i=2;i<=1000000;++i) {
		int van=0;
		for(int j=i;j<=1000000;j+=i){
			van+=cnt[j];
		}
		if(van>1) {
			ok=false;
		}
	}
	
	if(ok) {
		cout<<"pairwise coprime\n";
	}else if(all_gcd==1) {
		cout<<"setwise coprime\n";
	}else {
		cout<<"not coprime\n";
	}
	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define forabr(i, a, b) for(int i = int(b)-1; i >= int(a); i--)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    ll x = n / (a + b);
    x *= a;
    n %= (a + b);
    if (n > a) x += a;
    else x += n;
    cout << x << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=105;
int h,w;
char s[N][N];
int dp[N][N];
int main()
{
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++)
		scanf("%s",s[i]+1);
	memset(dp,63,sizeof(dp));
	dp[1][1]=s[1][1]=='#';
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
		{
			if(i>1) dp[i][j]=min(dp[i][j],dp[i-1][j]+(s[i-1][j]!=s[i][j]));
			if(j>1) dp[i][j]=min(dp[i][j],dp[i][j-1]+(s[i][j-1]!=s[i][j]));
		}
	printf("%d",(dp[h][w]+1)/2);
	return 0;
}

Measured memory_bytes: 3864
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import math

k = ni()
a = na()

r,l = 2,2

for i in a[::-1]:
    if r < i:
        print(-1)
        exit()
    l = math.ceil(l/i)*i
    r = (r//i)*i+i-1
    if l > r:
        print(-1)
        exit()

print(l,r)

Measured memory_bytes: 14264
#include<stdio.h>

#define MAX   20
#define N    200

int solve(int,int);

int n;
int A[MAX];

int main()
{
  int a,i,res;
  int B[N];

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&a);

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

  for(i = 0;i < a;i++){
    res = solve(0,B[i]);
    if(res == 1){
      printf("yes\n");
    }
    else if(res == 0){
      printf("no\n");
    }
  }

  return 0;
}

int solve(int i,int m)
{
  int res;
  if(m == 0) return 1;
  if(i >= n) return 0;

  if(solve(i+1,m) == 1 || solve(i+1,m - A[i]) == 1){
    return 1;
  }
  return 0;
}



Measured memory_bytes: 2120
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>
#include <array>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mn(x) *min_element((x).begin(),(x).end())
#define mx(x) *max_element((x).begin(),(x).end())
#define acc(x) accumulate((x).begin(),(x).end(),0ll)
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

const ld pi=acos(-1);
const ll inf=(ll)1e12+1;
//const int mod=1000000007;
const int mod=998244353;

int n,m,k;
const int N=3e5+10;







int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n;
    int ans=0;
    vi v(n);
    for(int i=0 ;i<n; i++){
        cin >> v[i];
    }
    sort(all(v));
//    auto lte = [&] (int n){
//        return upper_bound(all(v),n)-v.begin();
//    };
    int last=0;
    for(int i=0; i<n; i++){
        int tt=v[i]-last;
        if(tt%2){
            ans^=(n-i);
        }
        last=v[i];
    }
    if(ans){
        cout << "first\n";
    }
    else{
        cout << "second\n";
    }
    
    
    return 0;
}






Measured memory_bytes: 3648
k, s = map(int, input().split())
ans = 0
for i in range(k + 1):
    for j in range(i + 1):
        l = s - (i + j)
        if 0 <= l <= k and l <= j <= i:
            if i == j == l:
                ans += 1
            elif i == j or j == l or l == i:
                ans += 3
            else:
                ans += 6
print(ans)


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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    FOREACH(x, v) { cout << x << " "; }                                        \
    cout << "\n";

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, M;
vector<VL> F, P;
map<ll, ll> cnt;

ll mypow(ll x, ll n) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * x;
        x *= x;
        n >>= 1;
    }
    return res;
}

int main() {
    cin >> N;
    F.resize(N);
    P.resize(N);
    REP(i, N) REP(j, 10) { F[i].emplace_back(IN()); }
    REP(i, N) REP(j, 11) { P[i].emplace_back(IN()); }
    ll ans = -LINF;
    REP(i, 1 << 10) {
        if(!__builtin_popcount(i)) continue;
        ll tmp = 0;
        REP(j, 10) {
            if((i >> j) & 1) {
                REP(k, N) if(F[k][j]) cnt[k]++;
            }
        }
        REP(idx, N) tmp += P[idx][cnt[idx]];
        ans = max(ans, tmp);
        cnt.clear();
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#define ll long long
#define the_flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

int main() 
{
    the_flash;
    
    int n, count = 0;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int num;
        cin >> num;
        if (num != i + 1)
            count++;
    }

    if (count > 2)
        cout << "NO" << "\n";
    else 
        cout << "YES" << "\n";
    return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n;
  std::cin >> n;
  vt<int> a(n);
  rep(i,n)
    std::cin >> a[i];

  int ans = 0;
  int num = 0;
  vt<bool> check(n);
  rep(i,n) {
    if(check[num]) {
      std::cout << -1 << '\n';
      return 0;
    }
    else if(num == 1) {
      break;
    }
    else {
      check[num] = true;
      num = a[num]-1;
      ans++;
    }
  }

  std::cout << ans << '\n';
  return 0;
}


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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 1e5 + 5;
vector<ll> node[N];
ll dp[N][2], sz[N];
void build(ll root, ll u, ll p, ll d){
        dp[u][root] = d;
        for (auto j : node[u]){
                if (j != p){
                        build(root, j, u, d + 1);
                }
        }
}
void dfs(ll u, ll p){
        sz[u] = 0;
        for (auto j : node[u]){
                if (j != p){
                        dfs(j, u);
                        sz[u] = max(sz[u], sz[j] + 1);
                }
        }
}
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (fopen("WALKING.INP", "r")){
                freopen("WALKING.INP", "r", stdin);
                freopen("WALKING.OUT", "w", stdout);
        }
        ll n, s, t;
        cin >> n >> t >> s;
        for (int i = 1; i < n; i++){
                ll u, v;
                cin >> u >> v;
                node[u].push_back(v);
                node[v].push_back(u);
        }
        build(0, s, 0, 0);
        build(1, t, 0, 0);
        dfs(s, 0);
        ll ans = 0;
        for (int i = 1; i <= n; i++){
                if (dp[i][1] < dp[i][0]) {
                        ans = max(ans, dp[i][0] + sz[i] - 1);
                }
        }
        cout << ans;
}


Measured memory_bytes: 13440
#include <iostream>
#include <deque>

int main() {
    std::cin.tie(nullptr);

    int N, L;
    std::cin >> N >> L;

    std::deque<std::pair<int, int>> deq;
    for (int i = 0; i < N; ++i) {
        int a;
        std::cin >> a;

        while (!deq.empty() && deq.back().first >= a) deq.pop_back();
        deq.push_back(std::make_pair(a, i));

        if (i >= L - 1) std::cout << deq.front().first << " \n"[i == N - 1];
        if (deq.front().second == i - L + 1) deq.pop_front();
    }
    return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF = 1e9 + 5;
int main(){
    long long a, b, n; cin >> a >> b >> n;
    if(n < b) {
        cout << floor( (a * n) / b) - ( a * floor(n / b));
    }
    else {
        long long n1 = b - 1;
        long long res1 = floor( (a * n1) / b) - ( a * floor(n1 / b));
        long long res2 = floor( (a * n) / b) - ( a * floor(n / b));
        long long l = n / b;
        long long n = (l * b) - 1;
        long long res3 = floor( (a * n) / b) - ( a * floor(n / b));
        cout << max(res1, max(res2, res3));
    }
    return 0;
}

Measured memory_bytes: 3784
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    std::string s;
    cin >> s;
    
    bool ans = true;
    int tmp = s.size() / 2;
    if(s.size()%2 != 0){
        ans = false;
    }else{
    for(int i=0; i<s.size()/2; i++){
        //cout << s[i] << s[tmp+i] << endl;;
        if(s[i] != s[tmp+i]){
            ans = false;
            break;
        }
    }
    }
    std::string result = (ans == true)? "Yes":"No";
    cout << result << endl; 
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys,math,itertools
input = sys.stdin.readline
n, k = map(int, input().split())
d = [int(_) for _ in input().split()]
d_set = set(d)
d_all = set(range(10))
d_use = [str(a) for a in list(d_all - d_set)]
keta = int(math.log10(n))+1
l1 = [int(''.join(list(a))) if int(''.join(list(a)))>=n else 100000 for a in list(itertools.product(d_use, repeat=keta+1))]
l2 = [int(''.join(list(a))) if int(''.join(list(a)))>=n else 100000 for a in list(itertools.product(d_use, repeat=keta))]

print(min(min(l1), min(l2)))

Measured memory_bytes: 16476
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

const ll INF = 1000000000;
const int MAX_N = 1000;

int N;
string o, e;

void solve(){
    cin >> o >> e;
 
    for(int i = 0; i < e.size(); i++){
        cout << o[i] << e[i];
    }

    if(o.size() > e.size()) cout << o[o.size() - 1];

    cout << endl;

    return;
}

int main(){
    solve();
    return 0;
}


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

int main() {
  long long A, B;
  cin >> A >> B;
  A *= 100;
  B *= 100;
  long long res = -1;
  for (int i = 0; i < 100000; i++){
    if ((i * 8 - A) < 100 && (i * 8 - A) >= 0){
      if ((i * 10 - B) < 100 && (i * 10 - B) >= 0){
        res = i;
        break;
      }
    }
  }
  cout << res << endl;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

using namespace std;

using ull = unsigned long long;
using ll = long long;

#define pb push_back
#define endl '\n'

bool isPrime(int n)
{
    if(n==1)
        return true;
    for(ll i=2; i*i<=n; i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}

int countDivisor(int n) {
    int divisor=0;
    for(int i=1; i*i<=n; i++) {
        if (i*i==n)
            divisor+=1;
        else if(n%i==0)
            divisor+=2;
    }
    return divisor;
}

int binary_s(int a[], int n, int x)
{
    int left=0, right=n-1, mid;
    while(left<=right) {
        mid=left+(right-left)/2;
        if(a[mid]==x)
            return mid;
        else if(x>a[mid])
            left=mid+1;
        else
            right=mid-1;
    }
    return -1;
}

void solve()
{
    int l, r, i, j, min;
    cin>>l>>r;
    min=(((l%2019)*(r%2019))%2019);
    for(i=l; i<r; i++){
        if(min==0)
            break;
        for(j=i+1; j<=r; j++){
            if((((i%2019)*(j%2019))%2019)<min)
                min=((i%2019)*(j%2019))%2019;
            if(min==0)
                break;
        }
    }
    cout<<min<<endl;
}

int main()

{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    solve();

    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class DGatheringChildren {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      string s; cin >> s;
      int n = s.size();
      vector<int> ten(n);
      rep(i, n) {
        int p = i;
        rep(j, 10) {
          if (s[p] == 'L') {
            p--;
          } else {
            p++;
          }
        }
        ten[i] = p;
      }
      vector<int> s1 = ten;
      vector<int> s2(n);

      rep(k, 10) {
        rep(i, n) {
          int p = i;
          rep(j, 10) {
            p = s1[p];
          }
          s2[i] = p;
        }
        swap(s1, s2);
      }

      vector<int> ans(n);
      rep(i, n) {
        ans[s1[i]]++;
      }
      for(auto e: ans) {
        cout << e << ' ';
      }
      cout << endl;
    }
};

signed main() {
  DGatheringChildren solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 2256
/**
 * Created by hiramekun at 20:52 on 2019-08-24.
 */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll mod = 1000000007;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
ll factorial(ll n) {
    ll ans = 1;
    while (n > 1) {
        ans *= n;
        ans %= mod;
        n--;
    }
    return ans;
}


int main() {
    ll n;
    cin >> n;
    string s;
    cin >> s;

    n *= 2;

    vector<bool> is_right(n);
    rep(i, n) {
        if (i % 2 == 0 && s[i] == 'W') is_right[i] = true;
        if (i % 2 == 1 && s[i] == 'B') is_right[i] = true;
    }
    ll ans = 1;
    ll left_sum = 0;
    rep(i, n) {
        if (is_right[i]) {
            if (left_sum == 0) {
                cout << 0 << '\n';
                return 0;
            }
            ans *= left_sum;
            ans %= mod;
            left_sum--;
        } else {
            left_sum++;
        }
    }
    if (left_sum > 0) cout << 0 << '\n';
    else cout << ans * factorial(n / 2) % mod << '\n';
    return 0;
}

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

typedef vector<int> vi;
unordered_map<int, bool> memo;

bool solve(size_t p, int t, vi &A) {
	
	long key = p + 1 + ((t + 1) << 16);
	auto i = memo.find(key);
	if (i != memo.end())
		return (*i).second;

	bool res;
	if (t == 0)
		res = true;
	else if (p == A.size())
		res = false;
	else 
		res = solve(p + 1, t - A[p], A) ? true : solve(p + 1, t, A);

	memo[key] = res;
	return res;
}

int main()
{
	int n, q, m;

	cin >> n;
	vi A(n);
	for (int &x: A)
		cin >> x;
	
	cin >> q;
	while (q--) {
		cin >> m;
		cout << (solve(0, m, A) ? "yes" : "no") << endl;
	}

}



Measured memory_bytes: 4404
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define ll long long
using namespace std;

int main()
{
	int n;
	cin >> n;
	int ans = 0;
	vector<int> b(n);
	int tmp;

	for (int i = 0; i < n - 1; i++) {
		cin >> b[i];
	}
	b[n - 1] = b[n - 2];

	ans += b[0];
	for (int i = 0; i < n - 1; i++) {
		ans += min(b[i], b[i + 1]);
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 256
import Text.Printf
main = do
  s <- getContents
  let v = map (map read . words) . lines $ s 
  let w = map acc v
  mapM_ putStrLn w

acc :: [Int] -> String
acc [a,b,c,d,e,f] = (printf "%.3f" . sig $ x) ++ " " ++ (printf "%.3f" . sig $ y)
  where
    det = fromIntegral(a*e - b*d) :: Double
    x = fromIntegral(e*c-b*f) / det 
    y = fromIntegral(-c*d+a*f) /det 
    sig x = if x==0.0 then 0.0 else  x

Measured memory_bytes: 4144
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
 
#define rsz resize
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const int N = 55;
vvi g (N);
int dp [N];
int lvl [N];

int bridge_cnt = 0;

void dfs (int node) {
  GO (to, g[node]) {
    if (!lvl[to]) {
      lvl[to] = lvl[node] + 1;
      dfs (to);
      dp[node] += dp[to];
    } else if (lvl[node] < lvl[to]) {
      --dp[node];
    } else if (lvl[node] > lvl[to]) {
      ++dp[node]; 
    }
  }
  --dp[node];
  if (lvl[node] && dp[node] == 0) {
    ++bridge_cnt;
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); 
  int n, m;
  cin >> n >> m;
  F0R (i, m) {
    int st, et;
    cin >> st >> et;
    --st; --et;
    g[st].eb(et);
    g[et].eb(st);
  }
  lvl[0] = 1;
  dfs (0);
  cout << bridge_cnt << '\n';
  return 0; 
}


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

using namespace std;
int N; 
long long int M, A[100005];
vector<long long int> V;

long long int CALC(long long int K) {

	long long int ret = 0;
	for (int i = 1; i <= N; i++) {
		auto pos = lower_bound(V.begin(), V.end(), K - A[i]) - V.begin();
		ret += N - pos;
	}
	return ret;
}

int IsPossible(long long int H, long long int MM) {

	if (CALC(H) >= MM) { return 1; }
	return -1;

}

long long int INF = INT64_MAX / 2;

long long int BS(long long int MM) {

	long long int left = 0;
	long long int right = INF;

	long long int med;

	while (right > left + 1) {
		med = (right + left) / 2;
		if (IsPossible(med, MM) == 1) {
			left = med;
		}
		else {
			right = med;
		}
	}
	return left;
}

long long int S[100005];

long long int solve(long long int MM) {
	long long int cnt = 0;
	long long int ans = 0;

	long long int W = BS(MM);

	//cout << " W= " << W;

	for (int i = N - 1; i >= 0; i--) {

		if (MM - cnt <= (long long int) N) {
			for (int j = N - 1; j >= 0; j--) {
				if (V[i] + V[j] < W) { break; }
				if ((cnt < MM) && (V[i] + V[j] > W)) { ans += V[i] + V[j]; cnt++; }
			}
		}
		else {
			auto pos = lower_bound(V.begin(), V.end(), W +1- V[i]) - V.begin();
			long long int num = N - pos;
			//cout << "num= " << num << endl;
			cnt += num;
			ans += S[num] + V[i] * num;
		}
		//cout << "cnt= " << cnt << endl;
		if (cnt >= MM) { break; }
	}

	if (cnt < MM) { ans += W*(MM - cnt); }

	return ans;
}

int main(void) {

	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		V.push_back(A[i]);
	}

	sort(V.begin(), V.end());

	//for (auto y : V) { cout << " " << y; }cout << endl;

	//cout << BS() << endl;

	

/*	vector<pair<long long int,long long int> > Vec;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			Vec.push_back(make_pair(A[i] + A[j], A[i]));
		}
	}
	sort(Vec.rbegin(), Vec.rend());
	long long int tmp = 0;*/

	for (int i = 1; i <= (int)N; i++) {
		S[i] = S[i - 1] + V[N - i];
	}

/*	for (int i = 0; i < M; i++) {
		tmp += Vec[i].first;
		cout <<"  " << i << " " << Vec[i].first-Vec[i].second<< " + "<<Vec[i].second  << "= " <<Vec[i].first<<  " "<< tmp << endl;
	}*/




	cout << solve(M) << endl;

	return 0;
}

Measured memory_bytes: 2804
a, v = list(map(int, input().split(' ')))
b, w = list(map(int, input().split(' ')))
time = int(input())
if a>b:
  x1 = a - v*time
  x2 = b - w*time
  if x1 <= x2:
    print('YES')
  else:
    print('NO')
elif a<b:
  x1 = a + v*time
  x2 = b + w*time
  if x1 >= x2:
    print('YES')
  else:
    print('NO')
  




Measured memory_bytes: 9092
import java.util.Scanner;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);

        while (scanner.hasNextFloat()) {
            float v = scanner.nextFloat();
            float t = v / 9.8f;
            float y = 4.9f * t * t;
            System.out.println((int) Math.ceil(y / 5) + 1);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 0
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
b = [0]*(n+1)
for i in a:
    b[i] += 1
for i in range(1,n+1):
    print(b[i])


Measured memory_bytes: 32300
using System;
using System.Linq;

namespace agc026_a
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int back = x[0]; int count = 1; int ret = 0;
			for (int i = 1; i < n; i++)
			{
				if (back == x[i]) count++;
				else
				{
					ret += count / 2;
					count = 1;
				}
				back = x[i];
			}
			Console.WriteLine(ret + count / 2);
		}
	}
}

Measured memory_bytes: 13396
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
SAT = 0

for cnt, i in enumerate(A):
    SAT += B[i - 1]

    if cnt > 0 and A[cnt] == A[cnt - 1] + 1:
        SAT += C[i - 2]

print(SAT)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-9;
const ll MOD=1e9+7;
ll dp[25][100010];
int main(){
    int N,K;cin>>N>>K;
    for(int i=1;i<=N;i++)dp[0][i]=1LL;
    if(K>20){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<K;i++){
        for(int j=2;j<=N;j++){
            for(int k=1;k<=N;k++){
                if(j*k>N)break;
                dp[i+1][k*j]+=dp[i][k];
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=N;i++){
        ans+=dp[K-1][i];
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 18676
#include <bits/stdc++.h>
using namespace std ;
int main(){
    int n , m , i , cnt = 0 ;
    cin >> n >> m ;
    vector<int> h(n+1) , ma(n+1,0) ; 
    for(i=1;i<=n;++i) cin >> h[i] ;
    for(i=0;i<m;++i){
        int t1 , t2 ; cin >> t1 >> t2 ;
        ma[t1] = max(ma[t1],h[t2]) ;
        ma[t2] = max(ma[t2],h[t1]) ;
    }
    for(i=1;i<=n;++i) cnt += h[i] > ma[i] ;
    cout << cnt << "\n" ;
    return 0 ;
}

Measured memory_bytes: 4020
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>  
#include<vector>
#define ll long long
using namespace std;

struct Edge{
	int from,to;
	ll dist;
	Edge(int u,int v,ll d):from(u),to(v),dist(d){}
};
vector<int>G[100005];
vector<Edge>edges;
int flag=1,s;
ll d[100005];
int done[100005],bin[100005];
int pre[100005];

void dfs(int u){
	if (flag==0) return;
	done[u]=1;
	for (int i=0;i<G[u].size();i++){
		if (flag==0) return;
		Edge& e=edges[G[u][i]];
		if (!done[e.to]){
			d[e.to]=d[e.from]+e.dist;
			dfs(e.to);
		}else{
			if (d[e.to]!=d[u]+e.dist){
				flag=0;
				return;
			}
		}
	}
}

int find(int x){
	if (x==pre[x]) return x;
	else return pre[x]=find(pre[x]);
}

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=0;i<=n;i++) pre[i]=i; 
	for (int i=0;i<m;i++){
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		edges.push_back(Edge(l,r,d));
		G[l].push_back(i);
		pre[r]=find(l);
	}
	for (int i=1;i<=n;i++){
		if (flag==0) break;
		if ((!G[i].empty())){
			s=find(i);
			
			if (flag==0) break;
			if (bin[s]==0){
				memset(d,0,sizeof(d));
				memset(done,0,sizeof(done));
				dfs(s);
				bin[s]=1;
			}
		}
	}
	if (flag) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 13552
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    long long int a;
    std::deque<long long int> deq;
    cin>>n;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    std::deque<long long int> diff;
    for (int i=1;i<=n;i++) {
        diff.emplace_back(deq[i-1]-i);
    }
    sort(diff.begin(),diff.end());
    long long int sum=0;
    for (int i=1;i<=n;i++) {
        sum+=abs(deq[i-1]-(diff[diff.size()/2]+i));
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 6896
#include<iostream>
#include<vector>
#include<math.h>

using namespace std;

int main(int argc, char **argv) {
    int n, ans;
    double min;
    double ave = 0;
    vector<double> a;

    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ave += a[i];
    }
    ave /= (double)n;
    min = ave;

    for (int j = 0; j < n; j++) {
        a[j] = fabs(a[j] - ave);
        if (a[j] < min) {
            ans = j;
            min = a[j];
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int k, x;
  cin >> k >> x;
  for(int i = x-k+1; i <= x+k-2; i++) {
    cout << i << " ";
  }
  cout << x+k-1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  V t(n+1, 0), x(n+1, 0), y(n+1, 0);
  FOR(i, 1, n+1) {
    cin >> t[i] >> x[i] >> y[i];
  }
  int xs, a, b;
  REP(i, n) {
    xs = t[i+1]-t[i];
    a = x[i+1]-x[i];
    b = y[i+1]-y[i];
    xs -= abs(a)+abs(b);
    if (xs < 0 || xs%2 == 1) {
      dump("No");
      return 0;
    }
  }
  dump("Yes");
  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
int main(void) {
	int x, y;
	int f = 0;
	while (f == 0)
	{
		scanf("%d %d", &x, &y);

		if( x==0 && y==0 ){
			break;
		}
		else if (x > y) {
			int i;
			i = x;
			x = y;
			y = i;
		}
		printf("%d %d\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  vector<pair<pair<int,int>,int > > a(m);
  for(int i=0;i<m;i++)
  {
    int p,y;
    cin>>p>>y;
    a.at(i)=make_pair(make_pair(p,y),i);
  }

  sort(a.begin(),a.end());
  vector<pair<int,int> > ans(m);
  int cnt=1;
  for(int i=0;i<m;i++)
  {
    int p=a.at(i).first.first;
    int y=a.at(i).first.second;
    int I=a.at(i).second;
    if(i>=1 && p==a.at(i-1).first.first) cnt++;
    else cnt=1;
    ans.at(I)=make_pair(p,cnt);
  }

  for(int i=0;i<m;i++) printf("%06d%06d\n",ans.at(i).first,ans.at(i).second);
}

Measured memory_bytes: 3456
#include <iostream>

using namespace std;
using int64 = long long;

int main () {
    int64 n;
    cin >> n;
    int64 ans = LONG_MAX;
    for (int64 i=1; i*i<=n; i++) {
        if (n % i == 0) ans = min(ans, i+n/i-2);
    }

    cout << ans << endl;
}


Measured memory_bytes: 888
import collections

N = int(input())
co = [list(map(int, input().split())) for i in range(N)]

if N > 1:
    tmp = []
    for i in range(N):
        for j in range(N):
            tmp.append((co[i][0]-co[j][0],co[i][1]-co[j][1]))
    c = collections.Counter(tmp)
    print(N - c.most_common()[1][1])
else:
    print("1")

Measured memory_bytes: 3948