akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = -1;
constexpr ll MOD = 1e9 + 7;

int d[100005];
int d2[100005];
int n, m;
int s, t;
vector<vector<int>> G(100005);

int bfs()
{
    queue<int> que;
    REP(i, n + 3)
    d[i] = INF;
    que.push(s);
    d[s] = 0;
    while (que.size())
    {
        int p = que.front();
        que.pop();
        if (p == t)
            break;
        for (auto ite = G[p].begin(); ite != G[p].end(); ++ite)
        {
            for (auto ite2 = G[*ite].begin(); ite2 != G[*ite].end(); ++ite2)
            {
                if (d2[*ite2] == 0){
                for (auto ite3 = G[*ite2].begin(); ite3 != G[*ite2].end(); ++ite3)
                {
                    if (d[*ite3] == INF)
                    {
                        que.push(*ite3);
                        d[*ite3] = d[p] + 1;
                    }
                }
                d2[*ite2] = 1;
                }
            }
        }
        if (d[t] != INF)
            break;
    }
    return d[t];
}

int main()
{
    ciosup;
    cin >> n >> m;
    REP(i, m)
    {
        int u, v;
        cin >> u >> v;
        G[u].eb(v);
        //G[v].eb(u);
    }
    cin >> s >> t;
    cout << bfs() << endl;
}

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

int main() {
	int64_t N;
	cin >> N;
	int digit = 0, top; // それぞれ桁数-1と最上位の数字
	bool isAllNine = true;
	while (N >= 10) {
		isAllNine &= N % 10 == 9; // 9が連続している限りisAllNineはtrueになる
		digit ++;
		N /= 10;
	}
	top = N;
	if (isAllNine) { // 全て9だった
		cout << digit * 9 + top;
	} else {
		cout << digit * 9 + top - 1;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

まず、Nの上から二桁目以降が99...9ならば、Nの桁数-1の9倍+最上位の桁を出力すればおｋ 要するにNそのものの和だな
次に、そうではないときを考える
その時、Nの最上位の桁を1個下げる
例えば、3141592653589793ならば、2...を考える
後は全部9で埋めてしまうと、2999999999999999になり、これが最大
よって(Nの桁数-1)の9倍+Nの最上位の桁-1を出力すればおｋ
*/

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

const int MAX = 100007;
const int MOD = 1000000007;

void solve() {
    int n, k, h[MAX];
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> h[i + 1];
    }
    int dp[MAX];
    dp[1] = 0;
    for (int i = 2; i <= k; i++) {
        int mn = 2147483647;
        for (int j = 1; j < i; j++) {
            mn = min(mn, dp[i - j] + abs(h[i] - h[i - j]));
        }
        dp[i] = mn;
    }
    for (int i = k + 1; i <= n; i++) {
       int mn = 2147483647;
       for (int j = 1; j <= k; j++) {
           mn = min(mn, dp[i - j] + abs(h[i] - h[i - j]));
       }
       dp[i] = mn;
    }
    cout << dp[n];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("in.in", "r", stdin); freopen("out.out", "w", stdout);
    //int tt; cin >> tt; for (int i = 1; i <= tt; i++) {cout << "Case #" << i << ": "; solve();}
    solve();
}

Measured memory_bytes: 4352
const p = (...args) => {
  process.env.NODE_ENV === "test" ? console.log(...args) : ""
}

const tupple = (obj, mark) => {
  return Object.keys(obj).map((key) => {
    const value = obj[key]
    return {
      key,
      value,
      mark
    }
  })
  // .sort((a, b) => b.value - a.value)
}

const calc = (n, a, b) => {
  if (a[0].key !== b[0].key) {
    return n - a[0].value - b[0].value
  }
  if (b.length > 1) {
    return n - a[0].value - b[1].value
  }
  return n - a[0].value
}
const solve = (input) => {
  let [n, rest] = input.split("\n")

  // let odd = []
  let oddNum = {}
  // let even = []
  let evenNum = {}
  const vs = rest.split(" ").map(Number)
  n = vs.length
  vs.forEach((v, i) => {
    if (i % 2 == 0) {
      // even.push(v)
      evenNum[v] = (evenNum[v] || 0) + 1
    } else {
      // odd.push(v)
      oddNum[v] = (oddNum[v] || 0) + 1
    }
  })
  const odd2 = tupple(oddNum).sort((a, b) => b.value - a.value)
  const even2 = tupple(evenNum).sort((a, b) => b.value - a.value)
  return Math.min(calc(n, odd2, even2), calc(n, even2, odd2))
}

if (process.env.NODE_ENV === "test") {
  module.exports = (input) => solve(input.trim())
} else {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(solve(input.trim()))
}


Measured memory_bytes: 37300
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second

using namespace __gnu_pbds;
using namespace std;
const int mod = 1e9 + 7;
// const int mod=998244353;
//const int mod=1e9+9;
//const int INF=4e18+10;
const int INF = 4e18 + 10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) \
int n;      \
cin >> n;
#define readv(x, n)   \
vector<int> x(n); \
for (auto &i : x) \
    cin >> i;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template <typename T1, typename T2>
void set_min(T1 &a, T2 b)
{
    a = min(a, (T1)b);
}

