akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(N: int):
    mod = N % 10
    if mod in [2, 4, 5, 7, 9]:
        print("hon")
    elif mod in [0, 1, 6, 8]:
        print("pon")
    else:
        print("bon")
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
N = int(input())
V = list(map(int,input().split()))

minmin = sorted(V)

tmp = -1
for i in range(N):
    if i == 0:
        continue
    else:
        if tmp == -1:
            tmp = (minmin[i-1] + minmin[i])/2
        else:
            tmp = (tmp + minmin[i])/2
    # print(tmp)

print(tmp)

Measured memory_bytes: 3060
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

tmpA = [0]*(N+1)
tmpB = [0]*(M+1)
ans = 0

import bisect
for i in range(1,N+1):
    tmpA[i] = tmpA[i-1] + A[i-1]
for i in range(1,M+1):
    tmpB[i] = tmpB[i-1] + B[i-1] 
for i in range(N+1):
    tmp = tmpA[i]
    if tmp > K:
        break
    index = bisect.bisect_right(tmpB,K-tmp)
    ans = max(i+index-1,ans)
print(ans)

Measured memory_bytes: 117548
/**
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define REP(i,a,n) for(i=a;i<=n;i++)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,b,a) for(i=b;i>=a;i--)
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const ll mod=1e9+7;
const ll MAXN=100200;
ll i,j;
int main()
{
IOS
/*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
#endif // ONLINE_JUDGE*/
ll n;
cin>>n;
vector<ll> v(n);
F(i,0,n)
{
    cin>>v[i];
}
ll maxx=v[0];
ll sum=0;
F(i,1,n)
{
    if(v[i]<maxx)
    {
        sum+=maxx-v[i];
    }
    else
        maxx=max(v[i],maxx);
}
cout<<sum;
return 0;
}


Measured memory_bytes: 4740
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		List<Integer> times = new ArrayList<>();
		int modMax = -1;
		for (int i = 0; i < 5; ++i) {
			int time = Integer.parseInt(in.readLine());
			if (time % 10 == 0) {
				modMax = Math.max(modMax, 0);
			} else {
				modMax = Math.max(modMax, (10 - time % 10));
			}
			if (time % 10 == 0) {
				times.add(time);
			} else {
				time += 10 - time % 10;
				times.add(time);
			}
		}
		in.close();
		int sum = 0;
		for (int i = 0; i < 5; ++i) {
			sum += times.get(i);
		}
		System.out.println(sum - modMax);
	}

}


Measured memory_bytes: 21204
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <set>
#include <sstream>
#include <string>
#include <queue>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

//MOD//
const ll MOD = 1000000007;
struct big;
big ex(big a, ll tms);
typedef struct big{
  ll val;
  big():val(0){}
  big(ll val):val((val%MOD+MOD)%MOD){}
  big& operator += (const big& obj){ (val+=obj.val)%=MOD; return *this;}
  big& operator -= (const big& obj){ (val+=MOD-obj.val)%=MOD; return *this;}
  big& operator *= (const big& obj){ (val*=obj.val)%=MOD; return *this;}
  big& operator /= (const big& obj){ (val*=ex(obj,MOD-2).val)%=MOD; return *this;}
  big operator + (const big& obj)const{ return big(*this) += obj;}
  big operator - (const big& obj)const{ return big(*this) -= obj;}
  big operator * (const big& obj)const{ return big(*this) *= obj;}
  big operator / (const big& obj)const{ return big(*this) /= obj;}
  bool operator < (const big& obj)const{ return val < obj.val;}
  bool operator == (const big& obj)const{ return val == obj.val;}
} big;
istream& operator >> (istream& i, big& obj){ i>>obj.val; return i;}
ostream& operator << (ostream& o, const big& obj){ o<<obj.val; return o;}
big ex(big obj, ll tms){
  if(!tms) return 1;
  big ret = ex(obj, tms/2);
  ret *= ret;
  return (tms&1) ? ret*obj : ret;
}
//MOD//

ll pow(ll n, int m){
  if(!m) return 1;
  ll ret = pow(n, m/2);
  ret *= ret;
  return (m&1) ? ret*n : ret;
}

template <class F, class T>
void convert(const F &f, T &t){
  stringstream ss;
  ss << f;
  ss >> t;
}

int  N, L;
int abef, a;

