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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
// end of Template

int n,a,b;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>a>>b;
    a*=n;
    cout<<min(a,b)<<newl;

}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

public class Main {
	public static void main (String[] args){
    	Scanner sc = new Scanner(System.in);
    	long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
      	long y = 0, ans = 0;

        ans = (n / (a+b)) * a;
        y = n % (a+b);
      
        ans += Math.min(y, a);
      
      	System.out.println(ans);
    }
}

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

bool isWhite(string str)
{
    regex re(R"(\.+)");
    return regex_match(str, re);
}
vector<string> delRows(vector<string> vec)
{
    vector<string> shrinked;
    for (string row : vec)
    {
        if (!isWhite(row))
        {
            shrinked.emplace_back(row);
        }
    }
    return shrinked;
}
vector<string> delCols(vector<string> vec)
{
    int rowNum = vec.size();
    int colNum = vec[0].size();
    vector<string> shrinked;
    vector<bool> blackIndex(colNum, false);
    for (int i = 0; i < colNum; ++i)
    {
        string col = "";
        for (string row : vec)
        {
            col += row[i];
        }
        if (!isWhite(col))
        {
            blackIndex[i] = true;
        }
    }
    for (int i = 0; i < rowNum; ++i)
    {
        string tmp = "";
        for (int j = 0; j < colNum; ++j)
        {
            if (blackIndex[j])
            {
                tmp += vec[i][j];
            }
        }
        shrinked.emplace_back(tmp);
    }
    return shrinked;
}

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> vec(H);
    for (int i = 0; i < H; ++i)
    {
        cin >> vec.at(i);
    }
    vec = delRows(vec);
    vec = delCols(vec);
    H = vec.size();
    for (int i = 0; i < H; ++i)
    {
        cout << vec.at(i);
        if (i < H)
        {
            cout << endl;
        }
    }
}

Measured memory_bytes: 3792
n,d=map(int,input().split())
x=[]
for i in range(n):
    p=list(map(int,input().split()))
    x.append(p)
ans=0
for i in range(len(x)-1):
    for j in range(i+1,len(x)):
        dis=0
        for k in range(d):
            dis+=(x[i][k]-x[j][k])**2
        if int(dis**(1/2))==dis**(1/2):
            ans+=1
print(ans)


Measured memory_bytes: 9436
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1e9;
#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define pb(n) push_back(n)

int Digits_Sum(int N){
    int sum = 0;
    while(N){
        sum += N%10;
        N /= 10;
    }
    return sum;
}
int main(){
    int N;
    cin >> N;
    int ans;
    if(N % 10) ans = Digits_Sum(N);
    else ans = Digits_Sum(N/2)*2;
    cout << ans << endl; 
}

Measured memory_bytes: 256
def search_unblanced_position(char_str):
    for i in range(len(char_str)-1):
        if s[i] == s[i+1]:
            return i+1,i+2

    for i in range(len(char_str)-2):
        if s[i] == s[i+2]:
            return i+1,i+3

    return -1,-1

s = input()

a,b = search_unblanced_position(s)

print (a,b)

Measured memory_bytes: 3188
#include <stdbool.h>
#include <stdio.h>
int main() {
	int c[3][3];
	bool yes = true;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			scanf("%d", &c[i][j]);
		}
	}
	for (int i = 0; i < 2; i++) {
		if (c[i][0] - c[i][1] != c[i + 1][0] - c[i + 1][1]) yes = false;
		if (c[i][1] - c[i][2] != c[i + 1][1] - c[i + 1][2]) yes = false;
	}
	for (int i = 0; i < 2; i++) {
		if (c[0][i] - c[1][i] != c[0][i + 1] - c[1][i + 1]) yes = false;
		if (c[1][i] - c[2][i] != c[1][i + 1] - c[2][i + 1]) yes = false;
	}
	if (yes) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n;
ll p[e5];
ll ans;

