akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	int n;
	int count = 0;
	vi v(201);
	bool ans = false;
	cin >> n;
	range(i,1,n+1) {
		for (int j = 1; j*i <= 200; j++) {
			v[i*j]++;
		}
	}
	for (int i=0;(i*2)+1<=n;i++) {
		if (v[(i * 2) + 1] == 8)count++;
	}
	
	cout << count << endl;
}


Measured memory_bytes: 256
#input
N,Y = map(int,input().split())
#A = list(map(int, input().split()))
#print(N,Y)

ans = [-1,-1,-1]
#flag = True
# N = x + y + zを満たす組
for x in range(N+1):
    for y in range(N+1):
        z = N - x - y
        if z >= 0:
            list = [x,y,z]
            if Y == 10000*list[0]+5000*list[1]+1000*list[2]:
                ans = list
                break
print(ans[0],ans[1],ans[2])

Measured memory_bytes: 3064
#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;

int IntervalSum(const vector<int> &count, int left, int right)
{
    if (left > right) {
        return 0;
    }

    int sum = count[right];
    if (left > 0) {
        sum -= count[left - 1];
    }
    return sum;
}

int main()
{
    int n;
    cin >> n;
    cin.get();

    unordered_map<char, vector<int>> count;
    count.insert({'E', vector<int>(n, 0)});
    count.insert({'W', vector<int>(n, 0)});

    for (int i = 0; i < n; i += 1) {
        char ch;
        cin >> ch;
        count[ch][i] = 1;

        if (i > 0) {
            for (auto &p : count) {
                p.second[i] += p.second[i - 1];
            }
        }
    }

    int res = n;
    for (int i = 0; i < n; i += 1) {
        int cost = IntervalSum(count['W'], 0, i - 1)
                 + IntervalSum(count['E'], i + 1, n - 1);
        res = min(res, cost);
    }

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3820
using System;
using System.Linq;

namespace ABC118_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var ans = int.MaxValue;
            for (int i = 1; i < n; i++)
            {
                ans = Math.Min(ans, gcd(a[i], a[i - 1]));
            }

            Console.WriteLine(ans);
        }

        public static int gcd(int x, int y)
        {
            return ((y == 0) ? x : gcd(y, x % y));
        }
    }
}


