akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
using namespace std;

template<typename Type> class StarrySkyTree {
public:
	unsigned size_; std::vector<Type> dat1, dat2, dat;
	inline void update_(unsigned a, unsigned b, Type x, unsigned k, unsigned l, unsigned r) {
		if (r <= a || b <= l) return;
		if (a <= l && r <= b) {
			dat2[k] += x; return;
		}
		update_(a, b, x, (k << 1), l, (l + r) >> 1);
		update_(a, b, x, (k << 1) + 1, (l + r) >> 1, r);
		dat1[k] = std::min(dat1[k << 1] + dat2[k << 1], dat1[(k << 1) + 1] + dat2[(k << 1) + 1]);
	}
	inline Type query_(unsigned a, unsigned b, unsigned k, unsigned l, unsigned r) {
		if (r <= a || b <= l) return std::numeric_limits<Type>::max();
		if (a <= l && r <= b) return dat1[k] + dat2[k];
		Type lc = query_(a, b, (k << 1), l, (l + r) >> 1);
		Type rc = query_(a, b, (k << 1) + 1, (l + r) >> 1, r);
		return std::min(lc, rc) + dat2[k];
	}
	//StarrySkyTree() : size_(0), dat(std::vector<Type>()) {};
	StarrySkyTree(int size__) {
		for (size_ = 1; size_ < size__; ) size_ <<= 1;
		dat1.resize(size_ << 1, 0);
		dat2.resize(size_ << 1, 0);
		dat.resize(size_ << 1, 0);
	}
	template<class T>
	StarrySkyTree(T begin_, T end_) {
		unsigned n = (end_ - begin_);
		for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max());
		for (unsigned i = 0; i < n; i++) dat[i + size_] = *(begin_ + i);
		for (unsigned i = size_ - 1; i > 0; i--) dat[i] = std::min(dat[i << 1], dat[(i << 1) + 1]);
	}
	inline unsigned size() { return size_; }
	inline void add(unsigned i, Type x) {
		update_(i, i + 1, x, 1, 0, size_);
	}
	inline void add(unsigned l, unsigned r, Type x) {
		update_(l, r, x, 1, 0, size_);
	}
	inline Type query(unsigned l, unsigned r) {
		return query_(l, r, 1, 0, size_);
	}
};

long long N, M, L[1 << 18], R[1 << 18], A[1 << 18], dp[1 << 18], sum;
vector<pair<long long, long long>>G[1 << 18];

int main() {
	cin >> N >> M;
	StarrySkyTree<long long>X(N + 5);
	for (int i = 0; i < M; i++) { cin >> L[i] >> R[i] >> A[i]; sum += A[i]; G[R[i]].push_back(make_pair(L[i], A[i])); }

	X.add(0, 0);
	for (int i = 1; i <= N; i++) {
		dp[i] = X.query(0, i); X.add(i, dp[i]);
		for (int j = 0; j < G[i].size(); j++) {
			X.add(0, G[i][j].first, G[i][j].second);
		}
	}
	long long minx = 0; for (int i = 0; i <= N; i++) minx = min(minx, X.query(i, i + 1));
	cout << sum - minx << endl;
	return 0;
}

Measured memory_bytes: 33152
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N;
  long int x=0;
  long int y=5;
  long int z=1;
  cin >> N;
  int n=N;
  
  if (N==1 || N==0) {
    cout << 0 << endl;
    return 0;
  }
  if (N%2==1) {
    cout << 0 << endl;
    return 0;
  }
  while(N>0) {
      x += (N/5)/2;
      N = N/5;
  }
  cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
S = Counter([input() for i in range(n)])
m = int(input())
T = Counter([input() for i in range(m)])

ans = 0
for k, v in S.items():
    tmp = v
    if k in T:
        tmp -= T[k]
    ans = max(ans, tmp)
            
print(ans)

Measured memory_bytes: 3316
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

typedef vector<int> V;

const int N=2005;
const int E=N*N;

V seq[N];

int tov[E],nxt[E];
int num[N],id[N];
bool vis[N];
int last[N];
int n,tot,rt;

inline bool cmp(int x,int y){return num[x]<num[y];}

inline void insert(int x,int y){tov[++tot]=y,nxt[tot]=last[x],last[x]=tot;}

int gcd(int x,int y){return y?gcd(y,x%y):x;}

inline void merge(V a,V b,V &ret)
{
	ret.resize(0),ret.reserve(a.size()+b.size());
	vector<int>::iterator ita=a.begin(),itb=b.begin();
	for (;ita!=a.end()||itb!=b.end();)
		if (ita==a.end()||itb!=b.end()&&num[*itb]>num[*ita]) ret.push_back(*itb),++itb;
		else ret.push_back(*ita),++ita;
}

void dfs(int x)
{
	V son;vis[x]=1;
	for (int i=last[x];i;i=nxt[i]) son.push_back(tov[i]);
	sort(son.begin(),son.end(),cmp);
	for (int i=0,y;i<(int)son.size();++i)
		if (!vis[y=son[i]]) dfs(y),merge(seq[y],seq[x],seq[x]);
	seq[x].insert(seq[x].begin(),x);
}

