akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

typedef long long ll;

#define F first
#define S second

using namespace std;

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

    ll a, b, k;

    cin >> a >> b >> k;

    for (int i = 2; i <= k; i+=2)
    {
    	a = a/2;
    	b += a;

    	b = b/2;
    	a += b;
    }

    if (k&1) {
    	a = a/2;
    	b += a;
    }

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

    return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

#define LL long long

#define fi first
#define se second
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(a,b) (((a)+(b))>>1)
#define maxx(a,b) ((a)<(b)?(b):(a))
#define minx(a,b) ((a)<(b)?(a):(b))
#define absx(a) ((a)<0?-(a):(a))
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define itr iterator
#define lowbit(x) ((x)&-(x))

typedef unsigned LL ULL;
typedef unsigned uint;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;

template< typename T > inline void read(T &x) {
    bool f; char ch; f=0; x=0; ch=getchar();
    while(ch<'0' || ch>'9') {if(ch=='-') f=1; ch=getchar();}
    while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
    if(f) x=-x;
}

template< typename T > inline void Max(T &a, T b) {if(a<b) a=b;}
template< typename T > inline void Min(T &a, T b) {if(b<a) a=b;}
template< typename T > inline T Abs(T a) {if(a<0) return -a; else return a;}

const double pi=(double) acos(-1.0);
const int MOD=(int) 1e9+7;
const int INF=(int) 0x3f3f3f3f;
const LL  LINF=(LL) INF<<32|INF;
const int SINF=(uint) ~0>>1;
const LL  SLINF=(ULL) (-1)>>1;
const double DINF=(double) 1e50;
const double eps=(double) 1e-12;
const int maxn=(int) 1e5+20;
const int maxm=(int) 1e6+20;
const int maxk=(int) 5e2+20;

inline int sig(double x) {return x<-eps?-1:x>eps;}

//--------------start------------------

int n,m;
vector<int> G[maxn];
int vis[maxn];

bool dfs(int u,int t)
{
    if(vis[u]!=-1)
    {
        return vis[u]!=t;
    }

    vis[u]=t;

    for(int i=0;i<G[u].size();i++)
    {
        int v=G[u][i];

        if(dfs(v,!t)) return 1;
    }
    return 0;
}



void work()
{
    read(n), read(m);
    for(int i=0;i<m;i++)
    {
        int x,y; read(x), read(y);
        G[x].push_back(y);
        G[y].push_back(x);
    }

    if(n==3)
    {
        cout <<0 <<endl;
        return ;
    }

    if(n==4)
    {
        cout <<4-m <<endl;
        return ;
    }

    memset(vis,-1,sizeof(vis));

    if(dfs(1,1))
    {
        LL tot=(LL) n*(n-1)/2;

        cout <<tot-m <<endl;
        return ;
    }
    else
    {
        LL e=0, o=0, cnt=0;
        for(int i=1;i<=n;i++)
        {
            if(vis[i]) e++; else o++;
            for(int j=0;j<G[i].size();j++)
                if(vis[i]!=vis[G[i][j]]) cnt++;
        }
        cout <<e*o-cnt/2 <<endl;
        return ;
    }
}

//--------------end--------------------

int main()
{
#ifdef yukihana0416
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif // yukihana0416
    work();
    return 0;
}


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

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

    string longest = "";
    int N = S.size();
    for (int i = 0; i < N; i++) {
        string str = "";
        int j = i;
        while (j < N && (S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T')) {
            str += S[j];
            j++;
        }
        if (longest.size() < str.size()) longest = str;
    }

    cout << longest.size() << endl;
}

Measured memory_bytes: 3540
a,b = map(int, input().split())
if a==b==1:
  print('Draw')
elif a ==1:
  print('Alice')
elif b ==1:
  print('Bob')  
  
if a !=1 and b !=1:
  if a>b:
    print('Alice')
  elif a<b:
    print('Bob')
  elif a==b:
    print('Draw')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> P(n,0), Q(n,0);
    REP(i,n) {
        cin >> P[i];
        Q[i] = P[i];
    }
    sort(ALL(P));
    int cnt = 0;
    REP(i,n){
        if(P[i]!=Q[i])cnt++;
    }
    if(cnt==0 or cnt==2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a + b >= 10) {
            System.out.println("error");
        } else {
            System.out.println(a + b);
        }

    }
}


Measured memory_bytes: 21076
import java.util.*;
import java.io.*;
 
public class Main {
 
	static int[][] products;
	static int[] rows;
	static int[] columns;
 
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
 
		int n = Integer.parseInt(reader.readLine());
		products = new int[n][n];
 
		rows = new int[n];
		columns = new int[n];
 
		for (int i=0; i<n; i++) {
			String line = reader.readLine();
			rows[i] = Integer.parseInt(line.substring(0,line.indexOf(" ")));
			columns[i] = Integer.parseInt(line.substring(line.indexOf(" ")+1));
		}
 