Measured memory_bytes: 19680
#include <cstdio>
using namespace std;
int N, ans = 1; char S[100001];
int main() {
  scanf("%d %s", &N, &S);
  for(int i = 1; i < N; ++i) {
    if(S[i-1] != S[i]) ++ans;
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
  input! {
    n: usize,
    mut vals: [usize;n]
  }
  
  let mut flag = true;
  let mut index = 0;
  let mut count = 0;
  while flag {
    flag = false;
    let mut sc = 0;
    for i in 0..n {
      if vals[i] != 0 {
        vals[i] -= 1;
        sc += 1;
        flag = true;
      } else {
        if 0 < sc {
          count += 1;
        }
        sc = 0;
      }
    }
    if 0 < sc {
      count += 1;
    }
  }
  
  println!("{}", count);
}

Measured memory_bytes: 2128
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>

using namespace std;

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

int N;
ll a[210000];

ll ab(ll a1){
    if(a1 < 0) return -a1;
    else return a1;
}

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

    sort(a, a+N);
    ll m;
    ll res = LONG_LONG_MAX;
    if(N % 2 == 1){
        m = a[N/2];
        res = 0;
        for(int i = 0; i < N; i++){
            res += ab(a[i]-m);
        }
        cout << res << endl;
        return 0;
    }
    else{
        ll m = (a[N/2-1] + a[N/2]) / 2;
        ll res_min = LONG_LONG_MAX;
        for(ll j = max(m-1, 0LL); j <= m+1; j++){
            res = 0;
            for(int i = 0; i < N; i++){
                res += ab(a[i] - j);
            }
            res_min = min(res_min, res);
        }
        cout << res_min << endl;
        return 0;
    }



    return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm> // min()
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <tuple>
#include <climits> // INT_MAX
#include <cmath> // ceil()
#define rep(i, n) for (int i = 0; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;


void print_mp(Graph &graph) {
	cout << endl;
	for (auto&& y : graph) {
		for (auto&& x : y) {
			cout << x << " ";
		}
		cout << endl;
	}
}



int main() {
	int h, w, b_num = 0, min_white = -1;
	cin >> h >> w;
	vector<string> mp(h);
	rep(i, h) {
		cin >> mp[i];
		for (auto&& c : mp[i]) {
			if (c == '#') ++b_num;
		}
	}

	queue<P> q;
	q.emplace(0, 0);

	int dx[] = { 1, -1, 0, 0 };
	int dy[] = { 0, 0, 1, -1 };
	int x, y, x_next, y_next;
	Graph hist(h, vector<int>(w, -1));
	hist[0][0] = 0;

	while (!q.empty()) {
		//print_mp(hist);
		x = q.front().first;
		y = q.front().second;
		q.pop();

		rep(i, 4) {
			x_next = x + dx[i];
			y_next = y + dy[i];

			if (x_next < 0 || x_next >= w) continue;
			if (y_next < 0 || y_next >= h) continue;
			if (mp[y_next][x_next] == '#') continue;
			if (hist[y_next][x_next] != -1) continue; //逆走禁止
			if (hist[y_next][x_next] > hist[y][x]) continue; //逆走禁止

			hist[y_next][x_next] = hist[y][x] + 1;

			if (x_next == (w - 1) && y_next == (h - 1)) {
				min_white = hist[h - 1][w - 1] + 1;
				while (!q.empty()) q.pop();
				break;
			}
			else q.emplace(x_next, y_next);
		}
	}

	if (min_white != -1) cout << h * w - b_num - min_white << endl;
	else cout << min_white << endl;
}


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

int main()
{
	long long n;
	cin >> n;
	string name;
	while (n) {
		name.push_back((n - 1) % 26 + 'a');
		n -= (n - 1) % 26;
		n /= 26;
	}
	reverse(name.begin(), name.end());
	cout << name;
	return 0;
}

Measured memory_bytes: 3576
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

void print(vector<int> &v, bool b) {
  if (b) {
    cout << v[0];
    for (auto it = ++v.begin(); it != v.end(); ++it)
      cout << " " << *it;
    cout << endl;
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> A, B, C;
  while (cin >> n)
    A.push_back(n);
  C = B = A;
  print(B, prev_permutation(B.begin(), B.end()));
  print(A, true);
  print(C, next_permutation(C.begin(), C.end()));
}


Measured memory_bytes: 3148
#include <iostream>

using namespace std;

int cmpfunc (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}

int main(){
	int n,k, sum=0;
  cin>>n>>k;
  int arr[n];
  for(int i=0; i<n; i++){
  	cin>>arr[i];
  }
  qsort(arr,n,sizeof(int), cmpfunc);
  for(int i=0; i<k; i++){
  	sum+=arr[i];
  }
  cout<<sum;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;

const string YES = "Yes";
const string NO = "No";

void solve()
{
  string S;
  cin >> S;
  sort(S.begin(),S.end());
  if(S=="abc") cout << YES << endl;
  else cout << NO << endl;
}

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


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

void main() {
  int a, b, c, d;
  readf("%d %d %d %d\n", &a, &b, &c, &d);
  while(true) {
    c -= b;
    if(c<=0) {
      writeln("Yes");
      return;
    }
    a -= d;
    if(a<=0) {
      writeln("No");
      return;
    }
  }
}


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

int main(){
    int n,c[4];
    int sum;
    int en[]={10,50,100,500};
    bool kaigyo=false;
    
    while(1){
        cin>>n;
        if(n==0) break;
        if(kaigyo) cout<<endl;
        kaigyo=true;
        sum=0;
        for(int i=0;i<4;i++){
            cin>>c[i];
            sum+=c[i]*en[i];
        }
        sum-=n;
        for(int i=3;i>=0;i--){
            c[i]-=min(c[i],sum/en[i]);
            sum%=en[i];
        }
        for(int i=0;i<4;i++){
            if(c[i]!=0) cout<<en[i]<<" "<<c[i]<<endl;
        }
    }
}

Measured memory_bytes: 1160
s = input()
c = 0
x = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        c += 1
    else:
        x = max(c, x)
        c = 0
print(max(c, x))

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

int main() {
	int N;
	cin >> N;
	vector<int> L(N);
	for (int i=0;i<N;i++) {
		cin >> L[i];
	}
	sort(L.begin(), L.end());

	int ans = 0;
	for (int i=0;i<N;i++) {
		for (int j=i+1;j<N;j++) {
			for (int k=j+1;k<N;k++) {
				if (L[i] == L[j] || L[j] == L[k] || L[i] == L[k]) continue;
				if (L[i] + L[j] > L[k]) ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
ll digit(ll n) {
	ll d = 0;
	while (n) {
		n /= 10;
		d++;
	}
	return d;
}
int main() {
	ll n; cin >> n;
	ll a[10][10] = {};
	ll l, r;

	repe(i, 1, n) {
		if (i == 10) {
			cout << endl;
		}
		ll d = digit(i);
		if (d == 1) {
			l = i;
			r = i;
		}
		else {
			l = i / pow(10,d-1);
			r = i % 10;
		}

		a[l][r]++;
	}

	ll ans = 0;
	repe(i, 0, 9) {
		ans += a[i][i] * a[i][i];
	}

	repe(i, 0, 9) {
		repe(j, 0, 9) {
			if (i != j) {
				ans += a[i][j] * a[j][i];
			}
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll s, c;
ll ans;
int main() {
    cin >> s >> c;
    ans = 0;
    ans += min(s, c/2);
    c -= 2*s;
    if(c>0) ans += c/4;
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {


    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        final String b = in.readLine();

        if(b.equals("A")){
            System.out.println("T");
        }else if (b.equals("T")){
            System.out.println("A");
        }else if (b.equals("G")){
            System.out.println("C");
        }else if (b.equals("C")){
            System.out.println("G");
        }else{
            throw new IllegalArgumentException();
        }
    }


    static class CustomReader extends BufferedReader {

        private static final int DEFAULT_BUF_SIZE = 2048;
        // private static final int DEFAULT_BUF_SIZE = 4096;
        // private static final int DEFAULT_BUF_SIZE = 8192;
        //private static final int DEFAULT_BUF_SIZE = 16384;
        // private static final int DEFAULT_BUF_SIZE = 1048576;

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in), DEFAULT_BUF_SIZE);
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }
    }
}

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

using namespace std;

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

  double n;
  cin >> n;
  cout << ceil(n / 2) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

   int a, b, c;
   int ans = 0;

   cin >> a >> b >> c;

   for(int i = a; i <= b; i++){
      if(c % i == 0){
         ans++;
      }
   }

   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 3096
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}

//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m; 
  if (u < 0) u += m;
  return u;
}
ll const mod = 1e9+7;

// combination
const int MAX = 510000;
const ll MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long 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] % MOD) % MOD;
}

int main() {
  int N;
  cin >> N;
  if (N%1000==0) cout << 0 << endl;
  else cout << 1000 - N%1000 << endl;
}

Measured memory_bytes: 3624
N, X = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
if A[0] > X:
    ans += A[0] - X
    A[0] = X
for i in range(1, N):
    if A[i-1] + A[i] <= X:
        continue
    if A[i-1] <= X:
        ans += A[i-1] + A[i] - X
        A[i] = X - A[i-1]
    else:
        ans += A[i] + A[i] - X
        A[i] = 0
print(ans)


Measured memory_bytes: 14280
#include <stdio.h>
int main(void){
    int dice[6];
    int swap;            
    char c;
     
    int i;
     
    for(i=0;i<6;i++){
        scanf("%d",&dice[i]);
    }
     
    while(scanf("%c",&c)!=EOF){
     
        if(c=='E'){
            swap=dice[0];
            dice[0]=dice[3];
            dice[3]=dice[5];
            dice[5]=dice[2];
            dice[2]=swap;
        }
        if(c=='W'){
            swap=dice[0];
            dice[0]=dice[2];
            dice[2]=dice[5];
            dice[5]=dice[3];
            dice[3]=swap;
        }
        if(c=='S'){
            swap=dice[0];
            dice[0]=dice[4];
            dice[4]=dice[5];
            dice[5]=dice[1];
            dice[1]=swap;
        }   
        if(c=='N'){
            swap=dice[0];
            dice[0]=dice[1];
            dice[1]=dice[5];
            dice[5]=dice[4];
            dice[4]=swap;
        }
    }
     
    printf("%d\n",dice[0]);
     
    return 0;
 
}


Measured memory_bytes: 2112
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ x, y, z ] <- readInts
	print $ length $ takeWhile ( <= x ) $ [ k * y + ( k + 1 ) * z | k <- [ 1 .. ] ]


Measured memory_bytes: 508
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	string s;
	int p;
	map<string,vector<int> > index;
	while(cin>>s>>p) index[s].push_back(p);
	for(map<string,vector<int> >::iterator it=index.begin();it!=index.end();++it){
		cout<<(*it).first<<"\n";
		sort((*it).second.begin(),(*it).second.end());
		for(int i=0;i<(*it).second.size();++i)cout<<(*it).second[i]<<((i!=(*it).second.size()-1)?" ":"\n");
	}
	return 0;
}