int main()
{
	//freopen("rearranging.in","r",stdin),freopen("rearranging.out","w",stdout);
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&num[i]),id[i]=i;
	sort(id+1,id+1+n,cmp);
	for (int i=1;i<n;++i)
		for (int j=i+1;j<=n;++j)
			if (gcd(num[i],num[j])!=1) insert(i,j),insert(j,i);
	rt=0;
	for (int i=1,x;i<=n;++i)
		if (!vis[x=id[i]]) dfs(x),merge(seq[rt],seq[x],seq[x]),rt=x;
	for (int i=0;i<(int)seq[rt].size();++i) printf("%d%c",num[seq[rt][i]],i+1<(int)seq[rt].size()?' ':'\n');
	//fclose(stdin),fclose(stdout);
	return 0;
}

Measured memory_bytes: 41276
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<queue>
#include<map>

using namespace std;



int main(){
    long long int a, b;
    long long int v, w, t;

    cin >> a >> v;
    cin >> b >> w;
    cin >> t;

    

    if(v <= w){
        cout << "NO" << endl;
    } else {
        if(a < b){
            long long int diff = (b - a) + (w - v) * t;
            if(diff <= 0) cout << "YES" << endl;
            else cout << "NO" << endl;
        } else {
            long long int diff = (b - a) + (v - w) * t;
            if(diff < 0) cout << "NO" << endl;
            else cout << "YES" << endl;
        }
    }
}




Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
long long x[100010],y[100010],z[100010];
int main(){

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

  long long a,b,c,cnt=0,ans=0,n;
  string s,v;
  char ad[5];

  cin>>a>>b;
  cout<<(a-1)*(b-1)<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
#ifdef __LOCAL
#include <dump.hpp>
#define dump(...) DUMPOUT << "  " << string(#__VA_ARGS__) << ": " << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl << "    ", dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct IOInit { IOInit() { cin.tie(nullptr); ios::sync_with_stdio(false); dump("READY"); /*cout << unitbuf;*/} } IO_INIT;
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;



signed main(void) {
  int n, d; cin >> n >> d;
  Vi x(n), y(n);
  rep(i,n) cin >> x[i] >> y[i];

  two_sat ts(n);
  rep(i,n) {
    for (int j = i+1; j < n; ++j) {
      if (abs(x[i]-x[j]) < d) ts.add_clause(i, false, j, false);
      if (abs(x[i]-y[j]) < d) ts.add_clause(i, false, j, true);
      if (abs(y[i]-x[j]) < d) ts.add_clause(i, true, j, false);
      if (abs(y[i]-y[j]) < d) ts.add_clause(i, true, j, true);
    }
  }

  if (!ts.satisfiable()) plexit("No")

  pl("Yes")
  auto answer = ts.answer();
  rep(i,n) {
    if (answer[i]) pl(x[i])
    else pl(y[i])
  }
  return 0;
}


Measured memory_bytes: 3760
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)x=x->left;
  return x;


}

Node treeSearch(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(u->key>k)u=u->left;
    else u=u->right;
  }
  return u;


}

Node treeSuccessor(Node x){
  if(x->right!=NIL) return treeMinimum(x->right);
  Node y=x->parent;
  while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL||z->right==NIL)y=z;
  else y=treeSuccessor(z);
  if(y->left!=NIL) x=y->left;
  else x=y->right;
  if(x!=NIL)x->parent=y->parent;
  if(y->parent==NIL) root=x;
  else{
    if(y==y->parent->left)y->parent->left=x;
    else y->parent->right=x;
  }
  if(y!=z) z->key=y->key;

  



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else{
    if(z->key<y->key)y->left=z;
    else y->right=z;
  }
}






