akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cin,cout
#include <stdio.h> // printf,scanf (standard input/output)
#include <cstdlib>
#include <cmath>    // abs() for float, and fabs()
#include <string>
#include <algorithm> // min,max
using namespace std;

int main(){
    int N, T, A;
    int H[1000];
    float X[1000];
    
    cin >> N;
    cin >> T >> A;
    for (int i=0;i<N;i++) cin >> H[i];
    for (int i=0;i<N;i++) X[i] = fabs(T - 0.006*H[i] - A);
    
    float min = X[0];
    int result = 1;
    for (int i=0;i<N;i++) {
        if (min > X[i]) {
            min = X[i];
            result = i+1;
        }
    }
    
    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    int n, k; cin >> n >> k;
    vector<int> sunuke(n, 0);
    rep(i, k){
        int d; cin >> d;
        rep(j, d){
            int person; cin >> person;
            if(sunuke[person-1] == 0) sunuke[person-1] = 1;
        }
    }
    int ans = 0;
    rep(i, n) ans += sunuke[i];
    cout << n - ans << endl;
    return 0;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int result = 0;
    for(int i = 1;i < N;i++){
        if(s[i] == 'E'){
            result++;
        }
    }
    int min = result;
    for(int i = 0;i < N;i++){
        if(s[i] == 'W'){
            result++;
        }
        if(s[i+1] == 'E' && i != N-1){
            result--;
        }
        min = std::min(min,result);
    }
    cout << min << endl;
}

Measured memory_bytes: 900
#include <cstdio>
#include <cctype>
using namespace std;

int main(){
  while(true){
    char c;
    scanf("%c", &c);
    if(c == '\n'){
      printf("\n");
      break;
    }
    if(islower(c)) printf("%c", toupper(c));
    else printf("%c", tolower(c));
  }
  return 0;
}

Measured memory_bytes: 2604
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int cnt[100005],n;
int main(){
	cin>>n;
	rep(i,n){
		int a;scanf("%d",&a);cnt[a]++;
	}
	int ans = cnt[0];
	rep(i,100005){
		ans = max(ans,(i?cnt[i-1]:0)+cnt[i]+(i<100000?cnt[i+1]:0));
	}
	cout<<ans<<endl;
}

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


int main() {
	int N;
	double ans=0;
	cin >> N;
	vector<double> vec(N);
	rep(i, N) {
		cin >> vec[i];
	}
	sort(vec.begin(), vec.end());
	for (int i = 1; i < N; i++)
	{
		vec[i] = (vec[i] + vec[i - 1]) / 2.0;
	}
	cout << vec[N-1] << endl;
}

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

