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

int main() {

  string s;
  cin >> s;

  long long int n = s.size();

  long long int ans = 999;

  for ( long long int i = 0; i < 26; i++ ) {

    long long int m = 0;
    long long int cnt = 0;
    for ( long long int j = 0; j < n; j++ ) {
      if ( s[j] == i + 'a' ) {
	m = max( m, cnt );
	cnt = 0;
      }else {
	cnt++;
      }
    }
    m = max( m, cnt );
    ans = min( ans, m );

  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b){
	return b ? gcd(b, a%b) : a;
}
ll ged(ll a, ll b){
	return a * b / gcd(a,b);
}
int main(){
	ll a, b, c, d;
	ll ans = 0;
	cin >> a >> b >> c >> d;
    ll q = b - a + 1;
    ll s = b / c - a / c;
    if(a % c == 0)
       s++;
    ll h = b / d - a / d;
    if(a % d == 0)
       h++;
    ll f = ged(c, d);
    ll g = b / f - a / f;
    if(a % f == 0)
       g++;
    ans = q - s - h + g;
    cout << ans;
    
}

Measured memory_bytes: 256
fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val a = (1 .. n).map{
        (1 .. readLine()!!.toInt()).map{readLine()!!.split(" ").map{it.toInt()}}
    }
    var ans = 0
    for(i in 0 until (1 shl n)){
        var cnt = 0
        var ok = true
        var b = BooleanArray(n)
        for(j in 0 until n){
            if((i shr j) and 1 == 1){
                b[j] = true
                cnt++
            }
        }
        for(j in 0 until n){
            if(b[j]){
                for(k in 0 until a[j].size){
                    if((a[j][k][1] == 1 && b[a[j][k][0] - 1] == false) || (a[j][k][1] == 0 && b[a[j][k][0] - 1] == true)){
                        ok = false
                    }
                }
            }
        }
        if(ok) ans = Math.max(ans, cnt)
    }
    println(ans)
}

Measured memory_bytes: 42060
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int sx,sy,gx,gy;
int n;
int x[1010],y[1010];
int lx,ly;
int dis[210][210][6];
int obj[210][210];
int dx[6] = {0,1,1,0,-1,-1};
int dy[2][6] = {{1,0,-1,-1,-1,0},{1,1,0,-1,0,1}};

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

  cin >> sx >> sy >> gx >> gy >> n;
  REP(i,n) {
    cin >> x[i] >> y[i];
    obj[x[i]+100][y[i]+100] = 1;
  }
  cin >> lx >> ly;
  MINF(dis);
  dis[sx+100][sy+100][0] = 0;
  using P = tuple<int,int,int,int>;
  priority_queue<P,vector<P>,greater<P>> que;
  que.emplace(0,sx+100,sy+100,0);
  while (!que.empty()) {
    int dd,cx,cy,t;
    tie(dd,cx,cy,t) = que.top(); que.pop();
    if (dis[cx][cy][t] < dd) continue;
    for (int i = 0; i < 6; i++) {
      int nx = cx + dx[i];
      int ny = cy + dy[cx%2][i];
      int com = abs((cx-100)*(cy-100)*t)%6;
      if (IN(nx-100,-lx,lx) && IN(ny-100,-ly,ly) && !obj[nx][ny] && CHMIN(dis[nx][ny][(t+1)%6],dis[cx][cy][t]+(com!=i))) {
        que.emplace(dis[nx][ny][(t+1)%6],nx,ny,(t+1)%6);
      }
    }
    if (CHMIN(dis[cx][cy][(t+1)%6],dis[cx][cy][t]+1)) {
      que.emplace(dis[cx][cy][(t+1)%6],cx,cy,(t+1)%6);
    }
  }
  int ans = INF;
  REP(i,6) CHMIN(ans,dis[gx+100][gy+100][i]);
  cout << (ans == INF ? -1 : ans) << endl;

  return 0;
}


