akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    Yes((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d);
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll a;cin>>a;
  cout<<a + a*a + a*a*a<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3648
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int dp[101010],n;
int main()
{
	cin>>n;
	for(int i=0;i<101000;i++)
	{
		dp[i]=1e9;
	}
	dp[n]=0;
	for(int i=n;i>0;i--)
	{
		for(int j=6;j<=i;j*=6)
		{
			dp[i-j]=min(dp[i-j],dp[i]+1);
		}
		for(int j=9;j<=i;j*=9)
		{
			dp[i-j]=min(dp[i-j],dp[i]+1);
		}
	}
	int ans=1e9;
	for(int i=0;i<=n;i++)
	{
		ans=min(ans,dp[i]+i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll t=1,h,w,n,min=100000000000,k,ans=0;
    string s,s2;
    cin >> n;
    VI a(n);
    VI b(n);
    VI c(n-1);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
    }
    rep(i,n-1){
        cin >> c[i];
    }
    rep(i,n){
        if(a[i] == a[i+1]-1){
            ans += b[a[i]-1] + c[a[i]-1];
        }
        else
            ans += b[a[i]-1];
    }

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


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

using namespace std;

typedef long long int64;


vector< int64 > Divisor(int64 n)
{
  vector< int64 > ret;
  for(int64 i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main()
{
  int64 N;
  cin >> N;
  auto p = Divisor(N);
  int ret = numeric_limits< int >::max();
  for(auto &s : p) {
    int64 other = N / s;
    ret = min(ret, max< int >(to_string(s).size(), to_string(other).size()));
  }
  cout << ret << endl;
}

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

using namespace std;
using ll = long long;

#define FOR(i,m,n) for(ll i=(m); (i)<(n); ++(i))
#define REP(i,n) FOR(i,0,n)
#define INFTY 10000000000

ll cnt = 0;

void merge(vector<ll> &a, const ll left, const ll mid, const ll right){
  ll n1 = mid - left;
  ll n2 = right - mid;
  vector<ll> L(n1+1), R(n2+1);
  REP(i,n1) L[i] = a[left+i];
  REP(i,n2) R[i] = a[mid+i];
  L[n1] = INFTY, R[n2] = INFTY;
  ll i = 0, j = 0;
  FOR(k,left,right){
    ++cnt;
    if(L[i] <= R[j]){
      a[k] = L[i];
      ++i;
    }
    else{
      a[k] = R[j];
      ++j;
    }
  }
}

void mergeSort(vector<ll> &a, const ll left, const ll right){
  if(left+1 < right){
    ll mid = (left+right)/2;
    mergeSort(a, left, mid);
    mergeSort(a, mid, right);
    merge(a, left, mid, right);
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n; cin >> n;
  vector<ll> a(n); REP(i,n) cin >> a[i];
  mergeSort(a, 0, n);
  REP(i,n-1) cout << a[i] << " ";
  cout << a[n-1] << "\n";
  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 10704
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  int m = max(a, max(b, c));
  int s = (a + b + c) - m;
  for (int i = 0; i < k; i++) {
    m *= 2;
  }
  cout << s + m << endl;
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc084/tasks/abc084_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int a, b;
  string s, r = "No";

  cin >> a >> b >> s;

  if (a + b + 1 == s.length())
  {
    r = "Yes";
    REP(i, s.length())
    {
      if (i == a)
      {
        if (s[i] != '-')
        {
          r = "No";
          break;
        }
      }
      else if (s[i] < '0' || '9' < s[i])
      {
        r = "No";
        break;
      }
    }
  }

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
using namespace std;

int main()
{
    long long int N;
    long long int num[100000],len=0;
    long long int i;
    cin>>N;
    for(i=1;i<=sqrt(N);i++)
        if(N%i==0)
            num[len++]=i-1+N/i-1;
    sort(num,num+len);
    cout<<num[0]<<endl;
    return 0;
}


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

int main() {
  int i,answer=0;
  string pass,ano_pass;
  cin >> pass >> ano_pass;
  for(i=0;i<11;i++){
    if(pass[i]!=ano_pass[i]){
      answer += 1;
    }
  }
  if(answer == 1){
    
  	cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }  
  return 0;
 
}


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

int main(){
    int h, w; cin >> h >> w;
    vector<vector<char>> c(h, vector<char>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> c[i][j];
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++)
            printf("%c", c[i][j]);
        printf("\n");
        for(int j=0; j<w; j++)
            printf("%c", c[i][j]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 3612
n=int(input())
m=10**9+7

a=[1,4,16]
g=[1,4,15]
c=[1,4,14]
t=[1,4,16]

for i in range(3,n):
  a.append((a[i-1]+g[i-1]+c[i-1]+t[i-1])%m)
  t.append((a[i-1]+g[i-1]+c[i-1]+t[i-1])%m)
  g.append((a[i-1]+g[i-1]+(c[i-1]-a[i-2]+g[i-3])+t[i-1])%m)
  c.append(((a[i-1]-g[i-2])+(g[i-1]-a[i-2]-2*a[i-3])+c[i-1]+(t[i-1]-a[i-3]))%m)

n=n-1

ans=a[n]+g[n]+c[n]+t[n]
print(ans%m)


Measured memory_bytes: 3064
N = int(input())
s = [input() for i in range(N)]

s_sorted = list(map(''.join, list(map(sorted, s))))

s_dict = dict()
for k in s_sorted:
    if k in s_dict:
        s_dict[k] += 1
    else:
        s_dict[k] = 1

#cnt = 0
# for k in s_dict:
#    cnt += sum(range(s_dict[k]))
cnt = sum([sum(range(s_dict[k])) for k in s_dict])

print(cnt)


Measured memory_bytes: 38540
object Main {
  import scala.io.StdIn.readLine

  def minus(a: Long, b: Long): (Long, Long) =  {
    if (a > b) {
      (a - b, 0)
    } else {
      (0, b - a)
    }
  }

  def input[A](change: String => A) = readLine.split(" ").map(change(_))
  def main(args: Array[String]): Unit = {
    val inputs = input(_.toLong)
    val a = inputs(0)
    val b = inputs(1)
    val c = inputs(2)

    val (d,e) = minus(a,c)
    val (f,_) = minus(b,e)
    println(List(d,f).mkString(" "))
  }
}


Measured memory_bytes: 27344
#include "bits/stdc++.h"
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	if (A == 1) {
		A += 13;
	}
	if (B == 1) {
		B += 13;
	}
	string ans = "Draw";
	if (A > B) {
		ans = "Alice";
	}
	else if (B > A) {
		ans = "Bob";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3612
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int X;
  cin >> X;
  int ans = 10 - (X / 200);
  cout << ans << endl;
}

Measured memory_bytes: 3656
#include<cstdio>
namespace QiFeng233{
	int n,k,ans;
	void solve(){
		scanf("%d%d",&n,&k);
		while(n>0){
			n/=k;
			++ans;
		}
		printf("%d\n",ans);
	}
}
signed main(){
	QiFeng233::solve();
	return 0;
}

Measured memory_bytes: 128
from collections import deque

N, M = map(int, input().split())
edge = [[] for _ in range(3*N)]
for i in range(M):
    u, v = map(int,input().split())
    for i in range(3):
        edge[i*N + u-1].append(((i+1)%3)*N + (v-1))
S,T = map(int,input().split())
S -=1
T -=1

distance = [10**9 for _ in range(3*N)]
distance[S] = 0

queue = deque([S])
while queue:
    u = queue.popleft()
    for next in edge[u]:
        if distance[u]+1 < distance[next]:
            distance[next] = distance[u]+1
            queue.append(next)
if distance[T] < 10**9:
    print(distance[T]//3)
else:
    print(-1)

Measured memory_bytes: 60216
#include <iostream>

using namespace std;

int main() {
	int a, b, tmp;

	for (int i = 0; ; i++) {

		cin >> a >> b;

		if (a == 0 && b == 0)break;
		if (a > b) {
			tmp = b;
			b = a;
			a = tmp;

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


	}

	return 0;
}



Measured memory_bytes: 3088
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

printList [a] = print a
printList (a:as) = putStr ( show a ) >> putChar ' ' >> printList as

main = getLine >>= putStrLn . which "Yes" "No" . ( == 0 ) . ( `mod` 9 ) . sum . map digitToInt

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

int main() {
  std::vector<std::string> s = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  std::string d; std::cin >> d;
  int ans;
  for (int i = 0; i < 7; ++i) {
    if (s[i] == d) ans = 7-i;
  }
  std::cout << ans << std::endl;
  
  return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue( P x ){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b) { return a < b ? a : b; }

int main()
{
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
    for(i = 1; i <= n; i++){
        scanf("%s %d", Q[i].name, &Q[i].t);
    }
    head = 1; tail = n + 1;

    while( head != tail ){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if( u.t > 0 ) enqueue(u);
        else{
            printf("%s %d\n", u.name, elaps);
        }
    }
    return 0;
}

Measured memory_bytes: 11824
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> x(n),y(n),h(n);
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> h[i];
    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            int hight = -1;
            for(int k = 0; k < n; k++){
                if(h[k]){
                    hight = abs(x[k]-i)+abs(y[k]-j)+h[k];
                    break;
                }
            }
            bool ok = true;
            for(int k = 0; k < n; k++){
                if(max(hight-abs(x[k]-i)-abs(y[k]-j),0) != h[k]){
                    ok = false;
                    break;
                }
            }
            if(ok){
                cout << i << " " << j << " " << hight << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3568
//You can die anytime, but living takes true courage.
//Every journey begins with a single step. We just have to have patience.
//Life is not a game of luck. If you wanna win, work hard.
//It’s more important to master the cards you’re holding 
//than to complain about the ones your opponent was dealt.
//If you just submit yourself to fate, then that’s the end of it.




/*

struct P {
int x, y;
bool operator<(const P &p) {
if (x != p.x) return x < p.x;
else return y < p.y;
}
};


bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}

*/





/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  Akshay Vashishtha 

//It’s just pathetic to give up on something before you even give it a shot.
//Knowing you’re different is only the beginning. If you accept these differences 
you’ll be able to get past them and grow even closer.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/   
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#define lld long long int 
#define vll vector<long long int>
#define vs vector<string> 
#define vint vector<int> 
#define vp vector<pair<int,int>>
//#define tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
#define forl(i,a,b) for(int i = a ; i <= b ; i++)
#define forln(i,a,b) for(int i = a; i < b ; i++)
lld mod = 1e9 + 7;
#define ps push_back
#define mk make_pair
#define F first 
#define S second 
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL)
#define sv()                  int t; scanf("%d",&t); while(t--)
using namespace std;


//I too will obtain everything that I desire. Not because someone asked me to do it, 
//but because I know in my heart that I have something worth fighting for. 
//Whatever you do, enjoy it to the fullest. That is the secret of life.

int main()
{
	int n;
  bool f = false;
  cin>>n;
  while(n != 0){
    int tmp = n%10;
    if(tmp == 7)
      f = true;
      n/= 10;
  }
  if(f)
    cout<<"Yes\n";
  else 
    cout<<"No\n";
	return 0;
}




Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define sc1(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
using namespace std;
typedef long long LL;
int gcd(int a,int b){if (b == 0) return a; return gcd(b , a%b);}
int lcm(int a, int b){ return a/gcd(a,b)*b;}
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48); ch=getchar();}
    return x*f;
}
int main(){
    int n;
    int cnt = 0,tag = 1;
    cin >> n;
    while(cnt * 4 <= n){
        if ((n - cnt *4) % 7 == 0){
            cout << "Yes" << endl;
            tag = 0;
            break;
        }
        cnt++;
    }
    if (tag) cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)
#define Reps(i, x, N) for(int i = x; i < N; i++)

const int LLINF = 1LL << 60;

signed main()
{
  int N;
  int A, B, C;

  cin >> N;
  Rep(i, N) {
    
    int cnt = 0;
    cin >> A >> B >> C;

    while(A < 1000) {
      while(B <= 10) {
	while(C < ((B % 2 || !(A % 3)) ? 20 : 19)) cnt++, C++;
	C = 0, B++; 
      }
      B = 1;
      A++;
    }

    cout << cnt + 1 << endl;
  }

  return 0;
}
	

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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
  
  int n = r * 100 + g * 10 + b;
  
    if (n % 4 == 0) {
      cout << "YES" << endl;
    }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int x=100,ans=0;
    while(1)
    {
        if(x>=n)
        {
            cout<<ans;
            return 0;
        }
        x+=(x/100);
        ans++;
    }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
const int maxm=1e6+5;
int a[maxm];
int n;
signed main(){
    cin>>n;
    for(int i=1;i<=n*2;i++)cin>>a[i];
    int ans=0;
    sort(a+1,a+1+n*2);
    for(int i=1;i<=n*2;i+=2){
        ans+=min(a[i],a[i+1]);
    }
    cout<<ans<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,sum=0;
  cin >>N;
  vector<int> L(N*2);
  for(int i=0;i<N*2;i++)
    cin>>L.at(i);
  
  sort(L.begin(),L.end());
  for(int i=0;i<N*2;i+=2){
    sum+=L.at(i);
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))

ans=[[0 for i in range(w)] for i in range(h)]
ct=0
num=0
for i in range(h):
  for j in range(w):
    if ct<a[num]:
      ans[i][j]=str(num+1)
      ct+=1
    else:
      ct=0
      num+=1
      ans[i][j]=str(num+1)
      ct+=1
for i in range(h):
  if i%2==1:
    ans[i].reverse()
  print(' '.join(ans[i]))

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

int main()
{
    double x;
    // scanf("%d", &x);
    cin >> x;
    double ans;
    ans = 2 * x * 3.141592;
    // printf("%d\n", x * x * x);
    cout << 2 * x * 3.14159 << endl;
}

Measured memory_bytes: 3788
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        int[][] g = buildGraph(sc, n, n-1);
        long[] s = new long[n];
        for (int i = 0; i < q; i++) {
            int p = sc.nextInt()-1;
            int x = sc.nextInt();
            s[p] += x;
        }
        boolean[] used = new boolean[n];
        dfs(0, 0, g, s, used);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(s[i] + " ");
        }
        System.out.println(sb.toString().trim());
        sc.close();

    }

    private static void dfs(int v, long p, int[][] g, long[] s, boolean[] used) {
        if(used[v]) return;
        used[v] = true;
        s[v] += p;
        for(int nex : g[v]){
            dfs(nex, s[v], g, s, used);
        }
    }

    public static int[][] buildGraph(Scanner sc, int n, int m) {
        int[][] graph = new int[n][];
        int[][] edges = new int[m][2];
        int[] deg = new int[n];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            edges[i][0] = a;
            edges[i][1] = b;
            deg[a]++;
            deg[b]++;
        }
        for (int i = 0; i < n; i++) {
            graph[i] = new int[deg[i]];
        }
        for (int i = 0; i < m; i++) {
            int a = edges[i][0];
            int b = edges[i][1];
            graph[a][--deg[a]] = b;
            graph[b][--deg[b]] = a;
        }

        return graph;
    }


}


Measured memory_bytes: 205972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll H,W;
    cin >> H >> W;
    vector<string> A(H+2);
    REP(i,H)cin >> A[i+1];
    A[0] = string(W+2,'#');
    A[H+1] = string(W+2,'#');
    REP(i,H)A[i+1] = "#" + A[i+1] + "#";
    REP(i,H+2)cout << A[i] << "\n";
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

template <class T> using V = vector<T>;

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;
}

const long long INF = 1LL << 60;

using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;



#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);



ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}



const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


#define comuse Comuse()

ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}


ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

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

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}




/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  //vll segtree(524287);
  //ll N=262144;
  ll a,b;
    cin>>a>>b;
  if(a<b){
    char c='0'+a;
    string s(b,c);
    cout<<s<<"\n";
  }
  else{
    char c='0'+b;
    string s(a,c);
    cout<<s<<"\n";
  }
}

Measured memory_bytes: 256
// Created by arvybhatt

#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
    fast;
    int n;cin>>n;
    while(n)
    {
        int x=n%10;
        if(x==7)
        {
            cout<<"Yes";
            return 0;
        }
        n/=10;
    }
    cout<<"No";
    
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  int n, k;
  cin >> n >> k;
  vi a(n);
  for (int i : a) cin >> a.at(i);
  int mina = 100001, memo;
  for (int i = 0; i < n; i++) {
    if (mina > a.at(i)) {
      mina = a.at(i);
      memo = i;
    }
  }
  int nm = -1, cnt = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0 || memo == nm + 1) nm += k;
    else nm += k - 1;
    cnt++;
    if (nm >= n - 1) break;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222


