akhauriyash/Code-Regression huggingface dataset:
fun main(args : Array<String>) {
    val (A, B, Q) = readLine()!!.split(" ").map { it.toInt() }
    val s = LongArray(A)
    val t = LongArray(B)
    (0 until A).forEach {
        s[it] = readLine()!!.toLong()
    }
    (0 until B).forEach {
        t[it] = readLine()!!.toLong()
    }
    // O(AlogA)
    s.sort()
    // O(BlogB)
    t.sort()

    // O(QlogQ)
    (0 until Q).forEach {
        val x = readLine()!!.toLong()
        val si = lowerBound(s, x)
        val ti = lowerBound(t, x)

        val s1 = s.getOrElse(si - 1, { -50000000001L }) // x未満の最大のs
        val s2 = s.getOrElse(si, { 50000000001L }) // ｘ以上の最小のs
        val t1 = t.getOrElse(ti - 1, { -50000000001L }) // x未満の最大のt
        val t2 = t.getOrElse(ti, { 50000000001L })  // x以上の最小のt
        val answer = listOf(Math.max(x - t1,  x - s1), Math.max(t2 - x, s2 - x), t2 - s1 + Math.min(Math.abs(t2 -x), Math.abs(s1 -x)), s2 - t1 + Math.min(Math.abs(s2-x), Math.abs(t1-x)))
                .min()!!
        println(answer)
    }
}

fun lowerBound(array: LongArray, value: Long): Int {
    var low = 0
    var high = array.size
    while (low < high) {
        val mid = (low + high) / 2
        if (value <= array[mid]) {
            high = mid
        } else {
            low = mid + 1
        }
    }
    return low
}

Measured memory_bytes: 58628
# 初期入力
H,N = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))

# 攻撃力の和がHと比較して、大きければ勝てる可能性あり
if H <= sum(A):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 13964
/**
 *    author:  yoseph
 *    created: 02.08.2020 17:16:05      
**/
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	cout << (n % 1000 == 0 ? 0 : 1000 - (n % 1000)) << "\n";
	return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
const int MAX_N=1e6+5;
inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
bool is_prime[MAX_N];
int prime[MAX_N/10],cntp=0,mndiv[MAX_N];//mndiv?????
void init()
{
    repi(i,2,MAX_N-1)  is_prime[i]=1; mndiv[1]=1;
    repi(i,2,MAX_N-1){
        if(is_prime[i]) prime[++cntp]=i,mndiv[i]=i;
        for(int j=1;j<=cntp&&i*prime[j]<MAX_N;j++){
            is_prime[i*prime[j]]=false,mndiv[i*prime[j]]=prime[j];
            if(i%prime[j]==0) break;
        }
    }
}
int a[MAX_N],cnt[MAX_N];
int main()
{
	init();
	ms(cnt);
	int n; si(n);
	repi(i,1,n) a[i]=qi();
	repi(t,1,n){
		int x=a[t];
		repi(i,1,cntp){
			if(1ll*prime[i]*prime[i]>x) break;
			if(x%prime[i]==0) cnt[prime[i]]++;
			while(x%prime[i]==0) x/=prime[i];
		}
		if(x>1) cnt[x]++;
	} 
	int mx=0;
	repi(i,2,MAX_N-1) mx=max(mx,cnt[i]);
	if(mx<=1) puts("pairwise coprime");
	else if(mx<n) puts("setwise coprime");
	else puts("not coprime");
	return 0;
}

Measured memory_bytes: 16620
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int k = int.Parse(input[1]);

    if(k > (n-1)*(n-2)/2)
    {
      Console.WriteLine(-1);
    }else
    {
      long answer = n-1;
      answer += (n-1)*(n-2)/2 - k;
      Console.WriteLine(answer);

      for(int i = 0; i < n-1; i++)
      {
        Console.WriteLine(1 + " " + (i+2));
      }
      answer = (n-1)*(n-2)/2 - k;

      for(int i = 2; i < n; i++)
      {
        for(int j = i+1; j <= n; j++)
        {
          if(answer == 0) break;
          Console.WriteLine(i + " " + j);
          answer--;
        }
        if(answer == 0) break;
      }
    }
	}
}

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

using namespace std;

int main(){
    string s;
    vector <char> ans;

    cin >> s;

    for(int i = 0; i < s.size(); i++){
        if(i % 2 == 0){
            ans.push_back(s[i]);
        }
    }

    for(int i = 0; i < ans.size(); i++){
        cout << ans[i];
    }
}

Measured memory_bytes: 512
#  --*-coding:utf-8-*--

