akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = (int)1e6 + 10;
int a[maxN];
int cnt[3];
int solve() {
    int sm = 0;
    for (int i = 0; i < n; i++) {
        if ((i & (n - 1)) == i) sm ^= (a[i] % 2);
    }
    return sm;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        a[i] = c - '1';
        cnt[a[i]]++;
    }
    if (cnt[1] == 0) {
        for (int i = 0; i < n; i++) {
            a[i] /= 2;
        }
        cout << 2 * solve();
    }
    else {
        cout << solve();
    }
    return 0;
}

Measured memory_bytes: 4224
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n + 2];
		for (int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int total = 0;
		for (int i = 1; i < a.length; i++) {
			total += Math.abs(a[i] - a[i - 1]);
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 1; i <= n; i++) {
			int v1 = Math.abs(a[i] - a[i - 1]) + Math.abs(a[i] - a[i + 1]);
			int v2 = Math.abs(a[i + 1] - a[i - 1]);
			pw.println(total - v1 + v2);
		}
		pw.flush();
	}
}


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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define RREP(i,a) for(int i = a;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int A, B;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> A >> B;
	cout << (A + B) % 24 << endl;
	return 0;
}



Measured memory_bytes: 256
"use strict"
function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0].trim());
  let A = input[1].trim().split(' ').map(Number).sort((a, b) => b-a);

  let ret = 0;
  for(let i=0; i<N*2; i++){
    if((i+1)%2===0){
      ret += A[i];
    }
  }

  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 37588
def ad(A, B):
    n = len(A)
    tmp = [0] * n
    for i in range(n):
        tmp[i] += A[i] + B[i]
    return tuple(tmp)

def judge(A):
    flag = True
    for i in A[1:]:
        if i < X:
            flag = False
    return flag

def rec(A, i):
    global ans
    if i == N:
        if judge(A) and ans > A[0]:
            ans = A[0]
        return 0
    rec(ad(A,C[i]), i + 1)
    rec(A, i + 1)

N, M, X = [int(i) for i in input().split()]
C = [[int(i) for i in input().split()] for _ in range(N)]
A = tuple([0]*(M+1))
ans = 12*(10**5) + 1
rec(A, 0)
if ans == 12*(10**5) + 1:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 70188
x,k,d=map(int,input().split())
if d==0:
  print(abs(x))
  exit()

s=abs(x)//d
if s>=k:
  if x>=0:
    print(abs(x-k*d))
  else:
    print(abs(x+k*d))
elif k>s and (k-s)%2==0:
  if x>=0:
    print(abs(x-s*d))
  else:
    print(abs(x+s*d))
else:
  if x>=0:
    y=x-s*d
  else:
    y=x+s*d
  print(min(abs(y+d),abs(y-d)))
 

Measured memory_bytes: 9204
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
      	String T = sc.nextLine();
      	int max = Integer.MIN_VALUE;
      int s = S.length();
      int t = T.length();
      if(s<t) return;
      for(int i=0; i<=s-t; i++){
        int count = 0;
        for(int j=0; j<t; j++){
          if(S.charAt(i+j) == T.charAt(j)) count++;
        }
        max = Math.max(max, count);
      }
      	System.out.println(t - max);
	}
}

Measured memory_bytes: 35964
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        long totalXor = a[0];
        for (int i = 1; i < n; i++) {
            totalXor ^= a[i];
        }
        for (int i = 0; i < n; i++) {
            System.out.println(a[i] ^ totalXor);
        }
    }

}


Measured memory_bytes: 61436
def generate_G(n):
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    return G


def insertion_sort(A, n, g):
    global count
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j -= g
            count += 1
        A[j + g] = v


def shell_sort(A, n):
    G = generate_G(n)
    print(len(G))
    print(' '.join(map(str, G)))
    for g in G:
        insertion_sort(A, n, g)


def main():
    global count

    # input
    n = int(input())
    A = [int(input()) for _ in range(n)]

    # sort
    shell_sort(A, n)

    # output
    print(count)
    for a in A:
        print(a)


if __name__ == "__main__":
    count = 0
    main()



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

