akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    long long N, ans = 0;
    cin >> N;
    vector<long long> A(N), B(N);//B:書かれた整数ごとのボールの個数
    for(int i = 0; i < N; ++i){
        cin >> A.at(i);
        B.at(A.at(i) - 1)++;
    }
    for(int i = 0; i < N; ++i) ans += B.at(i)*(B.at(i) - 1)/2;//ボール選び出し総和
    for(int i = 0; i < N; ++i) cout << ans - B.at(A.at(i) - 1) + 1 <<endl;
    return 0;
}


Measured memory_bytes: 6428
import copy

def show (a,n):
  for i in range(n):
    if i > 0:
      print("",end=" ")
    print(a[i],end="")
  print("")

def selectionSort(a,n):
  for i in range(n):
    minj = i
    for j in range(i,n):
      if a[j][1] < a[minj][1]:
        minj = j
    a[minj],a[i] = a[i],a[minj]
  show(a,n)

def BubbleSort(a, n):
  for i in range(n):
    for j in range(n-1,i,-1):
      if a[j][1] < a[j-1][1]:
        a[j], a[j-1] = a[j-1],a[j]
  show(a,n)

n = int(input())
a1 = list(input().split())
a2 = copy.copy(a1)

BubbleSort(a1,n)
print("Stable")
selectionSort(a2,n)

for k in range(n):
  if a1[k] != a2[k]:
    print("Not stable")
    exit()

print("Stable")


Measured memory_bytes: 6344
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

class UnionFind:
    def __init__(self,n):
        self.ps = [-1]*(n+1)
    def find(self,x):
        if self.ps[x]<0:
            return x
        else:
            self.ps[x]=self.find(self.ps[x])
            return self.ps[x]
    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if x==y:
            return False
        if self.ps[x]>self.ps[y]:
            x,y = y,x
        self.ps[x] += self.ps[y]
        self.ps[y] = x
        return True
    def same(self,x,y):
        return self.find(x)==self.find(y)
    def size(self,x):
        x = self.find(x)
        return -self.ps[x]

n,m,k = nm()
ed = [nl() for _ in range(m)]
bl = [nl() for _ in range(k)]
al = [0]*n
uf = UnionFind(n)
for a,b in ed:
    uf.unite(a,b)
    al[a-1] += 1
    al[b-1] += 1
ans = [uf.size(x)-1-al[x-1] for x in range(1,n+1)]
for a,b in bl:
    if uf.same(a,b):
        ans[a-1] -= 1
        ans[b-1] -= 1
print(*ans)


Measured memory_bytes: 59772
//om namah shivaay
//faith over fear
//no one wants to die,yet death is the destination we all share 

#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
    ll n,c=0;
    cin>>n;
    while(n>0){
        if(n%10==7) c++;
        n/=10;
    }
    if(c>0) cout<<"Yes";
    else cout<<"No";
}

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    if(n % 2 == 0){
        for(int i = n-1; i >= 0 ;i -= 2){
            cout << a[i] << ' ';
        }
        for(int i = 0; i < n; i += 2){
            cout << a[i] << ' ';
        }
    }else{
        for(int i = n-1; i >= 0; i -= 2){
            cout << a[i] << ' ';
        }
        for(int i = 1; i < n; i += 2){
            cout << a[i] << ' ';
        }
    }
}

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

int main(){
  int N;
  int K;
  int X;
  int Y;
  cin >> N >> K >> X >> Y;
  if(N>=K){
    cout << K*X+(N-K)*Y << endl;
  }
  else{
    cout << N*X << endl;
  }
}  

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([][]int, n)
	for i := 0; i < n; i++ {
		arr[i] = make([]int, 3)
	}
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	arr[0][0], arr[0][1], arr[0][2] = a, b, c
	for i := 0; i < n - 1; i++ {
		fmt.Scan(&a, &b, &c)
		arr[i + 1][0] = max(arr[i][1] + a, arr[i][2] + a)
		arr[i + 1][1] = max(arr[i][0] + b, arr[i][2] + b)
		arr[i + 1][2] = max(arr[i][0] + c, arr[i][1] + c)
	}
	res := max(arr[n - 1][0], arr[n -1][1])
	res = max(res, arr[n - 1][2])
	fmt.Println(res)
}

func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

Measured memory_bytes: 10368
#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) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

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

Measured memory_bytes: 256
# include <stdio.h>
int main (void)
{
	int a,b,c,z,count=0,t,w[3],res;
		for(int i=0;i<3;i++)
		{
			scanf("%d",&w[i]);
		}
		for (int i=0;i<3;i++)
		{
			if(w[i]%2!=0) count++;
		}
		for(int i=0;i<2;i++)
		{
			int t;
			for(int j=i+1;j<3;j++)
			{
				if(w[i]>w[j])
				{
					t=w[i];
					w[i]=w[j];
					w[j]=t;
				}
			}
		}
		if(count==1) res++,t=1;
		if(count==2) res++,t=2;
		for(int i=0;i<3;i++)
		 {
		 	if(t==1 && w[i]%2==0) w[i]++;
		 	else if(t==2 && w[i]%2!=0) w[i]++;
		 }
		 res+=(w[2]-w[0])/2;
		 res+=(w[2]-w[1])/2;
    printf("%d",res);
	 return 0;
}