int main(){
  scanf("%d%d",&N,&L);
  scanf("%d", &abef);
  int pos = 0;
  rep(i,N-1) {
    scanf("%d",&a);
    if (a + abef >= L) {
      cout << "Possible" << endl;
      for (int j=0; j<i; ++j) {
        cout << (j+1) << endl;
      }
      for(int j=N-2; j>=i; --j) {
        cout << (j+1) << endl;
      }
      pos = 1;
      break;
    }
    abef = a;
  }
  if (!pos) {
    cout << "Impossible" << endl;
  }
  return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    string s; cin >> s; int n = s.size();
    if(s[0] == s[n-1]) n++;
    out((n%2==1)?"First":"Second");
}


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

const int N = 200005;
int arr[N + 5];

int main() {
	int n, k;
	cin>>n>>k;
	for(int i = 0;i < n;i++) {
		int x;
		cin>>x;
		arr[x]++;
	}
	sort(arr, arr + N);
	int total = 0;
	for(int i = 0;i < N - k;i++) total += arr[i];
	cout<<total<<endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define answer(x) cout << x << endl
typedef int64_t Int;

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

const double pi = M_PI;
const Int MOD = 1000000007;

Int modpow(Int a, Int n, Int mod) {
    Int ret = 1;
    while (n > 0) {
        if (n & 1) {
            ret = ret * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }

    return ret;
}

vector<Int> factorials(0), invs(0);
bool is_ncr_table = false;
void calc_ncr_table(Int n, Int mod) {
    is_ncr_table = true;

    // 1! ~ n! の計算
    Int f = 1;
    factorials.push_back(f);
    for (Int i = 1; i < n + 1; i++) {
        f *= i;
        f %= mod;
        factorials.push_back(f);
    }
    // n!^-1 の計算
    Int inv = modpow(factorials[n], mod - 2, mod);
    // (n-1)!^-1 ~ 1!^-1 の計算
    invs.assign(n, 1);
    invs[n] = inv;
    for (Int i = n; i >= 1; i--) {
        inv *= i;
        inv %= mod;
        invs[i - 1] = inv;
    }
}

Int factorial(Int n, Int mod = 1) {
    Int ret = 1;
    if (mod == 1) {
        for (Int i = 1; i < n + 1; i++) {
            ret *= i;
        }

        return ret;
    } else {
        for (Int i = 1; i < n + 1; i++) {
            ret *= i;
            ret %= mod;
        }

        return ret;
    }
}

Int ncr(Int n, Int r, Int mod, bool use_table = false) {
    if (use_table) {
        // modが素数の場合のみ
        if (!is_ncr_table) {
            calc_ncr_table(n, mod);
        }
        return factorials[n] * invs[r] * invs[n - r] % mod;
    } else {
        Int x = 1;
        for (Int i = n - r + 1; i < n + 1; i++) {
            x *= i;
            x %= MOD;
        }
        return x * modpow(factorial(r, mod), mod - 2, mod) % mod;
    }
}

int main() {
    Int A, B, K;
    cin >> A >> B >> K;

    A -= K;
    if (A < 0) {
        B += A;
        A = 0;
    }
    if (B < 0) {
        B = 0;
    }

    cout << A << ' ' << B << endl;

    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll>mp;
int a,b,c,d;
ll f(ll n)
{
    if(n==0)return 0;
    if(n==1)return d;
    if(mp.find(n)!=mp.end())return mp[n];
    ll res=2e18;
    if(!(n%2))res=f(n>>1)+a;
    else res=min(f(n>>1)+a+d,f((n+1)>>1)+a+d);
    int t=n%3;
    res=min(res,f(n/3)+b+1ll*d*t);
    if(t)res=min(res,f((n+2)/3)+b+1ll*d*(3-t));
    t=n%5;
    res=min(res,f(n/5)+c+1ll*d*t);
    if(t)res=min(res,f((n+4)/5)+c+1ll*d*(5-t));
    if(1.0*n*d<=1e18)res=min(res,n*d);
    mp[n]=res;
    return res;
}
int main()
{
    int _;
    scanf("%d",&_);
    while(_--)
    {
        ll n;
        scanf("%lld%d%d%d%d",&n,&a,&b,&c,&d);
        mp.clear();
        printf("%lld\n",f(n));
    }
    return 0;
}

Measured memory_bytes: 4584
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element


signed main()
{
	string S;
	cin >> S;
	string a = "";
	a += S[0];
	a += S[1];
	a += S[2];
	cout << a << endl;
}




Measured memory_bytes: 3056
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

int N;

int main() {
  io();
  
  cin >> N;
  double totaldiv = 0;
  fori(i, N) {
    int a;
    cin >> a;
    totaldiv += (double)(1/(double)a);
  }
  
  cout << 1 / totaldiv;
  
  return 0;
}

Measured memory_bytes: 256
#n = int(input())
#L = list(map(int, input().split()))
x, k, d = map(int, input().split())
#p = list(set(L))
a = abs(x)//d
b = abs(x)%d
if k < a:
  print(abs(x) - d*k)
else:
  if (k-a)%2 == 0:
    print(b)
  else:
    print(d-b)

Measured memory_bytes: 9180
n = int(input())
siritori_list = []
for come in range(n):
    word = input()
    siritori_list.append(word)

res = 'No'
ok_list = []
for i in range(n-1):
    if siritori_list[i][-1] == siritori_list[i+1][0]:
        ok_list.append('ok')

siritori_set_list = list(set(siritori_list))

if len(siritori_set_list) == n and len(ok_list) == n-1:
    res = 'Yes'

print(res)

Measured memory_bytes: 3064
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll K, A, B;
    cin >> K >> A >> B;
    if (A + 2 < B && K > A)
    {
        cout << (K - (A + 1)) / 2 * (B - A) + (K - (A + 1)) % 2 + B << endl;
    }
    else
    {
        cout << K + 1 << endl;
    }
}

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

int main(){
    string s;
    cin>>s;
    int first = 0, last =0;
    bool f = false;
    rep(i,s.size()){
        if(s[i]=='Z'){
            last = i;
        }
        if(f) continue;
        if(s[i]=='A'){
            first = i;
            f = true;
        }
        
        
    }
    cout << last-first+1 << endl;
}


Measured memory_bytes: 640
using System;
class Program {
  static void Main(string[] args) {
    string[] value = Console.ReadLine().Split();
    int R = int.Parse(value[0]);
    int M = int.Parse(value[1]);
    int L = 1;
    for (int i = 0; i < M; ++i) {
      string[] cards = Console.ReadLine().Split();
      int l = int.Parse(cards[0]);
      int r = int.Parse(cards[1]);
      L = Math.Max(L, l);
      R = Math.Min(R, r);
    }

    int ans = Math.Max(R - L + 1,0);
    Console.WriteLine(ans);    
  }
}


Measured memory_bytes: 17216
#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);


    if (a < b) {
        printf("a < b\n");
    } else if (a > b) {
        printf("a > b\n");
    } else {
        printf("a == b\n");
    }

    return 0;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int, int> p;

int n;
vector<int> a;
vector<int> b;
vector<int> c;
int dp[200000][3];

void init(){
  cin >> n;
  vector<int> va(n);
  vector<int> vb(n);
  vector<int> vc(n);
  for (int i = 0; i < n; i++) {
    cin >> va[i] >> vb[i] >> vc[i];
  }
  a = va;
  b = vb;
  c = vc;
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
}

void solve(){
  for (int i = 1; i < n; i++) {
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
    dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + c[i];
  }
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  init();
  solve();
  ll res = max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});
  cout << res << endl;
}


