akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9012337203685477580
using ll = long long;
using namespace std;

struct point {
    int x, y, d;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W,cnt;
    cin >> H >> W;
    cnt = H * W;
    vector<vector<char>> S(H,vector<char>(W));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> S[i][j];
            if (S[i][j] == '#') {
                cnt--;
            }
        }
    }
    queue<point> q;
    q.push(point{0,0,1});
    const int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
    while (!q.empty()) {
        point p = q.front(); q.pop();
        if (S[p.x][p.y] != '.') continue;
        S[p.x][p.y] = '*';
        if (p.x == H - 1 && p.y == W - 1) {
            cnt -= p.d;
            cout << cnt << endl;
            return 0;
        }
        for (int i = 0; i < 4; i++)
        {
            int nx = p.x + dx[i], ny = p.y + dy[i];
            if (nx >= 0 && nx < H &&
                ny >= 0 && ny < W &&
                S[nx][ny] == '.') {
                q.push(point{nx,ny,p.d + 1});
            }
        }
    }
    cout << -1 << endl;
    getchar(); getchar();
}

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

using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

bool pallan(string s){
    ll i=0,j=s.size()-1;
    while(i<j){
        if(s[i]!=s[j])
            return false;
        i++;
        j--;
    }
    return true;
}

int main() {
    fio;
    
    ll k,n;cin>>n>>k;//>>m;
    
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    
    sort(a,a+n);
    ll ans=0;
    for(ll i=n-1;i>=0;i--){
        if(k>0){
            k--;
            continue;
        }
        else{
            ans += a[i];
            // break;
        }
    }
    cout<<ans<<endl;
    
    
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << p.first << " " << p.second;
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

int main()
{
  ll N;
  std::cin >> N;

  ll ans = 180 * (N-2);
  print(ans);

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LF double
#define LL long long
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define fd(i,j,k) for(int i=j;i>=k;i--)
#define fr(i,j) for(int i=beg[j];i;i=nex[i])
using namespace std;
int const mn=15e5+3;
int n,l,v[mn];
LF t[mn];
int main(){
	scanf("%d%d",&n,&l);
	int he=1,ti=0,totv=0;LF tv=0;
	fo(i,1,n){
		ti++;
		scanf("%lf%d",&t[ti],&v[ti]);
		totv+=v[ti];tv+=t[ti]*v[ti];
		for(;(he<ti)&&(t[ti]<=t[ti-1]);ti--)if(v[ti]+v[ti-1]<=l){
				t[ti-1]=(t[ti]*v[ti]+t[ti-1]*v[ti-1])/(v[ti]+v[ti-1]);
				v[ti-1]+=v[ti];
			}else{
				v[ti-1]=l-v[ti];
				t[ti-1]=(t[ti]*v[ti]+t[ti-1]*v[ti-1])/(v[ti]+v[ti-1]);
				v[ti-1]=l;
				totv=l;tv=l*t[ti-1];
				he=ti-1;
			}
		for(;(he<ti)&&(totv-v[he]>=l);he++)totv-=v[he],tv-=t[he]*v[he];
		printf("%.10lf\n",(tv-(totv-l)*t[he])/l);
	}
	return 0;
}


Measured memory_bytes: 18560
import math,fractions
A,B,C,D=map(int,input().split())
E=C*D//fractions.gcd(C,D)

ac=(A-1)//C
ad=(A-1)//D
bc=B//C
bd=B//D
ae=(A-1)//E
be=B//E

s= bc-ac
t= bd-ad
u= be-ae

print(B-A+1 - s -t +u)

Measured memory_bytes: 5048
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        s1+=s1;
        if(s1.contains(s2)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 26260
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

enum POSITION{ONLINE_BACK = -2, CCW = -1, ON_SEGMENT = 0,
              CW = 1, ONLINE_FRONT = 2};

struct Point{
    long x;
    long y;
    Point(long x, long y) : x(x), y(y) {}
    Point(){}
    Point operator-(Point p){
        return Point(x - p.x, y - p.y);
    }
};
typedef Point Vector;
double cross(Vector v1, Vector v2){
    return v1.x * v2.y - v1.y * v2.x;
}
double dot(Vector v1, Vector v2){
    return v1.x * v2.x + v1.y * v2.y;
}

struct Segment{
    Point p1;
    Point p2;
    Segment(Point p1, Point p2) : p1(p1), p2(p2) {}
    Segment(){}
};
typedef vector<Point> Polygon;

POSITION get_position(Segment s, Point p){
    double c = cross(s.p2 - s.p1, p - s.p1);
    if (c > 0) return CCW;
    if (c < 0) return CW;
    double d = dot(s.p2 - s.p1, p - s.p1);
    if (d < 0) return ONLINE_BACK;
    if (d > dot(s.p2 - s.p1, s.p2 - s.p1)) return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool intersect(Segment s1, Segment s2){
    if (get_position(s1, s2.p1) * get_position(s1, s2.p2) != -1) {
        return false;
    }
    if (get_position(s2, s1.p1) * get_position(s2, s1.p2) != -1) {
        return false;
    }
    return true;
}

int determine_containment(Point p, Polygon poly){
    for (int i = 0, n = poly.size(); i < n; i++) {
        if (get_position(Segment(poly[i], poly[(i+1)%n]), p) == ON_SEGMENT) {
            return 1;
        }
    }
    Segment s_right(p, Point(p.x + 1e5, p.y));
    int count = 0;
    for (int i = 0, n = poly.size(); i < n; i++) {
        if (intersect(s_right, Segment(poly[i], poly[(i+1)%n]))) {
            count++;
        }
        if (get_position(s_right, poly[i]) == ON_SEGMENT) {
            int i_pre = (i == 0 ? n - 1 : i - 1);
            while (get_position(s_right, poly[i_pre]) != CCW && get_position(s_right, poly[i_pre]) != CW) {
                i_pre = (i_pre == 0 ? n - 1 : i_pre - 1);
            }
            int i_aft = (i + 1) % n;
            while (get_position(s_right, poly[i_aft]) != CCW && get_position(s_right, poly[i_aft]) != CW) {
                i_aft = (i_aft + 1) % n;
            }
            if (get_position(s_right, poly[i_pre]) * get_position(s_right, poly[(i+1)%n]) == -1) {
                count++;
            }
        }
    }
    if (count % 2) return 2;
    return 0;
}
int main(){
    int q;
    cin >> q;
    Polygon poly(q);
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        poly[i].x = x;
        poly[i].y = y;
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        cout << determine_containment(Point(x, y), poly) << endl;
    }
    return 0;
}



Measured memory_bytes: 3116
s=input()
n=int(input())
cnt=0
left=[]
right=[]
for _ in range(n):
    tmp=input()
    if tmp[0]=="1":
        cnt+=1
    else:
        num,side,st=tmp.split()
        if side=="1":
            if cnt%2==0:
                left.append(st)
            else:
                right.append(st)
        else:
            if cnt%2==0:
                right.append(st)
            else:
                left.append(st)
left="".join(left)
left=left[::-1]
right="".join(right)
s=left+s+right
if cnt%2==1:
    s=s[::-1]
print(s)

Measured memory_bytes: 91456
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
const int mod = 998244353, P = 200003, N = (1 << 19) + 100, G = 2, B = 4800;

int n, a[N], qlg[N], rev[N], b[N];

inline void getRev(int lim) {
	static int lst = 0, n = 1;
	if (lst == lim) return;
	n = 1 << lim, lst = lim;
	for (R int i = 1; i < n; ++i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << lim >> 1);
	return;
}

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

void ntt(int *a, int lim, int inv) {
	getRev(lim);
	int n = 1 << lim;
	for (R int i = 0; i < n; ++i)
		if (i < rev[i]) swap(a[i], a[rev[i]]);
	for (R int l = 2; l <= n; l <<= 1) {
		int m = l >> 1, g = quickpow(3, (mod - 1) / l), d;
		if (inv) g = quickpow(g, mod - 2);
		for (R int i = 0; i < n; i += l)
			for (R int j = i, w = 1; j < i + m; ++j, w = (ll) w * g % mod)
				d = (ll) a[j + m] * w % mod, a[j + m] = addMod(a[j], mod - d), a[j] = addMod(a[j], d);
	}
	if (inv) {
		inv = quickpow(n, mod - 2);
		for (R int i = 0; i < n; ++i)
			a[i] = (ll) a[i] * inv % mod;
	}
	return;
}

int main() {
	int pw = 2, x, lim = 0;
	for (R int i = 1; i < P - 1; ++i, pw = pw * G % P)
		qlg[pw] = i;
	read(n);
	ll ans = 0;
	for (R int i = 1; i <= n; ++i) {
		read(x);
		if (x) ++a[qlg[x]], ++b[x];
		ans -= (ll) x * x % P;
		while (1 << lim <= (qlg[x] + 10) << 1) ++lim;
	}
	for (R int i = 1; i < P; ++i) {
		if (b[i] > B) {
			for (R int j = 1; j < P; ++j)
				ans += (ll) i * j % P * b[i] * b[j] * (1 + (i != j));
			b[i] = a[qlg[i]] = 0;
		}
	}
	ntt(a, lim, 0);
	for (R int i = 0; i < 1 << lim; ++i)
		a[i] = (ll) a[i] * a[i] % mod;
	ntt(a, lim, 1), pw = 1;
	for (R int i = 0; i < 1 << lim; ++i)
		ans += (ll) a[i] * pw, pw = pw * G % P;
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 9288
a = int(input())
b = input().split()
b = list(map(int, b))
c = 0
for i in b:
    if i%2 == 0:
         if i%3 != 0:
            if i%5 != 0:
                print("DENIED")
                break
    c +=1
if c == a:
    print("APPROVED")

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

using namespace std;

int main(){

  long long N;
  vector <long long> a;
  vector <long long> b;
  int Q,aaa = 1;
  for(int i = 0;i < 4;i++){
    cin >> Q;
    a.push_back(Q/(0.25*aaa));
    b.push_back(Q);
    aaa = aaa*2;
    
  }
  int max = a[0],maxn = 0;

  cin >> N;

  long long sum = 0;
  
  for(int i = 1;i < 4;i++){
    if(max >= a[i]){
      max = a[i];
      maxn = i;
    }
  }
  //cout << b[maxn] << endl;
  if(maxn == 0){
    sum = N*4*b[0]; 
  }
  else if(maxn == 1){
    sum = N*2*b[1];
  }
  else if(maxn == 2){
    sum = N*b[2];
  }
  else{
    int n = N%2;
    if(n == 0){
      sum = N/2*b[3];
    }

    else{
      int sums;
      sum = N/2*b[3];
      a[maxn]= 1000000000;
      maxn = 0;
      max = a[0];
      for(int i = 1;i < 4;i++){
	if(max >= a[i]){
	  max = a[i];
	  maxn = i;
	}
      }

      if(maxn == 0){
	sums = 4*b[0];
      }
      else if(maxn == 1){
	sums = 2*b[1];
      }
      else{
	sums = b[2];
      }
      sum += sums;
    }
  }

  cout << sum << endl;
  
  
}


Measured memory_bytes: 256
A,B,C,X,Y = map(int,input().split())
min_price = float("inf")
c_count = 0
while True:
    min_price = min(min_price,(A * X) + (B * Y) + (C * c_count))
    if X == 0 and Y == 0:
        break
    X = 0 if X <= 0 else (X-1)
    Y = 0 if Y <= 0 else (Y-1)
    c_count += 2
print(min_price)

Measured memory_bytes: 9200
from math import ceil,floor
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

A,B,C,D = map(int,input().split())

ans = B-A+1
ans -= B//C - (A-1)//C
ans -= B//D - (A-1)//D
ans += B//lcm(C,D) - (A-1)//lcm(C,D)

print(ans)

Measured memory_bytes: 5048
n = int(input())
a = list(int(input()) for _ in range(n))

max_list = sorted(a,reverse=True)[:2]
num = max_list[0]
num2 = max_list[1]

for i in range(n):
    if a[i] < num:
        print(num)
    else:
        print(num2)

Measured memory_bytes: 13328
#include <bits/stdc++.h>
#define SORT(c) sort((c).begin(),(c).end())
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define reprs(i, m, n) for(int i = n; i >= m; i--)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;

int main(){

  int N;
  cin >> N;

  vector<int> vec(N);
  vector<int> a(N);
  vector<int> b;

  int M=0;

  rep(i,N){
    cin>>vec[i];
  }

  repr(i,N-1){
    int x;
    x=vec[i];

    int rr=N/(i+1);
    int ct=0;
    reps(j,2,rr+1){
      if(a[(j*(i+1))-1]==1) ct++;
    }

    if((ct%2)!=x){
      b.push_back(i+1);
      a[i]=1;
      M++;
    }

  }

  cout << M <<endl;
  rep(i,M){
    std::cout << b[i];
    if(i!=M-1){
      std::cout << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 3064
def main():
    S = list(input())
    K = int(input())

    if len(set(S)) == 1:
        print(len(S)*K//2)
    else:
        counter = []
        count = 1
        for i in range(len(S)-1):
            if S[i] == S[i+1]:
                count += 1
            else:
                counter.append(count)
                count = 1
        counter.append(count)
        ans = 0
        for c in counter:
            ans += c // 2
        ans *= K
        if S[0] == S[-1]:
            ans = ans - (counter[0] // 2 + counter[-1] // 2 - (counter[0] + counter[-1]) // 2) * (K - 1)
        print(ans)

if __name__ == '__main__': main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI 3.1415926535897
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


string S;


string subc(int s, int e){
	string ret;
	rep(i, 0, s) ret.pb(S[i]);
	rep(i, e+1, SIZE(S)) ret.pb(S[i]);
	return ret;
}


bool solve(){
	if(S == "keyence") return true;
	int N = SIZE(S);
	rep(i, 0, N)
		rep(j, i, N)
			if(subc(i, j) == "keyence") return true;
	return false;
}


signed main(){
	cin >> S;

	if(solve()) YES;
	else NO;

	return 0;
}

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

int n;
string str[12];

int digit[26];
bool used[26];
bool lead[26];
int maxlen;


int dfs(int i,int j,int s){
	if(i==maxlen){
		return !s;
	}
	if(j==n-1){
		if(digit[str[j][i]-'A']!=-1){
			if(s%10==digit[str[j][i]-'A'])return dfs(i+1,0,s/10);
			return 0;
		}
		if(!used[s%10] && !(s%10==0&&lead[str[j][i]-'A'])){
			used[s%10]=true;
			digit[str[j][i]-'A']=s%10;
			int res=dfs(i+1,0,s/10);
			used[s%10]=false;
			digit[str[j][i]-'A']=-1;
			return res;
		}
		return 0;
	}
	if(str[j].size()<=i)return dfs(i,j+1,s);
	if(digit[str[j][i]-'A']!=-1)
		return dfs(i,j+1,s+digit[str[j][i]-'A']);
	int res=0;
	for(int k=lead[str[j][i]-'A'];k<10;k++){
		if(used[k])continue;
		used[k]=true;
		digit[str[j][i]-'A']=k;
		res+=dfs(i,j+1,s+k);
		used[k]=false;
		digit[str[j][i]-'A']=-1;
	}
	return res;
}
int main(){
	while(cin>>n&&n){
		maxlen=0;
		memset(lead,false,sizeof(lead));
		memset(used,false,sizeof(used));	
		memset(digit,-1,sizeof(digit));
		for(int i=0;i<n;i++){
			cin>>str[i];
			if(str[i].size()!=1)lead[str[i][0]-'A']=true;
			reverse(str[i].begin(),str[i].end());
			maxlen=max(maxlen,(int)str[i].size());
		}
		if(str[n-1].size()<maxlen)cout<<0<<endl;
		else cout<<dfs(0,0,0)<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

// dp[i][j]:=i枚目まで見た時に、和がjとなるような場合の数
using P = pair<ll, ll>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a;
    cin >> n >> a;
    vector<int> x(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
        x[i] -= a;
    }
    map<P, ll> dp;
    set<ll> se;
    queue<ll> que;
    se.insert(0);
    dp[P(0, 0)] = 1;
    for (ll i = 0; i < n; i++)
    {
        for (auto j : se)
        {
            if (!dp[P(i, j + x[i])])
            {
                que.push(j + x[i]);
            }
            dp[P(i + 1, j + x[i])] += dp[P(i, j)];
            dp[P(i + 1, j)] += dp[P(i, j)];
        }
        while (que.size())
        {
            auto tmp = que.front();
            que.pop();
            se.insert(tmp);
        }
    }
    cout << dp[P(n, 0)] - 1 << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<numeric>
#include<map>

using namespace std;

const int MAX_N = 9;
int N, M;
bool g[MAX_N][MAX_N];

int main() {
   cin >> N >> M;
   map<int, int> ref;
   int a, b;
   memset(g, false, sizeof(g));
   for (int i = 0; i < M; i++) {
      cin >> a >> b;
      g[a][b] = true;
      g[b][a] = true;
   }
   vector<int> v(N);
   iota(v.begin(), v.end(), 1);
   int ans = 0;
   do {
      bool flg = true;
      if (v[0] != 1) continue;
      for (int i = 0; i < (int)v.size() - 1; i++) {
         if (!g[v[i]][v[i + 1]]) flg = false;
      }
      if (flg) ans++;
   } while ( next_permutation(v.begin(), v.end()) );
   cout << ans << endl;
   return 0;
}


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

int main(void){
  double W,H,x,y;cin>>W>>H>>x>>y;
  int jud;
  double menseki;
  menseki = (double(W*H))/2.0;
  if(x == W/2 && y == H/2)jud = 1;
  else jud = 0;
  cout<<menseki<<" "<<jud;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

char albt[26] = {'a','b','c','d','e','f','g','h','i','j','k','l',
                 'm','n','o','p','q','r','s','t','u','v','w','x',
                 'y','z'};

//vector<ll> g[202020];
//fill(score, score+202020, 0);
//vector<ll> v;

int main(){
  ll n;
  cin >> n;
  string s;
  cin >> s;
  
  ll ans = 1;
  for (int i=1;i<n;i++){
    if (s[i] != s[i-1]) ans += 1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
//writer：Sakura
//problem：Flip,Flip, and Flip......
//id：arc091_a
//from：Atcoder

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int n,m;
ll ans=0;
int f[1005][1005];
int dx[8]={-1,-1,-1,0,0,1,1,1};
int dy[8]={-1,0,1,-1,1,-1,0,-1};

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d %d",&n,&m);
	if(n==1 && m>1)printf("%d\n",m-2);
	else if(n>1 && m==1)cout<<n-2<<endl;
	else if(n==1 && m==1)cout<<1;
	else cout<<1ll*n*m-2*n-2*m+4<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
const int IMAX = 3001;
ll fac[IMAX + 1], ifac[IMAX + 1];
int dp[3001];

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


	fac[0] = 1;
	rep1(i, IMAX) fac[i] = fac[i - 1] * i % mod;
	ifac[IMAX] = modpow(fac[IMAX], mod - 2);
	for (int i = IMAX; i > 0; i--) ifac[i - 1] = ifac[i] * i % mod;

	int N, A, B, C, D;
	scanf("%d %d %d %d %d", &N, &A, &B, &C, &D);
	dp[0] = 1;
	for (int i = B; i >= A; i--) {
		ll ic = modpow(ifac[i], C);
		for (int j = N - i * C; j >= 0; j--) {
			if (dp[j]) {
				int tmp = dp[j] * ic % mod;
				int p = C;
				for (int k = j + i * C; k <= min(j + i * D, N); k += i) {
					dp[k] += tmp * ifac[p++] % mod;
					if (dp[k] >= mod) dp[k] -= mod;
					tmp = tmp * ifac[i] % mod;
				}
			}
		}
	}
	printf("%lld", dp[N] * fac[N] % mod);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int n;
    string s;
    cin>>n>>s;
    int cnt=0;
    REP(i,s.size()-2){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	for(;;){
	int H,W;
	cin>>H>>W;
	if(H==0&&W==0)break;
	if(H%2==0&&W%2==0){
		for(int i=0;i<H/2;i++){
			for(int j=0;j<W/2;j++){
				cout<<"#.";
			}cout<<endl;
			for(int k=0;k<W/2;k++){
				cout<<".#";
			}cout<<endl;
		}
	}
	if(H%2==0&&W%2==1){
		for(int l=0;l<H/2;l++){
			for(int m=0;m<(W-1)/2;m++){
				cout<<"#.";
			}
			cout<<"#"<<endl;
			for(int n=0;n<(W-1)/2;n++){
				cout<<".#";
			}
			cout<<"."<<endl;
		}
	}
	if(H%2==1&&W%2==0){
		for(int o=0;o<(H-1)/2;o++){
			for(int p=0;p<W/2;p++){
				cout<<"#.";
			}cout<<endl;
			for(int q=0;q<W/2;q++){
				cout<<".#";
			}cout<<endl;
		}
		for(int r=0;r<W/2;r++){
			cout<<"#.";
		}cout<<endl;
	}
	if(H%2==1&&W%2==1){
		for(int s=0;s<(H-1)/2;s++){
			for(int t=0;t<(W-1)/2;t++){
				cout<<"#.";
			}
			cout<<"#"<<endl;
			for(int u=0;u<(W-1)/2;u++){
				cout<<".#";
			}
			cout<<"."<<endl;
		}
		for(int v=0;v<(W-1)/2;v++){
			cout<<"#.";
		}
		cout<<"#"<<endl;
	}cout<<endl;
	}
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;

    vector<int>p(n);

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

    int count=0;

    for (int i=1;i<n-1;i++) {
        if(p[i-1]<p[i]&&p[i]<p[i+1]||p[i-1]>p[i]&&p[i]>p[i+1]){
            count++;
        }
    }

    cout<<count<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
    long int a,i,n;
    long long int sum=0;
    scanf("%ld",&n);
    for(i=1;i<=n;i++){
        if(i%3==0 || i%5==0){
        }
        else {
            sum +=i;
        }
    }
    printf("%lld\n",sum);

    return 0;
}


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

/////////////////////////////////////////////////////////

int comp(pair<int, int> &a, pair<int, int> &b){
  return a.second < b.second;
}

void Main(){
  int N, K; cin >> N >> K;
  vector<pair<int, int>> A(N);
  rep(i, 0, N) A[i] = make_pair(i, 0);
  rep(i, 0, N){
    int tmp; cin >> tmp; tmp--;
    A[tmp].second++;
  }
  sort(A.begin(), A.end(), comp);
  int res = 0;
  rep(i, 0, N - K) res += A[i].second;
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import sys

def main():
	n = int(input())
	
	ins = []
	for _ in range(n):
		t, a = map(int, input().split(" "))
		ins.append((t, a))
		
	takahashi = 0
	aoki = 0
	takahashi, aoki = ins[0]
	
	for i, val in enumerate(ins):
		if i == 0: continue
		t, a = val
		m = max(-(-takahashi // t), -(-aoki // a))
		takahashi, aoki = t * m, a * m
		
	print(takahashi + aoki)

if __name__ == "__main__":
	main()

Measured memory_bytes: 3064
//Written by Rhitwik Saha//
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vb          vector<bool>
// #define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
// #define ub(x)       upper_bound(x)
// #define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N            1e5+5
#define PRIME           998244353
#define MAX         100005
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
int i,j,k;

void Anon_mouS(){
    int a,b,c,k,t=0;
    cin>>a>>b>>c>>k;
    if(a>0){
        k-=a;
        t+=a;
        if(k<0){
            t-=abs(k);
            k=0;
        }
    }
    if(b>0){
        k-=b;
        if(k<0){
            k=0;
        }
    }
    if(c>0){
        k-=c;
        t-=c;
        if(k<0){
            t+=abs(k);
            k=0;
        }
    }
    cout<<t;
}
 
int32_t main(){
    fastio;
    int q=1;
    // cin>>q;
    // build();
    while(q--){
        Anon_mouS();
    }
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N, Q; cin >> N >> Q;
    vector<int> C(N); for (auto &c : C) cin >> c, c--;
    vector<int> L(Q), R(Q);
    for (int i = 0; i < Q; i++) cin >> L[i] >> R[i], L[i]--;
    vector<int> indices(Q); iota(begin(indices), end(indices), 0);
    int sqN = sqrt(N) + 1;
    sort(begin(indices), end(indices), [&](int i, int j) {
        int Si = L[i] / sqN;
        int Sj = L[j] / sqN;
        return make_pair(Si, (Si%2?-1:+1)*R[i]) < make_pair(Sj, (Sj%2?-1:+1)*R[j]);
    });
    vector<int> ans(Q), cnt(N);
    int l = 0, r = 0, type = 0; // [l, r)
    auto add = [&](int i) {
        cnt[C[i]]++;
        if (cnt[C[i]] == 1) type++;
    };
    auto sub = [&](int i) {
        cnt[C[i]]--;
        if (cnt[C[i]] == 0) type--;
    };
    for (int i : indices) {
        while (r < R[i]) add(r++);
        while (L[i] < l) add(--l);
        while (R[i] < r) sub(--r);
        while (l < L[i]) sub(l++);
        ans[i] = type;
    }
    for (int a : ans) {
        cout << a << '\n';
    }
    return 0;
}

Measured memory_bytes: 15484
#include <cstdio>
#include <cstring>
 
int c[201000]; char s[201000];
int st[201000], top = 0, inq[201000][2], T[201000];
int h[201000], nxt[401000], to[401000], K = 0;
bool used[201000][2];
int flag = 0;

void ins(int u, int v) {nxt[++K] = h[u]; h[u] = K; to[K] = v;}

void dfs(int x, int t)
{
	if(inq[x][t]) {flag = 1; return;}
	if(used[x][t]) return;
	st[++top] = x; T[top] = t; 
	inq[st[top]][T[top]] = 1;
	used[x][t] = 1;
	for(int i = h[x]; i; i = nxt[i])
	{
		if(flag) return;
		if(c[to[i]] == (t ^ 1))
		{
			dfs(to[i], c[x]);
		}
	}
	inq[st[top]][T[top]] = 0;
	top--;
}
 
int main()
{
	int n, m; scanf("%d%d", &n, &m);
	scanf("%s", s + 1);
	for(int i = 1; i <= n; i++) c[i] = (s[i] == 'A' ? 1 : 0);
	for(int i = 1; i <= m; i++)
	{
		int u, v; scanf("%d%d", &u, &v);
		ins(u, v); ins(v, u);
	}
	for(int i = 1; i <= n; i++)
	{
		if(!used[i][0])
		{
			dfs(i, 0);
			if(flag) return 0 * puts("Yes");
		}
		if(!used[i][1])
		{
			dfs(i, 1);
			if(flag) return 0 * puts("Yes");
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c,d;
  
  	cin >> a >> b >> c >> d;	
  	if (a + b < c + d ) {
      cout << "Right" << endl;
    } else if (a + b > c + d ){ 
      cout << "Left" << endl;
    } else {
      cout << "Balanced" <<endl;
    }
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
char x[100010];
int main()
{
	scanf("%s",x+1);
	int a = strlen(x+1);
	for(int i=1;i<=a;i++)
	{
		if(x[i]!=x[a-i+1])
		{
			printf("No");
			return 0;
		}
	}
	for(int i=1;i<=(a-1)/2;i++)
	{
		if(x[i]!=x[(a-1)/2-i+1])
		{
			printf("No");
			return 0;
		}
	}
	for(int i=(a+3)/2;i<=a;i++)
	{
		if(x[i]!=x[a-i+(a+3)/2])
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
}

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

int main()
{
	int n,r,next=90;
	double x=0,y=0;
	char tmp;
	while(1)
	{
		cin>>n>>tmp>>r;
		if(n==0&&r==0) break;

		double rad=M_PI/180*next;
		next-=r;

		x+=n*cos(rad);
		y+=n*sin(rad);
	}

	cout<<(int)x<<endl;
	cout<<(int)y<<endl;
	return 0;
}

Measured memory_bytes: 1164
#line 1 "main_a.cpp"
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */

using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;
 
#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, u64 b,Num id=1) {
  if(b==0)return id;
  Num x = id;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

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

  u64 x;
  std::cin>>x;

  std::cout<<(x^1)<<"\n";
  
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back

int s_to_i(string s) {
    int n;
    istringstream is(s);
    is >> n;
    return n;
}

int main() {
    int n; cin >> n;
    rep(YJSNPI, n) {
        string s, t;
        cin >> s;
        t = s;
        sort(s.begin(), s.end());
        sort(t.rbegin(), t.rend());
        int a = s_to_i(s);
        int b = s_to_i(t);
        cout << b - a << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,a,b,i,c=0;
  cin>>k;
  cin>>a>>b;
  for(i=a;i<=b;i++)
  {
    if(i%k==0)
      c++;
  }
  if(c>=1)
    cout<<"OK";
  else
    cout<<"NG";
}
  

Measured memory_bytes: 3592
#include <stdio.h>

#define M 1000
#define NIL -1
#define INF 10000000
#define black 1
#define white 0
#define gray 2

void syokika(int *,int *,int);
void dijkstra(int);

int A[M][M];

int main(){
  int len,path,elem,vert;
  int i,j;

  scanf("%d",&len);

  for(i=0;i<len;i++){
    scanf("%d%d",&elem,&path);
    for(j=0;j<path;j++){
      scanf("%d",&vert);
      scanf("%d",&A[elem][vert]);
    }
  }
  
  dijkstra(len);

  
  
  return 0;
}

void syokika(int *find,int *p,int len){
  int i;
  for(i=0;i<len;i++){
    find[i]=INF;
    p[i]=NIL;
  }
  find[0]=0;
}

void dijkstra(int len){
  int find[M],p[M],min,color[M],u;//warning;
  int i,j;

  syokika(find,p,len);
  for(i=0;i<len;i++) color[i]=white;

  while(1){
    min=INF;
    for(i=0;i<len;i++){
      if(color[i]!=black && find[i] < min){
	min=find[i];
	u=i;
      }
    }
    if(min == INF) break;
    color[u]=black;
    
    for(j=0;j<len;j++){
      if(A[u][j]>0){
	if(color[j]!=black && (find[u]+A[u][j])<find[j]){
	  p[j]=u;
	  find[j]=find[u]+A[u][j];
	}
      }
    }
  }

  for(i=0;i<len;i++) printf("%d %d\n",i,find[i]);
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,M,p,ans;
  cin>>N>>M;
  p=M/2;
  ans=min(N,p);
  M=M-ans*2;
  if(M>0)ans+=M/4;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int N; 
int S[210][210] = {}; 
int par[410] = {}; 
int depth[410] = {}; 
int size[410] = {}; 
int D[210][210] = {}; 
int find(int x){
	if(par[x] == x){
		return x;
	}
	else{
		return par[x] = find(par[x]); 
	}
}
void unite(int x, int y){
	x = find(x); 
	y = find(y); 
	if(x == y) return;
	else if(depth[x] < depth[y]){
		par[x] = y; 
		size[y] += size[x]; 
	}else{
		par[y] = x; 
		size[x] += size[y];  
		if(depth[x] == depth[y]) depth[x] ++; 
	}
}
bool same(int x, int y){
	return find(x) == find(y); 
}
int siz(int x){
	return size[find(x)]; 
}
int main(){
	cin >> N; 
	for(int i = 0; i < N*2; i++){
		par[i] = i; depth[i] = 0; size[i] = 1; 
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			char c; cin >> c; 
			S[i][j] = c - '0'; 
			if(i > j && S[i][j] == 1){
				unite(i, j + N); unite(i + N, j); 
			}
		}
	}
	bool nibu = true; 
	for(int i = 0; i < N; i++){
		if(same(i, i + N)) nibu = false; 
	}
	if(!nibu){
		cout << -1 << endl; return 0; 
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if(S[i][j] == 1) D[i][j] = 1; 
			else if(i != j) D[i][j] = 114514; 
		}
	}
	for(int k = 0; k < N; k++){
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
					D[i][j] = min(D[i][k] + D[k][j], D[i][j]); 
			}
		}
	}	
	int ans = 0; 
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			ans = max(ans, D[i][j]); 
		}
	}
	cout << ans+1 << endl; 
}

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

int main(){
    int r, g, b, n;
    cin >> r >> g >> b >> n;

    int res = 0;

    for(int i = 0; i <= 3000; i++){
        for(int j = 0; j <= 3000; j++){
            int tmp = n - (i * r) - (j * g);
            if(tmp >= 0 && tmp % b == 0)
                res++;
        }
    }

    cout << res << endl;
}

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

int c1, c2;
int n, k;

int main() {
    cin >> n >> k;
    for(int i = 1; i <= n; ++i) {
        if(i % k == 0) c1++;
        if(k % 2 == 0) {
            int z = k / 2;
            if(i % k == z) c2++;
        }
    }
    printf("%lld\n", 1ll * c1 * c1 * c1 + 1ll * c2 * c2 * c2);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
char S[11];
scanf("%s",S);
if((S[5]=='0')&&
((S[6]=='1')||(S[6]=='2')||(S[6]=='3')||(S[6]=='4')))
{
	printf("Heisei\n");
}
else
printf("TBD\n");
	return 0;
}


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

int main() {
	cout << fixed << setprecision(15);
	int N, A, B;
	cin >> N >> A >> B;
	vector<long long> V(N);
	for (int i = 0; i < N; i++) cin >> V[i];
	
	vector<vector<long long>> dp1(N+1, vector<long long>(B+1));
	vector<vector<long long>> dp2(N+1, vector<long long>(B+1));
	dp2[0][0] = 1;
	for (int i = 1; i <=N; i++) {
		for (int j = 0; j <= B; j++) {
			if (j == 0) {
				dp2[i][j] = 1;
				continue;
			}

			long long val_sel = dp1[i-1][j-1] + V[i-1];
			long long val_nosel = dp1[i-1][j];
			long long num_sel = dp2[i-1][j-1];
			long long num_nosel = dp2[i-1][j];
			if ((num_sel > 0) && (num_nosel > 0)) {
				if (val_sel > val_nosel) {
					dp1[i][j] = val_sel;
					dp2[i][j] = num_sel;
				}
				else if (val_sel < val_nosel) {
					dp1[i][j] = val_nosel;
					dp2[i][j] = num_nosel;;
				}
				else {
					dp1[i][j] = val_sel;
					dp2[i][j] = num_sel + num_nosel;;
				}
			}
			else if ((num_sel > 0) && (num_nosel == 0)) {
				dp1[i][j] = val_sel;
				dp2[i][j] = num_sel;
			}
			else if ((num_sel == 0) && (num_nosel > 0)) {
				dp1[i][j] = val_nosel;
				dp2[i][j] = num_nosel;
			}
			else {
				dp1[i][j] = 0;
				dp2[i][j] = 0;
			}
		}
	}

	long double ans_val = 0;
	long long ans_sel = 0;
	for (int i = A; i <= B; i++) {
		if ((long double)dp1[N][i]/i > ans_val) {
			ans_val = (long double)dp1[N][i]/i;
			ans_sel = dp2[N][i];
		}
		else if ((long double)dp1[N][i]/i == ans_val) {
			ans_sel += dp2[N][i];
		}
	}
	cout << ans_val << endl << ans_sel << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	private static long mod = (long)Math.pow(10, 9)+7;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		long sum = 0;
		for(int i = K;i <= N+1;i++){
			long res = (long)(N-i+1)*i+1;
			sum += res%mod;
		}
		System.out.println(sum%mod);
	}
}

Measured memory_bytes: 35644
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    string s;
    cin >> s;
    bool ok = true;
    int len = (int)s.size();
    vector<char> head;
    vector<char> tail;
    for(int i=0; i<len/2; ++i)
    {
        head.push_back(s[i]);
        tail.push_back(s[len-i-1]);
        if(s[i]!=s[len-i-1])
        {
            ok = false;
            break;
        }
        // cout << s[i] << s[len-i-1] << endl;
    }
    int len2 = (int)head.size();
    for(int i=0; i<len2/2; ++i)
    {
        if(head[i]!=head[len2-i-1] || tail[i]!=tail[len2-i-1])
        {
            ok = false;
            break;
        }
    }


    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
L, R = [int(i) for i in input().split()]

if R - L >= 2018:
    print(0)
else:
    if L % 2019 < R % 2019:
        modlist = list(range(L%2019 ,R%2019 +1))
    else:
        modlist = list(range(1,R % 2019 + 1)) + list(range(L % 2019, 2019))

    min_mod = 2018
    for i in range(len(modlist)):
        for j in range(len(modlist) - i - 1):
            mod = (modlist[i]*modlist[i+j+1]) % 2019
            min_mod = min(min_mod, mod)
    print(min_mod)


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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(n);i++)
#define rep2(i, m, n) for(int i=m;i<(n);i++)
#define rrep(i, n, m) for(int i=n;i>=(m);i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> a(M, vector<int>());
    for (int i = 0; i < M; ++i) {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int t;
            cin >> t;
            a[i].push_back(t);
        }
    }
    vector<int> p(M);
    for (int i = 0; i < M; ++i) {
        cin >> p[i];
    }
    
    int ans = 0;
    for (int i = 0; i < (1<<N); ++i) {
        vector<bool> on(N, false);
        for (int j = 0; j < N; ++j) {
            on[j] = (i & (1 << j)) != 0;
        }
        bool ok = true;
        for (int k = 0; k < M; ++k) {
            int cnt = 0;
            for (int j = 0; j < a[k].size(); ++j) {
                int b = a[k][j];
                if (on[b-1]){
                    cnt ++;
                }
            }
            if (cnt % 2 != p[k]){
                ok = false;
            }
        }
        if (ok){
            ans++;
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

h,w = li()
grid = [lc() for _ in range(h)]

black = 0
for row in grid:
    black += row.count("#")
                       
print("Possible") if black == h+w-1 else print("Impossible")

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

int main()
{
    int n,AC=0,WA=0,TLE=0,RE=0;
    cin >> n;

    for(int i=0; i<n; i++)
    {
        string str;
        cin >> str;
        if(str=="AC") AC++;
        if(str=="WA") WA++;
        if(str=="TLE") TLE++;
        if(str=="RE") RE++;
    }
    cout << "AC x " << AC << endl << "WA x " << WA << endl << "TLE x " << TLE << endl << "RE x " << RE << endl;
}


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

int main(){
  long long n,a,b,c,d,e;
  cin>>n>>a>>b>>c>>d>>e;

  long long bt=min(a, min(b,min(c,min(d,e))));
  long long ans=(n+bt-1)/bt+4;

  cout<<ans<<endl;
}


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

using namespace std;

#define ll long long
#define mp make_pair
#define f first
#define s second
#define pb push_back

int main()
{
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    int n;

    cin>>n;
    cout<<1LL*(n-1)*(n)/2;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
sum = 0

for num in range(a, b+1):
    s = list(str(num))
    s_num = len(s)
    t = []
    for i in range(1, s_num+1):
        x = str(s[-i])
        t.append(x)
    if s == t:
        sum += 1

print(sum)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N; cin >> N ;
  vector<int> V (N);
  for (int i = 0; i < N ; ++ i){cin >> V[i];}
  vector<int> C (N);
  for (int i = 0; i < N ; ++ i){cin >> C[i];}
  int ans=0;
  for(int i = 0;i < N;i++){if(V[i] > C[i]){ans += V[i] - C[i];}}
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________
	int k, s;
	cin >> k >> s;
	int ans = 0;
	rep(i, 0, k)
	{
		rep(j, 0, k)
		{
			if (s - (i + j) <= k && s - (i + j) >= 0)
			{
				ans++;
			}
		}
	}
	cout << ans << en;



	return 0;
}



Measured memory_bytes: 3600