akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

template< typename T >
class CumulativeSum
{
public:
    vector< T > m_data;
    CumulativeSum() {};
    CumulativeSum(int sz) : m_data(sz, 0) {};

    // k に x を加える O(1)
    void Add(int k, int x) {
        assert(m_data.size() >= k);
        if(m_data.size() <= k) { m_data.push_back(x); }
        else { m_data[k] += x; }
    }

    // 累積和の構築 O(m_data.size())
    void Build() { for(int i = 1; i < m_data.size(); i++) { m_data[i] += m_data[i - 1]; } }

    // 区間 [0, k] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int k) {
        if(k < 0) { return 0; }
        return (m_data[min(k, (int) m_data.size() - 1)]);
    }

    // 区間 [l, h] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int l, int h) { return this->Query(h) - this->Query(l-1); }
};

ll N, K;
ll A[MAX_N];

signed main()
{
    cin >> N >> K;
    CumulativeSum<ll> cs(N);
    CumulativeSum<ll> cs_pos(N);    // 正の数のみ
    REP(i, N) {
        cin >> A[i];
        cs.Add(i, A[i]);
        if(A[i] > 0) { cs_pos.Add(i, A[i]); }
    }
    cs.Build();
    cs_pos.Build();
    ll ans = 0;
    REP(i, N - K + 1) {
        ll cand = cs_pos.Query(N-1) - cs_pos.Query(i, i + K - 1);
        ans = max({ans, cand + cs.Query(i, i + K - 1), cand});
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2560
c=[p]*gets.to_i
l=$<.map{|t|n,a,b=t.split.map &:to_i;d=[];[[a,b],[b,a]].map{|i,j|i<0||(d<< i;c[i]=[i,n,j])};[n,d]}.sort
f=->n,d{c[n][3,0]=[l[n][1].size,d,h=(l[n][1].map{|i|f[i,d+1]}.max||-1)+1,d<1?:root:h<1?:leaf:"internal node"];h}
c[n=c.index(p)]=[n,-1,-1]
f[n,0]
puts c.map{|i|%w(node\ %d:\ parent sibling degree depth height %s)*" = %d, "%i}

Measured memory_bytes: 6124
# -*- coding: utf-8 -*-
'''
深さ優先探索で解く
木構造で解く
'''


n = int(input())
a=[[] for i in range(n)]
for i in range(n-1):
    b=[int(j)-1 for j in input().split()]
    a[b[0]].append(b[1])
    a[b[1]].append(b[0])

def dfs(v):
    d=[-1 for i in range(n)]
    q=[]
    d[v]=0
    q.append(v)
    while len(q):
        v=q.pop()

        for i in a[v]:
            if d[i]==-1:
                d[i]=d[v]+1
                q.append(i)
    return d
c1=dfs(0)
c2=dfs(n-1)
c=0
for i in range(n):
    if c1[i]>c2[i]:
        c+=1
if c>=n/2:
    print("Snuke")
else:
    print("Fennec")

Measured memory_bytes: 29168
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <vector>

#include <string>
#include <limits.h>
#include <set>
#define ll long
#define MAX 1e9
using namespace std;
typedef long long lli;
int main(){
    ios_base::sync_with_stdio(false);
    
  #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin>>n;
    int arr[n]={0};
    int k;
    cin>>k;
    int i, j;
    int num;
    for(i=0; i<k; i++)
    {
    	cin>>num;
    	int snu[num];
    	for(j=0; j<num; j++)
    	{
          cin>>snu[j];
          arr[(snu[j]-1)]++;
    	}
    }
    int count = 0;
    for(i=0; i<n; i++)
    {
    	if(arr[i]==0)
    		count++;
    }
    cout<<count<<"\n";
    return 0;
}


Measured memory_bytes: 3656
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, K, Rock, Scissor, Paper;
  string T;
  cin >> N >> K >> Rock >> Scissor >> Paper >> T;

  enum Janken : int32_t { kRock, kScissor, kPaper };
  const int64_t janken[] = {'r', 's', 'p'};
  const int64_t score[] = {Rock, Scissor, Paper};

  int64_t result = 0;
  for (int64_t k = 0; k < K; ++k) {
    vector<int64_t> dp(3, 0);
    for (int64_t i = 1; k + (i - 1) * K < N; ++i) {
      const char enemy = T[k + (i - 1) * K];
      vector<int64_t> prev(3, 0);
      swap(dp, prev);
      for (int64_t j = kRock; j <= kPaper; ++j) {
        bool win = false;
        if (janken[j] == 'r' && enemy == 's') {
          win = true;
        } else if (janken[j] == 's' && enemy == 'p') {
          win = true;
        } else if (janken[j] == 'p' && enemy == 'r') {
          win = true;
        }
        for (int64_t p = kRock; p <= kPaper; ++p) {
          if (j != p) {
            dp[j] = max(dp[j], prev[p] + (win ? score[j] : 0));
          }
        }
      }
    }
    result += max(dp[0], max(dp[1], dp[2]));
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3704
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>

using namespace std;



int main() {


	string s,t;

	cin >> s >> t;





	int cnt=0;

	for (int i = 0; i <3; i++) {
		if (s[i] == t[i])
			cnt++;
	}


	//printf("%0.10lf\n",sum);

	cout << cnt << endl;
	
	


	return 0;
}



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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

int H, W, N;

int main() {
	read(H), read(W), read(N);
	print((N - 1) / std::max(H, W) + 1);
}


Measured memory_bytes: 3592
N = int(input())
A = {}
for i in range(N):
    a = int(input())
    if a not in A:
        A[a] = 0
    A[a] = A[a] + 1
num = 0
for k, v in A.items():
    if v % 2 == 1:
        num = num + 1
print(num)

Measured memory_bytes: 15068
int main(){
    int m,f,r;
    for(;;){
        scanf("%d %d %d",&m,&f,&r);
        if(m==-1&&f==-1&&r==-1)break;
       else if(m==-1||f==-1)printf("F\n");
        else if (m+f>=80) printf("A\n");
        else if (m+f>=65) printf("B\n");
        else if (m+f>=50) printf("C\n");
        else if (m+f>=30 && r>=50) printf("C\n");
        else if (m+f>=30) printf("D\n");
        else if (m+f<30)  printf("F\n");
    }
    return 0;   
}
         
         
         
          
        
      
     
   



Measured memory_bytes: 2040
from functools import lru_cache
import sys

sys.setrecursionlimit(1000000)

mod = 10 ** 9 + 7

@lru_cache(maxsize=1000000)
def saiki(i):
    if ok[i]:
        if i == 0:
            return 1
        if i == 1:
            return 1
        return saiki(i - 1) % mod + saiki(i - 2) % mod
    else:
        return 0


n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
ok = [True] * (n + 1)
for i in a:
    ok[i] = False
print(saiki(n) % mod)

Measured memory_bytes: 283028
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, M; cin >> N >> M;
	vector<string>A(N);
	rep(i, 0, N)cin >> A[i];
	vector<string>B(M);
	rep(i, 0, M)cin >> B[i];
	bool is = false;
	rep(i, 0, N - M + 1) {
		rep(j, 0, N - M + 1) {
			int cnt = 0;
			rep(k, 0, M){
				if (A[i + k].substr(j, M) == B[k]) ++cnt;
			}
			if (cnt == M)is = true;
		}
	}
	cout << (is ? "Yes" : "No") << "\n";

	return 0;
}

Measured memory_bytes: 256
from sys import stdin
S = str(stdin.readline().rstrip())
i = 0
takahasi = 0
while i < 4:
  if S[i:i+1] == "+":
    takahasi += 1
  elif S[i:i+1] == "-":
    takahasi -= 1
  i += 1
print(takahasi)

Measured memory_bytes: 2940
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int mod=998244353,N=305;
int nm,m,n,f[N][N][N],ans,sum[N],a[N];
char s[N];

signed main(){
	scanf("%s",s+1);read(m);
	n=strlen(s+1);s[++n]='0';
	for(int i=1;i<=n;i++){
		if(s[i]=='0') nm++;
		else a[nm+1]++;
	}
	for(int i=1;i<=nm;i++) sum[i]=sum[i-1]+a[i];
	m=min(m,sum[nm]);
	f[0][0][0]=1;
	for(int i=1;i<=nm;i++) 	for(int j=sum[i];j<=sum[nm];j++){
		int lim=min(j,n-sum[i-1]-nm);
		for(int k=0;k<=m;k++) for(int bi=0;bi<=lim;bi++) if(max(0,bi-a[i])<=k)
			f[i][j][k]=(f[i][j][k]+f[i-1][j-bi][k-max(0,bi-a[i])])%mod;
	}
	for(int i=0;i<=m;i++) ans=(ans+f[nm][sum[nm]][i])%mod;
	write(ans);
}

Measured memory_bytes: 30624
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  
  vector<int> height(N);
  for (int i = 0; i < N; i++){
    cin >> height.at(i);
  }
  
  vector<int> ones(N);
  ones.at(0) = 0;
  vector<int> secs(N);
  secs.at(0) = 0;
  
  for(int i = 1; i < N; i++){
    ones.at(i) = abs(height.at(i-1) - height.at(i));
  }
  
  for(int i = 1; i < N-1; i++){
    secs.at(i) = abs(height.at(i-1) - height.at(i + 1));
  }
  
  vector<int> DP(N);
  DP.at(0) = 0;
  DP.at(1) = ones.at(1);
  
  for (int i = 2; i < N; i++){
    int a = DP.at(i-2) + secs.at(i-1);
    int b = DP.at(i-1) + ones.at(i);
    DP.at(i) = min(a,b);
  }
/*  
  cout << "heis" << " ";
  for(int i = 0; i < N; i++){
    cout << height.at(i) << " ";
  }
  cout << endl;
  cout << "ones" << " ";
  for(int i = 0; i < N; i++){
    cout << ones.at(i) << " ";
  }
  cout << endl;
  cout << "secs" << " ";  
  for(int i = 0; i < N; i++){
    cout << secs.at(i) << " ";
  }
  cout << endl;
  cout << "DP   ";
  for(int i = 0; i < N; i++){
    cout << DP.at(i) << " ";
  }
  cout << endl;  
*/  
  cout << DP[N-1] << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void){
        int i,j;

        for(i = 0;i < 9;i++){
                for(j = 0;j < 9;j++){
                        printf("%dx%d=%d\n",i+1,j+1,(i+1)*(j+1));
                }
        }
        return 0;
}

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

using namespace std;

#define ll            long long int
#define endl          '\n'
#define dbg(x)         cerr << #x << "=" << x << endl

static const int maxn = 2e5 + 5;
static const int inf = 1e9;
int dp[105][105 * 105];
int n;
int val[105];

int solve(int pos, int num)
{
      if (pos > n)
      {
            if (num % 10 == 0) return -inf;
            return 0;
      }
      int &ret = dp[pos][num];
      if (~ret) return ret;
      ret = solve(pos + 1, num);
      ret = max(ret, val[pos] + solve(pos + 1, num + val[pos]));
      return ret;
}

signed main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);



      cin >> n;
      for (int i = 1; i <= n; i++) cin >> val[i];
      memset(dp, -1, sizeof dp);
      cout << max(0, solve(1, 0)) << endl;
}