ll dp[MAX][2][111];


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


  cin >> s;
  cin >> m;

  dp[0][0][0] = 1;
  rep(i, s.length()) {
    ll num = s[i] - '0';
    rep(j, m) {
      rep(d, num) (dp[i + 1][1][(j + d) % m] += dp[i][0][j]) %= mod;
      (dp[i + 1][0][(j + num) % m] += dp[i][0][j]) %= mod;
      rep(d, 10) (dp[i + 1][1][(j + d) % m] += dp[i][1][j]) %= mod;
    }
  }

  rep(i, 2) ans += dp[s.length()][i][0];
  cout << (ans - 1 + mod) % mod << endl;


  return 0;
}

Measured memory_bytes: 18688
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
/*
template <typename T>  using ordered_set =
    tree<T, null_type, less<T>,   /// greater<T> for sorting decreasingly
    rb_tree_tag, tree_order_statistics_node_update>;
*/

#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         mod                         1000000007
#define         INF                         2e18
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;

vector<ll>v;

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n,x,now=0,t;
    sfl(n),sfl(t);
    v.pb(now);
    for(ll i=1;i<=n;i++){
        sfl(x);
        now += x;
        v.pb(now);
    }
    ll ans = upper_bound(all(v),t)-v.begin();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define db(x) cerr<<#x<<" = "<<x<<'\n'