Measured memory_bytes: 2664
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        if (s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2)) {
            System.out.println("Yes");
        } else if (s.charAt(1) == s.charAt(2) && s.charAt(2) == s.charAt(3)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
// 2018/12/26 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int A, B, C, D, E, F;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;
	cin >> E;
	cin >> F;

	cout << A+B+C+D+E+F-min(A, min(B, min(C, D)))-min(E, F) << endl;

	return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int E;
    cin >> E;
    while(E){
        ll mini = INF;
        rep(i,0,1001)rep(j,0,101){
            ll x = i * i + j * j * j;
            if(x <= E)mini = min(mini, i + j + (E - x));
        }
        cout << mini << endl;
        cin >> E;
    }
}


Measured memory_bytes: 2992
#include <bits/stdc++.h>
const double PI = acos(-1);
using namespace std;
int main() {
    string s;
    getline(cin, s);
        cin >> s;
        for(int i =0; i < s.size(); i++){
            if(isalpha(s.at(i))){
                if(islower(s.at(i))){
                    char ch = toupper(s.at(i));
                    std::cout << ch;
                }
                else{
                    char ch = tolower(s.at(i));
                    cout << ch;
                }
            }
            else{
                cout << s.at(i);
            }
        }
        cout << endl;    
}


Measured memory_bytes: 3128
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = readints()
if (n[0]*100+n[1]*10+n[2]) % 4 == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 38512
from collections import Counter
n = int(input())
V = [int(el) for el in input().split(' ')]

a = Counter(V[0::2]).most_common() + [(0,0)]
b = Counter(V[1::2]).most_common() + [(0,0)]