Measured memory_bytes: 4736
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>

using namespace std;

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

typedef long long ll;
typedef vector<vector<int> > Graph;

const int Mod = static_cast<int>(1e9 + 7);

int main()
{
	ll x;
	cin >> x;
	ll ans = 0;
	ll c = 100;

	while (c < x) {
		ans++;
		c = c + c / 100;
	}
	cout << ans << endl;
}

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

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

  if (s[2] == s[3] && s[4] == s[5]) { 
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  } 

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;

int main(){
	int n;
	int coin[6] = {500, 100, 50, 10, 5, 1};
	
	while(cin >> n, n){
		int m = 1000 - n;
		int num = 0;
		
		REP(i, 6){
			num += m / coin[i];
			m %= coin[i];
		}
		
		cout << num << endl;
	}
	
	return 0;
}

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

//Containers
typedef long long int lng;
#define vint vector<int>
#define vtwod vector<vector<int>>
#define vlng vector<long long int>
#define vstr vector<string>
#define vvint vector<int,int>
#define pint pair<int,int>
#define lint list<int>
#define qint queue<int>
#define dqint deque<int>
#define pq priority_queue<int>
#define rpq priority_queue<int,vector<int>,greater<int>>
#define fl forward_list<int>
#define st stack<int>
#define sint set<int>
#define msint multiset<int>