Measured memory_bytes: 128
n = int(input())
h = list(map(int,input().split()))
dp = [1000000]*n
dp[0] = 0
for i in range(n-2):
    dp[i+2] = dp[i]+abs(h[i+2]-h[i])
    dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
dp[n-1] = min(dp[n-1],dp[n-2]+abs(h[n-2]-h[n-1]))
print(dp[n-1])

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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;
constexpr ll MOD = 1e9 + 7;

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return n * __pow_mod(n, p - 1, mod) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

constexpr int64_t nCr_mod(int64_t n, int64_t r, int64_t mod) noexcept {
    int64_t count = 1;
    auto a = r;
    for (auto i = n; i > n - r; i--) {
        count *= i;
        if (count % mod != 0) {
            count %= mod;
        }
        int64_t inv = pow_mod(a, mod - 2, mod);
        count *= inv;
        if (count % mod != 0) {
            count %= mod;
        }
        a--;
    }
    return count;
}

int main() {
    int N, K;
    cin >> N >> K;
    vi A;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end());
    ll max = A[K - 1], min = A[N - K];

    ll ncr = 1;
    for (int i = 1; i + K - 1 <= N - 1; i++) {
        ncr *= pow_mod(i, MOD - 2, MOD);
        ncr %= MOD;
        ncr *= K - 1 + i;
        ncr %= MOD;
        max += ncr * A[K - 1 + i];
        max %= MOD;
        min += ncr * A[N - K - i];
        min %= MOD;
    }

    cout << (max - min + MOD) % MOD << endl;
    return 0;
}


Measured memory_bytes: 892
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        d: i64,
        e: i64,
        k: i64,
    }

    println!("{}", if e - a > k { ":(" } else { "Yay!" });
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    //ifstream cin("input.in");
    //ofstream cout("output.out");
    ios::sync_with_stdio(0);cin.tie(0);
    long n,a,b;
    cin>>n>>a>>b;
    if(abs(b-n)>abs(n-a))
        cout<<"A";
    else
        cout<<"B";
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int i, j;
    cin >> i >> j;
    if (i > j/2 || j % 2 == 1 || j > i * 4) {
        cout << "No";
    }
    else {
        cout << "Yes";
    }
}

Measured memory_bytes: 3632
s = list(map(int, input().split()))
n = s[0]
m = s[1]
ans = [0]*n
flag = 0
for i in range(m):
    s = list(map(int, input().split()))
    if ans[s[0]-1] != 0 and ans[s[0]-1] != s[1]:
        flag = 1
        break
    elif s[0] == 1 and s[1] == 0 and n>=2:
        flag = 1
        break
    else:
        ans[s[0]-1] = s[1]

if flag == 0:
    if ans[0]==0 and n>=2:
        ans[0]=1
    print(''.join(map(str, ans)))
else:
    print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define vi vector<int>
#define mod 10000000
using namespace std;
ll dp[100001];
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
 int n,k;
 cin>>n>>k;
 int arr[100000];
 for(int i=0;i<n;i++)
 cin>>arr[i];
 dp[2]=arr[1]-arr[0];
