akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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; }

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

    int n;
    cin >> n;
    VI h(n);
    FOR(i, 0, n)cin >> h[i];

    string ans = "Yes\n";
    FOR(i, 0, n - 1) {
        if (h[i] < h[i + 1])h[i + 1]--;
        if(h[i]>h[i+1])ans = "No\n";
    }
    cout << ans;
}

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

int toInt(int ph, int pm, int ps) {
  int h = ph / 5;
  int m = pm;
  int s = ps;
  int dh = ph - h * 5;
  if(dh != m / 12) return -1;
  return s + m * 60 + h * 3600;
}

string toTime(int t) {
  int h = t / 3600;
  int m = t % 3600 / 60;
  int s = t % 60;
  char buff[100];
  sprintf(buff, "%02d:%02d:%02d", h, m, s);
  return string(buff);
}

const int INF = 1<<28;
const int MAXN = 12;
int N;
int S[MAXN], T[MAXN], U[MAXN];

int rec(int k, int st, int sw) {
  if(k == N) return st;
  if(k == sw) return rec(k+1, st, sw);
  int res = INF;
  int a[3] = {S[k], T[k], U[k]};
  sort(a, a+3);
  do {
    for(int d = 0; d < 60; ++d) {
      int ph = (a[0] + d) % 60;
      int pm = (a[1] + d) % 60;
      int ps = (a[2] + d) % 60;
      int t = toInt(ph, pm, ps);
      if(t == -1 || t < st) continue;
      res = min(res, t);
    }
  } while(next_permutation(a, a+3));
  return max(res, rec(k+1, st, sw));
}

