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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n, x = 0;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        x ^= a[i];
    }
    rep(i, n - 1) {
        cout << (x ^ a[i]) << " ";
    }
    cout << (x ^ a[n - 1]) << endl;
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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


Measured memory_bytes: 4048
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

vector<bool> calc(string a, string b){
  vector<bool> ret(8001);
  for(int i=0;i<=8000;i++){
    string tmp(8001, '?');
    ll num = i - 4000;
    bool f = true;
    if(num<0) {
      ll of = abs(num);
      for(int j=0;j<b.size();j++) tmp[j] = b[j];
      for(int j=0;j<a.size();j++){
        if(a[j]=='?'||tmp[j+of]=='?') continue;
        else if(a[j]!=tmp[j+of]){
          f = false;
          break;
        }
      }
    }else{
      ll of = abs(num);
      for(int j=0;j<a.size();j++) tmp[j] = a[j];
      for(int j=0;j<b.size();j++){
        if(b[j]=='?'||tmp[j+of]=='?') continue;
        else if(b[j]!=tmp[j+of]){
          f = false;
          break;
        }
      }
    }
    ret[i] = f;
  }
  return ret;
}

//-------------------------------------------------------------------
#include <sstream>
#include <fstream>
ifstream ifs;
void init(string s){ifs.open(s);}
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while(getline(ss, buffer, sep)) v.push_back(buffer);
    return v;
}
ll read(){
  string str;
  getline(ifs, str);
  return stoll(str);
}
string read_str(){
  string str;
  getline(ifs, str);
  return str;
}
vector<ll> read_vec(){
  string str;
  getline(ifs, str);
  std::vector<ll> num;
  vector<string> data = split(str, ' ');
  for(int i=0;i<data.size();i++) num.push_back(stoll(data[i]));
  return num;
}
vvl read_mat(ll h){
  string str;
  vvl num = VV(h, 0, 0, ll);
  for(int i=0;i<h;i++){
    getline(ifs, str);
    vector<string> data = split(str, ' ');
    for(int j=0;j<data.size();j++) num[i].push_back(stoll(data[j]));
  }
  return num;
}
//-------------------------------------------------------------------

