akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265
#define seive_len 1000001

typedef long long int lli;

bool seive[seive_len];
const int MOD = 1000000007;
lli primeSeive[seive_len];

lli gcd(lli a, lli b) {
  if(b == 0)
    return a;
  return gcd(b, a%b);
}

lli lcm(lli a, lli b) {
  lli gcd_ = gcd(a, b);
  lli lcm_ = (a*b)/gcd_;
  return lcm_;
}

lli ncr(lli n, lli r) {
  lli res = 1;
  if(r > n-r)
    r = n-r;
  
  for(lli i=0;i<r;i++) {
    res *= (n-i);
    res /= (i+1);
  }
  return res;
}

lli ncrMODp(lli n, lli r) {
  if(r > n-r)
    r = n-r;
  lli prow[r+1];
  memset(prow, 0, sizeof(prow));
  prow[0] = 1;
  for(lli i=1;i<=n;i++) {
    for(lli j=min(i, r);j>0;j--) {
      prow[j] = (prow[j]+prow[j-1])%MOD;
    }
  }
  return prow[r];
}

lli fastPower(lli a, lli b) {
  lli res=1;
  while(b > 0) {
    if(b&1)
      res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}

lli fastPowerMODp(lli a, lli b) {
  a %= MOD;
  lli res = 1;
  while(b) {
    if(b%2 == 1)
      res = (res*a)%MOD;
    a = (a*a)%MOD;
    b >>= 1;
  }
  return res;
}

void multiply(lli a[][2], lli b[][2]) {
  lli res[2][2];
  memset(res, 0, sizeof(res));
  for(lli i=0;i<2;i++) {
    for(lli j=0;j<2;j++) {
      for(lli k=0;k<2;k++) {
        res[i][j] += a[i][k]*b[k][j]%MOD;
      }
    }
  }
  for(lli i=0;i<2;i++)
    for(lli j=0;j<2;j++)
      a[i][j] = res[i][j];
}

void matrixExpo(lli a[][2], lli n) {
  if(n == 0 || n == 1)
    return;
  lli b[][2] = {{1,1}, {1,0}};
  matrixExpo(a, n/2);
  multiply(a, a);
  if(n%2)
    multiply(a, b);
}

void makeSeive() {
  for(lli i=2;i*i<=seive_len;i++) {
    if(seive[i]) {
      for(lli j=i*i;j<=seive_len;j+=i)
        seive[j] = false;
    }
  }
}

void makePrimeSeive() {
  for(lli i=1;i<seive_len;i++)
    primeSeive[i] = i;
  for(lli i=4;i<seive_len;i+=2)
    primeSeive[i] = 2;
  for(lli i=3;i*i<seive_len;i++) {
    if(primeSeive[i] == i) {
      for(lli j=i*i;j<seive_len;j+=i) {
        if(primeSeive[j] == j)
          primeSeive[j] = i;
      }
    }
  }
}

bool isPrime(lli n) {
  for(lli i=2;i<=sqrt(n);i++) {
    if(n%i == 0)
      return false;
  }
  return true;
}

void getInput(vector<lli>& a, lli n) {
  lli x;
  for(lli i=0;i<n;i++) {
    cin >> x;
    a.push_back(x);
  }
}

void testCase() {
  lli i;
  string s;
  cin >> s;
  if(s[s.size()-1] == 's')
    cout << s << "es";
  else
    cout << s << 's'; 
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
	lli t=1;
	// cin >> t;
  // makePrimeSeive();
  // FILE* fp;
  // fp = fopen("out.txt", "w");
	for(lli i=1;i<=t;i++) {
    // fprintf(fp, "Case #%d:\n", i);
    // cout << "Case #" << i << ":" << ' ';
		testCase();
    cout << '\n';
	}
	return 0;
}

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

using namespace std;

const int INF = 1e9;
int n, a[500010], cnt = 0;

void merge(int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    vector<int> L(n1 + 1), R(n2 + 1);
    for (int i = 0; i < n1; i++)
        L[i] = a[left + i];
    for (int i = 0; i < n2; i++)
        R[i] = a[mid + i];
    L[n1] = R[n2] = INF;

    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        if (L[i] <= R[j]) a[k] = L[i++];
        else a[k] = R[j++];
        cnt++;
    }
}

void mergeSort(int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(left, mid);
        mergeSort(mid, right);
        merge(left, mid, right);
    }
}