Measured memory_bytes: 0
c = []
3.times do
  c.push gets.split.map(&:to_i)
end
diff_raw = Array.new(3).map { |e| [] }
diff_column = Array.new(3).map { |e| [] }
0.upto(2) do |i|
  0.upto(2) do |j|
    diff_raw[i].push(c[i][j] - c[i-1][j])
  end
end
0.upto(2) do |i|
  0.upto(2) do |j|
    diff_column[j].push(c[i][j] - c[i][j-1])
  end
end
if diff_raw.map { |e| e.uniq.size } == [1, 1, 1] &&
   diff_column.map { |e| e.uniq.size } == [1, 1, 1]
   puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll N,M;
  cin>>N>>M;
 priority_queue<ll> S;
  for(ll i=0;i<N;i++) {
ll A;
    cin>>A;
    S.push(A);
  }
  
 for(ll i=0;i<M;i++) {
ll K=S.top()/2;
   S.pop();
   S.push(K);
 }
  ll ans=0;
  while(!S.empty()) {
ans+=S.top();
    S.pop();
  }
  
  cout<<ans<<endl;
}
   

  
  
  
  
  
  

Measured memory_bytes: 4324
#include <iostream>
#include <algorithm>

int cou[50][50];
using namespace std;

int main(){
        int H,W,i,j;
        cin >> H >> W;
        char v[H][W];
        //int cou[H][W] = {0};
        for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                        cin >> v[i][j];
                }
        }
        for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                        if(v[i][j]=='#'){
                                for(int r=i-1;r<i+2;r++){
                                        if(r>-1 && r<H){
                                                if(j>0)cou[r][j-1]++;
                                                cou[r][j]++;
                                                if(j+1<W)cou[r][j+1]++;
                                        }
                                }
                        }
                }
        }
        for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                        if(v[i][j]=='#'){
                                cout << '#';
                        }else{
                                cout << cou[i][j];
                        }
                }
                cout << endl;
        }
        //cout << cou[0][1]<< endl;

        return 0;
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall
from itertools import permutations
from sys import stdin
nii=lambda:map(int,stdin.readline().split())

