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

using namespace std; 
const int MAX_N = 100005; 
vector <int> adj[MAX_N], topo; 
int f[MAX_N], mark[MAX_N]; 
int n, m, res; 

void DFS(int u) {
	mark[u] = 1;
	for (int i = 0; i < (int) adj[u].size(); i++) {
		int v = adj[u][i]; 
		if (!mark[v]) DFS(v);
	}
	topo.push_back(u);
}

int main () {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%d %d", &n, &m); 
	for (int i = 1; i <= m; i++) {
		int u, v; 
		scanf("%d %d", &u, &v); 
		adj[u].push_back(v);
	}

	for (int i = 1; i <= n; ++i) {
		if (!mark[i]) DFS(i);
	}

	reverse(topo.begin(), topo.end());

	for (int i = 0; i < topo.size(); ++i) {
		int u = topo[i];
		res = max(res, f[u]);
		for (int j = 0; j < adj[u].size(); ++j) {
			int v = adj[u][j];
			f[v] = max(f[v], f[u] + 1);
		}
	}
	// res = longest path
	cout << res << '\n';
	return 0; 
}

Measured memory_bytes: 9080
N,M=map(int,input().split())
li=["&"]*N
a=True
for i in range(M):
    s,c=map(int,input().split())
    if s==1 and c==0 and N!=1:
        ans="-1"
        a=False
    else:
        if li[s-1]=="&":
            li[s-1]=c
        else:
            if li[s-1]==c:
                pass
            else:
                ans="-1"
                a=False
if a==True:
    ans=""
    for j in range(N):
        if li[j]=="&" and j!=0:
            li[j]=0
        elif li[j]=="&" and j==0 and N!=1:
            li[j]=1
        elif li[j]=="&" and j==0 and N==1:
            li[j]=0
        ans+=str(li[j])
print(ans)



Measured memory_bytes: 9208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var v = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var c = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var sum = 0;
            for(var i =0;i<v.Length;i++)
            {
                var tmp = v[i] - c[i];
                if (0 < tmp) sum += tmp;
            }
            Console.WriteLine(sum);
        }
    }
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;
#define debug(x) cerr << #x << ": " << (x) << "\n";

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

  string sa, sb, sc;
  cin >> sa >> sb >> sc;
  queue<char> a, b, c;
  for (char ch: sa) {
    a.push(ch);
  }
  for (char ch: sb) {
    b.push(ch);
  }
  for (char ch: sc) {
    c.push(ch);
  }

  char turn = 'a';
  while (1) {
    if (turn == 'a') {
      if (a.empty()) {
        cout << 'A' << endl;
        break;
      }
      turn = a.front(); a.pop();
    } else if (turn == 'b') {
      if (b.empty()) {
        cout << 'B' << endl;
        break;
      }
      turn = b.front(); b.pop();
    } else {
      if (c.empty()) {
        cout << 'C' << endl;
        break;
      }
      turn = c.front(); c.pop();
    }
  }

  return 0;
};


Measured memory_bytes: 256
N, D = (int(item) for item in input().split())

import numpy as np

def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()
      
grid = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    grid.append(array)

cnt=0
for i in range(N):
  for j in range(i+1,N):
    d = np.linalg.norm(np.array(grid[i])-np.array(grid[j]))
    if is_integer(d):
      cnt+=1
print(cnt)
    

Measured memory_bytes: 12484
import java.util.Scanner;

public class Main {
    public static void main(String[]args){
        int a,b,sub1,sub2;
        Scanner in= new Scanner(System.in);
        a=in.nextInt(); b=in.nextInt();
        sub1=a+b;
        if(sub1%2==0)
            System.out.println(""+(sub1/2));
        else
            System.out.println("IMPOSSIBLE");
    }
}


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