int main() {
  int N;
  cin >> N;
  
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  
  int layer = 0;
   
  for (int j = 0; j < N; j++) {
    
    int max = 0;
    bool a = false;
  
    for (int i = 0; i < N; i++) {
      if (d.at(i) > max) {
        max = d.at(i);
        a = true;
      }
    }
    
    for (int i = 0; i < N; i++) {
      if (d.at(i) == max) {
        d.at(i) = -1;
      }
    }
    
    if (a) layer++;
  }
  
  cout << layer << endl;
  
}

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

char s[3005],t[3005],lcs[3005];
int dp[3005][3005];
pair<int,int> last[3005][3005];

int main() {
	scanf("%s%s",s+1,t+1);
	s[0] = t[0] = ' ';
	int ls = strlen(s)-1,lt = strlen(t)-1;
	for (int i=0; i<=ls; i++) {
		for (int j=0; j<=lt; j++) {
			if (i == 0 || j == 0) { dp[i][j] = 0; continue; }
			dp[i][j] = dp[i][j-1]; last[i][j] = {i,j-1};
			if (dp[i-1][j] > dp[i][j]) {
				dp[i][j] = dp[i-1][j]; last[i][j] = {i-1,j};
			}
			if (s[i] == t[j] && dp[i-1][j-1]+1 > dp[i][j]) {
				dp[i][j] = dp[i-1][j-1]+1; last[i][j] = {i-1,j-1};
			}
		}
	}
	int at = 0;
	pair<int,int> t(ls,lt);
	while (t.first > 0 && t.second > 0) {
		if (last[t.first][t.second] == make_pair(t.first-1,t.second-1)) {
			lcs[at++] = s[t.first];
		}
		t = last[t.first][t.second];
	}
	//printf("%d\n",dp[ls][lt]);
	for (int i=0; i<at; i++) {
		printf("%c",lcs[at-i-1]);
	}
	return 0;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
    int n,k;
    string s;
    cin>>n>>s>>k;
    rep(i,0,n){
        if(s[i]!=s[k-1])cout<<"*";
        else cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3640
import math
# from sympy import sieve
N=int(input())

num = math.factorial(N)
primeNum=[]

for i in range(2,1000):
  flag=False  
  for j in range(2,i):
    if i%j==0:
      flag=True
      break
  if flag==False:
    primeNum.append(i)
    

# primeNum = [i for i in sieve.primerange(1,1000)]
# print(primeNum)
resulNum=[0]*len(primeNum)
result=1

j=0
flag=False
for i in primeNum:
  while num % i == 0 :
    num = num // i
    resulNum[j]+=1
    flag=True
  
  if flag==True:
    result*=(resulNum[j]+1)
    result %= 10**9+7
  j+=1
  flag=False

print(result)



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

int main()
{
  string s;
  int c = 0;
  cin >> s;
  if (s[0] == '1')
    c++;
  if (s[1] == '1')
    c++;
  if (s[2] == '1')
    c++;

  cout << c << endl;
}


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

int main()
{
    long long N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<long long> A(N);
    for (long long &a : A)
    {
        cin >> a;
    }
    sort(A.rbegin(), A.rend());

    V -= P - 1;
    long long total = M * V;
    long long target = A[P - 1];

    vector<long long> diff;
    diff.push_back(0);
    for (int i = P; i < N; i++)
    {
        diff.push_back(min(M, target - A[i]));
    }
    for (long long d : diff)
    {
        total -= d;
    }
    diff.push_back(1e12);

    long long ans = P;
    if (total <= 0)
    {
        for (int i = P; i < N; i++)
        {
            if (A[i] + M >= target)
            {
                ans++;
            }
        }
    }
    else
    {
        set<long long> dset;
        for (long long d : diff)
        {
            if (d < M)
            {
                dset.insert(d);
            }
        }
        long long prev = M;
        for (auto itr = dset.rbegin(); itr != dset.rend(); itr++)
        {
            long long m = *itr;
            long long l = 0;
            long long r = diff.size() - 1;
            while (r - l > 1)
            {
                long long c = (l + r) / 2;
                if (diff[c] > m)
                {
                    r = c;
                }
                else
                {
                    l = c;
                }
            }
            assert(prev > m);
            total -= (l + 1) * (prev - m);
            if (total <= 0)
            {
                ans += l;
                break;
            }
            prev = m;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const int inf = 1<<29;

int H, W;
vector<vector<int>> cost(220, vector<int>(220, inf));

void floyd(){
    for(int k=0; k<10; k++){
        for(int i=0; i<10; i++){
            if(cost[i][k] == inf) continue;
            for(int j=0; j<10; j++){
                if(cost[k][j] == inf) continue;

                cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]);
            }
        }
    }
}

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

    for(int i=0; i<10; i++) for(int j=0; j<10; j++) cin >> cost[i][j];
    
    map<int, int> mp;
    for(int i=0; i<H; i++) for(int j=0; j<W; j++){
        int c; cin >> c;
        mp[c]++;
    }

    floyd();

    ll ans = 0;
    for(int i=0; i<10; i++){
        ans += mp[i]*cost[i][1];
    }

    cout << ans << endl;

}

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

int main(){
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int>vecx(n);
  vector<int>vecy(m);
  for (int i = 0; i < n; i++){
    cin  >> vecx.at(i);
  }
  for (int j = 0; j < m; j++){
    cin >> vecy.at(j);
  }
  sort(vecx.begin(),vecx.end());
  sort(vecy.begin(),vecy.end());
  int a = max(vecx.at(n-1),x);
  int b = min(vecy.at(0),y);
  if (b <= a)
    cout << "War" << endl;
  else{
    cout << "No War" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// ==================================================
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,a,b) for(i64 i=(int64_t)(a);i<(int64_t)(b);i++)
#define repn(i,n) rep(i,0,n)
#define din(t, ...) t __VA_ARGS__;_din(__VA_ARGS__)
#define v(t,n) vector<t> n
void _din() {}
void dout() { cout << endl; }
template <typename T, typename ... Args> inline void _din(T& head, Args& ... rest) { cin >> head; _din(rest...); }
template <typename T, typename ... Args> inline void dout(T head, Args ... rest) { cout << head; if (sizeof...(rest)) cout << ' '; dout(rest...); }
template <typename T>inline void qsortv(vector<T>& v) { qsort(v.data(), v.size(), sizeof(T), [](const void*a, const void*b)->int {if ((*(T*)a) < (*(T*)b))return -1; if ((*(T*)a) == (*(T*)b))return 0; return 1; }); }
template <typename T, typename F>inline void qsortv(vector<T>& v, F func) { qsort(v.data(), v.size(), sizeof(T), func); }
template <typename T>inline void sortv(vector<T>& v) { sort(v.begin(), v.end()); }
// ==================================================

int main()
{
	din(int, a, b);

	dout(a*b - (a + b - 1));
}

Measured memory_bytes: 256
n=int(input())
ans=[0]*120001
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            ans[(x+y)**2+(y+z)**2+(z+x)**2]+=1
for i in range(1,n+1):
  print(ans[2*i])

Measured memory_bytes: 10028
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,I##_N=N;I<I##_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
int main() {
  R(N)R(M);
  RV(H,N);
  std::vector<int> yoi(N,1);
  F(J,M){
    R(A)R(B);
    A--;B--;
    if(!(H[A]>H[B]))yoi[A]=0;
    if(!(H[B]>H[A]))yoi[B]=0;
  }
  int c=0;
  F(I,N)if(yoi[I])c++;
  P(c);
  return 0;
}


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

void swap( int* a, int* b ){
    int temp = *a;
    *a = *b;
    *b = temp;
}

void quick_sort( int value[], int left, int right ){
    int i;
    int pivot;
    int Left = left, Right = right;
    pivot = value[ ( left + right ) / 2 ];

    while( 1 ){
        while( pivot > value[ Left ] ){
            Left++;
        }

        while( value[ Right ] > pivot ){
            Right--;
        }

        if( Left >= Right ){
            break;
        }
        swap( &value[Left], &value[Right] );
        Left++;
        Right--;
    }
    if( left < Left - 1 ){
        quick_sort( value, left, Left-1 );
    }

    if( right > Right + 1 ){
        quick_sort( value, Right + 1 , right );
    }
}

int main(void){
    char *result = "YES";
    int n = 0;
    int i, j;
    int value[210000];

    //
    scanf( "%d", &n );
    for( i = 0; i < n ; i++ ){
        scanf( "%d", &value[i] );
    }
    //
    quick_sort( value, 0, n-1 );

    for( i = 0 ; i < n - 1 ; i++ ){
        if( value[ i ] == value[ i + 1 ] ){
            result = "NO";
        }
    }

    printf( "%s", result );

    return 0;
}

Measured memory_bytes: 896
# Template 1.0
import sys, re
from decimal import *
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, floor, trunc, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

x = INT()

if(x>=400 and x<=599):
    print(8)
elif(x>=600 and x<=799):
    print(7)
elif(x>=800 and x<=999):
    print(6)
elif(x>=1000 and x<=1199):
    print(5)
elif(x>=1200 and x<=1399):
    print(4)
elif(x>=1400 and x<=1599):
    print(3)
elif(x>=1600 and x<=1799):
    print(2)
else:
    print(1)

Measured memory_bytes: 72504
#include <iostream>
#include <stack>
#include <sstream>

using namespace std;

int main() {
  string line;
  getline(cin, line);
  
  stack<int> stack;

  stringstream ss(line);
  string word;
  while (ss >> word) {
    if (word == "+") {
      int v1 = stack.top();
      stack.pop();
      int v2 = stack.top();
      stack.pop();

      stack.push(v2 + v1);
    } else if (word == "-") {
      int v1 = stack.top();
      stack.pop();
      int v2 = stack.top();
      stack.pop();

      stack.push(v2 - v1);
    } else if (word == "*") {
      int v1 = stack.top();
      stack.pop();
      int v2 = stack.top();
      stack.pop();

      stack.push(v2 * v1);
    } else {
      // operand
      int v = std::stoi(word);
      stack.push(v);
    }
  }
  
  int v = stack.top();
  cout << v << endl;

  return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

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

		long N = sc.nextLong();
		long K = sc.nextLong();

		long ans = 0;
		if (K%2 != 0) {
			long a = N/K;
			ans = a*a*a;
		} else {
			long a= N/K;
			long b = (N + K/2)/K;
			ans = a*a*a + b*b*b;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23636
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
char in[10];
int q[110];
int n;
int query(){
	printf("?");
	for(int i=0;i<n;i++){
		printf(" %d",q[i]+1);
	}
	printf("\n");
	fflush(stdout);
	scanf("%s",in);
	if(in[0]=='R')return 0;
	return 1;
}
int ret[210];
int res[210];
int f[2][110];
int col[210];
char ans[210];
int main(){
	int a;scanf("%d",&a);
	n=a;
	int left=0;
	int right=a;
	for(int i=0;i<=a;i++)res[i]=-1;
	while(left+1<right){
		int M=(left+right)/2;
		int L=res[left];
		int S=res[M];
		int R=res[right];
		if(L==-1){
			for(int i=0;i<a;i++)q[i]=left+i;
			L=query();
			res[left]=L;
		}
		if(R==-1){
			for(int i=0;i<a;i++)q[i]=right+i;
			R=query();
			res[right]=R;
		}
		if(S==-1){
			for(int i=0;i<a;i++)q[i]=M+i;
			S=query();
			res[M]=S;
		}
		if(L==S){
			left=M;
		}else right=M;
	}
	for(int i=0;i<a*2;i++)col[i]=-1;
	col[left]=col[left+a]=-2;
	for(int i=0;i<a-1;i++){
		f[0][i]=right+i;
		col[right+i]=0;
	}
	int ind=0;
	for(int i=0;i<a*2;i++){
		if(col[i]==-1){
			f[1][ind++]=i;
		}
	}

	for(int i=0;i<2*a;i++){
		if(col[i]==0){
			for(int j=0;j<a-1;j++)q[j]=f[1][j];
		}else{
			for(int j=0;j<a-1;j++)q[j]=f[0][j];
		}
		q[a-1]=i;
		if(query()==0)ans[i]='R';
		else ans[i]='B';
	}
	printf("! %s\n",ans);

}


Measured memory_bytes: 628
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if (n == m) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <queue>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAX_N = 1e3 + 1;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int w, h, n;
int X1[MAX_N], X2[MAX_N], Y1[MAX_N], Y2[MAX_N];

// 塗る領域
bool fld[MAX_N * 6][MAX_N * 6];

int compress(int *x1, int *x2, int w)
{
    vector<int> xs;

    for (int i = 0; i < n; i++) {
        for (int d = -1; d <= 1; d++) {
            int tx1 = x1[i] + d;
            int tx2 = x2[i] + d;

            if (0 <= tx1 && tx1 <= w)
                xs.push_back(tx1);
            if (0 <= tx2 && tx2 <= w)
                xs.push_back(tx2);
        }
    }

    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());

    for (int i = 0; i < n; i++) {
        x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
        x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
    }
    
    return xs.size();
}

void solve()
{
    // 座標圧縮
    w = compress(X1, X2, w);
    h = compress(Y1, Y2, h);

    // マスキングテープの領域を塗りつぶす
    memset(fld, 0, sizeof(fld));
    for (int i = 0; i < n; i++) 
        for (int y = Y1[i]; y <= Y2[i]; y++)
            for (int x = X1[i]; x <= X2[i]; x++)
                fld[y][x] = true;

    int ans = 0;
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            if (fld[y][x])
                continue;
            ans++;
            
            queue<pair<int, int> > que;
            que.push(make_pair(x, y));
            while (!que.empty()) {
                int sx = que.front().first;
                int sy = que.front().second;
                que.pop();
                
                for (int i = 0; i < 4; i++) {
                    int tx = sx + dx[i];
                    int ty = sy + dy[i];

                    if (tx < 0 || tx >= w || ty < 0 || ty >= h)
                        continue;
                    if (fld[ty][tx])
                        continue;

                    que.push(make_pair(tx, ty));
                    fld[ty][tx] = true;
                }
            }
        }
    }
    cout << ans << endl;
}

int main()
{
    while (cin >> w >> h, w || h) {
        cin >> n;
        w *= 2;
        h *= 2;
        for (int i = 0; i < n; i++) {
            cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
            X1[i] *= 2;
            Y1[i] *= 2;
            X2[i] *= 2;
            Y2[i] *= 2;
        }

        solve();
    }

    return 0;
}

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

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

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

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	var hundredsPlace int
	hundredsPlace = n / 100
	desiredCnt := 100*hundredsPlace + 10*hundredsPlace + hundredsPlace

	if n <= desiredCnt {
		fmt.Println(desiredCnt)
	} else {
		fmt.Println(desiredCnt + 111)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

string str;
ll ans = 0;
ll cnt = 0;

int main() {
    cin >> str;
    for (int i = str.size()-1; i >= 0; i--) {
        if (str[i] == 'B') {
            ans += cnt;
        } else {
            cnt++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
#include <vector>

#define SPACE string(" ")
using namespace std;

int main(void) {
	int r, c;
	cin >> r >> c;

	cin >> ws;

	string str;
	vector<string> v;
	int *psum = new int[c + 1]();

	for (int i = 0; i < r; i++) {
		getline(cin, str);

		string::size_type spos = 0;
		string::size_type epos = 0;
		int wsum = 0, j = 0, n;
		while ((epos = str.find(SPACE, spos)) != string::npos) {
			n = atoi(str.substr(spos, epos - spos).c_str());
			spos = epos + SPACE.length();
			wsum += n;
			psum[j++] += n;
		}
		n = atoi(str.substr(spos).c_str());
		wsum += n;
		psum[j++] += n;

		psum[j] += wsum;

		stringstream ss;
		ss << str << " " << wsum;
		v.push_back(ss.str());
	}

	stringstream sss;
	for (int k = 0; k < c; k++) {
		sss << psum[k] << " " ;
	}
	sss << psum[c];
	v.push_back(sss.str());

	for (int l = 0; l < v.size(); l++) {
		cout << v[l] << endl;
	}

	delete[] psum;

	return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
int main()
{
    fio;
    int n;
    cin>>n;
    int p = log2(n);
    cout<<pow(2,p)<<endl;
    return 0;
}



Measured memory_bytes: 4120
#include <bits/stdc++.h>
#define MAXN 1000010
#define inf 0x3f3f3f3f
#define LL long long
#define pi acos(-1)
#define MOD 1000000007
using namespace std;



int main()
{
	int n,x,ans=0,tmp=0;
	cin >> n;
	for (int i = 1; i <= n ; i++) {
		cin>>x;
		if (x>=tmp) ans++,tmp=x;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
from numba import njit
i4 = np.int32
i8 = np.int64
u4 = np.uint32


@njit
def get_factorization(n):
    """
    nまでの割り切れる最小の素数を返す。
    """
    sieve_size = (n - 1) // 2
    sieve = np.zeros(sieve_size, u4)
    for i in range(sieve_size):
        if sieve[i] == 0:
            value_at_i = i*2 + 3
            for j in range(i, sieve_size, value_at_i):
                if sieve[j] == 0:
                    sieve[j] = value_at_i
    return sieve


@njit('(u4[::-1],)', cache=True)
def solve(A):
    a = np.sort(A)
    p_max = a[-1]
    p = get_factorization(p_max)
    primes_num = 1
    for i in range(p.shape[0]):
        if i*2 + 3 == p[i]:
            primes_num += 1
    a_start = 0
    while a[a_start] == 1:
        a_start += 1
        if a_start == a.shape[0]:
            return 0
    a = a[a_start:]
    if len(a) > primes_num:
        return 1
    check = np.zeros(p_max + 1, u4)
    for d in a:
        if d & 1 == 0:
            check[2] += 1
            d //= 2
            while d & 1 == 0:
                d //= 2
        prev = 2
        while d > 1:
            i = (d - 3) // 2
            f = p[i]
            if f > prev:
                check[f] += 1
                prev = f
            d //= f

    if check.max() > 1:
        return 1
    else:
        return 0


def main(in_file):
    stdin = open(in_file)
    stdin.readline()
    A = np.fromstring(stdin.readline(), u4, sep=' ')
    ans = solve(A)
    if ans:
        g = np.gcd.reduce(A)
        if g > 1:
            ans = 2
        else:
            ans = 1
    p = ['pairwise coprime', 'setwise coprime', 'not coprime']
    print(p[ans])


if __name__ == '__main__':
    main('/dev/stdin')


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

typedef long long ll;
ll tr[4100000];
struct rp {
    int x, y;
    ll z;
} a[110000];
vector<int> v[110000];
int n, m, all;

void getnew(int root) {
    root /= 2;
    while (root) {
        tr[root] = min(tr[root * 2], tr[root * 2 + 1]);
        root /= 2;
    }
}

ll getmin(int l, int r) {
    ll ans = 1e15;
    while (r - l > 1) {
        if (l % 2 == 0)
            ans = min(ans, tr[l + 1]);
        if (r % 2 == 1)
            ans = min(ans, tr[r - 1]);
        l >>= 1, r >>= 1;
    }
    return ans;
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++)
        scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z);
    for (int i = 1; i <= m; i++) {
        v[a[i].y].push_back(i);
    }
    all = 1;
    while (all <= n)
        all <<= 1;
    all--;
    for (int i = 1; i <= all + all + 1; i++)
        tr[i] = 1e15;
    for (int i = 1; i <= m; i++) {
        if (a[i].x == 1) {
            tr[all + a[i].y] = a[i].z;
            getnew(all + a[i].y);
        }
    }
    for (int i = 1; i <= n; i++) {
        for (auto j:v[i]) {
            ll now = getmin(all + a[j].x - 1, all +a[j].y + 1) + a[j].z;
            if (now < tr[all + a[j].y]) {
                tr[all + a[j].y] = now;
                getnew(all + a[j].y);
            }
        }
    }
  //  printf("%lld..\n", tr[all + n]);
    if (tr[all + n] < 1e15) {
        printf("%lld\n", tr[all + n]);
    } else puts("-1");
    return 0;
}


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

#define INF 100100100
#define MOD 1000000007

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

using namespace std;
using ll = long long;
using ull = unsigned long long ;

struct edge{ll to,cost;};

int main(int argc, char const* argv[]){
   string n;
   cin >> n;
   FOR(i,n.size()){
      if(n[i] == '1')n[i] = '9';
      else if(n[i] == '9')n[i] = '1';
   }
   cout << n << endl;
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if (h == 0 || w == 0) {
				sc.close();
				break;
			}
			printRectangle(h, w);
		}
	}
	
	public static void printRectangle(int h, int w) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				sb.append('#');
			}
			sb.append("\n");
		}
		System.out.println(sb);
	}
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  int n; cin >> n;
  vector<int> x(n), y(n);
  REP(i, n) {
    cin >> x[i] >> y[i];
    int nx = x[i] - y[i];
    int ny = x[i] + y[i];
    x[i] = nx;
    y[i] = ny;
  }

  int mx = -INF, mix = INF;
  int may = -INF, miy = INF;
  REP(i, n) {
    chmax(mx, x[i]);
    chmax(may, y[i]);
    chmin(mix, x[i]);
    chmin(miy, y[i]);
  }

  cout << max(mx - mix, may - miy) << endl;


  return 0;
}








Measured memory_bytes: 4780
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

bool used[105];

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

    int n;
    cin >> n;
    vector<P> red(n), blue(n);
    for(int i = 0; i < n; ++i)  cin >> red[i].first >> red[i].second;
    for(int i = 0; i < n; ++i)  cin >> blue[i].first >> blue[i].second;
    sort(blue.begin(), blue.end());
    int ans = 0;
    for(int i = 0; i < n; ++i){
        int bx = blue[i].first, by = blue[i].second;
        P maxp = P(-1, -1);
        int id = -1;
        for(int j = 0; j < n; ++j){
            if(used[j]) continue;
            int rx = red[j].first, ry = red[j].second;
            if(rx >= bx || ry >= by)    continue;
            P point = P(ry, rx);
            if(point > maxp){
                maxp = point;
                id = j;
            }
        }
        if(id == -1)    continue;
        ++ans;
        used[id] = true;
        // cerr << "(" << bx << "," << by << "), (" << red[id].first << "," << red[id].second << ")\n";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    long k;
    cin >> s >> k;

    int n = s.size();

    for (int i=0; i<n; i++) {
        if (i+1 == k) {
            cout << s[i] << endl;
            return 0;
        }
        if (s[i] != '1') {
            cout << s[i] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n;
	cin>>n;
	cout<<n+n*n+n*n*n<<endl; 
	return 0;
}



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

int main() {
    int n;
    cin >> n;
    double ans = 0;
    while (n--) {
        int x;
        cin >> x;
        ans = ans + 1.0 / x;
    }
    ans = 1.0 / ans;
    printf("%.6lf", ans);
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.Exception
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val k = sc.nextInt()
    val x = sc.nextInt()
    val y = sc.nextInt()
    println(x * minOf(n, k) + y * maxOf(0, n - k))
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34264
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main () {
  ll x, a;
  cin >> x >> a;
  if (x<a) cout << 0 << endl;
  else cout << 10 << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int layout[110][110];
int main(void){
	int n,m;
	int c;
	scanf("%d%d%d",&n,&m,&c);
	int xx=1,yy=1,d=1;
	for (int i=1;i<=c;i++){
		int aa,cnt=0;
		scanf("%d",&aa);
		while(cnt<aa){
			if (yy==0){
				d=1;
				yy=1;
				xx++;
			}
			if (yy==m+1){
				d=-1;
				yy=m;
				xx++;
			}
			layout[xx][yy]=i;
			yy+=d;
			cnt++;
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			printf("%d ",layout[i][j]);
		}
		putchar(10);
	}
	return 0;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

def table(n:int, p=998244353):
    global fact, factinv, inv
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    for i in range(2, n+1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)

def cmb(n:int, r:int, p=998244353):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

N, M, K = mi()
#inf = 998244353
table(2*10**5 + 1)
ans = 0
for i in range(K+1):
    #print(i, ans)
    ans = (ans + cmb(N-1, i) * M * pow(M-1, N-i-1, 998244353)) %998244353

print(ans)

Measured memory_bytes: 32980
def resolve():
    L, R = list(map(int, input().split()))
    MOD = 2019
    if R - L >= 2019:
        print(0)
        return
    import itertools
    ans = float("inf")
    for i, j in itertools.combinations(list(range(L, R+1)), 2):
        ans = min(ans, i*j%MOD)
    print(ans)

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 9132
import java.util.*;
import java.io.BufferedInputStream;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner (new BufferedInputStream(System.in));
    int n = sc.nextInt();
    int m = sc.nextInt();
    int total = 0;
    PriorityQueue<Integer> st = new PriorityQueue<>();
    for(int i = 0; i < n; ++i) {
        int now = sc.nextInt();
        st.offer(0 - now);
        total += now;
    }
    boolean res = true;
    for(int i = 0; i < m; ++i) {
        int now = 0 - st.poll();
        if(now < (double) total / (4 * m)) res = false;
    }
    if(res) System.out.println("Yes");
    else System.out.println("No");
  }
}


Measured memory_bytes: 21844
import scala.io.StdIn

object Main{
  def main(args:Array[String]) {
    val input = StdIn.readLine()
    val x = input.toInt
    println(pow(x, 3))
  }
  def pow(x:Int, y:Int) = {
    val list = List.fill(y)(x)
    list.reduceLeft{(x1, x2)=>x1*x2}
  }
}

Measured memory_bytes: 43904
N, M = map(int, input().split())
dict = {}

for i in range(N):
    dict[str(i+1)] = 0
for i in range(M):
    ai, bi = input().split()
    dict[ai] += 1
    dict[bi] += 1

for i in range(N):
    print(dict[str(i+1)])


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

int main() {
	int n; cin >> n;
	vector<vector<int>> train;
	for (int i = 0; i < n; ++i) {
		int c, s, f; cin >> c >> s >> f;
		train.push_back({ c,s,f });
	}

	for (int i = 0; i < n; ++i) {
		int t = 0;
		for (int j = i; j < n - 1; ++j) {
			int c, s, f, k;
			c = train[j][0];
			s = train[j][1];
			f = train[j][2];
			// kはtより後で初めて電車が来る時間
			if (t % f == 0) k = (t / f) * f;
			else k = (t / f + 1) * f;
			t = max(s, k);
			//cout << t << " " << t + c << endl;
			t += c;
		}
		cout << t << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN   
#define linf LLONG_MAX
#define lninf LLONG_MIN   
const ll mod=1e9+7;
const int N=2e5+4;

int sz[N],par[N];

int find(int x)
{
	if(x==par[x])
	return x;

	return par[x]=find(par[x]);
}

void merge(int i,int j)
{
	int pi = find(i), pj = find(j);

	if(pi == pj)
	return;

	sz[pi]+=sz[pj]; par[pj]=pi;
}

int main()                  
{
	fill(sz,sz+N,1); iota(par,par+N,0);

	int n,m; scn(n); scn(m);

	rep(i,0,m)
	{
		int a,b; scn(a); scn(b);

		merge(a,b);
	}

	int ans=0;

	rep(i,1,n+1)
	ans=max(ans,sz[find(i)]);

	pri(ans);
	
    return 0;
}

Measured memory_bytes: 6240
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
#define MOD int(1e9 + 7)

long long mod_pow(long long _x, long long _n)
{
    long long ret = 1;
    while (0 < _n)
    {
        if ((_n % 2) == 0)
        {
            _x = (_x * _x) % MOD;
            _n >>= 1;
        }
        else
        {
            ret = (ret * _x) % MOD;
            --_n;
        }
    }
    return ret;
}

string S;
long long dfs(int i)
{
    if (i == S.size())
        return 1;

    long long t;
    if (S[i] == '1')
    {
        t = mod_pow(3, S.size() - i - 1);
        t = (t + (2 * dfs(i + 1)) % MOD) % MOD;
    }
    else
        t = dfs(i + 1);

    return t;
}

int main()
{
    cin >> S;
    cout << dfs(0) << endl;
}

Measured memory_bytes: 3584
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_056_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(20).
    01 W      PIC 9(6).
    01 a      PIC 9(6).
    01 b      PIC 9(6).
    01 ans    PIC X(6).

    01 tmp    PIC 9(6).

    01 ZS     PIC Z(6)9.
    01 DUMMY  PIC X(1).

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO W a b.

    IF b < a THEN
        MOVE b TO tmp
        MOVE a TO b
        MOVE tmp TO a
    END-IF.

    ADD W TO a.

    IF b < a THEN
        DISPLAY ZERO
    ELSE
        SUBTRACT a FROM b
        MOVE b TO ZS
        PERFORM UNANS
        DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans))
    END-IF.

    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 764