using namespace std;

const int MAX=4005,MOD=998244353;

int n,k,f[MAX][MAX],f1[MAX][MAX][2];
bool mark[MAX][MAX],mark1[MAX][MAX][2];

int dp(int n,int k) {
	if(n==0)
		return 1;
	if(mark[n][k])
		return f[n][k];
	mark[n][k]=true;
	// get k
	f[n][k]=(f[n][k]+dp(n-1,k))%MOD;
	// switch to k+1
	if(k>1)
		f[n][k]=(f[n][k]+dp(n,k-1))%MOD;
	return f[n][k];
}

int dp1(int n,int k,int fi) {
	if(n==0)
		return 1;
	if(mark1[n][k][fi])
		return f1[n][k][fi];
	mark1[n][k][fi]=true;
	// get k
	if(fi)
		f1[n][k][fi]=(f1[n][k][fi]+2*dp1(n-1,k,false))%MOD;
	else
		f1[n][k][fi]=(f1[n][k][fi]+dp1(n-1,k,false))%MOD;
	// switch to k+1
	if(k>1)
		f1[n][k][fi]=(f1[n][k][fi]+dp1(n,k-1,true))%MOD;
	return f1[n][k][fi];
}

int cal(int n,int num) {
	int rs=0,p=0,p1=0;
	for(int i=1;i<=k;i++)
		if(1<=num-i&&num-i<=k)
			p1++;
		else
			p++;
	p1/=2;
	for(int i=0;i<=n;i++) {
		if((i>0&&p==0)||(n-i>0&&p1==0))
			continue;
		int t1=dp(i,p);
		int t2=dp1(n-i,p1,true);
		rs=(rs+t1*t2)%MOD;
	}
	return rs;
}