int main(void) {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    mergeSort(0, n);
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 6768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;

	vector<string> S(N);
	for (auto& s : S) {
		cin >> s;
	}
	int M;
	cin >> M;
	vector<string> T(M);
	for (auto& t : T) {
		cin >> t;
	}
	int ans = 0;
	for (auto& s : S) {
		int money = count(S.begin(), S.end(), s) - count(T.begin(), T.end(), s);
		ans = max(money, ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var r = int.Parse(Console.ReadLine());
            Console.WriteLine(r + Math.Pow(r, 2) + Math.Pow(r, 3));
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define array(N, t) (t*)calloc(N, sizeof(t))
#define ll long long
#define INF ((1LL << 62) - (1LL << 31))
#define max(p, q)((p) > (q) ? (p) : (q))
#define min(p, q)((p) < (q) ? (p) : (q))

int main(){
  char N[200010];
  scanf("%s", N);

  int sum = 0;
  rep(i, 200010) {
    if (N[i] == '\0') {
      break;
    }
    sum += N[i] - '0';
  }

  if (sum % 9 == 0) {
    puts("Yes");
  } else {
    puts("No");
  }
}


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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fr(i,k) for(i=0;i<k;i++)
#define ALL(c) (c).begin(),(c).end()
#define deb(x) cerr<<#x<<"  = "<<x<<endl;
#define SZ(x) (x).size();
#define ll long long
#define MOD 1000000007
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define em emplace_back
#define ulli unsigned long long int
#define INF 1e18
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
void solve();

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main() {
	fastio;
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	int t;
	t=1;

    //cin>>t;
	while (t--)
	{
		solve();
	}
	return 0;
}

ll n;

ll mex(unordered_set<ll> &s)
{
	ll mex = 0;

	while (s.find(mex) != s.end())
		mex++;

	return mex;
}

ll grundy(ll a[], ll k, vector<ll> &dp)
{
	if (dp[k] != -1)
		return dp[k];

	unordered_set<ll> s;

	for (ll i = 0; i < n; i++)
	{
		if (k - a[i] >= 0)
			s.insert(grundy(a, k - a[i], dp));
	}

	if (s.empty())
		return dp[k] = 0;

	return dp[k] = mex(s);
}

void solve()
{
	ll k, i, ans;
	cin >> n>>k;

	ll a[n];

	for (i = 0; i < n; i++)
		cin >> a[i];

	vector<ll> dp(k + 1, -1);
	dp[0] = 0;
	ans = grundy(a, k, dp);

	if (ans == 0)
		cout << "Second" << endl;
	else
		cout << "First" << endl;

}


Measured memory_bytes: 21144
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
//fflush(stdin);
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
	ll n;
	cin>>n;
	cout<<n*n*n<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//一括include
using namespace std;
int main()
{
    int a, b, c, x;
    int ans = 0;
    int i = 0;
    int j = 0;
    int k = 0;

    cin >> a >> b >> c >> x;
    for (i = 0; i <= a; i++)
    {
        for (j = 0; j <= b; j++)
        {
            for (k = 0; k <= c; k++)
            {
                if ((500 * i) + (100 * j) + (50 * k) == x)
                {
                    //cout << i << " " << j << " " << k << endl;
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int check(int i,int j,int n,int m)
{
	if(i>=0 && i<n && j>=0 && j<m)
		return 1;
	return 0;
}
int main()
{
	int h,w,i,j;
	int mod=1e9+7;
	scanf("%d%d",&h,&w);
	char s[h+1][w+1];
	for(i=0;i<h;i++)
		scanf("%s",s[i]);
	queue<pair<int,int>>q;
	q.push({h-1,w-1});
	int ar[h+1][w+1];
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
			ar[i][j]=0;
	}
	for(j=w-2;j>=0;j--)
	{
		if(s[h-1][j]=='.')
			ar[h-1][j]=1;
		else
			break;
	}
	for(i=h-2;i>=0;i--)
	{
		if(s[i][w-1]=='.')
			ar[i][w-1]=1;
		else
			break;
	}
	for(i=h-2;i>=0;i--)
	{
		for(j=w-2;j>=0;j--)
		{
			if(s[i][j]=='.')
				ar[i][j]=((ar[i+1][j]%mod)+(ar[i][j+1]%mod))%mod;
		}
	}
/*	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
			printf("%d ",ar[i][j]);
		printf("\n");
	}*/
	printf("%d\n",ar[0][0]%mod);
}


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

int main(){
  int N,K; cin>>N>>K;
  string S; cin>>S;
  S+='A';
  vector<int> V;
  int cnt=0;
  rep(i,N){
    if(S[i]!=S[i+1]){
      V.push_back(cnt+1);
      cnt=0;
    }else{
      cnt++;
    }
  }
  if(V.size()==1){
    cout<<N<<endl;
    return 0;
  }
  if(S[0]=='0') V.insert(V.begin(),0);
  if(S[N-1]=='0') V.push_back(0);

  int l=0,r=K*2,ans=0,sum=0,siz=V.size();
  for(int i=0;i<=min(r,siz);i++){
    sum+=V[i];
  }
  ans=sum;
  while(r+2<V.size()){
    sum-=V[l]+V[l+1];
    sum+=V[r+1]+V[r+2];
    ans=max(ans,sum);
    l+=2;
    r+=2;
  }
  cout<<ans<<endl;
  return 0;
}


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



int main(){
    int k,N;
    cin >> N >> k;
    long long  int monsters[N];


 for(int i = 0;i < N;i++) {
    cin >> monsters[i];
 }

 sort(monsters,monsters + N);

 long long int sum = 0;
 for(int i = 0;i <= N - k - 1;i++) {
    sum += monsters[i];
 }

 cout << sum;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	char ch[1000000];
	int p=0;
	cin>>ch;
	for(int i=0;i<strlen(ch)-1;i++){
		if(ch[i]!=ch[i+1])p++;
	}
	cout<<p<<endl;
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST
{
    static void Main()
    {
        var input = Console.ReadLine().Split(' ');

        var n = int.Parse(input[0]);
        var k = int.Parse(input[1]);
        var q = int.Parse(input[2]);

        int[] arr = new int[n];

        for (int i = 0; i < n; i++)
        {
            arr[i] = k - q;
        }

        for (int i = 0; i < q; i++)
        {
            var ans = int.Parse(Console.ReadLine());
            arr[ans - 1]++;
        }

        for (int i = 0; i < n; i++)
        {
            if (arr[i] <= 0)
            {
                Console.Write("No \n");
            }
            else
                Console.Write("Yes \n");

        }
    }
}






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

int main() {
	int n; scanf("%d", &n);
	vector<vector<int>> days(3, vector<int>(n));

	for (int i = 0; i < n; i++) {
		scanf("%d%d%d", &days[0][i], &days[1][i], &days[2][i]);
	}

	vector<vector<int>> dp(3, vector<int>(n, 0));
	// dp[0][0] = days[0][0];
	// dp[1][0] = days[1][0];
	// dp[2][0] = days[2][0];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k) continue;
				dp[j][i] = max(dp[j][i], dp[k][i - 1] + days[j][i]);
			}
		}
	}

	int ans = 0;
	ans = max({ans, dp[0].back(), dp[1].back(), dp[2].back()});
	printf("%d\n", ans);
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  string a;
  cin >> a;
  rep(i, bit32(3)) {
    int sum = a[0] - '0';
    string s;
    s += a[0];
    rep(j, 3) {
      if (i & bit32(j)) {
        sum += a[j + 1] - '0';
        s += '+';
      } else {
        sum -= a[j + 1] - '0';
        s += '-';
      }
      s += a[j + 1];
    }
    if (sum == 7) {
      cout << s << "=7" << endl;
      return;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

template <typename T>
void say(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}


/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	string s;
	cin >> s;
	
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == ',') cout << " ";
		else cout << s[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace

solve :: Int -> Int -> [(Int,Int)] -> Int
solve bN bW wvs = vecFin VU.! bW
  where
  vecFin = foldl' op (VU.replicate (bW+1) 0) wvs
  op vec (w,v) =
    VU.zipWith max vec (VU.replicate w 0 VU.++ VU.map (+ v) vec)

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bN,bs_bW]:remLines1 = remLines0
      bN = readBInt bs_bN
      bW = readBInt bs_bW
      wvs = map (\[x1,x2] -> (readBInt x1,readBInt x2)) remLines1
  in solve bN bW wvs

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


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

int32_t main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,h;
    cin>>h>>a;
    cout<<ceil(float(h)/float(a));
    return 0;
}

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

using namespace std;

unsigned int dp[80000][11];

int main(void)
{
    string S;
    int i, j, size, n, ans;
    while (true)
    {
        cin >> S;
        if (S == "0") break;
        size = S.size();
        for (j = 0; j < 11; j++) dp[0][j] = 0;
        dp[0][S[0] - '0'] = 1;
        ans = dp[0][0];
        for (i = 1; i < size; i++)
        {
            n = S[i] - '0';
            for (j = 0; j < 11; j++) dp[i][(j * 10 + n) % 11] = dp[i - 1][j];
            if (n) dp[i][n]++;
            ans += dp[i][0];
        }
        cout << ans << endl;
    }
    return 0;
}


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

char nth_letter(int n){
    return "abcdefghijklmnopqrstuvwxyz"[n-1];
}

int letter_n(char x){
    return (int) x - 96;
}

int main(void){
    long int s;
    long int l;
    string res;
    cin >> res;
    cin >> s;
    l = res.length();
    for (long int i=0; i<l; i++){
        int lag = 27 - letter_n(res[i]);
        if ((lag % 26 != 0) && (s >= lag) && (i < l - 1)){
            // not a and can conv
            res[i] = 'a';
            s -= lag;
        } else if (i == l - 1){
            res[i] = nth_letter((letter_n(res[i]) - 1 + s) % 26 + 1);
            }
    } 
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
while True:
    n = int(input())
    if n == 0:
        break
    
    field = [input().split() for _ in range(n)]
    field = list(reversed(field))
    score = 0

    while True:

        f = True

        for row in field:
            clear_index = set()
            for i in range(3):
                if row[i] == -1:
                    continue
                if row[i] == row[i+1] and row[i+1] == row[i+2]:
                    f = False
                    clear_index.add(i)
                    clear_index.add(i+1)
                    clear_index.add(i+2)

            for i in clear_index:
                score += int(row[i])
                row[i] = -1
        
        if f:
            break

        for i,row in enumerate(field):
            for j in range(5):
                if row[j] != -1:
                    continue
                
                for k in range(i+1,n):
                    if field[k][j] != -1:
                        field[k][j],row[j] = row[j],field[k][j]
                        break
    print(score)


Measured memory_bytes: 5632
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
	int n,m;
	scanf("%d",&n);
	double ans = 0;
	while(n--)
	{
		scanf("%d",&m);
		ans += (double)1/m;
	}
	printf("%lf",1.0/ans);
	return 0;
} 

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = list(input())
k = int(input())
for i in range(len(s)):
    num = (ord('z') - ord(s[i]) + 1) % 26
    if num <= k:
        k -= num
        s[i] = 'a'
s[-1] = chr((ord(s[-1]) - ord('a') + k) % 26 + ord('a'))
print(*s, sep='')


Measured memory_bytes: 6964
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {

	int h, w; cin >> h >> w;

	vector<string> a(h);

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

	vector<int> cnts(26);

	for (int i = 0; i < h; i++) {
		string buf = a[i];

		for (char c : buf) {
			++cnts[c - 'a'];
		}
	}
	//自然数はmod4で　奇数、4n+2,4nの3つのグループに分けられる。

	//奇数は1つ、4で割って2余る数がキー。
	int odd = 0;
	int r2 = 0;

	for (int i = 0; i < 26; i++) {
		if (cnts[i] % 2)odd++;
		if (cnts[i] & 2)r2++;
	}


	//両方偶数なら4のペアしか使えない。奇数個のもの、4で割って2余るものがあると
	//達成できない。

	//4444
	//4444
	//4444
	//4444

	//片方偶数なら、偶数の方の辺の半分が2個のペア。
	//424
	//424
	//424
	//424

	//両方奇数なら、中心のみ1、4で割って2余る数がh/2+w/2だけある。
	//424
	//424
	//212
	//424
	//424

	if (h % 2 == 0 && w % 2 == 0) {
		if (odd || r2)cout << "No" << endl;else cout << "Yes" << endl;
	}
	else if (h % 2 == 0) {
		if (odd || r2 > h / 2)cout << "No" << endl;else cout << "Yes" << endl;
	}
	else if (w % 2 == 0) {
		if (odd || r2 > w / 2)cout << "No" << endl;else cout << "Yes" << endl;
	}
	else {
		if (odd != 1 || r2 > h / 2 + w / 2)cout << "No" << endl;else cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
	int t;
	while (cin >> t, t) {
		int n; cin >> n;

		int sum = 0;
		for (int i = 0; i < n; ++i) {
			int s, f; cin >> s >> f;
			sum += f - s;
		}

		if (sum >= t) cout << "OK" << endl;
		else cout << (t - sum) << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  double fa=a,fb=b;
  //cout << (a/b) <<" "<<(a%b)<<" "<<(fa/fb)<<endl;
  printf("%d %d %.5f\n",(a/b),(a%b),(fa/fb));
  return 0;
}



Measured memory_bytes: 3220
#include <stdio.h>
#include <math.h>

int main(int argc,char* argv[]){
  double x1,y1,x2,y2,x3,y3;
  double x,y,r;
  double r12,r23,r31,angle1,angle2,angle3;
  int num,count;
  
  scanf("%d",&num);
  
  for(count = 0; num > count;count++){
    scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
    
    r12 = sqrt((x1 -x2)*(x1 -x2) + (y1 -y2)*(y1 -y2));
    r23 = sqrt((x2 -x3)*(x2 -x3) + (y2 -y3)*(y2 -y3));
    r31 = sqrt((x3 -x1)*(x3 -x1) + (y3 -y1)*(y3 -y1));
    
    angle3 = acos( (r23*r23+r31*r31-r12*r12) / (2.0*r23*r31) );
    angle1 = acos( (r31*r31+r12*r12-r23*r23) / (2.0*r31*r12) );
    angle2 = acos( (r12*r12+r23*r23-r31*r31) / (2.0*r12*r23) );
    
    x = (sin(2.0*angle1)*x1 + sin(2.0*angle2)*x2 + sin(2.0*angle3)*x3)/(sin(2.0*angle1) + sin(2.0*angle2) + sin(2.0*angle3));
    y = (sin(2.0*angle1)*y1 + sin(2.0*angle2)*y2 + sin(2.0*angle3)*y3)/(sin(2.0*angle1) + sin(2.0*angle2) + sin(2.0*angle3));
    
    r = r23/ sin(angle1) / 2.0;
    
    printf("%.3lf %.3lf %.3lf\n",x,y,r);
  }
  
  return 0;
  
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    int a,b,c=1,d;
    cin>>a>>b;
    d=(a*2)-1;
    for(int i=0; i<d; i++){
    cout<<b-(a-c)<<" ";
    c++;
    }
    cout<<'\n';
    return(0);
    }

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

using Point = complex<double>;
const complex<double> I = complex<double>(0,1);
const double PI = acos(-1);
const double EPS = 1e-9;

void rotate(Point &a, double theta){
    a *= exp(I*theta);
}

void move(Point &a, Point x){
    a += x;
}

// deg -> rad
double d2r(double deg){
    return deg*PI/180;
}

int main() {
    int N, D;
    while(cin >> N >> D, N){
        Point a(-D,0), b(D,0);  // Left Point, Right Point
        double nv = PI/2;  // 進行方向

        for(int i=0;i<N;i++){
            int Ls, Rs, t;
            cin >> Ls >> Rs >> t;
            // 直進
            if(Ls == Rs){
                move(a, exp(I*nv)*d2r(Ls)*double(t));
                move(b, exp(I*nv)*d2r(Rs)*double(t));
            }
            // 回転
            else{
                double n = -Ls, m = Rs;
                Point O = (a*m+b*n)/(n+m);  // 回転の中心点
                // 回転中心を原点に平行移動
                move(a,-O);
                move(b,-O);
                double theta;  // 回転角(rad)
                if(Rs != 0) theta = d2r(Rs)*t/abs(b);
                else theta = d2r(Ls)*t/abs(a);
                if(Ls*Rs >= 0 && abs(Ls) > abs(Rs)) theta *= -1;  // 外分点の位置によって回転角を反転
                // 回転
                rotate(a,theta);
                rotate(b,theta);
                // 元の位置に戻す
                move(a,O);
                move(b,O);
                nv += theta;  // 進行方向の修正
            }
        }
        Point ans = (a+b)/2.0;
        printf("%.8lf\n%.8lf\n",ans.real()+EPS, ans.imag()+EPS);
    }
    return 0;
}



Measured memory_bytes: 3460
N = int(input())
VW = [list(map(int,input().split())) for _ in range(N-1)]

for i in range(N-1):
    VW[i][0] -= 1
    VW[i][1] -= 1

edges = [list() for _ in range(N)]
for i in range(N-1):
    edges[VW[i][0]].append((VW[i][1],VW[i][2]))
    edges[VW[i][1]].append((VW[i][0],VW[i][2]))

D = [-1 for _ in range(N)]
D[VW[0][0]] = 0
stack = [VW[0][0]]

while stack:
    s = stack.pop(-1)
    for (i,c) in edges[s]:
        if D[i] == -1:
            D[i] = D[s] +c
            stack.append(i)

for e in D:
    if e % 2:
        print(0)
    else:
        print(1)






Measured memory_bytes: 88024
n,m = gets.split.map(&:to_i)
xyzs = []
n.times do
  x,y,z = gets.split.map(&:to_i)
  xyzs << [x,y,z]
end

ans = 0
(0..("111".to_i(2))).each do |i|
  bit = i.to_s(2).rjust(3, "0")
  op = bit.gsub("0","-").gsub("1","+")

  tmp = xyzs.sort do |a,b|
    aval = eval("#{op[0]}#{a[0]}#{op[1]}#{a[1]}#{op[2]}#{a[2]}")
    bval = eval("#{op[0]}#{b[0]}#{op[1]}#{b[1]}#{op[2]}#{b[2]}")
    bval <=> aval
  end

  tmp = tmp.first(m)
  t = tmp.transpose.reduce(0) do |a,e|
    a += (e.reduce(0){|a2,e2| a2+=e2}).abs
  end
  ans = [ans, t].max
end

puts ans


Measured memory_bytes: 4856
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>

#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}
//---------


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //CLion Standard Input
    //--------------------------------------------------------------------------
//    ifstream in("/Users/ryo/Dropbox/competition/CompetitiveProgramming/in.txt");
//    cin.rdbuf(in.rdbuf());
    //-------------------------------------------------------------------------

    int x;
    cin >> x;
    if(x < 1200){
        cout << "ABC" << endl;
    }else{
        cout << "ARC " << endl;
    }
    return 0;
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n; cin >> n;
  vll a(n), b(n);

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

  ll cnt = 0;

  rep(i, n) {
    if (a[i] % 2 != b[i] % 2) {
      ++b[i];
      ++cnt;
    }
    if (a[i] > b[i]) cnt += a[i] - b[i];
    else cnt -= (b[i] - a[i]) / 2;
  }

  if (cnt > 0) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 3788
import sys
readline = sys.stdin.readline
from collections import defaultdict
from bisect import bisect_left, bisect, insort_left, insort
INF = 10000
def lcs(s1, s2):
    c = defaultdict(list)
    for i, s in enumerate(s1):
        c[s].append(i)
    for s in set(s2):
        c[s].append(INF)
    dp = []
    for s2_k in s2:
        bgn_idx = 0
        for i, cur_idx in enumerate(dp):
            chr_idx = c[s2_k][bisect_left(c[s2_k], bgn_idx)]
            if chr_idx == INF:
                break
            dp[i] = min(cur_idx, chr_idx + 1)
            bgn_idx = cur_idx
        else:
            chr_idx = c[s2_k][bisect_left(c[s2_k], bgn_idx)]
            if chr_idx != INF:
                dp.append(chr_idx + 1)
    return len(dp)
def solve():
    N = int(input())
    for _ in range(N):
        x = readline().strip()
        y = readline().strip()
        print(lcs(x, y) if len(x) < len(y) else lcs(y, x))
solve()



Measured memory_bytes: 6024
#include<stdio.h>
 
void swap(int* a,int* b){
  int tmp=*a;
  *a=*b;
  *b=tmp;
}
 
int n;
int A[1000];
int B[1000];
int vd[1000];
int cnt,sum,mini;
 
int min(int x,int y){
  if(x<y)return x;
  else return y;
}
 
int search(int x){
  int i;
  for(i=0;i<n;i++)if(A[i]==x)return i;
}
 
int main(){
  int i,j,ans,x;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    B[i]=A[i];
  }
 
  for(i=n-1;i>0;i--)
    for(j=0;j<i;j++)
      if(B[j]>B[j+1])swap(&B[j],&B[j+1]);
   
  ans=0;
  for(i=0;i<n;i++)vd[i]=0;
 
  for(i=0;i<n;i++){   
    x=i;
    cnt=sum=0;
    mini=(1<<24);
    while(vd[x]==0){
      vd[x]=1;
      cnt++;
      sum+=A[x];
      mini=min(mini,A[x]);
      x=search(B[x]);
    }
    if(cnt<2)continue;
    ans+=min(sum+B[0]*(cnt+1)+mini,sum+mini*(cnt-2));
 
  }
 
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

string x;
int ans = 0, now = 0;

int main() {
    cin >> x;
    rep(i,x.size()) {
        if (x[i] == 'T') {
            ans = max(0, ans-1);
        } else {
            ans++;
        }
    }
    cout << ans*2 << endl;
}

Measured memory_bytes: 640
#C
def main():
    mod=998244353
    n=int(input())
    Fact=[1] #階乗
    for i in range(1,n+1):
        Fact.append(Fact[i-1]*i%mod)
    Finv=[0]*(n+1) #階乗の逆元
    Finv[-1]=pow(Fact[-1],mod-2,mod)
    for i in range(n-1,-1,-1):
        Finv[i]=Finv[i+1]*(i+1)%mod
    def comb(n,r):
        if n<r:
            return 0
        return Fact[n]*Finv[r]*Finv[n-r]%mod
    
    impossible=0
    m=1
    for k in range(n//2):
        impossible+=comb(n,k)*m%mod
        impossible%=mod
        m*=2
        m%=mod
    print((pow(3,n,mod)-impossible*2)%mod)

if __name__=='__main__':
    main()

Measured memory_bytes: 197548
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        for (int i = 1; i < 4; i++) {
            int tmp = a * b * i;
            if(tmp % 2 == 1) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

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

vector<int> to[200005];
vector<int> check;
int cnt=0;
int ans=0;

void dfs(int v, int p=-1) {
  check[v]=1;
  for (int u : to[v]) {
//    cout << u << ' ' <<p <<' '<< check[u] << endl;
    if (u == p) continue;
    if(check[u]==1) continue;
    cnt +=1;
//    cout << cnt << endl;
    dfs(u,v);
  }
}

int main(){
  int n,m;
  cin >> n >> m;
  rep(i,0,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  check.resize(n);
  rep(i,0,n){
    if(to[i].empty()) continue;
    if(check[i]==1) continue;
//    cout << i << endl;
    dfs(i);
    ans=max(ans,cnt);
//    cout << cnt << endl;
    cnt=0;
  }
  cout << ans+1 << endl;
  return 0;


}

Measured memory_bytes: 24312
#include<stdio.h>

int main()
{
   int i, j, tmp;
   int R[10];

   for(i=0; i<10; i++){
      scanf("%d", &R[i]);
   }

   for(i=0; i<10; i++){
      for(j=i+1; j<10; j++){
         if(R[i]<R[j]){
            tmp = R[j];
            R[j] = R[i];
            R[i] = tmp;
         }
      }
   }

   for(i=0; i<3; i++){
      printf("%d\n", R[i]);
   }

   return 0;
}

Measured memory_bytes: 1856
#include <bits/stdc++.h>
#define ll long long
#define mk make_pair
using namespace std;
 
const int N = 305;
const int mod = 1e9 + 7;
const int inf = 1e9;

int dp[2][N][N], n, m;
vector< pair<int, int> > V[N]; 

bool check(int i, int j, int k) {
	for (int p = 0; p < V[k].size(); p++) {
		int tmp = 1;
		if (i >= V[k][p].first) tmp++;
		if (j >= V[k][p].first) tmp++;
		if (tmp != V[k][p].second) return 0;
	}
	return 1;
}

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= m; i++) {
		int l, r, x;
		scanf("%d %d %d", &l, &r, &x);
		l += 2;
		r += 2;
		V[r].push_back(mk(l, x));
	} 
	n += 2;
	dp[0][0][1] = 1;
	for (int i = 2; i < n; i++) {
		memset(dp[(i + 1) & 1], 0, sizeof(dp[(i + 1) & 1]));
		int now = i & 1, nxt = (i + 1) & 1;
		for (int j = 0; j < i; j++) {
			for (int k = j + 1; k < i; k++) {
				if (check(j, k, i + 1)) {
					dp[nxt][j][k] += dp[now][j][k];
					if (dp[nxt][j][k] >= mod) dp[nxt][j][k] -= mod;
				} 
				if (check(k, i, i + 1)) {
					dp[nxt][k][i] += dp[now][j][k];
					if (dp[nxt][k][i] >= mod) dp[nxt][k][i] -= mod;
				}
				if (check(j, i, i + 1)) {
					dp[nxt][j][i] += dp[now][j][k];
					if (dp[nxt][j][i] >= mod) dp[nxt][j][i] -= mod; 
				}
			} 
		}
	}
	ll ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			(ans += dp[n & 1][i][j]) %= mod;
	cout << ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


int main() {
    srep(i,1,10){
        srep(j,1,10){
            cout << i << 'x' << j << '=' << i*j << endl;
        }
    }
    return 0;
}
 
 



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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n, a, b; cin >> n >> a >> b;
    ll p = a + b;

    ll ans = (n/p) * a;
    if(n%p > a) ans += a;
    else ans += n%p;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);
    long ans = 1;
    auto cnt = new int[](3);

    foreach (i ; 0 .. n) {
        int t;
        bool b;

        foreach (j ; 0 .. 3) {
            if (cnt[j] == a[i]) {
                t++;
                if (!b) {
                    cnt[j]++;
                    b = 1;
                }
            }
        }

        (ans *= t) %= mod;
    }

    writeln(ans);
}
















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 4176
N = int(input())
A = input()
B = input()
ans = 3
for i in range(len(A) - 1):
  if A[i] == B[i] and A[i + 1] == B[i + 1]:
    ans *= 2
  if A[i] == B[i] and A[i + 1] != B[i + 1]:
    ans *= 2
  if A[i] != B[i] and A[i + 1] != B[i + 1] and A[i] != A[i + 1]:
    ans *= 3
  if A[i] != B[i] and A[i + 1] != B[i + 1] and A[i] == A[i + 1] and i == 0:
    ans *= 2
  ans %= 1000000007
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;++i)
#define per(i,r,l) for (int i=r;i>=l;--i)
#define rep0(i,r) for (int i=0;i<r;++i)
#define pr pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define ll long long
using namespace std;
const int N=1e6+6,T=(1<<9)-1,M=1e5;
ll f[1003][M+5]; int hei[N],v[N],w[N],v0[N],w0[N];
int main(){
    int n; cin>>n;
    rep(i,1,n) scanf("%d%d",&v[i],&w[i]);
    rep(i,1,n) hei[i]=hei[i>>1]+1;
    rep(i,1,min(n,T)){
        rep(j,1,M) f[i][j]=f[i>>1][j];
        per(j,M,w[i]) f[i][j]=max(f[i][j],f[i][j-w[i]]+v[i]);
    }
    int q; cin>>q;
    while (q--){
        int u,m; scanf("%d%d",&u,&m);
        if (hei[u]<=9) printf("%lld\n",f[u][m]);
        else{
            int c=0; ll ans=0;
            for (;hei[u]>9;u>>=1) v0[++c]=v[u],w0[c]=w[u];
            rep(s,0,(1<<c)-1){
                int l=m; ll sum=0;
                rep(i,1,c) if (s>>i-1&1) l-=w0[i],sum+=v0[i];
                if (l>=0) ans=max(ans,sum+f[u][l]);
            }
            printf("%lld\n",ans);
        }
    }
    return 0;
}


Measured memory_bytes: 406156
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int e=a-c;
  if(e<0)
    e=e*(-1);
  int f=a-b;
  if(f<0)
    f=f*(-1);
  int g=b-c;
  if(g<0)
    g=g*(-1);
  if(e<=d){
    cout << "Yes" << endl;
  }
  else{
    if(f<=d && g<=d)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N, Q = map(int,input().split())
S = input()
L = [0 for k in range(N)]
t = 0
for k in range(N-1):
    if S[k:k+2] == "AC":
        t += 1
    L[k+1] = t

for k in range(Q):
    l, r = map(int,input().split())
    print(L[r-1]-L[l-1])


Measured memory_bytes: 6180
/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int main(){
	fastio;
	int k;
	R(k);
	rb(i,1,k){
		cout<<"ACL";
	}
	return 0;
}
/** 程序框架：
  *
  *
  *
  *
  **/


Measured memory_bytes: 3604
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int n, a[100000];

int64_t solve(bool plus) {
    int64_t ret = 0, sum = 0;
    rep(i, n) {
        sum += a[i];
        if (plus && sum <= 0 || !plus && sum >= 0) {
            ret += abs(sum) + 1;
            sum = plus ? 1 : -1;
        }
        plus ^= true;
    }
    return ret;
}

int main() {
    cin >> n;
    rep(i, n) cin >> a[i];
    cout << min(solve(true), solve(false)) << endl;
}

Measured memory_bytes: 640
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	s = chomp(readline())
	n = length(s)
	if s[1] == '0' || s[n-1] == '0' || s[n] == '1'
		println(-1)
	else
		flg = 0
		k = div(n-1,2)
		for i in 1:k
			if s[i+1] != s[n-1-i]
				flg = 1
				break
			end
		end
		if flg == 1
			println(-1)
		else
			init = n
			for i in 1:n-2
				if s[i] == '0'
					init = i
					break
				end
			end
			if init > k
				for i in 2:init
					println(i-1, " ", i)
				end
				for i in init+1:n
					println(1, " ", i)
				end
			else
				now = 1
				for i in 2:k+1
					println(now, " ", i)
					if s[i-1] == '1'
						now = i
					end
				end
				if s[k+1] == '1'
					println(now, " ", k+2)
					for i in k+3:n
						println(k+2, " ", i)
					end
				else
					for i in k+2:n
						println(now," ", i)
					end
				end
			end
		end
	end
end
main()

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

using namespace std;

int main() {
    string c;
    cin>>c;
    int flag=0;
    for(int i=0;i<c.size();i++){
        if(c[i]=='7'){
            flag=1;
            break;
        }
    }
    if(flag==1){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

template<typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    ll S;
    cin >> S;

    ll x1 = 0;
    ll y1 = 0;
    ll x2 = 1e09;
    ll x3 = 1;
    ll y3 = round_up(S, x2);
    ll y2 = x2 * y3 - S;

    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3<<endl;
    return 0;
}

Measured memory_bytes: 256