int main(){
  cin >> n;
  for(ll i = 0;i < n;i++) cin >> p[i];
  ans = n-2;
  for(ll i = 1;i < n-1;i++){
    if(max({p[i-1],p[i],p[i+1]}) == p[i] || min({p[i-1],p[i],p[i+1]}) == p[i]){
      ans--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
h,w,n=map(int,input().split())
H=[0]*h
W=[0]*w
L=[(0,0)]*n
for i in range(n):
    a,b=map(int,input().split())
    L[i]=(a,b)
    H[a-1]+=1
    W[b-1]+=1
h_max=max(H)
w_max=max(W)
ans=h_max+w_max
cnt=0
for l in L:
    if H[l[0]-1]==h_max and W[l[1]-1]==w_max:
        cnt+=1
if H.count(h_max)*W.count(w_max)==cnt:
    ans-=1
print(ans)

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

int main() {
    int n,k;
    cin >> n;
    int a[n+1];
    for(k=1;k<=n;k++){
        cin >> a[k];
    }
    for(k=n;k>0;k--){
        cout << a[k];
        if(k != 1)
            cout << " ";
    }
        cout << endl;
	return 0;
}

Measured memory_bytes: 3100
#include<stdio.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline char CH()
{
  static char buf[100000],*ptr1=buf,*ptr2=buf;
  return ptr1==ptr2&&(ptr2=(ptr1=buf)+fread(buf,1,100000,stdin),ptr1==ptr2)?EOF:*ptr1++;
}
static inline long IN(void)
{
  long x=0;int f=0,c=CH();while(c<48||c>57){f^=c==45,c=CH();}
  while(c>47&&c<58){x=x*10+c-48,c=CH();}return f?-x:x;
}
static inline void OUT(long x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
static inline void Radix32(int A[],const int sz)
{
  int temp[200001];const int bit=8;
  rep(k,4)
  {
    int u[256]={},v[256]={};
    rep(i,sz)u[A[i]>>bit*k&((1<<bit)-1)]++;
    rep(i,(1<<bit)-1)u[i+1]+=u[i];
    rep(i,sz){temp[--u[A[sz-1-i]>>bit*k&((1<<bit)-1)]]=A[sz-1-i];}k++;
    rep(i,sz)v[temp[i]>>bit*k&((1<<bit)-1)]++;
    rep(i,(1<<bit)-1)v[i+1]+=v[i];
    rep(i,sz)A[--v[temp[sz-1-i]>>bit*k&((1<<bit)-1)]]=temp[sz-1-i];
  }
}
int main(void)
{
  int N=IN(),p=0,m=0,z=0,A[200000];
  long K=IN(),count=0,l=-2e18,r=-l,mid,x;
  rep(i,N){x=IN();if(x>0)A[m+p++]=x;else if(x<0)A[p+m++]=x;else z++;}
  Radix32(A,m+p);
  if(K>1l*m*p&&K<1l*m*p+1l*z*(N-1)/2)return puts("0"),0;
  if(K<=1l*m*p)r=1l;else l=-1l;x=1l*z*(p+m)+1l*z*(z-1)/2+1l*p*m;
  while(l<=r)
  {
    mid=(l+r)/2;count=0;
    if(mid>=0)
    {
      int plus=p-1,minus=m-1;count+=x;
      rep(i,p){while(1l*A[i]*A[plus]>mid){plus--;}if(i>=plus){break;}count+=1l*plus-i;}
      rep(i,m){while(1l*A[m+p-1-i]*A[m+p-1-minus]>mid){minus--;}if(i>=minus){break;}count+=1l*minus-i;}
    }
    else{int low=0;rep(i,m){while(1l*A[low]*A[p+i]>mid&&low<p){low++;}count+=1l*p-low;}}
    if(count>=K)r=mid-1l;else l=mid+1l;
  }
  return OUT(l),0;
}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
unordered_map<int,int> id;
vector<int> v;
int a[MAXN], b[MAXN];
int p[MAXN], sz[MAXN];
int xa[MAXN], xb[MAXN];
int num = 1,n,N;
int find(int x){
    return p[x] == x ? x : p[x] = find(p[x]);
}
void unionset(int x, int y){
    x = find(x), y=  find(y);
    if (x == y) return;
    num--;
    p[x] = y;
    sz[y] += sz[x];
}
int main(){
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
        scanf("%d",&a[i]);
        a[n] ^= a[i];
    }
    for (int i = 0; i < n; i++){
        scanf("%d",&b[i]);
        b[n] ^= b[i];
    }
    for (int i = 0; i <= n; i++){
        xa[i] = a[i], xb[i] = b[i];
    }
    sort(xa,xa+n+1);
    sort(xb,xb+n+1);
    for (int i = 0; i <= n; i++){
        if (xa[i] != xb[i]){
            printf("-1");
            return 0;
        }
    }
    for (int i = 0; i <= n; i++){
        if (a[i] != b[i] || i == n){
            N++;
            v.push_back(a[i]);
        }
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    for (auto x : v){
        id[x] = num++;
    }
    num--;
    iota(p,p+N,0);
    for (int i = 0; i <= n; i++){
        if (a[i] != b[i] || i == n){
            unionset(id[a[i]],id[b[i]]);
        }
    }
    int ans = N+num-2;
    printf("%d",ans);
}


Measured memory_bytes: 8592
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstdio>

#include<string>
using namespace std;

int main(){
	string s;
	cin>>s;
	if(s[0]==s[1]&&s[1]==s[2]){
		puts("No");
	}
	else{
		puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv,  digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal ,RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag; vector<vpll> path, path2; vl D1, D2;
//***********//
int main() {
	cin >> N;
	vs S(N);
	for (i = 0; i < N; i++) {
		cin >> S[i];
	}
	for (i = 0; i < N; i++) {
			vs P(N);
			for (k = 0; k < N; k++) {
				for (l = 0; l < N; l++) {
					P[k] += S[(k + i) % N][(l) % N];
				}
				//debug(P[k]);
			}
			ll valid = 1;
			for (k = 0; k < N; k++) {
				for (l = 0; l < N; l++) {
					if (P[k][l] != P[l][k]) {
						valid = 0;
						break;
					}
				}
				if (!valid) break;
			}
			ans += valid;
			P.clear();
	}
	ans *= N;
	cout << ans;
}

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

    rep(i, n){
        cin >> a[i];
    }

    int tmp;
    for(int i=0; i<n; i++){
        tmp = a[i];
        for(int j=i-1; j>=0; j--){
            if(tmp < a[j]){
                a[j+1] = a[j];
                a[j] = tmp;
            }
            else{
                break;
            }
        }

        rep(k, n){
            cout << a[k];
            if(k != n-1){
                cout << " ";
            }
        }
        cout << "\n";
    }

    return 0;
}


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

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (x-r>=0 && x+r<=w && y-r>=0 && y+r<=h) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
import java.util.LinkedList;
import java.util.Scanner;

class Graph {
	private int totalVertex;
	// adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	// adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	// if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;

	public Graph() {
		totalVertex = 0;
	}

	public int getTotalVertex() {
		return totalVertex;
	}

	// load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for (i = 0; i < totalVertex; i++) {
			for (j = 0; j < totalVertex; j++) {
				adjWeight[i][j] = in.nextInt();
				if (adjWeight[i][j] != -1) {
					adjMatrix[i][j] = 1;
				}
			}
			ifSettled[i] = false;
		}
		in.close();
	}

	// return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}

	// return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for (int v = 0; v < totalVertex; v++) {
			if (adjMatrix[u][v] == 1)
				tmp.add(v);
		}
		return tmp;
	}

	// return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for (int v = 0; v < totalVertex; v++) {
			if ((adjMatrix[u][v] == 1) && (ifSettled[v] == false))
				tmp.add(v);
		}
		return tmp;
	}

	// return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for (v = 0; v < totalVertex; v++) {
			if ((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}

	// implement the following
	public int[] Dijkstra(int s) {
		int[] out = new int[totalVertex];
		for (int i = 0; i < totalVertex; i++) { // Initialize
			out[i] = Integer.MAX_VALUE;
		}
		out[s] = 0;
		int curr = s;
		while (curr != -1 && out[curr] != Integer.MAX_VALUE) {
			ifSettled[curr] = true;
			LinkedList<Integer> neighbors = getUnsettledNeighbors(curr);
			for(Integer i: neighbors) {
				out[i] = Math.min(out[i], getWeight(curr, i));
			}
			
			curr = getUnsettledNearest(out);
		}
		return out;
	}
}

