akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    vector<string> v(10000);
    for (int i = 0; i < 10000; ++i) {
        int x = i+1;
        if(x%3 == 0 || x%5 == 0){
            v[i] = string(x%3 == 0 ? "Fizz" : "") + (x%5 == 0 ? "Buzz" : "");
        }else {
            v[i] = to_string(x);
        }
    }
    while(cin >> n >> m, n){
        vector<int> alive(n, 1);
        int cnt = n, cur = 0;
        for (int i = 0; i < m; ++i) {
            string s;
            cin >> s;
            if(cnt == 1) continue;
            while(!alive[cur]) cur = (cur+1)%n;
            if(v[i] != s) alive[cur] = 0, cnt--;
            cur = (cur+1)%n;
        }
        vector<int> ans;
        for (int i = 0; i < n; ++i) {
            if(alive[i]) ans.emplace_back(i);
        }
        for (int i = 0; i < ans.size(); ++i) {
            if(i) printf(" ");
            printf("%d", ans[i]+1);
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 3284
L, R = (int(item) for item in input().split())

m=2020
if R-L > 2020:
  print(0)
else:
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      mm = i*j % 2019
      if m > mm:
        m = (i*j % 2019)
  print(m)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  int mn = S.size();
  for (int i = 0; i <= S.size() - T.size(); i++)
  {
    int tmp = 0;
    rep(j, T.size())
    {
      if (S[i + j] != T[j])
        tmp++;
    }

    mn = std::min(tmp, mn);
  }

  cout << mn << endl;

  return 0;
}


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

int main() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>b) swap(a,b);
    if(b>c) swap(b,c);
    for(int i=0; i<k; i++) {
        c *= 2;
    }
    cout<<a+b+c<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<ctime>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<vector>
#include<bitset>
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
string s,p;
int main()
{	cin>>s;
	int n=s.length(); p="KIH";
	int i=0,nn=0;
	if(s[i]=='A') i++;
	else if(s[i]!='K') goto ext;
	if(s.substr(i,3)==p)
	{	int now=0,pos=i+3,num=0;
		while(s[pos]!='B')
		{	if(s[pos]!='A') goto ext;
			num++; if(num>=2) goto ext;
			pos++;
		}
		num=0; pos++;
		while(s[pos]!='R')
		{	if(s[pos]!='A') goto ext;
			num++; if(num>=2) goto ext;
			pos++; 
		}
		pos++; 
		if(pos!=n&&pos!=n-1) goto ext;
		if(pos==n-1&&s[n-1]!='A') goto ext;
		cout<<"YES\n";return 0;
	}
	ext:
	cout<<"NO\n";
 	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main() {

	string SA, SB, SC;
	cin >> SA >> SB >> SC;

	char turn = 'a';
	while (1) {
		if(turn == 'a'){
			if (SA.size() == 0) {
				break;
			}
			turn = SA[0];
			SA = SA.substr(1, SA.size()-1);
			continue;
		}
		else if (turn == 'b') {
			if (SB.size() == 0) {
				break;
			}
			turn = SB[0];
			SB = SB.substr(1, SB.size()-1);
			continue;
		}
		else {
			if (SC.size() == 0) {
				break;
			}
			turn = SC[0];
			SC = SC.substr(1, SC.size()-1);
			continue;
		}
	}

	if (turn == 'a') turn = 'A';
	if (turn == 'b') turn = 'B';
	if (turn == 'c') turn = 'C';
	cout << turn << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template <typename T,typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E)>;
  int n;
  F f;
  G g;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int n_,F f,G g,T ti):
    f(f),g(g),ti(ti){
    init(n_);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.assign(2*n-1,ti);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(int k,E a){
    k+=n-1;
    dat[k]=g(dat[k],a);
    while(k>0){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
  inline T query(int a,int b){
    T vl=ti,vr=ti;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[(l++)-1]);
      if(r&1) vr=f(dat[(--r)-1],vr);
    }
    return f(vl,vr);
  }

  int find(int a,int b,function<bool(T)> &check,int k,int l,int r){
    if(!check(dat[k])||r<=a||b<=l) return -1;
    if(k>=n-1) return k-(n-1);
    int m=(l+r)>>1;
    int vl=find(a,b,check,k*2+1,l,m);
    if(~vl) return vl;
    return find(a,b,check,k*2+2,m,r);
  }
  
  int find(int a,int b,function<bool(T)> &check){
    return find(a,b,check,0,0,n);
  }
  
};
//END CUT HERE
signed AOJ_DSL2A(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n,q;
  cin>>n>>q;
  SegmentTree<int,int> rmq(n,
			   [](int a,int b){return min(a,b);},
			   [](int a,int b){return b;},
			   INT_MAX);
  for(int i=0;i<q;i++){
    int c,x,y;
    cin>>c>>x>>y;
    if(c) cout<<rmq.query(x,y+1)<<endl;
    else rmq.update(x,y);
  }
  return 0;
}
signed main(){
  AOJ_DSL2A();
  return 0;
}


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

using namespace std;
using ll = long long;

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

  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i = l; i <= r; i++)
    if (i % d == 0)
      ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstdlib>

using namespace std;

int main()
{
    double s;
    scanf("%lf", &s);

    /*
    int maxi = 0;
    for(int i = 1 ; i <= s - 2 ; i++)
    {
        for(int j = 1 ; j <= s - 2 ; j++)
        {
            int k = s - i - j;
            maxi = max(maxi, i * j * k);
        }
    }*/

    double length = s / 3;
    s -= length;
    double width = s / 2;
    double h = s - width;
    double maxi = length * width * h;

    printf("%lf\n", maxi);
    return 0;
}


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