int main() {
  while(cin >> N && N) {
    for(int i = 0; i < N; ++i) {
      cin >> S[i] >> T[i] >> U[i];
    }
    pair<int,int> ans(INF, INF);
    for(int k = 0; k < N; ++k) {
      int a[3] = {S[k], T[k], U[k]};
      sort(a, a+3);
      do {
        for(int d = 0; d < 60; ++d) {
          int ph = (a[0] + d) % 60;
          int pm = (a[1] + d) % 60;
          int ps = (a[2] + d) % 60;
          int t = toInt(ph, pm, ps);
          if(t == -1) continue;
          int end = rec(0, t, k);
          ans = min(ans, make_pair(end - t, t));
        }
      } while(next_permutation(a, a+3));
    }
    cout << toTime(ans.second) << " " << toTime(ans.second + ans.first) << endl;
  }
  return 0;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int fa[200010],FA[200010],v0[200010],v1[200010];
ll ans;
int hd(int x){return FA[x]==x?x:FA[x]=hd(FA[x]);}
std::priority_queue<std::pair<double,int>>que,del;
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi();
	for(int i=2;i<=n;++i)fa[i]=gi();
	for(int i=1;i<=n;++i)FA[i]=i;
	for(int i=1;i<=n;++i)gi()?v1[i]=1:v0[i]=1;
	for(int i=2;i<=n;++i)que.push({1.0*v0[i]/v1[i],i});
	for(int i=1;i<n;++i){
		while(!que.empty()&&!del.empty()&&que.top()==del.top())que.pop(),del.pop();
		int x=que.top().second;que.pop();
		int y=hd(fa[hd(x)]);
		ans+=1ll*v0[x]*v1[y];
		if(y!=1)del.push({1.0*v0[y]/v1[y],y});
		v0[y]+=v0[x],v1[y]+=v1[x];
		if(y!=1)que.push({1.0*v0[y]/v1[y],y});
		FA[x]=y;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 14572
S = input()

def is_kaibun(s):
    for i in range(len(s) // 2):
        if s[i] != s[-i-1]:
            print('No')
            exit()

N = len(S)
is_kaibun(S)
is_kaibun(S[:(N-1)//2])
is_kaibun(S[(N+3)//2-1:])
print('Yes')


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

int main() {
    int a,b;
    cin >> a >> b;
    int ans = 0;
    auto judge = [](int n) {
        string s = to_string(n);
        if(s[0] != s[4]) return false;
        if(s[1] != s[3]) return false;
        return true;
    };
    rep2(i,a,b+1) {
        if(judge(i)) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

const int N=1e6+3;

const double eps=0.000000001;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans;

char s[N];

void IO(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}

int g[10][10];

int main(){
	//IO();
	ll ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		x=i;
		int l=x%10;
		int f;
		while(x){
			f=x%10;
			x/=10;
		}
		g[f][l]++;
	}
	for(int i=1;i<=n;i++){
		x=i;
		int l=x%10;
		int f;
		while(x){
			f=x%10;
			x/=10;
		}
		ans+=g[l][f];
	}
	printf("%lld\n",ans);
}


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

int main() {
  int n, m;
  int s, c;
  bool flag = false;
  string ans = "";
  map<int, int> digit;
  cin >> n >> m;
  for (int i=1; i<4; i++) digit[i] = -1;
  for (int i=0; i<m; i++) {
    cin >> s >> c;
    if (digit[s]!=-1 and c!=digit[s]
        or s==1 and c==0 and n!=1
        or s>n) {
      flag = true;
    }
    else {
      digit[s] = c;
    }
  }
  for (int i=1; i<=n; i++) {
    if (digit[i]==-1) {
      if (i==1 and n!=1) ans += '1';
      else ans += '0';
    }
    else ans += to_string(digit[i]);
  }
  if (flag) cout << -1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,x,y;
  cin>>a>>b;
  x=a*b;
  y=x%2;
  if(y==1){
    cout<<"Odd"<<endl;
  }else{
  cout<<"Even"<<endl;
  }
  
}

Measured memory_bytes: 256
N = input()
if N[-1] == "2" or N[-1] == "4" or N[-1] == "5" or N[-1] == "7" or N[-1] == "9":
  print("hon")
elif N[-1] == "0" or N[-1] == "1" or N[-1] == "6" or N[-1] == "8":
  print("pon")
else:
  print("bon")

Measured memory_bytes: 8960
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int n, x, q, a[maxn];
int bz[20][maxn];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	rep(i, 1, n) cin >> a[i];
	cin >> x;
	rep(i, 1, n) {
		bz[0][i] = std::upper_bound(a + 1, a + n + 1, a[i] + x) - a - 1;
	}
	bz[0][n + 1] = n + 1;
	rep(i, 1, 19) rep(j, 1, n + 1)
		bz[i][j] = bz[i - 1][bz[i - 1][j]];
	cin >> q;
	rep(i, 1, q) {
		int l, r, ans = 0;
		cin >> l >> r;
		if(l > r) std::swap(l, r);
		for(int i = 19;i >= 0;--i) if(bz[i][l] < r) {
			ans += 1 << i;
			l = bz[i][l];
		}
		cout << ans + 1 << '\n';
	}
}


Measured memory_bytes: 16384
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int n, m, x; cin >> n >> m >> x;
    vector<int> cost(n);
    vector<vector<int>> ar(n, vector<int>(m));
    rep(i,n){
        cin >> cost[i];
        rep(j,m) cin >> ar[i][j];
    }
    int ans = 1e9;
    rep(i,1<<n){
        int c = 0;
        vector<int> ri(m,0);
        rep(j,n){
            if (i >> j & 1){
                c += cost[j];
                rep(k,m) ri[k] += ar[j][k];
            }
        }
        bool t = true;
        rep(j,m){
            if (ri[j] < x){
                t = false;
                break;
            }
        }
        if (t) ans = min(ans,c);
    }
    if (ans != 1e9) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	stack<int> S1;
	stack<pair<int,int> > S2;
	char ch;
	int sum=0;
	for (int i = 0; cin >> ch ; ++i) {
		if ( ch == '\\') S1.push(i);
		else if (ch == '/'  && S1.size() > 0 ){
			int j =S1.top(); S1.pop();
			sum += i-j;
			int a = i-j;
			while ( S2.size() > 0 && S2.top().first > j ){
				a += S2.top().second; S2.pop();
			}
			S2.push(make_pair(j,a));
		}
	}

    vector<int> ans;
	int t=0;
	while(S2.size()>0){ans.push_back(S2.top().second); S2.pop();}
	reverse(ans.begin(),ans.end());
	cout << sum << endl;
	cout << ans.size();
	for(int i = 0 ; i < ans.size(); i++){
		cout << " ";
		t += ans[i];
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3176
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

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

using namespace std;
typedef long long int ll;

int main() {
  ll n, m;
  cin >> n >> m;
  ll ans;
  if(n == 1 and m!= 1) ans= m-2;
  else if(m == 1 and n != 1) ans= n-2;
  else if(n == 1 and m == 1) ans =1;
  else ans = (m-2)*(n-2);

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

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

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
 //int ans=0;
 string s;
 cin>>s;
 if(s=="RRR")cout<<3<<endl;
 else if(s=="RRS")cout<<2<<endl;
 else if(s=="SRR")cout<<2<<endl;
 else if(s=="RSR")cout<<1<<endl;
 else if(s=="RSS")cout<<1<<endl;
 else if(s=="SRS")cout<<1<<endl;
 else if(s=="SSR")cout<<1<<endl;
 else cout<<0<<endl;
 
 
}



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

int main(){
    int n;
    cin >> n;

    vector<int> d(n);
    for(int i=0; i<n; i++){
        cin >> d[i];
    }

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

    int count = d[n/2] - d[n/2 - 1];
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int n, res, a, b;

int main()
{
	cin >> n >> a >> b;

	for (int i = 1; i <= n; ++i)
	{
		int x, sum;

		sum = 0; x = i;
		while (x > 0)
		{
			sum += x % 10;
			x /= 10;
		}

		if (a <= sum && sum <= b)
			res += i;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
ll W,H,x,y;
int main(){
    cin >> W >> H >> x >> y;
    double S = W*H/2.0000;

    cout << fixed << setprecision(10) << S << " ";
    if(2*x == W && 2*y == H) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
while true
  n, m = gets.chomp.split(' ').map(&:to_i)
  break if n == 0 && m == 0
  data = []
  n.times do
    d, p = gets.chomp.split(' ').map(&:to_i)
    data << [ p, d ]
  end
  data.sort!

  while true
    d = data[-1][1]
    if m > d
      m -= d
      data.pop
    elsif m == d
      data.pop
      break
    elsif m < d
      data[-1][1] -= m
      break
    end 
    break if data.size == 0
  end

  sum = 0
  data.each do |ary|
    sum += ary[0] * ary[1]
  end
  puts sum
end

Measured memory_bytes: 8920
# coding: utf-8

N = int(raw_input())

a, b, c = 2, 1, 3

if N == 0:
    print a
elif N == 1:
    print b
elif N == 2:
    print c

else:
    for i in range(N-2):
        a, b, c = b, c, (b+c)
    print c


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPEACH(i,k) for(auto& i:k)
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

signed main() {
	int n;
	cin >> n;
	vector<int> h(n);
	REP(i,n){
		cin >> h[i];
	}
	int max=0;
	int now=0;
	for(int i=0;i!=n-1;i++){
		if(h[i]>=h[i+1]){
			now++;
		}
		else{
			if(max<now){
				max=now;
			}
			now=0;
		}
	}
	if(max<now){
		max=now;
	}
	cout << max << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll a, b, c;
  ll k;
  cin >> a >> b >> c >> k;
  int ans = 0;
  if(k % 2 == 0) ans = a - b;
  else ans = b - a;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3548
s=input()[::-1]
ans=0
u=0
d=1
l=[0]*2019
l[0]=1
for i in map(int,s):
  u=(u+(i*d)%2019)%2019
  l[u]+=1
  d=d*10%2019
for i in l:
  ans+=i*(i-1)//2
print(ans)


Measured memory_bytes: 9368
import java.io.FileInputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static int h;
	static int[][] map;
	
	private static int calc()
	{
		int score = 0;
		
		// 消す
		for(int y = 0;y < h;y++)
		{
			// 消えるのは6通りしか無いので列挙
			if(map[y][0] == map[y][1] && map[y][1] == map[y][2] && map[y][2] == map[y][3] && map[y][3] == map[y][4])
			{
				score += map[y][0] * 5;
				map[y][0] = map[y][1] = map[y][2] = map[y][3] = map[y][4] = 0;
			}
			else if(map[y][0] == map[y][1] && map[y][1] == map[y][2] && map[y][2] == map[y][3])
			{
				score += map[y][0] * 4;
				map[y][0] = map[y][1] = map[y][2] = map[y][3] = 0;
			}
			else if(map[y][1] == map[y][2] && map[y][2] == map[y][3] && map[y][3] == map[y][4])
			{
				score += map[y][1] * 4;
				map[y][1] = map[y][2] = map[y][3] = map[y][4] = 0;
			}
			else if(map[y][0] == map[y][1] && map[y][1] == map[y][2])
			{
				score += map[y][0] * 3;
				map[y][0] = map[y][1] = map[y][2] = 0;
			}
			else if(map[y][1] == map[y][2] && map[y][2] == map[y][3])
			{
				score += map[y][1] * 3;
				map[y][1] = map[y][2] = map[y][3] = 0;
			}
			else if(map[y][2] == map[y][3] && map[y][3] == map[y][4])
			{
				score += map[y][2] * 3;
				map[y][2] = map[y][3] = map[y][4] = 0;
			}
		}
		
		// 落とす
		ArrayList<Integer> stock;
		for(int x = 0;x < 5;x++)
		{
			stock = new ArrayList<Integer>();
			for(int y = 0;y < h;y++)
			{
				if(map[y][x] != 0) stock.add(new Integer(map[y][x]));
			}
			
			for(int y = 0;y < h;y++)
			{
				if(y < stock.size())
					map[y][x] = stock.get(y).intValue();
				else
					map[y][x] = 0;
			}
		}
		
		return score;
	}
	
	private static void start()
	{
		int score = 0;
		while(true)
		{
			int dscore = 0;
			dscore = calc();
			if(dscore == 0) break;
			score += dscore;
		}
		
		System.out.println(score);
	}
	
	public static void main(String[] args)
	{
		Scanner sca = new Scanner(System.in);
		
		while(true)
		{
			h = sca.nextInt();
			if(h == 0) break;
			
			map = new int[h][5];
			for(int y = h-1;y >= 0;y--)
				for(int x = 0;x < 5;x++)
					map[y][x] = sca.nextInt();
			
			start();
		}
	}
}

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

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;
const int MOD = 1000000007;

typedef long long ll;

ll numZero(ll x)
{
    ll out = 0;
    while (x > 0) {
        out += (x /= 5) / 2;
    }
    return out;
}
int main()
{
    ll n;
    cin >> n;
    if (n % 2 == 1) {
        cout << 0 << endl;
    } else {
        cout << numZero(n) << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

typedef long long ll;

int asc(const void *arg1,const void *arg2) {return *((int *)arg2)-*((int *)arg1);}

int main(){
    ll n,a,b[9]={},sum=0;
    scanf("%lld",&n);
    for(int i=0;i<n;i++){
         scanf("%lld",&a);
         if(a<3200) b[a/400]=1;
         else b[8]++;
    }
    for(int i=0;i<8;i++) sum+=b[i];
    printf("%lld %lld",(sum>1)?sum:1,sum+b[8]);

    return 0;
}

Measured memory_bytes: 2116
N, Y = map(int, input().split(" "))
for i in range(N+1):
  for j in range(N+1-i):
    k = N-i-j
    if Y == (10000*k + 5000*j + 1000*i):
      print(k,j,i)
      exit(0)
print('-1 -1 -1')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,w;
    cin>>n>>w;
    vector<ll>W(n),V(n);
    for(ll i=0;i<n;i++)
    cin>>W[i]>>V[i];
    vector<vector<ll>>dp(n+2,vector<ll>(w+2,0));
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=w;j++)
        {
            if(j>=W[i-1])
            dp[i][j]=V[i-1]+dp[i-1][j-W[i-1]];
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
        }
    }
    cout<<dp[n][w];
}

Measured memory_bytes: 81024
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    s = input()
    if s[0] == 'A' and s[2:-1].count('C') == 1:
        for char in s:
            if not (char == 'A' or char == 'C' or char.islower()):
                break
        else:
            print('AC')
            exit()
    print('WA')



if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){   
   int n;
   cin>>n;
   int ans=0;
   for (int i = 1; i <= n; i+=2)
   {
      int count=0;
      for (int j = 1; j <= i; j++)
      {
         if(i%j==0){
            count++;
         }
      }
      if(count==8) ans++;
      
   }
   cout<<ans<<endl;
   
   


   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define repvin(n) vint a(n);r(i,n)cin>>a[i];
#define int long long
#define str string
#define vint vector<signed>
#define pint pair<signed,signed>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;

signed main(){
  int n;
  cin>>n;
  str s[n];
  rep(i,n)cin>>s[i];
  str march="MARCH";
  int sum[5]={0};
  rep(i,n)rep(j,5)if(s[i][0]==march[j])sum[j]++;
  int res=0;
  rep(i,5){
    for(int j=i+1;j<5;++j){
      for(int k=j+1;k<5;++k){
        res+=sum[i]*sum[j]*sum[k];
      }
    }
  }
  cout<<res<<endl;
  
  return 0;
}


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

int main(){
    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<long long int> a(x), b(y), c(z);
    for(int i=0; i<x; i++){
        cin >> a[i];
    }
    for(int i=0; i<y; i++){
        cin >> b[i];
    }
    for(int i=0; i<z; i++){
        cin >> c[i];
    }

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());

    sort(c.begin(),c.end());
    reverse(c.begin(),c.end());

    vector<long long int> cakes;
    int count = 0;
    for(int i=0; i<x; i++){
        for(int j=0; j<y; j++){
            for(int l=0; l<z; l++){
                if((i+1) * (j+1) * (l+1) <= k){
                    cakes.emplace_back(a[i] + b[j] + c[l]);
                    count += 1;
                }
            }
        }
    }
    cakes.resize(count);
    sort(cakes.begin(),cakes.end());
    reverse(cakes.begin(),cakes.end());

    for(int i=0; i<k; i++){
        cout << cakes[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 1404
pattern = input()
text = []
while True:
    tmp = input().split()
    if tmp[0] == "END_OF_TEXT":
        break
    text[len(text):len(text)] = tmp

count = 0
marks = "!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"
for i in range(len(text)):
    
    trim = text[i].lower()
    for mark in marks:
        trim = trim.replace(mark, "")
    word = trim
    
    if word == pattern:
        count += 1
    
print(count)



Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
int main(){
double a,b;cin>>a>>b;
int ans=-1;
bool s=false;
for(double i=0;i<=10000;i++){
    double c,d;
    c=i*0.08;
    d=i*0.1;
    if(c>=a&&c<(a+1)&&d>=b&&d<(b+1)){
        ans=i;
        s=true;
        }
if(s)break;
}

cout<<ans<<endl;




}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int main(){
  int N = 3;
  string tmp;
  cin >> tmp;
  string ans = "Yes";
  
  bool isOdd = true;
  for(int x=0;x < tmp.length(); x++)
  {
    if(isOdd)
    {
      if(tmp[x] == 'R' || tmp[x] == 'U' || tmp[x] == 'D')
      {
      }
      else
      {
        ans = "No";
        break;
      }
      isOdd = false;
    }
    else
    {
      if(tmp[x] == 'L' || tmp[x] == 'U' || tmp[x] == 'D')
      {
      }
      else
      {
        ans = "No";
        break;
      }
      isOdd = true;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	string a,b,s;
	string ans = "A";
	cin >> a >> s >> b;
	ans = ans + s[0] + "C";
	cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
            int a=sc.nextInt();
            int b=sc.nextInt();
            if (a>8 || b>8){
                System.out.println(":(");
            }else{
                System.out.println("Yay!");
            }
    }
}

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

using namespace std;

typedef long long ll;
ll c[100002];
ll d[100002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    
    ll n, x, m;
    cin >> n >> x >> m;
    ll ans = x;
    c[x] = (ll)1;
    d[1] = x;
    n -= (ll)1;
    ll start = (ll)1;

    while(n > 0){
        ll y = (x * x) % m;
        if(c[y] == 0){
            c[y] = ++start;
            d[c[y]] = d[c[y] - 1] + y;
            ans += y;
        }else{
            ll dif = (d[start] - d[c[y] - 1]);
            ll cnt = (start - c[y] + (ll)1);

            ans += (n / cnt) * dif;
            n %= cnt;

            for(int j = 0; j < n; j++){
                ans += y;
                y = (y * y) % m;
            }
            break;
        }
        x = y;
        n -= (ll)1;
    }

    cout << ans << '\n';
}


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

int main() {
    ll K; cin >> K;
    if (K == 2 || K == 5) {
        cout << -1 << endl;
        return 0;
    } else {
        ll x = 7;
        ll amari = 0;
        for (int i = 0; i < K; i++) {
            amari += x;
            if (amari % K == 0) {
                cout << i+1 << endl;
                return 0;
            }
            amari %= K;
            x *= 10;
            x %= K;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3636
S = list(input())
T = list(input())

if T in S:
    print(0)
    exit()

count_list = []
for n in range(len(S)-len(T)+1):
    count = 0
    for s, t in zip(S[n:n+len(T)], T):
        if s == t:
            count += 1
    count_list.append(count)

print(len(T)-max(count_list))

Measured memory_bytes: 8988
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
const long long Maxn=1e6;
typedef long long ll;

char a,b,c,d,e,f,g,h,i;

int main(){
	cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
	printf("%c%c%c",a,e,i);
}

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

#define int long long

typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N;
int a,d;
int M;
int x[222222],y[222222],z[222222];
int K;

signed main(){
    cin>>N>>a>>d>>M;
    rep(i,M)cin>>x[i]>>y[i]>>z[i],y[i]--,z[i]--;
    cin>>K;K--;

    int k=K;
    for(int i=M-1;i>=0;i--){
        if(x[i]||k<y[i]||z[i]<k)continue;
        int tmp=k-y[i];
        k=z[i]-tmp;
    }

    int v=a+d*k;

    rep(i,M){
        if(k<y[i]||z[i]<k)continue;
        if(x[i]==0){
            int tmp=k-y[i];
            k=z[i]-tmp;
        }
        else if(x[i]==1){
            v++;
        }
        else{
            v/=2;
        }
    }
    cout<<v<<endl;
    return 0;
}

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

using ll = long long;
using pint = pair<int, int>;

const ll INF = 1e12;

ll L, R;

int ans()
{
    if ((R - L + 1) >= 2019)
    {
        return 0;
    }

    int res = 2019;
    for (ll i = L; i <= R; ++i)
    {
        for (ll j = i + 1; j <= R; ++j)
        {
            int temp = (i * j) % 2019;
            res = min(temp, res);
        }
    }
    return res;
}

int main()
{
    cin >> L >> R;
    cout << ans() << endl;
}

Measured memory_bytes: 256
N = int(input())
happy = [list(map(int, input().split())) for _ in range(N)]
dp = [[-1]*3 for x in range(N)]

for i in range(3):
    dp[0][i] = happy[0][i]
    
for j in range(1, N):
    dp[j][0] = happy[j][0] + max(dp[j-1][1], dp[j-1][2])
    dp[j][1] = happy[j][1] + max(dp[j-1][0], dp[j-1][2])
    dp[j][2] = happy[j][2] + max(dp[j-1][0], dp[j-1][1])

print(max(dp[N-1][0], dp[N-1][1], dp[N-1][2]))

Measured memory_bytes: 47408
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

const int N=200010;
int n,m,fa[N];
int cnt[N],maxx;

int get(int x){
	if(x==fa[x]) return x;
	return fa[x]=get(fa[x]);
}
void merge(int x,int y){
	fa[get(x)]=get(y);
}

int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++) fa[i]=i;
    for(int i=1;i<=m;i++) {
    	int u,v;
    	cin>>u>>v;
    	merge(u,v);
	}
	for(int i=1;i<=n;i++) cnt[get(i)]++;
	for(int i=1;i<=n;i++) maxx=max(maxx,cnt[i]);
	cout<<maxx;
	return 0;
}

Measured memory_bytes: 10608
#include <stdio.h>

int main(int argc, char *argv[])
{
	int n;
	int d = 0;
scanf("%d", &n);
	for(;;){
		if(scanf(" %d", &n) != 1) break;
		if(n & 1) d++;
	}
	if(d & 1) printf("NO\n");
	else printf("YES\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

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

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=105;
//i_am_noob
int n,a[maxn];
bool ok=true;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	rep(n) cin >> a[i];
	rep(n) if(a[i]%2==0&&a[i]%3&&a[i]%5) ok=false;
	print1(ok?"APPROVED":"DENIED");
	return 0;
}

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

int K, A, B;

int main() {
    cin >> K;
    cin >> A >> B;

    string ans = "NG";

    for(int i = A; i <= B; i++) {
        if (i % K == 0) {
            ans = "OK";
        }
    }

    cout << ans << endl;
}

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

int edge_count[55];

int main() {
    int N, M, a, b;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        edge_count[--a]++;
        edge_count[--b]++;
    }
    for (int i = 0; i < N; i++) cout << edge_count[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define llu unsigned long long 
#define ll long long 
int read() { llu  x; if (scanf("%llu", &x) == -1)exit(0); return x; }
#define vi vector<int>
#define vb vector<bool>
#define LOCAL_JUDGE
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef LOCAL_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int gcd(int a, int b, int c) {
    return gcd(gcd(a, b), c);
}

int main() {
    //c_p_c();
    
    int k;
    cin >> k;

    int s = 0;
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            for (int t = 1; t <= k; ++t) {
                s += gcd(i, j, t);
            }
        }
    }
    cout << s << endl;

    return 0;
}



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

#define ll long long
#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf (int)(1e18)
#define ps(x, y) fixed << setprecision(y) << x
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(p) p.begin(), p.end()
#define ub(a, b) upper_bound(all(a), b)
#define lb(a, b) lower_bound(all(a), b)
#define PI 3.14159265
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void run()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void solution()
{
    int n;
    cin >> n;
    string ans;
    while (n)
    {
        int x = n % 26;
        if (x == 0)
        {
            ans += 'z';
            x = 26;
        }
        else
        {
            ans += (char)(x - 1 + 'a');
        }
        n -= x;
        n /= 26;
    }
    reverse(all(ans));
    cout << ans << endl;
}
int32_t main()
{
    run();
    solution();
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>

int main(){
	int a, b;
	
	while(std::cin >> a >> b){
		int n = a + b;
		int count = 1;
		//10??§?????£????????°????±???????
		while(n / 10 != 0){
			++count;
			n /= 10;
		}
		
		std::cout << count << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++ )

int main(){
  int data[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  int x, y;
  cin >> x >> y;
  if(data[x] == data[y]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int b1,b2,b3;
	cin>>b1>>b2>>b3;
	if(b1==1&&b2==0&&b3==0){
		cout<<"Close"<<endl;
	}else if(b1==0&&b2==1&&b3==0){
		cout<<"Close"<<endl;
	}else if(b1==1&&b2==1&&b3==0){
		cout<<"Open"<<endl;
	}else if(b1==0&&b2==0&&b3==1){
		cout<<"Open"<<endl;
	}else if(b1==0&&b2==0&&b3==0){
		cout<<"Close"<<endl;
	}
}

Measured memory_bytes: 1156
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
const long long inf = 1ll<<61;
const double eps = 0.000000000001;
typedef pair<int, int> P;
typedef pair<int ,P> PP;
struct edge { int to; int to2; int cost; };
double x[114514], y[114514];
char d[114514];
string SS = "LRUD";
int n; 
double tans(double t) {
	double mx = inf, MX = -inf, my = inf, MY = -inf;
	rep(i, n) {
		double nx, ny;
		if (d[i] == 'R') {
			nx = x[i] + t;
			ny = y[i];
		}
		if (d[i] == 'L') {
			nx = x[i] - t;
			ny = y[i];
		}
		if (d[i] == 'U') {
			nx = x[i];
			ny = y[i] + t;
		}
		if (d[i] == 'D') {
			nx = x[i];
			ny = y[i] - t;
		}
		mx = min(mx, nx);
		MX = max(MX, nx);
		my = min(my, ny);
		MY = max(MY, ny);
	}
	return (MX - mx)*(MY - my);
}

signed main() {
	cin >> n;
	rep(i, n)cin >> x[i] >> y[i] >> d[i];
	
/*	random_device rnd;
	mt19937 mt(rnd());
	rep(i, n) {
		x[i] = mt() % 200000000;
		x[i] -= 100000000;
		y[i] = mt() % 200000000;
		y[i] -= 100000000;
		d[i] = SS[mt() % 4];
	}*/


	double lb = 0, ub = 1e10;
	rep(i, 240) {
		double t1 = (2 * lb + ub) / 3;
		double t2 = (lb + 2 * ub) / 3;
		if (tans(t1)+eps < tans(t2))ub = t2;
		else lb = t1;
	}
//	printf("%.11lf\n", lb);
	printf("%.11lf\n", tans(lb));
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
//#define ls rt<<1
//#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=3e5+100;
const int N=2e5+100;
const int M=500+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

char s[N];
int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;cout.tie(0);
    int n;cin>>n>>(s+1);
    int l=1,r=n;
    int ans=0;
    while(l<=r)
    {
        if(s[l]==s[r])
        {
            if(s[l]=='W') r--;
            else l++;
        }
        else if(s[l]!=s[r])
        {
            if(s[l]=='W') ans++;
            l++;r--;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3748
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  string S;
  cin >> S;
  int N = S.size();
  int ans = N;
  {
    int count = 0;
    rep(i, N){
      if (S[i] != '1' - (i % 2)) count++;
    }
    ans = min(ans, count);
  }
  {
    int count = 0;
    rep(i, N){
      if (S[i] == '1' - (i % 2)) count++;
    }
    ans = min(ans, count);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
	
using namespace std;
	
#define endl "\n"
#define ll unsigned long long
#define int long long
#define vi vector <int >
#define vii vector < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define a first
#define b second

int32_t main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

	int dp[100010];
	int n;
	cin >> n;
	vi arr(n);
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	dp[0] = 0;
	dp[1] = abs(arr[0] - arr[1]);
	for(int i =  2; i <  n; i++){
		dp[i] = min(dp[i - 2] + abs(arr[i - 2] - arr[i]), dp[i - 1] + abs(arr[i - 1] - arr[i]));
	}
	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(){
 int a, b, c, hantei;
 hantei = 1;
 
 scanf("%d %d %d", &a, &b, &c);
 
 if ( (a >= b) || (b >= c) || (a >= c) ) {
   hantei = 0;
 }

 if (hantei == 1) {
   printf("Yes\n");
 } else {
   printf("No\n");
 }

 return 0;
}

Measured memory_bytes: 1796
import sys


def print_cards(cards: [str]) -> [str]:
    print(''.join(cards))


def shuffle(h: int, cards: [str]) -> [str]:
    return cards[h:] + cards[:h]


def resolve():
    for line in sys.stdin:
        line = line[:-1]  # reduce \n
        if line == '-':
            break
        if line.isalpha():
            cards = list(line)
            m = int(input())
            for _ in range(m):
                h = int(input())
                cards = shuffle(h, cards=cards)
            print_cards(cards)


resolve()



Measured memory_bytes: 5604
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

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

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		vector<int> data;
		data.clear();
		for(int i =0;i <n;i++){
			int x;
			cin>>x;
			data.push_back(x);
		}
		for(int i =0;i<m;i++){
			int x;
			cin>>x;
			data.push_back(x);
		}
		sort(data.begin(),data.end());
		int ans = 0;
		ans =data[0];
		for(int i =0;i <data.size()-1;i++){
			int tmp =data[i+1]-data[i];
			if(tmp>ans){
				ans =tmp;
			}
		}
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1348
N=int(input())
res =[0]
def rep(n,ans):
    if len(set(str(n)))==3 and n<=N:
        res[0]+=1
        return rep(n*10+3,ans+1)+rep(n*10+5,ans+1)+rep(n*10+7,ans+1)
    elif n<=N:
        for i in [3,5,7]:
            return sum([rep(n*10+i,ans) for i in [3,5,7]])
    else:
        return ans
for i in [3,5,7]:
    rep(i,0)
print(res[0])

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

  int main() {
    int N, M;
    cin >> N >> M;
    vector<int> city(N);
    vector<int> node(2*M);
    vector<int> sum(N, 0);
    for (int i = 0; i < M; i++) {
      for (int j = 0; j < 2; j++) {
        cin >> node.at(2*i+j);
        for (int k = 0; k < N; k++) {
          city.at(k) = k+1;
          if (node.at(2*i+j) == city.at(k)) {
            sum.at(k) += 1;
          }
        }    
      }
    }
    for (int l = 0; l < N; l++) {
      cout << sum.at(l) << endl;
    }
  }


Measured memory_bytes: 256
# 2019-11-26 01:21:13(JST)
import sys
import numpy as np 

def main():
    H, W = map(int, sys.stdin.readline().split())
    visited = np.array([sys.stdin.readline().rstrip() + '.' for _ in range(H)], dtype='U')
    visited = np.append(visited, '.' * (W + 1))

    if np.char.count(visited, '#').sum() != H + W - 1:
        print('Impossible')
        sys.exit()
    
    h, w = 0, 0
    for _ in range(H + W - 2):
        if visited[h+1][w] == '#' and visited[h][w+1] == '.':
            h += 1
        elif visited[h+1][w] == '.' and visited[h][w+1] == '#':
            w += 1
        else:
            print('Impossible')

    print('Possible')


if __name__ == '__main__':
    main()


Measured memory_bytes: 12508