akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MX = 200005;

ll ans = 0;

int X[MX];
int L, n;

ll S[MX];
ll SR[MX];

void solve()
{
	/*
	for (int i = 0; i <= n; i++) {
		cout << XX[i] << " ";
	} cout << endl << "--------" << endl;
	*/

	S[0] = 0;
	for (int i = 1; i <= n; i++) {
		S[i] = S[i - 1] + X[i];
	}

	SR[n] = L - X[n];
	for (int i = n - 1; i >= 0; i--) {
		SR[i] = SR[i + 1] + (L - X[i]);
	}

	for (int len = 1; len <= n; len++) {
		ll tmp = 0;
		
		int i = n - len / 2;

		if (len % 2 == 0) {
			tmp += SR[i+1]*2 - (L-X[i+1]);
			
			tmp += 2 * S[i];			
			tmp -= 2 * S[n - len];
		}
		else {
			tmp += SR[i+1]*2;
			
			tmp += 2 * S[i] - X[i];
			tmp -= 2 * S[n - len];
		}
		
		ans = max(ans, tmp);
	}
}

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

	cin >> L >> n;

	for (int i = 1; i <= n; i++) {
		cin >> X[i];
	}
	
	
	solve();
	
	for (int i = 1; i <= n; i++) {
		X[i] = L - X[i];
	}
	for (int i = 1, j = n; i < j; i++, j--) swap(X[i], X[j]);
	
	solve();
	
	cout << ans << "\n";
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int a, b, c;
int main() {
    DAU
    cin >> a >> b;
    c = (a + b) / 2;
    if (2 * c != a + b) {
        cout << "IMPOSSIBLE";
        PLEC
    }
    cout << c;
    PLEC
}


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

void print(int n, int A[]){
    
    for(int i = 0; i < n; i++){
        cout << A[i] << (i != n-1 ? " " : "\n");
    }
    
}

void insert_sort(int n, int A[]){
    
    for(int i = 1; i < n; i++){
        int memory = A[i];
        int count = i;
        for(int j = i - 1; j >= 0; j--){
            if(memory < A[j]){
                A[j + 1] = A[j];
            }
            else{
                break;
            }
            count--;
        }
        A[count] = memory;
        print(n, A);
    }
    
}

int main(void){
    
    int n, A[100] = {};
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    
    print(n, A);
    insert_sort(n, A);
    
    
}



Measured memory_bytes: 3096
NW=input().split()

N=int(NW[0])
W=int(NW[1])

item= []
for i in range(N):
    item.append(list(map(int, input().split())))

C=[[0 for i2 in range(W+1)]for i1 in range(N+1)]

for i in range(1,N+1):
    for j in range(1,W+1):
        if j>=item[i-1][1]:
            if item[i-1][0]+C[i-1][j-item[i-1][1]]>C[i-1][j]:
                C[i][j]=item[i-1][0]+C[i-1][j-item[i-1][1]]
            else:
                C[i][j]=C[i-1][j]
        else:
            C[i][j]=C[i-1][j]


print(C[N][W])

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

string S;
int K;

bool all_same(string s){
  for(int i = 0; i + 1 < s.length(); i++){
    if(s[i] != s[i + 1]){
      return false;
    }
  }
  return true;
}

long long op(string s){
  int begin = 0, ret = 0;
  while(begin < s.length()){
    int end = begin + 1;
    if(end < s.length() && s[begin] == s[end]){
      end++;
    }
    ret += (end - begin) / 2;
    begin = end;
  }
  return ret;
}

int main(){
  cin >> S;
  cin >> K;

  if(all_same(S)){
    cout << (S.length() * K) / 2 << endl;
    return 0;
  }
  long long ans_1 = op(S), ans_2 = op(S + S);

  cout << ans_1 + (K - 1) * (ans_2 - ans_1) << endl;
}


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

#define ll long long

using namespace std;

const int MAXN = 100010;
const int MAXM = 100010;
const int MAXINT = 2147483647;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int n, m, k;
int ans, tot, cnt;

int a[MAXN];
int head[MAXN];

string s;

inline int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while ('0' > ch || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while ('0' <= ch && ch <= '9') {s = (s << 3) + (s << 1) + ch - 48; ch = getchar();}
	return s * f;
}

struct edge {
	int to, next;
}e[MAXN << 1];

void add_edge(int x, int y) {
	e[++tot].to = y;
	e[tot].next = head[x];
	head[x] = tot;
	return;
}

int main(){
	int T;
	scanf("%d%d", &n, &m);
	printf("%d\n", n * m);
	return 0;
}

/*

*/

//Flakire
//Lord Wang
//yxm9
//akdxl
//WYXak
//MifafaOvO
//AKarry5037
//deakX
//xyx
//Fraggay



Measured memory_bytes: 3844
#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 ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