n,m,r=nii()
r=list(nii())

s=[[float('inf')]*n for i in range(n)]
for i in range(n):
  for j in range(n):
    s[i][j]=0
for i in range(m):
  a,b,c=nii()
  a-=1
  b-=1
  s[a][b]=c
  s[b][a]=c

ws=floyd_warshall(s)

ans=10**9
for i in permutations(r):
  t_ans=0
  for j in range(1,len(i)):
    t_ans+=ws[i[j-1]-1][i[j]-1]
  ans=min(ans,t_ans)
print(int(ans))

Measured memory_bytes: 15376
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N, K;
        N = sc.nextInt();
        K = sc.nextInt();
        int num = K;
        for (int a = 1; a < N; a++) {
            num = num *(K - 1);
        }
        System.out.println(num);
    }
}


Measured memory_bytes: 22996
# coding: utf-8
# Your code here!
import time
t1=time.time()
def LI():return list(map(int,input().split()))
n,k=LI()
a=LI()

for _ in range(k):
    tab=[0]*(n)
    for i in range(n):
        q=a[i]
        if 0<=i-q:
            tab[i-q]+=1
        else:
            tab[0]+=1
        if i+q+1<=n-1:
            tab[i+q+1]-=1
        else:
            pass
    b=[tab[0]]
    for i in range(n-1):
        b.append(tab[i+1]+b[-1])
    a=b[:]
    if time.time()-t1>1.5:
        print(*a)
        exit()
print(*a)


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

// n_C_2
inline long long combo2(long long n) {
    return n * (n-1) / 2;
}

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

    // 各整数iの出現回数v
    vector<int> freq(N+1);
    for (int i = 0; i < N; ++i) {
        freq[A[i]]++;
    }

    // 何も取り除かない場合、何通りあるか
    long long all = 0;
    for (int i = 1; i < N+1; ++i) {
        all += combo2(freq[i]);
    }

    //cout << "all = " << all << endl;
    for (int k = 1; k <= N; ++k) {
        int i = A[k-1];
        long long ans = all - combo2(freq[i]) + combo2(freq[i]-1);
        cout << ans << "\n";
    }
}


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

ll lcm(ll C, ll D) {
    return C / __gcd(C, D) * D;
}