int solve(std::string ABCD)
{
    string op[3];
    for (long long bit = 0; bit < (1 << 3); bit++)
    {
        //cout << bitset<8>(bit) << endl;
        long long sum = ABCD[0] - '0';
        for (int i = 0; i < 3; i++)
        {
            if (bit & (1 << i)) //1"+" , 0"-"
            {
                //cout << bitset<8>(bit & (1 << i)) << endl;
                op[i] = "+";
            }
            else
            {
                op[i] = "-";
            }

            //string temp = ABCD[i + 1];

            if (op[i] == "+")
            {
                int temp = ABCD[i + 1] - '0';
                //cout << temp << endl;

                sum += temp; //atoi(ABCD[i + 1].c_str()); //string
            }
            else
            {
                int temp = ABCD[i + 1] - '0';
                sum -= temp; //atoi(ABCD[i + 1].c_str());
            }
            //cout << sum << endl;
        }
        //cout << ABCD[0] << op[0] << ABCD[1] << op[1] << ABCD[2] << op[2] << ABCD[3] << "=7" << sum << endl;

        if (sum == 7)
        {
            cout << ABCD[0] << op[0] << ABCD[1] << op[1] << ABCD[2] << op[2] << ABCD[3] << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string ABCD;
    std::cin >> ABCD;
    solve(ABCD);
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<algorithm>
using namespace std;
const int N=1e5+5;
int cnt[30];
char s[N];

struct node{
	
};

int main(){
	scanf("%s",s);
	bool sign=false;
	for(int i=0;s[i]!='\0';i++){
		cnt[s[i]-'a']++;
		if(s[i]!='x')
			sign=true;
	}
	if(!sign){
		puts("0");
		return 0;
	}
	int count=0;
	char ch;
	for(int i=0;i<26;i++){
		if(cnt[i]&&cnt[i]%2==1&&i!='x'-'a'){
			count++;
		}			
	}
	if(count>1)
		puts("-1");
	else{
		int sum=0,ans=0;
		int i=0,j=strlen(s)-1;
		bool flag;
		if(count==0){
			while(i<j){
				flag=false;
				while(i<j&&s[i]=='x'){
					sum++;
					i++;
				}
				while(i<j&&s[j]=='x'){
					sum--;
					j--;
				}
				if(s[i]==s[j]){
					flag=true;
					if(s[i]!='x')
						ans+=abs(sum);
					i++,j--;
					sum=0;
				}		
				else
					break;
			}
		}
		else{
			while(i<=j){
				flag=false;
				while(i<=j&&s[i]=='x'){
					sum++;
					i++;
				}
				while(i<=j&&s[j]=='x'){
					sum--;
					j--;
				}
				if(s[i]==s[j]){
					flag=true;
					ans+=abs(sum);
					i++,j--;
					sum=0;
				}
				else
					break;
			}
		}
		if(!flag)
			puts("-1");
		else
			printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = a * b;
        if (c % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 22736
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n ;
    vector<int> x(n), y(n);
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    double ans = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            ans += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
        }
    }
    ans /= n;
    cout << setprecision(10) << ans << endl;
}

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

int main() {
string S;
cin >> S;
if(S[0] == S[1] && S[1] == S[2]) { cout << S; return 0; }

for(char i = '1'; i <= '9'; i++) {
  if(S[0] == i) {
    if(S[1] < i) { cout << S[0] << S[0] << S[0]; return 0; }
    else if(S[1] > i) { cout << (S[0] - '0') + 1 << (S[0] - '0') + 1 << (S[0] - '0') + 1; return 0; }
    else if(S[1] == S[0]) {
      if(S[2] < S[1]) { cout << S[0] << S[0] << S[0]; return 0; }
      else { cout << (S[0] - '0') + 1 << (S[0] - '0') + 1 << (S[0] - '0') + 1; return 0; }
     }
  }
}
 return 0;
}

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

int main() {
    ll n; cin >> n;
    ll min = n-1;
    for(int i = 1; i <= sqrt(n)+1; i++){
        ll a = n / i;
        // cout << a << " " << i << " " << a*i << endl;
        if(a*i == n){
            ll tmp = (i-1)+(a-1);
            if(tmp < min) min = tmp;
            // cout << i-1 << " " << a-1 << endl;
        } 
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  string str,fin;
  cin >> str;
  for(int i=0;i<str.length();i++){
    if(str[i]=='0'){
      fin+='0';
}else if(str[i]=='1'){
      fin += '1';
    }else if(!fin.empty()&&str[i]=='B'){
      fin.pop_back();
    }
  }
  cout << fin;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int msum(int a) {
  int ans=0;
  while(a!=0) {
    ans+=a%10;
    a=a/10;
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  int a,b;
  cin >> a >> b;
  int ans = 0;
  orep(i,n) {
    if(a<= msum(i) and msum(i) <= b) ans+=i;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_N 100
int N;
int a[MAX_N];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	rep(i, 0, N) cin >> a[i];
	
	int c[9];
	memset(c, 0, sizeof(c));
	rep(i, 0, N) {
		if(3200 <= a[i]) {
			c[8]++;
			continue;
		}
		rep(j, 0, 8) {
			if(400 * j <= a[i] && a[i] <= 399 + j * 400) c[j]++;
		}
	}

	int min_v = 0, max_v = 0;
	rep(i, 0, 8) {
		if(c[i] != 0) min_v++;
	}
	if(min_v == 0 && c[8] > 0) {
		min_v = 1;
		c[8]--;
	}

	max_v = min_v + c[8];

	cout << min_v << " " << max_v << endl;



}


Measured memory_bytes: 256
S = input()
is_N = S.find("N") != -1
is_W = S.find("W") != -1
is_S = S.find("S") != -1
is_E = S.find("E") != -1
if is_N:
    if is_S:
        flg = True
    else:
        flg = False
else:
    if is_S:
        flg = False
    else:
        flg = True
if not flg:
    print("No")
    exit()


if is_W:
    if is_E:
        flg = True
    else:
        flg = False
else:
    if is_E:
        flg = False
    else:
        flg = True
if not flg:
    print("No")
    exit()


print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
const long long INF = INT64_MAX;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).rbegin(), (v).rend())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define DESC(v) sort((v).rbegin(), (v).rend())
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    cout << (K % 2 == 0 ? A - B : B - A) << endl;
}

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


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


using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

ll dp[110][5][5][5];


//Aを0,Cを1,Gを2,Tを3とみなす
ll dfs(ll n, ll a, ll b, ll c){ //先頭の3文字がa,b,cのとき
  if( a == 0 && b == 2 && c == 1){ return 0;} //AGC自身を含むときは当然0返す
  if( a == 2 && b == 0 && c == 1){ return 0;} //GAC
  if( a == 0 && b == 1 && c == 2){ return 0;} //ACG
  
  if( n == 3){ return 1;} //それ以外のときは列abcの一通りしかありえない ベース
  
  if( dp[n][a][b][c] != -1){ return dp[n][a][b][c];}//メモ化
  
  ll res = 0;
  
  for(ll p = 0; p < 4; p++){
    if( a == 0 && c == 2 && p == 1){continue;} //A?GCは避ける
    if( a == 0 && b == 2 && p == 1){ continue;} //AG?Cも避ける
      res += dfs( n - 1,b,c,p ); res %= MOD;} 
  
  return dp[n][a][b][c] = res;}
  

  

ll N; 

int main(){
  cin >> N;
  for(ll i = 0; i < 110; i++){
    for(ll j = 0; j < 5; j++){
      for(ll k = 0; k < 5; k++){
        for(ll l = 0; l < 5; l++){
        dp[i][j][k][l] = -1;}}}}
    
  ll sum = 0;
    
 for(ll i = 0; i < 4; i++){
   for(ll j = 0; j < 4; j++){
     for(ll k = 0; k < 4; k++){
     sum += dfs(N,i,j,k); sum %= MOD;}}}
  
  cout << sum << endl; return 0;}


Measured memory_bytes: 384
M, D = map(int, input().split())
a = 0
for m in range(1, M+1) :
    for d in range(1, D+1) :
        if d>9 :
            d0 = d%10
            d1 = d//10
            if d0>1 and d1>1 :
                if d0*d1 == m :
                    a += 1
print(a)

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

using namespace std;

typedef long long int64;

int main()
{
  int X, Y, Z, A[100000], B[100000], C[100000];
  cin >> X >> Y >> Z;
  int sz = X + Y + Z;
  int64 ret = 0;
  for(int i = 0; i < sz; i++) {
    cin >> A[i] >> B[i] >> C[i];
    A[i] -= C[i];
    B[i] -= C[i];
    ret += C[i];
  }
  vector< int > order(sz);
  iota(begin(order), end(order), 0);
  sort(begin(order), end(order), [&](int a, int b)
  {
    return (A[a] - B[a] > A[b] - B[b]);
  });
  priority_queue< int, vector< int >, greater<> > que;
  int64 sum = 0LL;
  vector< int64 > left, right;
  left.emplace_back(0LL);
  for(int i : order) {
    que.emplace(A[i]);
    sum += A[i];
    if(que.size() > X) sum -= que.top(), que.pop();
    left.emplace_back(sum);
  }
  while(!que.empty()) que.pop();
  reverse(begin(order), end(order));
  sum = 0LL;
  right.emplace_back(0LL);
  for(int i : order) {
    que.emplace(B[i]);
    sum += B[i];
    if(que.size() > Y) sum -= que.top(), que.pop();
    right.emplace_back(sum);
  }
  reverse(begin(right), end(right));
  int64 beet = numeric_limits< int64 >::min();
  for(int i = 0; i <= sz; i++) {
    if(i >= X && sz - i >= Y) {
      beet = max(beet, left[i] + right[i]);
    }
  }
  cout << beet + ret << endl;
}

Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll t;
	t=1;
	while(t--)
    {
        ll n;
        cin>>n;
        string s,t;
        cin>>s>>t;
        for(int i=0;i<s.length();i++)
            cout<<s[i]<<t[i];
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int W, N;
int input[1024][2];

int main() {
	int i, j;
	int ans[1024][2];
	int t;

	for(t = 0; ; t++) {
		for(i = 0; i < 1024; i++) {
			ans[i][0] = 0;
			ans[i][1] = 0;
			input[i][0] = 0;
			input[i][1] = 0;
		}

		scanf("%d%d", &W, &N);
		if(W == 0)
			break;
		for(i = 0; i < N; i++)
			scanf("%d,%d", &input[i][0], &input[i][1]);

		for(i = 0; i < N; i++) {
			for(j = 1023; j >= input[i][1]; j--) {
				if(ans[j][0] < input[i][0] + ans[j - input[i][1]][0]) {
					ans[j][0] = input[i][0] + ans[j - input[i][1]][0];
					ans[j][1] = input[i][1] + ans[j - input[i][1]][1];
				}
			}
		}

		for(j = 0; ans[W][0] == ans[W - j - 1][0]; j++);

		printf("Case %d:\n%d\n%d\n", t + 1, ans[W - j][0], ans[W - j][1]);
	}

	return 0;
}

Measured memory_bytes: 616
#include <stdio.h>

int main(){
int N,M,Bilangan_Genap,Bilangan_Ganjil;
scanf("%d %d", &N,&M);
if (N==1 && M==1) {
printf("0\n");
}
else {
N=N-1;
M=M-1;
Bilangan_Genap=(N*(N+1))/2;
Bilangan_Ganjil=(M*(M+1)/2);
printf("%d\n",Bilangan_Genap+Bilangan_Ganjil);
}
return 0;

}

Measured memory_bytes: 1728
h, w = map(int, input().split())

s = [["." for _ in range(w + 2)]] + [["."] + list(input()) + ["."] for _ in range(h)] + [["." for _ in range(w + 2)]]

for r in range(1, h + 1):
    for c in range(1, w + 1):
        if s[r][c] == ".":
            s[r][c] = str([s[r + dr][c + dc] for dr in [-1, 0, 1] for dc in [-1, 0, 1]].count("#"))

for r in range(1, h + 1):
    print("".join(s[r][1: w+1]))


Measured memory_bytes: 3188
H,W=map(int,input().split())
field=[]
for i in range(H):
    s=input()
    a=[]
    for j in range(W):
        a.append(s[j])
    field.append(a)

def dfs(x,y):
    field[x][y]='.'
    dx=[0,1]
    dy=[1,0]
    for i in range(2):
        nx=x+dx[i]
        ny=y+dy[i]
        if 0<=nx and nx<H and 0<=ny and ny<W and field[nx][ny]=="#":
            dfs(nx,ny)
            break
    return

dfs(0,0)

for i in range(H):
    for j in range(W):
        if field[i][j]=='#':
            print('Impossible')
            exit()
print('Possible')

Measured memory_bytes: 9152
#include <bits/stdc++.h>
#define INF 1000000000000001
#define ll long long
using namespace std;

int main()
{
  ll a, b;
  cin >> a >> b;
  if (a > b)
  {
    for (ll i = 0; i < a; ++i)
    {
      cout << b;
    }
  }
  else
  {
    for (ll i = 0; i < b; ++i)
    {
      cout << a;
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>                          //include all library
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <string.h>
#include <functional> // greater<int> はfunctionalヘッダ
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)          //REP(i, 10){...} //i=0～i=9までのループ
#define REPR(i, n) for(int i = n;i >= 0;i--)        //REPR(i, 10){...} //i=10～i=0までのループ
#define FOR(i, m, n) for(int i = m;i < n;i++)       //FOR(i, 3, 10){...} //i=3～i=9までのループ
#define FORR(i, m, n) for(int i = m;i >= n;i--)     //FORR(i, 10, 3){...} //i=10～i=3までのループ
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define PI 3.141592653589
#define npos -1


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

	vector<int> vec[M];

	for(int i=0; i<M; i++){
		int k; cin >> k;
		for(int j=0; j<k; j++){
			int s; cin >> s;
			vec[i].pb(s-1);
		}
	}

	int p[M];
	for(int i=0; i<M; i++) cin >> p[i];
	int ans = 0;

	for(int i=0; i<(1<<N); i++){
		bool flag = true;

		for(int j=0; j<M; j++){
			int count=0;
			for(int k:vec[j]){
				if(i>>k & 1) count++;
			}
			if(count%2 != p[j]){
				flag = false;
				break;
			}
		}
		ans += flag;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  string S;
  cin>>S;
  
  if(S=="Sunny"){
    cout<<"Cloudy"<<endl;
  }

  else if(S=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
  
  else{
    cout<<"Sunny"<<endl;
  }

}


Measured memory_bytes: 256
print((function (fh)
	local a,r,n,k = {},10^9,fh:read("*n"),fh:read("*n")-1
	for i=1,n do a[i]=fh:read("*n") end
	table.sort(a)
	for i=1,n-k do r=a[i+k]-a[i]<r and a[i+k]-a[i] or r end
	return r
end)(io.stdin))

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

int main(){
    int n; cin>>n;
    int c0=0, c1=0, c2=0, c3=0;
    for (int i=0; i<n; i++){
        string s; cin>>s;
        if(s=="AC") c0++;
        else if (s=="WA") c1++;
        else if (s=="TLE") c2++;
        else if (s=="RE") c3++;
    }
   
    cout << "AC x "<< c0 << endl;
    cout << "WA x "<< c1 << endl;
    cout << "TLE x "<< c2 << endl;
    cout << "RE x "<< c3 << endl;
}

Measured memory_bytes: 3616
import sys
sys.setrecursionlimit(10**7)
N = int(input())
memo = [-1]*(N+1)
def rec(n):
    if n == 0:
        return 0
    if memo[n] != -1:
        return memo[n]
    res = n
    m = 1
    while m <= n:
        res = min(res,rec(n-m)+1)
        m *= 6
    m = 1
    while m <= n:
        res = min(res,rec(n-m)+1)
        m *= 9
    memo[n] = res
    return memo[n]

print(rec(N))

Measured memory_bytes: 89716
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll frac[300005];

ll comb(ll a, ll b) {
  ll ue = frac[a];
  ll shita1=1, shita2=1;
  ll tmpshita1, tmpshita2, two, h;
  h = mod - 2;
  while(h>0) {
    two = 1;
    tmpshita1 = frac[b];
    tmpshita2 = frac[a-b];
    while(2*two<h) {
      two *= 2;
      tmpshita1 *= tmpshita1;
      tmpshita2 *= tmpshita2;
      tmpshita1 %= mod;
      tmpshita2 %= mod;
    }
    h -= two;
    shita1 *= tmpshita1;
    shita2 *= tmpshita2;
    shita1 %= mod;
    shita2 %= mod;
  }
  return ue*shita1%mod*shita2%mod;
}

int main() {
  frac[0] = 1;
  for(ll i=1;i<300005;++i) {
    frac[i] = frac[i-1]*i%mod;
  }
  ll N, A, B, K;
  cin>>N>>A>>B>>K;
  ll ans = 0;
  for(ll x=0;x<=N;++x) {
    if(K<A*x) continue;
    if((K-A*x)%B==0) {
      if((K-A*x)/B>N) continue;
      ans += comb(N, x)*comb(N, (K-A*x)/B)%mod;
      ans %= mod;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 5876
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll a, b, c; cin >> a >> b >> c;
    cout << max(0LL, c-(a-b)) << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int ana=0;
  long long kekka=0;
  cin >>N;
  
  ana =(N-1)/2;
  
  vector<long long> human(N);
  for(int i=0;i<N;i++){
    cin >> human.at(i);
  }
  
  sort(human.begin(), human.end());
  reverse(human.begin(), human.end());
  
  if(N==2){
    cout<<human.at(0)<<endl;
  }
  else{
    kekka+=human.at(0);
    for(int k=1;k<ana+1;k++){
      kekka+=human.at(k)*2;
    }
    if(N%2==1){
      kekka-=human.at(ana);
    }
	cout << kekka<<endl;
  }
  
}


Measured memory_bytes: 4804
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
	Scanner scn = new Scanner(System.in);
      int check = 0;
      int[] a = new int[9];
      for(int i=0; i<a.length; ++i){
        a[i] = scn.nextInt();
      }
      int x1 = 0;
      int x2 = 0;
      int y1 = 0;
      int y2 = 0;
      x1 = a[3] - a[0];
      x2 = a[6] - a[3];
      y1 = a[1] - a[0];
      y2 = a[2] - a[1];
      
      if(a[4] != a[1]+x1){
        check=1;
      } if(a[5] != a[2]+x1){
        check=1;
      } if(a[7] != a[4]+x2){
        check=1;
      } if(a[8] != a[5]+x2){
        check=1;
      }
      
      if(check==0){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
	}
}


Measured memory_bytes: 35748
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    int r=n%2;
    if(r==0){
        cout<<0.5;
    }else{
        int onum=n/2+1;
        cout<<(double)onum/(double)n<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);
    vector<int> cntR(N+1);
    for(int i=0; i<N; i++) {
        char c; cin >> c;
        cntR[i+1] = cntR[i] + (c == 'R');
    }

    int ans = INF;
    // R < W
    for(int i=0; i<=N; i++) {
        int R_left = cntR[i], R_right = cntR[N] - R_left;
        int W_left = i - R_left, W_right = (N - i) - R_right;
        // swap W_left, R_right
        int mi = min(R_right, W_left);
        R_right -= mi;
        W_left -= mi;

        int cand = mi + R_right + W_left;
        chmin(ans, cand);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4076
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<max(0ll,b*(n-1)+a-a*(n-1)-b+1)<<endl;
    return 0;
}

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

int main()
{
  string s;
  cin >> s;
  int r = 0, l = 0;
  vector<int> p(s.size());
  for (int i = 1; i <= s.size(); i++) {
    if (i < s.size() && s.at(i - 1) == 'R' && s.at(i) == 'L') l = i;
    if (i == s.size() || s.at(i - 1) == 'L' && s.at(i) == 'R') {
      int d = i - r, dr = (d + (r + l) % 2) / 2, dl = d - dr;
      p.at(l - 1) = dr;
      p.at(l) = dl;
      r = i;
    }
  }
  for (int i = 0; i < s.size() - 1; i++) {
    cout << p.at(i) << " ";
  }
  cout << p.at(s.size() - 1) << endl;
}


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

int main() {
	int n, nAss; scanf("%d %d", &n, &nAss);
	int sum = 0;
	
	for (int i = 0; i < nAss; i++) {
		int t; scanf("%d", &t);
		sum += t;
	}
	
	if (sum > n) {
		printf("-1");
	} else {
		printf("%d", n - sum);
	}

	return 0;
}


Measured memory_bytes: 3760
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int a[300010];
int sumL[100010], sumR[100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int L = 0, R = 0;
    priority_queue<int, vector<int>, greater<int>> que1;
    priority_queue<int> que2;
    rep(i, N * 3) cin >> a[i];
    rep(i, N) {
        que1.push(a[i]);
        L += a[i];
    }
    rep(i, N) {
        que2.push(a[N * 3 - i - 1]);
        R += a[N * 3 - i - 1];
    }
    sumL[0] = L;
    rep(i, N) {
        if(a[N + i] > que1.top()) {
            sumL[i + 1] = sumL[i] + a[N + i] - que1.top();
            que1.pop();
            que1.push(a[N + i]);
        }
        sumL[i + 1] = max(sumL[i + 1], sumL[i]);
    }
    rep(i, N + 1) sumR[i] = INF2;
    sumR[N] = R;
    rep(i, N) {
        //cout << a[N * 2 - i - 1] << " " << que2.top() << endl;
        if(a[N * 2 - i - 1] < que2.top()) {
            sumR[N - i - 1] = sumR[N - i] + a[N * 2 - i - 1] - que2.top();
            que2.pop();
            que2.push(a[N * 2 - i - 1]);
        }
        sumR[N - i - 1] = min(sumR[N - i - 1], sumR[N - i]);
    }
    // rep(i, N + 1) cout << sumL[i] << " ";
    // cout << endl;
    // rep(i, N + 1) cout << sumR[i] << " ";
    // cout << endl;
    int ans = -INF2;
    rep(i, N + 1) ans = max(ans, sumL[i] - sumR[i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5876
def main():
    from collections import defaultdict,deque
    from itertools import count
    (n,),*a=[list(map(int,t.split()))for t in open(0)]
    d=defaultdict(count().__next__)
    es=[]
    for i,b in enumerate(a,1):
        for j,k in zip(b,b[1:]):
            x,y=i,j
            if y<x:x,y=y,x
            v,w=i,k
            if w<v:v,w=w,v
            es+=(d[x*n+y],d[v*n+w]),
    s=len(d)
    outs=[[]for _ in range(s)]
    ins=[0]*s
    f=set(range(s))
    for i,j in es:
        outs[i]+=j,
        f-={j}
        ins[j]+=1
    q=deque(f)
    r=[]
    data=[0]*s
    m=0
    while q:
        i=q.popleft()
        r+=i,
        t=data[i]+1
        if t>m:m=t
        for j in outs[i]:
            ins[j]-=1
            if ins[j]<1:q+=j,
            if t>data[j]:data[j]=t
    print(-(len(r)<s)or m)
main()

Measured memory_bytes: 235244
A, B, C = map(int, input().split(" "))
sumABC = sum([A, B, C])
maxABC = max([A, B, C])

if maxABC%2 == sumABC%2:
    print((maxABC*3 - sumABC) // 2)
else:
    print((maxABC*3 + 3 - sumABC) // 2)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws Exception {
        BufferedReader br = 
                new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int num = Integer.parseInt(line);
        int sec = num % 60;
        int min = 0;
        int hour = 0;
        num = num / 60;
        if (num > 0) {
            min = num % 60;
            num = num / 60;
            if (num > 0) {
                hour = num % 60;
            }
        }

        System.out.println(String.format("%d:%d:%d", hour, min, sec));
    }
}

Measured memory_bytes: 24480
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll d(n);
    rep(i, n){
        cin >> d[i];
    }
    ll ans = 0;
    rep(i, n)repr(j, i+1, n){
        ans += d[i]*d[j];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int a,b,c;
    int flag=0;
    cin>>a>>b>>c;
    if(a<b){
        if(b<c){
            flag=1;
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3104
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N = in.i();
        int K = in.i();
        int[] A = in.ii(N);
        int l = 1;
        int r = 1000000000;
        while (l < r) {
            int m = (l + r) / 2;
            int k = 0;
            for (int i = 0; i < A.length; i++) {
                k += (A[i] - 1) / m;
            }
            if (k <= K) {
                r = m;
            } else {
                l = m + 1;
            }
        }
        out.println(r);
    }

    static class MyReader extends BufferedReader {
        char[] cbuf = new char[1024];
        int head = 0;
        int tail = 0;

        MyReader() {
            super(new InputStreamReader(System.in));
        }

        char next() {
            if (head == tail) {
                try {
                    tail = read(cbuf, 0, cbuf.length);
                } catch (IOException e) {}
                head = 0;
            }
            return cbuf[head++];
        }

        void back() {
            head--;
        }

        boolean minus() {
            boolean minus;
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    if (!(minus = c == '-')) back();
                    return minus;
                }
            }
        }

        void skip() {
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    back();
                    break;
                }
            }
        }

        char[] s(final int N) {
            skip();
            char[] s = new char[N];
            for (int i = 0; i < s.length; i++) {
                s[i] = next();
            }
            return s;
        }

        int i() {
            boolean minus = minus();
            int n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }

        int[] ii(final int N) {
            int[] a = new int[N];
            for (int j = 0; j < a.length; j++) a[j] = i();
            return a;
        }

        long l() {
            boolean minus = minus();
            long n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }
    }
}


Measured memory_bytes: 36148
import java.util.Scanner;

public class Main {

    static int[] x;
    static int[] y;
    static double sum = 0;
    static int count = 0;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        x = new int[n];
        y = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(scan.next());
            y[i] = Integer.parseInt(scan.next());
        }
        scan.close();

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(i);
        }

        permutation(sb.toString(), "");

        System.out.println(sum / count);

    }

    private static void permutation(String q, String ans) {
        if (q.length() == 1) {
            String s = ans + q;
            for (int i = 0; i < s.length() - 1; i++) {
                int start = Integer.parseInt(s.substring(i, i + 1));
                int end = Integer.parseInt(s.substring(i + 1, i + 2));
                sum += Math.sqrt((x[start] - x[end]) * (x[start] - x[end]) + (y[start] - y[end]) * (y[start] - y[end]));
            }
            count++;
        } else {
            for (int i = 0; i < q.length(); i++) {
                permutation(q.substring(0, i) + q.substring(i + 1), ans + q.charAt(i));
            }
        }
    }

}


Measured memory_bytes: 51252
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    B = list(map(int, input().split()))

    res = []
    while B:
        for i in reversed(range(len(B))):
            if B[i] == i + 1:
                b = B.pop(i)
                res.append(b)
                break
        else:
            print(-1)
            exit()
    print(*res[::-1], sep="\n")


if __name__ == '__main__':
    resolve()


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

int main(){
  long long H,W;
  long long ans;
  cin>>H>>W;
  if((W==1)||(H==1)){
    cout<<1<<endl;
    return 0;
  }
  if (W%2==0){
    ans=H*(W/2);
    cout<<ans<<endl;
    return 0;
  }
  if(H%2==0){
    ans=(((W-1)/2)*(H/2)+((W+1)/2)*(H/2));
    cout<<setprecision(18)<<ans<<endl;
    return 0;
  }
  ans=(((W-1)/2)*((H-1)/2)+((W+1)/2)*((H+1)/2));
   cout<<setprecision(18)<<ans<<endl;
  return 0;
}

  
  

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

int main(){
    int A,B,X;
    cin >> A >> B >> X;
    if (A <= X & X <= A + B) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}

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

int main()
{
    int n, k; cin >> n >> k;
    vector<ll> h(n);
    for(int i=0;i<n;i++) cin >> h[i];
    sort(h.begin(),h.end());
    ll ans = 1e9;
    for(int i=0;i<=n-k;i++) ans = min(ans,abs(h[i+k-1]-h[i]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
n=int(input())
dp=[[0 for j in range(3)] for i in range(n+1)]
for i in range(1,n+1):
  a,b,c=map(int,input().split())
  dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a
  dp[i][1] = max(dp[i-1][2],dp[i-1][0])+b
  dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c
print(max(dp[n]))

Measured memory_bytes: 62044
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
    }

    let mut num = (n - 1) * n / 2;
    let mut edges = vec![];

    if n % 2 == 0 {
        num -= n / 2;
        for i in 1..=n {
            for j in i+1..=n {
                if i + j == n + 1 {
                    continue;
                }
                edges.push((i, j));
            }
        }
    } else {
        num -= (n-1) / 2;
        for i in 1..=n {
            for j in i+1..=n {
                if i + j == n {
                    continue;
                }
                edges.push((i, j));
            }
        }
    };

    println!("{}", num);
    for (a, b) in edges {
        println!("{} {}", a, b);
    }
}


Measured memory_bytes: 2176
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;
const ll inf = 10e17;
const ld eps = 10e-9;



ll solve(void);
ll gcd(ll x, ll y);

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

ll mulmod(ll x, ll y)
{
	return (x * y) % mod;
}

ll submod(ll x, ll y)
{
	return (x - y + 100 * mod) % mod;
}

ll power(ll n, ll r)
{
	if ( r == 0 ) { return 1; }
	if ( r == 1 ) { return n; }
	if ( n == 0 ) { return 0; }
	if ( n == 1 ) { return 1; }

	if (r % 2 == 0)
	{
		ll y = power(n, r/2);
		return mulmod(y, y);
	}
	else
	{
		ll y = power(n, (r-1)/2);
		return n * mulmod(y, y) % mod;
	}
}

ll gcd(ll x, ll y)
{
	if (y == 1) { return 1;}
	if (x % y == 0) { return y; }
	return gcd(y, x % y);
}

vector<ll> perm;
vector<ll> inv;
void init_inv(ll m)
{
	perm.resize(m);
	inv.resize(m);
	
	perm[0] = 1;
	inv[0] = 1;

	for (ll i = 1; i < m; i++)
	{
		perm[i] = mulmod(perm[i-1], i);
	}
	
	for (ll i = 1; i < m; i++)
	{
		inv[i] = power(perm[i], mod - 2);
	}
}

ll ncr(ll n, ll r)
{
	// n (n-1) ... (n-r)
	if ( r == n || r == 0 ) { return 1; }

	ll ans = 1;
	//for (ll i = 0; i < r; i++)
	//	ans = mulmod(ans, n - i);

	// return mulmod(ans, inv[r]);
	return mulmod(perm[n], mulmod(inv[n-r], inv[r]));
}

ll solve(void)
{
	string s, t, u;
	cin >> s >> t;

	ll a, b;
	cin >> a >> b;

	cin >> u;

	if ( s == u ) a--;
	if ( t == u ) b--;

	cout << a << " " << b << endl;

	return 0;
}



Measured memory_bytes: 256
n, k, q = [int(x) for x in input().split()]
a = []
for i in range(q):
    a.append(int(input()))

n_list = [k - q for i in range(n)]

for i in range(q):
    n_list[a[i] - 1] += 1

for i in range(n):
    if n_list[i] > 0:
        ans = 'Yes'
    else:
        ans = 'No'
    print(ans)

Measured memory_bytes: 11816
import sys
sys.setrecursionlimit(2*10**5)

# 入力
N = int(input())
a, b = (
    zip(*(map(int, input().split()) for _ in range(N - 1))) if N - 1 else
    ((), ())
)

G = [set() for _ in range(N + 1)]
for x, y in zip(a, b):
    G[x].add(y)
    G[y].add(x)


dp = [0 for _ in range(N + 1)]
dp[1] = 1


def f(i):
    for j in G[i]:
        if dp[j] == 0:
            dp[j] = i
            f(j)


f(1)
p = []
i = N
while i != 1:
    p.append(i)
    i = dp[i]
p.append(1)
dp2 = [0 for _ in range(N + 1)]
for j in range(len(p)):
    if dp2[p[-(j + 1)]] == 0:
        dp2[p[-(j + 1)]] = 1
    if dp2[p[j]] == 0:
        dp2[p[j]] = -1
dp3 = [0 for _ in range(N + 1)]
dp3[1] = 1


def g(i):
    for j in G[i]:
        if dp3[j] == 0 and dp2[j] != -1:
            dp3[j] = 1
            g(j)


g(1)
ans = (
    'Fennec' if dp3.count(1) > N // 2 else
    'Snuke'
)
print(ans)


Measured memory_bytes: 134892
n,k = map(int,input().split())
s = input()
key = s[0]
count = 0
for i in range(1,n):
    if key == s[i]:
        count += 1
    else:
        key = s[i]

ans = count+2*k
if ans >= n:
    print(n-1)
else:
    print(ans)


Measured memory_bytes: 3316
#define REP(i, n) for (int i = 0; i < (n); ++i)

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

signed main() {
  ios::sync_with_stdio(false);
  long long a, b, c;
  cin >> a >> b >> c;
  cout << min({c, b / a}) << endl;
  return 0;
}


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

using namespace std;

using int64 = long long;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if(A > B) swap(A, B);
  if(A > C) swap(A, C);
  if(B > C) swap(B, C);
  cout << C - A << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
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> r(N);
  for (int i = N-1; i >= 0; i--) {
    int p = -1;
    for (int j = 0; j < v.size(); j++) {
      if (v[j] == j+1) p = j;
    }
    if (p == -1) {
      cout << -1 << endl; return 0;
    }
    r[i] = p+1;
    v.erase(v.begin()+p);
  }
  for (int i = 0; i < N; i++) cout << r[i] << endl;
}

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

typedef long long ll;
#define endl "\n"

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int h,w,k;
    cin>>h>>w>>k;
	int ans=0;
	vector<vector<char>> grid(h, vector<char>(w));
	for (auto &x:grid){for (auto &y:x){cin>>y;}}
	for (int i=0; i<(1<<h); ++i){for (int j=0; j<(1<<w); ++j){int cnt=0; for (int x=0; x<h; ++x){for (int y=0; y<w; ++y){if (grid[x][y]=='#'&&(i&(1<<x))&&(j&(1<<y))){cnt++;}}}if (cnt==k){ans++;}}}
	cout<<ans;
}

Measured memory_bytes: 3660
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int N;
int key[102];
char h[102];
string s;

void inc(int& idx) {
  ++idx;
  idx %= N;
}

char chg(char c, int didx) {
  int numIdx;
  if (isupper(c)) numIdx = c - 'A' + 26;
  else numIdx = c - 'a';
  
  if ((numIdx - didx) >= 0)
    return h[numIdx - didx];
  return h[52 + (numIdx - didx)];
}

string solve() {
  const int M = s.size();
  string ret = s;
  int idx = 0;
  rep(i,M) {
    ret[i] = chg(s[i], key[idx]);
    inc(idx);
  }
  return ret;
}

int main() {
  rep(i,26) h[i] = 'a' + i;
  rep(i,26) h[i+26] = 'A'+i;
  
  while (cin >> N, N) {
    rep(i,N) cin >> key[i];
    cin >> s;
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
/*
Created on Thu Aug 27 21:32:39 2020

@author: roastedcoder

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
const int mod = 1e9+7;
const int INF = INT_MAX;
#define endl "\n"
#define append push_back
#define roastedcoder ios_base::sync_with_stdio(false); cin.tie(NULL);
//__________________________________________________________________


int main() {
	roastedcoder
	string a, b; cin>>a>>b;
	int n = a.length(), m = b.length();
	int res = INT_MAX;
	for(int i = 0; i<n-m+1; i++) {
		int tmp = 0;
		for(int j = i; j<i+m; j++) {
			if(a[j] != b[j-i]) tmp += 1;
		}
		res = min(res, tmp);
	}
	cout<<res<<endl;
}

//__________________________________________________________________
/*
Sample Input:


Sample Output:


*/


Measured memory_bytes: 3628
n = list(map(int, input().split()))


def solve(m):
    ans = 0
    while True:
        m = sorted(m)
        if m[0] == m[1] == m[2]:
            print(ans)
            return

        if m[-1] >= m[0] + 2:
            m[0] += 2
            ans += 1
        else:
            m[0] += 1
            m[1] += 1
            ans += 1


solve(n)


Measured memory_bytes: 3060