int main(int argc, char const *argv[]) {
  string a, b, c;
  /*
  init("1.in");
  a = read_str();
  b = read_str();
  c = read_str();
  */
  std::cin >> a;
  std::cin >> b;
  std::cin >> c;

  vector<bool> ab = calc(a, b);
  vector<bool> ac = calc(a, c);
  vector<bool> bc = calc(b, c);
  int as = a.size(), bs = b.size(), cs = c.size();
  int ans = 100000000;

  for(int l=0;l<=8000;l++){
    for(int r=0;r<=8000;r++){
      if(ab[l]&&ac[r]&&(abs(r-l)>4000||bc[r-l+4000])){
        int lef_idx = min({l - 4000, r-4000, 0});
        int ri_idx = max({as-1, l-4000+bs-1, r-4000+cs-1});

        if(ans > ri_idx-lef_idx+1){
          //std::cout << ri_idx-lef_idx+1 << " " << l << " " << r << " " << lef_idx << " " << ri_idx << '\n';
          ans = min(ans, ri_idx-lef_idx+1);
        }
      }
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 504
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int main() {
    int a[3];
    int cnt1=0,cnt2=0;
    while(~scanf("%d,%d,%d",&a[0],&a[1],&a[2])) {
        if(a[2]*a[2]==a[0]*a[0]+a[1]*a[1]) cnt1++;
        if(a[0] == a[1] ) cnt2++;
    }
    cout<<cnt1<<endl;
    cout<<cnt2<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;

ll DP[110][100100];

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i,N){
        int a;
        cin >> a;
        A[i] = a;
    }

    REP(i,110){
        REP(j,100100){
            DP[i][j] = 0;
        }
    }

    DP[0][0] = 1;

    REP(i,N){
        int a = A[i];
        ll sum = 0;
        REP(j,K+1){
            sum += DP[i][j];
            sum %= MOD;
            DP[i+1][j] = sum;
            DP[i+1][j] %= MOD;
            if(j - a >= 0){
                sum -= DP[i][j-a];
                sum += MOD;
                sum %= MOD;
            }
        }
    }

    ll ans = DP[N][K] % MOD;

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


Measured memory_bytes: 86272
main = do
    s <- getLine
    putStrLn $ toTime (read s :: Int) 2

toTime :: Int -> Int -> String
toTime s 0 = show s
toTime s n = show divSecond ++ ":" ++ toTime modSecond (n-1)
    where divSecond  = s `div` (60 ^ n)
          modSecond  = s `mod` (60 ^ n)


Measured memory_bytes: 3648
use std::collections::HashMap;
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let N = read_line().parse::<i64>().unwrap();
    let mut S:Vec<String> = Vec::new();
    for i in 0..N {
        S.push(read_line());
    }

    let mut count:HashMap<&String,i64> = HashMap::new();

    for word in S.iter() {
        let counter =  count.entry(word).or_insert(0);
        *counter+=1;
    }

    let max = count.values().max().unwrap();
    let mut max_word:Vec<&String> = count.iter()
                                            .filter(|&(key,item)| *item == *max)
                                            .map(|(key,item)|*key)
                                            .collect();
    max_word.sort();
    for i in max_word.iter() {
        println!("{}",i);
    }
}

Measured memory_bytes: 24464
# include<bits/stdc++.h>
# define ll long long
# define fo(i,n)for(int i=0;i<n;i++)
# define fo1(i,n)for(int i=1;i<=n;i++)
# define pb push_back
# define endl "\n"
# define mod 1000000007ll
# define pi  3.1415926535897932384626
using namespace std;

vector<vector<long long>>adj(100005);
vector<long long >vis(100005,0);

void bfs(int i)
{
  queue<int>q;
  q.push(i); 

  if(!vis[i])
  {
    vis[i]=1;
    while(!q.empty())
   {
      int u=q.front();
      q.pop();         
     for(auto a:adj[u]) 
     {
       if(!vis[a])
       {
         vis[a]=1;
         q.push(a);
       }
     }
   }
  }
}
void solve()
{
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=m;i++)
  {
    int x,y;
    cin>>x>>y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  int cnt=0;
   for(int i=1;i<=n;i++)
   {
     if(!vis[i])
     {
       cnt++;
       bfs(i);
     }
   }
   cout<<cnt-1;
}
int main()
{
 # ifndef ONLINE_JUDGE
   freopen("input1.txt","r",stdin);
   freopen("output1.txt","w",stdout);
 #endif
    ios::sync_with_stdio(0);
    cin.tie(0);

    solve();
    cout<<endl;
    return 0;
}

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

int main()
{
    int t1, t2, t3, temp;
    cin >> t1 >> t2 >> t3;
    temp = t1;
    t1 = t2;
    t2 = temp;
    temp = 0;
    temp = t1;
    t1 = t3;
    t3 = temp;
    cout << t1 << " " << t2 << " " << t3 << endl;
}


Measured memory_bytes: 256
from heapq import heappush,heappop,heapify

n,k = map(int,input().split())

# とりあえずネタは無視しておいしさが大きい寿司からk個を選び(hq)、満足ポイントを計算する。
# それに選ばれなかった寿司から、選ばれた寿司のネタにはないネタで、かつ、
# そのネタの中でおいしさが最大のものを選んでおく(rhq)。
# hqのうち、hqのネタ種類数が減らなように選んだおいしさが最小のものと、
# rhqのうちおいしさが最大のものを入れ替えて、満足ポイントを計算する。
# (こうすると、おいしさの合計は減るがネタの種類数は増える。)
# これを繰り返して、最大の満足ポイントを出力する。

td = []
for i in range(n):
  td.append(tuple(map(int,input().split())))
td.sort(key = lambda x:(x[0],-x[1]))

tf = [False for _ in range(n)]
s = []
for t,d in td:
  t -= 1
  if tf[t]:
    s.append((0,d)) #そのネタの中でおいしさ最大でないもの
  else:
    s.append((1,d)) #そのネタの中でおいしさ最大のもの
    tf[t] = True

s.sort(key = lambda x:-x[1])
#print(s)
hq = s[:k]
heapify(hq)

rhq = []
for t,d in s[k:]:
  if t == 1:
    rhq.append(-d)
heapify(rhq)

ans = 0
tsum = 0
dsum = 0
for t,d in hq:
  tsum += t
  dsum += d
ans = dsum+tsum**2

while(True):
  t,d = heappop(hq)
  if t == 1:
    break
  if len(rhq) == 0:
    break
  newd = heappop(rhq)
  dsum += -newd-d
  tsum += 1
  ans = max(dsum+tsum**2,ans)
print(ans)


Measured memory_bytes: 99032
#include<bits/stdc++.h>
using namespace std;
bool com(int x,int y)
{
    return x>y;
}
int main()
{
    long long  ch[100010],n;
    scanf("%lld",&n);
    for(int i=0;i<n;i++)
        scanf("%lld",&ch[i]);
    sort(ch,ch+n,com);
    long long  flag1=0,flag2=0;
    for(int i=0;i<n-1;)
    {
        if(flag1==0&&ch[i]==ch[i+1])
            flag1=ch[i],i+=2;
        else if(flag1!=0&&flag2==0&&ch[i]==ch[i+1])
            flag2=ch[i],i+=2;
        else if(ch[i]!=ch[i+1])
            i++;
        else if(flag1&&flag2)
            break;
    }
    if(flag1!=0&&flag2!=0)
        printf("%lld\n",flag1*flag2);
    else
        printf("0\n");
    return 0;
}


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

int main() {
  int s,w;
  cin >> s >> w;
  if(s <= w) cout << "unsafe" << endl;
  else cout << "safe" << endl;
}

Measured memory_bytes: 3672
#include<stdio.h>
int main(void){
	int n;
	long long int ban[4001],tan,suu;
	long long int bansum[4001],banf[4001],i;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=1;i<=4000;i++){
			bansum[i]=banf[i]=0;
		}
		for(i=0;i<n;i++){
			scanf("%ld %ld %ld",&ban[i],&tan,&suu);
			bansum[ban[i]]+=tan*suu;
		}
		int flg=0;
		for(i=0;i<n;i++){
			if(bansum[ban[i]]>=1000000 && banf[ban[i]]==0){
				printf("%d\n",ban[i]);
				banf[ban[i]]=1;
				flg=1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1112
y, m, d = map(int, input().split("/"))
if y < 2019:
  print("Heisei")
elif y == 2019 and m < 4:
  print("Heisei")
elif y == 2019 and m == 4 and d <=30:
  print("Heisei")
else:
  print("TBD")

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int dp[100001],h[100001],n,k;
int ABS(int x)
{
	return max(x,-x);
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);
	}
	memset(dp,0x3f3f3f3f,sizeof(dp));
	dp[1]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=min(n,i+k);j++)
		{
			dp[j]=min(dp[j],dp[i]+ABS(h[j]-h[i]));
		}
	}
	printf("%d",dp[n]);
	return 0;
}


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