//Methods of containers:-
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define binsear binary_search
#define popf pop_front
#define popb pop_back
#define empb emplace_back
#define empf emplace_front
#define emp emplace
#define emt empty
#define ins insert
#define insaft insert_after
#define emplaft emplace_after
#define ersaft erase_after
#define swp swap
#define splicaft splice_after


//FUNCTIONS
int min3(int a,int b,int c)
{
    return min(min(a,b),c);
}
int max3(int a,int b,int c)
{
    return max(max(a,b),c);
}
void gcd(int a,int b)
{
    cout<<__gcd(a,b)<<endl;
}

/*******************************************************CODE**************************************************************/
void doit()
{
    int n=0,dup=0;
    cin>>n;
    int x=n%1000;
    if(x==0)
    {
        cout<<0<<endl;
    }
    else{
    cout<<abs(1000-x)<<endl;}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(NULL);
    doit();
    return 0;
}




Measured memory_bytes: 3700
N, M = map(int, input().split())
l = []

for i in range(N):
    ab = list(map(int, input().split()))
    l.append(ab)

l.sort(key=lambda x:x[0])

pay = 0
hold = 0
for i in range(N):
    quantity = l[i][1]
    price = l[i][0]
    require = M - hold
    
    if require >= quantity :
        hold += quantity
        pay += price * quantity
    elif require < quantity :
        hold += require
        pay += price * require
            
    if hold == M:
        break