def main():
    S = input()
    K = int(input())

    if len(S) == 1:
        print(K//2)
        return

    R = []
    lastLetter = None
    cnt = 0

    for c in S:
        if lastLetter == c:
            cnt += 1
        else:
            lastLetter = c
            if cnt > 0:
                R.append(cnt)

            cnt = 1
    
    R.append(cnt)

    if len(R) == 1:
        print(len(S)*K//2)
        return

    S = 1 if len(R) > 1 and S[0] == S[-1] and R[0]%2 == 1 and R[-1]%2 == 1 else 0

    x = sum(r//2 for r in R)*K + (K-1)*S

    print(x)




if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
A = input()
N = len(A)
count = {}
ans = 0

for i in range(N):
  if A[i] in count.keys():
    count[A[i]] += 1
  else:
    count[A[i]] = 1

M = len(count.keys())
L = list(count.values())
for i in range(M):
  for j in range(i+1,M):
    
    ans += L[i] * L[j]
print(ans+1)

Measured memory_bytes: 3500
#include<stdio.h>
int main(void)
{
int a,b,c,d,e;
scanf("%d",&a);
b=a/3600;
c=a-(b*3600);
d=c/60;
e=c-(d*60);
printf("%d:%d:%d\n",b,d,e);
return 0;
}

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

int main()
{
    int n,m,correct=0,penalties=0,ans=0;
    cin>>n>>m;
    
    int wa[100006]={0},ac[100006]={0};
    int p;
    string s;
    
    for(int i=0;i<m;i++)
    {
        cin>>p;
        cin>>s;
        
        if(ac[p]==1)
        {
            continue;
        }
        
        if(s=="AC")
        {   
            correct++;
            penalties+=wa[p];
            ac[p]=1;
        }
        
        else if(s=="WA")
        {
            wa[p]++;
        }
        
    }
    
    cout<<correct<<" "<<penalties;
   
    
}

Measured memory_bytes: 1024
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pp pop_back
#define mp make_pair
typedef long long Long;
void FastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
}

const int N = 1e5;

int main()
{
  FastIO();
  int tc, ca = 0;
  int n, k;
  cin >> n >> k;
  vector <int> v(n);
  for (int i = 0;i < n;i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  int sum = 0;
  for (int i = 0;i < k;i++){
    sum += v[i];
  }
  cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 3656
N = int(input())
S = str(input())

count = 0
for i in range(N):
  if S[i] == "E":
    count += 1

ans = 10 ** 10
for i in range(N):
  if S[i] == "E":
    count -= 1
  if i != 0:
    if S[i - 1] == "W":
      count += 1
  ans = min(ans, count)
  
print(ans)
  

Measured memory_bytes: 9716
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}


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

  return 0;
}

Measured memory_bytes: 4816
#include<stdio.h>
#define compile 0
int func_debtHell(int money, int n);
void func_output(int money);
main()
{
	int money = 100000, n = 0, result = 0;
	scanf("%d", &n);
	result = func_debtHell(money, n);
	printf("%d\n", result);
	return 0;
}
int func_debtHell(int money, int n)
{
	static int i = 0;
	int money_a = money * 1.05;
#if compile == 1
	printf("利子計算後のmoney_a = %d\n", money_a);
#endif
	if(0 != (money_a % 1000))
	{
		money_a = ((money_a / 1000) + 1) * 1000; //端数切り上げ処理
	}
#if compile == 1
	printf("端数切り上げ後のmoney_a = %d\n", money_a);
#endif
	if(i == n - 1)
	{
		return money_a;
	}
	else
	{
		i++;
		func_debtHell(money_a, n);
	}
}

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

six = [pow(6, i + 1) for i in range(10) if pow(6, i + 1) <= N]
nine = [pow(9, i + 1) for i in range(10) if pow(9, i + 1) <= N]

d = [1] + six + nine
d.sort()

[1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049]

dp = [[i + 1 if j == 0 else 0 for i in range(N)] for j in range(len(d))]

for i in range(1, len(d)):
  for j in range(N):
    if j + 1 == d[i]:
      dp[i][j] = 1  
    elif j < d[i]:
      dp[i][j] = dp[i - 1][j]
    else:
      dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - d[i]] + 1, dp[i][j - d[i]] + 1)

#for i in dp:
#  print(i)

print(dp[-1][-1])

Measured memory_bytes: 73376
#include<stdio.h>
 