using namespace std;
using ll = long long;

#define FOR(i,m,n) for(ll i=(m); (i)<(ll)(n); ++(i))
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin,(a).end

typedef struct U{
  ll a, b, c, d;
}U;

template <typename T> bool next_combination(const T first, const T last, int k) {
    const T subset = first + k;
    // empty container | k = 0 | k == n 
    if (first == last || first == subset || last == subset) {
        return false;
    }
    T src = subset;
    while (first != src) {
        src--;
        if (*src < *(last - 1)) {
            T dest = subset;
            while (*src >= *dest) {
                dest++;
            }
            iter_swap(src, dest);
            rotate(src + 1, dest + 1, last);
            rotate(subset, subset + (last - dest) - 1, last);
            return true;
        }
    }
    // restore
    rotate(first, subset, last);
    return false;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n, m, q;
  cin >> n >> m >> q;
  vector<U> x(q);
  REP(i,q) cin >> x[i].a >> x[i].b >> x[i].c >> x[i].d;
  
  vector<ll> v;
  for(ll i=1; i<=m*n; ++i){
    v.push_back((i+n-1)/n);
  }
  
  ll maxsum = -1;
  do{
    vector<ll> num;
    for (int i = 0; i < n; i++) num.push_back(v[i]);
    ll sum = 0;
    for(ll i=0; i<q; ++i){
      if(num[x[i].b-1] - num[x[i].a-1] == x[i].c){
        sum += x[i].d;
      }
    }
    if(maxsum == -1 || maxsum < sum) maxsum = sum;
  }while(next_combination(v.begin(), v.end(), n));
  
  cout << maxsum << endl;
  
  return 0;
}

Measured memory_bytes: 3664
#include<cstdio>
int su[100005];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&su[i]);
    }
    su[n] = n+100;
    int ans = 0;
    for(int i=0;i<n;i++){
        if(su[i] == i+1){
            ans++;
            i++;
        }
    }
    printf("%d", ans);
}


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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int i##_to_ = (t), i = (f); i <= i##_to_; i++)
#define uptil(f, t, i)   for(int i##_to_ = (t), i = (f); i <  i##_to_; i++)
#define downto(f, t, i)  for(int i##_to_ = (t), i = (f); i >= i##_to_; i--)
#define downtil(f, t, i) for(int i##_to_ = (t), i = (f); i >  i##_to_; i--)
typedef long double LD;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
#define debug true
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 2
#define _LIBCPP_DEBUG2 2
#define ln << endl
#else
#define debug false
#define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '

vector<char> pyon(int x, int y, int z) {
    vector<char> ans;
    if(!y && !z) {
        ans = vector<char>(x, 'a');
    } else if(!z && !x) {
        ans = vector<char>(y, 'b');
    } else if(!x && !y) {
        ans = vector<char>(z, 'c');
    } else {
        bool zoi = !x;
        if(zoi) swap(x, y);

        ans.reserve(x + y + z);
        int p = z / x, s = z % x, q = y / (x - s), t = y % (x - s), u = x - s - t;
        for(char c: pyon(u, t, s)) {
            ans.push_back(zoi ? 'b' : 'a');
            if(c == 'a') {
                times(p, o) ans.push_back('c');
                times(q, o) ans.push_back('b');
            } else if(c == 'b') {
                times(p, o) ans.push_back('c');
                times(q+1, o) ans.push_back('b');
            } else {
                times(p+1, o) ans.push_back('c');
            }
        }
    }
    if(debug) { cout << x sp << y sp << z tb; for(char c: ans) cout << c; cout ln; }
    return ans;
}

signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z);

    for(char c: pyon(X, Y, Z)) cout << c;
    cout ln;

    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

// 26文字より少ない → まだ使っていない最小の文字を追加する
// zyx.....cba → -1
// その他→後ろから見ていって最初に下がった場所をカエる（例　~~~~~dzfc → ~~~~~fcqz）
// 

void main(){
	char[] s = readln.chomp.to!(char[]);
	
	if(s.length < 26){
		bool[char] xset;
		foreach(c; s) xset[c] = 1;
		foreach(char c; 'a' .. 'z' + 1){
			if(c !in xset){
				writeln(s ~ c);
				return;
				}
			}
		}
	
	for(int i = 24; i >= 0; i --){
		if(s[i] < s[i + 1]){
			int j1 = i + 1;
			for(int j = i + 1; j <= 25; j ++){
				if(s[i] < s[j]) if(s[j] < s[j1]) j1 = j;
				}
			char[] s2 = s[i .. j1] ~ s[j1 + 1 .. $];
			writeln(s[0 .. i] ~ s[j1]);
			return;
			}
		}
	
	writeln("-1");
	return;
	
	}


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

void init() {
#ifdef MADE_BY_SERT
    freopen("a.in", "r", stdin);
    ///freopen("a.out", "w", stdout);
#endif
}

typedef long long ll;
typedef long double ld;

const double EPS = 1e-9;
const int INF = (int)1e9 + 41;
const int N = (int)1e6 + 34;

void solve() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll g = __gcd(b, d);
    if (d < b || a < b) {
        cout << "No\n";
        return;
    }
    ll st = a % b;
    ll x = (b - st - 1) / g;
    //cerr << st << " " << x << " " << st + x * g << "\n";
    if (c < st + x * g) {
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
}