print(pay)

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

int main(void){
    int N; cin >> N;
    vector<int> A(N),B(N);

    for(int i=0; i<N; i++){
        int a; cin >> a;
        A[i]=B[i]=a;
    }
    sort(B.begin(),B.end());

    int left=B[N/2-1], right=B[N/2];
    for(int i=0; i<N; i++){
        if(A[i]<=left) cout << right << endl;
        else cout << left << endl;
    }
}

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

int main() {
	int N;
	cin >> N;
	int A = N % 10;
	if (A == 3) cout << "bon" << endl;
	else {
		if (A == 0 || A == 1 || A == 6 || A == 8) cout << "pon" << endl;
		else cout << "hon" << endl;
	}
}

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

int main(){
    int N,M,i,sum;
    int X[111111],L[111111];
    cin >> N >> M;
    for(i=0;i<=M-1;i++)
        cin >> X[i];
    sort(X,X+M);
    for(i=0;i<=M-2;i++)
        L[i] = X[i+1] - X[i];
    sort(L,L+M,greater<int>());
    sum = 0;
    for(i=0;i<=N-2;i++)
        sum += L[i];
    if(N<M)cout << X[M-1]-X[0]-sum << endl;
    if(N>=M)cout << 0 << endl;
}


Measured memory_bytes: 1024
import sys
n = sys.stdin.readline().rstrip("\n")
n1 = int(n[-1])
if n1 == 3:
    print('bon')
elif n1 == 0 or n1 == 1 or n1 == 6 or n1 == 8:
    print('pon')
else:
    print('hon')

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

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

void enqueue(P);
P dequeue();

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