ll anti_div(ll A, ll B, ll C, ll D) {
    ll BdC = B / C;
    ll BdD = B / D;
    ll BdCD = B / lcm(C, D);
    ll AdC = (A - 1) / C;
    ll AdD = (A - 1) / D;
    ll AdCD = (A - 1) / lcm(C, D);
    
    return (B - (BdC + BdD - BdCD)) - (A - 1 - (AdC + AdD - AdCD));
}

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll ans = anti_div(A, B, C, D);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
         int x = Integer.parseInt(sc.next());
         int ans = 1;
         for(int i =2;i<=x;i++){
             for(int j = i*i;j<=x;j=j*i){
                 ans = Math.max(ans,j);
             }
         }
         System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<long long, long long>;

const int MAXN = 1e5;

vector<bool> mp[MAXN];

void solve() {

    ll n, m;
    cin >> n >> m;

    for (int i = 0; i < m; ++ i){
        ll pi;
        string s;
        cin >> pi >> s;

        mp[pi].push_back(s == "AC");
    }

    ll crr = 0;
    ll pen = 0;


    for (int i = 1; i <= n; ++ i){
        bool ac_was = false;
        int c = 0;
        for (auto e : mp[i]){
            if (e){
                crr++;
                ac_was = true;
                break;
            } else {
                c++;
            }

        }

        if (ac_was)
            pen += c;

    }


    cout << crr << " " << pen << "\n";

}


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

    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(5);
    solve();
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define LL long long
#define MOD 1000000007
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int N;
  cin >> N;
  int a[200005];
  for (int i = 0; i < N; ++i) cin >> a[i];
  sort(a, a + N, greater<int>());
  LL ans = a[0];
  int j = 1;
  for (int i = 1; i <= N - 2; ++i)
    {
      ans += a[j];
      if (i % 2 == 0) j++;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4412
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b; cin >> a >> b;
    int h = 100, w = 100;

    char mat[h][w];

    rep(i, h){
        if(i < h/2){
            rep(j, w){
                mat[i][j] = '#';
            }
        }
        else{
            rep(j, w){
                mat[i][j] = '.';
            }
        }
    }

    int a_add = a - 1;
    int b_add = b - 1;

    int i = 0, j = 0;
    rep(k, a_add){
        mat[i][j] = '.';
        j += 2;
        if(j >= w){
            i += 2;
            j  = 0;
        }
    }

    i = h-1, j = w-1;
    rep(k, b_add){
        mat[i][j] = '#';
        j -= 2;
        if(j < 0){
            i -= 2;
            j  = w-1;
        }
    }

    cout << 100 << " " << 100 << endl;

    rep(i, h){
        rep(j, w){
            cout << mat[i][j];
        }
        cout << endl;
    }

    return 0;
}

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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll n;
ll dp[3010101];
ll a[30][30];
void solve(){
	cin>>n;
	REP(i,n) REP(j,n) cin>>a[i][j];

	dp[0]=1;
	REP(bit,(1LL<<n)){
		if(dp[bit]==0) continue;
		ll con=0;
		REP(i,n) if(bit&(1LL<<i)) con++;

		REP(i,n){
			if(bit&(1LL<<i)) continue;
			if(a[con][i]) (dp[bit+(1LL<<i)]+=dp[bit])%=MOD;
		}
	}

	cout<<dp[(1LL<<n)-1]<<en;
}

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

    solve();
    return 0;
}

Measured memory_bytes: 18688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll a,b,n;
	cin >> a >> b >> n;
	if(n>=b){
		cout << floor(a*(b-1)/b) << endl;
	}
	else{
		cout << floor(a*n/b) << endl;
	}
	return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  vector<int> ha(N);
  
  for (int i = 0; i < N; i++){
    if (S.at(i) == '.'){
      ha.at(i) = 0;
    } else {
      ha.at(i) = 1;
    }
  }
  
  vector<int> s(N+1, 0);
  
  for (int i = 0; i < N; i++){
    s.at(i + 1) = s.at(i) + ha.at(i);
  }
  
  int min = N;
  for (int i = 0; i <= N; i++){
    int ans = s.at(i) + (N - i - s.at(N) + s.at(i));
    if (min > ans){
      min = ans;
    }
  }
     
  cout << min << endl;

}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;