ll solve(ll N, ll l, ll r) { // [l, r)で条件を満たす数を求める
	ll d = N / l;
	
	while (r - l > 1) {
		ll m = (l + r) / 2;
		if (N % m >= d) l = m;
		else r = m;
	}
	
	if (N % l == N / l) return l;
	else return 0;
}

int main() {
	ll N;
	cin >> N;
	
	ll sqr = 1;
	while (sqr * sqr <= N) sqr++;
	sqr--;
	
	set<ll> ss;
	FOR(i, 1, sqr + 1) {
		ll l = N / (i + 1) + 1;
		ll r = N / i + 1;
		ss.insert(solve(N, l, r));
	}
	
	ll ans = 0;
	for (ll cur : ss) ans += cur;
	cout << ans << endl;
	
	return 0;
}


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

int main() {
  int X;
  cin>>X;
  bool judge=true;
  rep(i,X){
    if(100*i<=X && X<=105*i){
      cout<<1<<endl;
      judge=false;
      break;
    }
  }
  if(judge){
    cout<<0<<endl;
  }
}

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

int main() {
    int A, B;
    cin >> A >> B;
    if (A > B) cout << A + A - 1 << endl;
    else if (A == B) cout << A + B << endl;
    else cout << B + B - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int pron;cin >> pron;
  map<string,int> mp;
  for(int i=0;i<pron;i++){
    string s;cin >> s;
    mp[s]++;
  }
  int mn;cin >> mn;
  for(int i=0;i<mn;i++){
    string s;cin >> s;
    mp[s]--;
  }
  int ans = 0;
  for(auto&i:mp){
    ans = max(ans,i.second);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int>height(n);
	for (int i = 0; i < n; i++)
	{
		int d;
		cin >> d;
		height[i] = d;
	}
	vector<int>dp(n + 1);
	dp[0] = 0;
	dp[1] = abs(height[0] - height[1]);
	for (int i = 2; i < n; i++)
	{
		int pehla_op = abs(height[i] - height[i - 2]) + dp[i - 2];
		int dusra_op = abs(height[i] - height[i - 1]) + dp[i - 1];
		//cout << pehla_op << "   " << dusra_op << endl;
		dp[i] = min(pehla_op, dusra_op);
	}
	cout << dp[n - 1];
	return 0;
}

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

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

    int n;
    cin >> n;
    
    int mi = 1e9, ma = 0;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        mi = min(mi, a);
        ma = max(ma, a);
    }

    cout << ma - mi << endl;

    return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())

def combinations_count(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def A(i, j):
    if 0.5*i <= j and j <= 2*i and (i+j)%3==0:
        n, m = (2*j-i)//3, (2*i-j)//3
        return combinations_count(n+m,m)%((10**9)+7)
    else:
        return 0

print(A(x, y))

Measured memory_bytes: 102028
from sys import stdin
import math
import bisect
import heapq
import numpy as np
from math import factorial
inf = 10**10

h,w = [int(x) for x in stdin.readline().rstrip().split()]

li = [["." for i in range(w+2)]for j in range(h+2)]
for i in range(1,h+1):
    s = stdin.readline().rstrip()
    for j in range(1,w+1):
        li[i][j] = s[j-1]

lin = [[0 for i in range(w)]for j in range(h)]

for i in range(1,h+1):
    for j in range(1,j+1):
        if li[i][j] == "#":
            lin[i-1][j-1] = "#"
        else:
            point = 0
            if li[i-1][j-1] == "#":
                point += 1
            if li[i-1][j] == "#":
                 point += 1
            if li[i-1][j+1] == "#":
                 point += 1
            if li[i][j-1] == "#":
                 point += 1
            if li[i][j+1] == "#":
                 point += 1
            if li[i+1][j-1] == "#":
                 point += 1
            if li[i+1][j] == "#":
                 point += 1
            if li[i+1][j+1] == "#":
                 point += 1
            lin[i-1][j-1] = str(point)

for i in lin:
    s = "".join(i)
    print(s)

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

const int MX = 100001 ;

int main()
{
    int n;
    cin >> n; 
    vector<ll> cnt(MX) ;
    rep(i,n)
    {
        int a ;
        cin >> a ;
        cnt[a]++ ;
    }
    ll tot = 0;
    rep(i,MX) tot += i*cnt[i] ;

    int q ;
    cin >> q ;
    rep(i,q)
    {
        int b, c ;
        cin >> b >> c ;
        tot += (c-b)*cnt[b] ;
        cnt[c] += cnt[b] ;
        cnt[b] = 0 ;
        cout << tot << endl ;
    }

    return 0 ;
}

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

#define int long long

#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second

using vint = vector<int>;
using pint = pair<int, int>;
using vpint = vector<pint>;

template <typename A, typename B>
inline void chmin(A& a, B b) {
    if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A& a, B b) {
    if (a < b) a = b;
}

template <class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>& p) {
    ost << "{" << p.first << "," << p.second << "}";
    return ost;
}