int main(){
  int a,b,c;
  
  scanf("%d %d %d",&a,&b,&c);
  
  if((a==b&&b!=c)||(a!=b&&b==c)||(a==c&&a!=b)){
    printf("Yes\n");
  }	else	{
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
import math


# 組み合わせの計算
def C(n, r):
    ret = math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    return ret


# 組み合わせの総和こ計算
# nCr + nCr-1 + ... + nC0
def sum_C(n, R):
    nCr_0 = 1

    s = nCr_0
    for r in range(min(n, R)):
        nCr_1 = nCr_0 * (n - r) // (r + 1)
        nCr_0 = nCr_1
        s += nCr_1

    return s


# nC0, nC1, nC2, ..., nCrの答えをlistで返す
def list_conb(n, R):
    nCr_0 = 1

    ret = [nCr_0]
    for r in range(min(n, R)):
        nCr_1 = nCr_0 * (n - r) // (r + 1)
        ret.append(nCr_1)
        nCr_0 = nCr_1

    return ret


def main():
    N, P = map(int, input().split())
    A = list(map(int, input().split()))

    A = [a % 2 for a in A]

    n_1 = sum(A)
    n_0 = N - n_1

    # 0 -> 1の数が偶数
    # 1 -> 1の数が奇数

    c = 0
    # 1の袋をi個選び0の袋を好きな個数選ぶ
    if P == 0:
        r = range(0, n_1 + 1, 2)
    else:
        r = range(1, n_1 + 1, 2)

    for i in r:  # 偶数
        if N - i < 0:
            break
        c += C(n_1, i) * sum_C(n_0, N - i)

    print(c)


main()


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

fn input_vt<T: std::str::FromStr>() -> Vec<T> {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	s.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

fn main() {
	let     n  = input_t::<usize>();
    let     xs = input_vt::<u32>();
    let mut c  = xs[0] + xs[n - 2];
    
    for i in 1..(n - 1) {
    	c += std::cmp::min(xs[i - 1], xs[i]);
    }
    
	println!("{}", c);
}


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

inline int parent(int i){
  return i / 2;
}

inline int left(int i){
  return 2 * i;
}

inline int right(int i){
  return 2 * i + 1;
}

int A[500001], n;

void maxHeapify(int i){
  int largest;
  int l = left(i);
  int r = right(i);
  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= n && A[r] > A[largest]) largest = r;
  if(largest != i){
    int tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}

void buildMaxHeap(){
  for(int i = n / 2; i > 0; i--){
    maxHeapify(i);
  }
}

int main(){
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> A[i];
  buildMaxHeap();
  for(int i = 1; i <= n; i++) cout << " " << A[i];
  cout << endl;
  return 0;
}


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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    cin>>str;
    if(str=="SUN") cout<<7;
    else if(str=="MON") cout<<6;
    else if(str=="TUE") cout<<5;
    else if(str=="WED") cout<<4;
    else if(str=="THU") cout<<3;
    else if(str=="FRI") cout<<2;
    else if(str=="SAT") cout<<1;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var N = strShift()
  var X = ~~N;
  N = N.split(NOSP).map(a=>~~a).reduce((a,b)=>a+b);
  
  return X%N?"No":"Yes"
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
148
`);

Measured memory_bytes: 7372
#include<iostream>
using namespace std;
int main()
{

  int n;
  int p[10005];
  int box = 0;
  int ans_1 = 0;
  int ans_2 = 0;
  cin >> n;

  for( int i=0;i<n;i++ ){
    cin >> p[i];
    if( box < p[i] ){
      box  = p[i];
    }
    ans_1+=p[i];
  }

  ans_2 = (ans_1-box)+(box/2);

  cout << ans_2 << endl;

  return(0);

}


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

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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> A(n,vector<int>(m));
	vector<int> b(m);

	rep(i, n)rep(j, m) cin >> A[i][j];
	rep(i, m) cin >> b[i];

	vector<int> ans(n);
	int c;
	rep(i, n)
	{
		c = 0;
		rep(j, m)
		{
			c += A[i][j] * b[j];
		}
		cout << c << endl;
	}
}



Measured memory_bytes: 3200
S=input()
a=1
b=0
ct1,ct0=0,0
#print(type(S))
for i in range(len(S)):
    a=a^1
    b=b^1
    #print(a,b)
    if(a!=int(S[i])):
        ct1+=1
    if(b!=int(S[i])):
        ct0+=1
print(min(ct1,ct0))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define maxn 300300
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define debug
using namespace std;

int v[maxn];

int main() {
    int n,t,k;
    scanf("%d%d%d",&n,&t,&k);
    vector<pii> a;
    for(int i=0;i<n;i++){
        scanf("%d",v+i);
        a.pb(pii(v[i],i));
    }
    sort(a.begin(),a.end());
    int l = 0, r = 0;
    int ans = 2e9;
    while(l < n){
        while(r < n){
            int nq = 0;
            int len = 0, good = 0;
            for(int i=0;i<n;i++){
                if(v[i] > a[r].first){
                    len++;
                    continue;
                }
                else if(v[i] >= a[l].first){
                    len++, good++;
                    continue;
                }
                else {
                    nq += max(0,min(good,len-t+1));
                    len = good = 0;
                }
            }
            nq += max(0,min(good,len-t+1));
            debug("l %d r %d nq %d\n",a[l].first,a[r].first,nq);
            if(nq >= k)
                break;
            r++;
        }
        if(r == n)
            break;
        ans = min(ans,a[r].first-a[l].first);
        l++;
    }
    printf("%d\n",ans);
}

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

using namespace std;

const int INF = 1e9;

void up(long long & x, long long y)
{
    if(x < y)
        x = y;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 ///   freopen("input.txt", "r", stdin);

    int n, w;
    cin >> n >> w;

    vector <long long> dp(w + 1);
    for(int i = 0; i < n; ++i)
    {
        int a, b;
        cin >> a >> b;
        for(int j = w; j >= a; --j)
            up(dp[j], dp[j - a] + b);
    }

    cout << dp[w] << '\n';

    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define MAXN 200 + 5
const long long INF = 1LL << 60;
const int inf = 1 << 30;

void printVec(std::vector<ll> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}
 
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(){
  int n;
  cin >> n;

  int ans = 0;
  rep(i, 1, n+1){
    rep(j, 1, n+1){
      rep(k, 1, n+1){
        int g = __gcd(i, j);
        ans += __gcd(g, k);
      }
    }
  }
  cout << ans << endl;
}

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

#ifdef BTK
#define DEBUG if(1)
#else
#define DEBUG if(0)
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#endif

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r){bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r){bool a=l<r;if(a)l=r;return a;}
template <typename T>istream& operator>>(istream &is,vector<T> &v){for(auto &it:v)is>>it;return is;}

constexpr char ln = '\n';
constexpr int mod = 1e9+7;
const string ok = "Yes";
const string ng = "No";

struct edge{
    LL flow;int to,rev;
};
typedef vector<edge> E;
typedef vector<E> Graph;

void addedge(Graph&g,int from,int to,LL f){
    int x=g[from].size();
    int y=g[to].size();
    g[from].pb(edge{f,to,y});
    g[to].pb(edge{0ll,from,x});
}

vector<int> bfs(Graph& G,int s){
    int N = G.size();
    queue<int> que;
    vector<int> dist(N,-1);
    dist[s] = 0;
    que.push(s);
    for(;!que.empty();que.pop()){
        auto v=que.front();
        for(auto& e : G[v])
            if(e.flow>0&&dist[e.to]==-1){
                dist[e.to] = dist[v] + 1;
                que.push(e.to);
        }
    }
    return dist;
}

LL maxflow(Graph& G,int s,int t){
    LL res=0;
    int N = G.size();
    while(true){
        auto dist = bfs(G,s);
        if(dist[t] < 0)break;
        vector<unsigned> iter(N,0);
        std::function<LL(int,LL)> dfs=[&](int v,LL f){
            if(v==s)return f;
            for(auto &i = iter[v]; i < G[v].size(); i++){
                edge &e = G[v][i];
                edge &re = G[e.to][e.rev];
                if(re.flow>0 && dist[v] >dist[e.to]){
                    LL d=dfs(e.to,min(f,re.flow));
                    if(d>0){e.flow+=d;re.flow-=d;return d;}
                }
            }
            return 0ll;
        };
        LL f;
        while((f=dfs(t,114514))> 0)res+=f;
    }
    return res;
}

constexpr LL INF = 1e13;
int main(){
    int N;
    cin>>N;
    vector<LL> a(N);
    cin>>a;
    int S = N;
    int T = S+1;
    Graph g(N+2);
    REP(i,N){
        int I=i+1;
        for(int J=I+I;J<=N;J+=I){
            int j = J-1;
            addedge(g,i,j,INF);
        }
    }
    LL sum = 0;
    REP(i,N){
        if(a[i]>0){
            sum+=a[i];
            addedge(g,i,T,a[i]);
        }
        if(a[i]<0){
            addedge(g,S,i,-a[i]);
        }
    }
    cout<<sum-maxflow(g,S,T)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		 long double   ld;
typedef		vector<ll>      vll;
#define     fi              first
#define     print(v)        for(ll i:v) cout<<i<<ss
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;


int main()
{

    ll a,b,k;
    cin>>a>>b>>k;
    ll mn=min(a,k);
    a-=mn;
    k-=mn;
    b-=min(b,k);
    cout<<a<<ss<<b<<nn;





}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






Measured memory_bytes: 3568
#include<bits/stdc++.h>
#include<bitset>
#include<string>
using namespace std;
#include <numeric> 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using pi=pair<long long,long long>;
#define pii 3.1415926536
#define binary
#define mod 1000000007
typedef long long ll;
typedef long double ld;
bool sortbysec(const pair<long long,long long> &a, 
              const pair<long long,long long> &b) 
{ 
    return (a.first < b.first); 
}
bool compare(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll>&b)
{
    if(a.first.first==b.first.first)return (a.first.second<b.first.second);
    return (a.first.first < b.first.first); 
}
 int lcm(int a, int b)  
 {  
    return (a*b)/__gcd(a, b);  
 }  
 int Kad(ll dp[],ll n)
{
  ll curr_max=0,maxx=INT_MIN;
  for(int i=0;i<n;i++)
  {
    curr_max=curr_max+dp[i];
    if(curr_max>maxx)
      maxx=curr_max;

    if(curr_max<0)
      curr_max=0;
   
  }

  return maxx;
}

/*void dfs(int u)
{
    vis[u]=true;
    //cout<<u<<" ";
    std::vector<ll> ::iterator i;
     for (i = g[u].begin(); i != g[u].end(); ++i) 
        if (!vis[*i]) 
            dfs(*i); 
    for(int i=1;i<g[u].size();i++)
    {
        if(!vis[g[u][i]])
        {
            dfs(i);
        }
    }
}*/

class query
{
public:
    int fi,sec,in;
};
bool sortby(query a, query b)
{
    if(a.sec==b.sec)
        return (a.fi<b.fi);
    else
        return (a.sec<b.sec);
}
void update(int* bit,int ind,int val,int n)
{
    for(;ind<=n;ind+=(ind&(-ind)))
        bit[ind]+=val;
}
int value(int val,int *bit)
{
    ll sum=0;
    for(;val>0;val-=(val&(-val)))
        sum+=bit[val];
    return sum;
}
int main()
{

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

  query* qu=new query[q];
  for(int i=0;i<q;i++)
  {
    cin>>qu[i].fi>>qu[i].sec;
    qu[i].in=i;
  }
  sort(qu,qu+q,sortby);
  int* bit=new int[n+1];
  int* ans=new int[q]();

  ll total=0;
  ll k=0;
  ll* last=new ll[1000002];
  for(int i=0;i<1000002;i++)
  {
    last[i]=-1;
  }
  for (int i = 1; i <=n; ++i)
  {
      if(last[a[i]]!=-1)
      {
        update(bit,last[a[i]],-1,n);
      }
      else
      {
        total++;
      }
      update(bit,i,1,n);
      last[a[i]]=i;
      while(k<q && qu[k].sec==i)
      {
        ans[qu[k].in]=total-value(qu[k].fi-1,bit);
        k++;
      }
  }
  for (int i = 0; i < q; ++i)
  {
      cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 25320
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin>>n>>m;
	vector<pair<int,int>>a(m);
	for(int i=0;i<m;i++)cin>>a[i].first>>a[i].second;
	int l = a[0].first;
	int r = a[0].second;
	for(int i=1;i<m;i++)
	{
		if(a[i].first>l)l=a[i].first;
		if(a[i].second<r)r=a[i].second;
	}	
	if(r<l)cout<<"0"<<endl;
	else cout<<r-l+1<<endl;
	return 0;
}

Measured memory_bytes: 1024
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end

  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end

  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (h1, m1, h2, m2, k) = InputLine.to_ia

  h = (h2 + 1) - h1
  m = h * 60 - m1 - (60 - m2)
  puts (m - k).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14388
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b and b == c and a == c){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map(String::toLong).sorted()
    val aSumList = mutableListOf(aList[0])
    (1 until n).forEach { aSumList.add(aList[it] + aSumList[it - 1]) }
    for (i in n - 1 downTo 1) {
        if (aList[i]> aSumList[i - 1] * 2){
            println(n-i)
            return
        }
    }
    println(n)
}

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

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

  vector<vector<int>> c(10, vector<int>(10));
  rep(i, 10) rep(j, 10) cin >> c[i][j];

  vector<vector<int>> a(H, vector<int>(W));
  rep(i, H) rep(j, W) cin >> a[i][j];

  vector<int> v = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  vector<int> cost(10, 1000);
  auto dfs = [&](int n, int s, vector<bool> u, int acc, auto f) {
    u[n] = true;
    if (n == 1) {
      cost[s] = min(cost[s], acc);
      return;
    }
    for (auto next : v)
      if (!u[next])
        f(next, s, u, acc + c[n][next], f);
  };

  rep(i, 10) {
    vector<bool> used(10);
    dfs(i, i, used, 0, dfs);
  }

  int ans = 0;
  rep(i, H) rep(j, W) {
    if (a[i][j] == -1)
      continue;
    ans += cost[a[i][j]];
  }
  cout << ans << endl;
}

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

#define int long long 
#define f(i,n) for(int i=1;i<=n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int N = 403;
const int inf = 1e15;

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

void solve()
{   
    cin >> n;
    
    f(i,n) cin >> a[i];
    
    f(i,n-1) a[i+1]+=a[i];
    
    for(int len=1;len<=n;len++)
    {
        for(int i=1;i<=n-len;i++)
        {
            dp[i][i+len] = inf;
            
            for(int j=i;j<i+len;j++) 
                dp[i][i+len] = min(dp[i][i+len],dp[i][j] + dp[j+1][i+len] + a[i+len] - a[i-1]);
        }
    }
    
    cout << dp[1][n];
}

signed main()
{
    fast;
    solve();
}

Measured memory_bytes: 1536
# C
from itertools import permutations
import numpy as np
n = int(input())
machis = []
for _ in range(n):
    x, y = list(map(int, input().split()))
    machis.append((x, y))
kumi = permutations(machis)

nagasa = []
for k in list(kumi):
    kwa = 0
    for i in range(len(k)-1):
        x, y = k[i]
        nx, ny = k[i+1]
        kwa += np.sqrt((x-nx)**2 + (y-ny)**2)
    nagasa.append(kwa)
print(np.mean(nagasa))

Measured memory_bytes: 20324
from collections import deque

def main():
    n = int(input())
    l = list(map(int, input().split()))

    comfort = 0
    l_sorted = sorted(l, reverse=True)
    q = deque([l_sorted[0]])
    for i in range(1, n):
        comfort += q[0]
        q.popleft()
        for _ in range(2):
            q.append(l_sorted[i])
    print(comfort)

if __name__ == '__main__':
    main()


Measured memory_bytes: 106812
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define ll long long
using namespace std;

int main()
{
    map <int, int> mp;

    int n;
    cin >> n;
    int val;
    for(int i = 0; i < n - 1; i ++)
    {
    	cin >> val;
    	mp[val] ++;
    }

    for(int i = 1; i <= n; i ++)
    	cout << mp[i] << endl;
}

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

int main()
{
	int n;
	cin >> n;
	if(n%1000==0)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << (n/1000+1)*1000-n<< endl;
	}
	return 0;
}

Measured memory_bytes: 3532
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R


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

	cin >> N;
	char ans = 'a';
	for (int i = 0; i < N; i++){
		char a;
		cin >> a;
		if (ans == 'a') {
			ans = a;
			continue;
		}
		if (ans == 'F')ans = 'T';
		else ans = a;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int a,b,c=1000000000000,d;
  cin>>a;
  d=sqrt(a);
  for(long long int i=1;i<=d;i++){
      if(a%i==0){
        b=a/i;
        c=min(c,i+b-2);
    }
  }
  cout<<c;
}

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

int const N = 2e5 + 10;

int n;
string s;

int stk[N], top;

void solve ()
{
	top++;
	stk[top] = 0;
	int ans = s.size();
	for (int i = 1; i < s.size(); i++)
	{
		top++;
		stk[top] = i;
		while (top >= 2 && s[stk[top]] == 'T' && s[stk[top-1]] == 'S')
		{
			top -= 2;
			ans -= 2;
		}
	}
	cout << ans << '\n';
}

int main ()
{
	cin.sync_with_stdio (false);
	cin >> s;
	solve ();
	return 0;
}

Measured memory_bytes: 1300
import math

def isPrime(n):
    if n <= 2:
        return n == 2
    if (n % 2 == 0):
        return False
    for i in range(3, int(math.sqrt(n)) + 1, 2):
        if n % i == 0:
            return False
    return True

N = int(input())
print(len(list(filter(isPrime, [int(input()) for i in range(N)]))))



Measured memory_bytes: 6068
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		Queue<Long> queue = new LinkedList<>();		
		for(int i = 1; i < 10; i++){
			queue.add((long)i);
		}
		
		Long k = scanner.nextLong();
		for(Long i = 0l; i < k - 1; i++) {
			Long x = queue.poll();
			if(x % 10 != 0) {
				queue.add(10 * x + x % 10 - 1);
			}
			queue.add(10 * x + x % 10);
			if(x % 10 != 9) {
				queue.add(10 * x + x % 10 + 1);
			}
		}
		System.out.println(queue.poll());
		scanner.close();
	}

}


Measured memory_bytes: 46420
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
頂点-辺

1 2 3 4 5

2-3とか
11
12 22
13 23 33  2
14 24 34 44  2
15 25 35 45 55  2 = 3以降の、1と2のカウントだけ。
2-3 = 2 * (5-3+1) = 
辺数
L-R = L * (N-R+1)
頂点 2
11
12 22 2
13 23 33 2
1＝N
2 = (N-2+1)*2
3 = (N-3+1)*3

N=5
1*5 + 4*2 + 3*3 + 2*4 + 1*5

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N; cin >> N;
  ll side=0, edge=0;
  for(ll i=1; i<=N; i++)
    edge += i * (N-i+1);
  rep(i, N-1){
    ll u, v; cin >> u >> v;
    if (v < u)
      swap(u, v);
//cout <<u<<" "<<v<<endl;    
    side += u * (N - v + 1);
  }
  ll ans = edge - side;
  cout << ans << endl;
}


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

int gcd(int a, int b) {
     if (a%b == 0) {
    return b;
  }
  
  else {
    return gcd(b, a%b);
  }
}
  
int main() {
  int K;
  cin >> K;
  
  int ans = 0;
  for (int i = 1; i < K+1; i++) {
    for (int j = 1; j < K+1; j++) {
      for (int k = 1; k < K+1; k++) {
        ans += gcd(gcd(i, j), k);
      }
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back

using namespace std;

bool compare_by_b(pair<string,int> a,pair<string,int> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,int> a,pair<string,int> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    ll n;
    cin>>n;
    vector<double> v(n),div;
    rep(i,n) cin>>v[i];
    
    sort(ALL(v));
    div.pb((v[0]+v[1])/2);
    
    for(int i=2;i<n;i++){
        div.pb((div[i-2]+v[i])/2);
    }
    cout<<div[n-2]<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

var N, M int

func main() {
	fmt.Scan(&N, &M)
	A, B := make([]string, N), make([]string, M)

	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}
	for i := 0; i < M; i++ {
		fmt.Scan(&B[i])
	}

	ans := false
	// 行オフセット
	for i := 0; i+M <= N; i++ {
		// 列オフセット
		for j := 0; j+M <= N; j++ {
			ok := true

			// マッチ or ノットマッチ
			for y := 0; y < M; y++ {
				for x := 0; x < M; x++ {
					if B[y][x] != A[y+i][x+j] {
						ok = false
					}
				}
			}
			// マッチしてたら
			if ok {
				ans = true
			}
		}
	}
	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

/*  ----------------------------------------  */
func lcm(x, y uint64) uint64 {
	return (x / gcd(x, y)) * y
}

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 1000000007LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (ll i=(a); i >= b; i--)

#define MN 100005
int m, d;

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

    cin >> m >> d;
    int cnt = 0;
    FOR(i, 1, m){
        FOR(j, 1, d){
            int a = j/10, b = j%10;
            if(a <= 1 || b <= 1) continue;
            if(a*b==i) ++cnt;
        }
    }
    cout << cnt << "\n";
    
    return 0;
}


Measured memory_bytes: 256
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, M, X = map(int, input().split())
c = []
A = [[] for _ in range(N)]
for j in range(N):
	tmp = list(map(int, input().split()))
	for i in range(M+1):
		if i == 0:
			c.append(tmp[i])
		else:
			A[j].append(tmp[i])
A = np.array(A)
ans = 10**10
cond = 0
for s in range(1 << N):
	flg = np.zeros(M)
	cost = 0
	for i in range(N):
		if (s >> i) & 1 == 1:
			flg += A[i]
			cost += c[i]
	if np.count_nonzero(flg < X) == 0:
		cond = 1
		ans = min(ans, cost)
if cond:
	print(ans)
else:
	print(-1)

Measured memory_bytes: 27164
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n;
    cin>>n;
    int a[n];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a, a+n);
    int x=n/2, y=x-1;
    cout<<a[x]-a[y];
    return 0;
}

Measured memory_bytes: 4052
use std::vec::Vec;

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

const MOD: usize = 1_000_000_000 + 7;

fn main() {
    let n: usize = read();

    let mut power = 1;
    for i in 1..n+1 {
        power *= i;
        power %= MOD;
    }

    println!("{}", power);
}


Measured memory_bytes: 4352
//https://github.com/mostafa-saad/MyCompetitiveProgramming/blob/master/UVA/UVA_10740.txt
#include<queue>
#include<map>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)

int k,n;
string s;
 main()
{

//cout<<Pow((ll)1000000,(ll)110);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//    char input[15];
//    scanf("%s", &input);  array of char
//  gets(c+1);  array of char
//printf("%s, ",name[k[i]].c_str());  printf of string
input;
cin>>n>>k;
cin>>s;
if(s[k-1]=='A')s[k-1]='a';
else if(s[k-1]=='B')s[k-1]='b';
else if(s[k-1]=='C')s[k-1]='c';

cout<<s;

return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

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

    int ans = max(max(a, b), c) * 10 + a + b + c - max(max(a, b), c);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <bitset>
typedef long long ll;
#define inc(i) (++ (i))
#define dec(i) (-- (i))
#define Rep(i , a , b) for(int i = (a) , i##Limit = (b) ; i <= i##Limit ; inc(i))
#define rep(i , a , b) for(int i = (a) , i##Limit = (b) ; i >= i##Limit ; dec(i))
#define Eep(i , u , v) for(int i = Head[u] , v = Node[i] ; i ; v = Node[i = Next[i]])
using namespace std;

const int M = 400 + 7 , N = 100000 + 7;
int n , m , A[N] , B[N];
bool flag[N];
bitset <M> S[M];

int main() {
	scanf("%d%d" , &m , &n);
	Rep(i , 1 , n) scanf("%d%d" , A + i , B + i);
	Rep(i , 1 , m) {
		S[i][i] = 1;
		rep(j , n , 1) {
			if(S[i][A[j]] && S[i][B[j]]) {
				flag[i] = 1;
				break;
			}
			if(S[i][A[j]] || S[i][B[j]]) S[i][A[j]] = S[i][B[j]] = 1;
		}
	}
	int Ans = 0;
	Rep(i , 1 , m)	if(!flag[i])
		Rep(j , i + 1 , m) if(!flag[j]) 
			if(!(S[i] & S[j]).count()) inc(Ans);
	printf("%d" , Ans);
	return 0;
}

Measured memory_bytes: 1024
using System;
class Program
{
    private bool isnumber(string s, int k)
    {
        char[] num = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
        int i = Array.IndexOf(num, s[k]);
        return i >= 0 ? true : false;
    }
    public static void Main()
    {
        Program prog = new Program();
        string[] str = Console.ReadLine().Split(' ');
        int a, b;
        a = int.Parse(str[0]);
        b = int.Parse(str[1]);
        string s = Console.ReadLine();
        int f = 1;
        if (s[a] != '-')
            f = 0;
        for (int i = 0; i < a; i++)
        {
            if (!prog.isnumber(s, i))
            {
                f = 0;
                break;
            }
        }
        if (f == 1)
        {
            for (int i = a + 1; i <= a + b; i++)
            {
                if (!prog.isnumber(s, i))
                {
                    f = 0;
                    break;
                }
            }
        }
        if (f == 1)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}

Measured memory_bytes: 13140
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
 
for num in b:
    for i in range(len(a)):
        for j in range(len(a[i])):
            if a[i][j] == num:
                a[i][j] = 'O'
                
if (a[0][0] == a[0][1] == a[0][2]) or (a[1][0] == a[1][1] == a[1][2]) or (a[2][0] == a[2][1] == a[2][2])\
or (a[0][0] == a[1][1] == a[2][2]) or (a[0][2] == a[1][1] == a[2][0])\
or (a[0][0] == a[1][0] == a[2][0]) or (a[0][1] == a[1][1] == a[2][1]) or (a[0][2] == a[1][2] == a[2][2]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
#include <stdio.h>
#include <string.h>

int main(int argc, char const *argv[]) {
    int n;
    scanf("%d", &n);
    int t_p = 0, h_p = 0;

    for (int i = 0; i < n; i++) {
        char t_str[101];
        char h_str[101];

        scanf("%s", t_str);
        scanf("%s", h_str);

        if (strcmp(t_str, h_str) == 0) {
            t_p++;
            h_p++;
        } else if (strcmp(t_str, h_str) < 0) {
            h_p += 3;
        } else {
            t_p += 3;
        }
        
    }

    printf("%d %d\n", t_p, h_p);
    return 0;
}


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

#define INF (1 << 30)
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
template <typename T>
vector<vector<T> > v2init(int y_len, int x_len, T padding){
    vector<vector<T> > vec(y_len, vector<T>(x_len, padding));
    return vec;
}
template <typename T>
vector<vector<T> > v2sort(vector<vector<T> > vec, int index){
    sort(vec.begin(), vec.end(), [index](const vector <T>  a, const vector <T> b){return (a[index] < b[index]);});
    return vec;
}
template <typename T>
void v2show(vector<vector<T> > vec){
    for(int i = 0; i < vec.size(); i++){
        for(int j = 0; j < vec[0].size(); j++){
            cout << vec[i][j] << " ";
        }
        cout << endl;
    }
}
template <typename T>
ll v2sum(vector<vector<T>> vec){
    ll ans = 0;
    for (int i = 0; i < vec.size(); i++){
        for (int j = 0; j < vec[0].size(); j++){
            ans += vec[i][j];
        }
    }
    return ans;
}
template <typename T, typename S>
vector<vector<T> > banpei(vector<vector<T> > vec, S padding){
    vector<vector<T> > ret = v2init<T>(vec.size()+2, vec[0].size()+2, vec[0][0]);
    for (int i = 0; i < vec.size()+2; i++){
        for (int j = 0; j < vec[0].size()+2; j++){
            if((i == 0) || (j == 0) || (i == vec.size()+1) || (j == vec[0].size()+1)){
                ret[i][j] = padding;
            }else{
                ret[i][j] = vec[i-1][j-1];
            }
        }
    }
    return ret;
}

int main(){
    int n, m;
    cin >> n >> m;
    auto vec = v2init<int>(n, 2, 0);
    rep(i, n){
        cin >> vec[i][0] >> vec[i][1];
    }
    vec = v2sort(vec, 0);
    priority_queue<int> pq;
    int ans = 0;
    int start = 0;
    rep(i, m){
        int day = i+1;
        for(int j = start; j < n; j++){
            if(vec[j][0] <= day){
                pq.push(vec[j][1]);
                start++;
            }else{
                break;
            }
        }
        if(pq.empty() == false){
            ans += pq.top();
            pq.pop();
        }
    }
    out(ans);
    return 0;
}

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

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

const ll mod=998244353;
const int mx=1e5+5;

ll dis[mx];
ll dp[mx];
ll fre[mx];

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

	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>dis[i];
		fre[dis[i]]++;
	}
	
	ll ans=1;
	
	if(fre[0]!=1) ans=0;
	
	for(int i=2;i<=n;i++)
	{
		ans*=fre[dis[i]-1];
		ans%=mod;
	}
		
	cout<<ans;
	
							                                				
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}

Measured memory_bytes: 1792