if a[0][0]!=b[0][0]:
    print(n-a[0][1]-b[0][1])
else:
    print(n-max(a[1][1]+b[0][1],a[0][1]+b[1][1]))


Measured memory_bytes: 20572
# from sys import stdin
# input = stdin.readline
(R,C,K) = map(int, input().split())
rcv = [list(map(int, input().split())) for _ in range(K)]
 
grids = [[0]*C for _ in range(R)]
 
for r,c,v in rcv:
    grids[r-1][c-1] = v
 
dp = [0] * C

for r in range(R):
#     print(dp)
    ndp = [0] * C
    elm = [0] * 4
    for c in range(C):
        elm[0] = max(elm[0], dp[c])
        value = grids[r][c]
        if value:
            nelm = [0] * 4
            nelm[0] = elm[0]
#             print(f'{value=}')
#             print(f'{ elm=}')
#             print(f'{nelm=}')
            for i in range(3)[::-1]:
                nelm[i + 1] = max(elm[i + 1], elm[i] + value)
#             print(f'{value=}')
#             print(f'{ elm=}')
#             print(f'{nelm=}')
            elm = nelm
        ndp[c] = max(elm)
    dp = ndp
 

print(dp[-1])

Measured memory_bytes: 186788
N = int(input())
li = list(input())
an = 0
a = 0
b = len(li)-1
end = True

while True:
    while True:
        if a == len(li) -1 or a > b:
            end = False
            break

        if li[a] == 'W':
            break
        else:
            a += 1

    if end:
        while True:
            if b == 0 or a > b:
                end = False
                break

            if li[b] == 'R':
                break
            else:
                b -= 1

    if end:
        li[a] = 'R'
        li[b] = 'W'
        a+= 1
        b-= 1
        an += 1
    else:
        break
print(an)

Measured memory_bytes: 10776
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
llong a, b;
llong ans;

int main() {
    cin >> n >> a >> b;

    if (a == 0 && b == 0) {
        cout << 0 << endl;
        return 0;
    }
    
    ans += (n / (a + b)) * a;
    ans += (n % (a + b)) > a ? a : (n % (a + b));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

signed main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> v(h);
    rep(i, 0, h)
        cin >> v[i];
    // rep(line, 0, h)
    int tot = 0;
    rep(i, 0, h)
        rep(j, 0, w)
            if (v[i][j] == '#')
                tot++;
    int res = 0;
    for(int mask1 = 0; mask1 < (1<<h); mask1++)
    {
        int tot2 = tot;
        vector<bool> active1(h, false);
        for(int i=0; i<h; i++) if(mask1 & (1<<i))
        {
            active1[i] = true;
            rep(j, 0, w)
                if (v[i][j] == '#')
                    tot2--;
        }
        // cout << tot2 << endl;
        for(int mask2 = 0; mask2 < (1<<w); mask2++)
        {
            // vector<bool> active2(w, false);
            int tot3 = tot2;
            for(int i=0; i<w; i++) if(mask2 & (1<<i))
            {
                // active2[i] = true;
                rep(j, 0, h)
                    if (v[j][i] == '#' && active1[j] == false)
                        tot3--;
            }
            if (tot3 == k)
                res++;
        }
        // cout << tot2 << endl;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;



int main() {
    int a = 0, b = 0, c = 0;
    string sA, sB, sC;
    cin >> sA >> sB >> sC;
    char cur = 'a';
    while (1) {
        if (cur == 'a') {
            if (a == sA.size()) {
                cout << "A\n";
                return 0;
            }
            cur = sA[a];
            a++;
        }
        else if (cur == 'b') {
            if (b == sB.size()) {
                cout << "B\n";
                return 0;
            }
            cur = sB[b];
            b++;
        }
        else {
            if (c == sC.size()) {
                cout << "C\n";
                return 0;
            }
            cur = sC[c];
            c++;
        }
        
    }
    return 0;
}

Measured memory_bytes: 256
import itertools

n, m, q = list(map(int, input().split()))
data = [list(map(int, input().split())) for i in range(q)]
a, b, c, d = [[], [], [], []]
for i in range(q):
    a.append(data[i][0])
    b.append(data[i][1])
    c.append(data[i][2])
    d.append(data[i][3])

maxpoint = 0
for x in itertools.combinations_with_replacement(range(1, m+1), n):
    point = 0
    for i in range(q):
        if x[b[i]-1] - x[a[i]-1] == c[i]:
            point += d[i]
    maxpoint = max(point, maxpoint)

print(maxpoint)

Measured memory_bytes: 9240
N = int(input())
min = 10000000000000000000000000000000000000000000
M = int((N)**(1/2))
for i in range(1,M+1):
  if N%i==0:
    A = i
    B = N//i
    FAB  = max(len(str(A)),len(str(B)))
    if FAB < min:
      min = FAB
print(min)    
    

Measured memory_bytes: 9232
// Problem: C - Ubiquity
// Contest: AtCoder - AtCoder Beginner Contest 178
// URL: https://atcoder.jp/contests/abc178/tasks/abc178_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
 
using namespace std;
#define int long long
#define ll long long
const int N = 2e5+5;
const int mod = 1e9+7;
#define ld long double
#define PI 3.14159265358979323846
#pragma GCC optimize("-O2")
const int INF = 10000000;

int getIInput() {
	cout.flush();
	#ifdef LOCAL
	return generateLocalInputOrAnythingYouWant();
	#else
	int x;
	cin>>x;
	return x;
	#endif
}

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(9);
}
 
//3. Structure or classes
//3. Ends here
 
//1. Data structures declaration here
//1. Ends here
 
//2. Extra Functions here
int bin_pow(int base, int power) {
	int m=mod;
    base %= m;
    int res = 1;
    while (power > 0) {
        if (power & 1)
            res = res * base % m;
        base = base * base % m;
        power >>= 1;
    }
    return res;
}
//2. Ends here
 
 
void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}
 
 
 