int multiply(int a, int b, int in_mod) { return (a * b) % in_mod; }
int mult_identity(int a) { return 1; }


auto power(auto a, int b, int in_mod)
{
    auto prod = mult_identity(a);
    auto mult = a % in_mod;
    while (b != 0)
    {
        if (b % 2)
        {
            prod = multiply(prod, mult, in_mod);
        }
        mult = multiply(mult, mult, in_mod);
        b /= 2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod - 2, in_mod);
}
void solve()
{

    int n, m;
    cin>>n>>m;
    int ans = n*m;
    if(m>1)
    ans -= 2*n;
    if(n>1)
        ans-=2*m;
    if(n>1 && m>1)
        ans+=4; 
    cout<<ans<<endl;

}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cerr.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t = 1;
    // cin >> t;

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<":\n";
        //cout<<"Trip #"<<test<<": ";
        // cout<<endl;
        solve();
        // solveB();

        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


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

using namespace std;

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

  if(N>3199)
    cout << S << endl;
  else
    cout << "red" << endl;


  return 0;
}



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

int main()
{
  int n; cin>>n;
  vector<set<int>> vst(26);
  string s; cin>>s;
  for (int i=0; i<(int)(s.size()); i++) {
    vst[s[i]-'a'].insert(i);
  }
  int q; cin>>q;
  vector<int> ans;
  rep(i, q) {
    int a; cin >> a;
    if (a==1) {
      int b; cin >> b; b--;
      char c; cin >> c;
      rep(j, 26) vst[j].erase(b);
      vst[c-'a'].insert(b);
    } else {
      int b, c; cin>>b>>c; b--; c--;
      int sum = 0;
      rep(i, 26) {
        auto itr = vst[i].lower_bound(b);
        if (itr == vst[i].end()) continue;
        if (*itr <= c) sum++;
      }
      ans.push_back(sum);
    }
  }
  for (auto v:ans) cout << v << endl;

  return 0;
}


Measured memory_bytes: 24452
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n),b(n);
  ll suma=0,sumb=0;
  rep(i,n){
    cin >> a.at(i);
    suma+=a.at(i);
  }
  rep(i,n){
    cin >> b.at(i);
    sumb+=b.at(i);
  }
  if(sumb>suma){
    cout << -1;
    return 0;
  }
  ll p=0,ans=0;
  rep(i,n){
    if(b.at(i)-a.at(i)>0){
      p+=b.at(i)-a.at(i);
      ans++;
    }
  }
  vector<ll> an;
  rep(i,n){
    if(a.at(i)>b.at(i)){
      an.push_back(a.at(i)-b.at(i));
    }
  }
  sort(an.begin(),an.end());
  reverse(an.begin(),an.end());
  rep(i,n){
    if(p<=0){
      break;
    }
    p-=an.at(i);
    ans++;
  }
  cout << ans;
}

Measured memory_bytes: 5428
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
const int INF=1e9+5;
typedef long long ll;

