akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n, total = 0, max_n = 1, exclude;
  cin >> n;
  
  while(1) {
    total += max_n ;
    if(total >= n)
      break;
    max_n ++;
  } 
  exclude = total - n;
  fi(1, max_n + 1) {
    if(i != exclude)
      cout << i << endl;
  }
  // cout << ans << endl;
  return 0;
}



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

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

    int ans = (1900 * m + 100 * (n - m)) * pow(2, m);

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


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;

int n,a[200100],b[200100];

int main() {
	ios::sync_with_stdio(0);
	cin.tie();
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int l=0, r=n-1, cnt=0;
	for(int i=n-1;i>=0;i--){
		if(cnt%2==0){
			b[l++] = a[i];
		}
		else{
			b[r--] = a[i];
		}
		cnt++;
	}
	for(int i=0;i<n;i++){
		if(i) cout<<" ";
		cout<<b[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var r = int.Parse(Console.ReadLine());
 
			Console.WriteLine(2 * r * 3.1415);
		}
	}
}

Measured memory_bytes: 18612
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	try{
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    int[] array = new int[6];
	    int[] arr = new int[3];

	    StringTokenizer str;
	    
	    for(int i=0; i<3; i++){
		str = new StringTokenizer(br.readLine());
		int j=0;
		while(str.hasMoreTokens()){
		    array[j] = Integer.valueOf(str.nextToken());
		    j++;
		}
		arr[i] = 60*60*array[3]+60*array[4]+array[5] - 60*60*array[0]-60*array[1]-array[2];
	    }
	    
	    for(int i=0; i<3; i++){
		System.out.println(arr[i]/3600+" "+(arr[i]%3600)/60+" "+(arr[i]%60));
	    }
	}catch (Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 9316
#include <stdio.h>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define NUM (60000)
int pt[NUM];
int cnt[NUM];

int main() {
    vector<int> ps;
    for (int i = 2; i < NUM; i++) if (pt[i] == 0) {
        ps.push_back(i);
        for (int j = i+i; j < NUM; j+=i) pt[j] = i;
    }
    rep (i, ps.size()) rep (j, i+1) {
        if (ps[i]+ps[j] >= NUM) break;
        cnt[ps[i]+ps[j]]++;
    }
    for (;;) {
        int n;
        scanf("%d", &n);
        if (n == 0) return 0;
        printf("%d\n", cnt[n]);
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

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

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


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

	int max_d = 0;
	for (int i = 1; i < n; i++) 
		max_d = max(max_d, a[i] - a[i - 1]);

	max_d = max(max_d, k - a[n-1] + a[0]);

	cout << k - max_d << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c,k;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
	long long ans = min(a,k);
	k -= a;
	k = k-b;
	if(k > 0){
		ans -= k;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
  int city, road;
  cin >> city >> road;

  vector<int> data(city);

  for (int i = 0; i < road; i++) {
    int a, b;
    cin >> a >> b;
    
    data.at(a - 1)++;
    data.at(b - 1)++;
  }

  for (int i = 0; i < city; i++) {
    cout << data.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  string S;
  cin >> S ;
  int ans =  0 ;
  int count = 0 ;
  rep(i,S.size()){
	if(S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'T' ||  S.at(i) == 'G' )count++ ;
    else{
      ans = max(ans,count) ;
      count = 0 ;
    }
  }
  ans = max(ans,count) ;
  cout << ans << endl  ;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//

using namespace std;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0}; //次に行くところ
int dx[] = {0,1}; //上に同じ


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,w;
  cin >> h >> w;
  vector<vector<char>> a(h,vector<char>(w));
  vector<vector<long long>> dp(h+1,vector<long long>(w+1));

  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      cin >> a[i][j];
    }
  }

  dp[1][1] = 1;
  for (int i = 1; i <= h; i++){
    for (int j = 1; j <= w; j++){
      if ((i == 1 && j == 1) || (a[i-1][j-1] == '#')){
        continue;
      }
      dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % 1000000007;
    }
  }
  
  cout << dp[h][w] << '\n';
  return 0;
}

Measured memory_bytes: 12052
#include<stdio.h>

int main()
{
	int a, b, c;
	
	while(scanf("%d %d %d", &a, &b, &c) != EOF)
	{
		if(a == -1 && b == -1 && c == -1)
		{
			break;
		}
		if((a == -1 || b == -1) && c == -1)
		{
			printf("F\n");
		}
		else
		{
			int sum = 0, k = 0;
			if(a >= 0)
			{
				sum += a;
			}
			if(b >= 0)
			{
				sum += b;
			}
			if(sum >= 80)
			{
				printf("A\n");
			}
			else if(sum >= 65 && sum < 80)
			{
				printf("B\n");
			}
			else if((sum >= 50 && sum < 65) || c >= 50)
			{
				printf("C\n");
			}
			else if(sum >= 30 && sum < 50)
			{
				printf("D\n");
			}
			else
			{
				printf("F\n");
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 2576
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
  int n;
  scanf("%d",&n);
  if(n%10==9)
    printf("Yes\n");
  else if(n/10==9)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 128
S = input()

N1 = [0]*(len(S)+1)
N2 = [0]*(len(S)+1)

count1 = 0
count2 = 0

for i in range(len(S)):
  if S[i] == "<":
    count1 += 1
    N1[i+1] = count1
  else:
    count1 = 0
    
for i in range(len(S)):
  if S[-(i+1)] == ">":
    count2 += 1
    N2[-(i+2)] = count2
  else:
    count2 = 0
ans = 0
for i in range(len(N1)):
  ans += max(N1[i],N2[i])
print(ans)
  

Measured memory_bytes: 51144
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

int main()
{
    int A,B,C;
    cin >> A >> B >> C;
    if(A==B)
    {
        cout << C;
    }
    else if(A == C)
    {
        cout << B;
    }
    else
    {
        cout << A;
    }
}


Measured memory_bytes: 256
from sys import stdin
input = stdin.readline
ri = lambda : int(input())
ril = lambda : list(map(int, input().split()))

def main():
  K = ri()
  m = 0
  ans = -1
  for i in range(K):
    m = (10 * m + 7) % K
    if m == 0:
      ans = i + 1
      break
  print(ans)

if __name__ == '__main__':
  main()


Measured memory_bytes: 9028
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	int div=n/1.08;
	for(int i=div;i<=div+2;i++){
		if(floor((double)i*1.08)==n) {cout<<i<<endl; return 0;}
	}
	cout<<":("<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define COUT(a) cout << (a);
#define ENDL cout << "\n";

int main() {
    int n,m;
    scanf("%d %d\n",&n,&m);
    if(m%n==0) COUT(n+m)
    else COUT(m-n)
}




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

vector <long long> path;
int vis[100010];

int main () {
	memset(vis, -1, sizeof(vis));
	long long n, x, mod; cin >> n >> x >> mod;
	while (vis[x] == -1) {
		vis[x] = path.size();
		path.push_back(x);
		x = x * x % mod;
	}
	int pos = vis[x];
	long long ans = 0;
	int len = (int)path.size() - pos;
	long long k = (n - pos) / len, sum = 0;
	for (int i = 0; i < pos; i++) {
		ans += path[i], n--;
		if (n == 0) goto END;
	}
	for (int i = pos; i < path.size(); i++) {
		sum += path[i];
	}
	ans += k * sum, n %= len;
	for (int i = pos; i < pos + n; i++) {
		ans += path[i];
	}
	END:;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4236
N = int(input())
# A = []
# B = []
A_B = []
for i in range(N):
    a, b = map(int, input().split())
    A_B.append([a,b])
C = sorted(A_B, key=lambda x:x[1])
sum = 0
import sys
for i in range(N):
    sum += C[i][0]
    if sum > C[i][1]:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 39704
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

struct edge
{
    int to;
    int w;

    edge(int to, int w):
        to(to), w(w)
    { }
};

bool dfs(const vector<vector<edge> >& g, int cur, int d, vector<bool>& used, vector<int>& dist)
{
    used[cur] = true;
    dist[cur] = d;
    
    int n = g[cur].size();

    for(int i = 0; i < n; i++) {
        int to = g[cur][i].to;
        if(!used[to]) {
            if(!dfs(g, to, d + g[cur][i].w, used, dist))
                return false;
        } else {
            if(dist[to] != d + g[cur][i].w)
                return false;
        }
    }

    return true;
}

int main()
{
    int n, m;
    cin >> n >> m;
    
    vector<vector<edge> > g(n);

    int from, to, w;
    for(int i = 0; i < m; i++) {
        cin >> from >> to >> w;
        from--, to--;
        g[from].push_back(edge(to, w));
        g[to].push_back(edge(from, -w));
    }

    vector<bool> used(n);
    vector<int> dist(n);

    for(int i = 0; i < n; i++) {
        if(!used[i]) {
            if(!dfs(g, i, 0, used, dist)) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, MOD = 1e9 + 7;
int f[N], sum[N];
long long s[N];
bool lf[N], rf[N];
bool debug = 0;
int main() {
	int n;
	long long A, B;
	int seed = time(NULL);
	if (debug) {
		cout << seed << endl;
	}
	srand(seed);
	if (debug) {
		n = 20;
		A = rand() % 100 + 1;
		B = rand() % 100 + 1;
	}
	else {
		scanf("%d%lld%lld", &n, &A, &B);
	}
	vector<int> all;
	for (int i = 0; i <= 1000; ++ i) all.push_back(i);
	for (int i = 1; i <= n; ++ i) {
		if (debug) {
			int t = rand() % all.size();
			s[i] = all[t];
			all.erase(all.begin() + t);
		}
		else {
			scanf("%lld", &s[i]);
		}
	}
	sort(s + 1, s + 1 + n);
	if (debug) {
		cout << A << " " << B << endl;
		for (int i = 1; i <= n; ++ i) cout << s[i] << " "; cout << endl;
	}
	if (A < B) swap(A, B);
	int ans = 0, L, R;
	for (int i = 1; i + 2 <= n; ++ i) if (s[i + 2] - s[i] < B) {
		puts("0");
		goto eee;
	}
	lf[0] = lf[1] = 1;
	for (int i = 2; i <= n; ++ i) lf[i] = lf[i - 1] && (s[i] - s[i - 1] >= B);
	rf[n + 1] = rf[n] = 1;
	for (int i = n - 1; i >= 1; -- i) rf[i] = rf[i + 1] && (s[i + 1] - s[i] >= B);
	f[0] = sum[0] = 1;
	ans = rf[1];
	L = 1, R = 0;
	for (int i = 1; i <= n; ++ i) {
		if (i > 1 && s[i] - s[i - 1] >= A) f[i] = f[i - 1];
		while (R + 2 < i && s[i] - s[R + 1] >= A) ++ R;
		if (i > 2 && s[i - 1] - s[i - 2] < B) L = i - 2;
		if (lf[i - 1]) (++ f[i]) %= MOD;
		if (L <= R) (f[i] += (sum[R] - sum[L - 1] + MOD) % MOD) %= MOD;
		sum[i] = (sum[i - 1] + f[i]) % MOD;
		if (rf[i + 1]) (ans += f[i]) %= MOD;
	}
	printf("%d\n", ans);
eee:
	if (debug) {
		int duipai = 0;
		for (int mask = 0; mask < (1 << n); ++ mask) {
			vector<int> a, b;
			for (int i = 0; i < n; ++ i) if (mask >> i & 1) a.push_back(s[i + 1]); else b.push_back(s[i + 1]);
			bool flag = 1;
			for (int i = 1; i < (int) a.size(); ++ i) if (a[i] - a[i - 1] < A) flag = 0;
			for (int i = 1; i < (int) b.size(); ++ i) if (b[i] - b[i - 1] < B) flag = 0;
			if (flag) duipai ++;
		}
		assert(duipai == ans);
	}
}



Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
using namespace std;
 
 int main(){
     int N;
     cin >> N;
     int a[N];
     for(int i =0; i < N; i++) {
         cin >> a[i];
     }
     int x = N;
     sort(a, a + N);
     for (int i = 0; i < N; i++) {
         if (a[i] == a[i+1]){
             x--;
         }
     }
     cout << x << endl;
 }


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

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

int main() {
    //input
    double W;
    double H;
    double x;
    double y;
    std::cin >> W;
    std::cin >> H;
    std::cin >> x;
    std::cin >> y;

    cout << W * H / 2 << " " << (W/2 == x && H/2 == y);

    return 0;
}

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

int main() {
  int h,w;cin>>h>>w;
  vector<vector<char>> s(h,vector<char>(w));
  rep(i,h)rep(j,w)cin>>s[i][j];
  rep(i,h)rep(j,w){
    if(s[i][j]=='.'){
      s[i][j]='0';
      for(int dx=-1;dx<=1;dx++){
        for(int dy=-1;dy<=1;dy++){
          int nx=i+dx,ny=j+dy;
          if(0<=nx&&nx<h&&0<=ny&&ny<w&&s[nx][ny]=='#')s[i][j]++;
        }
      }
    }
  }
  rep(i,h)rep(j,w){
    cout<<s[i][j];
    if(j==w-1)cout<<endl;
  }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int N,L[110]={};
int main(){
  cin >>N;
  for(int i=0;i<N;i++){
    cin >> L[i];
  }
  sort(L,L+N);
  //reverse(L,L+N);
  int sum=0;
  for(int i=0;i<N-1;i++){
    sum +=L[i];
  }
  //cout << sum << endl;
  if(sum>L[N-1]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <set>
#include <algorithm> 
#include <iostream>
#include <bits/stdc++.h>
 
//------------------------------------------------------------------------------
 
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define mod 1000000007
#define ll long long
#define pb emplace_back
#define mp make_pair
#define sf scanf
#define pf printf
#define F first
#define S second
 
//------------------------------------------------------------------------------
using namespace std;
 
 
ll int n,dp[100010][4],a[100010][4]={0};

ll int vacation(ll int day, ll int last_activity)
{
    if(dp[day][last_activity]!=-1) return dp[day][last_activity];
    if(day>=n) return 0;
    
    ll int happy=-999999999999;
    for(int i=0; i<3;i++){
        if(i!=last_activity)
          happy=max(happy,a[day][i]+vacation(day+1,i));
    }
    
    return dp[day][last_activity]=happy;
}
 
 
int main() 
{
	fio;
	memset(dp,-1,sizeof(dp));
	ll int x;
	sf("%lld",&n);
	
	for(ll int i=0;i<n;i++)
	 for(int j=0;j<3;j++)
	   sf("%lld",&a[i][j]);
	
	x=vacation(0,5);
	
	pf("%lld\n",x);
    
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/agc017_a.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

ll comb(int n, int k) {
  if (k == 0) return 1;
  if (n / 2 < k) return comb(n, n - k);
  ll ans = 1;
  vector<int> p(0);
  vector<int> q(0);
  rep(i, k) { p.push_back(n - i); }
  repi(i, 1, k + 1) { q.push_back(i); }
  rep(i, k) {
    ans *= p[i];
    ans /= q[i];
  }

  return ans;
}

int main() {
  INPUT_FILE CIN_OPTIMIZE;
  int N, P;
  cin >> N >> P;

  int even = 0;
  int odd = 0;
  rep(i, N) {
    int a;
    cin >> a;
    if (a % 2 == 0) {
      even++;
    } else {
      odd++;
    }
  }

  ll ans = 0;
  ll c_even = 0, c_odd = 0;
  if (P == 0) {
    rep(i, even + 1) { c_even += comb(even, i); }
    for (int i = 0; i <= odd; i += 2) {
      c_odd += comb(odd, i);
    }
    ans = c_even * c_odd;
  } else {
    rep(i, even + 1) {
      // printf("%d, %d, comb:%lld\n", even, i, comb(even, i));
      c_even += comb(even, i);
    }
    for (int i = 1; i <= odd; i += 2) {
      c_odd += comb(odd, i);
    }
    ans = c_even * c_odd;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

string s; int n;
ll dp[1 << 18][8];

ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x%mod;
		x = x * x%mod; n >>= 1;
	}
	return res;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s; n = s.length(); int d = (n - 3) / 2;
	if (n == 1) {
		if (s[0] == '0')cout << 0 << endl;
		else cout << 1 << endl;
		return 0;
	}
	int num = 0;
	rep(i, n) {
		if (s[i] == '?')num++;
	}
	int cnt = 0;
	rep(i, 8) {
		bool valid = true;
		rep(j, 3) {
			int t = 0;
			if (i&(1 << j))t = 1;
			if (t == 0 && s[2-j] == '1')valid = false;
			if (t == 1 && s[2-j] == '0')valid = false;
		}
		if (valid)dp[0][i] = 1;
	}
	ll ans = 0;
	rep(i, 3) {
		if (s[i] == '?')cnt++;
	}
	rep(i, d) {
		ans = (ans + dp[i][6] * mod_pow(2, num - cnt) % mod + dp[i][7] * mod_pow(2, num - cnt) % mod) % mod;
		char le = s[2 * i + 3], ri = s[2 * i + 4];
		vector<int> v;
		if (le != '1'&&ri != '1')v.push_back(0);
		if (le != '1'&&ri != '0')v.push_back(1);
		if (le != '0'&&ri != '1')v.push_back(2);
		if (le != '0'&&ri != '0')v.push_back(3);
		int len = v.size();
		rep(j, len) {
			dp[i + 1][v[j]] = (dp[i + 1][v[j]] + dp[i][0] + dp[i][1]+dp[i][2]) % mod;
			dp[i + 1][v[j] + 4] = (dp[i + 1][v[j] + 4] + dp[i][3] + dp[i][5]) % mod;
			dp[i + 1][4 + v[j] % 2] = (dp[i + 1][4 + v[j] % 2] + dp[i][4]) % mod;
		}
		if (le == '?')cnt++;
		if (ri == '?')cnt++;
	}
	ans = (ans + dp[d][3] + dp[d][5] + dp[d][6] + dp[d][7]) % mod;
	cout << ans << endl;
	//stop
	return 0;
}

Measured memory_bytes: 10900
#include<stdio.h>
int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b){
		printf("a > b\n");
	}
	else if(a<b){
		printf("a < b\n");
	}
	else if(a==b){
		printf("a == b\n");
	}
	
	return 0;
}


Measured memory_bytes: 2568
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
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)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


ll a, b, ans;

long long GCD(ll a, ll b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main() {

	cin >> a >> b;

	ans = a * b / GCD(a, b);
	
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int INF = 0x3f3f3f3f;

void run_case() {
    int n, m;
    cin >> n >> m;
    vector<int> cost(m), mask(m);
    for(int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        cost[i] = a;
        while(b--) {
            int c; cin >> c;
            c--;
            mask[i] |= (1 << c);
        }
    }
    vector<int> d(1<<n, INF), e(1<<n);
    d[0] = 0;
    for(int i = 0; i < m; ++i) {
        copy(d.begin(), d.end(), e.begin());
        for(int k = 0; k < (1<<n); ++k) {
            int newk = k | mask[i];
            e[newk] = min(e[newk], d[k] + cost[i]);
        }
        swap(d, e);
    }
    cout << (d[(1<<n)-1] == INF? -1: d[(1<<n)-1]);
}


int main() {
    //freopen("input", "r", stdin);
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

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

int main()
{
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    
    int dx = x2 - x1, dy = y2 - y1;
    int x3 = x2 - dy, y3 = y2 + dx;
    int x4 = x1 - dy, y4 = y1 + dx;

    cout<< x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}

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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
#define MOD (int) 1e9+7
#define inf (int) (1e18)

void solve(){
    long int n;
    cin>>n;
    long int x[n];
    for(long int i=0;i<n;i++){
        cin>>x[i];
    }
    sort(x,x+n);
    vector<int> v(x[n-1]+10,0);
    long int ans=0;
    for(long int i=0;i<n;i++){
        if(i>0 && x[i]==x[i-1]){
            v[x[i]]=1;
            continue;
        }
        int j=2;
        while(x[i]*j<x[n-1]+10){
            v[x[i]*j]=1;
            j++;
        }
    }
    for(int i=0;i<n;i++){
        if(v[x[i]]==0)
            ans++;
    }
    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t=1;
    // cin >> t;
    for(long int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 8724
#include <iostream>
#include <string>

using namespace std;

int A, B;
string S;

bool isValid() {
    int i;
    if (S.size() != A + B + 1) return false;
    
    // 前半
    for(i = 0; i < A; i++) {
        if(S[i] == '-') return false;
    }
    
    if(S[i] != '-') return false;
    
    // 後半
    for(i = i + 1; i < A + B + 1; i++) {
        if(S[i] == '-') return false;
    }
    return true;
}

int main() {
    cin >> A >> B;
    cin >> S;
    
    if(isValid()) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int main(){
  int n,k,t,u,v,l,d[200];
  double time,pos;
  int b,i;

  cin >> n >> k >> t >> u >> v >> l;
  for(i=0;i<n;i++)cin >> d[i];

  time = 0.0;
  pos = 0.0;
  b = 0;
  i = 0;

  while(1){
    if(!b){
      if(i==n){
	time += (double)(l-pos)/u;
	break;
      }
      time += (double)(d[i]-pos)/u;
      pos = d[i];
      b++;
      i++;
    }else{
      b--;
      if(pos + v*t >= l){
	time += (double)(l-pos)/v;
	break;
      }
      if(d[i] > pos + v*t){
	time += t;
	pos += v*t;
      }else{
	while(i<n && d[i]<pos + v*t){
	  i++;
	  b = b+1;
	  if(b>k)break;
	}
	if(b>k){
	  time += (double)(d[i-1]-pos)/v;
	  pos = d[i-1];
	}else{
	  time += t;
	  pos += v*t;
	}
      }
    }
  }

  printf("%.8lf\n",time);
}

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

int main(){
  int N;
  cin >> N;
  vector<int> dif(N);
  for(int i=0;i<N;i++){
    cin >> dif.at(i);
  }
  sort(dif.begin(),dif.end());
  cout << dif.at(N/2)-dif.at(N/2-1) << endl;
}

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

a.sort()

max_a = a[-1]
is_available = [True] * (max_a + 1)

ans = 0

for i, x in enumerate(a[:-1]):
    if not a[i+1] == x and is_available[x]:
        ans += 1
    for b in range(x, max_a + 1, x):
        is_available[b] = False

if is_available[a[-1]]:
    ans += 1

print(ans)

Measured memory_bytes: 107660
#include <iostream>
#include <set>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  string str;
  cin >> str;
  char last = *str.rbegin();
  set<string> st = {str};
  bool flag = true;
  while (cin >> str) {
    if (last != *str.begin())
      flag = false;
    if (st.find(str) != st.end())
      flag = false;
    st.insert(str);
    last = *str.rbegin();
  }
  cout << (flag ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3640
def bfs(graph, start, rm)
  visited = {}
  count = 0
  queue = [start]
  until queue.empty? do
    p = queue.shift
    neighbors = graph[p]
    neighbors.each do |n|
      next if visited[n]
      next if (p == rm[0] && n == rm[1]) || (p == rm[1] && n == rm[0])
      visited[n] = true
      queue.push(n)
      count += 1
    end
  end
  count
end

@visited = {}
@count = 0
def dfs(graph, now, rm)
  @visited[now] = true
  @count += 1
  neighbors = graph[now]
  neighbors.each do |n|
    next if @visited[n]
    next if (now == rm[0] && n == rm[1]) || (now == rm[1] && n == rm[0])
    dfs(graph, n, rm)
  end
end

n, m = gets.strip.split.map(&:to_i)
graph = {}
(1..n).each do |i|
  graph[i] = []
end

edges = []
m.times do
  a, b = gets.strip.split.map(&:to_i)
  graph[a] << b
  graph[b] << a
  edges << [a, b]
end

num_bridges = 0
edges.each do |e|
  @visited = {}
  @count = 0
  dfs(graph, 1, e)
  #count = bfs(graph, 1, e)
  num_bridges += 1 if @count < n
end

puts num_bridges


Measured memory_bytes: 4092
/*
created by Sanyam Singhal
/*/

#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define w(t) int t;	cin>>t while(t--)
#define triplet pair<int,pair<int,int>>
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
#define loop(i, k, n) for(ll i=k; i<n; i+=1)
#define loop2(i, k, n) for(ll i=k; i>=n; i--)

const ll inf = 1e18;

void take_fileIO(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  return;
}

void solve(){
  ll n, w;
  cin>>n>>w;

  vector<ll>weights(n+1), values(n+1);

  loop(i, 1, n+1)
    cin>>weights[i]>>values[i];

  ll maxval = n*1000;
  ll dp[n+1][maxval+1];

  for(int val=0; val<=maxval; val++)
    dp[0][val]=inf;
  
  for(int i=1; i<=n; i++)
    dp[i][0] = 0;
    
  int ans =  INT_MIN;
  dp[0][0]=0;
  for(int i=1; i<=n; i++){
    for(int val=1; val<=maxval; val++){
      if(i==1){
        if(val == values[1])
          dp[1][val] = weights[1];
        else
          dp[1][val] = inf;
      }
      else{
        dp[i][val] = inf;
        if(values[i] <= val){
          dp[i][val] = min(dp[i-1][val], dp[i-1][val-values[i]] + weights[i]);
        }
        else
        {
          dp[i][val] = min(dp[i][val], dp[i-1][val]);
        }
      }
      if(dp[i][val] <= w)
        ans = max(ans, val);
    }
  }

  cout<<ans<<endl;

  // for(int i=0; i<=n; i++){
  //   for(int val=0; val<=maxval; val++){
  //     cout<<dp[i][val]<<" ";
  //   }
  //   cout<<endl;
  // }

  return;
}

int main(){

  fastIO;
  //take_fileIO();
  solve();

  return 0;
}

Measured memory_bytes: 79232
import math

a, b, x = map(lambda x: int(x), input().split())

V = a * a * b
if x <= V/2:
    theta = math.degrees(math.atan(a * b * b / x / 2))

else:
    theta = math.degrees(math.atan(2 / a  * (b - x / (a * a))))

print(theta)





Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> Qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> Qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  ll n,m,a,b;
  cin >> n >> m;
  vpll ab;
  REP(i,n) {
    cin >> a >> b;
    ab.emplace_back(a,b);
  }
  sort(ALL(ab));
  ll ans=0;
  ll j=0;
  while(1) {
    if(ab[j].second>=m) {
      ans+=m*ab[j].first;
      break;
    }
    ans+=ab[j].second*ab[j].first;
    m-=ab[j].second;
    j++;
    
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,T,k,q;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const ll MAXN = 501;

ll M[MAXN][MAXN] = {0};
ll A[MAXN][MAXN] = {0};
ll B[MAXN][MAXN] = {0};


int DP1[MAXN][MAXN][2] = {0};
bool DP1C[MAXN][MAXN][2] = {0};

int dp1(int i, int j, int kind){
    if(i > j)return 0;
    if(kind == -1)return j-i+1;
    if(DP1C[i][j][kind])return DP1[i][j][kind];
    int ans = dp1(i,j-1,kind) + dp1(j,n-1,kind-1);
    DP1[i][j][kind] = ans;
    DP1C[i][j][kind] = 1;
    return ans;
}

int enumerate(int a, int b, int c){
    return dp1(0, a-1, 1) + dp1(a, b-1, 0) + dp1(b, c-1, -1);
}

ll DP[20958500] = {0};
bool DPC[20958500] = {0};

ll dp(int a, int b, int c){
    if(a < 0)return 0;
    int h = enumerate(a,b,c);
    if(DPC[h])return DP[h];
    ll ans1 = A[a][b] + B[a][c] + dp(a-1,b,c);
    ll ans2 = big*big;
    if(b > a+1)ans2 = A[a][a+1] + B[a][b-1] + dp(a-1,a+1,b-1);
    ll ans3 = B[a][a] + dp(a-1, a, a);

    ll ans = ans1;
    ll pek = 0;
    if(ans2 < ans){
        ans = ans2;
        pek = 1;
    }
    if(ans3 < ans){
        ans = ans3;
        pek = 2;
    }

    DPC[h] = 1;
    DP[h] = ans;
    //cerr << a << " " << b << " " << c << "   pek: " << pek << "  ans: " << ans << "\n";
    return ans;
}

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

    //freopen("input.txt","r",stdin);
   // freopen("autput.txt","w",stdout);
    ll a,b,c,d;
    cin >> n;

    rep(c1,0,n){
        rep(c2,0,n-1){
            cin >> a;
            int c3 = c2;
            if(c2 >= c1)c3++;
            M[c1][c3] = a;
        }
    }

    rep(c1,0,n){
        a = 0;
        rep(c2,c1+1,n+1){
            A[c1][c2] = a;
            a += M[c1][c2];
        }
        a = 0;
        for(int c2 = n-1; c2 >= c1; c2--){
            B[c1][c2] = a;
            a += M[c2][c1];
        }
    }
    ll temp = big*big;
    ll extra = 0;
    for(int c1 = n-1; c1 > 0; c1--){
        extra += A[c1][n];
        temp = min(temp, dp(c1,c1+1,n-1) + extra);
    }

    cout << temp << "\n";


    return 0;
}


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

ll divisor=1e9+7;
int main(){
	int k,a,b;
	cin>>k>>a>>b;
	if((b)/k-(a-1)/k>0){
		puts("OK");
	}else{
		puts("NG");
	}
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0; i<n; i++)
int main()
{
	ll D,X,Y,N;
	int ans = 0;

	cin >> N >> D;
	D = D*D;

	rep(i,N){
		cin >> X >> Y;
		X = X*X;
		Y = Y*Y;
 		if(D>=X+Y){
 			ans++;
 //			cout << "\n" << X << " " << Y;
 		}
	}
	
	cout << ans;

	cin >> D;
	return 0;	
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;

#define MAX 50000

int main(void)
{
	bool p[MAX + 5];
	int i, j;
	
	for (i = 0; i <= MAX; i++){
		p[i] = true;
	}
	p[0] = p[1] = false;
	for (i = 2; i <= MAX; i++){
		if (p[i]){
			for (j = (i * 2); j <= MAX; j += i){
				p[j] = false;
			}
		}
	}
	
	int n;
	while (scanf("%d", &n)){
		if (n == 0) break;
		int res = 0;
		for (i = 2; i <= (n / 2); i++){
			if (p[i] && p[n - i]) res++;
		}
		printf("%d\n", res);
	}
		
	return (0);
}

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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#define mp make_pair
#define pb push_back
#define pll pair<LL,LL>
#define pii pair<int,int>
#define y second
#define x first
#define LL long long 
#define sqr(x) ((x)*(x))
#define pi acosl(-1)
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
using namespace std;
pll gcd(LL a, LL b){
    if(b == 0) return mp(1, 0);
    else{
        LL p = a / b;
        pll q = gcd(b, a % b);
      //  printf("%lld %lld %lld\n",q.x,q.y,p);
        return make_pair(q.y, q.x - q.y * p);
    }
}
vector<LL> v;
LL Min=1e18;
void dfs(LL i,LL a,LL b){
    if(i==v.size()){
        pll p=gcd(a,b);
        if(b==1){
            Min=min(Min,a-1);
        }
        else if(a==1){
            Min=min(Min,b-1);
        }
        else if(p.x<0){
            Min=min(Min,a*-p.x);
        }
        else if(p.y<0){
            Min=min(Min,b*-p.y);
        }else{
            printf("%lld %lld %lld %lld\n",a,b,p.x,p.y);
            assert(0);
        }
        return;
    }
    dfs(i+1,a*v[i],b);
    dfs(i+1,a,b*v[i]);
}
void solve(){
    LL n;
    scanf("%lld",&n);
    if(n==1){
        printf("1\n");
        return ;
    }
    n*=2;
    
    for(LL i = 2;i*i<=n;i++){
        if(n%i==0){
            LL tmp=1;
            while(n%i==0){
                tmp*=i;
                n/=i;
            }
            v.pb(tmp);
        }
    }
    if(n!=1)v.pb(n);
    dfs(0,1,1);
    printf("%lld\n",Min);
}
int main(){
    int t=1;
    //scanf("%d",&t);
    while(t--){
        solve();
    }
}
/*
1 6 6
2 7 4
3 5 2
4 3 1
5 2 5
6 4 0
7 1 3
*/
/*
100
5
5 4
4 2
4 2 3
5 4 2 3 1
*/


Measured memory_bytes: 3832
//
//  AtCoder123.cpp
//  playground
//
//  Created by Yang Ruiguo on 25/4/19.
//  Copyright © 2019 Yang Ruiguo. All rights reserved.
//

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

typedef long long ll;

using namespace std;

int main() {
    int x = 0, y = 0, z = 0, k = 0;
    vector<ll> va;
    vector<ll> vb;
    vector<ll> vc;

    cin >> x >> y >> z >> k;
    va.assign(x, 0);
    for(int i = 0; i < x; ++i) {
        cin >> va[i];
    }
    vb.assign(y, 0);
    for(int i = 0; i < y; ++i) {
        cin >> vb[i];
    }
    vc.assign(z, 0);
    for(int i = 0; i < z; ++i) {
        cin >> vc[i];
    }

    vector<ll> sum2;
    for(int i = 0; i < x; ++i) {
        for(int j = 0; j < y; ++j) {
            sum2.push_back(va[i] + vb[j]);
        }
    }
    sort(sum2.begin(), sum2.end());
    reverse(sum2.begin(), sum2.end());

    vector<ll> sum3;
    sort(vc.begin(), vc.end());
    reverse(vc.begin(), vc.end());
    for(int i = 0; i < min(k, int(sum2.size())); ++i) {
        for(int j = 0; j < z; ++j) {
            sum3.push_back(sum2[i] + vc[j]);
        }
    }

    sort(sum3.begin(), sum3.end());
    reverse(sum3.begin(), sum3.end());
    for(int i = 0; i < k; ++i) {
        cout << sum3[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 43240
N=int(input())

x=[]
if N != 0:
	flag = N // abs(N)
N=abs(N)
while N != 0:
	x.insert(0,N % 2 * flag )
	N //= 2
	flag *= -1
x.insert(0,0)
x.insert(0,0)

# 2 = (-1)*(-2) = (-2+1)*(-2) = (-2)^2+(-2)
for i in range(len(x))[::-1]:
	if x[i] == -1:
		x[i] = 1
		x[i-1] += 1
	if x[i] == 2:
		x[i] = 0
		x[i-1] += 1
		x[i-2] += 1

flag=0
for i in range(len(x)):
	if x[i] == 1 or i == len(x)-1:
		flag=1
	if flag == 1:
		print(x[i],end="")
"""
print()
check=0
count=1
for i in range(len(x))[::-1]:
	check +=  x[i] * count
	count *= -2
print(check)
"""

Measured memory_bytes: 3064
S = input()
n=len(S) - 1 
shiki = ""
output = 0
for i in range(2**n):
  result = list()
  shiki = S[0]
  for j in range(n):
    if ((i>>j)&1):
      shiki = shiki + '+' + S[j+1]
    else:
      shiki = shiki + S[j+1]
  result = list(map(int,shiki.split('+')))
  for k in range(len(result)):
    output += result[k]
print(output)

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

int main() {
  int n;
  int r;
  int ir;

  cin >> n >> r;
  
  if(n>=10) {
    ir=r;
  }

  else {
    ir=r+(100*(10-n));
  }

  cout << ir << endl;

  return 0;
}

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

template <typename T>
struct Graph {
    int V, E;
    struct Edge {
        int from, to;
        T cost;
    };
    vector<vector<Edge>> edge;
    vector<vector<T>> dist;
    vector<Edge> es;

    Graph(int V, int E) : V(V), E(E) {
        edge.assign(V, vector<Edge>(0));
        dist.assign(V, vector<T>(0));
    }

    void input(bool is_direct, bool index0 = false) {
        int a, b;
        T c;
        for (int i = 0; i < E; i++) {
            cin >> a >> b;
            if (!index0) a--, b--;
            edge[a].push_back((Edge){a, b, c});
            es.push_back((Edge){a, b, c});
            if (!is_direct) {
                edge[b].push_back((Edge){b, a, c});
                es.push_back((Edge){b, a, c});
            }
        }
    }

    void add_edge(int from, int to, T cost, bool is_direct) {
        edge[from].push_back({from, to, cost});
        es.push_back({from, to, cost});
        if (!is_direct) {
            edge[to].push_back({to, from, cost});
            es.push_back({to, from, cost});
            E++;
        }
        E++;
    }
    bool warshall_floid() {
        dist.assign(V, vector<T>(V, INF));
        for (int v = 0; v < V; v++) {
            for (int i = 0; i < edge[v].size(); i++) {
                dist[v][edge[v][i].to] = edge[v][i].cost;
            }
            dist[v][v] = 0;
        }
        for (int k = 0; k < V; k++) {
            for (int i = 0; i < V; i++) {
                for (int j = 0; j < V; j++) {
                    if (dist[i][k] != INF && dist[k][j] != INF) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
        for (int i = 0; i < V; i++) {
            if (dist[i][i] < 0) return false;
        }
        return true;
    }
};

int main() {
    int h, w;
    char c[20][20];
    cin >> h >> w;
    Graph<int> g(h * w, 0);
    auto f = [&](int i, int j) { return i * w + j; };
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> c[i][j];
            if (i && c[i][j] == '.' && c[i - 1][j] == '.') g.add_edge(f(i, j), f(i - 1, j), 1, false);
            if (j && c[i][j] == '.' && c[i][j - 1] == '.') g.add_edge(f(i, j), f(i, j - 1), 1, false);
        }
    }
    int ans = 0;
    g.warshall_floid();
    for (int i = 0; i < g.V; i++) {
        for (int j = i + 1; j < g.V; j++) {
            if (g.dist[i][j] != INF) ans = max(ans, g.dist[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void){
  int n, s[101], i, j, min;
  int sum=0, count=0;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%d", &s[i]);
    sum+=s[i];

    if(s[i]%10!=0)
    count=1;
  }

  if(sum%10!=0)
  printf("%d\n", sum);

  else{

  if(sum%10==0){
    min=101;

  if(count==1){
    while(1){
    for(i=0;i<n;i++){
      if(s[i]%10!=0&&s[i]<min){
        min=s[i];
        j=i;
      }
    }

    sum-=min;
    break;
  }
}
else{
  sum=0;
}
}
  printf("%d\n", sum);
}
  return 0;
}

Measured memory_bytes: 128
N,K=map(int,input().split())
S=input()
a,b=0,0
for i in range(N-1):
  if S[i]=='L'and S[i+1]=='R':
    a+=1
  elif S[i]=='R'and S[i+1]=='L':
    b+=1
if K>=max(a,b):
  print(N-1)
elif K<=min(a,b):
  print(N-1-a-b+2*K)
else:
  print(N-1-a-b+2*min(a+b)+K-min(a+b))

Measured memory_bytes: 3316
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<HashMap<Integer, Integer>> graph = new ArrayList<>();
		for (int i = 0; i < n; i++) {
		    graph.add(new HashMap<>());
		}
		for (int i = 0; i < n; i++) {
		    int from = sc.nextInt();
		    int count = sc.nextInt();
		    for (int j = 0; j < count; j++) {
		        graph.get(from).put(sc.nextInt(), sc.nextInt());
		    }
		}
		int[] costs = new int[n];
		Arrays.fill(costs, Integer.MAX_VALUE);
		PriorityQueue<Path> queue = new PriorityQueue<>();
		queue.add(new Path(0, 0));
		while (queue.size() > 0) {
		    Path p = queue.poll();
		    if (costs[p.idx] <= p.value) {
		        continue;
		    }
		    costs[p.idx] = p.value;
		    for (Map.Entry<Integer, Integer> entry : graph.get(p.idx).entrySet()) {
		        queue.add(new Path(entry.getKey(), entry.getValue() + p.value));
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
		    sb.append(i).append(" ").append(costs[i]).append("\n");
		}
		System.out.print(sb);
	}
	
	static class Path implements Comparable<Path> {
	    int idx;
	    int value;
	    
	    public Path(int idx, int value) {
	        this.idx = idx;
	        this.value = value;
	    }
	    
	    public int compareTo(Path another) {
	        return value - another.value;
	    }
	}
}



Measured memory_bytes: 335432
use proconio::input;

fn main() {
    input! {
        n: usize,
        h: [i32; n]
    };
    let mut dp = vec![1<<30; n];
    dp[0] = 0;
    for i in 1..n {
        dp[i] = dp[i].min(dp[i-1] + (h[i]-h[i-1]).abs());
        if i >= 2 {
            dp[i] = dp[i].min(dp[i-2] + (h[i]-h[i-2]).abs());
        }
    }
    println!("{}", dp[n-1]);
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int MOD = 1000000007;

int main() {
    char c;
    bool first = true;
    ll a,b;
    while(cin>>c){
        if(first){
            a = 2;
            b = 1;
            first = false;
            continue;
        }
        (b *= 3)%=MOD;
        if(c == '1'){
            (b += a)%=MOD;
            (a *= 2)%=MOD;
        }
    }
    (a += b)%=MOD;
    cout<<a<<endl;
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    S = _S()
    ans = 0
    for i in range(int(len(S)/2)):
        if S[i]==S[-i-1]:
            continue
        else:
            ans +=1
    print(ans)

main()



Measured memory_bytes: 27260
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 5e3+5;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n;
	cin >> n;
	int dp[n][3], x, y, z;
	for (int i = 0; i < n; i++)
	{
		cin >> x >> y >> z;
		if (!i)
		{
			dp[i][0] = x, dp[i][1] = y, dp[i][2] = z;
		}
		else
		{
			dp[i][0] = x + max(dp[i - 1][1], dp[i - 1][2]);
			dp[i][1] = y + max(dp[i - 1][0], dp[i - 1][2]);
			dp[i][2] = z + max(dp[i - 1][0], dp[i - 1][1]);
		}
	}
	cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
	return 0;
}


Measured memory_bytes: 1408