void solve()
{
	int n;
	cin>>n;
	int a = bin_pow(10,n);
	int b = bin_pow(9,n);
	int c = bin_pow(8,n);
	
	int ac = (a+c)%mod;
	int bb = (b+b)%mod;
	
	int ans = (ac-bb+mod)%mod;
	
	cout<<ans;
    return;
}
// how r u bro

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>
#include <stack>
#include <cassert>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;
using Graph = Vvec<int>;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int X;
    cin >> X;
    if(1800 <= X){
        cout << 1 << endl;
    }else if(1600 <= X){
        cout << 2 << endl;
    }else if(1600 <= X){
        cout << 2 << endl;
    }else if(1400 <= X){
        cout << 3 << endl;
    }else if(1200 <= X){
        cout << 4 << endl;
    }else if(1000 <= X){
        cout << 5 << endl;
    }else if(800 <= X){
        cout << 6 << endl;
    }else if(600 <= X){
        cout << 7 << endl;
    }else if(400 <= X){
        cout << 8 << endl;
    }
}

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

const int N=100005;
const long long INF=0x3f3f3f3f3f3f3f3f;
int n,k;
long long h[N],dp[N];

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%lld",&h[i]);
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		dp[i]=INF;
		for(int j=i-1;j>=i-k&&j>0;j--)
		{
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
		}
	}
	printf("%lld\n",dp[n]);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll,ll> M;
    rep(i,N){
        cin >> A[i];
        M[A[i]]++;
    }
    ll total = 0;
    rep(i,N+1){
        if(M[i]!=0){
            total+=M[i]*(M[i]-1)/2;
        }
    }
    rep(i,N){
        ll k;
        if(M[A[i]]<=1){
            cout << total << endl;
            continue;
        }
        k=total-M[A[i]]*(M[A[i]]-1)/2;
        k+=(M[A[i]]-1)*(M[A[i]]-2)/2;
        cout << k << endl;
    }
    return 0;
}

Measured memory_bytes: 17152
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
	ll n;
	cin>>n;
	vector<ll> v;
	rep(i,0,n){
		ll a;
		cin>>a;
		v.pb(a);
	}

	// 1 
	map<ll,ll> ma1;
	ll ans1 = 0;
	ll c1 = 0;
	rep(i,0,n){
		if(i%2==0){
			ma1[v[i]]++;
			c1++;
		}
	}
	vector<pair<ll,ll> > v1;
	map<ll,ll>::iterator itr1 = ma1.begin();
	while(itr1!=ma1.end()){
		ll a = (*itr1).fi;
		ll b = (*itr1).se;
		v1.pb(mp(b,a));
		itr1++;
	}
	sort(all(v1));
	reverse(all(v1));

	// 2 
	map<ll,ll> ma2;
	ll ans2 = 0;
	ll c2 = 0;
	rep(i,0,n){
		if(i%2==1){
			ma2[v[i]]++;
			c2++;
		}
	}
	vector<pair<ll,ll> > v2;
	map<ll,ll>::iterator itr2 = ma2.begin();
	while(itr2!=ma2.end()){
		ll a = (*itr2).fi;
		ll b = (*itr2).se;
		v2.pb(mp(b,a));
		itr2++;
	}
	sort(all(v2));
	reverse(all(v2));
	ll mn = 1000000000;
	rep(i,0,2){
		if(i==1&&v1.sz==1)continue;
		rep(j,0,2){
			if(j==1&&v2.sz==1)continue;
			if(v1[i].se!=v2[j].se){
				mn = min(mn,c1-v1[i].fi+c2-v2[j].fi);
			}
		}
	}
	if(mn==1000000000){
		cout << min(c1,c2) << endl;
	}
	else{
		cout << mn << endl;
	}
	return 0;
}