int main(){
    int N, T, A;
    cin >> N >> T >> A;

    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H.at(i);
    }

    //答えとなる地点でのAとの差
    int ans_dif = 1000000;
    //求める地点
    int ans = 0;

    //各地点の温度
    vector<int> tmp(N);
    for (int i =0; i < N; i++) {
        tmp.at(i) = T * 1000 - H.at(i) * 6;
        int dif = abs(tmp.at(i) - A * 1000);
        if (dif < ans_dif){
            ans_dif = dif;
            ans = i + 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;

namespace ITP1_8_B
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            while (true)
            {
                string x = Console.ReadLine();
                if (x == "0")
                    break;
                int sum = 0;
                foreach (var n in x)
                {
                    sum += int.Parse(n.ToString());
                }
                sb.AppendLine(sum.ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9184
using System;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();
        if (b - a == c - b)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 11092
import Foundation

let n = readLine()!
let sum = n.reduce(0, { res, char in res + char.wholeNumberValue! })
print(sum.isMultiple(of: 9) ? "Yes" : "No")










// MARK: ----------------------------------------------------------------------


func readInt() -> Int {
    Int(readLine()!)!
}

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func tuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func tuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func tuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
    
    func safe(at index: Index) -> Element? {
        self.indices.contains(index) ? self[index] : nil
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating _read {
            if let note = dictionary[argument] {
                yield note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                yield result
            }
        }
    }
}

extension Dictionary {
    init(_ initialize: (inout Self) -> ()) {
        var dictionary = Self()
        initialize(&dictionary)
        self = dictionary
    }
}


extension Int {
    var abs: Int {
        self < .zero ? -self : self
    }
}


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

int main()
{
	int h, w;
	char s[51][51] = {0};

	std::cin >> h >> w;
	for(int i = 0; i < h; i++) std::cin >> s[i];

	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(s[i][j] == '.'){
				int count = 0;
				if(i == 0){
					if(j == 0){
						if(s[i][j+1] == '#') count++;
						if(s[i+1][j+1] == '#')count++;
						if(s[i+1][j] == '#')count++;
					}else if(j == w-1){
						if(s[i][j-1] == '#') count++;
						if(s[i+1][j-1] == '#') count++;
						if(s[i+1][j] == '#') count++;
					}else{
						if(s[i][j+1] == '#') count++;
						if(s[i+1][j+1] == '#')count++;
						if(s[i][j-1] == '#') count++;
						if(s[i+1][j-1] == '#') count++;
						if(s[i+1][j] == '#') count++;
					}
				}else if(i == h-1){
					if(j == 0){
						if(s[i][j+1] == '#') count++;
						if(s[i-1][j+1] == '#')count++;
						if(s[i-1][j] == '#')count++;
					}else if(j == w-1){
						if(s[i][j-1] == '#') count++;
						if(s[i-1][j-1] == '#') count++;
						if(s[i-1][j] == '#') count++;
					}else{
						if(s[i][j+1] == '#') count++;
						if(s[i-1][j+1] == '#')count++;
						if(s[i][j-1] == '#') count++;
						if(s[i-1][j-1] == '#') count++;
						if(s[i-1][j] == '#') count++;
					}
				}else{
					if(j == 0){
						if(s[i-1][j+1] == '#') count++;
						if(s[i-1][j] == '#') count++;
						if(s[i][j+1] == '#') count++;
						if(s[i+1][j+1] == '#') count++;
						if(s[i+1][j] == '#') count++;
					}else if(j == w-1){
						if(s[i-1][j-1] == '#') count++;
						if(s[i-1][j] == '#') count++;
						if(s[i][j-1] == '#') count++;
						if(s[i+1][j-1] == '#') count++;
						if(s[i+1][j] == '#') count++;
					}else{
						if(s[i-1][j-1] == '#') count++;
						if(s[i][j-1] == '#') count++;
						if(s[i+1][j-1] == '#') count++;
						if(s[i-1][j+1] == '#') count++;
						if(s[i-1][j] == '#') count++;
						if(s[i][j+1] == '#') count++;
						if(s[i+1][j+1] == '#') count++;
						if(s[i+1][j] == '#') count++;
					}
				}
				s[i][j] = '0' + count;
			}
		}
	}

	for(int i =0 ; i < h; i++)std::cout << s[i] << std::endl;

  	return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define pf push_front
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
int M,K;
deque <int> ans;

bool vis[300001];

int ans1[6] = {3,1,3,2,1,2};

int main(){
	fast;
  	cin>>M>>K;
	
	if (K > (1<<M) - 1){
		cout<<-1;
		return 0;
	}
	
	if (ceil(log2(K)) == floor(log2(K)) && K != 0){
		if (K+1 > (1<<M) - 1){
			cout<<-1;
			return 0;
		}
		
		if (K == 1){
			if (3 > (1<<M) - 1){
				cout<<-1;
				return 0;
			}
			ans.pb(K); ans.pb(3); ans.pf(3); ans.pb(2); ans.pf(2);
			vis[3] = vis[2] = vis[1] = 1;
		}else{
			ans.pb(K); ans.pb(K+1); ans.pf(K+1); ans.pb(1); ans.pf(1);
			vis[K] = vis[K+1] = vis[1] =  1;
		}
		
		FOR(i,0,(1<<M) - 1){
			if (!vis[i]) ans.pb(i), ans.pf(i);
		}
		
		ans.pb(K);
		while (!ans.empty()) cout<<ans.front()<<' ', ans.pop_front();
		return 0;
		
	}
	
	if (K == 0){
		FOR(i,0,(1<<M) - 1) ans.pb(i),ans.pf(i);
		
		while (!ans.empty()) cout<<ans.front()<<' ',ans.pop_front();
		return 0;
	}
	ans.pb(K);
	
	vis[K] = 1;
	FOR(i,0,M){
		if (K & (1<<i)){
			ans.pb((1<<i));
			ans.pf((1<<i));
			vis[(1<<i)] = 1;
		}
	}
	
	
	
	
	FOR(i,0,(1<<M)-1){
		if (!vis[i]){
			ans.pb(i);
			ans.pf(i);
		}
	}
	ans.pb(K);
	
	while (!ans.empty()){
		cout<<ans.front()<<' ';
		ans.pop_front();
	}
	
}
      	
	




Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cout<<fixed<<setprecision(7);
	
	bool flag = false;
	string s, k;
	
	k = "keyence";
	
	cin>>s;
	
	// if(s == k) flag = true;
	
	for(int i = 0; i < s.size(); i++){
		for(int j = 0; j < s.size(); j++){
			string tt = s;
			tt.erase(i,j);
			// cout<<i<<" "<<j<<" "<<tt<<endl;
			if(tt == k) flag = true;
		}
	}
	
	cout<<YN(flag)<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
n=int(input())

c=input()

w=[]
r=[]

for i,color in enumerate(c):
    if color=="W":
        w.append(i)
    else:
        r.append(i)
# print(w)
# print(r)
w=w[::-1]

ans=0

def finish(w,r):
    if w==[] or r==[]:
        return True
    elif w.pop()>r.pop():
        return True
    return False
    

while not finish(w,r):
    ans+=1

print(ans)
    

Measured memory_bytes: 18692
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int count[5] = { 0 };
	string S;
	cin >> S;
	for (int i = 0; i < 3; i++) {
		count[S[i] - 'a']++;
	}
	for (int i = 0; i <=2; i++) {
		if (count[i] != 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math


def solve(A: int, B: int):
    ans = 0
    if(A > B):
        ans += A
        A = A-1
    else:
        ans += B
        B = B-1

    if(A > B):
        ans += A
    else:
        ans += B

    print(ans)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-07-25 21:03:41 +0900
# LastModified: 2020-07-25 21:11:58 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    a, b, c = map(int, input().split())
    k = int(input())
    for _ in range(k):
        if a >= b:
            b = 2*b
        elif b >= c:
            c = 2*c
        if a < b and b < c:
            print("Yes")
            return
    print("No")
        


if __name__ == "__main__":
    main()


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
// C - Rally / 

int main(){
    int N; cin >> N;
    
    vector<int>X(N); 
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> X.at(i);
        sum += X.at(i);
    }
    
    int av1,av2;

    av1 = sum/N;
    av2 = (sum+N)/N;

    int sum1 = 0;
    int sum2 = 0;

    for (int i = 0; i < N; i++)
    {
        sum1 += (X.at(i) - av1)*(X.at(i) - av1);
        sum2 += (X.at(i) - av2)*(X.at(i) - av2);

    }
     
    cout << min(sum1,sum2) <<endl;
    
    

}

Measured memory_bytes: 256
#include <iostream>

void fastin(int &num) {
    bool neg = false;
    int c;
    num = 0;
    c = getchar();
    if (c == '-') {
        neg = true;
        c = getchar();
    }
    for (; (c > 47 && c < 58); c = getchar()) num = num * 10 + c - 48;
    if (neg) num *= -1;
}

void fastout(int n) {
    int N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar('0'); putchar('\n'); return ;}
    while ((rev % 10) == 0) { ++count; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar('0');
}

int main(){
    int n, m, Q; fastin(n); fastin(m); fastin(Q);
    int l[m], r[m];
    for (int i = 0; i < m; ++i){fastin(l[i]); fastin(r[i]);}
    int p[Q], q[Q];
    for (int i = 0; i < Q; ++i) {fastin(p[i]); fastin(q[i]);}

    int square[n + 5][n + 5] = {};
    for (int i = 0; i < m; ++i){
        ++square[l[i]][r[i]];
    }
    int s[n + 5][n + 5] = {};

    for (int i = 1; i <= n; ++i){
        s[i][1] = square[i][1];
    }

    for (int i = 1; i <= n; ++i){
        for (int j = 2; j <= n; ++j){
            s[i][j] = s[i][j - 1] + square[i][j];
        }
    }

    for (int i = 0; i < Q; ++i){
        int sum = 0;
        for (int j = p[i]; j <= q[i]; ++j){
            sum += s[j][q[i]] - s[j][p[i] - 1];
        }
        fastout(sum); putchar_unlocked('\n');
    }
    
    return 0;
}

Measured memory_bytes: 5248
n=int(input())
a=list(map(int,input().split()))
mul=1
if a.count(0)>=1:
    print(0)
if a.count(0)==0:
    for i in range(len(a)):
        mul=mul*a[i]
        if mul>10**18:
            break
    
    if mul>10**18:
        print(-1)
    if mul<=10**18:
        print(mul)

Measured memory_bytes: 21616
#include <bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    int N; cin >> N; vector<int> s(N);
    for(int i = 0; i < N; i++){cin >> s[i];}
    auto check = [&](const int d){
        for(int i = 0; i < d; i++){
            for(int j = i; j < N; j+= d){if(s[j]!=s[i]){return false;}}
        }  
        return true;
    };
    deque<int> D1,D2;
    for(int d = 1; d*d <= N; d++){
        if(N % d > 0){continue;}
        D1.push_back(d);D2.push_front(N/d);
    }
    for(const int d:D1){if(check(d)){return (cout << N/d << endl),0;}}
    for(const int d:D2){if(check(d)){return (cout << N/d << endl),0;}}
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
typedef struct{
	int face[7];
}cube;
int rotation(char direction,cube *C){
	int temp;
	//cube C;
	switch(direction){
		case 'N':
			temp=C->face[4];
			C->face[4]=C->face[0];
			C->face[0]=C->face[1];
			C->face[1]=C->face[5];
			C->face[5]=temp;
		break;
		case 'E':
			temp=C->face[3];
			C->face[3]=C->face[5];
			C->face[5]=C->face[2];
			C->face[2]=C->face[0];
			C->face[0]=temp;
		break;
		case 'S':
			temp=C->face[0];
			C->face[0]=C->face[4];
			C->face[4]=C->face[5];
			C->face[5]=C->face[1];	
			C->face[1]=temp;//printf("S\n");
		break;
		case 'W':
			temp=C->face[0];
			C->face[0]=C->face[2];
			C->face[2]=C->face[5];
			C->face[5]=C->face[3];
			C->face[3]=temp;
		break;
		case 'R':
			temp=C->face[3];
			C->face[3]=C->face[4];
			C->face[4]=C->face[2];
			C->face[2]=C->face[1];
			C->face[1]=temp;
		break;
		case 'L':
			temp=C->face[3];
			C->face[3]=C->face[1];
			C->face[1]=C->face[2];
			C->face[2]=C->face[4];
			C->face[4]=temp;
		default :
		break;
	}
	return 1;
}
int main(void) {
	cube C1;
	cube C2;
	int roll[4];
	for(int i=0;i<6;i++)scanf("%d",&C1.face[i]);
	for(int i=0;i<6;i++)scanf("%d",&C2.face[i]);
	for(int i=0;i<6;i++){
		for(int j=0;j<4;j++){
			for(int k=0;k<6;k++){
				if(C1.face[k] != C2.face[k]){
					break;
				}else if(k==5){
					printf("Yes\n");
					i=100;
					j=100;
				}
			}
			rotation('R',&C2);
		}
		rotation((i%2)?'R':'L',&C2);
		rotation('N',&C2);
		if(i==5)printf("No\n");
	}
	return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define ll long long int
#define dbl double
#define pi acos(-1)
#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pb push_back
#define mxx 100000
map<string,ll>mp,mp2;
map<ll,ll>vis1;
map<ll,ll>vis;
map<ll,ll>vis_s;
map<pair<ll,ll>,ll>vis2;
priority_queue<ll>pq;
priority_queue<ll>pq2;
vector<ll>vec;
vector<ll>vec_s;
vector<ll>vec1;
map<vector<ll>,ll>mp3;
ll ara[1000006],ara1[1000006];


ll dx[]= {-1,0,+1,-1,+1,-1,0,+1};
ll dy[]= {-1,-1,-1,0,0,+1,+1,+1};
string v="aeiou";
ll n,m,t,cnt=0,a,b,c=0,no,d,sum=0,ans=0,item,mx=0,mn=10000000;

int main()
{
    sc2(n,m);
    for(ll i=0;i<=n;i++){
        ll no=i*2+(n-i)*4;
        if(no==m){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3764
def main():
    NOTFOUND = True
    maisu,money = map(int, input().split())
    for ichiman in range(maisu+1):
        if not NOTFOUND :
            break
        for gosen in range(maisu+1 - ichiman):
            sen = maisu - ichiman - gosen
            current_money = ichiman*10000 + gosen*5000 + sen*1000
            if current_money == money:
                print(ichiman,gosen,sen)
                NOTFOUND = False
                break
    if NOTFOUND :
        print(-1,-1,-1)

if __name__ == '__main__' :
    main()


Measured memory_bytes: 3064
(let* ((n (read))
       (lst (loop :repeat n :collect (read)))
       (lst-t (mapcar (lambda (a b) (= a (1- b))) lst (cdr lst)))
       (lst-a (loop :repeat n :collect (read)))
       (lst-b (loop :repeat (1- n) :collect (read))))
  (princ (+ (reduce #'+ lst-a)
            (loop :for k :from 0 :upto (1- n) :sum (if (nth k lst-t)
                                                       (nth (1- (nth k lst)) lst-b)
                                                       0)))))

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

int main() {
  long long N,M;
  cin >> N >> M;
  vector<long long> A(N),B(N);
  for (long long i=0;i<N;i++) {
    cin >> A[i] >> B[i];
  }
  
  vector<pair<long long, long long>> AB(N);
  for (long long i=0;i<N;i++) {
    AB[i] = make_pair(A[i],B[i]);
  }
  sort(AB.begin(),AB.end());
  
  long long ans=0,sum=0;
  for (long long i=0;i<N;i++) {
    if (M >= sum + AB[i].second) {
      ans += AB[i].first*AB[i].second;
      sum += AB[i].second;
    }
    else {
      ans += AB[i].first*(M-sum);
      break;
    }
  }
  
  cout << ans << endl;
}

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

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


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N = i_i()
A = i_l()
B = i_l()

ans = 0
for i in range(len(B)):
    if A[i] >= B[i]:
        ans += B[i]
        A[i] -= B[i]
        B[i] = 0
    else:
        ans += A[i]
        B[i] = B[i] - A[i]
        A[i] = 0
        if A[i+1] >= B[i]:
            ans += B[i]
            A[i+1] = A[i+1] - B[i]
            B[i] = 0
        else:
            ans += A[i+1]
            B[i] = B[i] - A[i+1]
            A[i+1] = 0

print(ans)


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;

int main() {
  int N; cin >> N;
  vector<int> A(N); rep(i, N) cin >> A[i];
  
  map<int, int> mp;
  rep(i, N) {
    mp[A[i]-1]++;
    mp[A[i]]++;
    mp[A[i]+1]++;
  }
  int cnt=0;
  int X;
  for(auto i=mp.begin(); i!=mp.end(); ++i) {
    if(cnt<i->second) {
      cnt = i->second;
      X = i->first;
    }
  }
  
  int ans=0;
  rep(i, N) {
    if ((A[i] - 1) == X || (A[i] + 1) == X || A[i] == X) ans++;
  }
  dump(ans);
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long num_size(long long X){
  int ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}
int main() {
  
  int N,T;
  cin>>N>>T;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  
  long long ans=T;
  
  for(int i=0;i<N-1;i++){
    if(vec[i+1]-vec[i]>T){
      ans+=T;
    }
    else{
      ans+=(vec[i+1]-vec[i]);
    }
  }
  
  cout<<ans<<endl;
}

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

int main()
{
	int n, a[99999], m, sum = 0;
	vector<pair<int, int>> v;
	cin >> n;

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

	cin >> m;
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		pair<int, int> p = make_pair(a, b);
		v.push_back(p);
	}

	for(int i = 0; i < m; i ++){
		cout << sum - a[v[i].first-1] + v[i].second << '\n';
	}

}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	long int i,x,j,n;
	n=s.size();
	n=n-2;
for(j=0;;j++)
	{
		x=0;
		for(i=0;i<n/2;i++)
		{	
		if(s[i]==s[(n/2)+i])
		{
			x++;	
		}
		}
		if(x==n/2)
		{
			cout<<x*2<<endl;
			return 0;
		}
		else
		{
			n=n-2;
		}
	}
	
	
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define mod 1000000007
using namespace std;
int n,a[100010];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        memset(a,0,sizeof(a));
        for(int i=2;i<=n;i++)
        {
            int num=i;
            for(int j=2;j<=num;j++)
            {
                while(num%j==0)
                {
                    a[j]++;
                    num/=j;
                }
            }
        }
        long long int flag=1;
        for(int i=1;i<=n;i++)
        {
            if(a[i])
            {
                flag=(flag*(a[i]+1))%mod;
            }
        }
        printf("%lld\n",flag);
    }
    return 0;
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

void print_vec(vector<int> vec) {
  cout << "[";
  for (int i = 0; i < vec.size(); i++) {
    if (i) {
      cout << ", ";
    }
    cout << vec.at(i);
  }
  cout << "]...size: " << vec.size() << endl;
}

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) { cin >> v[i]; }
  int count = 0;

  rep(i, n) {
    int minj = i;

    for (int j = i; j < n; j++) {
      if (v[j] < v[minj]) {
        minj = j;
      }
    }

    if (i != minj) {
      count++;
    }

    swap(v[i], v[minj]);
  }

  rep(i, n) {
    if (i) {
      printf(" ");
    }
    printf("%d", v[i]);
  }

  printf("\n%d\n", count);
}



Measured memory_bytes: 3232
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;

int main() {
	ll N, ans = 0;
	cin >> N;
	rep(i, N+1) {
		if (i % 3 != 0 && i % 5 != 0) ans += i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <string>

using namespace std;

int main(){
  char A[100]={},B[100]={},C[100]={};
  char tmp,x;
  int ai=0,bi=0,ci=0;

  scanf("%s %s %s",&A,&B,&C);

  tmp=A[0];
  ai++;
  if(tmp=='\0'){printf("A"); return 0;}

  for(;;){
    if(tmp=='a'){
     tmp=A[ai];   ai++; x='A';
    }else if(tmp=='b'){
      tmp=B[bi]; bi++; x='B';
    }else{
     tmp=C[ci];   ci++; x='C';
    }

    if(tmp=='\0') break;
  }
  printf("%c\n",x);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N;cin>>N;
    vector<ll> a(N),b(N);
    REP(i,N)cin>>a[i]>>b[i];
    ll res=0;
    for(int i=N-1;i>=0;i--){
        if((a[i]+res)%b[i]==0)continue;
        else{
            res+=b[i]-(a[i]+res)%b[i];
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <complex>
#include <algorithm>

using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;

#define int i64

template<class T>
inline bool chmin(T &a, T b) { if(a > b) {a = b; return true;} return false; }
template <class T>
inline bool chmax(T &a, T b) { if(a < b) {a = b; return true;} return false; }
const int INF = 1LL << 60;

signed main() {
	int n;
	string s;
	cin >> n;
	cin >> s;

	for(int i = 0; i < s.size(); i++) {
		char ch = s[i];
		ch += n;
		if(ch > 'Z') ch -= 26;
		s[i] = ch;
	}

	cout << s << endl;
	
	return 0;
}


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

int main(void){
    int c1, c5, c10, c50, c100, c500, x;
    cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
    x = c1 + c5*5 + c10*10 + c50*50 + c100*100 + c500*500;
    if(x >= 1000){
        cout << "1" << endl;
    }
    else {
        cout << "0" << endl;
    }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{
	int h,w,n,a;
	vector<int>v;
	cin>>h>>w;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		for(int j=0;j<a;j++)
		{
			v.push_back(i);
		}
	}
	for(int i=1;i<=h;i++)
	{
		if((i-1)%2)
		{	
			for(int j=w*i-1;j>=w*(i-1);j--)
			{
				if(j==w*i-1)cout<<v[j];
				else cout<<" "<<v[j];
			}
		}	
		else
		{	
			for(int j=w*(i-1);j<w*i;j++)
			{
				if(j==w*(i-1))cout<<v[j];
				else cout<<" "<<v[j];
			}
		}
		cout<<endl;
	}
	return 0;
}

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


int main(){
    string a,b;
    cin>>a>>b;

    string s = a+b;

    int n = stoi( s );

    for( int i=0; i<1000; ++i ){
        if( i*i == n ){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

}

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

int main(int argc, char const *argv[])
{
	int a,b;
	cin>>a>>b;
	int ans=0;
	for (int i = a; i <= b; ++i)
	{
		int now=i,d[5];
		for (int j = 0; j < 5; ++j)
		{
			d[j]=now%10;
			now/=10;
		}
		if (d[0]==d[4]&&d[1]==d[3])
		{
			++ans;
		}
	}	
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
    int d, n;
    cin >> d >> n;
    int ans = 0;
    if (d == 0)
    {
        if (n == 100)
            ans = n + 1;
        else
            ans = n;
    }
    if (d == 1)
    {
        if (n == 100)
            ans = n * 100 + 100;
        else
            ans = n * 100;
    }
    if (d == 2)
    {
        if (n == 100)
            ans = n * 10000 + 10000;
        else
            ans = n * 10000;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
const int maxn = 1e5+10;

int n;
int niz[maxn][10];
int dp[maxn][10];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) 
		for (int j = 0; j < 3; j++)
			scanf("%d", &niz[i][j]);
		
	for (int i = 0; i < 3; i++) dp[0][i] = niz[0][i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) 
				if (j != k) dp[i][j] = max(dp[i][j], dp[i - 1][k] + niz[i][j]);
		}
	}
	
	printf("%d", max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]));
	return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<math.h>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int maxn = 1e5+5;
int fa[maxn];
struct Node{
  ll x, y, id;
}st[maxn];
 
struct Edge{
  ll cost, p1, p2;
}edge[maxn*2];
 
int cmp1(Node a,Node b){ 
	return a.x<b.x; 
}
int cmp2(Node a,Node b){ 
	return a.y<b.y; 
}
int cmp3(Edge a,Edge b){ 
	return a.cost<b.cost; 
}
 
int find(int u){
  	if(fa[u]==u) 
  		return fa[u];
  	return fa[u]=find(fa[u]);
}
 
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
		scanf("%lld%lld", &st[i].x, &st[i].y); 
		st[i].id=i; 
		fa[i]=i;
	}
    sort(st+1,st+1+n,cmp1);
    int cnt=0;
    for(int i=2;i<=n;i++){
        edge[++cnt].p1=st[i-1].id;
        edge[cnt].p2=st[i].id;
        edge[cnt].cost=st[i].x-st[i-1].x;
    }
    sort(st+1,st+1+n,cmp2);
    for(int i=2;i<=n;i++){
        edge[++cnt].p1=st[i-1].id;
        edge[cnt].p2=st[i].id;
        edge[cnt].cost=st[i].y-st[i-1].y;
    }
    sort(edge+1,edge+1+cnt,cmp3);
    ll ans=0;int num=0;
    for(int i=1;i<=cnt;i++){
        int fa_p1=find(edge[i].p1);
        int fa_p2=find(edge[i].p2);
        if(fa_p1==fa_p2) 
			continue;
        else{
            fa[fa_p1]=fa_p2;
            num++;
            ans+=(edge[i].cost);
        }
        if(num==n-1) break;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 7808
#include "iostream"
#include "algorithm"

using namespace std;

long long int N, M, K, L, R, H, W;

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

	cin >> N >> M >> L >> R;
	cout << min(N, M) + min(L, R) << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	string s = {};
	int cnt = 0, max = 0;
	cin >> s;

	rep(i, s.length()){
		for(int j = i; ; j++){
			if(s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T'){
				++cnt;
				if(max < cnt) max = cnt;
			}else{
				break;
			}
		}
		cnt = 0;
	}

	cout << max << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define fi first
#define se second

int main(void){
	while(1){
		int m; scanf("%d", &m);
		if(m == 0) break;
		vector<pair<int, int> > seiza(m);
		rep(i, m) scanf("%d %d", &seiza[i].fi, &seiza[i].se);

		//?????§??????????????????????????????????¨????
		vector<pair<int, int> > v(m);//fi x??§?¨? se y??§?¨?
		v[0].fi = 0, v[0].se = 0;//????????????????????????????????????
		//????????????????????????????????????????????§?????§?¨????????????????????????????????????§?????§?¨???????????????????????±???????
		reps(i, 1, m){
			v[i].fi = seiza[i].fi - seiza[0].fi;
			v[i].se = seiza[i].se - seiza[0].se;
		}

		int n; scanf("%d", &n);
		vector<pair<int, int> > hosizora(n);//?????????????????\????????????
		rep(i, n) scanf("%d %d", &hosizora[i].fi, &hosizora[i].se);
	
		int nowx, nowy;
		int cnt = 0;
		//?????§?±?????????????????????????????????????????????¨??¢?´¢??§??¢???
		rep(i, n){
			nowx = hosizora[i].fi;
			nowy = hosizora[i].se;
			rep(j, n){
				int vx = hosizora[j].fi - nowx;
				int vy = hosizora[j].se - nowy;
				rep(k, m){
					if(vx == v[k].fi && vy == v[k].se){
						cnt++;
						break;
					}
				}
			}
			//cnt==m???????????°???m???????????????????????????????????????????????¨??????????????§???????????????????????????????????´????????????
			if(cnt == m) break;
			cnt = 0;
		}
		printf("%d %d\n", nowx - seiza[0].fi, nowy - seiza[0].se);
	}
	return 0;
}

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

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

    int t = T.size();
    if (S + T.at(T.size() - 1) == T) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;

int h,w;
char maze[20][20];
ll x,y;
ll d[20][20][20][20];
ll dx[4]={-1,0,1,0}; int dy[4]={0,1,0,-1};


int main(){
  cin >>h>>w;
  
  rep(i,0,h){
    rep(j,0,w){
      cin >> maze[i][j];
    }
  }
  ll ans=0;
  rep(sy,0,h){
    rep(sx,0,w){
      if(maze[sy][sx]=='#')continue;
      queue<P>que;
      rep(i,0,h){rep(j,0,w){d[sy][sx][i][j]=100000;}}
      d[sy][sx][sy][sx]=0;
      que.push(P(sy,sx));

      while(que.size()){
        P p=que.front(); que.pop();
        for (int i=0; i<4; i++){
          int ny=p.first+dy[i] ; int nx = p.second+dx[i];
          if(nx>=0 && nx<w && ny>=0 && ny<h && d[sy][sx][ny][nx]==100000 &&maze[ny][nx]!='#'){
              d[sy][sx][ny][nx]=d[sy][sx][p.first][p.second] +1;
              que.push(P(ny,nx));
          }
          }
        }
        ll tmp=0;
      rep(i,0,h){
        rep(j,0,w){
          if(d[sy][sx][i][j]==100000)continue;
          tmp=max(tmp,d[sy][sx][i][j]);
        }
      }
      ans=max(ans,tmp);
    }
  }
  
  cout <<ans<<endl;


}



Measured memory_bytes: 4684