int32_t main() {
	//freopen("input","r",stdin);
	cin>>k>>n;
	for(int i=2;i<=2*k;i++)
		if(i%2==1)
			cout<<cal(n,i)<<'\n';
		else
			cout<<(cal(n-1,i)+cal(n,i))%MOD<<'\n';
}


Measured memory_bytes: 101864
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var HW = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var (H, W) = (HW[0], HW[1]);
            var pixels = new string[H];
            for (var i = 0; i < H; i++)
            {
                var s = Console.ReadLine();
                pixels[i] = s;
            }

            for (var i = 0; i < H; i++)
            {
                Console.WriteLine(pixels[i]);
                Console.WriteLine(pixels[i]);
            }
        }
    }
}


Measured memory_bytes: 27948
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mn(x) *min_element((x).begin(),(x).end())
#define mx(x) *max_element((x).begin(),(x).end())
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

const ld pi=acos(-1);
const ll inf=(ll)1e18;
const int mod=1000000007;
//const int mod=998244353;

int n,m,k;
const int N=3e3+10;

ll dp[N][N][4];
int val[N][N];

int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    int q,t,u,v,h;
    ll x,a,b,c,d,y,w,z,k;
    cin >> n >> m >> k;
    for(int i=1; i<=k; i++){
        cin >> u >> v >> val[u][v];
    }
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            for(int k=0; k<4; k++){
                dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k]);
                dp[i][j][1]=dp[i][j][0]+val[i][j];
            }
            dp[i][j][1]=max(dp[i][j][1],dp[i][j-1][1]);
            dp[i][j][2]=max(dp[i][j-1][2],dp[i][j-1][1]+val[i][j]);
            dp[i][j][3]=max(dp[i][j-1][3],dp[i][j-1][2]+val[i][j]);
        }
    }
    ll ans=0;
    for(int i=0; i<4; i++){
        ans=max(ans,dp[n][m][i]);
    }
    cout << ans << el;
    
    
    return 0;
}