Measured memory_bytes: 9588
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int N,M;
    cin >> N >> M;
    vector<int> vec(M);
    for(int i = 0; i < M; i++){
        cin >> vec.at(i);
    }
    
    sort(vec.begin(),vec.end());
    
    vector<int> sa(M-1);
    for(int i = 0; i < M-1; i++){
        sa.at(i) = vec.at(i+1) - vec.at(i);
    }
    
    sort(sa.begin(),sa.end());
    
    int wa = 0;
    for(int i = 0; i < M-N; i++){
        wa = wa + sa.at(i);
    }
    cout << wa << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A;
    long double B;
    cin >>A>>B;
    B*=100.0;
    ll C =ll(B+0.5);
    cout << A*C/100 << endl;


    return 0;
    

}

Measured memory_bytes: 3740
#include <iostream>
#include <vector>

using namespace std;

const int MAX_N = 1e4 + 5, MAX_DIGIT = 9, oo = 1e6;
int max_length_with_last_digit[MAX_N][MAX_DIGIT];
int digit_cost[MAX_DIGIT + 1] = {0,2,5,5,4,5,6,3,7,6};

int main()
{
    int total_cost, no_of_digits;
    cin >> total_cost >> no_of_digits;

    vector <int> is_present(MAX_DIGIT + 1, false);
    for(int i = 1; i <= no_of_digits; i++)
    {
        int digit;
        cin >> digit;
        is_present[digit] = true;
    }

    vector <int> max_length(total_cost + 1, -oo);
    max_length[0] = 0;

    for(int cost = 1; cost <= total_cost; cost++)
    {
        for(int last_digit = 1; last_digit <= MAX_DIGIT; last_digit++)
        {
            if(!is_present[last_digit] || digit_cost[last_digit] > cost)
                continue;

            int remaining_cost = cost - digit_cost[last_digit];

            max_length_with_last_digit[cost][last_digit] = 1 + max_length[remaining_cost];

            max_length[cost] = max(max_length[cost], max_length_with_last_digit[cost][last_digit]);
        }
    }

    vector <int> answer;

    for(int cost = total_cost; cost > 0; )
    {
        for(int last_digit = MAX_DIGIT; last_digit >= 1; last_digit--)
        {
            if(!is_present[last_digit])
                continue;

            if(max_length_with_last_digit[cost][last_digit] == max_length[cost])
            {
                answer.push_back(last_digit);

                cost -= digit_cost[last_digit];

                break;
            }
        }
    }

    for(int i = 0; i < answer.size(); i++)
        cout << answer[i];

    return 0;
}

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

int main()
{
    string s;
    cin>>s;
    if(s=="SUN")
    {
        cout<<7<<endl;
    }
    else if(s=="SAT")
    {
        cout<<1<<endl;
    }
    else if(s=="FRI")
    {
        cout<<2<<endl;
    }
    else if(s=="THU")
    {
        cout<<3<<endl;
    }
    else if(s=="WED")
    {
        cout<<4<<endl;
    }
    else if(s=="TUE")
    {
        cout<<5<<endl;
    }
    else
    {
        cout<<6<<endl;
    }
    return 0;
}


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

using namespace std;