Measured memory_bytes: 5508
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int box[8][8];
	char moji;
	while (1) {
		for (a = 0; a < 8; a++) {
			for (b = 0; b < 8; b++) {
				if(scanf("%1d", &box[a][b]) == EOF) return 0;
			}
		}
		for (a = 0; a < 8; a++) {
			for (b = 0; b < 8; b++) {
				if (box[a][b] == 1 && box[a][b + 1] == 1) {
					if (box[a][b + 2] == 1 && box[a][b + 3] == 1) {
						moji = 'C';
					}
					else if (box[a + 1][b] == 1 && box[a + 1][b + 1] == 1) {
						moji = 'A';
					}
					else if (box[a + 1][b + 1] == 1 && box[a + 1][b + 2] == 1) {
						moji = 'E';
					}
					else if (box[a + 1][b - 1] == 1 && box[a + 1][b] == 1) {
						moji = 'G';
					}
				}
				else if (box[a][b] == 1 && box[a + 1][b] == 1) {
					if (box[a + 2][b] == 1 && box[a + 3][b] == 1) {
						moji = 'B';
					}
					else if (box[a + 1][b - 1] == 1 && box[a + 2][b - 1] == 1) {
						moji = 'D';
					}
					else if (box[a + 1][b + 1] == 1 && box[a + 2][b + 1] == 1) {
						moji = 'F';
					}
				}
			}
		}
		printf("%c\n", moji);
	}
}
		