public class Main {
	public static void main(String[] argv) {
		Graph g = new Graph();
		g.loadAdjMatrix();
		int[] dist = g.Dijkstra(0);
		int cost = 0;
		for(int i = 0; i < g.getTotalVertex(); i ++) {
			cost += dist[i];
		}
		System.out.println(cost);
	}
}


Measured memory_bytes: 40912
import java.util.*;

public class Main {
 	public static void main(String[] args) {
     	Scanner s = new Scanner(System.in);
      	int n = s.nextInt();
      	int a = s.nextInt();
      	int b = s.nextInt();
      	System.out.println(Math.min(n*a, b));
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

int x[10],y[10];

double dis (int i, int j){
    int dx = abs(x[i]-x[j]);
    int dy = abs(y[i]-y[j]);

    return  sqrt(dx*dx + dy*dy);
 }
 //あとで取る
 
 
int main(){
    int N;
    cin >> N;

    vector<int> a(N);
    rep(i,N)cin >> a[i];

    int sum=0;
    int j = 1;
    for(int i = 0; i<N;i++){
        while(a[i] == j){
            j++;
        }
    }
    if(j == 1) cout << -1 << endl;
    else cout << N-(j-1) << endl;


 
}

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

int main() {
  int n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];

  sort(a, a + n);
  int ans1 = a[n-1];
  int ans2 = 0;
  int diff = 2 * 1e9;
  for (int i=0; i<n; i++) {
    int tmp = min(abs(a[i]-ans1/2), abs(a[i]-(ans1+1)/2));
    if (tmp < diff) {
      ans2 = a[i];
      diff = tmp;
    }
  }
  cout<<ans1<<" "<<ans2<<endl;
}

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

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long llint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double pi = 3.14159265358979323846;

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  llint a, b, c;
  cin >> a >> b >> c;