int main(void) {
	int N, M, X, Y;
	vector<int> x, y;

	cin >> N >> M >> X >> Y;

	for (int i = 0; i < N; i++) {
		int t;
		cin >> t;
		x.push_back(t);
	}
	for (int i = 0; i < M; i++) {
		int t;
		cin >> t;
		y.push_back(t);
	}

	bool judge = true;

	for(int z = X + 1; z <= Y; z++){
		judge = true;
		for (int i = 0; i < x.size(); i++) {
			if (x[i] >= z) {
				judge = false;
				break;
			}
		}
		if (!judge) continue;
		for (int i = 0; i < y.size(); i++) {
			if (y[i] < z) {
				judge = false;
				break;
			}
		}
		if (judge) break;
	}

	if (judge) cout << "No War" << endl;
	else cout << "War" << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Yulian
 */

#include <iostream>
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>


#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>



int getTheAnswer() {
    return 42;
}

template< class InputIt>
void incAll(const InputIt &first, const InputIt &last){
  for(auto it = first; it != last; ++it){
    ++*it;
  }
}

template <class InputIt>
void printAll(const InputIt &first, const InputIt &last, std::ostream& out){
  for(InputIt it = first; it != last; ++it){
    out << *it << " ";
  }
}

// only for positive integers
int gcd(int a, int b){
  int tmp;
  if(a < b){
    tmp = a;
    a = b;
    b = tmp;
  }
  while(b != 0){
    tmp = a;
    a = b;
    b = tmp % b;
  }
  return a;
}

int lcm(int a, int b){
  return abs(a*b) / gcd(a, b);
}


using namespace std;

class TaskC {
public:
  void solve(std::istream &in, std::ostream &out) {
    ios::sync_with_stdio(false);
    long long int x, res;
    res = 0;
    in >> x;
    if (x >= 11) {
      res = 2 * (x / 11);
      x -= 11 * res / 2;
    }
    if (x > 0) {
      if (x <= 6) {
        res += 1;
      } else {
        res += 2;
      }
    }


    out << res << endl;
  }
};


int main() {
	TaskC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  int n;
  cin>>n;
  vi a(n);
  vi b(n);
  rep(i,n) {
    cin>>a[i];
    b[i]=a[i];
  }
  vsort(b);
  int c=n/2;
  rep(i,n){
    if(a[i]<=b[c-1]) cout<<b[c]<<endl;
    else cout<<b[c-1]<<endl;
  }
}


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

int main() {
    int n, m, total = 0, ans;
    int a[10000];
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> a[i];
    }
    for(int i = 0; i < m; i++){
        total += a[i];
    }
    ans = n - total;
    if(ans < 0){
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    int x=0,y=0;
    string S;
    cin>>S;
    int a[4]={0};
    for(int i=0;i<S.size();i++){
        if(S[i]=='S')a[0]=1;
        if(S[i]=='N')a[1]=1;
        if(S[i]=='E')a[2]=1;
        if(S[i]=='W')a[3]=1;
    }
    if(a[0]==a[1]&&a[2]==a[3])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

vector<int> get_divisors(int n) {
  double a = sqrt(n);
  vector<int> divisors;
  for (int i=1; i<a+1; i++) {
    if (n % i == 0){
      divisors.push_back(i);
      if (i * i != n) {
        divisors.push_back(n / i);
      }
    }
  }
  sort(divisors.begin(), divisors.end());
  return divisors;
}
int main() {
  int n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  sort(a, a + n);
  vector<int> d1 = get_divisors(a[0]);
  vector<int> d2 = get_divisors(a[1]);
  set<int> s(d1.begin(), d1.end());
  for (auto di: d2) {
    s.insert(di);
  }
  vector<int> v(s.begin(), s.end());
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  for (int vi: v) {
    int cnt = 0;
    for (int i=0; i<n; i++) {
      if (a[i] % vi == 0) {
        ++cnt;
      } else if (i - cnt > 1) {
        break;
      }
    }
    if (cnt >= n - 1) {
      cout<<vi<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,x,li[200010]={};

int main(){
	cin >> n >> x;
	
	if(x==1 or x==2*n-1){cout << "No" << endl; return 0;}
	else cout << "Yes" << endl; stack<int> st;
	if(x+2<2*n){
		li[n-2]=x+1,li[n-1]=x-1,li[n]=x,li[n+1]=x+2;
		REP(i,1,2*n){
			if(i==x or i==x-1 or i==x+1 or i==x+2) continue;
			st.push(i);
		}
	}else{
		li[n-2]=x-1,li[n-1]=x,li[n]=x+1,li[n+1]=x-2;
		REP(i,1,2*n){
			if(i==x-1 or i==x or i==x+1 or i==x-2) continue;
			st.push(i);
		}
	}
	
	REP(i,0,2*n-1) if(!li[i]) li[i]=st.top(),st.pop();
	REP(i,0,2*n-1) cout << li[i] << endl;
	return 0;
}


Measured memory_bytes: 2864
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;

int main(void)
{
	string s;
	cin >> s;
	if (s.find('C') != string::npos && s.find('F') != string::npos)
	{
		if (s.find('C') < s.rfind('F'))
		{
			return 0 * printf("Yes\n");
		}
	}
	return 0 * printf("No\n");
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MAX_N = 100;

int d[MAX_N][MAX_N];
int N;

int warchall_floyd(){
	rep(k, N) rep(i, N) rep(j, N)
	d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int M;
	cin >> N >> M;
	rep(i,N)rep(j,N){
		d[i][j] = INF;
		if(i == j) d[i][j] = 0;
	}
	int a[M], b[M], c[M];
	rep(i,M){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
		d[a[i]][b[i]] = c[i];
		d[b[i]][a[i]] = c[i];
	}
	warchall_floyd();
	int ans = 0;
	rep(i,M){
		if(d[a[i]][b[i]] < c[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long LL;
using namespace std;

string s;
LL n;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	cin >> s >> n;
	int len = s.size();
	if(len == 1) {printf("%lld\n", n / 2); return 0;}
	int num = 0, num1 = 0, num2 = 0;
	s = s + s + s;
	for (int i = 1; i < len * 3; i++){
		if(s[i] == s[i - 1]){
			num++;
			if(len <= i && i < 2 * len) num1++;
			else if(2 * len <= i) num2++;
			i++;
		}
	}
	printf("%lld\n", (num - num1 - num2) + num1 * (n / 2) + num2 * ((n - 1) / 2));

	return 0;
}
/**/

Measured memory_bytes: 256
r,c=map(int, input().split(" "))

table=[]

for i in range(r):
    table.append(list(map(int, input().split(" "))))
#print(table)

for i in range(r):
    table[i].append(sum(table[i]))
#print(table)

table_t=[list(x) for x in zip(*table)]
#print(table_t)

for i in range(c+1):
    table_t[i].append(sum(table_t[i]))
#print(table_t)

ans=[list(x) for x in zip(*table_t)]
#print(ans)

for i in range(r+1):
    for j in range(c+1):
        if(j):
            print(" ",end="")
        print(ans[i][j],end="")
    print()


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int a,b;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> a>>b;

    if( a + b == 15){ cout << "+";}
    else if( a * b == 15){ cout << "*";}
    else { cout << "x";}




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e6 + 5;

int n;
int a[N];
int have[N], mark[N];

void work()
{
	for(int i = 1; i < N; i++)
	{
		if(have[i])
		{
			if(have[i] >= 2)
				mark[i] = 1;
			for(int j = 2; i * j < N; j++)
				mark[i * j] = 1;
		}
	}
}

int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		have[a[i]]++;
	}
	int ans = 0;
	work();
	for(int i = 1; i <= n; i++)
		ans += !mark[a[i]];
	cout << ans;
	return 0;
}

Measured memory_bytes: 20728
try:
 while True:
  l1=list(map(int,input().split()))
  l2=list(map(int,input().split()))
  hit=blow=0
  for i in l1:
    for s in l2:
     if i==s:
      if l1.index(i)==l2.index(s):
        hit+=1
      else:
        blow+=1
  print(hit,blow)
except:
  pass
    

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

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

    ll n,m;
    cin >> n >> m;
    if (n >= m/2){
        cout << m/2 << endl;
    }
    else{
        m -= 2*n;
        cout << n + m/4 << endl;
    }
}

Measured memory_bytes: 3620
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 2e5 + 10;
int f[maxn];
int f1[maxn];
int n;
void init() {
    for (int i = 1; i <= n; i++) f[i] = i;
}
int fd(int x) {
    if(x == f[x]) return x;
    return f[x] = fd(f[x]);
}
bool un(int x, int y) {
    x = fd(x); y = fd(y);
    if(x == y) return 0;
    f[x] = y; return 1;
}
int k, l;
map<pii, int> ma;
void solve() {
    while(cin >> n) {
        cin >> k >> l;
        int x, y;
        init();
        ma.clear();
        while(k--) {
            cin >> x >> y;
            un(x, y);
        }
        for (int i = 1; i <= n; i++) {
            fd(i); f1[i] = f[i];
        }
        init();
        while(l--) {
            cin >> x >> y;
            un(x, y);
        }
        for (int i = 1; i <= n; i++) {
            fd(i);
            ma[{f1[i], f[i] } ]++;
            //cout << f1[i] << " ad " << f[i] << endl;
        }
        for (int i = 1; i <= n; i++) {
            if(i != 1) cout << " ";
            cout << ma[{f1[i], f[i] } ];
        }
        cout << endl;
    }
}
int main() {
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 13568