template <class T>
ostream& operator<<(ostream& ost, const vector<T>& v) {
    ost << "{";
    for (int i = 0; i < v.size(); i++) {
        if (i) ost << ",";
        ost << v[i];
    }
    ost << "}";
    return ost;
}

inline int topbit(unsigned long long x) {
    return x ? 63 - __builtin_clzll(x) : -1;
}

inline int popcount(unsigned long long x) {
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x) {
    return __builtin_parity(x);
}

signed main() {
    int H, W, M;
    cin >> H >> W >> M;

    vint cntH(H), cntW(W);
    set<pint> s;
    rep(i, M) {
        int h, w;
        cin >> h >> w;
        h--;
        w--;
        cntH[h]++;
        cntW[w]++;
        s.insert(pint(h, w));
    }

    vint idxH, idxW;
    {
        int ma = *max_element(all(cntH));
        rep(i, H) if (cntH[i] == ma) idxH.pb(i);
    }
    {
        int ma = *max_element(all(cntW));
        rep(i, W) if (cntW[i] == ma) idxW.pb(i);
    }

    auto tmp = [&]() {
        if ((int)idxH.size() * idxW.size() > M) {
            return true;
        }
        for (auto y : idxH)
            for (auto x : idxW)
                if (s.find(pint(y, x)) == s.end()) return true;
        return false;
    }();

    int ans = cntH[idxH.front()] + cntW[idxW.front()];
    if (!tmp) ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35060
#include <bits/stdc++.h>
#define print(a,n)  for(lli i=0;i<n;i++)cout<<a[i]<<' ';br
#define br          cout<<endl;
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define upar        1000000007
#define fr(i,a,b)  for(int i=a;i<=b;i++)
using namespace std;
int n;
int ans=0;
using namespace std;
void solve()
{
cin>>n;
int a[n+1]={0};
//int st=en=0;
//int sans=eans=-1;

fr(i,1,n)
  cin>>a[i];

    int ans=0,maxx=0;
fr(i,1,n-1)
{
     if((a[i]-a[i+1])>=0)
        {
            ans++;
           // cout<<a[i]<<" ";
            maxx=max(maxx,ans);
        }
        else
        {
           // cout<<" 0 called ";
            ans=0;
        }
}

    cout<<maxx;

}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;

    //cin>>t;

    while(t--){
        solve();

    }

    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		sc.close();
		if(X >= 30){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}



Measured memory_bytes: 35644
from sys import stdin

N, *xyh = map(int, stdin.read().split())

xyh = list(zip(*[iter(xyh)] * 3))
xyh.sort(key=lambda x: -x[2])

x1, y1, h1 = xyh[0]
for X in range(101):
    for Y in range(101):
        H = h1 + abs(x1-X) + abs(y1-Y)
        if all(max(H-abs(x-X)-abs(y-Y), 0) == h for x, y, h in xyh[1:]):
            print(X, Y, H)
            break

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

vector<char> ch;
int w;

int main(){
    scanf("%d", &w);
    while(w > 0){
        if(w % 3 == 0){
            ch.push_back('0');
            w /= 3;
        }else if(w % 3 == 1){
            ch.push_back('+');
            w = (w - 1) / 3;
        }else{
            ch.push_back('-');
            w = (w + 1) / 3;
        }
    }
    reverse(ch.begin(), ch.end());
    for(int i = 0; i < ch.size(); i++){
        cout << ch[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define all(x) (x).begin(),(x).end()
int INF = 100000000;

int main() {
  int A, B, C; cin >> A >> B >> C;
  int sum = A + B + C;
  int ma = max(max(A, B), C);
  int diff = (3 * ma - sum + 1) / 2;
  int ans;
  if (sum % 2 == 0 ) {
    if (ma % 2 == 0) {
      ans = diff;
    }
    else {
      ans = diff + 1;
    }
  }
  else {
    if (ma % 2 == 1) {
      ans = diff;
    }
    else {
      ans = diff + 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MAX 50
int main()
{
	char str1[MAX];
	char str2;
	int i,j;
	int flag = 0;
	scanf("%s", str1);

	for (i = 0; i < strlen(str1); i++)
	{
		str2 = str1[i];
		
		for (j = i+1; j < strlen(str1); j++)
		{
			if (str2 == str1[j])
			{
				flag = 1;
				break;
			}
		}
		if (flag == 1)
		{
			break;
		}
	}

	if (flag == 1)
	{
		printf("no");
	}

	else
	{
		printf("yes");
	}

	return 0;
	
}

Measured memory_bytes: 128
object Main extends App {
  val n =  scala.io.StdIn.readLine()
  val matsubi = n.last.toString.toInt
  if (matsubi == 3) {
    println("bon")
  } else if (matsubi == 0 || matsubi == 1 || matsubi == 6 || matsubi == 8) {
    println("pon")
  } else {
    println("hon")
  }

}

Measured memory_bytes: 54544
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

#define INF INT_MAX
// ????????°????????§??°
#define MAX_V 100000
// ??°????????????????????°
int V;

class edge {
public:
  int to, cap, rev;
  edge (int to = 0, int cap = 0, int rev = 0): to(to), cap(cap), rev(rev) {}
};

vector <edge> graph[MAX_V];
bool vis[MAX_V];

void add_edge(int from, int to, int cap) {
  graph[from].push_back(edge(to, cap, graph[to].size()));
  int n = graph[from].size();
  graph[to].push_back(edge(from, 0, n-1));
}

int dfs(int v, int t, int f) {
  if (v == t) return f;
  vis[v] = true;
  for (int i = 0; i < graph[v].size(); i++) {
    edge &e = graph[v][i];
    if (!vis[e.to] && e.cap > 0) {
      int d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
	e.cap -= d;
	graph[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s, int t) {
  int flow = 0;
  for (;;) {
    memset(vis, false, sizeof(vis));
    int f = dfs(s, t, INF);
    if (f == 0) return flow;
    flow += f;
  }
}

int main() {
  int E;
  cin >> V >> E;
  for (int i = 0; i < E; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    add_edge(s, t, c);
  }
  cout << max_flow(0, V-1) << endl;
}

Measured memory_bytes: 3692
#include <stdio.h>

int main(){

  int a,b,c,d;

   scanf("%d %d",&a,&b);

   if(a<b){

     d = a;

     a = b;

     b = d;

    }

    c = a % b;

    while(c!=0){

     a = b;

     b = c;

     c = a % b;

  }

  printf("%d\n",b);

 return 0;

}

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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace

#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
    ll n;
    cin >> n;
    vll nums(n);
    FOR(i, n) cin >> nums[i];
    ll sum = 0;
    FOR(i, n)
    {
        FORN(j, i + 1, n)
        {
            sum += nums[i] * nums[j];
        }
    }
    cout << sum << '\n';
}



Measured memory_bytes: 256
#define rep(i,n) for(i=0;i<(n);++i)
#include<iostream>
#include<string>
#include<cstdint>
#include<algorithm>
#include<bitset>
using namespace std;

int main(){
    int n;
    string s;
    cin >> n;
    if(n==26){n=0;}
    cin >> s;
    char p;
    int i,j;
    s.shrink_to_fit();
    rep(i,s.size()){
        p=s[i];
        p +=n;
        if(p>'Z') p-=26;
        cout << p;
    }
    return 0;
}

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

typedef int i32;
typedef long long i64;
typedef unsigned int u32;
typedef unsigned long long u64;


template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};


#define debug(x)  cerr<<x<<"\n";
#define loop(i,n) for(i32 i = 0; i < n; ++i)
#define pi  pair<i32,i32>
#define ti  triple<i32,i32,i32>
#define mk  make_pair
#define vi  vector<i32>
#define vll vector<i64>
#define fastInOut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pr(a) for(auto x:a) cout<<x<<" ";
#define prmap(m) for(auto x:m) cout<<x.first<<" "<<x.second<<"\n";
using namespace std;

bool isPrime(i64 x){
	
	for(i64 i=2;i*i<=x;i++)
		if(x%i==0)
			return false;
	return true;
}

vi V;
const i32 N=7e7+9;
bool prime[N]; 
void SieveOfEratosthenes() 
{
    for (int  p=2; p*p<=N; p++){ 
        if (prime[p] == false){ 
            for (int  i=p*p; i<=N; i += p) 
                prime[i] = true; 
        } 
    } 
    int u=0,mx=0;
    for (int p=2; p<=N; p++) 
      if (!prime[p]) {
          V.push_back(p);
    }
   
}
i64 a,k,w,c;
i64 A[3];
void solve(){
    cin>>A[0]>>A[1]>>A[2];
    cin>>c;
    sort(A,A+3);
    while(c--)
       A[2]=A[2]+A[2];
   cout<<(A[0]+A[1]+A[2]);
    
}

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


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

// input
int N;
vector<int> D;


void input() {
    cin >> N;
    D = vector<int>(N);
    rep(i, N) cin >> D[i];
}


int main() {
    input();
    set<int> s;
    rep(i, N) s.insert(D[i]);
    int ans = s.size();
    cout << ans << endl;
}


Measured memory_bytes: 3640
s = list(input())
n = len(s)

l = s[0:int((n-1)/2)]
m = s[int((n+3)/2)-1:]

n_l = len(l)
n_m = len(m)
if all(s[i] == s[-i-1] for i in range(n//2)):
    if all(l[i] == l[-i-1] for i in range(n_l//2)):
        if all(m[i] == m[-i-1] for i in range(n_m//2)):
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')


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

#define N 1000002
#define L 13
#define M 1000003

char T[M][L];

int getchar(char ch){
  if(ch == 'A') return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch == 'T') return 4;
  else return 0;
}

int getkey(char str[]){
  int key,s,sum = 0,p = 1;

  s = strlen(str);

  for(int i = 0;i < s;i++){
    key = getchar(str[i]);
    sum += p * key;
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key % M;
}

int h2 (int key){
  return 1 + (key % (M - 1));
}

int find(char str[]){
  int key,h;
  key = getkey(str);
  for(int i = 0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(T[h],str) == 0) return 1;
    else if(strlen(T[h]) == 0)return 0;
  }
  return 0;
}

int insert(char str[]){
  int key,h;

  key = getkey(str);
  for(int i = 0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(T[h],str) == 0) return 1;
    else if(strlen(T[h]) == 0){
      strcpy(T[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int n,h;
  char str[L],com[9];

  for(int i = 0;i < M;i++) T[i][0] = '\0';
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> com >> str;

    if(com [0] == 'i'){
      insert(str);
    }
    else{
      if(find(str)) cout << "yes" << endl;
      else cout << "no" << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 15820
N, K = map(int, input().split())
P = 0
for i in range(min(N,K-1)):
    tmp=1.0/float(N)
    now=i+1
    while now < K:
        now *= 2
        tmp /= 2
    P += tmp
if N > K-1:
    P += 1./float(N)*float(N-K+1)
print(P)

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

int main(){
  int Mt[10];
  int s;
  int i, j;
  for (i = 0; i <= 9; i++){
    cin >> Mt[i];
  }

  for (i = 1; i <= 3; i++){
    for (j = 8; j >= 0; j--){
      if (Mt[j] <= Mt[j + 1]){
        s = Mt[j];
        Mt[j] = Mt[j + 1];
        Mt[j + 1] = s;
      }
    }
  }

  for (i = 0; i <= 2; i++){
    cout << Mt[i] << "\n";
  }
  return (0);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 2e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, a[N], f[N];
ll k;
bool ok(ll score){
	ll cnt = 0;
	for(int i=0; i<n; i++){
		ll mul = 1LL*a[i]*f[i];
		if (mul <= score) continue;
		cnt += a[i] - score/f[i];
	}
	return cnt <= k;
}
int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> k;
	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=0; i<n; i++) cin >> f[i];
	sort(a, a+n, greater<int>());
	sort(f, f+n);
	ll l = 0, r = 1e12;
	while(l <= r){
		ll mid = (l+r) / 2;
		if (ok(mid)){
			r = mid - 1;
		} else l = mid + 1;
	}
	ll ans = r + 1;
	cout << ans << endl;


	return 0;
}


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

#define N 100000
#define INF 1000000

typedef struct{
  int g; //go 前に進む
  int b; //back 後ろに戻る
  int c; //cost コスト
}Date;

int n, d[N];
Date a[500000];

void root(int);

int main(){
  int i, j;
  int k, u, count = 0;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&u,&k);
    for(j = 0 ; j < k ; j++){
      a[count].b = u;
      scanf("%d%d",&a[count].g,&a[count].c);
      count++;
    }
  }

  root(count);

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

  return 0;
}

void root(int x){
  int i, flag = 1;

  for(i = 0 ; i < n ; i++) d[i] = INF;
  d[0] = 0;

  while(flag != 0){
    flag = 0;
    for(i = 0 ; i < x ; i++){
      if(a[i].c + d[a[i].b] < d[a[i].g]){
        d[a[i].g] = a[i].c + d[a[i].b];
        flag = 1;
      }
    }
  }
}



Measured memory_bytes: 7580
#include "bits/stdc++.h"

using namespace ::std;

typedef long long ll;
typedef unsigned long long ull;


int px[] = {0, 1, 0, -1, 1, -1, -1, 1};
int py[] = {1, 0, -1, 0, 1, 1, -1, -1};

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

    //scanf("%d", &test);


    scanf("%d%d", &n, &m);

    if(m > n * 4 or m&1 or n > m/2) return puts("No"), 0;

    puts("Yes");
   
}

Measured memory_bytes: 3756
#include <iostream>
#include <vector>
using namespace std;
int n;
vector <int> a;

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    int t;
    cin>>t;
    a.push_back(t);
  }
  int i;
  for(i=n-1;i>=0;i-=2){
    cout<<a[i]<<" ";
  }
  if(n%2==0){
    i-=2;
  }
  for(i+=3;i<n;i+=2){
    if(i+2<n){
      cout<<a[i]<<" ";
    }else{
      cout<<a[i]<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3060
integer N
integer,allocatable,dimension(:)::A,C
integer i,j,cnt
read*,N
allocate(A(N),C(N))
read*,A
cnt=0
do i=n,1,-1
  if(A(i)/=0)then
    cnt=cnt+1
    C(cnt)=i
    do j=1,i
      if(j*j>i)exit
      if(mod(i,j)==0)then
        A(j)=xor(A(j),1)
        if(j*j/=i)A(i/j)=xor(A(i/j),1)
      endif
    end do
  endif
end do
print"(I0)",cnt
do i=cnt,1,-1
  if(i==cnt)then
  write(*,'(i0)', advance='no')c(i)
  else
  write(*,'(x,i0)', advance='no')c(i)
  endif
end do
end

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define length(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, length(a))cin >> a[i]
#define ccin(i, j, a) rep(i, length(a))rep(j, length(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define sqrtl sqrt
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    intl n;
    cin >> n;
    string s;
    cin >> s;
    intl x = 0;
    intl m = x;
    rep(i, n){
        if(s[i] == 'I')x++;
        else x--;
        m = max(x,m);
    }
    cout << m << endl;
    return 0;
}

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

char S[100010];

int main()
{
    scanf("%s",S);
    if(strlen(S) % 2 == 0 ^ S[0] == S[strlen(S) - 1])
    {
        printf("Second\n");
    }
    else
    {
        printf("First\n");
    }
    return 0;
}


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

t = 0
ans = 0
for i in a:
  s = max(0, t+i-x) # 一つ前の値の差分を含めて、xとの差分を取得し、比較
  t = i - s
  ans += s
print(ans)

Measured memory_bytes: 20100
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int a,b,c,d;cin>>a>>b>>c>>d;

  set<int> s{a,b,c,d};
  if (s.count(1)==0) {
    cout << "NO" << endl;
    return 0;
  }
  if (s.count(9)==0) {
    cout << "NO" << endl;
    return 0;
  }
  if (s.count(7)==0) {
    cout << "NO" << endl;
    return 0;
  }
  if (s.count(4)==0) {
    cout << "NO" << endl;
    return 0;
  }

  cout << "YES" << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=500001;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 


int main()
{
    string s;
    cin>>s;
    reverse(all(s));
    int md=2019;
    ll int arr[2020]={0},ans=0,f=1,cur=0;
    arr[0]=1;
    fo(i,0,sz(s))
    {
        cur=(cur+(s[i]-'0')*f)%md;
        ans+=arr[cur];
        arr[cur]++;
        f=(f*10)%md;
    }
    cout<<ans;

}

Measured memory_bytes: 3704
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int[] t = new int[n];
        for (int i = 0 ; i < n ; i++) {
            t[i] = sc.nextInt();
        }
        Arrays.sort(t);
        int bus = 0;
        int pass = 0;
        int time = 0;
        for (int i = 0 ; i < n ; i++) {
            if (time == 0) {
                time = t[i];
            }
            if (t[i] - time > k) {
                bus++;
                pass = 1;
                time = t[i];
            } else {
                pass++;
                if (pass == c) {
                    bus++;
                    pass = 0;
                    time = 0;
                }
            }


        }

        if (pass > 0) {
            bus++;
        }

        System.out.println(bus);

    }

}

Measured memory_bytes: 50264
N, K, Q = list(map(int, input().split()))
A = [0]*N
for i in range(Q):
    num = int(input())
    A[num-1] += 1
# n番目の人の正解数がA[n-1]に入る
for i in range(N):
    if K > Q-A[i]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 4680
#include <iostream>
#include <set>
using namespace std;
int main(){
  int n,k,ans;
  set<int> s;
  cin>>n >>k;

  for (int i = 0; i < k; i++){
    int d;
    cin>>d;
  	for (int j = 0; j < d; j++){
      int man;
      cin>> man;
  		s.insert(man);
    }
  }
  ans = n - s.size();
  cout <<ans;
  
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if((a + b + c) >= 22)
        cout << "bust" << endl;
    else if((a+b+c) < 22)
        cout << "win" << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min, max};

struct Scanner<R: Read> {
    reader: R,
    buffer: String,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader, buffer: String::new() }
    }

    // fn line(&mut self) -> String {
    //     self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
    //         .skip_while(|&c| c == '\n' || c == '\r')
    //         .take_while(|&c| !(c == '\n' || c == '\r'))
    //         .collect::<String>();
    //     self.buffer.clone()
    // }

    fn read_buffer(&mut self) {
        self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        self.read_buffer();
        if self.buffer.is_empty() {
            None
        } else {
            self.buffer.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            // writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item=U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn merge(a: &mut [u32], mid: usize) {
    let l: Vec<_> = a[..mid].iter().cloned().collect();
    let r: Vec<_> = a[mid..].iter().cloned().collect();
    let mut i = l.iter().peekable();
    let mut j = r.iter().peekable();
    let max = &&u32::max_value();
    for x in a.iter_mut() {
        *x = if i.peek().unwrap_or(max) <= j.peek().unwrap_or(max) {
            *i.next().unwrap()
        } else{
            *j.next().unwrap()
        }
    }
    assert_eq!(i.next(), None);
    assert_eq!(j.next(), None);
}

fn merge_sort(a: &mut [u32]) -> usize {
    let n = a.len();
    if n >= 2 {
        let mid = n / 2;
        let res = n + merge_sort(&mut a[0..mid]) + merge_sort(&mut a[mid..]);
        merge(a, mid);
        res
    } else {
        0
    }
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n = sc.read();
    let mut a: Vec<u32> = sc.vec(n);
    let cnt = merge_sort(&mut a[0..n]);
    println!("{}", a.iter().join(" "));
    println!("{}", cnt);
}



Measured memory_bytes: 35692
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m = map(int, input().split())
    foods = [0] * m
    ans = 0
    for _ in range(n):
        k = list(map(int, input().split()))
        for i in range(1, k[0]+1):
            foods[k[i]-1] += 1
    for i in range(m):
        if foods[i] == n:
            ans += 1
    print(ans)
        
if __name__ == '__main__':
    main()

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

using namespace std;

using i64 = int64_t;
const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


signed main(){
    int h, w, n;
    cin >> h >> w >> n;
    vector<pair<int,int>> v;
    for(int i = 0; i < n; ++i){
        int x, y;
        cin >> x >> y;
        v.emplace_back(x, y);
    }
    v.emplace_back(0, 0);
    int y_bound = 0;
    sort(v.begin(), v.end());
    int ans = v[n].first;
    for(int i = n; i >= 1; --i){
        y_bound = max(y_bound, v[i].second);
        int x_bound = v[i - 1].first;
        ans = min(ans, x_bound + y_bound);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3880
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

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

  set<string> S;
  for(int i=0; i< s.length(); i++){
    for(int j=1; j <= K; j++){
      if(i+j-1 < s.length()){
        string sub = s.substr(i,j);
        S.insert(sub);
      }
    }
  }

  rep(i,K-1) {
    S.erase(S.begin());
  }

  cout << *S.begin() << endl;
}


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

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> red(N, { 0,0 });
	vector<pair<int, int>> blue(N, { 0,0 });
	for (int i = 0; i < N; i++) cin >> red[i].first >> red[i].second;
	for (int i = 0; i < N; i++) cin >> blue[i].first >> blue[i].second;
	auto lambda1 = [](auto const& a, auto const& b) {return max(a.first, a.second) > max(b.first, b.second); };
	auto lambda2 = [](auto const& a, auto const& b) {return min(a.first, a.second) < min(b.first, b.second); };
	sort(red.begin(), red.end(), lambda1);
	sort(blue.begin(), blue.end(), lambda2);

	vector<int> IsUsed(N, 0);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (IsUsed[j] == 1) continue;
			if (red[i].first < blue[j].first && red[i].second < blue[j].second) {
				ans++;
				IsUsed[j] = 1;
				break;
			}
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;
using Graph = vector<vector<int>>;

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 myAbs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

vector<bool> seen;
void dfs(const Graph& G, int v, int count) {
    seen[v] = true;
    count = 0;
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue;
        if (count > 2) continue;
        count++;
        cout << count << ":" << next_v << endl;
        dfs(G, next_v, count);
    }
}

const long long INF = 1LL << 60;

int main() {
    char a, b; cin >> a >> b;
    if (a == 'H' && b == 'H') cout << 'H' << endl;
    else if (a == 'H' && b == 'D') cout << 'D' << endl;
    else if (a == 'D' && b == 'H') cout << 'D' << endl;
    else cout << 'H' << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const int inf=1e9;
const ll MOD=1000000007;

int main(){
    int N;string S,T;cin>>N>>S>>T;
    string ans;
    rep(i,N){
        ans+=S[i];
        ans+=T[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	string s;
	cin >> s;
	replace(s.begin(), s.end(), ',', ' ');
	cout << s << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

int main(){
    int n; cin >> n;
    cout << ceil(n/2.0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin>>a;
  char b[100];
  cin>>b;
  int c = strlen(b);
  int ji = 0;
  for (int i = 0; i < c; i++) {
    if (b[i] == 'A')
      if (b[i+1] == 'B')
        if (b[i + 2] == 'C')
          ji++;
  }
  cout<<ji;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
long long INF = 1e18;
struct edge{
    int from;
    int to;
    long long cost;
};
void solve(int N, int M, vector<edge> &es, int s, int t){
    vector<long long> d(N);//各頂点までの距離
    for(int i = 0; i < N; i++) d[i] = INF;
    d[s] = 0;
    long long k = 0;
    long long ans = 0;
    while(true){
        bool flag = false;
        for(int i = 0; i < M; i++){
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                flag = true;
            }
        }
        if(!flag || k == N) break;
        k++;
    }
    ans = min(ans, d[t]);
    k = 0;
    while(true){
        for(int i = 0; i < M; i++){
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = -INF;
            }
        }
        k++;
        if(k == N) break;
    }
    if(d[t] == -INF) cout << -1 << endl;
    else cout << -ans << endl;
}
int main(){
    int N, M;
    cin >> N >> M;
    long long P;
    cin >> P;
    vector<edge> es(M);
    for(int i = 0; i < M; i++){
        int x, y;
        long long c;
        cin >> x >> y >> c;
        x--;
        y--;
        edge e = {x, y, -c + P};
        es[i] = e;
    }
    solve(N, M, es, 0, N - 1);
}

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

int main() { 
    string c1, c2;
    cin >> c1 >> c2;
    
    for (int i = 0; i < 3; i++) {
        if (c1[i] != c2[2 - i]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000

ll mulmod(ll, ll);
ll fastpower(ll, ll);
void getprime(vector<ll>&);
void getfact(vector<ll>&, vector<ll>&);
ll ncr(ll, ll, vector<ll>&, vector<ll>&);


void solve()
{
    ll n, m, sum = 0;
    cin>>n;
    map<ll, ll>mp;
    for(ll i=0;i<n;i++){
        ll x;
        cin>>x;
        sum += x;
        mp[x]++;
    }
    cin>>m;
    while(m--)
    {
        ll a, b;
        cin>>a>>b;
        if(mp.find(a) != mp.end())
        {
            ll count = mp[a];
            sum -= a*count;
            sum += b*count;
            mp.erase(a);
            if(mp.find(b) != mp.end())
                mp[b] += count;
            else
                mp[b] = count;
        }
        cout<<sum<<"\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();        
    }
    return 0;
}

ll mulmod(ll a, ll b)
{
    ll res = 0; 
    a = a % MOD;
    while(b > 0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
 
        a = (a * 2) % MOD; 
        b /= 2;
    } 
    return res % MOD; 
}

ll  fastpower(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n % 2 != 0)
        {
            res = (res * a) % MOD;
        }
        n /= 2;
        a = (a * a) % MOD;
    }
    return res;
}

void getprime(vector<bool>&prime)
{
    prime[0] = false;
    prime[1] = false;
    
    for(ll i = 2;i <= MAX; i++)
    {
        if(prime[i])
        {
            for(ll j = i*i; j <= MAX; j += i)
                prime[j] = false;
        }
    }
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
    fact[0] = 1;
    ifact[0] = 1;
    
    for(ll i = 1; i <= MAX; i++)
    {
        fact[i] = (fact[i-1] * i)%MOD;
        ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
    }
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
    ll res;
    res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
    return res;
}


Measured memory_bytes: 7572
#include <bits/stdc++.h>
using namespace std;
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define chmax(a,b) a=max(a,b)
int n,m;
map<int,int> mp;
multiset<int> v;
int main(){
	cin>>n>>m;
	for(int i=0;i<m;++i){
		mp[i]=i;
	}
	for(int i=0;i<m;++i){
		v.insert(0);
	}
	for(int i=0;i<n;++i){
		int l,r;
		cin>>l>>r;
		l--;
		auto it=mp.lower_bound(l);
		int rr=-1;
		while(it!=mp.end()&&it->first<=r){
			rr=max(rr,it->second);
			int len=it->first-it->second;
			v.erase(v.find(len));
			mp.erase(it++);
		}
		if(rr!=-1&&r<m){
			v.insert(r-rr);
			mp[r]=rr;
		}
		int ans=-1;
		if(!v.empty()){
			ans=*v.begin()+(i+1);
		}
		cout<<ans<<'\n';
	}
	return 0;
}


Measured memory_bytes: 22380
# https://atcoder.jp/contests/abc080/tasks/abc080_c
# 普通にbit全探索では？

N = int(input())
F = []
for _ in range(N):
    F.append(list(map(int, input().split())))
P = []
for _ in range(N):
    P.append(list(map(int, input().split())))

bitlen = 10


# def ret_score(n: int):
#     # 営業時間かぶり計算
#     C = []
#     for i in range(N):  # Nでiter
#         cnt = 0
#         for bit in range(bitlen):  # 桁とFを対応
#             if ((n >> bit) & 1) and F[i][bit]:  # もし1その桁で1なら
#                 cnt += 1
#         C.append(cnt)

#     # スコア計算
#     ret = 0
#     for i, c in enumerate(C):
#         ret += P[i][c]
#     return ret


# ans = -10**10
# for n in range(1, 1 << bitlen):
#     ans = max(ans, ret_score(n))
# print(ans)


# numpyでも実装してみる
import numpy as np
F = np.array(F)
P = np.array(P)

bitshifter = np.array([x for x in range(bitlen)])


def ret_score(n: int, F, bitshifter, P):
    bit_arr = (n >> bitshifter) & 1
    F_matched = bit_arr & F
    C = F_matched.sum(axis=1)

    # スコア計算
    ret = 0
    for i, c in enumerate(C):
        ret += P[i, c]
    return ret


ans = -10**10
for n in range(1, 1 << bitlen):
    ans = max(ans, ret_score(n, F, bitshifter, P))
print(ans)


Measured memory_bytes: 13340