void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);

}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20544
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
cout<<fixed<<setprecision(10);
string S;
  cin >>S;
  
  if (S=="abc" || S=="acb" || S=="bac" || S=="bca" || S=="cab" || S=="cba" ) cout <<"Yes";
  else cout <<"No";

	
}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    string a = s.substr(0, n);
    string b = s.substr(n, n);
    reverse(b.begin(), b.end());
    map<pair<string, string>, int> app;
    fori(mask, 0, 1 << n) {
        vector<string> tmp(2);
        fori(i, 0, n) {
            if(mask & (1 << i)) {
                tmp[0] += a[i];
            }
            else {
                tmp[1] += a[i];
            }
        }
        app[make_pair(tmp[0], tmp[1])]++;
    }
    ll ans = 0;
    fori(mask, 0, 1 << n) {
        vector<string> tmp(2);
        fori(i, 0, n) {
            if(mask & (1 << i)) {
                tmp[0] += b[i];
            }
            else {
                tmp[1] += b[i];
            }
        }
        ans += app[make_pair(tmp[1], tmp[0])];
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 91904
#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

int main()
{
	bool isYYMM = false, isMMYY = false;

	string S;
	cin >> S;

	if (1 <= ((int)S[2] - 48) * 10 + (int)S[3] - 48 &&
		((int)S[2] - 48) * 10 + (int)S[3] - 48 <= 12)
	{
		isYYMM = true;
	}
	if (1 <= ((int)S[0] - 48) * 10 + (int)S[1] - 48 &&
		((int)S[0] - 48) * 10 + (int)S[1] - 48 <= 12)
	{
		isMMYY = true;
	}

	if (isYYMM)
	{
		if (isMMYY)
		{
			cout << "AMBIGUOUS" << endl;
		}
		else
		{
			cout << "YYMM" << endl;
		}
	}
	else
	{
		if (isMMYY)
		{
			cout << "MMYY" << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){

    int i, a, b, c, j;

    j = 0;

    cin >> a >> b >> c;

    for(i = a; i < b + 1; i++){

         if(c % i == 0){ 

             j = j + 1;

         }

    }

    cout << j << endl;

return 0;

}

Measured memory_bytes: 1164
while True:
    n, k = map(int,input().split())
    a = []
    if n==0 and k==0:
        break
    for i in range(n):
        a.append(int(input()))
    b = sum(a[0:k])
    c = b
    for i in range(k,n):
        b = b + a[i] - a[i-k]
        if b > c:
            c = b
    print(c)


Measured memory_bytes: 9864
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
#n = ip()                                     #入力整数1つ
h,w= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
n = ip()
a = [int(i) for i in input().split()]
horz = 1
vert = 1
x = 0
y = 0
ans  = [[0 for i in range(w)] for i in range(h)]
pos = 0
for i in range(h*w):
    ans[y][x] = pos+1
    a[pos]-=1
    if a[pos] ==0:
        pos+=1
    if y == h-1 and vert == 1:
        x+=1
        vert = -1
    elif y == 0 and vert == -1:
        x+=1
        vert = 1
    else: y+=vert
for i in range(h):
    for k in range(w):
        if k+1 != w: print(ans[i][k],"",end="")
        else : print(ans[i][k],end="")
    print()

Measured memory_bytes: 14436
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        if (m == 2) {
            int first = 0;
            int second = 0;
            for (int i = 0; i < n; i++) {
                int x = sc.nextInt();
                if (i % 2 == 0) {
                    if (x == 1) {
                        second++;
                    } else {
                        first++;
                    }
                } else {
                    if (x == 1) {
                        first++;
                    } else {
                        second++;
                    }
                }
            }
            System.out.println(Math.min(first, second));
        } else {
            int prev = sc.nextInt();
            int count = 0;
            for (int i = 1; i < n; i++) {
                int x = sc.nextInt();
                if (prev == x) {
                    count++;
                    prev = 0;
                } else {
                    prev = x;
                }
            }
            System.out.println(count);
        }
    }
}



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

int main(){
  int n;cin >> n;double v[n];
  for (int i=0;i<n;i++){
    cin >> v[i];
  }
  sort(v,v+n);
  double x=v[0];
  for(int i=1;i<n;i++){
    x=(x+v[i])/2;
  }
  cout << x << endl;
}

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

typedef long long ll;

ll a[300050];
ll dp1[300050], dp2[300050];
priority_queue<ll,vector<ll>,greater<ll> > pq;
priority_queue<ll> pq2;

int main() {
	/* freopen("input.in", "r", stdin);
	freopen("output.o", "w", stdout); */
	ll n;
	scanf("%lld", &n);
	for (ll i = 1; i <= 3 * n; i++) scanf("%lld", &a[i]);
	ll cs = 0;
	for (ll i = 1; i <= n; i++) {
		pq.push(a[i]);
		cs += a[i];
	}
	dp1[n] = cs;
	for (ll i = n + 1; i <= 2 * n; i++) {
		ll smallest = pq.top();
		if (a[i] > smallest) {
			cs += a[i];
			cs -= smallest;
			dp1[i] = cs;
			pq.pop();
			pq.push(a[i]);
		} else {
			dp1[i] = cs;
		}
	}
	cs = 0;
	while (!pq.empty()) pq.pop();
	for (ll i = 3 * n; i >= 2 * n + 1; i--) {
		cs += a[i];
		pq2.push(a[i]);
	}
	dp2[2*n+1] = cs;
	for(ll i=2*n;i>=n+1;i--){
		ll largest = pq2.top();
		if (a[i] < largest) {
			cs += a[i];
			cs -= largest;
			dp2[i]=cs;
			pq2.pop();
			pq2.push(a[i]);
		} else {
			dp2[i] = cs;
		}
	}
	ll cur=-1e18;
	for (ll i=n;i<=2*n;i++) {
		cur=max(cur,dp1[i]-dp2[i+1]);
	}
	printf("%lld",cur);
}

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

typedef long long ll;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

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

    if(a==b&&b==c){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

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

  std::cin >> n >> a >> b;

  int r = 0;

  for (int i = 1; i <= n; i++) {
    int c = i;
    int x = 0;
    for (;c > 0;) {

      x += c%10;
      c /= 10;

    }
    if (x >= a && x <= b) {
      r += i;
    }
  }


  std::cout << r << std::endl;

  return 0;
}


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

s=0

def check(a, b):
  judge=False
  while(judge==False):
    a,b=b,a%b
    if(b==0):
      judge = True
      return a
    elif(b==1):
      return 1
    
for i in range(1, n+1):
  for j in range(1, n+1):
    for k in range(1, n+1):
      s+=check(k,check(i,check(j,k)))


print(s)


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

#define int long long
// #define max(a,b) max((signed)a,(signed)b);
#define min(a,b) min((signed)a,(signed)b);

using namespace std;

int dp[3005][3005]={0};
//int dp[100005]={0};

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

	for(int i=n-1;i>=0;i--){
		for(int j=i;j<n;j++){
			if(i==j){
				dp[i][i] = a[i];
			}
			else{
				dp[i][j] = max((a[i]-dp[i+1][j]),(a[j]-dp[i][j-1]));
			}
		}
	}
	for(int i=0;i<n;i++){
		// for(int j=0;j<n;j++) cout<<dp[i][j]<<" ";
		// cout<<"\n";
	}
	cout<<dp[0][n-1]<<"\n";
}