Measured memory_bytes: 596
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.util.function.Function;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class E {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int H = in.nextInt();
            int W = in.nextInt();
            int K = in.nextInt();
            char[][] S = new char[H][W];
            for (int i = 0; i < H; i++) {
                S[i] = in.next().toCharArray();
            }

            int INF = 1000000000;
            int ans = INF;
            for (int h = 0; h < (1 << H); h++) {
                int g = 0;
                int[] id = new int[H];
                for (int i = 0; i < H; i++) {
                    id[i] = g;
                    if ((h >> i & 1) == 1) {
                        g++;
                    }
                }

                int[] c = new int[g + 1];
                Function<Integer, Boolean> add = (i) -> {
                    for (int j = 0; j < H; j++) {
                        c[id[j]] += S[j][i] - '0';
                        if (c[id[j]] > K) return false;
                    }
                    return true;
                };
                int cnt = g;
                for (int i = 0; i < W; i++) {
                    if (!add.apply(i)) {
                        Arrays.fill(c, 0);
                        cnt++;
                        if (!add.apply(i)) {
                            cnt = INF;
                            break;
                        }
                    }
                }
                ans = Math.min(ans, cnt);
            }
            out.println(ans == INF ? 0 : ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 40504
#include <stdio.h>

int main() {
	int a, b;	
	scanf("%d %d", &a, &b);
	
	int sum = 1;
	
	for(int i = 0; i < a; i++) {
			if(sum*2 < sum+b) {
				sum = sum*2;
			}
			else if (sum*2 > sum+b) {
				sum += b;
			}
			else {
				sum = sum * 2;
			}
		}
	printf("%d", sum);

	return 0;
}


Measured memory_bytes: 1704
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    bool bl = 0;
    int a, b;
    int n, c = 0;
    scanf("%d", &n);
    while (n--)
    {
        scanf("%d %d", &a, &b);
        if (a == b)
            ++c;
        else
            c = 0;
        bl |= (c >= 3);
    }
    if (bl)
        puts("Yes");
    else
        puts("No");
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MAX = 3000;
int dp[MAX][MAX];
int moves[MAX][MAX];

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

	int n = s.length() , m = t.length();

	if(s[n-1]==t[m-1]){
		dp[n-1][m-1] = 1;
		moves[n-1][m-1] = 1;
	}
	else{
		dp[n-1][m-1] = 0;
	}

	for(int i=m-2;i>=0;i--) {
		if(s[n-1]==t[i]) {
			dp[n-1][i] = 1;
			moves[n-1][i] = 1;
		}
		else {
			dp[n-1][i] = dp[n-1][i+1];
			moves[n-1][i] = 3;
		}
	}
	for(int i=n-2;i>=0;i--){
		if(s[i]==t[m-1]) {
			dp[i][m-1] = 1;
			moves[i][m-1] = 1;
		}
		else {
			dp[i][m-1] = dp[i+1][m-1];
			moves[i][m-1] = 2;
		}
	}

	for(int i=n-2;i>=0;i--){
		for(int j=m-2;j>=0;j--){
			if(s[i]==t[j]){
				dp[i][j] = 1 + dp[i+1][j+1];
				moves[i][j] = 1;
			}
			else{
				if(dp[i+1][j] > dp[i][j+1]){
					moves[i][j] = 2;
				}
				else {
					moves[i][j] = 3;
				}
				dp[i][j] = max( dp[i+1][j] , dp[i][j+1] );
			}
		}
	}

	// for(int i=0;i<n;i++){
	// 	for(int j=0;j<m;j++) cout << moves[i][j] << " ";
	// 		cout << endl;
	// }

	// cout << dp[0][0] << endl;
	int len=dp[0][0];
	int cnt = 0 , i=0, j=0;
	while(cnt < len){
		if(moves[i][j]==1){
			cout << s[i];
			i++;j++;
			cnt++;
		}
		else if(moves[i][j]==2){
			i++;
		}
		else if(moves[i][j]==3){
			j++;
		}
	}
	cout << endl;

	return 0;
}

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

int main() {
	// your code goes here
	int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << arr[k - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<vector<char>> g;
int main(){
    string s, t;   cin >> s >> t;
    vector<vector<ll>> key(26);
    ll n=s.size();
    rep(i, n){
        key[s[i]-'a'].push_back(i+1);
    }
    ll res=0;
    rep(i, t.size()){
        if(!key[t[i]-'a'].size()) res = -1;
    }
    
    if(0<=res){
        ll now=0;
        rep(i, t.size()){
            ll c = t[i]-'a';
            auto itr = upper_bound(ALL(key[c]), now);
            if(itr==key[c].end()){
                res += s.size()-now + *key[c].begin();
                now = *key[c].begin();
            }else{
                res += *itr-now;
                now = *itr;
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 4640
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }



main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (auto &i : a) cin >> i;
    ll ans = 0;
    map <int, int> cnt;
    for (int i = 0; i < n; i++) {
        ans += cnt[i - a[i]];
        ++cnt[a[i] + i];
    }
    cout << ans << '\n';
}


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


int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  int ans=0;
  rep(i, n){
    if(i < k) ans += x;
    else ans += y;
  }
    
  cout << ans << endl;  
  return 0;
  
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n = ni()
a = sorted(nl())
ans = 1
for ele in a:
    ans *= ele
    if ans > 10 ** 18:
        break

if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

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

bool dp[80][80][170*170];

int main() {
    int h,w;
    cin >> h >> w;
    int a[h][w];
    int b[h][w];
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
        }
    }
    rep(i,h){
        rep(j,w){
            cin >> b[i][j];
        }
    }
    dp[0][0][170*85 + a[0][0] - b[0][0]] = 1;
    dp[0][0][170*85 + b[0][0] - a[0][0]] = 1;

    rep(i,h){
        rep(j,w){
            if(i < h - 1){
                rep(k,170*170){
                    if(dp[i][j][k]){
                        dp[i+1][j][k+a[i+1][j] - b[i+1][j]] = 1;
                        dp[i+1][j][k+b[i+1][j] - a[i+1][j]] = 1;
                    }
                }
            }
            if(j < w - 1){
                rep(k,170*170){
                    if(dp[i][j][k]){
                        dp[i][j+1][k+a[i][j+1] - b[i][j+1]] = 1;
                        dp[i][j+1][k+b[i][j+1] - a[i][j+1]] = 1;
                    }
                }
            }
        }
    }

    int ans = 1001001001;

    rep(k,170*170){
        if(dp[h-1][w-1][k]){
            ans = min(ans, abs(85*170 - k));
        }
    }

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



Measured memory_bytes: 179584
let input = require('fs').readFileSync('/dev/stdin', 'utf8')
// let input = require('fs').readFileSync('./sample_b.txt', 'utf8')
.split(/\n| /)
// .map(item => parseInt(item))
.slice(0,-1)

const number = input[0].split("").map(item => parseInt(item))
const isNine = number.reduce((prev, item) => prev + item ,0) % 9 === 0

console.log(isNine ? 'Yes' : 'No')

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


def solve(N: int, D: int):
    if N % (2*D + 1) == 0:
        print(N // (2*D + 1))
    else:
        print(N // (2*D + 1) + 1)
    return


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


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
const int maxn = 100000;
int n, k;
int a[maxn + 5];
int main() {
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; i++)scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	int Min = 1e9 + 7;
	for(int i = 1; i <= n - k + 1; i++)Min = min(Min, abs(a[i] - a[i + k - 1]));
	printf("%d\n", Min);
	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = new int[4];

            for (int i = 0; i < 4; i++)
            {
                input[i] = Int32.Parse(Console.ReadLine());
            }

            int result = 0;

            int sum = input[3];
            int coin500 = input[0];
            int coin100 = input[1];
            int coin50 = input[2];

            for (int i = 0; i <= coin500; i++)
            {
                for (int j = 0; j <= coin100; j++)
                {
                    for (int k = 0; k <= coin50; k++)
                    {
                        if (500 * i + 100 * j + 50 * k == sum)
                        {
                            result++;
                        }
                    }
                }
            }

            Console.WriteLine(result);


        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int mod=1000000007;
int numpath(int n,int m,vector<vector<char>> &a){
	int dp[n][m];
	dp[0][0]=1;
	for(int i=1;i<n;i++){
		if(a[i][0]=='#')
		dp[i][0]=0;
		else
		dp[i][0]=dp[i-1][0];
	}
	for(int j=1;j<m;j++){
		if(a[0][j]=='#')
		dp[0][j]=0;
		else
		dp[0][j]=dp[0][j-1];
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<m;j++){
			if(a[i][j]=='#'){
				dp[i][j]=0;
			}
			else
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
		}
	}
	return dp[n-1][m-1];
}
int main() {
	int m,n;
	cin>>n>>m;
	vector<vector<char>> a(n);
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			char m;cin>>m;
			a[i].push_back(m);
		}
	}
	cout<<numpath(n,m,a)<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 5248
#include <iostream>

using namespace std;

int main() {
    int n, sum;
    sum = 0;
    cin >> n;
    int t[n];
    for(int i = 0; i < n; i++) {
        cin >> t[i];
        sum += t[i];
    }
    int m;
    cin >> m;
    int p[m], x[m];
    for(int i = 0; i < m; i++) { 
        cin >> p[i] >> x[i];
    }
    int index;
    for(int i = 0; i < m; i++) {
        index = p[i] - 1;
        cout << (sum - t[index] + x[i]) << endl;
    }
}

Measured memory_bytes: 256
<?php
$strs = "abcdefghijklmnopqrstuvwxyz";
fscanf(STDIN, "%d", $n);
$s = [];
$counter = [];
for ($h = 0; $h<$n;$h++) {
    fscanf(STDIN, "%s", $s[$h]);    
}

for ($i = 0; $i < $n; $i++) {
    for ($m = 0;$m < strlen($strs); $m++) {
        $counter[$strs[$m]][$i] = 0;
    }
    
    for ($k = 0; $k < strlen($s[$i]); $k++) {
        $counter[$s[$i][$k]][$i] += 1;
    }
}

$result = [];
for ($m = 0; $m < strlen($strs); $m++) {
    $result[$strs[$m]] = min($counter[$strs[$m]]);
    for ($u = 0; $u < $result[$strs[$m]]; $u++) {
        echo $strs[$m];
    }
}

echo "\n";

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

int a[3];
signed main(){
	int b;cin>>b;
	for(int c=0;c<b;c++){
		int d;scanf("%d",&d);
		a[d%3]++;
		}
	if(a[1]==0&&a[2]==0){puts("1");return 0;}
	else{
		int ans=a[0];
		int K=min(a[1],a[2]);
		ans+=K*2;
		a[1]-=K;
		a[2]-=K;
		ans+=min(3,a[1]);
		ans+=min(3,a[2]);
		cout<<ans<<endl;
		}	
	}

Measured memory_bytes: 3244
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) REP(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
typedef long long ll;

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    cout << a[1] - a[0] + a[2] - a[1] << endl;
    return 0;
}




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

int main(){
  long long H,W;
  cin >> H >> W;

  long long ans = 10000000000;
  for (int i = 0; i < 2; i++)
  {
    for (long long h = 1; h < H; h++)
    {
      long long s1 = max({h*W,(H-h)/2*W,(H-h-(H-h)/2)*W}) - min({h*W,(H-h)/2*W,(H-h-(H-h)/2)*W});
      long long s2 = max({h*W,W/2*(H-h),(H-h)*(W-W/2)}) - min({h*W,(W/2)*(H-h),(H-h)*(W-W/2)});
      ans = min({ans,s1,s2});
    }
    swap(H,W);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

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

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int32_t main(){
	ios::sync_with_stdio(false);
    int n, k;
    cin>>n>>k;
    string s;
    cin>>s;
    if(s[k-1]=='A'){
        s[k-1]='a';
    }
    if(s[k-1]=='B'){
        s[k-1]='b';   
    }
    if(s[k-1]=='C'){
        s[k-1]='c';
    }
    cout<<s<<"\n";



	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long n = long.Parse(input[0]);
		long k = long.Parse(input[1]);
    long answer = long.MaxValue;
    long[] heights = new long[n];
    for(int i = 0; i < n; i++)
    {
      heights[i] = long.Parse(Console.ReadLine());
    }
    Array.Sort(heights);

    for(int i = 0; i <= n-k; i++)
    {
      answer = Math.Min(answer, heights[i+k-1]-heights[i]);
    }
	
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 15964
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int h, m, d;
    int a, b;
    while (cin >> a >> b)
    {
        if (((-1000 <= a) && (a <= 1000)) && ((-1000 <= b) && (b <= 1000)))
        {
            if (a < b)
            {
                cout << "a < b" << endl;
            }
            else if (a > b)
            {
                cout << "a > b" << endl;
            }
            else
            {
                cout << "a == b" << endl;
            }
        }
    }
    return (0);
}

Measured memory_bytes: 3100
N = int(input())
city = []

for i in range(N):
    city.append(list(map(int, input().split())))

sum = 0

for i in range(N):
    for j in range(N):
        if i > j:
            sum += ((city[i][0]-city[j][0])**2 + (city[i][1]-city[j][1])**2) ** (1/2)

ave = 2 * sum / N
print(ave)

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

int main()
{
    int a,b;
    cin >> a >> b;
    if(a <= 5) cout << 0 << "\n";
    else if(a < 13) cout << b/2<< "\n";
    else cout << b << "\n";
    return 0;
}


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

#define ll long long int
ll mod=1e9+7;

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    ll t = 1;
    // cin >> t;
    while(t--)
    {        
        ll n,i,j;
        cin >> n;
        ll arr[n+1];
        ll ans = 0;
        for(i=1;i<=n;i++)
        {
            cin >> arr[i];
            if(i%2 !=0 && arr[i]%2 !=0)
            {
                ans++;
            }
        }
        cout << ans << '\n';
    }
    
    return 0;
}

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

int main() {
  int n;
  std::cin >> n;
  if (n == 1) {
    std::cout << "Hello World" << std::endl;
  } else {
    int a, b;
    std::cin >> a >> b;
    std::cout << a + b << std::endl;
  }
  return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

'''
import random
N = 200000
A = [random.randint(1,10**9) for i in range(N)]
#A = [1]*N
B = A[:]
for i in range(200000):
    j = random.randint(0,N-1)
    #j = 1
    B[j] += B[j-1] + B[(j+1)%N]
    '''

class SegmentTree:
    def __init__(self,data,op,default):
        N = len(data)
        self.N = N
        self.op = op
        self.default = default
        self.l = 2**((N-1).bit_length())
        self.data = [default]*self.l + data + [default]*(self.l-N)
        for i in range(self.l-1,0,-1):
            self.data[i] = op(self.data[2*i], self.data[2*i+1])

    def get_data(self):
        return self.data[self.l:self.l + self.N]

    def set(self,i,val):
        i += self.l
        self.data[i] = val
        i = i//2
        while i > 0:
            self.data[i] = self.op(self.data[2*i], self.data[2*i+1])
            i = i//2

    def get(self,i,j):
        i += self.l
        j += self.l
        s = self.default 
        while j-i > 0:
            if i & 1:
                s = self.op(s,self.data[i])
                i += 1
            if j & 1:
                s = self.op(s,self.data[j-1])
                j -= 1
            i, j = i//2, j//2
        return s

D = [b-a for b,a in zip(B,A)]
D = [(d,i) for i,d in enumerate(D)]

inf = 10**16
seg = SegmentTree(D,max,(-inf,-inf))

cnt = 0
while True:
    m, i = seg.get(0,N)
    if m == 0:
        break
    l = B[i-1]
    r = B[(i+1) % N]
    diff = l+r
    n = (m - max(l,r)-1)//diff + 1
    if n <= 0 or m-diff*n < 0:
        print(-1)
        exit()
    seg.set(i,(m-diff*n,i))
    B[i] -= diff*n
    cnt += n

print(cnt)



Measured memory_bytes: 148084
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class Program{
  public static void Main(){

    int n = int.Parse(Console.ReadLine());
    int m = 1;
    while(n >= m){
      m *= 2;
    }
    Console.WriteLine(m/2);
  }
}


Measured memory_bytes: 11092
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
using namespace std;

typedef unsigned int uint;
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> ii;
typedef pair<int64, int64> int64int64;
typedef vector<int> vint;
typedef vector<int64> vint64;
typedef vector<uint64> vuint64;
typedef vector<vint> vvint;
typedef vector<vint64> vvint64;
typedef vector<vuint64> vvuint64;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;

#define mp make_pair
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define fori(n) for(int i = 0; i < n; ++i)
#define forj(n) for(int j = 0; j < n; ++j)
#define fork(n) for(int k = 0; k < n; ++k)
#define INF9 (int64)(1e9)
#define INF18 (int64)(1e18)

template<typename T>
struct compF{
	bool operator()(const pair<T, T> &a, const pair<T, T> &b){
		return a.first < b.first;
	}
};

template<typename T>
struct compS{
	bool operator()(const pair<T, T> &a, const pair<T, T> &b){
		return a.second < b.second;
	}
};

template<typename T>
void printMatrix(const string &txt, vector<vector<T>> &a){
	cout << txt;
	fori(a.size()){
		forj(a[i].size())
			cout << a[i][j] << ' ';

		cout << endl;
	}
}

template<typename T>
void printVector(const string &txt, vector<T> &a){
	cout << txt;
	for (int i = 0; i < a.size(); ++i)
		cout << a[i] << ' ';
	cout << endl;
}

template<typename T>
void readVector(int n, vector<T> &a){
	if (a.size() < n)
		a.resize(n);

	fori(n) cin >> a[i];
}

template<typename T1, typename T2>
bool exist(map<T1, T2> &m, T1 x){
	if (m.find(x) == m.end())
		return false;

	return true;
}

int64 gcd(int64 a, int64 b){
	while (a != 0 && b != 0){
		if (b > a)
			b %= a;
		else
			a %= b;
	}

	return a + b;
}

int64 minFactor(int64 x){
	for (int64 i = 2; i * i <= x; ++i)
		if (x % i == 0)
			return i;

	return x;
}

int64 allFactors(int64 x, vint64 &prms, vint64 &prm_cnt){
	prms.clear();
	prm_cnt.clear();
	while (x > 1){
		int64 t = minFactor(x);
		prms.push_back(t);
		int s = prms.size() - 1;
		prm_cnt.push_back(0);
		while (x % t == 0){
			x /= t;
			++prm_cnt[s];
		}
	}

	return 0;
}

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie();
	
	int n;
	cin >> n;

	int nn = ((n + 999) / 1000) * 1000;
	cout << nn - n << endl;

	return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;


void solve(ll vn){
    set<ll> g[vn];
    ll s = 1;

    rep(src, vn){
        for(ll to = src+1; to < vn; to++){
            g[src].insert(s);
            g[to].insert(s);
            s++;
        }
    }

    rep(src, vn){
        cout << vn-1;
        for(auto e : g[src]){
            cout << " " << e;
        }
        cout << endl;
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n;
    cin >> n;
   
    for(ll vn = 1; vn <= 450; vn++){
        ll en = vn*(vn-1)/2;
        if(en == n){
            cout << "Yes" << endl;
            cout << vn << endl;
            solve(vn);
            return 0;
        }
    }

    cout << "No" << endl;


    return 0;
}



Measured memory_bytes: 10752
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] data = new int[N];
		int sum= 0;
		for(int i =0;i < N;i++){
			data[i] = scan.nextInt();
		}
		for(int i=0;i<N;i++){
			while(data[i]%2 ==0){
				sum++;
				data[i] /= 2;
			}
		}

		System.out.println(sum);

	}





}

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int tmp;
    int n, k;
    cin >> n >> k;
    int a[n], d[n+1]={};
    REP(i,n) cin >> a[i];
    REP(i,k){
    	REP(j,n+1) d[j]=0;
    	REP(j, n){
    		d[max(0,j-a[j])]++;
    		d[min(n-1, j+a[j])+1]--;
      	}
        bool ch = true;
    	REP(j, n){
    		if(j==0) a[j] = d[j];
    		else a[j] = a[j-1] + d[j];
    		if(a[j] < n) ch = false;
    	}
    	if(ch) break;
    }
    REP(i,n) cout << a[i] << " ";
    cout << endl;
}


Measured memory_bytes: 5188
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }




int main() {
	int n, k;
	cin >> n >> k;
	if (k == 1) {
		cout << 0 << endl;
		return 0;
	}
	cout << n-k << endl;
	
}



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

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		p[i]--;
	}

	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		if (p[i] == i) {
			swap(p[i], p[i + 1]);
			ans++;
		}
	}
	ans += (p[n - 1] == n - 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

int N;
cin>>N;

long long A[N];
long long B[N];

rep(i,N)cin>>A[i];

rep(i,N)cin>>B[i];

long long minus=0,plus=0;
long long sumA=0,sumB=0;
//plus
rep(i,N){
    sumA+=A[i];
    sumB+=B[i];
    if(A[i]>=B[i])plus+=A[i]-B[i];
    else{
        minus+=ceil(double(B[i]-A[i])/2);
    }
}

long long cnt=sumB-sumA;//cnt=最高操作回数
if(cnt<0){
    cout<<"No"<<endl;
    return 0;
}

if(plus>cnt || minus>cnt ){
    cout<<"No"<<endl;
}
else{
    cout<<"Yes"<<endl;
}

 return 0;
}
/*
3
1 2 3
5 2 2

Yes


5
3 1 4 1 5
2 7 1 8 2

No

5
2 7 1 8 2
3 1 4 1 5

No
*/

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
import  itertools

