akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << (char)(a[0] - 'a' + 'A') << (char)(b[0] - 'a' + 'A') << (char)(c[0] - 'a' + 'A') << '\n';
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    int N,K,S; cin >> N >> K >> S;
    int ans[N];
    fill(ans,ans+N,INF);
    if(S==INF){
        for(int i=0;i<N-K;i++){
            ans[i]=1;
        }
    }else{
        for(int i=0;i<K;i++){
            ans[i]=S;
        }
    }
    for(int i=0;i<N;i++){
        cout << ans[i] << " ";
    }
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        ll p, q;
        cin >> p >> q;
        if(p * p + q * q <= d * d) ans++;
    }
    cout << ans << endl;
}

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

int main(){
    int x,y,tmp;
    cin>>x>>y;
    while(x!=0||y!=0){
        if(x>y){
            tmp=x;
            x=y;
            y=tmp;
        }
        cout<<x<<" "<<y<<endl;
        cin>>x>>y;
    }
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

vector<int> G[100010];
int d[2][100010];
void dfs(int s, int v, int parent) {
	for (int to : G[v]) {
		if (to == parent) continue;
		d[s][to] = d[s][v] + 1;
		dfs(s, to, v);
	}
}
int main()
{
	int N, u, v;
	cin >> N >> u >> v;
	u--; v--;
	for (int i = 0; i < N - 1; i++) {
		int A, B;
		cin >> A >> B;
		A--; B--;
		G[A].push_back(B);
		G[B].push_back(A);
	}
	dfs(0, u, -1);
	dfs(1, v, -1);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (d[0][i] < d[1][i]) {
			ans = max(ans, d[1][i] - 1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 12928
def main():
    n, k = map(int, input().split())
    xycs = [input().split() for _ in range(n)]
    tbl = [[0 for _ in range(k*2+1)] for _ in range(k+1)]
    
    for sx, sy, c in xycs:
        rx, ry = map(int, (sx, sy))
        mx, my = (rx-1) % (2*k), (ry-1) % (2*k)
        dx, dy = (mx + is_black(c)*k + (my<k)*k) % (2*k), my%k

        if dx < k:
            tbl[0][0] += 1
            tbl[0][dx+1] -= 1
            tbl[dy+1][0] -= 1
            tbl[dy+1][dx+1] += 2

            tbl[0][dx+1+k] += 1
            tbl[dy+1][dx+1+k] -= 2
        else:
            dx = dx % k
            tbl[0][dx+1] += 1
            tbl[dy+1][0] += 1
            tbl[dy+1][dx+1] -= 2

            tbl[0][dx+1+k] -= 1
            tbl[dy+1][dx+1+k] += 2
    for i in range(k):
        for j in range(1, 2*k):
            tbl[i][j] += tbl[i][j-1]
    for i in range(1, k):
        for j in range(0, 2*k):
            tbl[i][j] += tbl[i-1][j]
    print(max(max(t for t in ts) for ts in tbl[:k][:2*k]))

def is_black(c):
    return 1 if c=='B' else 0

main()

Measured memory_bytes: 113544
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll INFll = 1e18;
#define put(n) cout<<(n)<<endl
#define Cout(n) cout<<(n)
#define rep(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define rrep(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define MP make_pair
#define pb(q) push_back(q)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    vector<int> num(5,0);
    rep(i,0,N){
        int a;
        cin>>a;
        if(a%4==0) ++num[4];
        else if(a%2==0) ++num[2];
        else ++num[0];
    }

    if(num[2]) ++num[0];

    cout<<(++num[4]>=num[0]?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))
P = sum(X) // N
result1 = 0
result2 = 0

for x in X:
  result1 += (x - P)**2
  result2 += (x - P - 1)**2

if result1 <= result2:
  result = result1
elif result1 > result2:
  result = result2


print(result)

Measured memory_bytes: 9180
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
struct edge{
    ll to;
    ll w;
};
static const ll max_n = 200010;
static const ll max_abs_value = 1000000010;
static const ll mod = 1000000007;
vector<ll>dp(max_n);
vector<vector<ll>>adj_list(max_n);
vector<ll> all_answer(max_n);
vector<ll> mod_inv(max_n);
vector<ll> mod_factorial_inv(max_n);
vector<ll> mod_factorial_power(max_n);
vector<ll> sub_tree_size(max_n);
// int N;
ll N;

ll mod_pow(ll base, ll power){
    if(power==0) return 1;
    ll u = mod_pow(base, power/2);
    u = (u * u) % mod;
    if(power % 2) u = (u * base) % mod;
    return u;
}

void init_mod_inv(ll N){
    for(ll i=N;i>=0;i--){
        mod_inv[i] = mod_pow(i, mod-2);
    }    
}

void init_mod_factorial(ll N){
    ll temp = 1;
    for(ll i=1;i<=N;i++){
        temp = (temp * mod_inv[i]) % mod;
        mod_factorial_inv[i] = temp;
    }
    mod_factorial_inv[0] = 1;
}

void init_mod_power(ll N){
    mod_factorial_power[0] = 1;
    mod_factorial_power[1] = 1;
    for(ll i=2;i<=N;i++){
        mod_factorial_power[i] = (mod_factorial_power[i-1] * i) % mod;
    }
}

void init_all(){
    // init_mod_inv(N);
    // init_mod_factorial(N);
    init_mod_power(N);
}

void dfs1(ll st, ll parent){
    // ll this_permute = 1;
    // ll num_child = 0;
    sub_tree_size[st] = 1;
    for(auto next:adj_list[st]){
        if(next == parent) continue;
        dfs1(next, st);
        // this_permute *= permute_num[next];
        // this_permute = this_permute % mod;
        sub_tree_size[st] += sub_tree_size[next];
        // this_permute = (this_permute * mod_factorial_inv[sub_tree_size[next]]) % mod ;
        // num_child ++;
    }

    dp[0] = (dp[0] * mod_pow(sub_tree_size[st], mod-2)) % mod;
}

void dfs2(ll st, ll parent){
    for(ll child: adj_list[st]){
        if(child == parent) continue;
        dp[child] = (dp[st] * sub_tree_size[child]) % mod;
        dp[child] = (dp[child] * mod_pow(N-sub_tree_size[child], mod-2)) % mod;
        dfs2(child, st);
    }

}

int main(){
    // int u, v;
    // bool updated = false;
    ll ans = 0, u, v;
    scanf("%lld", &N);
    init_all();
    // printf("input\n");

    for(ll i=0;i<N-1;i++){
        scanf("%lld %lld", &u, &v);
        u --;
        v --;
        adj_list[u].emplace_back(v);
        adj_list[v].emplace_back(u);
    }

    // printf("dfs1 start\n");
    dp[0] = mod_factorial_power[N];
    dfs1(0, -1);
    // printf("dfs2 end\n");
    // for(ll i=0;i<N;i++){
    //     printf("permute [%lld]=%lld\n", i, permute_num[i]);
    // }

    dfs2(0, -1);
    for(ll i=0;i<N;i++){
        printf("%lld\n", dp[i]);
    }

    return 0;

}

Measured memory_bytes: 24048
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	for (int i = 0; i <= N / 4; i++) {
		for (int j = 0; j <= N / 7; j++) {
			if (4 * i + j * 7 == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

namespace ALDS1_11_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var neibors = Enumerable.Repeat(0, n).Select(x => new List<int>()).ToArray();

            for (int i = 0; i < n; i++)
            {
                var input = ReadInt();
                for (int j = 0; j < input[1]; j++)
                {
                    neibors[input[0] - 1].Add(input[j + 2] - 1);
                }
            }

            int[] d = Enumerable.Repeat(0, n).Select(X => -1).ToArray();
            Queue<int> que = new Queue<int>();

            //スタート
            d[0] = 0;
            que.Enqueue(0);

            while (que.Count > 0)
            {
                var elem = que.Dequeue();

                foreach (var item in neibors[elem])
                {
                    if (d[item] != -1) continue;

                    que.Enqueue(item);
                    d[item] = d[elem] + 1;
                }
            }

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(i + 1 + " " + d[i]);
            }
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}



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

int main() {
    string S; cin >> S;
    int a=0,b=0;
    rep(i,S.size()){
        if(S[i] == '0') a++;
        else b++;
    }
    cout << min(a,b)*2 << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
//******************************************************************************
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int A,B,C,D,E,F,X,Y,Z,N,M,W,R,Q,G;
string s,t;

signed main()
{
	int ans = 0;
	cin>>R>>B>>G>>N;
	rep(i,0,3001){
		rep(j,0,3001){
			if(N-i*R-j*B>=0&&(N-i*R-j*B)%G==0)ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
parseint(x) = parse(Int, x)
readints() = map(parseint, readline() |> split)

function main()
    n, l = readints()
    d = [l + i - 1 for i = 1:n]
    sort!(d, lt = (u, v) -> abs(u) < abs(v))
    println(sum(d[2:end]))
end

main()


Measured memory_bytes: 117256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

int main(){
	int n,q,label,com,x,y,to_change1,to_change2;

	scanf("%d %d",&n,&q);
	int table[n];

	for(int i = 0; i < n; i++)table[i] = i;
	label = n;

	for(int i = 0; i < q; i++){
		scanf("%d %d %d",&com,&x,&y);

		if(com == 1){
			if(table[x] == table[y])printf("1\n");
			else{
				printf("0\n");
			}
		}else{
			if(table[x] == table[y])continue;

			to_change1 = table[x];
			to_change2 = table[y];

			for(int i = 0; i < n; i++){
				if(table[i] == to_change1 || table[i] == to_change2){
					table[i] = label;
				}
			}
			label++;
		}
	}

    return 0;
}

Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
long long  N,M;

int main(){
 long long i,j,count=0,ch=0;
  scanf("%lld%lld",&N,&M);
  /*  for(i=1;i<=N;i++){
    for(j=1;j<=M;j++){
      if(i>1){
	ch++;
	if(j>1)ch++;
	if(j<M)ch++;
      }
      if(i<N){
	ch++;
	if(j>1)ch++;
	if(j<M)ch++;
      }
      if(j>1)ch++;
      if(j<M)ch++;
      if(ch%2==0)count++;
      ch=0;
      }

      }*/
  if(N==1&&M==1)count=1;
  else if(N==1)count = M-2;
  else if(M==1)count = N-2;
  else if(N==2||M==2) count = 0;
  else count = (M-2)*(N-2);
  printf("%lld\n",count);
  return 0;
}


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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define DEBTG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
	int x = 0, fh = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	return x * fh;
}

void File() {
#ifdef zjp_shadow
	freopen ("F.in", "r", stdin);
	freopen ("F.out", "w", stdout);
#endif
}

const int N = 15, Mod = 1e9 + 7;

int n, m, G[N], Table[1 << N], dp[1 << N];

int main () {

	File();

	n = read(); m = read();
	For (i, 1, m) { int u = read() - 1, v = read() - 1; G[u] |= (1 << v); }

	int maxsta = (1 << n) - 1; dp[0] = 1;
	For (i, 0, maxsta) Table[i] = 1 << __builtin_popcount(i);

	For (S, 2, maxsta) if ((S & 1) == ((S >> 1) & 1))
		for (int U = S; U; U = (U - 1) & S) if ((U & 1) == ((U >> 1) & 1)) {
			int Ways = 1, T = S ^ U;
			For (p, 0, n - 1) if ((S >> p) & 1) {
				if ((U >> p) & 1) Ways = 1ll * Table[G[p] & T] * Ways % Mod;
				else Ways = 1ll * (Table[G[p] & U] - 1) * Ways % Mod;
			}
			dp[S] = (dp[S] + 1ll * Ways * dp[T]) % Mod;
		}

	int ans = 1; For (i, 1, m) ans = (ans << 1) % Mod;
	printf ("%d\n", (ans + Mod - dp[maxsta]) % Mod);

	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#define MOD 1000000007
#define smax(a,b) ((a)>(b)?(a):(b))

int lc(const void *a,const void *b){
    if(*(long*)a == *(long*)b)return 0;
    return *(long*)a < *(long*)b ? -1:1;
}

static inline long mdml(long a,long b){
    return  ((long long)a * b) % MOD;
}

static inline long mdiv(long num){
    unsigned long mdnm = MOD - 2ul;
    long res = 1;
    while(mdnm){
        if(1ul & mdnm)res = mdml(res,num);
        num = mdml(num,num);        
        mdnm >>= 1;
    }
    return res;
}

int main(void){
    int n;
    scanf("%d",&n);
    long iar[n],arcp[n];
    for(int i = 0;i < n;i++)scanf("%ld",&iar[i]);
    for(int i = 0;i < n;i++)arcp[i] = iar[i];
    int fc[1000][n];
    for(int i = 0;i < 1000;i++)for(int j = 0;j < n;j++)fc[i][j] = 0;
    for(int i = 0;i < n;i++)for(int fci = 1;fci < 1000;fci++)
        while(!(iar[i] % (fci+1))){
            iar[i] /= (fci+1);
            fc[fci][i]++;
        }
    int mfc[1000] = {0};
    long sumtmp = 1;
    for(int i = 1;i < 1000;i++)for(int iari = 0;iari < n;iari++)mfc[i] = smax(mfc[i],fc[i][iari]);
    for(int i = 1;i < 1000;i++)for(int fcc = 0;fcc < mfc[i];fcc++)sumtmp = mdml(sumtmp,i+1);
    qsort(iar,n,sizeof(long),lc);
    long bef;
    for(int i = 0;i < n;i++)if(!i || iar[i] != bef){
        bef = iar[i];
        sumtmp = mdml(sumtmp,iar[i]);
    }
    long sumas = 0;
    for(int i = 0;i < n;i++)sumas = (sumas + mdml(sumtmp,mdiv(arcp[i]))) % MOD;
    printf("%ld",sumas);
    return 0;
}

Measured memory_bytes: 39424
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

import sys
sys.setrecursionlimit(10**6)

def dfs(u):
    global grpah,vis,dp
    vis[u] = 1
    for i in graph[u]:
        if not vis[i]:
            dfs(i)
        dp[u] = max(dp[u],dp[i] + 1)

n,m = ip()
graph = {i:[] for i in range(1,n+1)}
for i in range(m):
    a,b = ip()
    graph[a].append(b)

dp = [0]*(n+1)
vis = [0]*(n+1)
for i in range(1,n+1):
    if not vis[i]:
        dfs(i)
#print(dp)
print(max(dp))

Measured memory_bytes: 152644
class Dice:
    def __init__(self, data):
        self.data = data
    
    def move(self, direction):
        if direction == 'E':
            self.data[0], self.data[3], self.data[5], self.data[2] = \
                self.data[3], self.data[5], self.data[2], self.data[0]
        elif direction == 'N':
            self.data[0], self.data[4], self.data[5], self.data[1] = \
                self.data[1], self.data[0], self.data[4], self.data[5]
        elif direction == 'S':
            self.data[0], self.data[1], self.data[5], self.data[4] = \
                self.data[4], self.data[0], self.data[1], self.data[5]
        elif direction == 'W':
            self.data[0], self.data[2], self.data[5], self.data[3] = \
                self.data[2], self.data[5], self.data[3], self.data[0]

    def getTop(self):
        return self.data[0]

dice = Dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])
print(dice.getTop())

Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define F(i,a,b) for(int i=int(a);i<=int(b);i++)
#define endl "\n"
#define ios std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<x<<endl,exit(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second

const int N=1005;
ll dp[N][N],mod=1e9+7;
char a[N][N];

int main(){
	ios;
	ll h,w;
	cin>>h>>w;

	F(i,1,h){
		F(j,1,w){
			cin>>a[i][j];
		}
	}

	dp[1][0]=1;
	F(i,1,h){
		F(j,1,w){
			if(a[i][j]=='.'){
				dp[i][j]=dp[i-1][j]+dp[i][j-1];
				dp[i][j]%=mod;
			}
		}
	}

	cout<<dp[h][w];
}

Measured memory_bytes: 9088
S = input()
T = input()

if len(set(S)) != len(set(T)):
    print("No")
    exit()
else:
    for i in range(len(S)):
        if S.index(S[i]) != T.index(T[i]):
            print("No")
            #print(S.index(S[i]), T.index(T[i]))
            exit()
print("Yes")


Measured memory_bytes: 9332
#include <stdio.h>
int main(void) {
	int i, j, H, W;
	while (scanf("%d %d", &H, &W) != EOF) {
		if(H == 0 && W == 0) {
		break;
		}
		for (i = 1; i <= H; i++) {
			for (j = 1; j <= W; j++) {
				printf("#");
			}
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}


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

int main(){
    int n, k;
    int x, y;
    int sum = 0;

    cin >> n >> k >> x >> y;

    if(n <= k){
        sum = n * x;
    }
    else{
        sum = k * x + (n - k) * y;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    int a,b;cin>>a>>b;
    if(a<b)cout<<"a < b"<<endl;
    else if(a==b)cout<<"a == b"<<endl;
    else cout<<"a > b"<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------

































Measured memory_bytes: 3232
N, M = map(int,input().split())
answer = [-1]*N
ae = 0
  

for i in range(M):
  s,c = map(int,input().split())
  if answer[-s] == -1:
    answer[-s] = c
  elif answer[-s] != -1 and answer[-s] != c:
    print(-1)
    ae = 1
    break
for i in range(N):
  if answer[i] == -1:
    if i == N-1 and N > 1:
      answer[i] = 1
    else:
      answer[i] = 0
if ae == 0 and answer[N-1] == 0 and N != 1:
  print(-1)
  ae = 1
elif ae == 0:
  for i in range(N):
    print(answer[-(i+1)],end='')
  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	long long a, b, c; cin >> a >> b >> c;
	if (c < b) {
        cout << b + c << endl;
	} else {
        cout << 2 * b + min(a + 1, c - b) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  string n;
  cin >> n;
  ll ans = 0;
  for (ll i = 0; i < 4; i++) {
    if (n[i] == '2') ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

int digit_sum(ll n) {
    string n_str = to_string(n);
    int sum = 0;
    for(auto c : n_str) sum += (int)(c - '0');
    return sum;
}

ll f(ll n) {
    ll candidate = n + 1;
    ll end_n = pow(10, (int)log10(candidate) + 1) - 1;
    ll adder = 1;
    ll res = n + 1;
    while(candidate <= end_n) {
        if(candidate % (adder * 10) == adder * 10 - 1) adder *= 10;
        if(res * digit_sum(candidate) > candidate * digit_sum(res)) res = candidate;
        candidate += adder;
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    ll n = 1;
    cout << 1 << endl;
    REP(i, k - 1) cout << (n = f(n)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<class T> class Dijkstra {
public:
	int N;
	T inf;
	vector<T> cost;
	vector<vector<pair<T, int>>> edge;

	Dijkstra(const int N, T inf) : N(N), inf(inf),cost(N), edge(N) {
	}

	void make_edge(int from, int to, T w) {
		edge[from].push_back({ w,to });
	}

	void solve(int start) {
		for(int i = 0; i < N; ++i) cost[i] = inf;

		priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> pq;
		cost[start] = 0;
		pq.push({ 0,start });

		while (!pq.empty()) {
			T v = pq.top().first;
			int from = pq.top().second;
			pq.pop();
			for (auto u : edge[from]) {
				T w = v + u.first;
				int to = u.second;
				if (w < cost[to]) {
					cost[to] = w;
					pq.push({ w,to });
				}
			}
		}
		return;
	}
};

int main(){
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    int N, X, Y;
    cin >> N >> X >> Y;
    --X, --Y;
    Dijkstra<int> d(N, INF);
    d.make_edge(X, Y, 1);
    d.make_edge(Y, X, 1);
    REP(i,N-1){
        d.make_edge(i, i+1, 1);
        d.make_edge(i+1, i, 1);
    }
    vector<int> ans(N);
    REP(i,N-1){
        d.solve(i);
        for(int j=i+1;j<N;j++) ans[d.cost[j]]++;
    }
    for(int i=1;i<N;i++) cout << ans[i] << endl;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception{
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader (is);
		String input[] = br.readLine().split("");
		int nFlag = 0;
		int wFlag = 0;
		int sFlag = 0;
		int eFlag = 0;
		for(String s:input) {
			if(s.equals("N")) {
				nFlag = 1;
			}else if(s.equals("S")) {
				sFlag = 1;
			}else if(s.equals("W")) {
				wFlag = 1;
			}else if(s.equals("E")) {
				eFlag = 1;
			}
		}
		if((nFlag == sFlag) && wFlag ==  eFlag ) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout<<#x<<" "<<x<<endl
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n"
#define deb3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	
int gcd(int a, int b){ if(a==0) return b; return gcd(b%a, a);}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//ci(t);
	while(t--){
		int a,b,c,d;
		ci2(a,b); ci2(c,d);
		int cnt=1;
		while(a>0 && c>0){
			if(cnt%2!=0){
				c-=b;
			}
			else{
				a-=d;
			}
			cnt++;
		}
		if(a>0){
			co("Yes");
		}
		else{
			co("No");
		}
				
	}
	return 0;
}



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

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

int lcm(int a, int b)
{
	return a / gcd(a, b)*b;
}

int main()
{
	int a, b;
	while (cin >> a >> b) 
	{
		cout << gcd(a, b) << " " << lcm(a, b) << endl;
	}
	return 0;
}

Measured memory_bytes: 2984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll ans = 0;
    int D = 40;
    ll N,K,a;
    cin >> N >> K;
    vector<ll> b(D);
    for (int i=0;i<N;i++) {
        cin >> a;
        int j = 0;
        while(a > 0) {
            b[j] += a & 1;
            a >>= 1;
            j++;
        }
    }
    bool flipped = false;
    for (int i=D-1; i>=0; i--) {
        if (N - b[i] > b[i]) {
            if (flipped) {
                ans += (N - b[i]) << i;
            } else if ((K >> i) & 1 == 1) {
                ans += (N - b[i]) << i;
            } else {
                ans += b[i] << i;
            }
        } else {
            ans += b[i] << i;
            flipped = flipped || ((K >> i) & 1 == 1);
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)

using namespace std;
int even[100010];
int odd[100010];
int maxeven = 0, maxodd = 0, secondeven = 0, secondodd = 0, maxevenarg, maxoddarg;
const int nil = -1;
int i, n, t;

int main() {
    for (i=0;i<100010;i++) {
        even[i] = 0;
        odd[i] = 0;
    }
    scanf(" %d", &n);
    for (i=0;i<n;i++) {
        scanf(" %d", &t);
        if (i%2 == 0) even[t]++;
        else odd[t]++;
    }
    for (i=0;i<100010;i++) {
        if (even[i] >= maxeven) {
            secondeven = maxeven;
            maxeven = even[i];
            maxevenarg = i;
        } else if (even[i] >= secondeven) {
            secondeven = even[i];
        }
        if (odd[i] >= maxodd) {
            secondodd = maxodd;
            maxodd = odd[i];
            maxoddarg = i;
        } else if (odd[i] >= secondodd) {
            secondodd = odd[i];
        }
    }
    int res = 0;
    if (maxevenarg != maxoddarg) res = n - maxeven - maxodd;
    else res = min(n - maxeven - secondodd, n - maxodd - secondeven);
    printf("%d\n", res);
}

Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//符号反転
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(ll n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
     mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
int main(){
  init();
  ll n,m,k;
  cin>>n>>m>>k;
  mint ans=0;
  for(int i=0;i<=k;i++){
    mint d=mint(m-1).pow(n-1-i)*COM(n-1,i);
    ans+=d*mint(m);
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 50492
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
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
trace _ = id

solve :: Int -> [Int] -> Int
solve bN as = cntL + cntS
  where
  top0 : sorted = sortOn (* (-1)) as
  -- sorted = traceL "sorted" sortedX sortedX
  ((cntM,topM), lstPos) = mapAccumL f (0,top0) (zip [1..] sorted)
    where
    f (cnt,top) (k,a) | top < 2*bN = ((cnt,top), top - ht)
                      | otherwise = (newAcc, pos)
      where
        ht = a + cnt
        (lp, pos) = divMod (top - ht) (bN + 1)
        newAcc = (cnt + lp*k, top + lp*((k-1) - bN))
  (cntL, topL) | topM < 2*bN = (cntM, topM)
               | otherwise = (cntM + (topM - 2*bN)*bN, 2*bN)
  cntS = solveSimp bN (map (topL -) (0:lstPos))

solveSimp :: Int -> [Int] -> Int
-- solveSimp bN as | traceL "solveSimp" as False = undefined
solveSimp bN as = sub 0 (VU.fromListN bN as)
  where
  sub !cnt vA
    | aMax < bN = cnt
    | otherwise = sub (cnt+1) (VU.imap f vA)
    where iMax = VU.maxIndex vA
          aMax = vA VU.! iMax
          f i a | i == iMax = a - bN
                | otherwise = a + 1

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]:remLines1 = remLines0
      bN = readBInt bs_bN
      line2:remLines2 = remLines1
      as = map readBInt line2
  in solve bN as

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

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

traceL :: Show a => String -> a -> b -> b
traceL label showObj val = trace (label ++ " " ++ show showObj) val

traceLM :: (Monad m, Show a) => String -> (b -> a) -> m b -> m b
traceLM label showFn act = do
  aaa <- act
  traceL label (showFn aaa) (return ())
  return aaa




-------------------------------------------------------------------------------

inp1 = "4\n3 3 3 3\n"
inp2 = "3\n1 0 3\n"
inp3 = "2\n2 2\n"
inp4 = "7\n27 0 0 0 0 0 0\n"
inp5 = "10\n1000 193 256 777 0 1 1192 1234567891011 48 425\n"
inp6 = "3\n0 0 3\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
tv4 = tmain $ B.pack inp4
tv5 = tmain $ B.pack inp5
tv6 = tmain $ B.pack inp6
test1 = tv1 == 0
test2 = tv2 == 1
test3 = tv3 == 2
test4 = tv4 == 3
test5 = tv5 == 1234567894848
test6 = tv6 == 1
alltest = test1 && test2 && test3 && test4 && test5 && test6



Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

class ModInt {
  int val; static const int MOD = 1e9+7; static_assert(MOD > 0, "Modulus not set!");
  int modInverse(int a) { // simplified extended GCD, only solving for x
    int b = MOD, x = 0, x_ = 1, q; while (a != 0) { q = b / a; swap(b, a); a %= b;
    swap(x, x_); x_ -= q * x; } assert(b == 1); return (x %= MOD) < 0 ? (x + MOD) : x; }
  public: ModInt() : val(0) { } ModInt(int v) : val(v) { if ((val %= MOD) < 0) val += MOD; }
    ModInt& operator += (const ModInt& b) { if ((val += b.val) >= MOD) val -= MOD; return *this; }
    ModInt& operator -= (const ModInt& b) { if ((val -= b.val) < 0) val += MOD; return *this; }
    ModInt& operator *= (const ModInt& b) { val = ((ll)val*(ll)b.val) % MOD; return *this; }
    ModInt& operator /= (const ModInt& b) { return (*this) *= modInverse(b.val); }
#define _op(op, btype, op2) ModInt operator op (btype b) const { ModInt ans = *this; return ans op2 b; }
    _op(+, const ModInt&, +=); _op(-, const ModInt&, -=); _op(*, const ModInt&, *=); _op(/, const ModInt&, /=);
    _op(+, int, +=); _op(-, int, -=); _op(*, int, *=); _op(/, int, /=);
#undef _op
    int toInt() const { assert(0 <= val && val < MOD); return val; }
};

template <typename T> // T needs to implement +/- operators
class BIT { // Point updates, range sum queries.
	vector<T> B; public: BIT (int n) : B(n+1) { }
  // sum [0, r)
  T query(int r) { T res = T(); while (r > 0) { res += B[r], r -= (r & -r); } return res; }
  // sum [l, r)
	T query(int l, int r) { return (l == r ? T() : query(r) - query(l)); }
  // BIT[i] += val
	void add(int i, T val) { for (++i; i < B.size(); B[i] += val, i += (i & -i)); }
};

ModInt sumTo(int n) {
  ModInt ans(n);
  return ans*(ans+1)/2;
}

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  int n, k;
  cin >> n >> k;
  VI nums(n);
  forx(i, n) cin >> nums[i];
  ModInt ans = 0;
  BIT<int> cnt(2001);
  //count inversions in the first array
  for (int i = n-1; i >= 0; i--) {
    cnt.add(nums[i], 1);
    ans += cnt.query(nums[i]);
  }
  ans *= k;
  //cout << "temp: " << ans.toInt() << nl;
  forx (i, n) {
    ans += (sumTo(k-1)*cnt.query(nums[i]));
  }
  //
  cout << ans.toInt() << nl;
  
  return 0;
}



Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))
s=0
for i in range(len(a)-1):
    if a[i]+a[i+1]>x:
        if a[i]>x:
            s+=a[i+1]+a[i]-x
            a[i+1]=0
            a[i]=x
        else:
            s+=a[i+1]+a[i]-x
            a[i+1]=x-a[i]
print(s)


Measured memory_bytes: 14052
import java.io.*;

public class Main {
    public static void main(String[] arg){
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            while(true){
            String line = reader.readLine();
            if(line.equals("0")) break;
            int b = 0;
            for(int i=0;i<line.length();i++){
            int a = line.charAt(i)-'0';
            b = b + a;
            }
            System.out.println(b);
        }
            } catch (IOException e){
                System.out.println("e");
            }
        }
    }


Measured memory_bytes: 24364
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<LL>;
using vvl = vector<vl>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
int P[5050], memo[5050], idx[5050], gIdx[5050];
LL C[5050];

int main(){
    
    // 1. 入力情報.
    int N;
    LL K;
    scanf("%d %lld", &N, &K);
    rep(i, N) scanf("%d", &P[i + 1]);
    rep(i, N) scanf("%lld", &C[i]);
    
    // 2. 巡回する整数ごとにグループ分け.
    vvi g;     // グループ情報.
    int n = 0; // グループ番号.
    vvl gCum;  // グループごとの累積和.
    repx(i, 1, N + 1){
        vi v;
        int cur = i;
        while(!memo[cur]){
            // 2-1. グループに追加.
            v.pb(cur);
            
            // 2-2. 訪問済みフラグ設定.
            memo[cur] = 1;
            
            // 2-3. グループ番号を設定.
            idx[cur] = n;
            
            // 2-4. 次のマス.
            cur = P[cur];
        }
        
        // 2-5. グループサイズが, 0 より大きい場合.
        int l = v.size();
        if(l){
            // グループを追加.
            g.pb(v);
            
            // グループに関する累積和, 追加.
            vl c(l * 2 + 2, 0LL);
            rep(i, l * 2 + 1) c[i + 1] = c[i] + C[v[i % l] - 1];
            gCum.pb(c);
            
            // グループ番号をインクリメント.
            n++;
        }
    }
    // for(auto &v : g){
    //     for(auto &u : v) printf("%d ", u);
    //     puts("");
    // }
    // repx(i, 1, N + 1) printf("%d ", idx[i]);
    // puts("");
    // for(auto &v : gCum){
    //     for(auto &u : v) printf("%lld ", u);
    //     puts("");
    // }
    
    // 3. 各グループごとに, ゲーム終了時のスコアとして, 有り得る最大値を計算.
    LL ans = -202020202020202020;
    repx(i, 1, N + 1){
        // 3-1. 出発点の所属グループ.
        int sg = idx[i];
        
        // 3-2. 出発点の所属グループのサイズ.
        int gSize = g[sg].size();
        
        // 3-3. 周期を計算.
        LL q = K / (LL)gSize, r = K % (LL)gSize;
        
        // 3-4. 項数 1 ～ r 個 までの累積和を全探索.
        // [gIdx[sg], gIdx[sg] + 1], ..., [gIdx[sg], gIdx[sg] + r] の r個 の 区間 を 確認.
        LL t1 = -202020202020202020;
        repx(j, 1, r + 1) t1 = max(t1, gCum[sg][gIdx[sg] + j] - gCum[sg][gIdx[sg]]);
        
        // 3-5. 1周期以上ある場合.
        LL t2 = -202020202020202020, t3 = -202020202020202020;
        if(q){
            // 1周期以下.
            // [gIdx[sg], gIdx[sg] + r + 1], ..., [gIdx[sg], gIdx[sg] + gSize] の (gSize - r)個 の 区間 も 確認.
            repx(j, r + 1, gSize + 1) t2 = max(t2, gCum[sg][gIdx[sg] + j] - gCum[sg][gIdx[sg]]);
            
            // 1周期を超える場合.
            if(gCum[sg][gSize] > 0){
                // t2 の 結果を優先しない場合.
                t3 = max(t3, t1 + q * gCum[sg][gSize]);
                
                // t2 の 結果を優先する場合.
                t3 = max(t3, t2 + (q - 1) * gCum[sg][gSize]);
            }
        }
        
        // 3-6. 出発点の所属グループにおけるインデックスをインクリメント.
        gIdx[sg]++;
        
        // 3-7. ゲーム終了時のスコアの最大値更新.
        ans = max({ans, t1, t2, t3});
    }
    
    // 4. 出力.
    printf("%lld\n", ans);
    return 0;
    
}


Measured memory_bytes: 4060
#include<stdio.h>
long long gcd(long long a,long long b)
{  
    int temp;  
    if(a < b)
	{  
      temp = a;  
      a = b;  
      b = temp;  
    }    
    if(a%b == 0){  
        return b;    
    }
	else
	{    
        return gcd(b,a%b);    
    }    
} 
int main()
{
	int n;
	long long  gcd(long long a,long long b);
    long long  c[109],sum;
	while(~scanf("%d",&n))
	{
		sum=0;
		for(int i=0;i<n;i++)
		scanf("%lld",&c[i]);
		while(n==1) 
		{
		printf("%lld\n",c[0]);
		return 0;	
		}
			for(int i=0;i<n-1;i++)
			{	
				
				sum=(c[i]/gcd(c[i],c[i+1]))*c[i+1];
				c[i+1]=sum;
			}
			printf("%lld\n",sum);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 1e6;

int main() {
    int n, m;
    cin >> n >> m;
    int t = 1900 * m + 100 * (n - m);
    double p = 1.0 / pow(2, m);
    double ans = 0.0;
    rep(i, (int)1e6) {
        ans += (i + 1) * t * pow(1 - p, i) * p;
    }
    cout << (int)(ans + 0.0001) << endl;
}

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

#define N 0
#define INF 0x3f3f3f3f
#define LL long long
#define mz(x) ms(x,0)
#define ms(x,y) memset(x,y,sizeof(x))
#define mc(x,y) memcopy(x,y,sizeof(y))
#define MOD 1000000007

using namespace std ;

int main()
{
	string n ;
	cin >> n ;
	
	int sum = 0 ;
	for (char c : n)
	{
		int t = c - '0' ;
		
		sum += t ;
		sum %= 9 ;
	}
	
	if (!sum)
		cout << "Yes" << endl ;
	else
		cout << "No" << endl ;

	return 0 ;
}

Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

 
void solve()
{
    int a,b;cin>>a>>b;
    if(abs(b-a)%2)cout<<"IMPOSSIBLE"<<endl;
    else cout<<abs(b-a)/2+min(a,b)<<endl;
}

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

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int N, const vector<int>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    set<string> xs;

    for (int i = 0; i < N; ++i)
    {
        string x;
        cin >> x;

        xs.insert(x);
    }

    cout << xs.size() << '\n';

    return 0;
}


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

int main() {
    int A,B;cin >> A >> B;
    int sum = 0;
    if (A >= B){
        sum += A;
        A--;
    }
    else{
        sum += B;
        B--;
    }

    if (A >= B){
        sum += A;
        A--;
    }
    else{
        sum += B;
        B--;
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func reverse(s string) string {
	ans := ""
	for i := len(s) - 1; i >= 0; i-- {
		ans += string(s[i])
	}
	return ans
}

func main() {
	var str string
	fmt.Scan(&str)

	rev := reverse(str)

	count := 0
	for i := 0; i < len(str)/2; i++ {
		if str[i] != rev[i] {
			count++
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 512