Measured memory_bytes: 49720
using System;
using System.Collections.Generic;

namespace AOJ.Volume1
{
    public class PropertyDistribution
    {
        private static char[,] map;
        private class Position
        {
            public int H { get; set; }
            public int W { get; set; }
        }

        public static int Main()
        {
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                int h = int.Parse(input[0]);
                int w = int.Parse(input[1]);
                if (h == 0 && w == 0) { break; }

                map = new char[h + 2, w + 2];
                for(int i = 1; i <= h; i++)
                {
                    var line = Console.ReadLine();
                    for(int j = 0; j < w; j++) { map[i, j + 1] = line[j]; }
                }

                var target = new List<char>() { '@', '#', '*' };
                int answer = 0;
                for(int i = 1; i <= h; i++)
                {
                    for(int j = 1; j <= w; j++)
                    {
                        if (target.Contains(map[i, j]))
                        {
                            answer++;
                            Check(map[i, j], i, j);
                        }
                    }
                }

                Console.WriteLine(answer);
            }

            return 0;
        }

        private static void Check(char c, int pos_h, int pos_w)
        {
            var st = new Stack<Position>();
            var p = new Position() { H = pos_h, W = pos_w };
            st.Push(p);
            while (st.Count > 0)
            {
                // ???????????????????????????????????¢???????????????????????\????????????
                p = st.Pop();
                if (map[p.H - 1, p.W] == c) { st.Push(new Position() { H = p.H - 1, W = p.W }); }
                if (map[p.H + 1, p.W] == c) { st.Push(new Position() { H = p.H + 1, W = p.W }); }
                if (map[p.H, p.W - 1] == c) { st.Push(new Position() { H = p.H, W = p.W - 1 }); }
                if (map[p.H, p.W + 1] == c) { st.Push(new Position() { H = p.H, W = p.W + 1 }); }

                // ??¢?´¢????????¨?????????????????????
                map[p.H, p.W] = ' ';
            }
        }
    }
}

Measured memory_bytes: 11300
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[120];
		for(int i=0; i<120; i++){
			x[i]=0;
		}
		for(int i=0; i<n; i++){
			int b = sc.nextInt();  //?£?
			int f = sc.nextInt();  //???
			int r = sc.nextInt();  //??????
			int v = sc.nextInt();  //?????°
			int num=(b-1)*30+(f-1)*10+r;
			x[num-1]=x[num-1] + v;
		}
		for(int i=1; i<121; i++){
			System.out.print(" " + x[i-1]);
			if(i%10==0){
				System.out.println();
			}
			if(i%30==0 && i!=120){
				System.out.println("####################");
			}
		}
	}
}