int main() {
    init();
    int t; cin >> t; while (t--)
	solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}
bool solve() {
  int h, hma; cin >> h >> hma;
  if(h == 0) return false;
  int r, c; cin >> r >> c;
  vector<string> g(r);
  for(int i=0;i<(r);++i) {
    cin >> g[i];
  }
  int t; cin >> t;
  vi mp(26);
  for(int i=0;i<(t);++i) {
    char c; cin >> c;
    int k; cin >> k;
    mp[c-'A'] = k;
  }
  int s; cin >> s;
  vector<int> dr(s), dc(s), num(s);
  for(int i=0;i<(s);++i) {
    char c; cin >> c >> num[i];
    if(c == 'L') {
      dc[i] = -1;
    } else if(c == 'R') {
      dc[i] = 1;
    } else if(c == 'U') {
      dr[i] = -1;
    } else if(c == 'D') {
      dr[i] = 1;
    }
  }
  int p; cin >> p;
  vi tmpv(p);
  for(int i=0;i<(p);++i) {
    cin >> tmpv[i];
  }
  set<P> val;
  for(int i=(1);i<(1<<p);++i) {
    int now = 0;
    for(int j=0;j<(p);++j) {
      if((i>>j)&1) now += tmpv[j];
    }
    val.insert({now, i});
  }
  P pos = {0, 0};
  bool ok = true;
  for(int i=0;i<(s);++i) {
    if(!ok) break;
    for(int j=0;j<(num[i]);++j) {
      int nr = pos.first + dr[i], nc = pos.second + dc[i];
      int nowval = mp[g[nr][nc]-'A'];
      h -= nowval;
      if(h <= 0) {
        auto it = val.lower_bound(make_pair(-h+1, 0));
        if(it == val.end()) {
          ok = false;
          break;
        }
        if(min(h + nowval + it->first, hma) - nowval <= 0) {
          ok = false;
          break;
        }
        h = min(h + nowval + it->first, hma) - nowval;
        int bit = it->second;
        vector<P> er;
        for(auto &e: val) {
          if(e.second & bit) {
            er.emplace_back(e);
          }
        }
        for(auto &e: er) {
          val.erase(e);
        }
      }
      pos = {nr, nc};
    }
  }
  cout << (ok ? "YES" : "NO") << endl;
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(solve()) {}
}



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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	char x;
	cin>>x;
	if( 'a' <= x and x <= 'z' ){
		cout<<'a'<<'\n';
	}else{
		cout<<'A'<<'\n';
	}


	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N - 1);
  for(int i = 0; i < N - 1; i++)
  cin >> B.at(i);
  for(int i = 0; i < N; i++){
    if(i == 0)
    A.at(i) = B.at(i);
    else if(i == N - 1)
    A.at(i) = B.at(i - 1);
    else{
      if(B.at(i) < B.at(i - 1))
      A.at(i) = B.at(i);
      else
      A.at(i) = B.at(i - 1);
    }
  }
  int sum = 0;
  for(int i = 0; i < N; i++)
  sum += A.at(i);
  cout << sum << endl;
}

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

int main(){
    int a=0;
    char c,d;
    cin >> c>>d;
    if(c=='D')a++;
    if(d=='D')a++;
    if(a%2==0)
        cout<<'H'<<endl;
    else
        cout<<'D'<<endl;
    return 0;
}

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

using namespace std;

int main(){
    int K, N;
    while(cin >> K >> N){
        vector<int> A(N);
        for(auto& t : A) cin >> t;
        int res = 0;
        for(int i=0;i+1<N;i++) res = max(res, A[i+1] - A[i]);
        res = max(res, K-A.back()+A[0]);
        cout << (K-res) << endl;
    }
}

Measured memory_bytes: 1024
if __name__ == '__main__':
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    
    d = {}
    for Ai in A:
        if Ai in d.keys():
            d[Ai] += 1
        else:
            d[Ai] = 1
    
    #d_sorted = sorted(d.items(), key=lambda x: x[1])
    
    kosuu = [item[1] for item in d.items()]
    kosuu.sort()
    shuruisuu = len(kosuu)
    
    ans = 0
    cnt = 0
    while K < shuruisuu:
        ans += kosuu[cnt]
        shuruisuu -= 1
        cnt += 1
    
    print(ans)

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

d = 1000000000000
ans_count = 1
for i in range(n):
    ans = t - h[i] * 0.006
    if d > abs(a - ans):
        d = abs(a-ans)
        ans_count = i+1
print(ans_count)

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

class LazySegmentTree {
	const int n;
	const int flag = -1;
	const int id = INT_MAX;
	vector<int> data, data2;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	int sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return id;
		if (data[node] != flag) {
			return data[node];
		}
		if (l <= lb && ub <= r) {
			return data[node] == flag ? data2[node] : data[node];
		}
		int left = node * 2, right = node * 2 + 1;
		if (data[node] != flag) {
			data[left] = data[node];
			data[right] = data[node];
		}
		return min(sub(l, r, node * 2, lb, (lb + ub) / 2), sub(l, r, node * 2 + 1, (lb + ub) / 2, ub));
	}
	void suc(int l, int r, int node, int lb, int ub, int val) {
		if (ub <= l || r <= lb) return;
		if (data[node] == val) return;
		if (l <= lb && ub <= r) {
			data[node] = val;
			return;
		}
		int left = node * 2, right = node * 2 + 1;
		if (data[node] != flag) {
			data[left] = data[node];
			data[right] = data[node];
		}
		data[node] = flag;
		suc(l, r, left, lb, (lb + ub) / 2, val);
		suc(l, r, right, (lb + ub) / 2, ub, val);
		data2[node] = min(data[left] == flag ? data2[left] : data[left], data[right] == flag ? data2[right] : data[right]);
	}