int main() {
  ll a[5],ans;
  for(int i=0;i<5;i++){
    cin>>a[i];
    if(a[i]==0){
      ans=i+1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
typedef long long int   ll;
typedef long double     ld;
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define GCD(a, b)       __gcd(a, b)
#define pi              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
using namespace std;


int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)
        cout<<"bust";
    else
        cout<<"win";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int N, i, cnt=1;
  cin >> N;
  vector<int> vec(N);
  for (i=0; i<vec.size(); i++)
    cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for (i=1; i<vec.size(); i++) {
    if (vec.at(i)!=vec.at(i-1))
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

int t[1234];

void solve() {
	int n; scanf("%d", &n);
	long long sum = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d", t+i);
		sum += t[i];
	}
	int m; scanf("%d", &m);
	for (int i = 0; i < m; ++i) {
		int p, x; scanf("%d%d", &p, &x);
		printf("%lld\n", sum-t[p-1]+x);
	}
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 384
# 何となく分かったが、0の扱いが結構怪しい、解き直し必要

n = int(input())

xyh = []
for i in range(n):
    xyh.append(list(map(int, input().split())))
xyh.sort(key=lambda x: x[2], reverse=True)

for i in range(101):
    for j in range(101):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        flag = True
        for k in range(1, n):
            if xyh[k][2] == 0:
                if abs(xyh[k][0] - i) + abs(xyh[k][1] - j) < h:
                    flag = False
                    break
            else:
                temp = xyh[k][2] + abs(xyh[k][0] - i) + abs(xyh[k][1] - j)
                if h != temp:
                    flag = False
                    break
        if flag == True and h >= 1:
            print(i, j, h)
            exit()


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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main(){
    int n;
    cin >> n;
    vector<int> a, buka;
    rep(i, n){
        buka.push_back(0);
    }
    rep(i, n-1){
        int sen;
        cin >> sen;
        // a.push_back(sen);
        buka[sen-1]++;
    }
    rep(i, n){
        cout << buka[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4316
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

const int N=1e5+19;

int A[N],B[N],C[N];
int n,m,res;

void work(int &x,int &y){
	int tmp=min(x,y);
	x-=tmp,y-=tmp,res+=tmp;
}

int main(){
	n=IN();m=IN();
	For(i,0,n) A[IN()]++;
	For(i,0,N){
		B[i%m]+=A[i]%2;
		C[i%m]+=A[i]-A[i]%2;
	}
	for (int i=1;2*i<m;i++){
		work(B[i],B[m-i]);
		work(B[i],C[m-i]);
		work(C[i],B[m-i]);
		res+=C[i]/2;
		res+=C[m-i]/2;
	}
	if (m%2==0) res+=(B[m/2]+C[m/2])/2;
	res+=(B[0]+C[0])/2;
	printf("%d\n",res);
}

Measured memory_bytes: 1408
N, M = map(int,input().split())                                         # N:ノード数、M:エッジ数
visited = [False for i in range(N)]                                     # ノードの訪問済みフラグ
edges = [[i-1 for i in map(int,input().split())] for j in range(M)]     # エッジ情報のインプット
graph = [[False for i in range(N)] for j in range(N)]                   # 接続行列の入れ物

# 各エッジについて、情報を接続行列に埋め込む
for edge in edges:
    graph[edge[0]][edge[1]] = True
    graph[edge[1]][edge[0]] = True

# dfs:ノードvについて、エッジで接続した未訪問のノードを即時訪問する(再帰処理)
def dfs(v):
    queue = [v]
    while len(queue) != 0:
        now = queue.pop(0)
        visited[now] = True
        for next in range(N):
            if graph[now][next] == False:continue
            if visited[next] == True:continue
            queue.append(next)

ans = 0

# 各エッジを取り除いたとき、dfsして未訪問のノードが残っていれば、そのエッジは橋
for i in range(M):
    graph[edges[i][0]][edges[i][1]] = False
    graph[edges[i][1]][edges[i][0]] = False

    for j in range(N):
        visited[j] = False

    dfs(0)

    bridge = False
    for j in range(N):
        if visited[j] == False:
            bridge = True
    if bridge:
        ans += 1

    graph[edges[i][0]][edges[i][1]] = True
    graph[edges[i][1]][edges[i][0]] = True

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>

int H[2000001],size;

void MaxHeapify(int pos){
	int L=pos*2, R=pos*2+1,largest,tmp;

	if(L<=size && H[L]>H[pos])largest=L;
	else largest=pos;

	if(R<=size && H[R]>H[largest])largest=R;

	if(largest!=pos){
		//swap
		tmp=H[pos];
		H[pos]=H[largest];
		H[largest]=tmp;

		MaxHeapify(largest);
	}

	return;
}

void Insert(int key){
	int pos,tmp;
	H[++size]=key;

	pos=size;

	while(pos/2>0 && H[pos/2]<H[pos]){
		//swap
		tmp=H[pos];
		H[pos]=H[pos/2];
		H[pos/2]=tmp;

		pos/=2;
	}

	return;
}

int Extract(void){
	int ret=H[1];
	H[1]=H[size];	--size;
	MaxHeapify(1);

	return ret;
}

int main(){
	int k;
	char com[10];

	while(1){
		scanf("%s",com);
		if(com[0]=='i'){
			//insert
			scanf("%d",&k);
			Insert(k);

		}else{
			if(com[2]=='d')break;

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

	return 0;
}



Measured memory_bytes: 5708
#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.at(2)==S.at(3))&&(S.at(4)==S.at(5))){
        cout << "Yes"<< endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
/////16:25~
/////A:16:34
/////B:16:42
/////C:17:48

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
#define ll long long

ll n, m;
ll MAX_M = 1000000;
ll t[111111];

bool flg[111111];

bool canClear(ll x)
{

    ll level = 1;
    ll cnt = 0;
 

    //solved=0LL;

    // //倒した敵を数える
    // for(int i=0;i<n;i++){
    //     if(flg[i])solved++;
    //     else break;
    // }

    //if(solved==n)break;

    //cout<<solved<<" "<<x+level<<endl;

    /*if(t[solved]<x+level){
            //cout<<solved<<" "<<"I"<<level<<" ";
            flg[solved]=1;
            solved++;
            level+=max(1LL,x-abs(level-t[solved-1]));
        }*/

    //else{

    while (true)
    {

        if (t[n - 1] < x + level)
        {
            cnt++;
            break;
        }

        int pos = lower_bound(t, t + n, level) - t;
        ll levelup = x - abs(level - t[pos]);

        if (pos > 0)
            levelup = max(levelup, x - abs(level - t[pos - 1]));

        level += max(1LL, levelup);

        cnt++;
    }

    return cnt >= m;
}

int main()
{

    while (cin >> n >> m, n || m)
    {
        for (int i = 0; i < n; i++)
            cin >> t[i];

        ll ng = t[0]-1, ok = MAX_M + 1;
        ll mid;
        while (abs(ok - ng) > 1)
        {
            mid = (ok + ng) / 2;

            if (canClear(mid))
            {
                ng = mid;
            }
            else
            {
                ok = mid;
            }
        }
        if(ng==t[0]-1){
           cout<<-1<<endl;
        }
        else{
            cout<<ng<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3844
//Spreadseat
#include<iostream>
using namespace std;

int main()
{
	int r, c, a[101][101];
	for(int i = 0; i < 101; i++)
		for(int j = 0; j < 101; j++)
			a[i][j] = 0;
			
	cin >> r >> c;
	for(int i = 0; i < r; i++)
		for(int j = 0; j < c; j++)
			cin >> a[i][j];
			
	for(int i = 0; i < r; i++)
		for(int j = 0; j < c; j++){
			a[i][c] += a[i][j];
			a[r][c] += a[i][j];
		}
			
	for(int j = 0; j < c; j ++)
		for(int i = 0; i < r; i++)
			a[r][j] += a[i][j];
	
	for(int i = 0; i <= r; i++){
		for(int j = 0; j < c; j++){
			cout << a[i][j] << " ";
		}
		cout <<a[i][c] << endl;
	}
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
 
using namespace std;
#define ll  long long
#define ld  long double
 
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN=1e5 + 5;
int main() {
    int n,r;
    cin>>n>>r;
    if(n<10)
    {
        cout<<100*(10-n)+r<<endl;
    }
    else
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 256
// Cursor jump numbers
// main @ 39
// global @ 35
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long int
#define MOD ((int)(1e9) + 7)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string inp;
  cin >> inp;
  if(inp.compare("SUN") == 0) {
    cout << 7;
  } else if(inp.compare("MON") == 0) {
    cout << 6;
  } else if(inp.compare("TUE") == 0) {
    cout << 5;
  } else if(inp.compare("WED") == 0) {
    cout << 4;
  } else if(inp.compare("THU") == 0) {
    cout << 3;
  } else if(inp.compare("FRI") == 0) {
    cout << 2;
  } else if(inp.compare("SAT") == 0) {
    cout << 1;
  }
  cout << '\n';
  return 0;
}



Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

main :: IO ()
main = do
    [n,m] <- r'
    sss <- (map tail <$> replicateM m r') :: IO [[Int]]
    ps <- map (==1) <$> r' :: IO [Bool]
    let bulbAndSwitches = zip ps sss :: [(Bool, [Int])]
    let res = map (\st -> --traceShow st $
                let bulbOn = map (\(p,ss) -> count st ss p) bulbAndSwitches :: [Bool]
                in {-traceShow (bulbOn, and bulbOn) $-} and bulbOn
            ) (onoffV n) :: [Bool]
    print $ length $ filter id res



count :: U.Vector Bool -> [Int] -> Bool -> Bool
count vec iis b = odd (length (filter id $ sublist vec iis)) == b

sublist :: U.Vector Bool -> [Int] -> [Bool]
sublist vec chos = map ((vec U.!) . pred) chos


onoffV :: Int -> [U.Vector Bool]
onoffV m = map U.fromList (onoff m)

onoff :: Int -> [[Bool]]
onoff 0 = [[]]
onoff m = do
    s <- [True,False]
    map (s:) (onoff (m-1))




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

int n;
vector<int> g[100010];
int pre[100010];
int b[100010];
int x,y;
vector<int> ans;
int a[3];

void dfs(int o,int fa=-1)
{
	for (int i=0;i<g[o].size();i++)
		if (g[o][i]!=fa) 
		{
			pre[g[o][i]]=o;
			dfs(g[o][i],o);
		}
}

void dfs2(int o,int fa=-1)
{
	for (int i=0;i<g[o].size();i++)
		if (g[o][i]!=fa) 
		{
			if (b[g[o][i]]==0) b[g[o][i]]=b[o];
			dfs2(g[o][i],o);
		}
}

int main()
{
    ios::sync_with_stdio(false);
	cin>>n;
	for (int i=1;i<n;i++)
	{
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(1);
	int i=n;
	while (i)
	{
		ans.push_back(i);
		i=pre[i];
	}
	for (i=0;i<ans.size()/2;i++) b[ans[i]]=2;
	for (;i<ans.size();i++) b[ans[i]]=1;
	dfs2(1);dfs2(n);
	for (int i=1;i<=n;i++) a[b[i]]++;
	if (a[1]>a[2]) cout<<"Fennec"<<endl;else cout<<"Snuke"<<endl;
}

Measured memory_bytes: 13304
#include <iostream>
#include <vector>
#include <cmath>
 
using namespace std;
int main()
{
  long A, B, K;
  cin >> A >> B >> K;
  if (A>=K) {
    A -= K;
  } else {
    K -= A;
    A = 0;
    if (B>=K) {
      B -= K;
    } else {
      B = 0;
    }
  }
  printf("%ld %ld\n", A, B);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

  int a,b,n;

  int s;

  int temp;


  while(cin >> a >> b >> n) {

    s=0;

    for(int i=0;i<n;i++) {

      if(i==0) {

	s+=((10*a)/b)%10;

	temp=(10*a)%b;

      }

      else {

	s+=(10*temp)/b;

	temp=(10*temp)%b;

      }

    }

    cout << s << endl;

  }

  return 0;

}

Measured memory_bytes: 0
N, K = gets.chomp.split(" ").map(&:to_i)
R, S, P = gets.chomp.split(" ").map(&:to_i)
T = gets.chomp

t = T.chars.map {|c|
  case c
  when "r" then
    "p"
  when "s" then
    "r"
  when "p" then
    "s"
  end
}.join

chars = t.chars.reverse

i = 0
while i < chars.size do
  if chars[i] == chars[i+K] then
    chars[i+K] = "x"
  end
  i += 1
end

chars = chars.reverse

sum = 0
chars.each do |c|
  case c
  when "r" then
    sum += R
  when "s" then
    sum += S
  when "p" then
    sum += P
  end
end

puts sum

Measured memory_bytes: 18556
#include <iostream>
#include<string>

using namespace std;

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

	int n;
	int n_sum = 0;
	int S_sum = 0;

	for (int i = 1; i <= N; i++) {
		n = i;
		for (int j = 0; j < 5; j++) {
			n_sum += n % 10;
			n /= 10;
			if (n == 0) break;
		}
		if (n_sum >= A && n_sum <= B) S_sum += i;
		n_sum = 0;
	}

	cout << S_sum << "\n";

	return 0;
}

Measured memory_bytes: 256
a,s[104],r[104],n,i,j;main(b){for(scanf("%d",&n);~scanf("%d%d%d%d",&a,&b,s,r);)*s-*r?s[*s>*r?a:b]+=3:++s[a]-++s[b];for(;i++-n;)for(a=0;a++-n;)r[i]+=s[i]<s[a];for(;j++-n;)printf("%d\n",r[j]+1);exit(0);}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    int n, m, l, k, a, h;
    cin >> n >> m >> l >> k >> a >> h;
    if (n + m + l + k + a + h == 0) return 0;
    
    vector<bool> freeze(n, false);
    for (int i = 0; i < l; i++) {
      int x;
      cin >> x;
      freeze.at(x) = true;
    }
    
    vector<vector<pair<int, ll>>> G(n); // G:頂点数nのグラフの隣接リスト
    for (int i = 0; i < k; i++) {
      int u, v;
      ll w;
      cin >> u >> v >> w;
      G[u].emplace_back(make_pair(v, w));
      G[v].emplace_back(make_pair(u, w)); // 有向グラフではコメントアウト
    }
    
    vector<vector<ll>> dp(n, vector<ll>(m + 1, 1e18));
    dp.at(a).at(m) = 0;
    queue<tuple<ll, ll, int>> q; // 累計時間, 制限時間, 頂点
    q.push(make_tuple(0, m, a));
    while (!q.empty()) {
      tuple<ll, ll, int> t = q.front();
      q.pop();
      ll total = get<0>(t), rest = get<1>(t);
      int node = get<2>(t);
      for (int i = 0; i < G[node].size(); i++) {
        if (rest < G[node][i].second) continue;
        if (dp.at(G[node][i].first).at(rest - G[node][i].second) > total + G[node][i].second) {
          dp.at(G[node][i].first).at(rest - G[node][i].second) = total + G[node][i].second;
          q.push(make_tuple(total + G[node][i].second, rest - G[node][i].second, G[node][i].first));
        }
      }
      if (rest < m) {
        if (dp.at(node).at(rest + 1) > total + 1 && freeze.at(node)) {
          dp.at(node).at(rest + 1) = total + 1;
          q.push(make_tuple(total + 1, rest + 1, node));
        }
      }
    }
    
    ll ans = 1e18;
    for (int i = 0; i <= m; i++) {
      if (dp.at(h).at(i) < ans) ans = dp.at(h).at(i);
    }
    
    if (ans == 1e18) cout << "Help!\n";
    else cout << ans << '\n';
  }
}


Measured memory_bytes: 3296
n = int(input())
a = []
for i in range(1, n+1):
    s,p = map(str,input().split())
    a.append((s,int(p),i))
a.sort()
ans = [a[0][2]]
k = 0
for i in range(1,n):
    if a[i-1][0] == a[i][0]:
        ans.insert(k,a[i][2])
    else:
        k = i
        ans.append(a[i][2])

for i in range(n):
    print(ans[i])





Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val x = readLine()!!.toInt()

    val max = Math.min(x * 2, 100004)
    val arr = BooleanArray(max+1) { false }
    var i = 3
    while(i <= max) {
        if (!arr[i]) {
            var j = i+i
            while(j <= max) {
                arr[j] = true
                j += i
            }
        }
        i += 2
    }
    i = x
    if (i != 2 && i % 2 == 0) i++
    while (arr[i]) {
        i+=2
    }
    println(i)
}


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

long long md(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int GCD(int x,int y){
    int temp;
    if(x<y){
        temp=x,x=y,y=temp;
    }
    if(y<1){
        return -1;
    }
    if(x%y==0){
        return y;
    }
    return GCD(x,x%y);
}

int main(){
    long long N,ans=1000000000005;
    cin >> N;
    long long T=pow(N,0.5)+2;
    for(long long i=1;i<T;i++){
        if(N%i==0){
            ans=min(ans,i+N/i-2);
        }
    }
    cout << ans << endl;
}

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

int main (void) {
	long long r, c; cin >> r >> c;
	long long result;
	if (c == 1 && r == 1)
		result = 1;
	else if (c == 1) {
		result = r-2;
	}
	else if (r == 1)
		result = c-2;
	else
		result =  (c-2)*(r-2) ;

	cout << result << endl;


	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
using namespace std;
int main() {
	int H, W;
	while(true) {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) {
				break;
		}
		for (int i=0; i < H; i++) {
			for (int j=0; j < W; j++) {
				if (i == 0 || j == 0 || i == H-1 || j == W-1) {
					printf("%c", '#');
				} else {
					printf("%c", '.');
				}
			}
			printf("\n");
		}
		printf("\n");
	}
}


Measured memory_bytes: 2536
public class Hello{
    public static void Main(){
        // Here your code !
        
     for(int i =1;i<=9; i++){ 
         for(int j =1;j<=9; j++){
              System.Console.Write("{1}x{0}={2}\n", j,i,i*j);
         }
        
          
     }
  
}}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define all(a) (a).begin(), (a).end()

#define int long long

const int M = 1e9 + 7;

int c[60];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        for (int i = 0; i < 60; i++) c[i] += (a >> i)&1;
    }
    int ans = 0, pw = 1;
    for (int i = 0; i < 60; i++) {
        ans += c[i]*(n-c[i])%M*pw%M;
        ans %= M;
        pw *= 2;
        pw %= M;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n, m;
ll a[5010];
ll as[5010];
ll b[5010][210];
vpl v[210];
ll s[5010][5010];

int main(){

  n = in();
  m = in();
  REP( i , n-1 ){
    a[i] = in();
  }
  REP( i , n-1 ){
    as[i+1] = as[i] + a[i];
  }
  REP( i , n ){
    REP( j , m ){
      b[i][j] = in();
      v[j].pb( b[i][j] , i );
    }
  }
  REP( i , m ){
    SORT( v[i] );
    REVERSE( v[i] );
    set<int> used;
    used.insert( -1 );
    used.insert( n );
    YYS( w , v[i] ){
      auto ite = used.lower_bound( w.se );
      int r = (*ite);
      ite--;
      int l = (*ite) + 1;
      s[l][w.se+1] += w.fi;
      s[l][r+1] -= w.fi;
      s[w.se+1][w.se+1] -= w.fi;
      s[w.se+1][r+1] += w.fi;
      used.insert( w.se );
    }
  }

  REP( i , n+1 ){
    REP( j , n+1 ){
      s[i+1][j] += s[i][j];
    }
  }
  REP( i , n+1 ){
    REP( j , n+1 ){
      s[i][j+1] += s[i][j];
    }
  }

  ll ans = 0;
  REP( j , n+1 ){
    REP( i , j ){
      chmax( ans , s[i][j] - ( as[j-1] - as[i] ) );
    }
  }

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


Measured memory_bytes: 226176
import java.util.*;

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

        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();

        for(int loop=0; loop<=x; loop++){
            if( loop*2 + (x-loop)*4 == y ){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");

    }
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

string make( vector<int> a, int N ){

}

int main() {

    ll N;
    cin >> N;
    vector<int> a(N+1);
    vector<int> b(N+1, 0);
    int size = 0;
    ll M = N;

    vector<int> ans;
    REP1(i, N+1)cin >> a[i];

    for(int i = N; i >= 1; i--){
        int sum = 0;
        for(int j = i; j <= N; j+=i){
            sum += b[j];
        }
        if(sum % 2 != a[i]){
            b[i] = 1;
            size = max(size, i);
            ans.push_back(i);
        }
    }

    // cout << size << endl;
    // REP1(i, size+1){
    //     cout << b[i] << " ";
    // }cout << endl;

 
     reverse(ans.begin(), ans.end());
 
     cout << ans.size() << endl;
     for(auto x: ans) cout << x << " ";
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
const int MAX_N = 1<<15;
 
vector<int> sq;
 
void make() {
  for(int i = 0; i*i <= MAX_N; ++i) {
    sq.push_back(i*i);
  }
}
 
int solve(int n) {
  int res = 0;
  for(int i = 0; i < sq.size() && sq[i] <= n; ++i) {
    for(int j = i; j < sq.size() && sq[i]+sq[j] <= n; ++j) {
      for(int k = j; k < sq.size() && sq[i]+sq[j]+sq[k] <= n; ++k) {
        int t = n - (sq[i] + sq[j] + sq[k]);
        vector<int>::iterator it = lower_bound(sq.begin(), sq.end(), t);
        if(it == sq.end() || *it != t) continue;
        if(*it >= sq[k]) ++res;
      }
    }
  }
  return res;
}
 
int main() {
  make();
  int n;
  while((cin >> n) && n) cout << solve(n) << endl;
  return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dump(x) cerr << #x " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define endl '\n'

#ifdef _DEBUG27_
    //#define STRESS 1
#endif

typedef long long llong;

const int INF = 2e9 + 999;
const llong LINF = 2e18 + 999;

void inv(bool e);
template<typename T> T sign(T a);
template<typename T> void die(T &a);
template<typename T> void umax(T &a, T b);
template<typename T> void umin(T &a, T b);

bool brute, alter;
int cnt_tests = 1;

// Get + in div1

// Code below

string s, t;

void inp() {
    cin >> s >> t;
}

bool check(int pos) {
    for (int i = pos; i - pos < sz(t); ++i) {
        if (s[i] != '?' && s[i] != t[i - pos]) {
            return false;
        }
    }
    return true;
}

void solve() {
    for (int i = sz(s) - sz(t); i >= 0; --i) {
        if (check(i)) {
            for (int j = 0; j < sz(s); ++j) {
                if (s[j] == '?') {
                    s[j] = 'a';
                }
            }
            for (int j = i; j - i < sz(t); ++j) {
                s[j] = t[j - i];
            }
            cout << s;
            return;

        }
    }
    cout << "UNRESTORABLE";
}

void stress() {

}

void naive() {

}

void run();
int main() {
    #ifdef _DEBUG27_
        if (1)
            freopen("input.txt", "r", stdin);
    #else
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (0) {
            freopen("palindrome.in", "r", stdin);
            freopen("palindrome.out", "w", stdout);
        }
    #endif
    srand(time(0));
    #ifdef STRESS
        brute = true;
    #else
        brute = false;
    #endif

    for (int i = 0; (i < cnt_tests); i++) {
        run();
    }

    #ifdef _DEBUG27_
        cout << endl << "Time: " << clock() / 1000.0 << " ms";
    #endif
    return 0;
}

void run() {
    if (!brute) {
        inp();
    }
    else {
        stress();
    }
    solve();
    cout << endl;
}

template<typename T>
void die(T &a) {
    cout << a;
    exit(0);
}

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

template<typename T>
void umax(T &a, T b) {
    if (b > a)
        a = b;
}

template<typename T>
void umin(T &a, T b) {
    if (b < a)
        a = b;
}

void inv(bool e) {
    if (!e) {
        vector<int> a;
        a[-1] += 1;
    }
}

/** CLEARING BUFFER

    cout << VAL << flush;

    OR

    printf(VAL);
    fflush(stdout);
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include <stack>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
	int t,n;
	cin>>t;
			if(t%1000==0) cout<<0<<endl;
	else{
		 n=t%1000;
		 cout<<1000-n<<endl;
	
	}
	
	return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;

int kakuketanosum(int n) {
	int s = 0;
	while (n > 0) {
		s += n % 10;
		n = n / 10;
	}
	/*if (s >= 10)
		s = kakuketanosum(s);
	else*/
		return s;
}
int main(void) {
	int n;
	cin >> n;
	int x = kakuketanosum(n);
	if (n % x == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Set<Integer> list = new HashSet<>();
		int persons;
		try (Scanner sc = new Scanner(System.in);) {
			// 最初の一回は空振り
			persons = sc.nextInt();
			sc.nextInt();
			// 1人目
			int num = sc.nextInt();
			for (int i = 0; i < num; i++) {
				list.add(sc.nextInt());
			}
			for (int p = 0; p < persons - 1; p++) {
				int num1 = sc.nextInt();
				Set<Integer> templist = new HashSet<>();
				for (int i = 0; i < num1; i++) {
					templist.add(sc.nextInt());
				}
				list.retainAll(templist);
			}
		}
		System.out.println(list.size());
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_c() {
	ll n;
	ll ans = 1;

	cin >> n;

	V a(n);
	V o, e4;
	rep(i, n) {
		cin >> a[i];
		if (a[i] % 2 == 1) {
			o.push_back(a[i]);
		}
		else if (a[i] % 4 == 0) {
			e4.push_back(a[i]);
		}
	}
	
	if (n % 2 == 0) {
		if (o.size() <= e4.size()) {
			cout << "Yes" << "\n";
		}
		else {
			cout << "No" << "\n";
		}
	}
	else {
		if (o.size() - 1 <= e4.size()) {
			cout << "Yes" << "\n";
		}
		else {
			cout << "No" << "\n";
		}
	}

}

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

	solve_abc_c();

	return 0;
}


Measured memory_bytes: 2168
# C
N = int(input())
X_list = list(map(int, input().split()))
X_list_s = sorted(X_list)
Right = X_list_s[N // 2]
Left = X_list_s[(N // 2) - 1]
for i in range(N):
    if X_list[i] >= Right:
        print(Left)
    else:
        print(Right)

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

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

  map<string, int> bag;
  bag["P"] = 0;
  bag["W"] = 0;
  bag["G"] = 0;
  bag["Y"] = 0;
  
  string S;
  
  for (int i = 0; i < N ; i++) {
    cin >> S;
    bag[S] += 1;
  }
  
  if (bag["Y"] == 0){
  	cout << "Three" << endl;
  }else {
    cout << "Four" << endl;
  }
  

}




Measured memory_bytes: 256
row_1 = list(map(int, input().split()))
row_2 = list(map(int, input().split()))
row_3 = list(map(int, input().split()))
N = int(input())
numbers_called = []
for i in range(N):
    b = int(input())
    numbers_called.append(b)

col_1 = [row_1[0], row_2[0], row_3[0]]
col_2 = [row_1[1], row_2[1], row_3[1]]
col_3 = [row_1[2], row_2[2], row_3[2]]
diagonal = [row_1[0], row_2[1], row_3[2]]
anti_diagonal = [row_3[0], row_2[1], row_1[2]]

winning_combinations = [row_1, row_2, row_3, col_1, col_2, col_3, diagonal, anti_diagonal]

is_bingo = False
for combination in winning_combinations:
    # check if every number for this combination has been called
    is_bingo = all([number in numbers_called for number in combination])
    
    if is_bingo:
        break


if is_bingo:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9260
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;

class unionfind {
public:
	vector<int> par;
	vector<int> rnk;

	unionfind(int N) :par(N),rnk(N) {//コンストラクタ
		for (int i = 0; i < N; i++) {
			par[i] = i;
			rnk[i] = 0;
		}
	}

	int root(int x) {//データｘが属する木の根を再帰で得る:root(x)={ｘの木の根}
		if (par[x] == x)return x;
		return par[x] = root(par[x]);

	}

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;//ｘとｙの根が同じ（＝同じ木にある）時はそのまま
		if (rnk[rx] < rnk[ry]) {
			par[rx] = ry;//xとyの根が同じでない（＝同じ木にない）時：ｘの根をｒｘをｙの根につける
		}
		else if (rnk[rx] > rnk[ry]) {
			par[ry] = rx;
		}
		else {
			par[rx] = ry;
			rnk[ry]++;
		}
	}

	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}

};



ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y,x%y);
}


int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	ll A, B;
	cin >> A >> B;
	ll G = gcd(A, B);
	ll ans = 1;

	for (ll i = 2; i*i <= G;i++) {
		if (G%i == 0) {
			ans++;
			while (G%i == 0)G /= i;
		}
	}
	if (G > 1)ans++;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //string[] str = Console.ReadLine().Split(' ');
            //int n = int.Parse(Console.ReadLine());

            string[] str = Console.ReadLine().Split(' ');
            long h = long.Parse(str[0]);
            long w = long.Parse(str[1]);

            if (h == 1 || w == 1)
            {
                Console.WriteLine(1);
            }
            else if (h * w % 2 == 0)
            {
                Console.WriteLine(h * w / 2);
            }
            else
            {
                Console.WriteLine(h * w / 2 + 1);
            }



            //ここまで
        }
    }

}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;
string IntToString(int);
int StringToInt(string);
int cal(int n){
  int ans = n;
  int cnt = 0;
  while(ans >= 10){
    string tmp = IntToString(ans);
    vector<int> keep;
    for(int i = 1;i < tmp.size();i++){
      int f,l;
      f = StringToInt(tmp.substr(0,i));
      l = StringToInt(tmp.substr(i));
      keep.push_back(f*l);
    }
    sort(keep.begin(),keep.end());
    /*    cout << "=========" << endl;
    for(int j = 0;j< keep.size();j++){
      cout << keep[j] << endl;
    }
    cout << "=========" << endl;*/
    ans = keep[keep.size()-1];
    ///    cout << ans << endl;
    cnt++;
  }
  
  return cnt;
}
int main(){
  /*  string a = "12";
  cout << a.substr(0,1) << " " << a.substr(1) << endl;
  return 0;
  */
  int n;
  cin >> n;

  for(int i = 0;i < n;i++){
    int tmp;
    cin >> tmp;
    cout << cal(tmp) << endl;
  }

  return 0;
}
string IntToString(int number){
  stringstream ss;
  ss << number;
  return ss.str();
}
int StringToInt(string number){
  stringstream ss;
  ss << number;
  int numInt;
  ss >> numInt;
  return numInt;
  
}
/*#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

*/

Measured memory_bytes: 1248
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

const int MAX_N = 1005;

int n, m;
vector<int> g[MAX_N];
vector<int> revG[MAX_N];
bool used[MAX_N];
int dist[MAX_N];
int par[MAX_N];

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

	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		u--; v--;
		g[u].push_back(v);
		revG[v].push_back(u);
	}

	int resultSz = n + 5;
	vector<int> result;
	queue<int> q;
	for (int i = 0; i < n; i++)
	{
		memset(used, 0, sizeof(used));
		memset(dist, 0, sizeof(dist));
		memset(par, 0, sizeof(par));

		q.push(i);
		used[i] = true;
		dist[i] = 0;
		par[i] = -1;
		while (!q.empty())
		{
			int u = q.front();
			q.pop();
			for (int v : revG[u])
			{
				if (used[v])
					continue;
				q.push(v);
				used[v] = true;
				dist[v] = dist[u] + 1;
				par[v] = u;
			}
		}

		for (int v : g[i])
		{
			if (used[v] && dist[v] + 1 < resultSz)
			{
				resultSz = dist[v] + 1;
				result.clear();
				int x = v;
				while (x != -1)
				{
					result.push_back(x + 1);
					x = par[x];
				}
			}
		}
	}

	if (resultSz > n)
		cout << "-1" << endl;
	else
	{
		cout << resultSz << endl;
		for (int v : result)
			cout << v << endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

int main(){
  string s, s2;
  cin >> s;

  REP(i, 0, s.size()){
    if(s[i] != 'x'){
      s2.push_back(s[i]);
    }
  }

  string r(s2);
  reverse(r.begin(), r.end());

  REP(i, 0, s2.size()){
    if(s2[i] != r[i]){
      cout << "-1" << endl;
      return 0;
    }
  }

  ll ans = 0;

  int h = 0, t = s.size()-1;


  while(h <= t){
    // cout << "h:" << h << endl;
    // cout << "t:" << t << endl;
    if(s[h] == 'x' && s[t] != 'x'){
      h++;
      ans++;
    } else if(s[h] != 'x' && s[t] == 'x'){
      t--;
      ans++;
    } else {
      h++;
      t--;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512