Measured memory_bytes: 321008
#include <iostream>
#include <queue>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  priority_queue<int> q;
  for (int i=0; i<N; i++) {
    int a;
    cin >> a;
    q.push(a);
  }
  for (int i=0; i<M; i++) {
    int a = q.top(); q.pop();
    a /= 2;
    q.push(a);
  }
  long long ret = 0;
  while (!q.empty()) {
    ret += q.top(); q.pop();
  }
  cout << ret << endl;
}

Measured memory_bytes: 892
#include <vector>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) a[i] = b[n-i-1] = i * n + 1;
    for (int i = 0; i < n; i++) {
        int p; cin >> p;
        a[p-1] += i;
        b[p-1] += i;
    }
    for (int i = 0; i < n; i++) cout << a[i] << (i == n-1 ? '\n' : ' ');
    for (int i = 0; i < n; i++) cout << b[i] << (i == n-1 ? '\n' : ' ');
}


Measured memory_bytes: 768
a,b,c,k=map(int,input().split())
sum=0
if k>a:
    sum+=a
    k-=a
    if k<0:
        k=0
else:
    sum+=k
    k=0
if k>b:
    k=k-b
    if k<0:
        k=0
else:
    k=0
if k>c:
    sum-=c
else:
    sum-=k
print(sum)