int main() {
    int s;
    cin >> s;
    int h = s / 60 / 60;
    int m = s / 60 % 60;
    int sec = s % 60;
    printf("%d:%d:%d\n", h, m, sec);
}


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル

	int N;
	cin >> N;
	map<string,int> S;
	string temp;
	for(int i=0; i<N; i++){
			cin >> temp;
			S[temp]++;
	}

	cout << S.size() << endl;

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
  }
  int A=p.at(N-1);
  vector<int> q(N);
  for(int i=N-1;i>=0;i--){
    q.at(i)=A-p.at(i);
    A=max(A,p.at(i));
  }
  sort(q.begin(),q.end());
  reverse(q.begin(),q.end());
  int Z=1;
  for(int i=0;i<N-1;i++){
    if(q.at(i)==q.at(i+1)){
      Z++;
    }
    else{
      break;
    }
  }
  cout<<Z<<endl;
}



Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
    int n, k;
    scanf("%d %d", &n, &k);

    int ans = 0;

    for (int i = 0; i < n; i++) {
        if (i == 0) {
            ans = k;
            continue;
        }
        ans = ans * (k - 1);
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
bool search (int *A,int n,int key)
{
	int i=0;
	A[n]=key;
	while (A[i]!=key) i++;
	if (i==n) return false;
	else return true;
}

int main ()
{
	int i,n,A[10000+1],q,key,sum=0;
	scanf ("%d",&n);
	for (int i=0;i<n;i++) scanf ("%d",&A[i]);
	
	scanf ("%d",&q);
	for (int i=0;i<q;i++)
	{
		scanf ("%d",&key);
		if (search(A,n,key)) sum++;
	}
	printf ("%d\n",sum);
	return 0; 
}


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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  vector<int> sagaku(N);
  for (int i =0; i<N; i++) cin >> A.at(i);
  for (int i =0; i<N-1; i++) {
    sagaku.at(i) = A.at(i+1) - A.at(i);
  }
  
  long shojikin = 1000;
  for (int i =0; i<N-1; i++) {
    if (sagaku.at(i) > 0) {
      shojikin = shojikin % A.at(i) + (shojikin / A.at(i)) * A.at(i+1); 
    }
  }
  cout << shojikin << endl;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int max = -2000000000;
    int min = stdIn.nextInt();
    for (int i = 1; i < n; i++) {
      int now = stdIn.nextInt();
      if (now - min > max) 
        max = now - min;
      if (now < min)
        min = now;
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 99640
from math import sqrt, ceil

def factorization(n):
    l = [n]
    for i in range(1,ceil(sqrt(n))+1):
        if not n % i:
            l.append(i)
            l.append(n//i)
    return l
N, M = map(int, input().split())

if (M % N) == 0:
    print(M//N)
    exit()

f = factorization(M)
ans = 1
for i in f:
    if (M / i) >= N:
        ans = max(i, ans)
print(ans)


Measured memory_bytes: 3064
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[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; }

int main()
{
    ll a, b; cin >> a >> b;
    a--;
    ll ansa, ansb;

    if((b+1)/2%2==0){
        ansb = 0;
    }else{
        ansb = 1;
    }
    if(b%2==0) ansb ^= b;

    if((a+1)/2%2==0){
        ansa = 0;
    }else{
        ansa = 1;
    }
    if(a%2==0) ansa ^= a;
    ll ans;
    if(a==-1) ans = ansb;
    else ans = ansa^ansb;

    pr(ans);

    // pr(ans^a);
    return 0;}

Measured memory_bytes: 3628
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int M,S,cou=0;
int func(int n,int m,int s){
    if(n==10){
        if(m==M&&s==S){
            cou++;
        }
        return cou;
    }
        func(n+1,m,s);
        func(n+1,m+1,s+n);
        return cou;
}
int main(){
    for(;;){
    cou=0;
    cin>>M>>S;
    if(M==0&&S==0)break;
    cou=func(0,0,0);
    cout<<cou<<endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #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); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int H, W;
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		REP(i, H) {
			REP(j, W) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



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

typedef long double ld;
const int N = 333;
const ld inf = 1e9;

int n;
int a[N];
ld f[N][N][N];

ld calc(int u, int v,int w) {
	if (u + v + w == 0) {
		return f[u][v][w] = 0.0;
	}
	if (f[u][v][w] > -1.0) {
		return f[u][v][w];
	}
	ld up = 1.0;
	ld down = 1.0 - (1.0 * (ld)((ld)(n - u - v - w) / (ld)n));
	if (u) up += (1.0 * (ld)((ld)u / (ld)n)) * calc(u - 1, v, w);
	if (v) up += (1.0 * (ld)((ld)v / (ld)n)) * calc(u + 1, v - 1, w);
	if (w) up += (1.0 * (ld)((ld)w / (ld)n)) * calc(u, v + 1, w - 1);
	return f[u][v][w] = (ld)(up / down);
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n; ++j) {
			for (int k = 0; k <= n; ++k) {
				f[i][j][k] = -inf;
			}
		}
	}
	int u = count(a + 1, a + n + 1, 1);
	int v = count(a + 1, a + n + 1, 2);
	int w = count(a + 1, a + n + 1, 3);
	cout << fixed << setprecision(11) << calc(u, v, w) << '\n';
}

Measured memory_bytes: 522368
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
    int n;

    while(cin >> n && n) {
        int a = 0,b = 0;
        rep(i,n) {
            int x,y;
            cin >> x >> y;

            if(x == y) {
                a += x;
                b += y;
            } else if(x > y) {
                a += (x+y);
            } else {
                b += (x+y);
            }
        }

        cout << a << " " << b << endl;
    }

    return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> b(n);
  rep(i, n) cin >> b.at(i);
  bool ok = true;
  vector<int> res;
  while (!b.empty()) {
    int cur = -1;
    per(i, b.size()) {
      if (b.at(i) == i + 1) {
        cur = i;
        break;
      }
    }
    if (cur == -1) {
      ok = false;
      break;
    } else {
      res.insert(res.begin(), b.at(cur));
      b.erase(b.begin() + cur);
    }
  }
  if (ok) {
    for (int c : res) {
      cout << c << endl;
    }
  } else {
    cout << -1 << endl;
  }
  return 0;
}


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


int main(){

  int N,i,j,k,v;
  int *A;

 /* Using loop to check input numbers are in constrants or not */
  while(1){  
    scanf("%d", &N);
    if (N<1 && N>100) printf("error!\n");
    else break;
  }

  /* doing dynamic storange allocation */
  A=(int *)malloc(sizeof(int) * N);
 
 for(i=0 ; i<N ; i++){
    scanf("%d", &A[i]);
  }

 /* output the contents of A */
  for(i=0 ; i<N ; i++){
    printf("%d",A[i]); 
    if(i==N-1)printf("\n");
    else printf(" ");
  }

  /* doing insertion sort and output the machineries */
  for(i=1 ; i<=N-1 ; i++){
    v=A[i];
    j=i-1;
    while(j >= 0 && A[j] > v){
      A[j+1]=A[j];
	j--;
	A[j+1]=v;
    }

    for(k=0 ; k<N ; k++){
      printf("%d",A[k]);
      if(k==N-1)printf("\n");
      else printf(" ");
    }
  }
 
  return 0;
}

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

const long long MOD = 1000000007;

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;
}

long long mul(long long a,long long b,const long long mod){
    return b?(mul(a*2,b/2,mod)+(b&1?a:0))%mod:0;
}

long long bpow(long long a,long long b,const long long mod){
    return (b?bpow(a*a%mod,b/2,mod)*(b&1?a:1):1)%mod;
}

long long inv(long long a,const long long mod){
    return bpow(a,mod-2,mod);
}

// to overflow
/*long long bpow(long long a,long long b,const long long mod){
    return (b?mul(bpow(mul(a,a,mod),b/2,mod),(b&1?a:1),mod):1)%mod;
}*/
class mInt{
public:
    static const long long mod = 1000000007;
    long long v;
    mInt():v(0){}
    mInt(long long v):v((v%mod+mod)%mod){}
};
mInt& operator += (mInt &a,mInt b){ return a = a.v + b.v; }
mInt& operator -= (mInt &a,mInt b){ return a = a.v - b.v; }
mInt& operator *= (mInt &a,mInt b){ return a = a.v * b.v; }
mInt& operator /= (mInt &a,mInt b){ return a = a.v * inv(b.v,mInt::mod); }
mInt operator + (mInt a,mInt b){ return a += b; }
mInt operator - (mInt a,mInt b){ return a -= b; }
mInt operator * (mInt a,mInt b){ return a *= b; }
mInt operator / (mInt a,mInt b){ return a /= b; }
ostream& operator<<(ostream& os, const mInt& x){ return os << x.v; }

typedef vector<vector<mInt>> Matrix;


Matrix operator * (Matrix a, Matrix b){
    Matrix c(a.size(), vector<mInt>(b.size()));
    for(int i = 0 ; i < a.size() ; i++){
        for(int j = 0 ; j < a.size() ; j++){
            for(int k = 0 ; k < a.size() ; k++){
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    return c;
}
Matrix id(Matrix x){
    for(int i = 0 ; i < x.size() ; i++){
        for(int j = 0 ; j < x.size() ; j++){
            x[i][j] = i == j;
        }
    }
    return x;
}

Matrix pow(Matrix a, long long b){
    if( b == 0 ) return id(a);
    Matrix ans = pow(a * a, b / 2);
    if( b & 1 ){
        ans = ans * a;
    }
    return ans;
}


int main(){
    int n;
    cin >> n;
    long long k;
    cin >> k;
    Matrix m(n, vector<mInt>(n));

    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n ; j++){
            int a;
            cin >> a;
            m[i][j] = a;
        }
    }
    auto mm = pow(m, k);
    mInt ans = 0;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n ; j++){
            ans += mm[i][j];
        }
    }
    cout << ans << endl;
}

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

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int targetNum = 7;
array<char,2> ops = {'+', '-'};
vector<int> nums;
int main() {
    string N;
    cin >> N;
    for(auto n: N) {
        nums.push_back(ctoi(n));
    }

    int one, two, three, four;
    int go_seven = 0;
    rep(i, ops.size()) {
        rep(j, ops.size()) {
            rep(k, ops.size()) {
                go_seven += nums[0];
                if(ops[i] == '+') {
                    go_seven += nums[1];
                }       
                else if(ops[i] == '-') {
                    go_seven -= nums[1];
                }
                if(ops[j] == '+') {
                    go_seven += nums[2];
                }       
                else if(ops[j] == '-') {
                    go_seven -= nums[2];
                }
                if(ops[k] == '+') {
                    go_seven += nums[3];
                }       
                else if(ops[k] == '-') {
                    go_seven -= nums[3];
                }

                if(go_seven == 7) {
                    cout << nums[0] << ops[i] << nums[1] << ops[j] << nums[2] << ops[k] << nums[3] << "=7" << endl;
                    return 0;
                }
                go_seven = 0;
            }
        
        } 
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
//#define M   1000000007 // 1e9 + 7
#define MAXN 500100
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
	
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int a[MAXN];
int b[MAXN];
struct coisa{
  int a,b;
  coisa(){}
  coisa(int _a,int _b){
	  a = _a;
	  b = _b;
  }   	
  bool operator < (const coisa &o)const{
  	if(b!=o.b)return !(b>o.b);
  	return !(a > o.a);
  }
};

int32_t main(){
	fastio;
	int n,m;
	cin>>n>>m;
	priority_queue<coisa> pq;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		pq.push(coisa(a[i],b[i]));
	}
	int ans=0;
	set<int> S;
	for(int i=0;i<m;i++)S.insert(i);
	while(!pq.empty()){
		int A = pq.top().a;
		int B = pq.top().b;
		pq.pop();
		if(!S.empty()){
			set<int>::iterator it = S.lower_bound(m - A + 1);
		
			if(it==S.begin())continue;
			--it;
			S.erase(*it);
			ans+=B;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 11376
N = int(input())

def check(t, a):
    T, A = map(int, input().split())
    t = T * max((t + (T-1))//T, (a + (A-1))//A)
    a = A * max((t + (T-1))//T, (a + (A-1))//A)
    return t, a

t = 1
a = 1
for _ in range(N):
    t, a = check(t, a)

print (t + a)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if (S.charAt(1) == 'B') {
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }
        sc.close();
    }
}

Measured memory_bytes: 35712
n = int(input())
A = []

for i in range(n):
    a = int(input())
    A.append(a)

A.sort()

odd = 0
prev = A[0]
cnt = 1

for i in range(1,n):
    if A[i] != prev:
        if cnt % 2 == 1:
            odd += 1
        cnt = 1
        prev = A[i]
    else:
        cnt += 1

if cnt % 2 == 1:
    odd += 1

print(odd)

Measured memory_bytes: 81032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
int N;
  string s;
  cin>>N>>s;
  
  int cnt;
  cnt=0;
for(int i=0;i<N;i++){
  if(s.at(i)=='R'){
    cnt++;
  }
}
  
  if(cnt>N-cnt){
  cout<<"Yes"<<endl;
  }
  else{
      cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
    int A, B, X;
    
    scanf("%d %d %d", &A, &B, &X);
    
    if(X < A){
        printf("NO\n");
    }
    
    else if(X > A+B){
        printf("NO\n");
    }
    
    else{
        printf("YES\n");
    }

    return 0;
}


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


def solve(A: int, B: int):
    if A <= 5:
        return 0
    if A <= 12:
        return B // 2
    return B

# Generated by 1.1.6 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()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(solve(A, B))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188