		System.out.println(calc(0,n-1));
 
		
	}
 
	static int calc(int x,int y){
		if (x-y == 1)
			return products[x][y] = rows[x] * columns[x] * columns[y];
		
		if (products[x][y] != 0 || x==y)
			return products[x][y];
		
		int minimum = Integer.MAX_VALUE;
		for (int a=x; a<y; a++){
			minimum = Math.min(minimum, calc(x,a) + calc(a+1,y) + rows[x] * rows[a+1] * columns[y]);
		}
		return products[x][y] = minimum;
	}
}




Measured memory_bytes: 25372
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=1e5+1;
LL dp[L];
LL N,A,B;
int main() {
	cin >> N >> A >> B;
	LL c;
	cin >> c;
	LL ret=0;
	for(int i=1;i<N;i++){
		LL x;
		cin >> x;
		ret+=min(A*(x-c),B);
		c=x;
	}
	cout << ret << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a > b)
        swap(a,b);
    if(b > c)
        swap(b,c);
    if(a > b)
        swap(a,b);
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 3224
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    int len = s.length();
    if(s.substring(0,len).equals(t.substring(0,len))){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35672
import Control.Arrow
import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad

main :: IO ()
main = breads >>= main'
    where
        main' [n, c] = replicateM n breads >>= print . solve n c

solve :: Int -> Int -> [[Int]] -> Int 
solve n c xvs = max (count gs bs) $ count rgs rbs
    where
        rxvs = map (\[x, v] -> [c - x, v]) $ reverse xvs

        scanVss = scanl (\acc [_, v] -> acc + v) 0
        vss = scanVss xvs
        rvss = scanVss rxvs
        gs = zip3 [0..] vss . (0 :) $ map head xvs
        rgs = zip3 [0..] rvss . (0 :) $ map head rxvs
        scanBs = reverse . scanl (\acc (_, v, x) -> max acc $ v - x) 0 . tail 
        bs = scanBs rgs
        rbs = scanBs gs

        count xs = maximum . map mf . zip xs
            where
                mf ((_, v, x), mv) = max (v - x) $ v - 2 * x + mv

breads :: IO [Int]
breads = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

Measured memory_bytes: 103036
n = int(input())
A = [int(i) for i in input().split()]

def merge(A, left, mid, right, cnt):
    L = A[left:mid]
    R = A[mid:right]
    i = 0
    j = 0
    L.append(1000000000)
    R.append(1000000000)
    for k in range(left,right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            if k < mid + j:
                cnt += mid + j - k
            A[k] = R[j]
            j += 1
    return A, cnt

def mergeSort(A, left, right, cnt):
    if left+1 < right:
        mid = (left + right)//2
        A, cnt = mergeSort(A, left, mid, cnt)
        A, cnt = mergeSort(A, mid, right, cnt)
        A, cnt = merge(A, left, mid, right, cnt)
    return A, cnt

A, cnt = mergeSort(A, 0, n, 0)
print(cnt)





Measured memory_bytes: 27484
#include <iostream>
using namespace std;
int N;
int A[100010];
int used[100010] = {};

int main(){
  cin >> N;
  for(int i=1;i<=N;i++) cin >> A[i];
  int id = 1,ans = 0;
  while(true){
    used[id] = 1;
    ans++;
    id = A[id];
    if(id==2 || used[id]) break;
  }
  cout << (id==2? ans:-1) << endl;
}

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

int main() {
  int q1, b, c1, c2, q2, n1, n2;

  while (1) { 
    cin >> q1;
    if (!q1) break;

    cin >> b >> c1 >> c2 >> q2;
    if (c1 > c2) {
      n1 = (b - c2 * q1) / (c1 - c2);
      if (n1 > q1) {
        n1 = b / c1;
      }
    } else {
      n1 = b / c1;
    }
    if (n1 > q2) {
      n1 = q2;
    }
    n2 = (b - c1 * n1) / c2;

    if (n1 <= 0 || n1 + n2 < q1) {
      cout << "NA" << endl;
    } else {
      cout << n1 << " " << n2 << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    ll arr[n+1];
    arr[0]=0;
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    ll dp[n+1];
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);
    for(int i=3;i<=n;i++)
        dp[i]=min((dp[i-1]+abs(arr[i]-arr[i-1])),(dp[i-2]+abs(arr[i]-arr[i-2])));
    cout<<dp[n];

}


Measured memory_bytes: 1792
a,b = map(int,input().split())
def gcd(a,b):
    if a < b:
        temp = b
        b = a 
        a = temp
    remainder = a % b
    if remainder == 0:
        return b
    else:
        return gcd(remainder,b)
 
def gys(a,b):
    remainder = gcd(a,b)
    print(int(a*b/remainder))
gys(a,b)

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
	int al;int bb;
	cin>>al>>bb;
	if(al==1) al=100;
	if(bb==1) bb=100;
	if(al==bb) cout<<"Draw\n";
	else if(al>bb) cout<<"Alice\n";
	else cout<<"Bob\n";
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 50;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;

int L, A[202020];
int dp[202020][6];

itn cost(int i, int s) {
    if (s == 0 || s == 4) {
        return A[i];
    } else if (s == 1 || s == 3) {
        if (A[i] == 0) {
            return 2;
        } else
            return A[i] % 2;
    } else
        return !(A[i] % 2);
}

void solve() {
    Fill(dp, INF);
    dp[0][0] = 0;
    FOR(L) {
        FOR(j, 0, 5) {
            FOR(k, j, 5) {
                chmin(dp[i + 1][k], dp[i][j] + cost(i, k));
            }
        }
    }
    int ans = INF;
    FOR(5) {
        chmin(ans, dp[L][i]);
    }
    cout << ans << endl;
}

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

    cin >> L;
    FOR(L)
    cin >> A[i];

    solve();
    return 0;
}


Measured memory_bytes: 11392
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var debug = false

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var target string
	if sc.Scan() {
		target = sc.Text()
	}

	res := GetAnswer(target)
	fmt.Printf("%v\n", res)
}

// GetAnswer ...
func GetAnswer(target string) int {
	prt("inputs: target:%#v", target)
	result := 0
	arr := getIntArray(target)
	priceA := arr[0]
	priceB := arr[1]
	priceC := arr[2]
	needA := arr[3]
	needB := arr[4]
	needC := needA
	if needA > needB {
		needC = needB
	}
	if priceA+priceB <= priceC*2 {
		// そのまま買った方が良い
		As := priceA * needA
		Bs := priceB * needB
		result = As + Bs
	} else {
		// 組み換えパターンの方が得
		Cs := priceC * needC * 2
		result = Cs
		remA := needA - needC
		remB := needB - needC
		if remA > 0 {
			if priceA <= priceC*2 {
				result = Cs + priceA*remA
			} else {
				result = Cs + priceC*remA*2
			}
		}
		if remB > 0 {
			if priceB <= priceC*2 {
				result = Cs + priceB*remB
			} else {
				result = Cs + priceC*remB*2
			}
		}
	}

	return result
}

func getIntArray(str string) []int {
	strarr := strings.Split(str, " ")
	intarr := []int{}
	for _, st := range strarr {
		ti, _ := strconv.Atoi(st)
		intarr = append(intarr, ti)
	}
	return intarr
}

func prt(format string, inputs ...interface{}) {
	if debug {
		fmt.Printf(format+"\n", inputs...)
	}
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	vector<int> east(n+1, 0), west(n+1, 0);
	rep(i,n){
		west[i+1] = west[i];
		if(s[i] == 'W') west[i+1]++;
	}
	for(int i = n-1; i >= 0; i--){
		east[i] = east[i+1];
		if(s[i] == 'E') east[i]++;
	}
	int ans = 1e9;
	rep(i,n){
		chmin(ans, east[i+1] + west[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

const int mod = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, a;
    cin >> n;
    map<int, int> m;
    ll ans = 1;
    
    rep(i, n) {
        cin >> a;
        
        if ((n % 2) == (a % 2)) {
            cout << 0 << endl;
            return 0;
        }
        
        m[a]++;
    }
    
    for (auto u : m) {
        if (u.first == 0) {
            if (u.second != 1) {
                cout << 0 << endl;
                return 0;
            }
        }
        else {
            if (u.second != 2) {
                cout << 0 << endl;
                return 0;
            }
            
            ans = ans * 2 % mod;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define INF 2139062143
#define inf -2139062144
#define ll long long
using namespace std;
ll a[200005];
int main() {
	ll ans=100000000000000000,n,i,sum=0,nnn=0,temps;
	scanf("%lld",&n);
	for(i=1; i<=n; i++) {
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	for(i=1; i<=n-1; i++) {
		nnn+=a[i];
		if(2*nnn>sum) {
			temps=nnn-(sum-nnn);
		} else {
			temps=sum-nnn-nnn;
		}
		ans = min(ans,temps);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
  	int a;
  
	cin >> a;
  
  	if (400 <= a && a <= 599){
    	cout << "8" << endl;
    }
  	else if(600 <= a && a <= 799){
    	cout << "7" << endl;
    }
  	else if(800 <= a && a <= 999){
    	cout << "6" << endl;
    }
  	else if(1000 <= a && a <= 1199){
    	cout << "5" << endl;
    }
    else if(1200 <= a && a <= 1399){
    	cout << "4" << endl;
    }
    else if(1400 <= a && a <= 1599){
    	cout << "3" << endl;
    }
    else if(1600 <= a && a <= 1799){
    	cout << "2" << endl;
    }
    else if(1800 <= a && a <= 1999){
    	cout << "1" << endl;
    }
  
  return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n;
    cin >> n;

    int64_t ans = 0;
    int64_t m = 0;
    for (auto i : irange(0L, n)) {
        int64_t a;
        cin >> a;
        m += a;

        if (a == 0) {
            ans += m / 2;
            m = 0;
        }
    }

    ans += m / 2;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    string s,t;
    cin>>s>>t;
    int n=s.size();
    vector<int>a(26,-1),b(26,-1);

    bool ok=true;
    rep(i,n){
        int now=s[i]-'a';
        int opo=t[i]-'a';
        if(a[now]==-1)a[now]=opo;
        else if(a[now]!=opo){
            ok=false;
            break;
        }
        if(b[opo]==-1)b[opo]=now;
        else if(b[opo]!=now){
            ok=false;
            break;
        }
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 776
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()

i = N
while 1:
    s = str(i)
    for a in A:
        if s.count(str(a)):
            break
    else:
        print(i)
        exit()
    i += 1


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N; vector<ll> A(N); rep(i, N){cin >> A.at(i);}
    // やり方
    // (i) ((1, 4), (2), (0)) みたいに単調増加する数列の入れ物を持つ, 最大値だけ簡単に取り出せるようにしておくことが大事
    // - どの最大値よりも低いものが来た場合は，新しい組が生成
    // - そうじゃない場合は，ぎりぎり大きいものを使う (上の例では，3が来たら(0)側ではなく(2)側に)
    // あ，完全に二分探索やん,,

    vector<ll> x;
    rep(i, N){
        if (x.size() == 0){
            x.push_back(A.at(i));
        } else {
            if (A.at(i) <= x.at(0)){
                // 最小なので先頭に入れる
                x.insert(x.begin(), A.at(i));
            } else {
                // 二分探索で座標を得て入れ替え
                // (2, 4) に3を入れるなら 2 -> 3
                auto pos = lower_bound(x.begin(), x.end(), A.at(i));
                x[distance(x.begin(), pos) - 1] = A.at(i);
            }
        }
    }
    cout << x.size() << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 2168
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int[] list = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1,
                      5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
      
       System.out.println(list[K-1]);
	}

}


Measured memory_bytes: 35652
n = int(input())
list_v = list(map(int, input().split()))
list_c = list(map(int, input().split()))

max_value = 0

for i in range(n):
    if list_v[i]>list_c[i]:
        max_value = max_value + (list_v[i]-list_c[i])

print(max_value)

Measured memory_bytes: 3060
//
// Created by corol

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio();
    cin.tie(0);
    int x;
    cin >> x;
    cout << (x>=30 ? "Yes": "No");
    //cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s. \n";
    return 0;
}

Measured memory_bytes: 3596
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int calc(int k) {
	return (ll)k * (k - 1) / 2;
}

int main() {
	int N; cin >> N;
	while (N--) {
		vector<int> v(3);
		cin >> v[0] >> v[1] >> v[2];
		sort(v.begin(), v.end());
		cout << (v[0] * v[0] + v[1] * v[1] == v[2] * v[2] ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 1204
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define maxn 100005
const ll mod=1e9+7;
using namespace std;
ll x[maxn];
int n,m;
ll y[maxn];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%lld",&x[i]);
    for(int i=1;i<=m;i++)
        scanf("%lld",&y[i]);
        ll  ans1=0,ans2=0;
        for(int i=1;i<=n;i++)
        {
            ans1=(ans1+(i-1)*x[i]+mod)%mod;
            ans1=(ans1-(n-i)*x[i]+mod)%mod;
        }
        for(int i=1;i<=m;i++)
        {
            ans2=(ans2+(i-1)*y[i]+mod)%mod;
            ans2=(ans2-(m-i)*y[i]+mod)%mod;
        }
        printf("%lld\n",(ans1%mod*ans2%mod)%mod);
        return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXSIZE=30000020;
int bufpos;
char buf[MAXSIZE];
#define NEG 0
void init(){
	#ifdef LOCAL
		freopen("D.txt","r",stdin);
	#endif
	buf[fread(buf,1,MAXSIZE,stdin)]='\0';
	bufpos=0;
}
#if NEG
int readint(){
	bool isneg;
	int val=0;
	for(;!isdigit(buf[bufpos]) && buf[bufpos]!='-';bufpos++);
	bufpos+=(isneg=buf[bufpos]=='-');
	for(;isdigit(buf[bufpos]);bufpos++)
		val=val*10+buf[bufpos]-'0';
	return isneg?-val:val;
}
#else
int readint(){
	int val=0;
	for(;!isdigit(buf[bufpos]);bufpos++);
	for(;isdigit(buf[bufpos]);bufpos++)
		val=val*10+buf[bufpos]-'0';
	return val;
}
#endif
char readchar(){
	for(;isspace(buf[bufpos]);bufpos++);
	return buf[bufpos++];
}
int readstr(char* s){
	int cur=0;
	for(;isspace(buf[bufpos]);bufpos++);
	for(;!isspace(buf[bufpos]);bufpos++)
		s[cur++]=buf[bufpos];
	s[cur]='\0';
	return cur;
}
bool x[200002],y[200002];
int main(){
	init();
	int n=readint(),m=readint();
	while(m--){
		int a=readint(),b=readint();
		if (a==1)
			x[b]=true;
		if (b==n)
			y[a]=true;
	}
	for(int i=1;i<=n;i++)
		if (x[i] && y[i]){
			return puts("POSSIBLE"),0;
		}
	puts("IMPOSSIBLE");
}

Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] c = str.toCharArray();
        System.out.println(c[0] + "" + c[1] + "" + c[2]);
    }
}


Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  vector<string> T(H);
  for(int i=0;i<H;i++){
    cin>>T.at(i);
  }
  for(int i=0;i<H;i++){
    cout<<T.at(i)<<endl;
    cout<<T.at(i)<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	char a[200001];
	cin >> a;
	for (int i = 0;;i++) {
		if (a[i] == 0) break;
		else if (a[i] == '?') {
			if (i == 0) {
				if (a[1] == 'D') a[0] = 'P';
				else a[0] = 'D';
			}
			else {
				if (a[i - 1] == 'P') a[i] = 'D';
				else if (a[i + 1] == 0) a[i] = 'D';
				else if (a[i + 1] == 'P') a[i] = 'D';
				else a[i] = 'P';
			}
		}
	}
	cout << a;
}


Measured memory_bytes: 3832
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);

        long N = scanner.nextLong();
        long K = scanner.nextLong();
        long min = N;

        N %= K;
        while (true) {
            long next = Math.abs(N - K);
            if (min > next) {
                min = next;
            } else {
                break;
            }
            N = next;
        }
        System.out.println(N);
    }
}


Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

string make(int n)
{
  string res="";
  rep(i,6)
  {
    res=(char)('0'+n%10)+res;
    n/=10;
  }
  return res;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  vector<pair<int,pair<int,int>> >city(m);
  rep(i,m)
  {
    int p,y;cin>>p>>y;
    p--;
    city[i]={p,{y,i}};
  }
  sort(all(city));
  vector<string>res(m);
  vector<int>num(n);
  for(auto tc:city)
  {
    int ke=tc.first,ye=tc.second.first,cinu=tc.second.second;
    num[ke]++;
    string tres;
    tres=make(ke+1)+make(num[ke]);
    res[cinu]=tres;
  }
  rep(i,m)
  {
    cout<<res[i]<<endl;
  }



  return 0;

}


Measured memory_bytes: 8576
n = int(input())
lis = [0]
s = str(input())
cou = 0
co  = 0
for i in range(n-1):
    if s[i] == "W":cou += 1
    lis.append(cou)
for k in range(1,n):
    if s[n-(k)] == "E":co += 1
    lis[n-(k+1)] += co
print(min(lis))

Measured memory_bytes: 15516
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S ;
  cin >> S;
  
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;

    int x = a + b;
    int y = a - b;
    int z = a * b;

    if (x > y) {
        if (x > z) {
            cout << x;
        } else {
            cout << z;
        }
    } else {
        if (y > z) {
            cout << y;
        } else {
            cout << z;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
struct PersistentSegTree {
	struct Node {
		int l = 0, r = 0;
		int x = 0; // Set default value here
		Node() {}
		// Used for updates and propagation.
		void apply(int s, int e, int v) {
			x += v;
		}
	};
	inline Node combine(Node a, Node b) {
		Node res;
		res.x = a.x + b.x;
		return res;
	}
	int start, end;
	vector<Node> tree; // tree[0] is empty node, do not modify
	int copyNode(int id) {
		tree.push_back(tree[id]);
		return tree.size() - 1;
	}
	int build(int s, int e) {
		int sn = copyNode(0);
		if (s == e) {
			// initialize here, possibly.
			return sn;
		}
		int m = (s + e) >> 1;
		int lsn = build(s, m);
		int rsn = build(m + 1, e);
		tree[sn] = combine(tree[lsn], tree[rsn]);
		tree[sn].l = lsn;
		tree[sn].r = rsn;
		return sn;
	}
	template <typename... T>
	int update(int sn, int s, int e, int qs, int qe, const T&... v) {
		sn = copyNode(sn);
		if (qs <= s && e <= qe) {
			tree[sn].apply(s, e, v...);
			return sn;
		}
		int m = (s + e) >> 1, lsn = tree[sn].l, rsn = tree[sn].r;
		if (qs <= m) lsn = update(lsn, s, m, qs, qe, v...);
		if (qe > m) rsn = update(rsn, m + 1, e, qs, qe, v...);
		tree[sn] = combine(tree[lsn], tree[rsn]);
		tree[sn].l = lsn;
		tree[sn].r = rsn;
		return sn;
	}
	Node query(int sn, int s, int e, int qs, int qe) {
		if (!sn) return tree[sn];
		if (qs <= s && e <= qe) return tree[sn];
		int m = (s + e) >> 1, lsn = tree[sn].l, rsn = tree[sn].r;
		if (qe <= m) return query(lsn, s, m, qs, qe);
		if (qs > m) return query(rsn, m + 1, e, qs, qe);
		return combine(query(lsn, s, m, qs, qe), query(rsn, m + 1, e, qs, qe));
	}
	PersistentSegTree(int n) : PersistentSegTree(0, n - 1) {}
	PersistentSegTree(int _start, int _end, bool init = false) : start(_start), end(_end) {
		tree = {Node()};
		if (init) build(start, end);
	}
	Node query(int root, int qs, int qe) {
		return query(root, start, end, qs, qe);
	}
	Node query(int root, int p) {
		return query(root, start, end, p, p);
	}
	template <typename... T>
	int update(int root, int qs, int qe, const T&... v) {
		return update(root, start, end, qs, qe, v...);
	}
};
struct RangeDistinct {
	vector<int> tree;
	PersistentSegTree pst;
	int count(int l, int r) {
		assert(0 <= l && l <= r && r < tree.size());
		return pst.query(tree[l], l, r).x;
	}
	RangeDistinct(const vector<int>& a) : pst(a.size()), tree(a.size()) {
		assert(!a.empty());
		int n = a.size();
		map<int, int> pre;
		vector<vector<int>> ends(n);
		for (int i = 0; i < n; ++i) {
			ends[pre[a[i]]].push_back(i);
			pre[a[i]] = i + 1;
		}
		for (int i = 0; i < n; ++i) {
			tree[i] = i ? tree[i - 1] : 0;
			for (int e : ends[i]) {
				tree[i] = pst.update(tree[i], e, e, 1);
			}
		}
	}
};
int main() {
	int n, q;
	scanf("%d%d", &n, &q);
	vector<int> A(n);
	for (int i = 0; i < n; ++i) scanf("%d", &A[i]);
	RangeDistinct distinct(A);
	while (q--) {
		int l, r;
		scanf("%d%d", &l, &r);
		--l;
		--r;
		printf("%d\n", distinct.count(l, r));
	}
}


Measured memory_bytes: 242428
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn       cout<<"Yes\n"; else cout<<"No\n";
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;
const ll LINF = 1e18;


int main()
{
    int n;
    string s,t;
    cin>>n>>s>>t;
    rep(i,n) if(s.substr(i)==t.substr(0,n-i)) cout<<i+n<<endl,exit(0);
    cout<<n+n<<endl;

    return 0;
}


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

int main(){
	string S;
	cin >> S;
	if(S[0] ==  'S'){
		cout << "Cloudy" << endl;
	}else if(S[0] ==  'C'){
		cout << "Rainy" << endl;
	}else{
		cout << "Sunny" << endl;
	}
	return 0;
}

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

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  vector<int> seq;
  if (s.at(0) == '0') seq.push_back(0);
  int seq_count = 1;
  for (int i = 1; i < n; i++) {
    if (s.at(i) == s.at(i - 1)) {
      seq_count++;
    } else {
      seq.push_back(seq_count);
      seq_count = 1;
    }
  }
  seq.push_back(seq_count);
  if (seq.size() % 2 == 0) seq.push_back(0);
  int count = seq.at(0), ans;
  for (int i = 0; i < k; i++) {
    if (2 * i + 2 >= seq.size()) {
      cout << count << endl;
      return 0;
    }
    count += seq.at(2 * i + 1) + seq.at(2 * i + 2);
  }
  ans = count;
  for (int i = k; 2 * i + 2 < seq.size(); i++) {
    count += seq.at(2 * i + 1) + seq.at(2 * i + 2);
    count -= seq.at(2 * (i - k)) + seq.at(2 * (i - k) + 1);
    ans = max(ans, count);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1020
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := new(big.Int)
	b := new(big.Int)
	fmt.Sscan(getNextString(scanner), a)
	fmt.Sscan(getNextString(scanner), b)
	fmt.Fprintln(writer, a.Add(a, b))
}



Measured memory_bytes: 6440
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a,b,c;
	cin>>a>>b>>c;
	int ans = 0;
	for(int i = 0; i < n ;i++){
		if(a[i] == b[i] && b[i] == c[i])
			ans += 0;
		else if(a[i] != b[i] && a[i] != c[i] && b[i] != c[i])
			ans += 2;
		else ans += 1;
		}
	printf("%d\n",ans);	
	}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Stream;
import java.util.Arrays;
public class Main {
  public static void main (String args[]) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] colorArray = br.readLine().split(" ");
    String[] cntArray = br.readLine().split(" ");
    int[] icntArray = Stream.of(cntArray).mapToInt(Integer::parseInt).toArray();
    String rmColor = br.readLine();
    if(colorArray[0].equals(rmColor)){
      icntArray[0]-=1;
    }else if(colorArray[1].equals(rmColor)){
      icntArray[1]-=1;
    }
    System.out.print(icntArray[0] + " " + icntArray[1]);
  }
}

Measured memory_bytes: 26580
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int W = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans;
        
        if(a < b){
            ans = b - a - W;
        }else{
            ans = a - b - W;
        }
        System.out.println( ans > 0  ?  ans : 0 );
    }
}


Measured memory_bytes: 23892
#include<string>
#include<iostream>
#include<cctype>
#include<cmath>
#include<cstdio>

using namespace std;

double sum(int n,int *a){
	int i;
	double sum=0;
	for(i=0;i<n;i++){
		sum+=a[i];
		}
	return sum;
	}


int main()
{

	while(1){
		int c;
		cin >> c;
		if(c==0) break;	
		else{
		int *a;
		a=new int[c];
		int i; 
		for(i=0;i<c;i++){
			cin >> a[i];
			}
			
		double mean=sum(c,a)/c;
		int *b;
		b=new int[c];
		for(i=0;i<c;i++){
			b[i]=pow(a[i],2);
			}
		double mean2=sum(c,b)/c;
		
		printf("%lf\n",sqrt(mean2-pow(mean,2)));
		}
	}		
	return 0;
}

Measured memory_bytes: 1224
import sys

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    aa=LI()
    x=0
    for a in aa[2:]:x^=a
    t=aa[0]+aa[1]-x
    if t<0 or t&1:
        print(-1)
        exit()
    t>>=1
    #print(t)
    a0=a1=0
    for i in range(40,-1,-1):
        dt=t>>i&1
        dx=x>>i&1
        if (dt,dx)==(1,1):
            print(-1)
            exit()
        if (dt,dx)==(1,0):
            a0|=1<<i
            a1|=1<<i

    for i in range(40,-1,-1):
        dt=t>>i&1
        dx=x>>i&1
        if (dt,dx)==(0,1):
            if (a0|1<<i)<=aa[0]:a0|=1<<i
            else:a1|=1<<i

    #print(a0,a1)
    if a0>0 and a0<=aa[0]:print(aa[0]-a0)
    else:print(-1)

main()

Measured memory_bytes: 62144
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

mod = 1000000007
n, k = na()
li = na()
ct1 = 0
ct2 = 0
for i in range(n):
    for j in range(n):
        if li[i] > li[j]:
            if i < j:
                ct1 += 1
            else:
                ct2 += 1

al = ct1 + ct2
an = ((k * (k-1))//2) % mod
print((ct1 * k + al * an) % mod)





Measured memory_bytes: 42220
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;

const long long TIME_LIMIT=10000;

ll scorecalc(vector<vector<ll>> a, vector<ll> los, ll d, vector<ll> an)
{
    ll ans = 0;
    
    vector<ll> last(los.size(), 0);
    for (int i = 0; i < an.size(); i++)
    {
        ll loss = 0;
        for (int j = 0; j < 26; j++)
        {
            if (j == an[i] - 1)
                continue;

            loss += los[j] * (d - last[j]);
        }
        ans += a[i][an[i] - 1] - loss;
    }

    return ans;
}

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

    ll d;
    cin >> d;
    vector<ll> c(26);
    rep(i, 26)
    {
        cin >> c[i];
    }
    vector<vector<ll>> s(d, vector<ll>(26));
    rep(i, d)
    {
        rep(j, 26)
            cin >> s[i][j];
    }

    vector<ll> ans(d);

    vector<ll> last(26, 0);

    for (ll i = 0; i < d; i++)
    {
        ll lost = 0;
        for (int j = 0;j < 26; j++)
        {
            lost += c[j] * (i + 1 - last[j]);
        }
        ll man = s[i][0]-lost+c[0]*(i+1-last[0]);
        ll manu = 1;
        for (int j = 0; j < 26; j++)
        {
            if (man <= s[i][j]-lost+c[j]*(i+1-last[j]))
            {
                man = s[i][j] - lost + c[j] * (i + 1 - last[j]);
                manu = j + 1LL;
                last[j] = i + 1;
            }
        }
        ans[i] = manu;
    }
    ll score = scorecalc(s, c, d, ans);
    ll times = 0;
    while (times < 10000)
    {
        ll tmpD = (ll)rand() % d;
        ll tmpN = ans[tmpD];
        ans[tmpD] = (ll)rand() % 26 + 1;

        if (score >= scorecalc(s, c, d, ans))
            ans[tmpD] = tmpN;

        times++;
    }

    rep(i, d)
    {
        cout << ans[i] << endl;
    }

	return 0;

}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n,a[110];
bool ok[110];

bool find(int x,int w){
	int cnt=0;
	for(int i=0;i<n;i++){
		if(ok[i]||a[i]!=x)continue;
		ok[i]=true;
		cnt++;
		if(cnt==w)break;
	}
	if(cnt!=w)return false;
	return true;
}

void input(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	return;
}

void solve(){
	sort(a,a+n);
	int mx=a[n-1];
	if(mx%2==0){
		for(int i=mx;i>=mx/2;i--){
			if(i==mx/2){
				if(!find(i,1)){
				cout<<"Impossible"<<endl;
				return;
				}
			}
			else {
				if(!(find(i,2))){
				cout<<"Impossible"<<endl;
				return;
				}
			}
		}
		for(int i=0;i<n;i++){
			if(ok[i])continue;
			if(a[i]>mx/2&&a[i]<=mx)ok[i]=true;
			else{
				cout<<"Impossible"<<endl;
				return;
			}
		}
	}
	else{
		for(int i=mx;i>=(mx+1)/2;i--){
			if(!(find(i,2))){
				cout<<"Impossible"<<endl;
				return;
			}
		}
		for(int i=0;i<n;i++){
			if(ok[i])continue;
			if(a[i]>(mx+1)/2&&a[i]<=mx)ok[i]=true;
			else{
				cout<<"Impossible"<<endl;
				return;
			}
		}
	}
	cout<<"Possible"<<endl;
	return;
}

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

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



int main(){
    int n, k;
    cin >> n >> k;
    vector<int> have(n,0);
    for(int i=0; i<k; i++){
        int d;
        cin >> d;
        rep(j,d){
            int temp;
            cin >> temp;
            have[temp-1] = 1;
        }
    }
    int res=0;
    for(int i=0; i<n; i++){
        if(have[i] == 0) res ++;
    }
    cout << res << endl;


   

}

Measured memory_bytes: 3616
n = int(input())
l = list(map(int, input().split()))

sum_length = 0
max_index = l.index(max(l))
for i in range(n):
    if i == max_index:
        continue
    sum_length += l[i]
if sum_length > l[max_index]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

s = input()

print("x" * len(s))

Measured memory_bytes: 38256
from heapq import heappush, heappop
N,*A = map(int, open(0).read().split())
F = []
fs = 0
ss = 0
P = []
state = [0]*(3*N)
for i in range(N):
  heappush(F,A[i])
  fs += A[i]
ls = sorted(range(N,3*N),key=lambda x:A[x])
for i in range(N):
  state[ls[i]] = 1
  ss += A[ls[i]]
for i in range(N,2*N):
  state[ls[i]] = 2
  heappush(P,(A[ls[i]],ls[i]))
ans = fs-ss
for i in range(N,2*N):
  n = heappop(F)
  fs = fs-n+A[i]
  heappush(F,A[i])
  if state[i]==1:
    while state[P[0][1]]==0:
      heappop(P)
    p,j = heappop(P)
    ss += -A[i]+p
    state[j] = 1
  state[i] = 0
  ans = max(ans,fs-ss)
print(ans)

Measured memory_bytes: 39828
#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main(){
  string z;
  vector<char> x(10);
  cin>>z;
  int l=z.length(),p=0,j;
  for(j=0;j<l;j++){
    if(z[j]!='B'){
      x[p]=z[j];
      p++;
    }
    else if(p>0){
      x[p]=0;
      p--;
    }
  }
  for(j=0;j<p;j++) cout<<x[j];
  cout<<endl;
}

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

int main()
{
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    int dp[3][n];
    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];
    for(int i=1;i<n;i++){
        dp[0][i] = a[i] + max( dp[1][i-1],dp[2][i-1] );
        dp[1][i] = b[i] + max( dp[0][i-1],dp[2][i-1] );
        dp[2][i] = c[i] + max( dp[0][i-1],dp[1][i-1] );
    }
    cout<<max(max(dp[0][n-1], dp[1][n-1]), dp[2][n-1])<<"\n";
    return 0;
}


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

int main(){
  string s,t;
  cin >> s >> t;
  
  int n = t.size(),m = s.size();
  int cnt = n;
  for(int i=0;i<=m-n;i++){
    int k = 0;
    for(int j=0;j<n;j++){
      if(t.at(j) != s.at(i+j)) k++;
    }
    cnt = min(cnt,k);
  }
  
  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 3588