Measured memory_bytes: 61664
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;


const int mod=1000000007;
//const int mod=998244353;

set<int> X,Y;
vvi xx(1e5+1),yy(1e5+1);
vector<bool> markx(1e5+1),marky(1e5+1);
ll z=0;
void bfs(int u){
    markx[u]=true;
    X.insert(u);
    z+=xx[u].size();
    for ( auto it : xx[u]){
        if(!marky[it]){
            Y.insert(it);
            marky[it]=true;
            for( auto ti: yy[it]){
                if(!markx[ti]){
                    bfs(ti);
                }
            }
        }
    }
}



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d;
    cin>>n;
    set<int> s,g;
    for (int i=0; i<n; i++){
        cin>>a>>b;
        xx[a].pb((int)b);
        yy[b].pb((int)a);
    }
    a=0;
    for(int i=0; i<=1e5; i++){
        if(!markx[i]&&xx[i].size()>0){
            bfs(i);
            a+=X.size()*Y.size()-z;
//            cout << X.size() <<' ' << Y.size() << ' ' << z<<el;
            X.clear();
            Y.clear();
            z=0;
        }
    }
    cout << a<< el;
    return 0;
}



Measured memory_bytes: 15232
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

/**
 * 重み付きUnionFind
 * 
 * https://qiita.com/drken/items/cce6fc5c579051e64fab
 */
template<typename T>
class WeightedUnionFind
{
    private:
        vector<T> parents;
        vector<T> rank;
        vector<T> diff_weight;
        
    public:
        WeightedUnionFind(T n)
        {
            parents.resize(n);
            rank.resize(n);
            diff_weight.resize(n);
            for (T i = 0; i < n; i++) {
                parents[i] = i;
            }
        }

        T root(T x)
        {
            if (parents[x] == x) return x;
            T r = root(parents[x]);
            diff_weight[x] += diff_weight[parents[x]];
            return parents[x] = r;
        }

        bool same(T x, T y)
        {
            return root(x) == root(y);
        }

        T weight(T x)
        {
            root(x);
            return diff_weight[x];
        }

        // xからyへの重みを求める
        T diff(T x, T y)
        {
            // (1) x => root の重み
            // (2) root => y の重み
            // とした時、xからyへの重みは(1) + (2)である。
            // ここで(2)について、diff_weightに保持しているのはy => rootなので、符号反転させている。
            return diff_weight[x] + (-diff_weight[y]);
        }