public:
	LazySegmentTree(int n_) :
		n(size(n_)), data(n * 2, id), data2(n * 2, id) {}
	void update(int l, int r, int val) {
		suc(l, r + 1, 1, 0, n, val);
	}
	int find(int l, int r) {
		return sub(l, r + 1, 1, 0, n);
	}
};

int main()
{
	int n, q, b, s, t, x;
	cin >> n >> q;
	LazySegmentTree lst(n);
	while (q--) {
		cin >> b;
		if (b) {
			cin >> s >> t;
			cout << lst.find(s, t) << endl;
		}
		else {
			cin >> s >> t >> x;
			lst.update(s, t, x);
		}
	}
	return 0;
}

Measured memory_bytes: 4948
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n;
  std::cin >> n;
  vvi a(2,vt<int>(n));
  rep(i,2)
    rep(j,n)
      std::cin >> a[i][j];

  vvi dp(3,vt<int>(n+1));

  rep(i,2) {
    rep(j,n) {
      dp[i+1][j+1] = std::max(dp[i][j+1], dp[i+1][j]) + a[i][j];
    }
  }

  std::cout << dp[2][n] << '\n';
  return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout, marker::Chars};

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        c: [Chars; h],
    }
    let mut res = 0;

    for i in 0..((2 as usize).pow(h as u32)) {
        for j in 0..((2 as usize).pow(w as u32)) {
            let mut temp_c = c.clone();
            for ii in 0..h {
                if ((i+1) & (1 << ii)) > 0 {
                    for i_j in 0..w {
                        temp_c[ii][i_j] = 'r';
                    }
                }
            }
            for jj in 0..w {
                if ((j+1) & (1 << jj)) > 0 {
                    for j_i in 0..h {
                        temp_c[j_i][jj] = 'r';
                    }
                }
            }

            // cnt #
            let mut temp_cnt_k = 0;
            for cnt_i in 0..h {
                for cnt_j in 0..w {
                    if temp_c[cnt_i][cnt_j] == '#' {
                        temp_cnt_k += 1;
                    }
                }
            }
            if temp_cnt_k == k {
                res += 1;
            }
        }
    }

    println!("{:?}", res);
}


Measured memory_bytes: 2148
#include<stdio.h>
#include<string.h>

#define SIGN_LENGTH 9
#define CIPHER_NUM 32
#define CODE_MAX 801
#define NUL 0x00
#define INITIALIZE 0
#define TEXT_MAX 100
typedef struct cipher
{
	char charcter_change_sign[SIGN_LENGTH];
	char sign_change_charcter[SIGN_LENGTH];
	char charcter;
}CIPHER;