int main ()
{
  int elaps=0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);
  for(i=1;i<=n;i++)
    {
      scanf("%s",Q[i].name);
      scanf("%d",&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;
}

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




Measured memory_bytes: 11888
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <unistd.h>
using namespace std; 
using namespace std::chrono; 
using namespace __gnu_pbds;
//mp.reserve(1024);
//mp.max_load_factor(0.25);
typedef tree<int, null_type, less<int>, rb_tree_tag,  
                tree_order_statistics_node_update>  
        ordered_set;  
#define ll long long int 

void addEdge(vector<ll> adj[], ll u, ll v) 
{ 
   adj[u].push_back(v); 
   adj[v].push_back(u); 
} 

int main() 
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin); 
   // freopen("output1.txt", "w", stdout); 
	ll n,k;
	cin>>n>>k;
	cout<<min(n%k,abs(n%k-k))<<endl;;
 return 0; 
} 


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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 main(){
    int x, a, b; cin >> x >> a >> b;
    int res = x - a;
    res = res - (res/b)*b;
    cout << res << ln;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;
    vector<int> A(3*N);
    rep(i, 3*N) cin >> A[i];
    sort(A.begin(), A.end(), greater<int>());

    ll ans = 0LL;
    for (int i=1; i<=2*N; i+=2) {
        ans += A[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 1408
def ok(m):
    c = 1
    tmp = m
    for w in W:
        if tmp > w:
            tmp -= w
        else:
            c += 1
            tmp = m - w
    return k >= c
 
n, k = map(int, input().split())
W = [int(input()) for i in range(n)]
 
left = max(W)
right = sum(W)+1
while left+1 < right:
    mid = (left+right) // 2
    if ok(mid):
        right = mid
    else:
        left = mid
print(left)


Measured memory_bytes: 9560
#include <stdio.h>

int main()
{
  int x, y, r = 0;

  scanf("%d",&x);
  scanf("%d",&y);

  if(x > y)
    {
      while(y > 0)
	{
	  r = x % y;
	  x = y;
	  y = r;
	}
      printf("%d\n",x);
    }
  else
    {
      while(x > 0)
	{
	  r = y % x;
	  y = x;
	  x = r;
	}
      printf("%d\n",y);
    }
  
  return 0;
}



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

using namespace std;

bool iseven(string a){
	int n = int(a.size());
	if(n % 2 != 0) return false;
	string a1 = "", b = "";
	for(int i = 0;i < n / 2;i++){
		a1 += a[i];
	}
	for(int i = n / 2;i < n;i++){
		b += a[i];
	}
	if(a1 == b) return true;
	return false;
}

int main(){
	string a; cin >> a;
	string b = "";
	int n = int(a.size());
	int Max = -1;
	for(int i = 0;i < n;i++){
		if(iseven(b)){
			Max = max(Max, int(b.size()));
		}
		b += a[i];
	}
	cout << Max;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
ll pow(ll x){
    ll mod=1e9+7;
    if(x==0) return 1;
    if(x%2==0){
        ll t=pow(x/2);
        return (t*t)%mod;
    }
    return (2*pow(x-1))%mod;
}


int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll mod=1e9+7;
    ll res=0;
    rep(i,70){
        ll one=0, zero=0;
        rep(j,n){
            if(a[j] & 1) one++;
            else zero++;
            a[j] /=2;
        }
        //if(cnt==n) break;
        ll d=pow(i);
        ll e=one*zero;
        if(e==0) continue;
        e%=mod;
        res+=(e*d)%mod;
        res%=mod;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 2560
import math
a=int(input())
b_4 = math.ceil(a/4)
b_7 = math.ceil(a/7)

count =0
for i in range(b_4+1):
    for j in range(b_7+1):
        
        if (4*i+j*7) == a:
            count += 1
            break

if count>=1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import sys
from collections import defaultdict

def load(vtype=int):
    return vtype(input().strip())

def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]

def exit():
    import sys
    sys.exit(0)

def check(s, i, j):
    if s[i:j+1] == 'ABC':
        return True
    return False

n = load()
s = load(str)

result = 0
for i in range(0, len(s)):
    if check(s, i, i+2):
        result += 1

print(result)



Measured memory_bytes: 3316
#include <cstdio>
#include <algorithm>  
#include <bitset>
#include <cassert>
#include <ctime>  
#include <cmath>  
#include <cstdlib>  
#include <cstring>  
#include <functional>  
#include <iostream>  
#include <deque>  
#include <stack>
#include <queue>  
#include <vector>  
#include <map>  
#include <set>  
#include <string>  
#include <unordered_map>  
#include <unordered_set>  
#pragma warning(disable:4996)

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const int INF = 1e9;
const int MAXN = 2e5 + 5;

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

	double L; cin >> L;
	printf("%.7f", pow(L/3, 3));
}

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

using ll=long long;

int main() {
  vector<int> city(4);
  rep(i,0,3) {
    int a,b; cin >>a >>b;
    city[a-1]++;
    city[b-1]++;
  }
  if (city[0]==1 && city[1]==2 && city[2]==2 && city[3]==1) {
    cout <<"YES" <<endl;
  } else {
    cout <<"NO" <<endl;
  }
  return 0;
}


Measured memory_bytes: 3612
#include<cstdio>
int main(){
int a,b,c,tmp;
scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		tmp = b;
		b = a;
		a = tmp;
		}
	if(b>c){
		tmp = c;
		c = b;
		b = tmp;
		}
	if(a>b){
		tmp = b;
		b = a;
		a = tmp;
		}
printf("%d %d %d\n",a,b,c);
return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC optimize("Ofast")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T1, typename T2>
T2 sum_mod(T1 x, T2 MOD) {
	if (x < 0)
		x += MOD;
	if (x >= MOD)
		x -= MOD;
	return x;
}

template <typename T1, typename T2>
T2 mul_mod(T1 x, T2 MOD) {
	if (x < 0)
		return (abs(x) % MOD == 0 ? 0 : MOD - abs(x) % MOD);
	return x % MOD;
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 18;
const int N = (int)3e5 + 7;
const int MAXN = (int)2e6 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e17;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x; cin >> x;
		n -= x;
	}
	cout << max(-1, n);

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 3640
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
unsigned int randInt() {
	static unsigned int tx = 123456789, ty = 362436069, tz = 521288629, tw = 88675123;
	unsigned int tt = (tx ^ (tx << 11));
	tx = ty; ty = tz; tz = tw;
	return (tw = (tw ^ (tw >> 19)) ^ (tt ^ (tt >> 8)));
}
int cnt[13] = {};
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int D[51];
    cnt[0]++;
    rep(i, N) {
        cin >> D[i];
        cnt[D[i]]++;
        if(cnt[D[i]] > 2) {
            cout << 0 << endl;
            return 0;
        }
    }
    D[N] = 0;
    int ans = 0;
    int loop = 1000000;
    N++;
    while(loop--) {
        int k = randInt() % N;
        D[k] = 24 - D[k];
        int tmp = 24;
        rep(i, N) {
            REP(j, i + 1, N - 1) {
                int d = abs(D[i] - D[j]);
                tmp = min(tmp, min(d, 24 - d));
            }
        }
        // if(ans < tmp) {
        //     rep(i, N) cout << D[i] << " ";
        //     cout << endl;
        // }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    



    return 0;
}


Measured memory_bytes: 3628
N,K=map(int,input().split())
RSP=list(map(int,input().split()))
RSP.append(0)
T=list(input())
A=[0]*N

for i in range(N):
  if T[i]=='r':
    A[i]=2
  elif T[i]=='s':
    A[i]=0
  else:
    A[i]=1

ans=0
for i in range(K):
  B=A[i::K]
  for j in range(1,len(B)):
    if B[j-1]==B[j]:
      B[j]=3
  for k in B:
    ans+=RSP[k]

print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define foreach(it, S) for (__typeof (S.begin()) it = S.begin(); it != S.end(); it++)
#define all(x) x.begin(), x.end()
#define endl '\n'
#define _ ios_base :: sync_with_stdio(false); cin.tie(NULL);

#ifdef inputf
# define fname ""
#else
# define fname "" // <- Here
#endif

#ifndef lcl
# define cerr if (0) cout
#endif

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

#define dlong long double

const dlong eps = 1e-30;
const int MAXN = (1 << 20) + 256;
const int MOD = (int)1e9 + 7, INF = (int)1e9;
const ll INFLL = (ll)1e18;

int a[MAXN], n;
int cnt[MAXN];

inline void print(bool ok) {
	if (!ok)
		puts("Impossible");
	else
		puts("Possible");
	exit(0);
}

int main() { // _
	#ifdef lcl
		freopen(fname".in", "r", stdin);
		freopen(fname".out", "w", stdout);
	#endif

	scanf("%d", &n);

	for (int i = 0; i < n; ++i) {
		scanf("%d", a + i);
		cnt[a[i]]++;
	}

	int x = *max_element(a, a + n);

	if (x & 1) {
		int y = (x + 1) / 2;
		if (cnt[y] != 2)
			print(false);
		for (int j = 1, i = y + 1; i < x; ++i, ++j) {
			int y = i;
			if (cnt[i] < 2)
				print(false);
		}
		print(true);
	} else {
		int y = x / 2;
		if (cnt[y] != 1)
			print(false);
		for (int j = 1, i = y + 1; i < x; ++i, ++j) {
			int y = i;
			if (cnt[i] < 2)
				print(false);
		}
		print(true);
	}

	return 0;
}



Measured memory_bytes: 384
from collections import deque
h, w = map(int, input().split())
a = []
for _ in range(h):
    a.append(list(input()))
q = deque()
for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            q.append((i, j, 0))
dxdy = [(-1, 0), (0, -1), (0, 1), (1, 0)]
ans = 0
while q:
    y, x, cnt = q.popleft()
    for dx, dy in dxdy:
        if not(0<=x+dx<w and 0<=y+dy<h):
            continue
        if a[y+dy][x+dx]=='.':
            a[y+dy][x+dx] = '#'
            q.append((y+dy, x+dx, cnt+1))
            ans = cnt+1
print(ans)

Measured memory_bytes: 161628
package main

import (
	"fmt"
)

func main() {
	var A, B, X int
	fmt.Scan(&A, &B, &X)
	if A > X {
		fmt.Println("NO")
	} else if A+B < X {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


Measured memory_bytes: 512
n = int(input())
p = list(map(int, input().split()))
ans = 0
before =0
for i in range(n-1):
    if p[i+1]-p[i]>0:
        up = 1
    else:
        up = -1
    if before*up>0:
        ans += 1
    else:
        pass
    before = up
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  int G[100][100];
  int n, u, k, v, i, j;

  scanf("%d", &n);

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      G[i][j] = 0;
    }
  }

  for(i = 0;i < n;i++){
    scanf("%d%d", &u, &k);
    for(j = 0;j < k;j++){
      scanf("%d", &v);
      G[u-1][v-1] = 1;
    }
  }

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

  return 0;
}

Measured memory_bytes: 1820
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N;
vector<int> v;
pair<ll,ll> dp[405][405];

pair<ll,ll> solve(int i, int j){
  if(dp[i][j].first != -1) return dp[i][j];
  if(i==j) return dp[i][j] = make_pair(v[i],0);

  pair<ll,ll> best = make_pair(-1,(ll)1e15);  
  REP(k,i,j){
    pair<ll,ll> a = solve(i,k);
    pair<ll,ll> b = solve(k+1,j);
    pair<ll,ll> c = make_pair(a.first+b.first, a.second+b.second+a.first+b.first);

    if(best.second > c.second) best = c;
  }
  return dp[i][j] = best;
}

int main(){
  cin >> N;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  rep(i,405) rep(j,405) dp[i][j] = make_pair(-1, 0);
  
  cout << solve(0, N-1).second << endl;
  
  return 0;
}



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

int even(int n) {
  return n/2;
}

int odd(int n) {
  return n*3+1;
}

  

int main() {
  int s;
  cin >> s;
  vector<int> vec(1000000);
  bool check = true;
  for (int i = 0; i < 1000000; i++) {
    vec.at(s)++;
    if (vec.at(s) == 2) {
      cout << i+1 << endl;
      break;
    }
    else if (s%2==0) {
      s = even(s);
    }
    else if (s%2==1) {
      s = odd(s);
    }
  }
}


Measured memory_bytes: 4096
n,m=map(int,input().split())
s=input()
ans=[]
now=n
while now>0:
    for i in range(m,0,-1):
        if now-i<0:
            continue
        if s[now-i]=='0':
            ans.append(str(i))
            now-=i
            break
    else:
        print(-1)
        exit()
print(' '.join(ans[::-1]))

Measured memory_bytes: 10484
#include<bits/stdc++.h>
using namespace std;
const int N=2009;
int n,m;
vector<int>g[N];
int dfn[N],low[N],num,vis[N],co[N],col;
stack<int>S;
int siz[N];
void tarjan(int u){
   // cout<<u<<endl;
    dfn[u]=low[u]=++num;
    vis[u]=1;S.push(u);
    for(auto v:g[u]){
        if(!dfn[v])tarjan(v),low[u]=min(low[u],low[v]);
        else if(vis[v])low[u]=min(low[u],dfn[v]);
    }
    if(dfn[u]==low[u]){
        co[u]=++col;siz[col]++;
        while(S.top()!=u){
            co[S.top()]=col;
            vis[S.top()]=0;
            siz[col]++;
            S.pop();
        }
        vis[u]=0;S.pop();
    }
}
//bool vv[N];
vector<int>ans;
vector<int>uu;
int pre[N],vv[N];
void print(int u,int fa){
    ans.clear();
    while(1){
        ans.push_back(u);
        u=pre[u];
        if(u==fa)break;
        if(ans.size()>1000)break;
    }
    ans.push_back(fa);
    if(uu.size()==0||uu.size()>ans.size())uu=ans;
   // cout<<uu.size()<<endl;
    //cout<<ans.size()<<endl;
   // for(auto v:ans)cout<<v<<endl;
  //  exit(0);
}
void bfs(int u,int fa){
    queue<int>q;
    q.push(u);vv[u]=1;
    while(!q.empty()){
        int now=q.front();q.pop();
        for(auto v:g[now])if(vv[v]==1){vv[v]=2;print(now,v);}
        else{
            if(vv[v]==2)continue;
            if(co[v]!=fa)continue;
        //    if(vv[v])memset(vv,0,sizeof(vv)),bfs(now,fa);
            vv[v]=1;q.push(v);pre[v]=now;
        }
    }   
}
int main(){
   // freopen("tt.in","r",stdin),freopen("tt.out","w",stdout);
    cin>>n>>m;
    for(int i=1,u,v;i<=m;i++)cin>>u>>v,g[u].push_back(v);
    for(int i=1;i<=n;i++)if(!dfn[i])tarjan(i);
    for(int i=1;i<=col;i++)if(siz[i]>1){
       // cout<<siz[i]<<endl;
        for(int j=1;j<=n;j++)if(co[j]==i){bfs(j,i);break;}
        break;
       // return 0;
    }
    if(uu.empty()){cout<<-1<<endl;return 0;}
    cout<<uu.size()<<endl;
    for(auto i:uu)cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
#define MAX 100000
#define INF 100000000
using namespace std;
typedef long long ll;
int a[MAX+1],b[MAX+1];
int main()
{	
	int n,length=1;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	b[1]=a[1];
	for(int i=2;i<=n;i++)
	{
		if(b[length]<a[i])
		{
			b[++length]=a[i];
		}else{
			*lower_bound(b+1,b+1+length,a[i])=a[i];
		}
	}
	cout<<length<<endl;
}


Measured memory_bytes: 3860
#include <stdio.h>
#define ERR (0.0001)

int main(void)
{
	double a, b, c, d, e, f;
	while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
		printf("%.3lf %.3lf\n", (e*c - b*f) / (a*e - b*d) + ERR, (a*f - c*d) / (a*e - b*d) + ERR);
	}
	return (0);
}

Measured memory_bytes: 656
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var read = cin.ReadIntArray(2);

            if(read[0]==read[1]) WriteLine("Yes");
            else WriteLine("No");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vll = vector<vl>;
using vii = vector<vi>;
using pii = pair<int, int>;

using vc = vector<char>;
using vcc = vector<vc>;
using vb = vector<bool>;
using vbb = vector<vb>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using vd = vector<double>;
using vdd = vector<vd>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


const int MOD = 1e9 + 7;

vector<pii> prime_factorization(int n){ // 素因数分解をしたvector<素数, 指数>を返す
  vector<pii> res;
  int tmp, root_n = floor(sqrt(n));
  if(n % 2 == 0){
    tmp = 1;
    n /= 2;
    while(n % 2 == 0){
      n /= 2;
      tmp++;
    }
    res.push_back(make_pair(2, tmp));
  }
  ll i = 3;
  while(i <= root_n && i <= n){
    if(n % i == 0){
      tmp = 1;
      n /= i;
      while(n % i == 0){
        n /= i;
        tmp++;
      }
      res.push_back(make_pair(i, tmp));
    }
    i += 2;
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}
vector<pli> prime_factorization(ll n){ // 素因数分解をしたvector<素数, 指数>を返す
  vector<pli> res;
  int tmp, root_n = floor(sqrt(n));
  if(n % 2 == 0){
    tmp = 1;
    n /= 2;
    while(n % 2 == 0){
      n /= 2;
      tmp++;
    }
    res.push_back(make_pair(2, tmp));
  }
  ll i = 3;
  while(i <= root_n && i <= n){
    if(n % i == 0){
      tmp = 1;
      n /= i;
      while(n % i == 0){
        n /= i;
        tmp++;
      }
      res.push_back(make_pair(i, tmp));
    }
    i += 2;
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}

// n は 2以上の素数表を返す
vb Primes(int n){
  vector<bool> res(n + 1, true);
  res.at(0) = false; res.at(1) = false;
  for(int i = 2; i <= sqrt(n); i++){
    if(res.at(i)){
      for(int j = 2 * i; j <= n; j += i){
        res.at(j) = false;
      }
    }
  }
  return res;
}
// ===================================================

ll power_mod(ll k, int n, int mod){
  if(n == 0) return 1;
  ll tmp = power_mod(k, n / 2, mod);
  tmp = (tmp * tmp) % mod;
  if(n % 2 == 0) return tmp;
  return (k * tmp) % mod;
}

ll v_p(int n, int p){
  int res = 0;
  while(n >= p){
    res += (n / p);
    n /= p;
  }
  return res;
}



int main(){
  int a, b, c; cin >> a >> b >> c;
  if(a + b + 1 >= c) cout << b + c << "\n";
  else cout << (a + b) + b  + 1 << "\n";
  return 0;
}

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;
const int MOD = 1000000007;
const ll INF = (ll) 1e18;
int main()
{
  int N;
  cin >> N;
  string s;
  cin >> s;
  rep(i,2){
    rep(j,2){
      vector<int>now(N,-1);
      now[0]=i;
      now[1]=j;
      for(int k=2;k<N;k++){
        if((s[k-1]=='x')^(now[k-1]==1)){
          now[k]=(now[k-2]^1);
        }
        else{
          now[k]=now[k-2];
        }
      }
      bool ok=true;
      ok&=(((s[N-1]=='x')^(now[N-1]==1))^(now[N-2]==now[0]));
      ok&=(((s[0]=='x')^(now[0]==1))^(now[N-1]==now[1]));

      if(ok){
        rep(k,N){
          cout << (now[k]==1?"W":"S") << (k==N-1?"\n":"");
        }
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 4088
#include <iostream>
#include <vector>
const int N_MAX = 1e5 + 10;

typedef long long ll;

using namespace std;

ll dp[N_MAX][2] = {0};
int A[N_MAX];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    dp[0][0] = A[0];
    dp[0][1] = -A[0];
    for (int i = 1; i < N - 1; i++) {
        dp[i][0] = max(dp[i - 1][0] + A[i], dp[i - 1][1] - A[i]);
        dp[i][1] = max(dp[i - 1][0] - A[i], dp[i - 1][1] + A[i]);

        // cout << dp[i][0] << " " << dp[i][1] << endl;
    }

    cout << max(dp[N - 2][0] + A[N - 1], dp[N - 2][1] - A[N - 1]) << endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define in              insert
#define pb              push_back
#define mp              make_pair
#define lb              lower_bound
#define ub              upper_bound
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n]
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vi adj[100001];
int vis[100001];
int lvl[100001];

void dfs(int i)
{
	vis[i] = 1;

	for (auto nb : adj[i]) {
		if (!vis[nb])
			dfs(nb);

		lvl[i] = max(lvl[i], 1 + lvl[nb]);
	}
}

int32_t main()
{
	FIO;
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		adj[u].pb(v);
	}

	for (int i = 1; i <= n; i++) {
		if (!vis[i])
			dfs(i);
	}

	int ans = lvl[1];
	for (int i = 2; i <= n; i++)
		ans = max(ans, lvl[i]);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 13288
#pragma GCC optimize("Ofast")

//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main() {
  // 高速化
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    string X, Y, Z;
    cin >> X;
    cin >> Y;
    cin >> Z;


    string ans;

    cout << Z+" "+X+" "+ Y<< "\n"; 

    return 0;
}

Measured memory_bytes: 256