        // xからyへの重みをwにする
        // ここのロジックについては以下記事がわかりやすい
        // https://at274.hatenablog.com/entry/2018/02/03/140504
        void unite(T x, T y, T w)
        {
            T rx = root(x);
            T ry = root(y);
            if (rx == ry) return;

            if (rank[rx] < rank[ry]) {
                rank[ry] += rank[rx];
                parents[rx] = ry;
                diff_weight[rx] = w + diff_weight[y] - diff_weight[x];
            } else {
                rank[rx] += rank[ry];
                parents[ry] = rx;
                diff_weight[ry] = diff_weight[x] - w - diff_weight[y];
            }
        }

        // デバッグ用
        void show()
        {
            for (T i = 0; i < parents.size(); i++) {
                cout << "i: " << i << ", p[i]: " << parents[i] << ", rank[i]: " << rank[i] << ", w[i]: " << diff_weight[i] << endl;
            }
        }
};

int main() {
    int N, M;
    cin >> N >> M;
    vl L(M), R(M), D(M);
    rep(i, M) {
        cin >> L[i] >> R[i] >> D[i];
        L[i]--; R[i]--;
    }

    WeightedUnionFind<ll> uni(N);

    bool ok = true;
    rep(i, M) {
        if (uni.same(L[i], R[i])) {
            ll diff = uni.diff(L[i], R[i]);
            if (diff != D[i]) {
                ok = false;
                break;
            }
        } else {
            uni.unite(L[i], R[i], D[i]);
        }
    }

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

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef long long lint;
typedef pair< int, int > pii;

int N, M, dp[100010];
vector< vector< int > > adj;
vector< int > g[2], col;
map< int, int > part_cnt;

bool dfs(int v, int c) {
	if (col[v] != -1) {
		if (col[v] != c) return false;
		return true;
	}
	
	col[v] = c;
	g[c].push_back(v);
	
	for (int u : adj[v]) if (!dfs(u, 1 - c)) return false;
	
	return true;
}

lint calc(lint A) {
	memset(dp, -1, sizeof(dp));
	
	dp[0] = 0;
		
	for (auto it = part_cnt.begin(); it != part_cnt.end(); ++it) {
		int a = (*it).first, c = (*it).second;
		
		for_(j,0,N+1) {
			if (dp[j] >= 0) {
				dp[j] = c;
			} else if (j < a || dp[j - a] <= 0) {
				dp[j] = -1;
			} else {
				dp[j] = dp[j - a] - 1;
			}
		}
	}
	
	lint res = 0;
	
	for_(a,0,N+1) {
		if (dp[a] == -1) continue;
		lint B = N - (A + a);
		res = max(res, (A + a) * B);
	}
	
	return res;
}

void solve() {
	col.assign(N, -1);
	
	bool flag = true;
	lint A = 0;
	
	for_(v,0,N) {
		if (col[v] != -1) continue;
		for_(i,0,2) g[i].clear();
		
		flag &= dfs(v, 0);
		
		int a = min(g[0].size(), g[1].size()), b = max(g[0].size(), g[1].size());
		++part_cnt[b - a];
		A += a;
	}
		
	cout << (!flag ? -1 : calc(A) - M) << endl;
}

int main() {
	cin >> N >> M;
	
	adj.assign(N, vector< int >());
	
	for_(i,0,M) {
		int u, v;
		scanf("%d %d", &u, &v);
		--u; --v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	
	solve();
}

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

int main() {
	string O, S; cin >> O >> S;
	int size = O.size() + S.size();
	for( int i = 0; i < size; i++ ){
		if( i % 2 == 0) cout << O[i/2];
		else cout << S[i/2];
	}
	cout << endl;
}

Measured memory_bytes: 256
N=int(input())
A=sorted(list(map(int,input().split(' '))))
l_tmp=A[1:]
tmp = A[0]
ans = A[0]
while True:
    l_tmp_tmp=[]
    for i in l_tmp:
        if i%tmp:
            l_tmp_tmp.append(i%tmp)
            ans = min(ans,i%tmp)
    l_tmp_tmp.append(tmp)
    if len(l_tmp_tmp)>1:
        tmp = ans
        l_tmp=l_tmp_tmp
    else:
        break
print(ans)

Measured memory_bytes: 14252