if(dp[2]<0)
dp[2]=arr[0]-arr[1];
 for(int i=3;i<=n;i++)
 {
 	
 	int a=arr[i-1]-arr[i-2];
 	if(a<0)
 	a=-a;
 	dp[i]=dp[i-1]+a;
 	for(int j=2;j<=k;j++)
 	{
 		if(i-j-1>=0)
 		{
		 int b=arr[i-1]-arr[i-j-1];
 		if(b<0)
 		b=-b;
 		dp[i]=min(dp[i],dp[i-j]+b);
 	   }
	 }
 }
 cout<<dp[n]<<endl;

    return 0;
}



Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(){
  string s; cin >> s;
  // 文字列を数値に変換.
  int former = (s[0]-'0')*10+(s[1]-'0');
  int latter = (s[2]-'0')*10+(s[3]-'0');
  if(former>=1 && former<=12){
    if(latter>=1 && latter<=12) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }else{
    if(latter>=1 && latter<=12) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'

signed main() {
    int k,n;
    cin >> k >> n;

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

    for(int i = 0; i < n; i++){
        int x = a[i] + k;
        a.push_back(x);
    }

    int m = a.size();
    int ans = 1e9;
    for(int i = n - 1; i < m ; i++){
        ans = min(ans, a[i] - a[i- (n - 1)]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define INF 10000000000



int main(){
    int N,M; cin>>N>>M;
    vector<vector<ll>> dp(M+1,vector<ll>(1<<12,INF));
    dp[0][0] = 0;
    rep(i,M){
        ll a,b; cin>>a>>b;
        vector<ll> c(b);
        int add = 0;
        rep(j,b){
            cin>>c[j];
            c[j]--;
            add |= (1<<c[j]);
        }
        //i個目の鍵を使わないとき
        for(int bit = 0; bit < (1<<N); bit++){
            dp[i+1][bit] = min(dp[i][bit],dp[i+1][bit]);
            dp[i+1][bit|add] = min(dp[i+1][bit|add],dp[i][bit]+a);
        }
    }
    cout<<((dp[M][(1<<N)-1]==INF)?-1:dp[M][(1<<N)-1])<<endl;
}

Measured memory_bytes: 35404
import numpy as np
from scipy.sparse.csgraph import dijkstra

N,M,R = list(map(int,input().split()))
r = list(map(int,input().split()))
for i in range(R):
    r[i] -= 1

connections = np.zeros((N,N))
for i in range(M):
    A,B,C = list(map(int,input().split()))
    A,B = A-1,B-1
    
    connections[A][B] = C
    connections[B][A] = C

connections = dijkstra(connections)

def explore(unvisited,total,start):
    if unvisited:
        ret = float('inf')
        for town in unvisited:
            ret = min(ret,explore(unvisited-set([town]),
                total+connections[start][town],town))
        return ret
    else:
        return total

ans = float('inf')
targets = set(r)
for s in r:
    ans = min(ans,explore(targets-set([s]),0,s))
print(int(ans))

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

int main()
{
   
    double m,n,s=0.0,c=0.0,v;
    long long int i;
   
    cin>>n>>m;
     vector<double> a;
    for(i=0;i<n;i++)
    {
    cin>>v;
    a.push_back(v);
    s+=v;
    }
    double t=s/(4*m);
    for(i=0;i<n;i++)
    {
        if(a[i]>=t)
        c++;
    }
    if(c>=m)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}


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

const int _ = 1e5 + 7 , MOD = 1e9 + 7;
char str[_]; int L , dp[_] , pos[_][3] , sum[_];

void inc(int &a , int b){a = a + b >= MOD ? a + b - MOD : a + b;}

int main(){
	scanf("%s" , str + 1); L = strlen(str + 1); bool flg = 1;
	for(int i = 1 ; i <= L ; ++i) sum[i] = (sum[i - 1] + str[i] - 'a' + 1) % 3;
	for(int i = 2 ; i <= L ; ++i) flg &= str[i] != str[i - 1];
	if(flg){puts("1"); return 0;}
	pos[L + 1][0] = pos[L + 1][1] = pos[L + 1][2] = L + 1;
	for(int i = L ; i ; --i){
		for(int j = 0 ; j < 3 ; ++j) pos[i][(j + str[i] - 'a' + 1) % 3] = pos[i + 1][j];
		pos[i][str[i] - 'a' + 1] = i;
	}
	int p = dp[0] = 1 , ans = 0;
	for(int i = 0 ; i < L ; ++i){
		inc(dp[i + 1] , dp[i]);
		while(p <= L && (p == i + 1 || str[p] != str[p - 1])) ++p;
		inc(dp[pos[p][(!(str[i + 1] - 'a') + 4 - (sum[p - 1] - sum[i])) % 3]] , dp[i]);
	}
	for(int i = 1 ; i <= L ; ++i) inc(ans , (sum[i] == sum[L]) * dp[i]);
	cout << ans; return 0;
}

Measured memory_bytes: 2304
N = int(input())
A = list(map(int, input().split()))
if N == 0:
    if A[0] == 1:
        print(1)
    else:
        print(-1)
elif A[0] != 0:
    print(-1)
else:
    rest = [1]
    for i in range(1, N+1):
        rest.append(min(rest[i-1]*2 - A[i], 10**13))
    ans, cnodes = A[N], A[N]
    for i in range(N-1, -1, -1):
        if cnodes//2 + cnodes%2 > rest[i]:
            print(-1)
            exit()
        else:
            cnodes = min(cnodes, rest[i]) + A[i]
            ans += cnodes
    print(ans)

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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<int> a(n, 0);
	vector<int> b(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}

	sort(b.begin(), b.end());

	int maxx = b[n-1];
	int maxx2 = b[n-2];
	for (int i = 0; i < n; i++) {
		if (a[i] == maxx) {
			cout << maxx2 << endl;
		}
		else {
			cout << maxx << endl;
		}
	}
	

}

Measured memory_bytes: 3200
def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f = f * m % MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv = inv * m % MOD
        invs[m - 1] = inv

    return factorials, invs


def solve(n, a, b, c, d, MOD):
    facts, invs = prepare(n, MOD)
    dp = [0] * (n + 1)
    dp[n] = 1
    for i in range(a, b + 1):
        iv = invs[i]
        for j in range(i * c, n + 1):
            base = dp[j] * facts[j] % MOD
            for k in range(c, d + 1):
                ik = i * k
                if ik > j:
                    break
                pat = base * invs[j - ik] % MOD
                pat = pat * pow(iv, k, MOD) * invs[k]
                dp[j - ik] = (dp[j - ik] + pat) % MOD
    return dp[0]


n, a, b, c, d = map(int, input().split())
MOD = 10 ** 9 + 7
print(solve(n, a, b, c, d, MOD))


Measured memory_bytes: 50780
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<ll,ll> pint;
int main(){
    ll n,k;cin>>n>>k;
    vector<ll> a(n);rep(i,n)cin>>a[i];
    vector<ll> s(n+1,0);
    vector<ll> v;
    //priority_queue<ll> que;
    rep(i,n){
        s[i+1]=s[i]+a[i];
    }
    rep(left,n){
        REP(right,left+1,n+1){
            v.push_back(s[right]-s[left]);
        }
    }
    int m=v.size();
    ll ans=0;
    int b=50;
    for(int i=50;0<=i;i--){
        int cnt = 0;
        ll p = pow(2.0,i);
        rep(j,m){
            ll y = v[j];
            //cout<<((ans+p)&y)<<endl;
            if(((ans+p)&y)==(ans+p)){
                cnt++;
                //cout<<cnt<<endl;
            }
        }
        //cout<<ans+p<<endl;
        if(k<=cnt){
            ans+=p;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6644
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

void solve(long long N, long long K, vector<long long> x){
  x.push_back(0);
  K++;
  sort(x.begin(), x.end());
  vector<long long> l, r;
  for (int i = 0; i < N + 1; i++) {
    if (x[i] < 0) {
      l.push_back(x[i+1] - x[i]);
    } else if (x[i] > 0){
      r.push_back(x[i] - x[i-1]);
    } else {
      K--;
    }
  }
  if (K == 0) {
    std::cout << 0 << std::endl;
    return;
  }
  vector<long long> cl(l.size() + 1);
  vector<long long> cr(r.size() + 1);
  cl[0] = 0;
  cr[0] = 0;
  for (int i = 0; i < l.size(); i++) {
    cl[i+1] = cl[i] + l[i];
  }
  for (int i = 0; i < r.size(); i++) {
    cr[i+1] = cr[i] + r[i];
  }
  long long ret = numeric_limits<long long>::max() >> 1;
  long long t;
  int nl = l.size();
  int nr = r.size();
  for (int i = 0; i < K+1; i++) {
    if ((nl-i < 0) || (K-i > nr)) continue;
    t = 2 * (cl[nl] - cl[nl-i]) + (cr[K-i] - cr[0]);
    ret = min(ret, t);
    t = (cl[nl] - cl[nl-i]) + 2 * (cr[K-i] - cr[0]);
    ret = min(ret, t);
  }
  std::cout << ret << std::endl;
}

int main(){
  long long N;
  long long K;
  scanf("%lld",&N);
  vector<long long> x(N);
  scanf("%lld",&K);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&x[i]);
  }
  solve(N, K, x);
  return 0;
}


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

using namespace std;

int main() {

    int N;
    cin >> N;

    int ans[200010];

    int A[200010];
    for (int i = 2; i <= N; i++) {
        cin >> A[i];
    } 

    for(int i = 2; i <= N; i++) {
        ans[A[i]]++;
    }

    for(int i = 1; i <= N; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}

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

using namespace std;

const int N = 1e5 + 2;

int n, a[N], k, dp[N];

int main(){
      cin >> n >> k;

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

      for(int i = 1; i <= k; i ++){
            for(int j = 1; j <= n; j ++){
                  if(a[j] <= i && !dp[i - a[j]])
                        dp[i] = 1;
            }
      }

      if(dp[k])
            cout << "First";
      else
            cout << "Second";
}


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

#define int long long
#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(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
unsigned GetDigit(unsigned num){
    return log10(num)+1;
}

signed main(){

	int a1,a2,b1,b2;
	cin >> a1 >>b1>>a2>>b2;
	cout << (a1==a2?0:1);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long n;
	cin>>n;
	int ans=0;
	long long m=n;
	for(int i=2;i<=m/i;i++){
		int j=i,t=0;
		while(n%j==0){
			n/=j;
			t++;
		}
		int l=0,r=1000000;
		while(l<r){
			long long mid=l+r+1>>1;
			if((mid)*(mid+1)<=2*t) l=mid;
			else r=mid-1;
		}
		ans+=l;
	}
	if(n>1) ans++;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int a[50][50];

int main(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<int>c(n);
  rep(i,n){
    cin>>c[i];
    rep(j,m){
      cin>>a[i][j];
    }
  }

  int ans=INF;
  rep(bits,(1<<n)){
    vector<int>r(m);
    int sum=0;
    rep(j,n){
      if(bits>>j&1){
        rep(k,m){
          r[k]+=a[j][k];
        }
        sum+=c[j];
      }
    }
    bool ok=true;
    rep(j,m){
      if(r[j]<x)ok=false;
    }
    if(ok)chmin(ans,sum);
  }
  if(ans==INF)ans=-1;
  cout<<ans<<endl;
  return(0);
}



Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int ans = 1;
        int ans2 = 1;
        for (int i = a; i > a - 2; i--) {
            ans *= i;
        }
        ans /= 2;
        for (int i = b; i > b - 2; i--) {
            ans2 *= i;
        }
        ans2 /= 2;
        System.out.println(ans + ans2);
    }
}


Measured memory_bytes: 21844
using System;

namespace AOJ.Volume1
{
    class AizuPR
    {
        public static void Main()
        {
            int cnt = int.Parse(Console.ReadLine());
            for (int i = 0; i < cnt; i++)
            {
                var input = Console.ReadLine();
                Console.WriteLine(input.Replace("Hoshino", "Hoshina"));
            }
        }
    }
}

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

inline int parent(int i) {return i >> 1;}
inline int left(int i) {return i << 1;}
inline int right(int i) {return (i << 1) + 1;}

void maxHeapify(vector<int> & heap, int i){
    int H = heap.size() - 1;
    auto L = left(i);
    auto R = right(i);
    int largest = (L <= H && heap[L] > heap[i]) ? L : i;
    if (R <= H && heap[R] > heap[largest]) largest = R;
    if (largest != i){
        int tmp = heap[i];
        heap[i] = heap[largest];
        heap[largest] = tmp;
        maxHeapify(heap, largest);
    }
}

void buildMaxHeap(vector<int> & heap){
    for (int i = (heap.size() - 1)/2; i != 0; --i) maxHeapify(heap, i);
}


int main()
{
    int H = 0;
    cin >> H;
    vector<int> heap(H + 1);
    heap[0] = 0;
    for (auto it = heap.begin() + 1; it != heap.end(); ++it) cin >> *it;
    buildMaxHeap(heap);
    for (auto it = heap.begin() + 1; it != heap.end(); ++it) cout << ' ' << *it;
    cout << endl;
    return 0;
}

Measured memory_bytes: 4548
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  i64 N;
  cin >> N;
  vector<i64> a(N);
  rep(i,0,N) cin >> a[i];
  sort(all(a));
  double ans = -1e18;
  rep(i,0,N) {
    rep(j,i + 1,N) {
      i64 m = abs(a[i] - a[j]);
      i64 x[2];
      i64 kk = 0;
      for(int k = N - 1;k >= 0;k--) {
        if(i == k || j == k) continue;
        x[kk++] = a[k];
        if(kk == 2) break;
      }
      ans = max(ans, 1.0 * (x[0] + x[1]) / m);
    }
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    string s;
    int n;
    cin >> s >> n;
    for(int i=0; i<s.length(); i+=n) cout << s[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    long long n, m, x;
    long long a[100] = {};
    long long cum_a[100] = {};
    
    cin >> n >> m >> x;
    for(int i = 0; i < m; i++){
        long long temp;
        cin >> temp;
        a[temp] = 1;
    }
    for(int i = 1; i < n; i++)
        cum_a[i] = cum_a[i-1] + a[i];
        
    cout << min(cum_a[x-1], cum_a[n-1]-cum_a[x-1]) << endl;
        
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))

a.sort()
tf = [True] * a[-1]
dup = [False] * a[-1]


for i in range(n):
    if tf[a[i]-1] == True:
        #print(a[i])
        if dup[a[i]-1] == True:
            tf[a[i]-1] = False
        else:
            dup[a[i]-1] = True
            for j in range(a[i]*2, a[-1]+1, a[i]):
                tf[j-1] = False
                

c = 0

#print(tf)

for x in a:
    if tf[x-1]:
        c += 1

print(c)








Measured memory_bytes: 123436
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
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;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int k, a, b;
    cin >> k >> a >> b;
    FOR(x,a,b){
        if (x % k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n,q = map(int,input().split())
s = input()
a = [list(map(int,input().split())) for i in range(q)]
rui = [0] * n
for i in range(n-1):
        if s[i]+s[i+1] == "AC":
                rui[i+1] += rui[i] +1
        else:
                rui[i+1] = rui[i]
for i in range(q):
        tmp = rui[a[i][1]-1] - rui[a[i][0]-1]
        print(tmp)

Measured memory_bytes: 32548
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

vector<int> check;
vector< vector<int> > el;

void dfs(int id) {
	for (int i = 0; i < el[id].size(); ++i) {
		if (check[el[id][i]] == 0) {
			check[el[id][i]] = 1;
			dfs(el[id][i]);
		}
	}
	return;
}

int main(void) {
	int N,M;
	cin >> N >> M;
	vector< pair<int,int> > noe(N);
	for (int i = 0; i < N; ++i) {
		noe[i].first = 0;
		noe[i].second = i;
	}
	el = vector< vector<int> >(N);
	for (int i = 0; i < M; ++i) {
		int u,v,w;
		cin >> u >> v >> w;
		el[u-1].push_back(v-1);
		++noe[u-1].first;
		el[v-1].push_back(u-1);
		++noe[v-1].first;
	}
	sort(noe.begin(),noe.end());

	int res = 0;
	check = vector<int>(N,0);
	for (int i = 0; i < N; ++i) {
		if (check[noe[N-i-1].second] == 0) {
			check[noe[N-i-1].second] = 1;
			++res;
			dfs(noe[N-i-1].second);
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 9984
#![allow(non_snake_case)]

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let N: usize = read();
    let mut dp = vec![N; N+1];
    dp[0] = 0;
    for i in 1..N+1 {
        let mut pow6 = 1;
        while i >= pow6 {
            dp[i] = std::cmp::min(dp[i], dp[i-pow6] + 1);
            pow6 *= 6;
        }
        let mut pow9 = 1;
        while i >= pow9 {
            dp[i] = std::cmp::min(dp[i], dp[i-pow9] + 1);
            pow9 *= 9;
        }
    }
    println!("{}", dp[N]);
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int ma = 0;
vvi a;
bitset<15> sel;
void sch(int n, int now) {
  if(n == now) {
    int cnt = sel.count();
    bool ok = true;
    for(int i=0;i<n;++i) {
      if(!ok) break;
      for(int j=0;j<n;++j) {
        if(a[i][j] != -1 && sel[i] && sel[j] != a[i][j]) {
          ok = false;
          break;
        }
      }
    }
    if(ok) ma = max(ma, cnt);
  } else {
    sel[now] = 1;
    sch(n, now+1);
    sel[now] = 0;
    sch(n, now+1);
  }
}

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

  int n; cin >> n;
  a.resize(n, vi(n, -1));
  for(int i=0;i<n;++i) {
    int m; cin >> m;
    for(int j=0;j<m;++j) {
      int x, y; cin >> x >> y;
      x--;
      a[i][x] = y;
    }
  }

  sch(n, 0);

  cout << ma << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;


int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    rep(k,2)rep(h,2){//最初の文字4パターンを試す
         bool judge=true;
        vector<int>ans;
        ans.pb(k);ans.pb(h);//狼:0　羊:1
    for(int i=2;i<n;++i){
        if(ans[i-1]){
        if(s[i-1]=='x')ans.pb(1-ans[i-2]);
        else ans.pb(ans[i-2]);
        }
        else {
            if(s[i-1]=='x')ans.pb(ans[i-2]);
            else ans.pb(1-ans[i-2]);
        }
    }
    string t="";
    rep(i,n){
        if(ans[i])t+="S";
        else t+="W";
    }
    t.insert(t.begin(),t[n-1]);
    t.push_back(t[1]);
    for(int i=1;i<=n;++i){
            if(ans[i-1]){
                if(s[i-1]=='o'){
                    if(t[i-1]!=t[i+1])judge=false;
                }
                else if(s[i-1]=='x'){
                    if(t[i-1]==t[i+1])judge=false;
                }
            }
            else {
                if(s[i-1]=='x'){
                    if(t[i-1]!=t[i+1])judge=false;
                }
                else if(s[i-1]=='o'){
                    if(t[i-1]==t[i+1])judge=false;
                }
            }
        if(!judge){
            break;
        }
    }
    if(judge){
        t.erase(t.begin());
        t.pop_back();
        cout<<t<<endl;
        return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 1392
// tell me a superman story and hope that dc code is cool about this
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(a);i--)
typedef long long ll;


int main() {
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    vector<char> v;
    rep(i, 0, s.size()) {
        if (v.size() == 0 || v.back() == 'T' || s[i] == 'S') {
            v.push_back(s[i]);
        } else {
            v.pop_back();
        }
    }
    cout << v.size() << endl;
    
    return 0;
}


Measured memory_bytes: 788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;

map<ll, ll> getPrimeFactors(int n) {
  map<ll, ll> p;

  if (n == 0) return p;

  p[1] = 1;

  int num = n;
  for (int i = 2; i * i <= n; i++) {
    while (num % i == 0) {
      num /= i;
      p[i]++;
    }

    if (num == 1) break;
  }

  if (num != 1) p[num]++;

  return p;
}

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}

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

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

  map<ll, ll> lcmP;
  for (int k = 0; k < n; k++) {
    map<ll, ll> primes = getPrimeFactors(a[k]);

    for (auto p : primes) {
      lcmP[p.first] = max(lcmP[p.first], p.second);
    }
  }

  ll lcmNum = 1;
  for (auto lp : lcmP) {
    lcmNum *= modpow(lp.first, lp.second, MOD);
    lcmNum %= MOD;
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += lcmNum * modinv(a[i], MOD) % MOD;
    ans %= MOD; 
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 896
def main():
    A, B, C, X, Y = (int(i) for i in input().split())
    if(A + B) <= C *2:
        print(A * X + B * Y)

    else:
        value = 0
        value = min(X, Y) * C * 2
        if (X - Y) >0:
            min_value = min(int(X - Y)*A, abs(X-Y)*C*2)
        else:
            min_value = min(int(Y - X)*B, abs(X-Y)*C*2)

        print(value + min_value)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
s = input().strip()
Xs = list(map(int, input().split()))
bs = [[],[]]
bb=t=0
for c in s:
    if c == 'T':
        bs[bb].append(t)
        bb=1-bb
        t = 0
    else:
        t += 1
bs[bb].append(t)
rr, bs[0] = bs[0][0],bs[0][1:]
for i in range(2):
    t = 1<<8000
    if i == 0:
        t = t<<rr
    for x in bs[i]:
        t = (t<<x) | (t>>x)
    if not (t>>(Xs[i]+8000))%2:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 39544
#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
//#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010
#define md 1000000007//998244353

#define pb push_back
#define _vcppunko4(tuple) _getname4 tuple
#define _getname4(_1,_2,_3,_4,name,...) name
#define _getname3(_1,_2,_3,name,...) name
#define _trep2(tuple) _rep2 tuple
#define _trep3(tuple) _rep3 tuple
#define _trep4(tuple) _rep4 tuple
#define _rep1(n) for(lint i=0;i<n;++i)
#define _rep2(i,n) for(lint i=0;i<n;++i)
#define _rep3(i,a,b) for(lint i=a;i<b;++i)
#define _rep4(i,a,b,c) for(lint i=a;i<b;i+=c)
#define _trrep2(tuple) _rrep2 tuple
#define _trrep3(tuple) _rrep3 tuple
#define _trrep4(tuple) _rrep4 tuple
#define _rrep1(n) for(lint i=n-1;i>=0;--i)
#define _rrep2(i,n) for(lint i=n-1;i>=0;--i)
#define _rrep3(i,a,b) for(lint i=b-1;i>=a;--i)
#define _rrep4(i,a,b,c) for(lint i=a+(b-a-1)/c*c;i>=a;i-=c)
template<class T>
istream& operator>>(istream& is,vector<T>& vec);
template<class T,size_t size>
istream& operator>>(istream& is,array<T,size>& vec);
template<class T,class L>
istream& operator>>(istream& is,pair<T,L>& p);
template<class T>
ostream& operator<<(ostream& os,vector<T>& vec);
template<class T,class L>
ostream& operator<<(ostream& os,pair<T,L>& p);
template<class T>
istream& operator>>(istream& is,vector<T>& vec){ for(T& x: vec) is>>x;return is; }
template<class T,class L>
istream& operator>>(istream& is,pair<T,L>& p){ is>>p.first;is>>p.second;return is; }
//template<class T>
//ostream& operator<<(ostream& os,vector<T>& vec){ os<<vec[0];rep(i,1,vec.size())os<<' '<<vec[i];return os; }
//template<class T>
//ostream& operator<<(ostream& os,deque<T>& deq){ os<<deq[0];rep(i,1,deq.size())os<<' '<<deq[i];return os; }
template<class T,class L>
ostream& operator<<(ostream& os,pair<T,L>& p){ os<<p.first<<" "<<p.second;return os; }

inline void in(){}
template <class Head,class... Tail>
inline void in(Head&& head,Tail&&... tail){ cin>>head;in(move(tail)...); }
template <class T>
inline bool out(T t){ cout<<t<<'\n';return 0; }
inline bool out(){ cout<<'\n';return 0; }
template <class Head,class... Tail>
inline bool out(Head head,Tail... tail){ cout<<head<<' ';out(move(tail)...);return 0; }

#define rep(...) _vcppunko4((__VA_ARGS__,_trep4,_trep3,_trep2,_rep1))((__VA_ARGS__))
#define rrep(...) _vcppunko4((__VA_ARGS__,_trrep4,_trrep3,_trrep2,_trrep1))((__VA_ARGS__))
#define lin(...) lint __VA_ARGS__;in(__VA_ARGS__)
#define stin(...) string __VA_ARGS__;in(__VA_ARGS__)
#define vin(type,name,size) vector<type> name(size);in(name)
#define fi i.first
#define se i.second

int main(){
	lin(a,b);--a;--b;
	vector<string>s(100);rep(100)s[i].resize(100,(i<50?'#':'.'));
	lint x=0,y=0;
	while(a){
		--a;
		s[y][x]='.';
		x+=2;
		if(x>=100)x=0,y+=2;
	}x=0,y=99;
	while(b){
		--b;
		s[y][x]='#';
		x+=2;
		if(x>=100)x=0,y-=2;
	}cout<<100<<" "<<100<<endl;
	for(auto i:s)cout<<i<<endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  ll h, w; cin >> h >> w;
  ll a[n], b[n];
  int cnt = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    if(a[i] >= h && b[i] >= w) cnt++;
  }
  cout << cnt << endl;

  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------

/// problem's variable---------------


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


int main()
{
    Phuong_;
    int n;
    cin >> n;
    vector<ll> dem(n+1,0);
    vector<int> a(n);
    for(int i=0; i<n; ++i)
    {
        cin >> a[i];
        dem[a[i]]++;
    }
    ll ans=0;
    for(int i=1; i<=n; ++i)
    {
        ans+= (dem[i]*(dem[i]-1))/2;
    }
    for(int i=0; i<n; ++i)
    {
        if (dem[a[i]]<2) cout << ans << '\n'; else
        cout << ans - dem[a[i]]+1 << '\n';
    }
    return 0;
}



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

current_money = 1000
for i in range(N-1):
    stock = 0
    if A[i] < A[i+1]:
        stock = current_money // A[i]
    current_money += (A[i+1] - A[i]) * stock

print(current_money)


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

int main() {
  int N;
  string s;
  cin >> N;
  cin >> s;
  int ans = 0;
  int mx = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'I') ans++;
    else ans--;
    mx = max(mx, ans);
  }
  cout << mx << endl;
}

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

namespace How_Many_Divisors
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            int num1 = int.Parse(input[0]);
            int num2 = int.Parse(input[1]);
            int num3 = int.Parse(input[2]);

            int count = 0;

            for (int i = num1; i <= num2; ++i)
            {
                if (num3 % i == 0)
                {
                    ++count;
                }
            }
            Console.WriteLine(count);
        }
    }
}



Measured memory_bytes: 17924
import Control.Monad
import Data.List

main = do
  li <- getLine
  let [n,m] = map read $ words li
  scs <- forM [1..m] (\_ -> do
    li <- getLine
    let [s,c] = map read $ words li
    return (s,c)
    )
  let ans = compute n scs
  print ans

compute :: Int -> [(Int,Int)] -> Int
compute n scs
  | not (ok c1) = -1
  | otherwise = inner n
  where
    [c1,c2,c3] = [ nub $ findAll i scs | i <- [1..3] ]
    ok c = null c || singleton c
    dig d c = if null c then d else head c
    d1 = dig 1 c1
    d2 = dig 0 c2
    d3 = dig 0 c3
    inner 1 | null c2 && null c3 = dig 0 c1
    inner _ | d1 == 0 = -1
    inner 2 | ok c2 && null c3 = d1 * 10 + d2
    inner 3 | ok c2 && ok c3 = d1 * 100 + d2 * 10 + d3
    inner _ = -1

findAll x kvs = [ v | (k,v) <- kvs, x == k ]

singleton [_] = True
singleton _ = False


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

const int keysize = 7;
const string keyence = "keyence";

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

    if (S == keyence) {
        cout << "YES" << endl;
        return 0;
    }

    if (S.size() < keysize) {
        cout << "NO" << endl;
        return 0;
    }

    if (S.substr(0, keysize) == keyence || S.substr(S.size() - keysize, keysize) == keyence) {
        cout << "YES" << endl;
        return 0;
    }

    int r = 0, l = 0;
    for (int i = 1; i <= keysize; i++) if (S.substr(0, i) == keyence.substr(0, i)) r = i;
    for (int i = 1; i <= keysize; i++) if (S.substr(S.size() - i, i) == keyence.substr(keysize - i, i)) l = i;
    if (r + l >= keysize) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	Weathers := []string{"Sunny", "Cloudy", "Rainy"}
	for i, weather := range Weathers {
		if weather == "Rainy" {
			fmt.Println("Sunny")
			return
		} else {
			if weather == S {
				fmt.Println(Weathers[i+1])
				return
			}
		}
	}
}


Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author emli
 */


#include <bits/stdc++.h>
using namespace std;

class DFloorFunction {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);


        long long a,b,n;

        cin >> a >> b >> n;

        long long r = min(b- 1,n);

        cout << ( (a * r)  - (a * r) % b) / b << endl;


    }
};


int main() {
	DFloorFunction solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

bool issosu(int);
int cntsosu(int);

int main() {
    int n;
    while(true){
        cin>>n;
        if(n==0)break;
        cout<<cntsosu(n)<<endl;
    }
    
    return (0);
}

int cntsosu(int a){
    int ans=0;
    if(a==1)return 1;
    for(int i=a+1;i<2*a;i++){
        if(issosu(i))ans++;
    }
    return ans;
}

bool issosu(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}


Measured memory_bytes: 3076
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <functional>
#include <sstream>
#include <string>
#include <iomanip>
using namespace std;
#define LOG(x) cout << #x << " := " << (x) << endl
#define _LOG(x) cout << "Momentai " << x << endl
typedef long long ll;
typedef long double Lf;

const int max_N = 55;

int N, A, ar[max_N];
ll memo[max_N][max_N][max_N * max_N];

ll rec(int n, int k, int sum) {
    if (k == 0 && sum == 0) return 1;
    if (n == N || sum < 0) return 0;
    ll &ans = memo[n][k][sum];
    if (ans != -1) return ans;

    ans = rec(n+1, k, sum) + rec(n+1, k-1, sum-ar[n]);
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    memset(memo, -1, sizeof(memo));
    cin >> N >> A;
    for (int i = 0; i < N; ++i) cin >> ar[i];
    
    ll ans = 0;
    for (int i = 1; i <= N; ++i) ans += rec(0, i, i*A);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 71808