Measured memory_bytes: 29400
import java.util.*;
public class Main { 
	static int[][] map;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int H = stdIn.nextInt();
			if(H == 0) break;
			map = new int[H][5];
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < 5; j++) {
					map[i][j] = stdIn.nextInt();
				}
			}
			int ans = 0;
			while(true) {
				int x = check();
				if(x == 0) break;
				ans += x;
				remove();
				drop();
			}
			System.out.println(ans);
		}
	}
	
	public static int check() {
		int ans = 0;
		for(int i = 0; i < map.length; i++) {
			int l = 0;
			int c = 0;
			for(int j = 0; j < 5; j++) {
				if(l == map[i][j]) {
					c++;
					
				}
				else if(c >= 3){
					ans += c * l;
					c = 1;
				}
				else {
					c = 1;
				}
				
				l = map[i][j];
				
				if(j == 4 && c >= 3) {
					ans += c * l;
				}
			}
		}
		return ans;
	}
	public static void remove() {
		for(int i = 0; i < map.length; i++) {
			int l = 0;
			int c = 0;
			int s = 0;
			for(int j = 0; j < 5; j++) {
				if(l == map[i][j]) {
					c++;
				}
				else if(c >= 3){
					for(int k = s; k < c+s; k++) {
						map[i][k] = 0;
					}
					c = 1;
					s = j;
				}
				else {
					c = 1;
					s = j;
				}
				
				l = map[i][j];
				if(j == 4 && c >= 3) {
					for(int k = s; k < c+s; k++) {
						map[i][k] = 0;
					}
				}
				
				
			}
		}
	}
	public static void drop() {
		for(int i = map.length; i >= 0; i--) {
			for(int j = 0; j < 5; j++) {
				int count = i;
				while(true) {
					if(count < 2) break;
					if(map[i-1][j] == 0) {
						map[i-1][j] = map[count-2][j];
						map[count-2][j] = 0;
						count--;
					}
					else {
						break;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 52300
#include <stdio.h>

int main(void)
{
	int i,j;
	int score[2][4];
	int result[2];
	for(i=0;i<2;i++){
		scanf("%d %d %d %d",&score[i][0],&score[i][1],&score[i][2],&score[i][3]);
		result[i] = score[i][0]+score[i][1]+score[i][2]+score[i][3];
	}
	if(result[0]>=result[1])
		printf("%d\n",result[0]);
	else
		printf("%d\n",result[1]);

	return 0;
}

Measured memory_bytes: 0
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    //tmp = input.split("\n");
    tmp = input.split(" ");

    answer = Number(tmp[0]) + 0.5*Number(tmp[1]);

    console.log(answer);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
	int r,g,b;
	cin >> r >> g >> b;
	if ((r*100+g*10+b) % 4 == 0) cout << "YES" << endl;
	else cout << "NO" << 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;
 
int main() {
  int H, A;
  cin >> H;
  cin >> A;
  int ans = 0;
  for (;;) {
    H -= A;
    ++ans;
    if (H <= 0) {
      break;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
import itertools as it
from collections import Counter as c
n=int(input())
a=c()
b=c()
s=input()
q=s[:n]
r=s[n:][::-1]
for i in it.product([0,1],repeat=n):
    d,e,f,g="","","",""
    for j in range(n):
        if i[j]==1:
            d+=q[j]
            f+=r[j]
        else:
            e+=q[j]
            g+=r[j]
    a[d,e]+=1
    b[f,g]+=1
print(sum(a[i]*b[i] for i in a.keys()))

Measured memory_bytes: 126052
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        E solver = new E();
        solver.solve(1, in, out);
        out.close();
    }

    static class E {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            Integer n = Integer.parseInt(in.next());
            Integer[] a = new Integer[n];
            Integer[] b = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
                b[i] = Integer.parseInt(in.next());
            }
            int ans = 0;
            Arrays.sort(a);
            Arrays.sort(b);

            if (n % 2 == 0) {
                ans = (b[(n / 2) - 1] + b[n / 2]) - (a[(n / 2) - 1] + a[n / 2]) + 1;
            } else {
                ans = b[n / 2] - a[n / 2] + 1;
            }
            // 出力
            out.println(ans);

        }

    }
}



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

string s;
int arr[26];

int main() {
	cin>>s;
	for(int i=0;i<s.size();i++){
		arr[s[i]-'a']++;
	}
	if(s.size()<25){
		cout<<s;
		for(int i=0;i<26;i++){
			if(!arr[i]){
				cout<<(char)((int)'a'+i);
				return 0;
			}
			
		}
	}
	else{
		while(s.size()){
			int c=s[s.size()-1]-'a';
			arr[c]--;
			s.pop_back();
			for(int i=c+1;i<26;i++){
				if(!arr[i]){
					cout<<s<<(char)((int)'a'+i);
					return 0;
				}
			}
		}
		cout<<-1;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<queue>
#define ios ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const int maxn=1e5+100;
priority_queue<int> st;
int main(){
	ios;
	int m,n,t;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>t;	st.push(t);
	}
	long long sum=0;
	for(int i=1;i<=m;i++){
		t=st.top()/2;
		st.pop();
		st.push(t);
	}
	while(!st.empty()){
		sum+=st.top();
		st.pop();
	}
	cout<<sum<<'\n';
	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define l1 long long
int main(){ int a,b,c,d,e; cin>>a>>b>>c>>d>>e;
 if(a==0)cout<<1; else if(b==0)cout<<2; else if(c==0)cout<<3;  else if(d==0)cout<<4; else if(e==0)cout<<5;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>
const int N = 2e5 + 10;

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string ans = "";
    string o, e;
    cin >> o >> e;
    int p1 = 0, p2 = 0;
    bool turn = 1;
    while (p1 < sz(o) || p2 < sz(e)) {
        if (turn) {
            ans += o[p1++];
        } else {
            ans += e[p2++];
        }
        turn = 1 - turn;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>

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];
    for(int i = 0; i < N; i++) cin >> B[i];
    for(int i = 0; i < N; i++) cin >> C[i];
    int ans=0;
    ans += B[A[0]-1];
    for(int i = 1; i < N; i++){
        ans += B[A[i]-1];
        if(A[i] == A[i-1]+1){
            ans += C[A[i-1]-1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
class TEST{
	static void Main(){
		Stopwatch sw=new Stopwatch();
		sw.Start();
		
		String s="";
		while(!String.IsNullOrEmpty(s=rs())){
			int n=int.Parse(s);
			if(n==0)break;
			Sol mySol =new Sol(n);
			mySol.Solve();
		}
		
		sw.Stop();
		//Console.Error.WriteLine(sw.ElapsedMilliseconds);
	}
	static String rs(){return Console.ReadLine();}
}

class Sol{
	public void Solve(){
		used=new bool[101];
		Max=0;
		for(int i=0;i<101;i++){
			if(Count[i]==0)continue;
			used[i]=true;
			cnt=1;
			for(int j=0;j<Count[i];j++){
				if(used[ARR[i][j]])continue;
				used[ARR[i][j]]=true;
				cnt++;
				if(cnt>Max)Max=cnt;
				dfs(ARR[i][j]);
				cnt--;
				used[ARR[i][j]]=false;
			}
			cnt--;
			used[i]=false;
		}
		
		Console.WriteLine(Max);
	}
	
	
	int Max;
	int cnt;
	bool[] used;
	
	void dfs(int now){
		int jj=0;
		for(jj=0;jj<Count[now];jj++){
			if(used[ARR[now][jj]])continue;
			used[ARR[now][jj]]=true;
			cnt++;
			if(cnt>Max)Max=cnt;
			dfs(ARR[now][jj]);
			cnt--;
			used[ARR[now][jj]]=false;
		}
	}
	
	
	int N;
	int[][] ARR;
	int[] Count;
	public Sol(int n){
		N=n;
		ARR=new int[101][];
		for(int i=0;i<101;i++)ARR[i]=new int[101];
		Count=new int[101];
		for(int i=0;i<N;i++){
			var d=ria();
			Count[d[0]]++;
			ARR[d[0]][Count[d[0]]-1]=d[1];
			Count[d[1]]++;
			ARR[d[1]][Count[d[1]]-1]=d[0];
		}
	}


	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

Measured memory_bytes: 6236
#include <bits/stdc++.h>
using namespace std;
#define int long long



signed main(){
    int n;
    cin >>n;
    vector<int> a(n);
    cin >> a[0];
    int t;
    for(int i=1;i<n;i++){
        cin >> t;
    a[i]= t+a[i-1];
    }
    int p=0,q=2,ans=-1;
    for(int i=1;i<n-2;i++){
       while(abs(a[i]-2*a[p])>abs(a[i]-2*a[p+1]))p++;
       while(abs(a[n-1]+a[i]-2*a[q])>abs(a[n-1]+a[i]-2*a[q+1]))q++;
        if(ans<0||ans>max(max(a[p],a[i]-a[p]),max(a[q]-a[i],a[n-1]-a[q]))-min(min(a[p],a[i]-a[p]),min(a[q]-a[i],a[n-1]-a[q])))ans=max(max(a[p],a[i]-a[p]),max(a[q]-a[i],a[n-1]-a[q]))-min(min(a[p],a[i]-a[p]),min(a[q]-a[i],a[n-1]-a[q]));

       // cerr << ans<< ' '<<p <<' '<<q<<endl;
        
    }

    
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
N, M = map(int, input().split())
Hs = list(map(int, input().split()))
ans = [1 for i in range(N)]
for i in range(M):
	a, b = map(int, input().split())
	if Hs[a-1] <= Hs[b-1]:
		ans[a-1] = 0
	if Hs[b-1] <= Hs[a-1]:
		ans[b-1] = 0
print(sum(ans))


Measured memory_bytes: 20088
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long mat[9],i,j,flag=0;
    for(i=0;i<9;i++)
    {
        cin>> mat[i];
    }
    long long n,a;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >>a;
        for(j=0;j<9;j++)
        {
            if(mat[j]==a)
                {
                    mat[j]=0;
                    break;
                }
        }
    }
    long long ans[8];
    ans[0]=mat[0]+mat[1]+mat[2];
    ans[1]=mat[3]+mat[4]+mat[5];
    ans[2]=mat[6]+mat[7]+mat[8];
    ans[3]=mat[0]+mat[3]+mat[6];
    ans[4]=mat[1]+mat[4]+mat[7];
    ans[5]=mat[2]+mat[5]+mat[8];
    ans[6]=mat[0]+mat[4]+mat[8];
    ans[7]=mat[2]+mat[4]+mat[6];
    for(i=0;i<8;i++)
    {
        if(ans[i]==0)
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
        cout <<"Yes"<<endl;
    else
        cout <<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;

const int MOD = 998244353;
const int N = 2e5 + 5;
vector<long long> T[20], X[20];
long long one[N];
long long ten[N];

void push(int h, int k)
{
	if (X[h][k]) {
		T[h][k] = X[h][k] * one[1 << h] % MOD;
	}
	if (h) {
		if (X[h][k]) {
			X[h - 1][k << 1] = X[h][k];
			X[h - 1][k << 1 | 1] = X[h][k];
		}
	}
	X[h][k] = 0;
}
void pull(int h, int k)
{
	// printf("pull h %d k %d\n", h, k);
	long long sl = T[h - 1][k << 1];
	long long sr = T[h - 1][k << 1 | 1];
	if (X[h - 1][k << 1]) {
		sl  = X[h - 1][k << 1] * one[1 << (h - 1)] % MOD;
	}
	if (X[h - 1][k << 1 | 1]) {
		sr = X[h - 1][k << 1 | 1] * one[1 << (h - 1)] % MOD;
	}
	T[h][k] = (sl * ten[1 << (h - 1)] % MOD + sr) % MOD;
}
long long query(int h, int k, int i, int j)
{
	// printf("query h %d k %d i %d j %d\n", h, k, i, j);
	push(h, k);
	int m = (k << h) + (1 << (h - 1));
	if (i == (k << h) && j == ((k + 1) << h) - 1) return T[h][k];
	if (j < m) return query(h - 1, k << 1, i, j);
	if (i >= m) return query(h - 1, k << 1 | 1, i, j);
	long long sl = query(h - 1, k << 1, i, m - 1); 
	long long sr = query(h - 1, k << 1 | 1, m, j);
	return (sl * ten[j - m + 1] % MOD + sr) % MOD;
}
void update(int h, int k, int i, int j, int x)
{
	push(h, k);
	int m = (k << h) + (1 << (h - 1));
	if (i == (k << h) && j == ((k + 1) << h) - 1) {
		X[h][k] = x;
		return;
	}
	if (j < m)  update(h - 1, k << 1, i, j, x);
	else if (i >= m)  update(h - 1, k << 1 | 1, i, j, x);
	else {
		update(h - 1, k << 1, i, m - 1, x);
		update(h - 1, k << 1 | 1, m, j, x);
	}
	pull(h, k);
}
int main()
{
	int n, q;
	scanf("%d%d", &n, &q);
	int d = ceil(log2(n));
	for (int i = 0; i <= d; i++) {
		T[i].clear();
		T[i].resize(1 << (d - i), 0);
		X[i].clear();
		X[i].resize(1 << (d - i), 0);
	}
	one[0] = 0;
	for (int i = 1; i <= n; i++) {
		one[i] = (one[i - 1] * 10 + 1) % MOD;
	}
	ten[0] = 1;
	for (int i = 1; i <= n; i++) {
		ten[i] = ten[i - 1] * 10 % MOD;
	}
	for (int i = 0; i < n; i++) {
		T[0][i] = 1;
	}
	for(int i = 1; i <= d; i++) {
		for(int j = 0; j < (int)T[i].size(); j++) {
			T[i][j] = T[i - 1][j << 1] * ten[1 << (i - 1)] % MOD + T[i - 1][j << 1 | 1];
		}
	}

	while (q--) {
		int l, r, dig;
		scanf("%d%d%d", &l, &r, &dig);
		update(d, 0, l - 1, r - 1, dig);
		printf("%lld\n", query(d, 0, 0, n - 1));
	}
	return 0;
}


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

int main(){
  int ans=753;
  int kari;
  string s;
  cin >> s;
  size_t len = s.length();
  for(int i=0;i<len-2;i++){
    kari = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0');
    kari = abs(kari-753);
    if(kari<=ans){
      ans = kari;
    }
  }

  cout << ans << endl;

}


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

using namespace std;

int p[100];

vector<int> G[100];

void dfs1(int root)
{
    if(root==-1)
    {
        return;
    }
    printf(" %d",root);

    dfs1(G[root][0]);
    dfs1(G[root][1]);
}

void dfs2(int root)
{
    if(root==-1) return;

    dfs2(G[root][0]);
    printf(" %d",root);
    dfs2(G[root][1]);
}

void dfs3(int root)
{
    if(root==-1) return ;

    dfs3(G[root][0]);
    dfs3(G[root][1]);
    printf(" %d",root);
}

int main()
{

    int n;

    while(scanf("%d",&n)!=EOF)
    {

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

        for(int i=0;i<n;i++)
        {
            G[i].clear();
        }
        int a,b,c;
        for(int i=0;i<n;i++)
        {
            scanf("%d %d %d",&a,&b,&c);

            G[a].push_back(b);
            G[a].push_back(c);

            if(b!=-1)
            {
                p[b]=a;
            }
            if(c!=-1)
            {
                p[c]=a;
            }
        }

        int root;
        for(int i=0;i<n;i++)
        {
            if(p[i]==-1)
            {
                root=i;
                break;
            }
        }

        puts("Preorder");
        dfs1(root);
        putchar('\n');
        puts("Inorder");
        dfs2(root);
        putchar('\n');
        puts("Postorder");
        dfs3(root);
        putchar('\n');
    }



    return 0;
}



Measured memory_bytes: 3224
var
	N,T:int64;
begin
	read(N);
	dec(N);
	T:=26;
	while N>=T do begin
		dec(N,T);
		T:=T*26;
	end;
	while T>1 do begin
		T:=T div 26;
		write(Chr(N div T+97));
		N:=N mod T;
	end;
end.

Measured memory_bytes: 1388
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define int long long
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int N,x=0;
	cin >> N ;
	vector <int> p(N);
	rep(i, N)
		cin >> p[i];
	rep(i, N - 2) {
		if ((p[i] > p[i + 1] && p[i + 1] > p[i + 2]) || (p[i]<p[i + 1] && p[i + 1]<p[i + 2]))
			x++;
	}
	cout << x;
}

Measured memory_bytes: 256
#include<stdio.h>
using namespace std;

int main(void){
	int n, o[100];
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf("%d", &o[i]);
	}
	for(int i = n; i > 0; --i){
		printf("%d", o[i-1]);
		if(i == 1){
			break;
		}
		printf(" ");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1028
N = int(input())
m_rank = 1
point_at_m_rank = 1000000000
for i in range(N):
    a, b = map(int, input().split())
    if a >= m_rank:
        m_rank = a
        point_at_m_rank = b
print(m_rank+abs(point_at_m_rank))

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

int main() {
  int H, W;
  cin >> H >> W;
  
  char a[110][110];
  
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> a[i][j];
    } 
  }
  
  
  vector<bool> row(110, false), column(110, false);
  
  // が全部白の行を見つける
  bool cond = true;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (a[i][j] == '#') break;
      if (j == W) column[i] = true;
    }
  }
  
  // 全部が白の列を見つける
  for (int j = 1; j <= W; j++) {
    for (int i = 1; i <= H; i++) {
      if (a[i][j] == '#') break;
      
      if(i == H) row[j] = true;
    }
  }

  
  
  for (int i = 1; i <= H; i++) {
    if (column[i]) continue;
    for (int j = 1; j <= W; j++) {
      if (row[j]) continue;
      
      cout << a[i][j];
    }
    cout<< endl;
  }
}

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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        int a, b , c;
        cin >> a >> b >> c;
        cout << ( (a+b+c) >= 22 ? "bust" : "win" ) << endl;
        return 0;
}










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

// これ以降の行は変更しなくてよい

int main() {
  int n;
  cin >> n;
  vector<int> t(n), x(n), y(n);
  for (int i = 0; i < n; i++) cin >> t[i] >> x[i] >> y[i];

  for (int i = 0; i < n; i++) {
    int ti, xi, yi;
    if (i == 0) {
      ti = t[i];
      xi = x[i];
      yi = y[i];
    }
    else{
      ti = t[i] - t[i-1];
      xi = x[i] - x[i-1];
      yi = y[i] - y[i-1];
    }

    // cout << ti << " " << xi << " "<< yi << " " << endl;

    if ((abs(xi+yi) <= ti) && (abs(xi+yi-ti)%2 == 0)) continue;
    else {cout << "No" << endl; return 0;}
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 4592
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+7;
int f[maxn],x[maxn];
vector<int> fa[maxn];
void init()
{
	for(int i=1;i<=maxn-6;i++)
	{
		for(int j=2;j<sqrt(i);j++)
		{
			if(i%j==0)
			{
				fa[i].push_back(j);
				fa[i].push_back(i/j);
			}
		}
		int j=sqrt(i);
		if(j>1&&j*j==i)
		{
			fa[i].push_back(j);
		}
		//cout<<i<<" ";
		//for(auto u:fa[i]) cout<<u<<" ";
		//cout<<endl;
	}
}
int main()
{
	//freopen("1.txt","r",stdin);
    //freopen("2.txt","w",stdout);
	init();
	int n;
	while(cin>>n)
	{
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x[i]);
	}
	vector<int> ans;memset(f,0,sizeof f);
	for(int i=n;i>=1;i--)
	{
		if((x[i]%2) != (f[i]%2))
		{
			f[i]++; 
			ans.push_back(i);
			//if(fa[i].size()==0) continue;
			for(auto u:fa[i])
			{
				f[u]++;
			}
			if(i!=1) f[1]++;
		}
	}
	cout<<ans.size()<<endl;
	for(auto u:ans) cout<<u<<" ";
		cout<<endl;
	}
	
}

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

using namespace std;

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

    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        p[i] = i + 1;
    }
    vector<int> b(n);
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    int ath = -1, bth = -1;
    int cnt = 1;
    do {
        if (p == a) {
            ath = cnt;
        }
        if (p == b) {
            bth = cnt;
        }
        cnt++;
    } while (next_permutation(p.begin(), p.end()));
    cout << abs(ath - bth) << '\n';

    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int N,A,B;cin>>N>>A>>B;
    cout<<min(N*A,B)<<endl;


}


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

int a, b;

int main () {
	cin >> a >> b;
	 if (a == b){
	cout << "Draw" << endl;
	} else if (a == 1) {
		cout << "Alice" << endl;
	} else if (b == 1) {
		cout << "Bob" << endl;
	} else if (a > b) {
		cout << "Alice" << endl;
	} else if (a < b) {
		cout << "Bob" << endl;
	} 
}

Measured memory_bytes: 3528
#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

class UnionFind{
public:
    vector<int> v;
    UnionFind(int size):v(size,-1){}

    int root(int a){
        if(v[a]<0){
            return a;
        }else{
            int res=root(v[a]);
            v[a]=res;
            return res;
        }
    }

    void unite(int a,int b){
        int roota=root(a);
        int rootb=root(b);
        if(roota==rootb){return;}
        if(v[roota]>v[rootb]){
            v[rootb]+=v[roota];
            v[roota]=rootb;
        }else{
            v[roota]+=v[rootb];
            v[rootb]=roota;
        }
    }

    bool same(int a,int b){
        return root(a)==root(b);
    }

    int size(int a){
        return v[root(a)];
    }
};

int main(){
    int N,M;
    cin>>N>>M;

    UnionFind uf(N+1);
    int a,b;
    for(int i=0;i<M;i++){
        cin>>a>>b;
        uf.unite(a,b);
    }

    int ans=0;
    for(auto p:uf.v){
        if(ans>p){
            ans=p;
        }
    }
    cout<<-1*ans<<endl;

    return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
int N;
int A[MAX];
VI win_lose_graph[MAX], lose_win_graph[MAX];
int memo[MAX];
int cnt[MAX];

VPII win_lose[MAX];

VI v[MAX];
VI v2;

int dfs(int now) {
    int res = 0;
    VI vv;
    FORE(e, win_lose[now]) {
        vv.EB(dfs(e.second));
    }
    RSORT(vv);
    REP(i, vv.size()) vv[i] += i + 1;
    FORE(e, vv) chmax(res, e);
    return res;
}

int main(void) {
    memset(memo, -1, sizeof(memo));
    memset(cnt, 0, sizeof(cnt));
    scanf("%d", &N);
    A[0] = -1;
    FOR(i, 1, N) {
        scanf("%d", &A[i]);
        A[i]--;
        cnt[A[i]]++;
        if (A[i] == 0) v[0].EB(i);
        win_lose[A[i]].EB(MP(A[i], i));
    }
    int ans = cnt[0];
    FORE(e, v[0]) v2.EB(dfs(e));
    RSORT(v2);
    REP(i, v2.size()) v2[i] += i + 1;
    FORE(e, v2) chmax(ans, e);
    //REP(i, N) DEBUG(memo[i])
    cout << ans  << endl;
}


Measured memory_bytes: 23296
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    h,w = LI()
    for _ in range(h):
        s = S()
        print(s)
        print(s)

main()


Measured memory_bytes: 5460