  if (c - a - b < 0) {
    cout << "No" << endl;
  } else {
    if (4 * a * b < (c - a - b) * (c - a - b)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int M = (int)1e3+5;
const int Q = 301;
const int logN = 19;

ll dp[101][N], p[N];
void solve() {
    int n,k,a;
    cin>>n>>k;
    dp[0][k] = p[k+1] = 1;
    REP(i,1,n) {
        cin>>a;
        REP(r,0,k) {
            dp[i][r] = (p[r+min(a,k-r)+1]-p[r])%mod;
            if(dp[i][r]<0) dp[i][r] += mod;
        }
        p[0] = 0;
        REP(r,0,k) {
            p[r+1] = (p[r] + dp[i][r])%mod;
        }
    }
    cout<<dp[n][0];
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 79232
#include <stdio.h>

int main() {
    int n,r, a=0;
    scanf("%d%d\n", &n, &r);
    if (n >= 10){
        printf("%d\n", r);
    } else {
        a = 100 * ( 10 - n);
        printf("%d\n", a + r);
        
    }
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int M, D; cin >> M >> D;
	int res = 0;
	for (int m = 1; m <= M; m++) {
		for (int a = 2; a <= 9; a++) {
			for (int b = 2; b <= 9; b++) {
				if (10 * a + b <= D && a * b == m) {
					res++;
				}
			}
		}
	}
	cout << res << '\n';

	return 0;
}


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

int main(){
    int N,K,d,e;
    cin >> N >> K;
    vector<int> snuke(N);
    for (int i = 0; i < K; i++) {
        cin >> d;
        for (int i = 0; i < d; i++) {
            cin >> e;
            snuke.at(e - 1)++;
        }
    }
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (snuke.at(i) == 0) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin >> P.at(i);
  }
  sort(P.begin(),P.end());
  int ans=0;
  for(int i=0;i<K;i++){
    ans+=P.at(i);
  }
  cout << ans << endl;
}
    
  

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


size_t a005()
{
    string str;
    cin >> str;

    const auto n = str.size();
    size_t cnt = 0, inc = 0;
    for(size_t i = n - 1; i < n; --i)
        if(str[i] == 'T')
            ++ cnt;
        else if(cnt)
        {
            -- cnt;
            inc += 2;
        }

    return n - inc;
}


int main(const int argc, char * argv [])
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << a005();

    return EXIT_SUCCESS;
}


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

int main(){
  long long int N,b,c;
  int count = 0;
  char ans[20];
  cin >> N;
  
  for(int i=0;i<15;i++){
    
    b = N / 26;
    c = N % 26;
    
    if(c == 0){
      b = b - 1;
      c = 26;
    }
    
    ans[i] = 'a' + c - 1;
    count += 1;
    
    if(b == 0)
      break;
    
    N = b;
    
  }
  
  for(int i=count-1;i>=0;i--)
    cout << ans[i];
  
  cout << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
//#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
#define N  1000000007
#define MAXN   100001
 //priority_queue<int, vector<int>, greater<int> > Q; 
int main()
{

string s;
cin>>s;
if(s[5]!='0')
{
cout<<"TBD";return 0;	
}

if(s[5]=='0' && s[6]>'4')
{
cout<<"TBD";return 0;	
}
if(s=="2019/04/30")
	{cout<<"Heisei";return 0;}
cout<<"Heisei";

}
















































































































Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True

A = 0
B = 0
C = 0
N = 0


def dfs(cur, L, a, b, c):
    # print(A, B, C)
    if cur == N:
        return abs(A - a) + abs(B - b) + abs(C - c) if min(a, b, c) > 0 else IINF

    ret0 = dfs(cur + 1, L, a, b, c)
    ret1 = dfs(cur + 1, L, a + L[cur], b, c) + (0 if a == 0 else 10)
    ret2 = dfs(cur + 1, L, a, b + L[cur], c) + (0 if b == 0 else 10)
    ret3 = dfs(cur + 1, L, a, b, c + L[cur]) + (0 if c == 0 else 10)

    return min(ret0, ret1, ret2, ret3)


def main():
    global A
    global B
    global C
    global N
    N, A, B, C = MI()
    L = [0] * N

    for i in range(N):
        L[i] = int(input())

    # itertools.combinations(L, 2)
    print(dfs(0, L, 0, 0, 0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 72152
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c[1001],cnt=0;
	cin>>a>>b;
	for (int i=0;i<a;i++)
		cin>>c[i];
	for (int i=0;i<b;i++)
	{
		cnt+=*min_element(c,c+a);
		*min_element(c,c+a)=100000;
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 3572
from itertools import accumulate

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

D = [ai - bi for ai, bi in zip(A, B)]
M = [di for di in D if di < 0]
P = [di for di in D if di > 0]

sum_m = sum(M)
if sum_m == 0:
    print(0)
    exit()

P.sort(reverse=True)
for i, pi in enumerate(P):
    sum_m += pi
    if sum_m >= 0:
        print(len(M) + i + 1)
        exit()
print(-1)


Measured memory_bytes: 19068
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	c=(c+b-1)/b;
	a=(a+d-1)/d;
	if(c<=a)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;

int main(void){
  int a,b,k;
  cin >> k >> a >> b;
  
  int largest = (b / k) * k;
  if(a <= largest)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
  
  return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<algorithm>
#define maxn 100
using namespace std;
int n,l,r,a[maxn],p,b[maxn],cnt,sum,ans=0;
int main(){
	scanf("%d%d",&n,&p);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<=min(n,p);i++){//Ò»¹²½øÐÐÁË¼¸´ÎÈ¡µÄ²Ù×÷ 
		for(int j=0;j<=i;j++){
			int lnum=j,rnum=i-j;
			cnt=0;sum=0;
			for(int k=1;k<=lnum;k++){
				b[++cnt]=a[k];
				sum+=a[k];
			}
			for(int k=n;k>=n-rnum+1;k--){
				b[++cnt]=a[k];
				sum+=a[k];
			}
			sort(b+1,b+cnt+1);
			for(int k=1;k<=min(p-i,cnt);k++){
				if(b[k]>=0)break;
				sum-=b[k];
			}
			ans=max(ans,sum);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
inline ll kissme(ll x,ll y)
{
	ll res=1;
	if(x==0)return 1;
	if(x==1)return y;
	res=kissme(x/2,y);
	res=res*res%mod;
	if(x%2==1)res=res*y%mod;
	return res;
}
ll x,k,d;
int main()
{
	Very_fast;
	cin>>x>>k>>d;
	ll move=abs(x)/d;
	ll lstmove=k-move;
	lstmove%=2;
	if(move>=k)
	{
		cout<<abs(x)-k*d<<"\n";
		return 0;
	}
	ll ans=abs(x)-move*d;
	if(lstmove)ans=d-ans;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		//int[][] a = new int[n][m];
		int[] b = new int[m];
		int count = 0;
		
		for(int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}
		
		for(int i = 0; i < n; i++) {
			int result = 0;
			for(int j = 0; j < m; j++) {
				int a = sc.nextInt();
				result += b[j]*a;
			}
			result += c;
			
			if(result > 0) {
				count++;
			}
		}
		
		System.out.println(count);
		sc.close();
	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <queue>


using namespace std;

int main(){
  int N, Q; cin >> N >> Q;
  queue<string> name;
  queue<int> tm;

  for(int i=0;i<N;++i){
    string s;
    int t;
    cin >> s >> t;
    name.push(s); tm.push(t);
  }

  int now = 0;
  while(!name.empty()){
    string s = name.front(); name.pop();
    int t = tm.front(); tm.pop();
    if(t > Q){
      now += Q;
      name.push(s);
      tm.push(t - Q);
    }
    else{
      now += t;
      cout << s << " " << now << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 4164
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>;
using L = vector<long long>;
using M = map<int,long long>;
using A = vector<vector<long long>>;
using Q = priority_queue<long long>;
using U = unordered_map<int,long long>; //mapとの違いはkeyの順番を保持していない

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long l,r;
    cin>>l>>r;
    if (r-l>2018){
        cout<<"0"<<endl;
    }else{
        long long ans=1e18;
        for(long long i=l  ;i<r  ;i++){
            for(long long j=i+1  ;j<r+1  ;j++){
                ans=min(i*j%2019,ans);
            }
        }
    cout<<ans<<endl;
    }
}
    

Measured memory_bytes: 256
a,b,c = map(int,input().split())
cnt=0
if a==b==c and a%2==0:
    cnt = -1
else:
    for i in range(100):
        if a%2==0 and b%2==0 and c%2==0:
            t_a = b//2 + c//2
            t_b = a//2 + c//2
            t_c = a//2 + b//2
            a,b,c = t_a,t_b,t_c
            cnt+=1
        else:
            break
print(cnt)

Measured memory_bytes: 3064
n, k = map(int, input().split())
a = list(map(int, input().split()))

bc = [0]*40
for A in a:
    for i in range(40):
        bc[i]+=(A&(1<<i))>>i
#print(bc)
X=0
f=False
for i in range(39, -1, -1):
	bit = 1<<i
	if(f or (k&bit)!=0):
		if(bc[i]<=(n//2)):
			X+=2**i
		else:
			f=True

#print("X= ",X)
sum=0
for A in a:
    sum+=A^X
print(sum)


Measured memory_bytes: 14596
n = int(input())
h = list(map(int, input().split()))
ans = 0
c = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        c += 1
        if i == n-2:
            if c > ans:
                ans = c
                
    else:
        if c > ans:
            ans = c
        c = 0

print(ans)




 

 


                                        




    




        


    







        



Measured memory_bytes: 14252
import numpy as np

A = np.zeros(10001,dtype=np.bool)
A[0] = 1
N = int(input())
for _ in range(N):
  s = int(input())
  A[s:] = np.logical_or(A[s:],A[:-s])

A[10::10] = 0
answer = np.nonzero(A)[0].max()
print(answer)

Measured memory_bytes: 12392
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char[] s = sc.next().toCharArray();
		
		for(int i=0; i<s.length; i++) {
			if(s[i]=='?') {
				s[i] = 'D';
			}
		}
		
		System.out.println(String.valueOf(s));
		sc.close();
	}
}


Measured memory_bytes: 32040
#include <bits/stdc++.h>
#define mod 998244353
using namespace std;
/*Atcoder Regular Contest 082 E
  For each convex polygon,we count it for 2^t times,
  while t is the size of the subset of points inside the polygon.
  So,it can be considered as,each subset of t is counted once.
  And it can be tranformed to the number of subsets having a convex hull.
  Then it's easy to calculate the number of it.
*/
int x[205],y[205],num[205];
int ans,n,b[205];
int gcd(int a,int b)
{if (a%b==0) return b;
return gcd(b,a%b);
}
inline int abs(int a)
{if (a<0) return -a;
return a;
}
inline int read()
{int x=0;
char c=getchar();
while (c<'0'||c>'9') c=getchar();
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return x;
}
int main (){
	int i,j,k;
	n=read();
	b[0]=1;
	for (i=1;i<=n;i++)
	{b[i]=b[i-1]*2;b[i]%=mod;}
	ans=b[n]-1-n;
	for (i=1;i<=n;i++)
	{x[i]=read();y[i]=read();}
	for (i=1;i<=n;i++)
	{memset (num,0,sizeof(num));
	map <int,int> d[2][10005];
	map <int,int>::iterator it;
	int nx=0,ny=0;
	for (j=i+1;j<=n;j++)
	{int dx=x[i]-x[j],dy=y[i]-y[j],tag;
	if (dx==0) {nx++;continue;}
	if (dy==0) {ny++;continue;}
	if (dx*dy<0) {tag=0;}
	else {tag=1;}
	dx=abs(dx);dy=abs(dy);
	int t=gcd(dx,dy);
	dx/=t;dy/=t;
	if (d[tag][dx][dy])
	{num[d[tag][dx][dy]]--;}
	d[tag][dx][dy]++;
	num[d[tag][dx][dy]]++;
	}
	num[nx]++;num[ny]++;
	//printf ("Case %d\n",i);
	for (j=1;j<=n;j++)
	{if (num[j])
	{//printf ("%d %d\n",j,num[j]);
	ans-=num[j]*(b[j]-1);ans%=mod;
	if (ans<0) ans+=mod;
	}
	}
	}
	printf ("%d",ans);
	return 0;
}

Measured memory_bytes: 1152
object Main extends App {
  val in = io.Source.stdin.getLines.toIndexedSeq.head.toInt
  //println(in)
  if(in==25)
  	println("Christmas")
  else if(in==24)
    	println("Christmas Eve")
  else if(in==23)
    	println("Christmas Eve Eve")
          else if(in==22)
            	println("Christmas Eve Eve Eve")
  else
            	println("")
}


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

int main() {
  long long x, ans = 0;
  cin >> x;
  ans = x / 11; ans *= 2; x %= 11;
  if (x != 0) ans += (x > 6) ? 2 : 1;
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
	cout << a << "\n";
}


int main(int argc, const char * argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin >> s;
	char old='x';
	bool good=true;
	for(char _s : s)
	{
		if(old==_s){
			good = false;
			break;
		}
		old = _s;
	}
		
	if(good)
	{
		cout << "Good" << endl;
	}else{
		cout << "Bad" << endl;
	}


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, m;
  cin >> n >> m;
  if (n == 1 && m == 1) {
    cout << 1 << endl;
    return 0;
  }

  if (n == 1) {
    cout << m - 2 << endl;
    return 0;
  }

  if (m == 1) {
    cout << n - 2 << endl;
    return 0;
  }
  cout << (ll)(n - 2) * (m - 2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<vector<i64>> g;
vector<i64> c, y;

void dfs(i64 u, i64 p) {
  y[u] = c.back();
  c.pop_back();
  for (i64 v : g[u]) {
    if (v != p) dfs(v, u);
  }
}

int main() {
  cin >> n;
  init_n(g, n + 1);
  for (i64 i = 0; i < n - 1; ++i) {
    i64 a, b; cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  init_n(c, n + 1);
  for (i64 i = 1; i <= n; ++i) cin >> c[i];
  sort(begin(c), end(c));
  
  i64 sum = 0;
  for (i64 i = 1; i < n; ++i) sum += c[i];

  init_n(y, n + 1);
  dfs(1, -1);

  cout << sum << '\n';
  for (i64 u = 1; u <= n; ++u) {
    cout << y[u] << ' ';
  }
  cout << '\n';
  return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,i,j,temp1,temp2,x,y,z,sum=0,o,n,m,k,d;
    cin >> x >> y >> z >> k;
    if(k>x+y){
        cout << x - (k-x-y);
    }
    else if(k>x){
        cout << x;
    }
    else cout << k;
}

Measured memory_bytes: 3652
import sys

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    S = input()
    T = input()
    cnt = 0
    for i in range(len(S)):
        if S[i] != T[i]:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 67852
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var x = long.Parse(Console.ReadLine().Trim());
        getAns(x);
    }
    static void getAns(long x)
    {
        for (int i = -200; i <= 200; i++)
            for (int j = -200; j <= 200; j++)
            {
                if ((long)Pow(i, 5) - (long)Pow(j, 5) == x)
                {
                    Console.WriteLine("{0} {1}", i, j);
                    return;
                }
            }
    }
}


Measured memory_bytes: 18124
M, D = map(int, input().split())

ans = 0
for i in range(1, M+1):
    for j in range(1, D+1):
        d1 = j % 10
        d10 = j // 10
        if d1 >= 2 and d10 >= 2 and d1 * d10 == i:
            ans += 1
print(ans)


Measured memory_bytes: 3060
INF = 10 ** 9 + 7

n = gets.to_i
b = gets.chomp.split.map(&:to_i)
a = Array.new(n, INF)
0.step(n - 2) do |i|
  a[i] = b[i] if a[i] > b[i]
  a[i + 1] = b[i] if a[i + 1] > b[i]
end
puts a.inject(:+)

Measured memory_bytes: 1788
S = input()

odd = []
even = []

for i in range(len(S)):
    if i % 2 == 0:
        even.append(int(S[i]))
    else:
        odd.append(int(S[i]))


count = 0
if sum(even) == sum(odd):
    if len(even) > len(odd):
        count = len(odd) - sum(odd) + sum(even)
    else:
        count = len(even) - sum(even) + sum(odd)
elif sum(even) > sum(odd):
    count = len(even) - sum(even) + sum(odd)
else:
    count = len(odd) - sum(odd) + sum(even)

print(count)


Measured memory_bytes: 4092
S = int(input())
L = sorted(list(map(int,input().split())))

count=0
for i in range(len(L)):
    for j in range(i+1,len(L)):
        for k in range(j+1,len(L)):
            if (L[i]!=L[j] and L[j]!=L[k]):
                if ((L[i]+L[j]>L[k]) and (L[j]+L[k]>L[i]) and ((L[k]+L[i]>L[j]))):
                    count+=1
print(count)


Measured memory_bytes: 9204
#include<stdio.h>
#include<string.h>
#define M 100000

typedef struct{
  char name[100];
  int time;
}Que;

int head,tail,n;

int min(int,int);
Que dequeue(void);
void enqueue(Que);
Que Q[M];

 int main(){
  
  
  int e=0,d;
   int i,q;
   Que p;
   
   scanf("%d %d",&n,&q);
   
   for(i=1;i<=n;i++){
     scanf("%s",Q[i].name);
     scanf("%d",&Q[i].time);
   }

   head=1;
  tail=n+1;
   
   while(head!=tail){
     p=dequeue();
     d=min(q,p.time);
     p.time-=d;
     e+=d;
     if(p.time>0) enqueue(p);
     else {
       printf("%s %d\n",p.name,e);
     }
   }
   return 0;
}

int min(int x, int y){ 
  return x < y ? x : y;
}

Que dequeue(){
  Que x;
 x= Q[head];
  head = (head + 1) % M;
  
  return x;
}

void enqueue(Que x){ 
  
  Q[tail] = x;

  tail = (tail + 1) % M;
  
}

Measured memory_bytes: 10756
import java.io.*;
import java.util.StringTokenizer;

class Main {

    public static void main(String[] args) throws IOException {
        init();

        int n = nextInt(), m = nextInt(), q = nextInt();

        int[][] trains = new int[n + 1][n];

        for (int i = 0; i < m; i++) {
            int l = nextInt(), r = nextInt();
            int dist = r - l;
            trains[l][dist]++;
        }

        for (int i = 1; i < trains.length; i++) {
            for (int j = 0; j < trains[i].length; j++) {
                trains[i][j] += j > 0 ? trains[i][j - 1]: 0;
            }
        }

        for (int i = 0; i < trains[0].length; i++) {
            for (int j = 1; j < trains.length; j++) {
                if (j > i + 1) break;
                if (i - j + 1 < trains[0].length) {
                    trains[j][i - j + 1] += i - j + 2 < trains[0].length ? trains[j - 1][i - j + 2]: 0;
                }
            }
        }

        for (int i = 0; i < q; i++) {
            int pi = nextInt(), qi = nextInt();
            System.out.println(trains[qi][0] - (qi - pi + 1 < trains[0].length ? trains[pi - 1][qi - pi + 1] : 0));
        }
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int A, B, C;
    cin >> A >> B >> C;

    ll ans = 0LL;
    while (true) {
        if ((A&1) || (B&1) || (C&1)) break;
        if (A == B && B == C) {
            cout << -1 << endl;
            return 0;
        }

        int nA = (B + C) / 2;
        int nB = (A + C) / 2;
        int nC = (A + B) / 2;
        A = nA;
        B = nB;
        C = nC;
        ans++;
    }

    cout << ans << endl;
}



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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<vector<int>> Graph;

int main() {

	string s;
	cin >> s;

	if (s == "Sunny")
		cout << "Cloudy";
	else if (s == "Rainy")
		cout << "Sunny";
	else
		cout << "Rainy";
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
#define N 410
using namespace std;
ll n,dp[N][N],a[N],qdh[N];
ll dfs(ll l,ll r)
{
	if(l>=r)
	{
		return 0;
	}
	if(dp[l][r]!=INF127)
	{
		return dp[l][r];
	}
	ll i;
	for(i=l;i<r;i++)
	{
		dp[l][r]=min(dp[l][r],dfs(l,i)+dfs(i+1,r)+qdh[r+1]-qdh[l]);
	}
	return dp[l][r];
}
int main(){
	ll i;
	cin>>n;
	qdh[0]=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		qdh[i+1]=qdh[i]+a[i];
	}
	memset(dp,127,sizeof(dp));
	cout<<dfs(0,n-1)<<endl;
	return 0;
}

Measured memory_bytes: 1536