int main(void)
{
	short i = INITIALIZE;
	short j = INITIALIZE;
	short text_length = INITIALIZE;
	char input_text[TEXT_MAX];
	
	CIPHER code[CIPHER_NUM] = {
		{"100101","00000",'A'},
		{"10011010","00001",'B'},
		{"0101","00010",'C'},
		{"0001","00011",'D'},
		{"110","00100",'E'},
		{"01001","00101",'F'},
		{"10011011","00110",'G'},
		{"010000","00111",'H'},
		{"0111","01000",'I'},
		{"10011000","01001",'J'},
		{"0110","01010",'K'},
		{"00100","01011",'L'},
		{"10011001","01100",'M'},
		{"10011110","01101",'N'},
		{"00101","01110",'O'},
		{"111","01111",'P'},
		{"10011111","10000",'Q'},
		{"1000","10001",'R'},
		{"00110","10010",'S'},
		{"00111","10011",'T'},
		{"10011100","10100",'U'},
		{"10011101","10101",'V'},
		{"000010","10110",'W'},
		{"10010010","10111",'X'},
		{"10010011","11000",'Y'},
		{"10010000","11001",'Z'},
		{"101","11010",' '},
		{"010001","11011",'.'},
		{"000011","11100",','},
		{"10010001","11101",'-'},
		{"000000","11110",'\''},
		{"000001","11111",'?'}
	};
	
	char barcode[CODE_MAX];
	char code_fivecut[160][5];
	
	for(i = 0; i < TEXT_MAX; i++)
	{
		input_text[i] = NUL;
	}

	for(i = 0; i < CODE_MAX-1; i++)//配列の最後(800番目)には\0が入るためマイナス1してある
	{
		barcode[i] = NUL;
	}
	
	for(i = 0; i < 160;i++)
	{
		for(j = 0; j < 5; j++)
		{
			code_fivecut[i][j] = '0';
		}
	}
	
	while(gets(input_text) != NULL)
	{
		for(i = 0; i < TEXT_MAX; i++)
		{
			text_length++;
			if(input_text[i] == NUL)
			{
				break;
			}
		}
		
		for(i = 0; i < text_length; i++)
		{
			for(j = 0; j < CIPHER_NUM; j++)
			{
				if(input_text[i] == code[j].charcter)
				{
					strcat(barcode, code[j].charcter_change_sign);
				}
			}
		}
		
		int barcode_length = 0;
		
		for(i = 0; i < 801; i++)
		{
			barcode_length++;
			if( barcode[barcode_length] == '\0')
			{
				break;
			}
		}
		int c = 0;
		
		for(i = 0; i < barcode_length; i++)
		{
			for(j = 0; j < 5; j++)
			{
				if(c < barcode_length)
				{
					code_fivecut[i][j] =  barcode[c];
					c++;
				}
			}
		}
		int count=0;
		for(i = 0;i < 800 ; i+= 5)
		{
			if(barcode_length <= i)
			{
				count = i / 5;
				break;
			}
		}
		
		int k = 0;
		int cc = 0;
		for(i = 0; i < count; i++)
		{
			for(j = 0; j < CIPHER_NUM; j++)
			{
				for(k = 0; k < 5; k++)
				{
					if(code_fivecut[i][k] == code[j].sign_change_charcter[k])
					{
						cc++;
					}
				}
				if(cc == 5)
				{
					printf("%c",code[j].charcter);
				}
				cc = 0;
			}
		}
		printf("\n");
		count = 0;
		barcode_length = 0;
		text_length = 0;
		for(i = 0; i < TEXT_MAX; i++)
		{
			input_text[i] = NUL;
		}
		for(i = 0; i < 801; i++)
		{
			barcode[i] = NUL;
		}
		
		for(i = 0; i < 160;i++)
		{
			for(j = 0; j < 5; j++)
			{
				code_fivecut[i][j] = '0';
			}
		}
	}
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for (int i=0; i<N; ++i) cin >> l.at(i);
  
  sort(l.begin(), l.end(), greater<int>());
  int length = 0;
  for (int i=0; i<K; ++i) {
    length += l.at(i);
  }
  
  cout << length << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
/*
	vec1.size();
	str1.length();
	vec1.pop_back;
*/
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<pll> vplll;
#define rep(i,l,r) for (ll i = l; i < r; ++i)
#define reprev(i,l,r) for (ll i = r; i >= l; --i)
ll mod = 998244353;
// ll mod = 1e9 + 7;
ll expo_mod(ll x, ll y, ll p) 
{ 
	ll res = 1;
	x = x % p; 
	if (x == 0) 
		return 0; 
	while (y > 0) 
	{
		if (y%2==1) 
			res = (res*x) % p; 
		y = y>>1; // y = y/2 
		x = (x*x) % p; 
	}
	return res; 
} 
ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m,k;
	ll sum,ans,str,val,temp;
	cin>>n>>m>>k;
	sum=0;
	if(m==1 && k==n-1)
	{
		cout<<"1\n";
		return 0;
	}
	ans=m;
	rep(i,0,n-1)
	{
		ans*=(m-1);
		ans%=mod;
	}
	ans%=mod;
	sum+=ans;
	sum%=mod;
	str=expo_mod(m-1,mod-2,mod);

	rep(i,0,k)
	{
		ans*=(n-i-1);
		ans%=mod;
		temp=i+1;
		val=expo_mod(temp,mod-2,mod);
		ans*=val;
		ans%=mod;

		ans*=str;
		ans%=mod;
		
		sum+=ans;
		sum%=mod;
	}
	sum%=mod;
	cout<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 3652
n, k = map(int, input().split())
s = input()

if s[k-1] == "A":
    t = s[:k-1] + "a" + s[k:]
elif s[k-1] == "B":
    t = s[:k-1] + "b" + s[k:]
elif s[k-1] == "C":
    t = s[:k-1] + "c" + s[k:]

print(t)
        


    







        



Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
typedef pair<int, int> PII;
typedef long long ll;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int a, b, ans;
int a1[5002], b1[5002];

int main() {

	cin >> a >> b;
	rep(i, a)cin >> a1[i];
	rep(i, b)cin >> b1[i];

	rep(i, b) {
		int cnt = i;
		rep(k, a) {
			if (cnt != b) {
				if (a1[k] == b1[cnt]) {
					cnt++;
				}
			}
		}
		ans = max(cnt - i, ans);
	}

	cout << ans << endl;

	return 0;
}



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

using namespace std;
#define endl "\n"

const int MOD = 1e9 + 7;

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

    int64_t h , n;
    cin >> h >> n;
    int64_t a[n];

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

    if(h <= sum)
		cout << "Yes\n";
	else
		cout << "No\n";



	return 0;
}


Measured memory_bytes: 1024
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

const R: u64 = 1000000007;

fn main() {
    let n: usize = read();
    let mut a: Vec<u64> = read_vec();

    let mut ans = 0;
    let mut pow = 1;
    for _ in 0..60 {
        let mut c0: u64 = 0;
        let mut c1: u64 = 0;
        for i in 0..n {
            if a[i] % 2 == 0 {
                c0 += 1;
            } else {
                c1 += 1;
            }
            a[i] /= 2;
        }
        ans = ((c0 * c1 % R) * pow % R + ans) % R;
        pow = 2 * pow % R;
    }

    println!("{}", ans);
}


Measured memory_bytes: 15608
x, k, d = map(int, input().split())
if abs(x) / d > k:
    print(abs(x) - d * k)