n = int(input())
l = list( map(int, input().split()))
l.sort()

ans = 0
for v in itertools.combinations(l, 3):
    if v[0] == v[1] or v[1] == v[2]:
        continue
    elif v[2] < v[0]+v[1]: ans+=1

print(ans)


Measured memory_bytes: 9100
import sys
import math
from collections import Counter
import itertools
import fractions
import datetime
from decimal import Decimal
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

N=II()
A=LI()
B=LI()

cnt=0
i = -1
for b in B:
    i+=1
    if A[i] > B[i]:
        A[i]-=B[i]
        cnt+=B[i]
        continue
    else:
        cnt+=A[i]
        B[i]-=A[i]
    if A[i+1] > B[i]:
        A[i+1] -= B[i]
        cnt+=B[i]
    else:
        cnt+=A[i+1]
        A[i+1] = 0
print(cnt)

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

int main()
{
 int k;
 cin>>k;
  string S =  "ACL";
  string R;
  for(int i=1;i<=k;i++)
  {
    R = R + S;
  }
  cout<<R<<endl;
  return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main()
{
	int h, w, n;
	scanf("%d %d %d", &h, &w, &n);
	int sr, sc;
	scanf("%d %d", &sr, &sc);
	char s[200005], t[200005];
	scanf("%s%s", s, t);
	int z;
	z = sr;
	int i;
	for (i = 0; i < n; i++)
	{
		if (s[i] == 'U')
			z--;
		if (z < 1)
		{
			printf("NO\n");
			return 0;
		}
		if (t[i] == 'D' && z < h)
			z++;
	}
	z = sr;
	for (i = 0; i < n; i++)
	{
		if (s[i] == 'D')
			z++;
		if (z > h)
		{
			printf("NO\n");
			return 0;
		}
		if (t[i] == 'U' && z > 1)
			z--;
	}
	z = sc;
	for (i = 0; i < n; i++)
	{
		if (s[i] == 'L')
			z--;
		if (z < 1)
		{
			printf("NO\n");
			return 0;
		}
		if (t[i] == 'R' && z < w)
			z++;
	}
	z = sc;
	for (i = 0; i < n; i++)
	{
		if (s[i] == 'R')
			z++;
		if (z > w)
		{
			printf("NO\n");
			return 0;
		}
		if (t[i] == 'L' && z > 1)
			z--;
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = INT_MAX;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
const int MOD = 1000000007;

//-------------------------------------

using P = pair<int, int>;

void dfs(int x, int y, int h, int w, vector<vector<int>> &g, vector<vector<bool>> &seen)
{
    stack<P> st;
    st.push(P(x, y));
    while (st.size())
    {
        P now = st.top();
        st.pop();
        seen[now.second][now.first] = true;
        for (int dx = -1; dx <= 1; dx++)
        {
            for (int dy = -1; dy <= 1; dy++)
            {
                int nx = now.first + dx;
                int ny = now.second + dy;
                if (0 <= nx && nx < w && 0 <= ny && ny < h && !seen[ny][nx] && g[ny][nx] == 1)
                {
                    st.push(P(nx, ny));
                }
            }
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (true)
    {
        int w, h;
        cin >> w >> h;
        if (w == 0 && h == 0)
        {
            return 0;
        }
        // 陸は1、海は0
        vector<vector<int>> g(h, vector<int>(w));
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                cin >> g[i][j];
            }
        }
        vector<vector<bool>> seen(h, vector<bool>(w, false));
        int ans = 0;
        for (int y = 0; y < h; y++)
        {
            for (int x = 0; x < w; x++)
            {
                if (!seen[y][x] && g[y][x] == 1)
                {
                    dfs(x, y, h, w, g, seen);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3132
// たなこふ先生の input マクロ (´･_･`)
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn gcd(a: usize, b: usize) -> usize {
    assert!(a > 0 && b > 0);

    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let b = a[0];

    println!("{}", a.into_iter().fold(b, |acc, a| gcd(a, acc)));
}


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

int main (){
    int X, Y;
    bool ans = 1;
    cin >> X >> Y;

    //cout << ans << endl;
    ans =  (Y+1)%2;
    if(Y-X <= 0)ans = 0;
    if(Y-2*X < 0)ans = 0;
    if(Y-4*X > 0)ans = 0;
        if(ans){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }

    
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	string s;
	cin >> s;
	ll ans = 0;
	for (ll i = 0; i < 3; i++) {
		ll j = i;
		while (j < 3 && s[j] == 'R') j++;
		ans = max(ans, j - i);
	}
	cout << ans << endl;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;

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

	vector<int> oks(N + 1, true);
	for(int i=0; i < M; ++i){
		int a;
		cin >> a;
		oks[a] = false;
	}

	vector<ll>dp(N + 1);
	dp[0] = 1;
	for(int now = 0; now < N; ++now){
		for(int next = now + 1; next <= min(N, now + 2); ++next){
			if(oks[next]){
				dp[next] += dp[now];
				dp[next] %= mod;
			}
		}
	}

	cout << dp[N] << endl;
	return 0;
}

Measured memory_bytes: 1408
from collections import deque
def solve():
  h,w = (int(i) for i in input().split())
  maze = ["0"*(w+2)]
  for i in range(h):
    maze.append("0"+input()+"0")
  maze.append("0"*(w+2))
  black = deque([])
  count = 0
  visit = [[False]*(w+2) for _ in range(h+2)]
  
  for i in range(h+2):
    for j in range(w+2):
      if maze[i][j] == "#":
        black.append((0,i,j)) #move,h,w

  d = [(0,1),(1,0),(-1,0),(0,-1)]
  ans = 0
  
  while count != h*w:
    move,y,x = black.popleft()
    #print(move,y,x)
    if visit[y][x]:
      continue
    else:
      visit[y][x] = True
      count += 1
      for dy,dx in d:
        ny,nx = y+dy,x+dx
        if visit[ny][nx]:
          continue
        elif maze[ny][nx] ==".":
          black.append((move+1,ny,nx))
  print(move)
          

    
solve()

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[1000000];
//P r[1000000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a[1000000],b,c,cmp,data,m,h,x,y,xcmp=0,ycmp=0,sum=0,t;

string s,w;

vector<int> z;

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

       cin >> n >> t;
       rep(i,n){
           cin >> a[i];
       }
       rep(i,n){
           if(i==n-1){
               break;
           }
           ans+=min(t,a[i+1]-a[i]);
           //Cout(ans);
       }
       Cout(ans+t);
return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;


unsigned long long int gcd(unsigned long long int a, unsigned long long int b)
{
	if(b == 0)
	{
		return(a);
	}
	else
	{
		gcd(b, a % b);
	}
}

unsigned long long int lcm(unsigned long long int a, unsigned long long int b, unsigned long long int g)
{
	return(a * b / g);
}

void solve()
{
	int m, n;
	while(cin >> m >> n)
	{
		int g = gcd(m, n);
		cout << g << " " <<	lcm(m, n, g) << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
# ABC084C - Special Trains
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    arr = tuple(tuple(map(int, input().split())) for _ in range(n - 1))
    for i in range(n):
        cur = 0
        for c, s, f in arr[i:]:
            if cur <= s:
                cur = s + c
            else:
                cur = (cur + f - 1) // f * f + c
        print(cur)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188