int main()
{ 
  int n; cin >> n;
  vector<int> ns;
  for (int i = 0; i < n; i++) {
    int k; cin >> k;
    ns.push_back(k);
  }
  int q; cin >> q;
  int ans = 0;
  while (q--) {
    int k; cin >> k;
    for (int i = 0; i < n; i++) {
      if (k == ns[i]) {
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
  return EXIT_SUCCESS;
}



Measured memory_bytes: 3204
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
bitset<16005> dpx[16005],dpy[16005];
ll mid=8000;
int main(){
string s;
cin>>s;
int x,y;
cin>>x>>y;
dpx[0][mid]=1;dpy[0][mid]=1;
int n=s.size();
int j=1;
int t=0,cnt=0;
for(int i=0;i<n;){
    if(t%2==0){
        while(i<n&&s[i]!='T'){
            i++;
            cnt++;
        }
        if(j==1){
            dpx[j]|=(dpx[0]<<cnt);
        }
        else{
            dpx[j]|=(dpx[j-1]<<cnt);
            dpx[j]|=(dpx[j-1]>>cnt);
        }
        cnt=0;
        j++;
    }
    if(s[i]=='T'){
    while(i<n&&s[i]=='T'){
        i++;
        t++;
    }
    }
    else i++;
}
int k=1;
t=0;
for(int i=0;i<n;){
    if(t%2==1){
        while(i<n&&s[i]!='T'){
            i++;
            cnt++;
        }
         dpy[k]|=(dpy[k-1]<<cnt);
         dpy[k]|=(dpy[k-1]>>cnt);
        k++;
        cnt=0;
    }
   if(s[i]=='T'){
    while(i<n&&s[i]=='T'){
        i++;
        t++;
    }
    }
    else i++;
}
if(dpx[j-1][x+mid]&&dpy[k-1][y+mid])cout<<"Yes"<<"\n";
else cout<<"No"<<"\n";
}

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

using namespace std;

int n, v[101], w[101], W;
long long dp[100100];

void solve() {
  for (int i = 0; i < n; i++)
    for (int j = W; j >= w[i]; j--)
      dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
  printf("%lld",dp[W]);
}

int main () {
	cin >> n;
	cin >> W;
	for (int i = 0; i < n; i++)
		cin >> w[i] >> v[i];
	solve();
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e14;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;

void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const ll MAXN = 1e6 + 10;
const ll N = 4000 + 10;
const ll MN = 200 + 10;
const ll mod = 1e9 + 7;

ll dp[N][N] , par[N][N];

int main()
{
	faster();
	string s , t;
	cin >> s >> t;
	int n = s.size() , m = t.size();
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if(dp[i + 1][j] > dp[i][j + 1])
			{
				par[i + 1][j + 1] = 2;
				dp[i + 1][j + 1] = dp[i + 1][j];
			}
			else
			{
				par[i + 1][j + 1] = 3;
				dp[i + 1][j + 1] = dp[i][j + 1];
			}
			if(s[i] == t[j])
			{
				if(dp[i][j] + 1 > dp[i + 1][j + 1])
				{
					par[i + 1][j + 1] = 1;
					dp[i + 1][j + 1] = dp[i][j] + 1;
				}
			}
		}
	}
	string k;
	while(par[n][m] != 0)
	{
		if(par[n][m] == 1)
		{
			k.push_back(s[n - 1]);
			n--;
			m--;
		}
		if(par[n][m] == 2)
		{
			m--;
		}
		if(par[n][m] == 3)
		{
			n--;
		}
	}
	reverse(k.begin(), k.end());
	cout << k << endl;
}

Measured memory_bytes: 190464
#include <iostream>
using namespace std;
  
int main(void){
        string Taro;
        string Hanako;
        int n;
        cin>>n;
        int taro_score=0;
        int hanako_score=0;
        for(int i=0; i<n; i++) {
                cin>>Taro>>Hanako;
                if(Taro==Hanako) {
                        taro_score+=1;
                        hanako_score+=1;
                }
                else if(Taro<Hanako) {
                        hanako_score+=3;
                }
                else{
                        taro_score+=3;
                }
        }
        cout<<taro_score<<" "<<hanako_score<<endl;
}


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

int main()
{
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> xx(n);
  vector<int> yy(m);
  int i;
  int xmax = -100;
  int ymin = 100;
  for(i = 0; i < n; i++)
  {
    cin >> xx.at(i);
    if(xx.at(i) > xmax)
    {
      xmax = xx.at(i);
    }
  }
  for(i = 0; i < m; i++)
  {
    cin >> yy.at(i);
    if(yy.at(i) < ymin)
    {
      ymin = yy.at(i);
    }
  }
  int x2max = max(xmax, x);
  int y2min = min(ymin, y);
  if(x2max < y2min) cout << "No War" << endl;
  else cout << "War" << endl;
}

Measured memory_bytes: 256
#A
N=int(input())
print(sum(i for i in range(1,N+1)))

#C
if False:
    N=int(input())
    V=[int(i) for i in input().split()]
    K=list(set(V))
    if len(K)==1:
        print(N//2)
        exit()

    cnt={}
    cnt[-1]=0
    for k in K:
        cnt[k]=0
    for i in range(0,N,2):
        cnt[V[i]]+=1
    ev_MAX=0
    sec_ev_MAX=0
    ev=-1
    ev_cnt=[(cnt[k],k) for k in K]
    ev_cnt.sort(key=lambda x: x[0],reverse=True)
    ev=ev_cnt[0][1]
    ev_MAX=ev_cnt[0][0]
    sec_ev_MAX=0 if len(ev_cnt)<2 else ev_cnt[1][0]
    # print(ev_cnt)
    cnt={}
    cnt[-1]=0
    for k in K:
        cnt[k]=0
    for i in range(1,N,2):
        cnt[V[i]]+=1
    od_MAX=0
    sec_od_MAX=0
    od=-1
    od_cnt=[(cnt[k],k) for k in K]
    od_cnt.sort(key=lambda x: x[0],reverse=True)
    od=od_cnt[0][1]
    od_MAX=od_cnt[0][0]
    sec_od_MAX=0 if len(od_cnt)<2 else od_cnt[1][0]

    ans=0
    if od!=ev:
        # print('#',1)
        ans+=N//2-ev_MAX
        ans+=N//2-od_MAX
    else:
        # print(sec_ev_MAX,od_MAX,sec_od_MAX,ev_MAX)
        ans+=min(N//2-sec_ev_MAX+N//2-od_MAX,N//2-sec_od_MAX+N//2-ev_MAX)
    print(ans)

#D
#N,L=map(int,input().split())


Measured memory_bytes: 3064
N=int(input())
a=list(map(str,input().split()))
s=0
box=[]
dp={}
for x in a:
    s+=int(x)
    if x not in dp.keys():
        dp[x]=1
    else:
        dp[x]=dp[x]+1
q=int(input())
for i in range(q):
    b,c=map(str,input().split())
    if b not in dp.keys():
        box.append(s)
        continue
    s+=int(dp[b])*(int(c)-int(b))
    if c not in dp.keys():
        dp[c]=dp[b]
    else:
        dp[c]+=dp[b]
    del dp[b]
    box.append(s)
for x in box:
    print(x)


Measured memory_bytes: 96400
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n, ans = 0;
	string s;
	vector<int> pos[10];
	cin >> n >> s;
	for (int i = 0; i < n; i++) pos[s[i] - '0'].push_back(i);
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			for (int k = 0; k < 10; k++)
				if (!pos[i].empty()) {
					if (!pos[j].empty() && pos[j].back() > pos[i].front()) {
						if (upper_bound(pos[k].begin(), pos[k].end(), *upper_bound(pos[j].begin(), pos[j].end(), pos[i].front())) != pos[k].end()) ans++;
					}
				}
	cout << ans << endl;
}


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

int main(){
  
  int a;
  cin >> a;
  
  int ans = 0;
  if(a%10 == 1)ans += 1;
  if(a%100/10 == 1)ans += 1;
  if(a/100 == 1)ans += 1;
  
  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

#define MP make_pair
#define MT make_tuple
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	LL MOD = 1e9 + 7;
	LL n, m;
	cin >> n >> m;

	if(1 < abs(n - m)){
		cout << 0 << endl;
	}
	else{
		LL ret = 1;
		if(abs(n - m) == 0) ret *= 2;
		while(n){
			ret *= n;
			ret %= MOD;
			n--;
		}
		while(m){
			ret *= m;
			ret %= MOD;
			m--;
		}
		cout << ret << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int count = 1000;

		while(n > count) {
			count += 1000;
		}

		System.out.println(count - n);
	}
}


Measured memory_bytes: 35800
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    vector<pair<int,int>> a;
    while(true){
        int n,x;cin>>n>>x;
        if(n==0&&x==0) break;
        a.push_back(make_pair(n,x));
    }
    for(int i=0;i<a.size();i++){
        int ans=0;
        int n,x;
        n=a[i].first;
        x=a[i].second;
        for(int i=1;i<=n-2;i++){
            for(int j=i+1;j<=n-1;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+k+j==x) ans++;
                }
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3108
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main() {

	double n,k;
	cin >> n >> k;
	double ans=0;
	int r;
	if(n>=k){
		ans=(n-k+1)/n;
		r=k-1;
	}else{
		r=n;
	}
	
	for(int i=1;i<=r;i++){
		double rate_now=1/n;
		double temp=i;
		while(temp<k){
			rate_now*=0.5;
			temp*=2;
		}
		ans+=rate_now;
	}
	
	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [(-1)*int(input()) for _ in range(n)]
dp = [10**18 for _ in range(n)]

import bisect
def lis(a):
	"""
	param a: list
	return: the length of Longest increasing subsequence
	(be careful that [list] seq is not the LIS, but its length is accurate LIS length.)
	"""
	seq = []
	tmp = 0
	for i in a:
		pos = bisect.bisect_right(seq, i)
		if tmp <= pos:
			seq.append(i)
			tmp += 1
		else:
			seq[pos] = i
	return tmp

print(lis(a))

Measured memory_bytes: 14276
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int k;
	long long int a[100001], min[100001], max[100001];
	scanf("%d", &k);
	for(int i=1; i<=k; i++){
		scanf("%lld", &a[i]);
	}
	min[k]=2, max[k]=2;
	if(a[k]!=2){
		printf("%d\n", -1);
		return 0;
	}
	for(int i=k-1; i>=0; i--){
		long long int r1=(min[i+1]+a[i+1]-1)/a[i+1], r2=max[i+1]/a[i+1];
		if(max[i+1]<r1*a[i+1]){
			printf("%d\n", -1);
			return 0;
		}else{
			min[i]=r1*a[i+1];
			max[i]=r2*a[i+1]+a[i+1]-1;
		}
	}
	printf("%lld %lld\n", min[0], max[0]);

	return 0;
}

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

int main(){
  int n,m,l,i,j,k;
  long long a[101][101] = {0};
  long long b[101][101] = {0};
  long c[101][101] = {0};

  cin >> n >> m >> l;
  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  for(j = 0; j < m; j++){
    for(k = 0; k < l; k++){
      cin >> b[j][k];
    }
  }
  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      for(k = 0; k < l; k++){
        c[i][k] += a[i][j] * b[j][k];
      }
    }
  }
  for(i = 0; i < n; i++){
    for(k = 0; k < l - 1; k++){
      cout << c[i][k] << " ";
    }
    cout << c[i][l-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1416
#include "algorithm"
#include "iomanip"
#include "iostream"
#include "queue"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
void drop(const T& x) {
  cout << x << endl;
  exit(0);
}

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

  string S;
  cin >> S;

  if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()

row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '#':
			row[i] = True
			col[j] = True

for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end = '')
		print()



Measured memory_bytes: 4468
primes = Array.new(1000000, true)
primes[0], primes[1] = false, false

(2..Math.sqrt(1000001)).each do |i|
    if primes[i]
        (2 * i).step(1000001, i).each do |j|
            primes[j] = false
        end
    end
end

while n = gets
    n = n.to_i
    puts primes.slice(0..n).count(true)
end

Measured memory_bytes: 20348
h,w = map(int,input().split())
ans = float('inf')
for i in range(1,h):
    sa = i*w
    sb = (h-i)*int(w//2)
    sc = (h-i)*(w-int(w//2))
    sd = (h-i-int((h-i)//2))*w
    se = (int((h-i)//2))*w
    s_max1 = max(sa,sb,sc)
    s_min1 = min(sa,sb,sc)
    s_max2 = max(sa,sd,se)
    s_min2 = min(sa,sd,se)
    ans = min(ans,s_max1-s_min1,s_max2-s_min2)
for i in range(1,w):
    sa = i*h
    sb = (w-i)*int(h//2)
    sc = (w-i)*(h-int(h//2))
    sd = (w-i-int((w-i)//2))*h
    se = (int((w-i)//2))*h
    s_max1 = max(sa,sb,sc)
    s_min1 = min(sa,sb,sc)
    s_max2 = max(sa,sd,se)
    s_min2 = min(sa,sd,se)
    ans = min(ans,s_max1-s_min1,s_max2-s_min2)
print(ans)


Measured memory_bytes: 73540
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int A, B;
    cin >> A >> B;
    
    cout << fixed << setprecision(20);

    if (A >= 13) cout << B << endl;
    else if(A >= 6) cout << int(B / 2) << endl;
    else cout << 0 << endl;

}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n),b(n-1);
    for(int i=0;i<n-1;i++)
    {
        cin >> b[i];
    }
    
    a[0] = a[1] = b[0];
    for(int i=1;i<n-1;i++)
    {
        if(a[i] > b[i])
        {
            a[i] = a[i+1] = b[i];
        }
        else
        {
            a[i+1] = b[i];
        }
    }
    long long sum = 0;
    for(int i=0;i<n;i++)
    {
        sum += a[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
a,b,k = map(int,input().split())
if a > 0:
    if a == k:
        print(0,b)
    elif a > k:
        print(a-k,b)
    elif k > a and k-a>=b:
        print(0,0)
    elif k > a and b >k-a:
        print(0,b-(k-a))
if a ==0 :
    if b > k:
        print(0,b-k)
    elif k >= b:
        print(0,0)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(15);

  string s;
  cin >> s;
  int ret = -1;
  if(s == "SUN"){
    ret = 7;
  }
  else if(s == "MON"){
    ret = 6;
  }
  else if(s == "TUE"){
    ret = 5;
  }
  else if(s == "WED"){
    ret = 4;
  }
  else if(s == "THU"){
    ret = 3;
  }
  else if(s == "FRI"){
    ret = 2;
  }
  else if(s == "SAT"){
    ret = 1;
  }

  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a[5];
  int k;
  int i, j;
  
  for(i = 0;i < 5;i++){
    scanf("%d", &a[i]);
  }
  scanf("%d", &k);
  
  for(i = 0;i < 4;i++){
    switch(i){
      case 0:
        for(j = 1;j < 5;j++){
          if(a[j] - a[i] > k){
            printf(":(\n");
            return 0;
          }
        }
        break;
      case 1:
        for(j = 2;j < 5;j++){
          if(a[j] - a[i] > k){
            printf(":(\n");
            return 0;
          }
        }
        break;
      case 2:
        for(j = 3;j < 5;j++){
          if(a[j] - a[i] > k){
            printf(":(\n");
            return 0;
          }
        }
        break;
      case 3:
        for(j = 4;j < 5;j++){
          if(a[j] - a[i] > k){
            printf(":(\n");
            return 0;
          }
        }
        break;
    }
  }
    printf("Yay!\n");
    return 0;
}
  
  

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

struct Node {
    int key;
    struct Node *next,*prev;
};

struct Node *nil;

struct Node* listSearch(int key){
    struct Node *cur = nil->next; //番兵の次の要素からたどる
    while( cur != nil && cur->key != key){
        cur=cur->next;
    }
    return cur; //cur は現在位置のノードポインタ
}

void input(){ //リストの初期化
    nil = (struct Node *)malloc(sizeof(struct Node));
    nil->next=nil;
    nil->prev=nil;
}

void print(){
    struct Node *cur = nil->next;
    int i = 0;
    while(1){
        if( cur == nil) break;
        if( i++>0 ) printf(" ");
        printf("%d",cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(struct Node *t){
    if(t==nil) return; //tが番兵と同値なら処理しない
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deletefirst(){
    deleteNode(nil->next);
}

void deletelast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){//検索したノードを除去
    deleteNode(listSearch(key));
}

void insert(int key){
    struct Node *x = (struct Node *)malloc(sizeof(struct Node));
    x->key = key; //番兵の直後に要素を追加
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main(){
    int key,n,i;
    int size = 0;
    char com[20];
    int np=0,nd=0;
    
    scanf("%d",&n);
    
    input();
    
    for(i=0;i<n;i++){
        scanf(" %s %d",com,&key);
        if( com[0] == 'i'){
            insert(key);
            np++;
            size++;
        }else if( com[0] == 'd'){
            if(strlen(com) > 6){
                if(com[6]=='F') deletefirst();
                else if( com[6]=='L') deletelast();
            }else{
                deleteKey(key);
                nd++;
            }
            size--;
        }
    }
    
    print();
    
    return 0;
    
}



Measured memory_bytes: 32952
#[allow(dead_code)]
const MOD: usize = 1_000000000 + 7;

fn main() {
    let mut cin = Scanner::new();
    let n = cin.next_usize();
    let m = cin.next_usize();
    let r = cin.next_usize();
    let ri = (0..r).map(|_| cin.next_usize() - 1).collect::<Vec<usize>>();
    let inf = 1<<29;
    let mut dist = vec![vec![inf; n]; n];
    for _ in 0..m {
        let a = cin.next_usize() - 1;
        let b = cin.next_usize() - 1;
        let c = cin.next_usize();
        dist[a][b] = c;
        dist[b][a] = c;
    }
    for i in 0..n { dist[i][i] = 0; }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                dist[i][j] = std::cmp::min(dist[i][j], dist[i][k] + dist[k][j])
            }
        }
    }
    let mut dp = vec![vec![inf; 1<<r]; r];
    for i in 0..r { dp[i][1<<i] = 0 }
    for i in 1..1<<r {
        for j in 0..r {
            for k in 0..r {
                dp[k][i|1<<k] = std::cmp::min(dp[k][i|1<<k], dp[j][i] + dist[ri[j]][ri[k]])
            }
        }
    }
    println!("{}", (0..r).map(|i| dp[i][(1<<r)-1]).min().unwrap());
}


struct Scanner {
    reader: std::io::Stdin,
    tokens: std::collections::VecDeque<String>,
}

impl Scanner {
    fn new() -> Self {
        Scanner {
            reader: std::io::stdin(),
            tokens: std::collections::VecDeque::new(),
        }
    }

    fn next(&mut self) -> String {
        if self.tokens.is_empty() {
            let mut s = String::new();
            loop {
                self.reader.read_line(&mut s).ok();
                let s = s.trim();
                if s.len() != 0 {
                    for it in s.split_whitespace() {
                        self.tokens.push_back(it.into())
                    }
                    break;
                }
            }
        }
        self.tokens.pop_front().unwrap()
    }

    fn next_generics<T>(&mut self) -> T where
        T: std::str::FromStr + std::marker::Copy,
        <T as std::str::FromStr>::Err: std::fmt::Debug
    {
        self.next().parse().unwrap()
    }
    
    #[allow(dead_code)] fn next_i32(&mut self) -> i32 { self.next_generics::<i32>() }
    #[allow(dead_code)] fn next_i64(&mut self) -> i64 { self.next_generics::<i64>() }
    #[allow(dead_code)] fn next_u64(&mut self) -> u64 { self.next_generics::<u64>() }
    #[allow(dead_code)] fn next_usize(&mut self) -> usize { self.next_generics::<usize>() }
    #[allow(dead_code)] fn next_isize(&mut self) -> isize { self.next_generics::<isize>() }
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/*天才だから気づいてしまったのですが、
奇数番目にあるやつをいくら操作2でスワップしても
奇数番目にしか動けないんですね
 */
int main(){
    int n;
    cin>>n;
    vector<ll> a(n),ac(n);
    rep(i,n){
        cin>>a[i];
        ac[i]=a[i];
    }
    sort(ALL(ac));
    map<ll,int> mp;
    rep(i,n){
        mp[ac[i]]=i;
    }
    int ans=0;
    rep(i,n){
        int j=mp[a[i]];
        if(i%2==0&&j%2==1) ans++;
        else if(i%2==1&&j%2==0) ans++;
    }
    cout<<ans/2<<endl;
    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

signed main(){
    int n, t, q;
    cin >> n >> t >> q;
    vector<int> a(n + 1), d(n + 1), x(q);
    rep(i, 0, n) cin >> a[i] >> d[i];
    rep(i, 0, q) cin >> x[i];
    vector<int> ans(n);
    int l = 0, r = n;
    rep(i, 0, n){
        if(d[i] == 1){
            l = i; break;
        }
        ans[i] = a[i] - t;
    }
    repb(i, n - 1, 0){
        if(d[i] == 2){
            r = i + 1; break;
        }
        ans[i] = a[i] + t;
    }
    d[r] = 1;
    int st = l, now = 1, tmp = 0;
    rep(i, l, r + 1){
        if(d[i] == now) continue;
        if(d[i] == 2) tmp = (a[i - 1] + a[i]) / 2;
        if(d[i] == 1){
            rep(j, st, i){
                if(abs(a[j] - tmp) <= t) ans[j] = tmp;
                else if(d[j] == 1) ans[j] = a[j] + t;
                else ans[j] = a[j] - t;
            }
            st = i;
        }
        now = d[i];
    }
    rep(i, 0, q){
        cout << ans[x[i] - 1] << endl;
    }
}

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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define eps 1e-9
#define fast_cin ios_base::sync_with_stdio(false)

const int MOD = 1e9+7;

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

int main()
{
	//freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	fast_cin;
	ll n, m;
	cin >> n >> m;
	cout << (n-1)*(m-1) << endl;

	return 0;
}

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

int main() {
  long   i,j,k,m,l,n,s2=0;
  cin>>n;
  int a[n],b[n],c[n-1];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  for(i=0;i<n;i++)
  {
  cin>>b[i];
  }
  for(i=0;i<n-1;i++)
  {
    cin>>c[i];
  }
  long long s1=accumulate(b,b+n,(0));
  for(i=0;i<n-1;i++)
  {
    if(a[i]+1==a[i+1])
    {
      s2+=(c[a[i]-1]);
    }
  }
    cout<<s1+s2<<endl;
  return 0;
}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main(void){
    int n,i,count=0;
    int flag=0;
    cin>>n;
    for(i=0;i<n;i++){
        int tmp1,tmp2;
        cin>>tmp1>>tmp2;
        if(tmp1==tmp2){
            count++;
            if(count==3){
                flag=1;
            }
        }else{
            count=0;
        }
    }
    if(flag==1){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b;
}


Measured memory_bytes: 3632
N=int(input())
T,A=map(int,input().split(" "))
H=list(map(int,input().split(" ")))
for i,items in enumerate(H):
  H[i]=T-items*0.006-A
  if(H[i]<0):
    H[i]=-H[i]
print(H.index(min(H))+1)




Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int n;  cin >> n;
    map<int,int> nNum[2];
    for(int i=0; i<n; i++){
        int v;  cin >> v;
        int evenOdd = i%2;
        if(nNum[evenOdd].find(v) == nNum[evenOdd].end()){
            nNum[evenOdd][v] = 1;
        }else{
            nNum[evenOdd][v]++;
        }
    }

    vector<P> cntList[2];
    for(int i=0; i<2; i++){
        for(auto itr=nNum[i].begin(); itr!=nNum[i].end(); itr++){
            cntList[i].push_back(P(itr->second, itr->first));
        }
        sort(cntList[i].begin(), cntList[i].end());
    }

    int ans = n;
    int lenEven = cntList[0].size(), lenOdd = cntList[1].size();
    for(int i=0; i< min(2, lenEven); i++){
        for(int j=0; j<min(2, lenOdd); j++){
            if(cntList[0][lenEven-1-i].second != cntList[1][lenOdd-1-j].second){
                ans = min(n - cntList[0][lenEven-1-i].first - cntList[1][lenOdd-1-j].first, ans);
            }
        }
    }
    if(ans == n) cout << ans/2 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 6136
#!/usr/bin/env python3
n = int(input())
a = list(map(lambda x: int(x) - 1, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
s = 0
for i in range(n):
    s += b[a[i]]
for i in range(n - 1):
    if a[i] + 1 == a[i + 1]:
        s += c[a[i]]
print(s)


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

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

	for (int i = 0; i < s.size(); i++){
		for (char j = 'a'; j <= 'z'; j++){
			if(s.find(j)== string::npos){
				cout<<j<<endl;
				return 0;
			}
		}
	}

	cout<<"None"<<endl;

}


Measured memory_bytes: 512
#include <iostream>

int main()
{
	int w, h, x, y, r;
	std::cin >> w >> h >> x >> y >> r;
	if (0 <= x-r && x+r <= w && 0 <= y-r && y+r <= h)
		std::cout << "Yes" << '\n';
	else std::cout << "No" << '\n';
}

Measured memory_bytes: 3044
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  ll x,y,ans=0,tmp=1;
  cin>>x>>y;
  tmp=x;
  while(x<=tmp&&tmp<=y){
    ans++;
    tmp=tmp*2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int K,i,l;
  int number[101];//array
  scanf("%d",&K);
  for(i=1;i<=K;i=i+1){
    scanf("%d",&number[i]);
  }
  int a = 0, b = 0;
  for(i=1;i<=K;i=i+1){
    int p = 1;
    for(l=1;l<=K;l=l+1){
      if(number[l] > number[p]) {
        p = l;
      }
    }
    if (i %2==0)
    b=b+number[p];
    else
    a=a+number[p];
    number[p] = -1;
  }
  int ans=a-b;
  printf("%d\n",ans); 
  return 0;
}

Measured memory_bytes: 2080
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define db double
#define pb push_back
#define wrln cout<<'\n';
#define pii pair<int,int>

using namespace std;
const int H=1e9+7;
const int N=2e5+100;

int n,m,u,v,res,dem;
vector <int> ke[N];
bool kt[N];

void dfs(int u)
{
    kt[u]=1;
    dem++;
    for (auto v:ke[u])
    {
        if (!kt[v])
        {
            dfs(v);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.flush();

   // freopen("test11.INP","r",stdin);
   // freopen("test.OUT","w",stdout);
    cin>>n>>m;
    while (m--)
    {
        cin>>u>>v;
        ke[u].pb(v);
        ke[v].pb(u);
    }

    int res=0;

    for (int i=1; i<=n; i++)
    {
        if (!kt[i])
        {
            dem=0;
            dfs(i);
            res=max(dem,res);
        }
    }

    cout<<res;

}


Measured memory_bytes: 20988
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,m;
	std::cin >> n >> m;
	if(n==m) print("Yes");
	else print("No");
	return 0;
}


Measured memory_bytes: 764
import sys
from functools import reduce

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B = lr()
MOD = 10 ** 9 + 7

def F(A):
    num = reduce(lambda x, y: x * y % MOD, range(N, N-A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A+1))
    return num * pow(den, MOD-2, MOD) % MOD

answer = pow(2, N, MOD) - F(A) - F(B) - 1
print(answer % MOD)


Measured memory_bytes: 3572
n, m = map(int, input().split())
a = []
for i in range(m):
  a.append(int(input()))
ans = 0
flag = 0
a = set(a)

#フィボナッチ数列の初期値を調節
dp = [0] * (n+1)
dp[0] = 1
if 1 in a:
  dp[1] = 0
else:
  dp[1] = 1
  
for i in range(2, n+1):
  if dp[i-2] == 0 and dp[i-1] == 0:
    ans = 0
    flag = 1
    break
  elif i in a:
    continue
  else:
    dp[i] = dp[i-1] + dp[i-2]
if flag == 0:
  ans = dp[n]
print(ans%(10**9+7))

Measured memory_bytes: 460020
#include <stdio.h>
int main(void){
    long int a, m=100;
    do{
      scanf("%ld",&a);
    }while(a<101 || a>1000000000000000000);  
    long int i, r=1, count=0;
    while(r){
      m=m*1.01;
      count++;
      if(m>=a){
        r=0;  
      }
    }
    printf("%ld\n",count);
    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
using namespace std;
int main() {
  int N;
  string S;
  cin >> N >> S;
  if (N % 2 == 1) {
	  cout << "No" << endl;
	}
  else {
	  if (S.substr(0, N / 2) == S.substr(N / 2)) {
		  cout << "Yes" << endl;
		}
	  else {
		  cout << "No" << endl;
		}
	}
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


const int N = 200000 + 10;

long long int  A[N];

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

	for (int i = 0; i < N; i++)
		cin >> A[i];
	long long int  sum_ = 0;
	for (int i = 1; i < N; i++)
	{
		if (A[i] < A[i - 1])
		{
			sum_ += (A[i - 1] - A[i]);
			A[i] = A[i - 1];
		}
	}
	cout << sum_ << endl;
	return 0;
}

Measured memory_bytes: 4688
s = gets.chomp
x = 0
i = 0
n = s.size
ans = 0
while (i < n)
    if s[i] == "A"
        x += 1
        i += 1
    elsif n-i > 1 && s[i,2] == "BC"
        ans += x
        i += 2
    else
        # t << a if a.size != 0
        x = 0
        i += 1
    end
end
puts ans

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#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++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

vector<vector<int>> dp(1000003, vector<int>(2, INF));
//dp.at(i).at(j)は繰り下がりがjのときにN%10^i円払う最小値

int main(){
  string N;
  cin >> N;
  vector<ll> s(sz(N)+1);
  rep(i, sz(N)){
    s.at(i+1) = s.at(i) + N.at(i) - '0';
  }
  dp.at(0).at(0) = 0;
  rep(i, sz(N)){
    rep(j, 2){
      rep(d, 10){
        if(j == 0){
          if(d < N.at(sz(N)-1-i)-'0'){
            chmin(dp.at(i+1).at(1), d + 10+d-(N.at(sz(N)-1-i)-'0') + dp.at(i).at(0) + 1);
          }
          else{
            chmin(dp.at(i+1).at(0), d + d-(N.at(sz(N)-1-i)-'0') + dp.at(i).at(0));
          }
        }
        else{
          if(d-1 < N.at(sz(N)-1-i)-'0'){
            chmin(dp.at(i+1).at(1), d-1 + 10+d-1-(N.at(sz(N)-1-i)-'0') + dp.at(i).at(1) + 1);
          }
          else{
            chmin(dp.at(i+1).at(0), d-1 + d-1-(N.at(sz(N)-1-i)-'0') + dp.at(i).at(1));
          }
        }
      }
    }
  }
  cout << min(dp.at(sz(N)).at(0), dp.at(sz(N)).at(1)) << endl;
}

Measured memory_bytes: 65924
/*
[ ( ^ _ ^ ) ]
*/

import java.io.*;
import java.util.*;


public class Main {
    int INF = (int)1e9;
    long MOD = 1000000007;
    

    void solve(InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int m = in.nextInt();
        int rs = (n*(n-1) + m*(m-1))/2;
        out.println(rs);
    }
    
    
    public static void main(String[] args) throws IOException {
        if(args.length>0 && args[0].equalsIgnoreCase("d")) {
            DEBUG_FLAG = true;
        }
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        long start = System.nanoTime();
        while(t-- >0) {
            new Main().solve(in, out);
        }
        long end = System.nanoTime();
        debug("\nTime: " + (end-start)/1e6 + " \n\n");
        out.close();
    }
    
    static boolean DEBUG_FLAG = false;
    static void debug(String s) {
        if(DEBUG_FLAG) System.out.print(s);
    }
    
    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
    
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
char mp[1009][1009];
long long dp[1009][1009];

int main(){
  int h,w;
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>mp[i][j];
    }
  }
  dp[1][1]=1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i>0&&mp[i-1][j]=='.'){
	dp[i+1][j+1]+=dp[i][j+1];
      }
      if(j>0&&mp[i][j-1]=='.'){
	dp[i+1][j+1]+=dp[i+1][j];
      }
      dp[i+1][j+1]%=mod;
    }
  }
  cout<<dp[h][w]<<endl;
  return(0);
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
#define ll long long
#define trace(x) cerr << #x << " = " << x << endl
using namespace std;

/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
int main()
{
   /*
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("ouput.txt","w",stdout);
    #endif 
   */

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while(t--){
         int n, x, T;
	 cin>>n>>x>>T;
	 int time = 0;
	 int ans = n;
	 while(ans > x){
             ans -= x;
	     time++;

	 }
         cout<<((time*T) + T)<<endl;
    }
	 
    return 0;
} 


Measured memory_bytes: 3648
def resolve():
    INF = 10 ** 18
    N, K = map(int, input().split())
    P = list(map(lambda x: int(x) - 1, input().split()))
    C = list(map(int, input().split()))

    ans = -INF
    for s in range(N):
        S = []
        x = P[s]
        S.append(C[x])
        tot = C[x]
        while s != x:  # スタート位置に戻ったら終了
            x = P[x]
            S.append(C[x])
            tot += C[x]
        s_n = len(S)
        t = 0
        for i in range(s_n):
            t += S[i]
            now = t
            if tot > 0:
                loop = (K - i - 1) // s_n
                now += tot * loop
            ans = max(ans, now)

    print(ans)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 84160
N=int(input())
H=list(map(int, input().split()))
h=H[::-1]
a=True

for i in range(N-1):
    if h[i] < h[i + 1]:
        if h[i+1]-h[i] <= 1:
            h[i+1] -=1
        else:
            a = False
            break

if a:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14396
#!/usr/bin/env python3
#dp8 #Coin

import sys
sys.setrecursionlimit(10000000)
def LI(): return list(map(float,sys.stdin.readline().split()))
def LIR(n): return [LI() for _ in range(n)]
mod = 10**9+7

def I():
    n = int(input())
    p = LI()
    #縦:コインの枚数,横:表が出た回数
    dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
    dp[0][0] = 1
    for i in range(1,n+1):
        for j in range(n+1):
            dp[i][j] = p[i-1]*dp[i-1][j-1]+(1-p[i-1])*dp[i-1][j]
    print(sum(dp[n][n//2+1:n+1]))





if __name__ == '__main__':
    I()


Measured memory_bytes: 272136
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);
    char s[n + 1];
    scanf("%s", s);
    int ans = 1;
    for (int i = 0; i < n - 1; i++){
        if (s[i] != s[i + 1]){
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
# -*- Coding: utf-8 -*-
W,H,x,y = map(int,input().split())


if (W/2 == x) and (H/2 == y):# 中心の場合無限だから1
    print("{:.9f}".format(W*H/2),1)
else:
    print("{:.9f}".format(W*H/2),0)
     

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
           int n;
           cin>>n;
           vector<vector<int>> v(n);
           int dp[200000][3];
           for(int i=0;i<n;i++)
           {
           		int a,b,c;
           		cin>>a>>b>>c;
           		v[i].push_back(a);
           		v[i].push_back(b);
           		v[i].push_back(c);
           }
           dp[0][0]=v[0][0];
           dp[0][1]=v[0][1];
           dp[0][2]=v[0][2];
           for(int i=1;i<n;i++)
           {
           		dp[i][0]=v[i][0]+max(dp[i-1][1],dp[i-1][2]);
           		dp[i][1]=v[i][1]+max(dp[i-1][0],dp[i-1][2]);
           		dp[i][2]=v[i][2]+max(dp[i-1][0],dp[i-1][1]);

           }
           cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 6912