else:
    c = (-(-abs(x) // d))
    if (k - c) % 2 == 0:
        print(abs(abs(x) - d * c))
    else:
        print(abs(abs(abs(x) - d * c) - d))

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

int main(){
    int n,sum=0;
    cin>>n;
    vector<int> dat(n+5);
    rep(i,n){
        cin>>dat[i];
        sum+=abs(dat[i]-dat[i-1]);
    }
    sum+=abs(dat[n]);
    rep(i,n){
        int now=sum;
        now-=abs(dat[i-1]-dat[i]);
        now-=abs(dat[i]-dat[i+1]);
        now+=abs(dat[i-1]-dat[i+1]);
        cout<<now<<endl;
    }
    return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000000

int main() {
    int A, B, M, i, j, min, price;
    cin >> A >> B >> M;
    vector<int> fr(A);
    vector<int> mr(B);
    vector<vector<int>> discount(M, vector<int>(3));
    for (i = 0; i < A; i++) cin >> fr.at(i);
    for (i = 0; i < B; i++) cin >> mr.at(i);
    for (i = 0; i < M; i++) {
        for(j = 0; j < 3; j++) {
            cin >> discount.at(i).at(j);
        }
    }
    
    for (i = 0; i < M; i++) {
        price = fr.at(discount.at(i).at(0) - 1) + mr.at(discount.at(i).at(1) - 1) - discount.at(i).at(2);
        if (i == 0) min = price;
        else if (price < min) min = price;
    }
    sort(fr.begin(), fr.end());
    sort(mr.begin(), mr.end());
    price = fr.at(0) + mr.at(0);
    if (price < min) min = price;
    cout << min << endl;
}

Measured memory_bytes: 6528
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

class SCC:

    def __init__(self, n):
        self.n = n
        self.graph = [[] for i in range(n)]
        self.graph_rev = [[] for i in range(n)]
        self.used = [False]*n

    def add_edge(self, fr, to):
        if fr == to:
            return
        self.graph[fr].append(to)
        self.graph_rev[to].append(fr)

    def dfs(self, node, graph):
        self.used[node] = True
        for nex in graph[node]:
            if self.used[nex]:
                continue
            self.dfs(nex,graph)
        self.order.append(node)

    def first_dfs(self):
        self.used = [False]*self.n
        self.order = []
        for i in range(self.n):
            if self.used[i]:
                continue
            self.dfs(i,self.graph)
    
    def second_dfs(self):
        self.used = [False]*self.n
        self.ans = []
        for node in reversed(self.order):
            if self.used[node]:
                continue
            self.used[node] = True
            self.order = []
            self.dfs(node, self.graph_rev)
            self.order.reverse()
            self.ans.append(self.order)

    def scc(self):
        self.first_dfs()
        self.second_dfs()
        return self.ans
        

n,m = map(int,input().split())
scc = SCC(n)
for _ in range(m):
    a,b = map(int,input().split())
    scc.add_edge(a,b)

ans = scc.scc()

print(len(ans))
for i in ans:
    print(len(i),*i)

Measured memory_bytes: 200044
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  ll n;
  cin >> n;
  for (double i = 1; i <= 100000.0; ++i)
  {
    if ((int)floor(i * 1.08) == n)
    {
      cout << (int)i << endl;
      return 0;
    }
  }
  Yay(false);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define ll long long 
int n;
vector<int> g[100005];
int d1[100005],d2[100005];
inline void dfs(int r,int f,int d,int dist[])
{
    dist[r]=d;
    for(int x=0;x<g[r].size();x++){
        if(g[r][x]!=f){
        	dfs(g[r][x],r,d+1,dist);
		}
    }
}
int main()
{
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
    	int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0,-1,0,d1);
    dfs(n-1,-1,0,d2);
    int ans=0;
    for(int i=0;i<n;i++){
        if(d1[i]<=d2[i]){
            ans++;
		}
        else{
        	ans--;
        }
    }
    if(ans>0){
    	cout <<"Fennec"<< endl;
	}
    else{
    	cout<<"Snuke"<<endl;
	}
    return 0;
}

Measured memory_bytes: 9984
#include <iostream>
#include <map>

using namespace  std;

int main(int argc, char *argv[])
{
	string S;
	map<string, int> mp;

	mp["SUN"] = 7;
	mp["MON"] = 6;
	mp["TUE"] = 5;
	mp["WED"] = 4;
	mp["THU"] = 3;
	mp["FRI"] = 2;
	mp["SAT"] = 1;

	cin >> S;
	cout << mp[S] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn=110;
char s[maxn];
LL k;

int main()
{
    //freopen("1.txt","r",stdin);
    while (scanf("%s%d",s,&k)!=EOF)
    {
        int ans=0;
        for (ans=0;ans<k;ans++)
            if (s[ans]!='1')
                break;

        printf("%c\n",ans==k?s[ans-1]:s[ans]);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll long long 

int n,d;
int ans;
int x[100][100];


bool che(int a,int b){
    int dis=0;
    
    rep(i,d)dis+=(x[a][i]-x[b][i])*(x[a][i]-x[b][i]);
    
    for(int i=0;i<=dis;i++)if(i*i==dis)return 1;
    return 0;
}
int main(){
    cin>>n>>d;
    rep(i,n)rep(j,d)cin>>x[i][j];
    
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(che(i,j))ans++;
        }
    }
    
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>


using namespace std;

int main() {
	string s;
	cin >> s;
	if (s == "Sunny") {
		cout << "Cloudy" << endl;
	}
	if (s == "Cloudy") {
		cout << "Rainy" << endl;
	}
	if (s == "Rainy") {
		cout << "Sunny" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		List<Integer> listH = new ArrayList<Integer>();
		List<Integer> listW = new ArrayList<Integer>();
		for(;;){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if((H == 0) && (W == 0)){
				break;
			}
			listH.add(H);
			listW.add(W);
		}

		for(int i = 0; i < listH.size(); i++){
			int h = listH.get(i);
			int w = listW.get(i);
			for(int j = 0; j < h; j++){
				for(int k = 0; k < w; k++){
					if((j == 0) || (j == h - 1) || (k == 0) || (k == w - 1)){
						System.out.print("#");
					} else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}

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

int main() {
	int N;
	int M;

	cin >> N;
	cin >> M;

	int a = N * (N - 1) / 2;
	int b = M * (M - 1) / 2;

	int c = a + b;
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;
int main() {
	long long n;
	cin >> n;
	vector<long long>d(n, 0);
	for (long long i = 0; i < n; i++)cin >> d[i];
	long long m;
	cin >> m;
	vector<long long>t(m, 0);
	for (long long i = 0; i < m; i++)cin >> t[i];
	sort(d.begin(), d.end());
	sort(t.begin(), t.end());
	long long begin = 0;
	for (long long i = 0; i < m; i++) {
		for (long long j = begin; j < n; j++) {
			if (d[j] == t[i]) {
				begin = j + 1;
				break;
			}
			else if (d[j] > t[i]) {
				cout << "NO";
				return 0;
			}

		}
	}
	cout << "YES";
	return 0;
}





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

using namespace std;

int main(int argc, char* argv[])
{
  int N, W;
  cin >> N >> W;
  vector<int> v(N);
  vector<long long> w(N);
  for (int i=0; i<N; i++) {
    cin >> w[i] >> v[i];
  }
  int V=0; // maximum possible value
  for (int i=0; i<N; i++) {
    V += v[i];
    //cout << w[i] << " " << v[i] << "\n";
    //cout << V << "\n";
  }  
  vector< vector<long long> > c(N);
  for (int i=0; i<N; i++) c[i].resize(V+1);
  // c[i][j] = minimum cost of achiving at least value j with items up to i
  long long INF = W + 1;  // impossibly large cost
  
  for (int i=0; i < N; i++) {
    c[i][0] = 0;
    for (int j=1; j<=V; j++) {
      if (i == 0) {
        if (v[i] < j) {
          c[i][j] = INF; 
        } else {
          c[i][j] = w[i];
        }
      } else {
        c[i][j] = min(INF, min(c[i-1][j], c[i-1][max(0, j - v[i])] + w[i]));
      }
      //cout << i << ", " << j << " cost " << c[i][j] << "\n";
    }    
  }
  
  for (int j=V; j>=0; j--) {
    //cout << j << " " << c[N-1][j] << "\n";
    if (c[N-1][j] <= W) {
      cout << j << "\n";
      break;
    }
  }  
  return 0;
}


Measured memory_bytes: 78592
def check(a, b):
    for i, j in zip(a, b):
        if i == "?" or i == j:
            pass
        else:
            return False
    return True


def make(a):
    x = ""
    for i in a:
        if i == "?":
            x += "a"
        else:
            x += i
    return x


s = list(input())
t = list(input())
n = len(t)
ans = []
for i in range(len(s)-n+1):
    if check(s[i:n+i], t):
        w = s[:i] + t + s[n+i:]
        ans.append(make(w))

if len(ans) == 0:
    print("UNRESTORABLE")
else:
    print(min(ans))



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

int main () {
  int N, X;
  cin >> N >> X;
  vector<int> x(N), y(N+1), z(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
    y.at(i) = x.at(i);
  }
  y.at(N) = X;
  sort(y.begin(), y.end());
  for (int i = 0; i < N; i++) {
    z.at(i) = y.at(i+1)-y.at(0);
  }
  for (int i = 0; i < N-1; i++) {
    int a = z.at(i+1), b = z.at(i);
    int r = a%b;
    while (r != 0) {
      a = b;
      b = r;
      r = a%b;
    }
    z.at(i+1) = b;
  }
  cout << z.at(N-1) << endl;
}
    

Measured memory_bytes: 1408
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string input = ReadLine();
        string even = ReadLine();
//        int studen = int.Parse(input[0]);
//        int checkp = int.Parse(input[1]);
//        int c = int.Parse(input[2]);
        int leng = input.Length + even.Length;
        string ans ="";
        for(int i=0;i<leng;i++){
            if(i%2==0){
                ans += input[i/2].ToString();
            }else{
                ans += even[i/2].ToString();
            }
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while (1) {
        int N,Q; cin >> N >> Q;
        if (N+Q==0) break;
        map<int, int> dic;
        rep(i,N) {
            int M; cin >> M;
            rep(j,M) {
                int a; cin >> a;
                dic[a]++;
            }
        }
        int ans = 0;
        int cnt = Q-1;
        for (auto i : dic) {
            if (chmax(cnt,i.second)) ans = i.first;
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3144
#include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;
int N,M,K;
int dist[3005];
vector<int> to[3005],len[3005];
bool visited[3005];

int main(void){
	cin>>N>>M>>K;
	int a,b,l;
	for(;M--;){
		cin>>a>>b>>l;
		--a;--b;
		to[a].push_back(b);
		to[b].push_back(a);
		len[a].push_back(l);
		len[b].push_back(l);
	}
	
	for(int i=0;i<N;i++){
		dist[i] = 1000000000;
		visited[i]=false;
	}
	
	for(;K--;){
		cin>>a;
		dist[--a] = 0;
	}//??\???&?????????
	
	for(int i=0;i<N;i++){//dijkstra??¨?¨????????????? ????????????????????????????±???????
		int mark=-1;//?????????????????????????????¢????????????????????? ?????????????£???????
		for(int j=0;j<N;j++){
			if(!visited[j] && (mark==-1 || dist[mark] > dist[j])) mark = j;
		}
		visited[mark] = true;//???????¢????
		
		for(int j=0;j<to[mark].size();j++){
			int ikisaki=to[mark][j],distkouho=dist[mark]+len[mark][j];
			if(dist[ikisaki]>distkouho)dist[ikisaki]=distkouho;
		}
		
	}
	int ans=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<to[i].size();j++){
			ans = max(ans,dist[i]+dist[to[i][j]]+len[i][j]);
		}
	}
	ans=(ans+1)/2;
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 4196
(defun app ()
    (let* ((n (read))
        (m (read))
        (a (make-array n :initial-element 0))
        (sum 0)
        (ans "Yes"))
        (dotimes (i n)
            (setf (aref a i) (read))
            (incf sum (aref a i))
        )
        (sort a '>)

        (dotimes (i m)
        (if (< (aref a i) (/ sum (* 4 m)))
            (setq ans "No")
        )
        )
    (format t "~A~%" ans)
    )
)

(app)

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

#define maxn 500005
int a[27][maxn];

int sum(int ch, int idx)
{
	int result = 0;
	while(idx>0)
	{
		result += a[ch][idx];
		idx -= idx & (-idx);   
	}
	return result;
}
 
void add(int ch, int n, int idx, int val)
{	
	while(idx<=n)
	{
		a[ch][idx] += val;
		idx += idx & (-idx); 
	}
}
int query(int ch, int l, int r)
{
	return sum(ch, r) - sum(ch, l-1);
}
signed main()
{
	//freopen("input.txt", "r", stdin);
	
	int n; cin >> n;
	string s; cin>>s;
	memset(a, 0, sizeof(a));
	for(int i=0; i<n; i++)
	{
		int ch = s[i] - 'a' + 1;
		add(ch, n, i+1, 1);
	}
	
	int q; cin>>q;
	while(q--)
	{
		int type; cin>>type;
		if(type == 1)
		{
			int pos; cin>>pos;
			char letter; cin>>letter;
			int to_be = 0;
			for(int i=1; i<27; i++)
			{
				if(query(i, pos, pos))
				{
					to_be = i;
					break;
				}
			}
			add(to_be, n, pos, -1);
			int ch = letter - 'a' + 1;
			add(ch, n, pos, 1);
		}
		else
		{
			int l, r; cin>>l>>r;
			int ans = 0;
			for(int i=1; i<27; i++)
			{
				if(query(i, l, r) > 0)
					ans++;
			}
			cout<<ans<<"\n";
		}
	}
}


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

#define int __int128_t
#define MOD (int)1000000007

using namespace std;

signed main()
{
    signed n;
    cin >> n;

    int sum = 0;
    int msum = 0;
    int ssum = 0;
    for (int i = 0; i < n; i++)
    {
        long long t;
        cin >> t;
        sum += t;
        //sum %= MOD;
        ssum += t * t;
        //ssum %= MOD;
    }

    //sum %= MOD;
    msum = sum * sum;
    //msum %= MOD;

    signed ans = ((msum - ssum) / 2 + MOD) % MOD;
    cout << ans << endl;
}

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

int main(){
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC"  << endl;
    else cout << "ABC" << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
 
    long long ans = 0;
    int MaxNum = 0;
    for (int i = 0; i < N; i++)
    {
        //Use common MaxNum to reduce the compuation time
        MaxNum = max(MaxNum, A[i]);
        int Bi = MaxNum;
        ans += Bi - A[i];
    }
 
    cout << ans << endl;
}

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

int main(){

    string a,b,c;

    cin >> a >> b >> c;

    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  int n,x,y;
  cin >> n;
  vector<pair<int,int> > p(n);
  for(int i=0; i<n; i++) {
      cin >> x >> y;
      p[i]=make_pair(x,y);
  }
  sort(p.begin(),p.end());
  for(int i=0; i<n; i++) {
      cout << p[i].first << " " << p[i].second << endl;
  }
}


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

using namespace std;

int main(void)
{
  int N, Q;
  cin >> N >> Q;
  string str;
  cin >> str;
  vector<int> numAC(N);
  int cnt = 0;
  numAC[0] = 0;

  for(int i = 1; i < N; i++){
    string s2 = str.substr(i-1, 2);
    if(s2 == "AC"){
      cnt++;
    }
    numAC[i] = cnt;
  }
  vector<int> ans(Q);
  for(int i = 0; i < Q; i++){
    int l, r;
    cin >> l >> r;
    int ac = numAC[r-1] - numAC[l-1];
    //cout << numAC[r-1] << " " << numAC[l-1] << emdl;;
    ans[i] = ac;
  }

  for(int i = 0; i < Q; i++){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 1792
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}



int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;

      bool flag=false;

      string str;


        cin>>str;


        cnt=0;
           if(str[0]==str[1] && str[1]==str[2] && str[0]=='R')cnt=3;

           else if( str[1]==str[2] && str[1]=='R')cnt=2;

           else if(str[0]==str[1] && str[0]=='R')cnt=2;

           else if(str[0]=='R' || str[1]=='R' || str[2]=='R')cnt=1;


           cout<<cnt<<endl;







}



Measured memory_bytes: 3640
using System;
  
class hoge
{
    static void Main(String[] args)
    {
        String input = Console.ReadLine();
        String[] splittedInput = input.Split(null);
        int x = int.Parse(splittedInput[0]);
        int y = int.Parse(splittedInput[1]);
        Console.WriteLine("{0} {1}", x*y, x*2+y*2);
  
}}

Measured memory_bytes: 9060