akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();
    
    ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    b -= a;
    a = 0;
    if (b < 0)b = -b;

    bool ok = false;
    for (ll i = 1; i <= n; ++i) {
        ll Max = d * (i - 1) - c * (n - i);
        ll Min = c * (i - 1) - d * (n - i);
        ok |= (Min <= b && b <= Max);
    }

    cout << (ok ? "YES\n" : "NO\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool isP(int n){
if(n>2&&n%2==0){ return false; }
for(int i=3; i*i<=n; i+=2){ if(n%i==0){ return false; } }
return true;  
}

int main(){
int N, i; cin >> N; vector<int> P;
for(i=11; i<55555; i+=5){ if(isP(i)){ P.push_back(i); } }
for(i=0; i<N; i++){ cout << P[i] << " "; }
cout << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int s;
    cin >> s;
    i64 tmp = s;
    unordered_set<i64> a_set;
    a_set.insert(tmp);
    rep(i,1000001)
    {
        if(tmp%2 == 0) tmp = tmp/2;
        else tmp = 3*tmp + 1;

        if(a_set.find(tmp) != a_set.end())
        {
            cout << i + 2 << endl;
            break;
        }
        a_set.insert(tmp);
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
const lint INF = 1001001001001001LL;
const lint MOD = 1000000007LL;
int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

void yes(){ cout << "yes" << endl; }
void Yes(){ cout << "Yes" << endl; }
void YES(){ cout << "YES" << endl; }
void no(){ cout << "no" << endl; }
void No(){ cout << "No" << endl; }
void NO(){ cout << "NO" << endl; }
void possible(){ cout << "possible" << endl; }
void Possible(){ cout << "Possible" << endl; }
void POSSIBLE(){ cout << "POSSIBLE" << endl; }
void impossible(){ cout << "impossible" << endl; }
void Impossible(){ cout << "Impossible" << endl; }
void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(int i = s; i < t; i++)
#define all(a) a.begin(),a.end()

int main(){
  
  lint h, w, n; cin >> h >> w >> n;
  vector<lint> x(n);
  vector<lint> y(n);
  rep(i, n) cin >> x[i] >> y[i];
  set<pair<lint, lint>> allPointSets;
  vector<set<lint>> xPointSets(h + 1);
  rep(i, n){ 
    allPointSets.insert({x[i], y[i]});
    xPointSets[x[i]].insert(y[i]);
  }

  lint maxHeight = 1;
  srep(i, 1, h){
    //cerr << "(" << i << ", " << maxHeight << ")" << endl;
    
    // i + 1 に maxHeight 以下にあれば終わりや
    for(auto val : xPointSets[i + 1]){
      if(val <= maxHeight){
        cout << i << endl;
        return 0;
      } 
    }

    // (i + 1, maxHeight + 1) に存在しなければ
    if(allPointSets.find({i + 1, maxHeight + 1}) == allPointSets.end()){
      maxHeight++;
    }
  }

  cout << h << endl;
  
  return 0;
}


Measured memory_bytes: 34688
#include "bits/stdc++.h"

typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

int t[100010] = {0};
int x[100010] = {0};
int y[100010] = {0};

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

    for(int i = 1;i <= n;i++){
        cin >> t[i] >> x[i] >> y[i];
        if(abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]) <= t[i] - t[i-1]
        && (abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]) - (t[i] - t[i-1]))%2 == 0){
        
        }else{
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";

    

    return 0;
}


Measured memory_bytes: 1408
function Main(input) {
    input = input.split(" ");
    A = Number(input[0]);
    B = Number(input[1]);
    K = Number(input[2]);
    P = [];
    for(i = 1; i <= Math.min(A,B); i++){
        if(A % i === 0 && B % i === 0) P.unshift(i);
    }
    console.log(P[K-1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> PII;
int a,b;
ll res;
int main()
{	
	cin>>a>>b;
	res=a+b;
	if(res%2){
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	cout<<res/2<<endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
x1, y1, x2, y2 = map(int, input().split())
if x1 == x2:
    print(x2 - (y2 - y1), y2, x2 - (y2 - y1), y1)
else:
    print(x2 - (y2 - y1), y2 + (x2 - x1), x2 - (y2 - y1) - (x2 - x1), y2 + (x2 - x1) - (y2 - y1))

Measured memory_bytes: 3060
_temp = []

size = int(input().rstrip())
for i in range(size):
    try:
        _temp.append(int(input()))
    except EOFError:
        continue

my_max = -20000000000000
my_min = _temp.pop(0)


for val in _temp:
    my_max = max(my_max, (val - my_min))
    my_min = min(my_min, val)

print(my_max)

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < int(n); ++ i)

const int all = 200000, thr = 100000;

int tot = 2; int nd() { return ++ tot; }

int Z, O;

int cnt;
stringstream ss;

void qadd(int i, int j, int k) { ++ cnt; ss << "+ " << i << " " << j << " " << k << endl; }
void qless(int i, int j, int k) { ++ cnt; ss << "< " << i << " " << j << " " << k << endl; }
void qgreater(int i, int j, int k) { qless(j, i, k); }
void qnot(int k) { qless(k, O, k); }
void qleq(int i, int j, int k) { qless(j, i, k); qnot(k); }
void qgeq(int i, int j, int k) { qgreater(j, i, k); qnot(k); }

int mul_1bit(int i, int j) {
	int k = nd();
	qadd(i, j, k);
	qgreater(k, O, k);
	return k;
}

void init() {
	Z = nd();
	O = nd(); qless(Z, 0, O);
}

int get_2k(int x, int k) {
	int y = nd();
	qadd(x, y, y);
	rep(i, k) qadd(y, y, y);
	return y;
}

vector <int> get_bin(int x) {
	vector <int> v;
	int s = nd();
	for (int i = 30 - 1; ~i; -- i) {
		int ns = nd();
		qadd(get_2k(O, i), s, ns);
		int k = nd();
		qleq(ns, x, k);
		qadd(get_2k(k, i), s, s);
		v.pb(k);
	}
	reverse(v.begin(), v.end());
	return v;
}

int main() {
	#ifdef DEBUG
	freopen("out", "w", stdout);
	#endif
	
	init();
	vector <int> v0 = get_bin(0);
	vector <int> v1 = get_bin(1);
	
	rep(i, v0.size()) rep(j, v1.size()) {
		int k = mul_1bit(v0[i], v1[j]);
		int s = get_2k(k, i + j);
		qadd(s, 2, 2);
	}
	
	cout << cnt << endl << ss.str() << endl;
	
	return 0;
}

Measured memory_bytes: 4260
from itertools import permutations



# INPUT
n = int(input())

A = tuple(input().split())


# PROCESS, OUTPUT
str_num = ""

for num in range(1, n + 1):
    str_num += str(num)


flag_break = False
list_num_previous = None

for list_num in permutations(str_num):
    if flag_break:
        # next
        print(*list_num)
        break

    if list_num == A:
        if list_num_previous != None:
            # previous
            print(*list_num_previous)

        # now
        print(*list_num)
        flag_break = True

    list_num_previous = list_num



Measured memory_bytes: 5636
#include <stdio.h>
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main()
{
	string text;
	int n;
	int replacing = 0;
	int ascii[26] = {0};
	int min_ascii = 0;

	cin >> text >> n;
	int length = text.length();

	for (int i = 0; i < length; i++)
	{
		ascii[text[i] - 97] ++;
	}

	//cout << (int)'a' << endl;

	for (int i = 0; i < n; i++)
	{
		if (replacing + 1 >= text.length() ) break;

		if (ascii[min_ascii] == 0)
		{
			min_ascii += 1;
		}
	
		int replace_no;
		char replace_char = 0;
		int end = n - i + replacing + 1;
		int length = text.length();
		
		for (int j = replacing; j < (length < end ? length : end); j++)
		{
			//cout << text[j] << ", ";
			if (replace_char > text[j] || replace_char == 0)
			{
				replace_char = text[j];
				replace_no = j;
				if(replace_char - 97 == min_ascii)
					break;
			}
		}
		//cout << endl;
		ascii[replace_char - 97] --;
		
		if (replace_char && text[replacing] > replace_char)
		{
			//cout << endl << replace_no << " " << replace_char << " " << endl;

			int difference = replace_no - replacing;
			/*for (int j = 0; j < loop_max; j++)
			{
				char replaced_char = text[replace_no - 1];
				text[replace_no] = replaced_char;
				text[replace_no - 1] = replace_char;
				replace_no --;
				i ++;
				cout << text << endl;
			}*/

			string original_text = text;
			text[replacing] = replace_char;

			for (int j = 1; j < difference + 1; j++)
			{
				text[replacing + j] = original_text[replacing - 1 + j];
			}

			i += difference - 1;
			replacing ++;

			//cout << text << " " << replacing <<  " " << i << endl;
		}
		else
		{
			//cout << "!skip" << endl;
			replacing ++;
			i --;
			continue;
		}

		//cout << endl;
	}

	cout << text << endl;
}


Measured memory_bytes: 3480
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		for(int i = 0; i < s.length(); i+=2) {
			System.out.print(s.substring(i, i + 1));
		}
		scan.close();
	}

}


Measured memory_bytes: 29188
#include <iostream>
#include <vector>

int main() {
    int n = 0; std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    std::sort(a.begin(), a.end(), [](const auto& a, const auto& b) {return a > b;});

    int s = 0; int x = 1;
    for (const auto aa: a) {
        s += aa * x;
        x *= -1;
    }

    std::cout << s << std::endl;
    return 0;
}

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

int main(){

    int n;
    cin>>n;
    set<char> c;

    for(int i=0;i<n;i++){
        char s;
        cin>>s;
        c.insert(s);
    }
    cout<<(c.size()==3?"Three":"Four")<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll H;
	cin >> H;
	ll tmp=2;
	while(tmp<=H){
		tmp*=2;
	}
	cout << tmp-1;
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        n:usize,
        mut s:chars,
    }

    s.dedup();
    println!("{}",s.len());
}


fn is_prime(x:i64) -> bool {
    if x == 2 {return true;}
    if x < 2 || x % 2 == 0 {return false;}
    let mut j = 3;
    while j <= (x as f64).sqrt() as i64 {
        if x % j == 0 {
            return false;
        }
        j += 2;
    }
    true
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

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

int main() {
  int a, b; cin >> a >> b;
  if (b % a == 0) cout << a + b << endl;
  else cout << b - a << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

l_num, r_num = 0, 0
for i in s:
    if i == '(':
        l_num += 1
    elif l_num <= 0:
        r_num += 1
    else:
        l_num -= 1
print('(' * r_num + s + ')' * l_num)


Measured memory_bytes: 2940
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		int[] arr = new int[n];
		int num = 0;
		for(int i = 0;i<n;i++) {
			arr[i]=l+i;
			num+= arr[i];
		}
		int temp = arr[0];
		//System.out.println(temp);
		int close = temp;
		Arrays.sort(arr);
		for(int i = 1;i<n;i++) {
			if(temp<0&&arr[i]>temp) {
				temp = arr[i];
				close = temp;
			}else if(arr[i]==0) {
				close = 0;
				break;
			}else if(temp>0&&arr[i]>temp) {
				close = temp;
				break;
			}
		}
		System.out.println(num-close);

	}

}


Measured memory_bytes: 22740
#include <vector>
#include <iostream>

#define int long long

using namespace std;

const int N = 1e7;

int lp[N + 1];
vector<int> pr;

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
    int n;
    cin >> n;
    for (int i = 2; i <= N; ++i) 
    {
        if (lp[i] == 0) 
        {
            lp[i] = i;
            pr.push_back(i);
        }
        for (int j = 0; j < pr.size() && pr[j] <= lp[i] && i * pr[j] <= N; ++j)
        {
            lp[i * pr[j]] = pr[j];
        }
    }
    int ans = 1;
    for (int i = 2; i <= n; ++i)
    {
        int z = i;
        int x = lp[i];
        int res = 1;
        while (z > 1)
        {
            int cur = 0;
            while (z % x == 0)
            {
                ++cur;
                z /= x;
            }
            res *= cur + 1;
            x = lp[z];
        }
        ans += i * res;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 89748
#include<stdio.h>
int main()
{
    int A,B,c;
    while(scanf("%d %d",&A,&B)!=EOF)
    {
        if(A==B)
            printf("Draw\n");
        else if(A==1)
            printf("Alice\n");
        else if(B==1)
            printf("Bob\n");
        else if(B>A)
            printf("Bob\n");
        else
            printf("Alice\n");
    }
    return 0;
}


Measured memory_bytes: 128
h,w=map(int,input().split())
inf=10**3
T=[[] for _ in range(h+2)]
T[0]=["#" for _ in range(w+2)]
T[h+1]=["#" for _ in range(w+2)]
for i in range(h):
  T[i+1]=["#"]+[inf if _!="#" else "#" for _ in input()]+["#"]
count=0
for t in T:
  count+=t.count("#")
count-=(2*(h+2)+2*w)
T[1][1]=0
Chk=[[1,1]]
while len(Chk)>0:
  c=Chk.pop(0)
  x,y=c[0],c[1]
  if T[x-1][y]!="#" and T[x-1][y]>T[x][y]+1:
    T[x-1][y]=T[x][y]+1
    Chk.append([x-1,y])
  if T[x][y-1]!="#" and T[x][y-1]>T[x][y]+1:
    T[x][y-1]=T[x][y]+1
    Chk.append([x,y-1])
  if T[x+1][y]!="#" and T[x+1][y]>T[x][y]+1:
    T[x+1][y]=T[x][y]+1
    Chk.append([x+1,y])
  if T[x][y+1]!="#" and T[x][y+1]>T[x][y]+1:
    T[x][y+1]=T[x][y]+1
    Chk.append([x,y+1])
print(-1 if T[h][w]==10**3 else h*w-count-T[h][w]-1)

Measured memory_bytes: 3192
#include<stdio.h>
#include<string.h>
int main(void)
{
	int n,a;
	char s[1000];
	scanf("%d", &n);
	if (n % 2 == 1)printf("No");
	if (n % 2 == 0)
	{
		for (int i = 0; i < n; i++)
		{
			scanf("%s", &s);
		}
		for (int i = 0; i < n / 2; i++)
		{
			if (s[i] == s[i + n / 2])a++;
		}
		if (a == n / 2)
		{
			printf("Yes");
		}else
		{
			printf("No");
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define INF 0x3f3f3f3f
int a[15];
char str[10];
int flag[20];
//int fflag[20];
int main()
{
  int k;
  scanf("%s%d",str,&k);
  memset(flag,0,sizeof(flag));
  for(int i=0;i<k;i++)
  {
    scanf("%d",&a[i]);
    flag[a[i]]=1;
  }
  int len=strlen(str);
  int fflag=0;int ans,ssum,pos=0,tt;
  for(int i=0;i<len;i++)
  {
    ssum=0;
    for(int j=0;j<=9;j++)
    {
      if((j>(str[i]-'0'))&&flag[j]==0)
      {
        printf("%d",j);
        fflag=1;
        ans=i;
        ssum=1;
        break;
      }
      else if((j==(str[i]-'0'))&&flag[j]==0)
      {
        printf("%d",j);
        ssum=1;
        break;
      }
    }
    if(ssum==0) {pos=1;tt=i;break;}
    //printf("####%d\n",ssum);
    if(fflag) break;
  }
  int cnt=0;
  for(int i=0;i<=9;i++)
  {
    if(flag[i]==0)
    {
      cnt=i;break;
    }
  }
  if(fflag)
  {for(int i=ans+1;i<len;i++)
    printf("%d",cnt);}
  if(pos)
  {
    //printf("%d\n",tt);
    for(int i=tt;i<len+1;i++)
    printf("%d",cnt);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
 
const int N = 3e5 + 7;
const int mod = 1e7;
 
int dp[N], h[N];
 
int32_t main() {
    FIO
    int n, k;
    cin >> n >> k;
    for ( int i = 1; i <= n; i++ ) {
        cin >> h[i];
        dp[i] = 1e12;
    }
    dp[1] = 0;
    for ( int i = 1; i <= n; i++ ) {
        for ( int j = 1; j <= k; j++ ) {
            dp[i + j] = min( dp[i + j], dp[i] + abs( h[i] - h[i + j] ) );
        }
    }
    cout << dp[n];

    return 0 ; 
}

Measured memory_bytes: 5192
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <algorithm>

using namespace std;
#define n_max 1000

int main()
{
    int N, x;
    int cnt = 0;
    int cnt_dif = 0;
    char tmp = '\0';
    char S[5];

    cin >> S;

    for(int i = 1; i < 4; i++){
        if(S[0] == S[i]) {
            cnt++;
        } else {
            if(tmp != S[i]) { cnt_dif++; }
            tmp = S[i]; 
        }
    }
    //cout << cnt << endl;
    //cout << cnt_dif << endl;

    if((cnt == 1) && (cnt_dif == 1)) {
        puts("Yes");
    } else {
        puts("No");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp> 
using namespace boost::multiprecision; 
using namespace std;
# define MAX 1000000000000000000
int main() {
	// your code goes here
	int n;
	cin>>n;
	 long long int arr[n];
	 int1024_t product=1;
	for( int i=0;i<n;i++)
	{
	    cin>>arr[i];
	    
	}
	sort(arr,arr+n);
	for(int i=0;i<n;i++)
	{
	    product=product*(int1024_t)arr[i];
	    //cout<<"p: "<<product<<endl;
	    if(product>MAX)
	    {
	        //cout<<"-1"<<endl;
	        break;
	    }
	   // cout<<"p: "<<product<<endl;
	}
	if(product<=MAX)
	{
	    cout<<product<<endl;
	}
	else
	{
	    cout<<"-1"<<endl;
	}
	    
	    
	
	return 0;
}


Measured memory_bytes: 4468
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (int i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<int, int>  ii;
typedef pair<double, double>  iidb;
#define iii pair<ii, nodo*>
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
#define initseg ll new_nodo=(pnodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 300000
#define offset 3000
#define ptr nodo*


using namespace std;
int v[tam];
int main()
{	
	int n;
	cin>>n;
	forr(i,0,n)
	{
		cin>>v[i];
	}	
	sort(v,v+n);
	ll area=1;
	for(int i=n-1;i>0;i--)
	{
		if (v[i]==v[i-1]){
			if (area!=1)
			{
				cout<<area*v[i]<<endl;
				return 0;
			}
			area*=v[i];
			i--;
		}
	}
	cout<<0<<endl;
}

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

int main(void){
    ll n, k;
    cin >> n >> k;

    string s;
    cin >> s;

    vector<ll> count;
    ll tmp = 0;

    if(s[0] == '0'){
        count.push_back(0);
    }
    rep(i, n){
        if(i == 0){
            tmp = 1;
        }else if(s[i] == s[i-1]){
            tmp += 1;
        }else{
            count.push_back(tmp);
            tmp = 1;
        }
    }
    count.push_back(tmp);
    if(s[s.size()-1] == '0'){
        count.push_back(0);
    }

    rep(i, count.size()){
        if(i != 0){
            count[i] += count[i-1];
        }
    }

    ll ma = 0;
    for(int i = k * 2; i < count.size(); i += 2){
        ll res = count[i];
        if(i - k * 2 - 1 >= 0){
            res = count[i] - count[i - k * 2 - 1];
        }
        ma = max(ma, res);
    }

    if(k * 2 >= count.size()){
        cout << s.size() << endl;
    }else{
        cout << ma << endl;
    }
    return 0;


}


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

int main(void)
{
  int S;
  cin >> S;
  int a,b;
  a=S/100;
  b=S%100;
  if(((a>=0&&a<=99)&&(b>=1&&b<=12))&&((b>=0&&b<=99)&&(a>=1&&a<=12))) 
    cout << "AMBIGUOUS" << endl;
     else if((b>=0&&b<=99)&&(a>=1&&a<=12)) cout << "MMYY" << endl;
     else if((a>=0&&a<=99)&&(b>=1&&b<=12)) cout <<"YYMM" << endl;
     else cout << "NA" << endl;
  return 0;
}
               

Measured memory_bytes: 256
S = input()
T = input()
used = [0] * 30
inv = [i for i in range(0, 30)]

for i in range(30):
    used[i] = chr(ord('a') + i)

for i in range(len(S)):
    idx = ord(S[i]) - ord('a')
    idx2 = ord(T[i]) - ord('a')
    idx3 = ord(used[idx]) - ord('a')
    if used[idx] == T[i]:
        continue
    used[idx],used[inv[idx2]],inv[idx3],inv[idx2]= used[inv[idx2]], used[idx], inv[idx2], inv[idx3]


SS = ''
for i in range(len(S)):
    idx = ord(S[i]) - ord('a')
    SS = SS + used[idx]

ans = SS == T
print ('Yes' if ans else 'No')
    


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimization ("O2")
#pragma GCC target("popcnt")
#pragma GCC target ("avx2")
using namespace std;

int main(){
	int n,m,x,ans=1000000000;
	cin >> n >> m >> x;
	vector<pair<int,vector<int>>> v;
	for(int i = 0 ; i < n ; i += 1){
		pair<int,vector<int>> p;
		cin >> p.first;
		for(int j = 0 ; j < m ; j += 1){
			int a;
			cin >> a;
			p.second.push_back(a);
		}
		v.push_back(p);
	}
	for(int i = 0 ; i < (1<<n) ; i += 1){
		int skill[m];
		for(int j = 0 ; j < m ; j += 1){
			skill[j] = 0;
		}
		int sum = 0;
		for(int j = 0 ; j < n ; j += 1){
			if(i & (1<<j)){
				sum += v[j].first;
				for(int k = 0 ; k < m ; k += 1){
					skill[k] += v[j].second[k];
				}
			}
		}
		bool f = true;
		for(int j = 0 ; j < m ; j += 1){
			if(skill[j] < x){
				f = false;
				break;
			}
		}
		if(!f){
			continue;
		}
		ans = min(ans,sum);
	}
	if(ans == 1000000000){
		cout << -1 << endl;
	}else{
		cout << ans << endl;
	}
}

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  int a;
  cin >> a ;
  printf("ABC%d\n", a);
  return 0;
}

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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
struct UnionFind {
    int n, cc, *u;
    UnionFind() : n(0), cc(0), u(NULL) {}
    UnionFind(int n_) : n(n_), cc(n_) {
	u = new int[n_];
	memset(u, -1, sizeof (int) * n);
    }
    UnionFind(const UnionFind &y) : n(y.n), cc(y.cc) {
	u = new int[y.n];
	memcpy(u, y.u, sizeof (int) * n);
    }
    ~UnionFind() {
	delete[] u; u = NULL;
	n = cc = 0;
    }
    friend void swap(UnionFind &x, UnionFind &y) {
	swap(x.n, y.n); swap(x.cc, y.cc); swap(x.u, y.u);
    }
    UnionFind& operator=(UnionFind y) { 
	swap(*this, y);
	return *this;
    }
    int root(int x) {
	int y = x, t;
	while (u[y] >= 0) y = u[y];
	while (x != y) { t = u[x]; u[x] = y; x = t; }
	return y;
    }
    bool link(int x, int y) {
	x = root(x); y = root(y);
	if (x == y) return false;
	if (u[y] < u[x]) swap(x, y);
	u[x] += u[y]; u[y] = x; cc--;
	return true;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int size(int x) { return -u[root(x)]; }
    int count() { return cc; }
};

int N, M;
LL X[100011];
struct Edge {
    int x, y, c;
    Edge(int x_, int y_, int c_) {
	 x = x_;
	 y = y_;
	 c = c_;
    }
    bool operator<(const Edge &o) const {
	return c < o.c;
    }
};
vector<Edge> E;

LL SUM[100011];
LL MA[100011];
int PEN[100011];

void MAIN() {
    scanf("%d%d", &N, &M);
    REP (i, N) scanf("%lld", X+i);
    E.reserve(M);
    REP (i, M) {
	int x, y, c;
	scanf("%d%d%d", &x, &y, &c);
	x--; y--;
	E.emplace_back(x, y, c);
    }


    int ans = 0;
    sort(E.begin(), E.end());
    UnionFind U(N);
    REP (i, N) SUM[i] = X[i];

    EACH (e, E) {
	int x = U.root(e->x);
	int y = U.root(e->y);
	int c = e->c;
	int r;
	if (x != y) {
	    U.link(x, y);
	    r = U.root(x);
	    SUM[r] = SUM[x] + SUM[y];
	    PEN[r] = PEN[x] + PEN[y] + 1;
	} else {
	    r = x;
	    PEN[r]++;
	}

	MA[r] = c;
	ans++;

	if (SUM[r] >= MA[r]) {
	    ans -= PEN[r];
	    PEN[r] = 0;
	}
    }

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

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  for (int i = v.size() - 1; i >= 0; --i) {
    if (i < v.size() - 1) cout << " ";
    cout << v[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1196
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

const int MOD = 1e9 + 7;
ll mod_pow(ll n, int x) {
    if (x == 0) {
        return 1L;
    } else {
        ll res = mod_pow(n * n % MOD, x / 2) % MOD;
        return (x % 2 == 0 ? 1L : n) * res % MOD;
    }
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MAX_N = 1e5;
    int N, A;
    cin >> N;
    vector<int> v(N, 0);
    REP(i, N) {
        cin >> A;
        v[A]++;
    }
    if (N % 2 != v[0]) {
        cout << 0 << endl;
        return 0;
    }
    FOR(i, 1, N, 1) {
        if (v[i] != 0 && v[i] != 2) {
            cout << 0 << endl;
            return 0;
        }
    }
    if (N % 2 == 1) {
        N--;
    }
    cout << mod_pow(2L, N / 2) << "\n";
    return 0;
}


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

int main() {
  int n, m;
  while(cin >> n >> m, n+m) {
    vector<int> field(n), dice(m);
    for(int i = 0; i < n; i++) cin >> field[i];
    for(int i = 0; i < m; i++) cin >> dice[i];
    
    int p = 0, cnt = 0;
    while(p < n-1) {
      p +=  dice[cnt] + field[p+dice[cnt]];
      cnt++;
    }
    cout << cnt << endl;
  }
}

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

using namespace std;

#define DIM 3009
#define pairll pair<long long,long long>
#define fi first
#define se second
#define INF ((long long)1e18+9ll)
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ld long double
#define MODULO 998244353

long long i,j,k,l,n,m,a,b,c,d;

long long dp[DIM][DIM];

int main()
{
    fast;

    cin>>a>>b>>c>>d;

    dp[a][b]=1;

    for(i=a;i<=c;i++){
        for(j=b;j<=d;j++){
            if(i==a && j==b)continue;

            dp[i][j]=((dp[i-1][j]*j)%MODULO+(dp[i][j-1]*i)%MODULO-(dp[i-1][j-1]*(i-1)*(j-1))%MODULO)%MODULO;

            dp[i][j]%=MODULO;
        }
    }

    cout<<(dp[c][d]+MODULO)%MODULO<<endl;

    amen;
}

Measured memory_bytes: 73996
import sys
readline = sys.stdin.buffer.readline
from collections import Counter
n,m = map(int,readline().split())
mod = 10**9+7

"""素因数分解"""
def factrize(n):
    b = 2
    fct = []
    while b*b <= n:
        while n % b == 0:
            n //= b
            #もし素因数を重複させたくないならここを加えてfct.append(b)を消す
            """
            if not b in fct:
                fct.append(b)
            """
            fct.append(b)
        b = b+1
    if n > 1:
        fct.append(n)
    return fct #リストが帰る
def pow(n,p,mod=10**9+7): #繰り返し二乗法(nのp乗)
    res = 1
    while p > 0:
        if p % 2 == 0:
            n = n ** 2 % mod
            p //= 2
        else:
            res = res * n % mod
            p -= 1
    return res % mod
def factrial_memo(n=20**5+1,mod=10**9+7):
    fact = [1, 1]
    for i in range(2, n + 1):
        fact.append((fact[-1] * i) % mod)
    return fact
fact = factrial_memo()
def fermat_cmb(n, r, mod=10**9+7): #needs pow,factrial_memo(only fact). return nCk
    return fact[n] * pow(fact[r],mod-2) * pow(fact[n-r],mod-2) %mod

lst1 = factrize(m)

c = Counter(lst1)

ans = 1
for i in c.values():
    ans *= fermat_cmb(n+i-1,i)
    ans %= mod

print(ans)
    

Measured memory_bytes: 125728
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
long long N, A, B , C, D;
map<long long, long long> m;
long long dfs(long long a){
    if(a == 0) return 0;
    if(a == 1) return D;
    if(m.count(a)) return m[a];
    long long res = 1e18;
    if(a < res / D) res = a * D;
    long long l2 = a/2*2, r2 = (a + 1) / 2*2;
    long long l3 = a/3*3, r3 = (a + 2) / 3*3;
    long long l5 = a/5*5, r5 = (a + 4) / 5*5;
    res = min(res, min(llabs(a - l2) * D + A + dfs(l2 / 2), llabs(a - r2) * D + A + dfs(r2 / 2)));
    res = min(res, min(llabs(a - l3) * D + B + dfs(l3 / 3), llabs(a - r3) * D + B + dfs(r3 / 3)));
    res = min(res, min(llabs(a - l5) * D + C + dfs(l5 / 5), llabs(a - r5) * D + C + dfs(r5 / 5)));
    m[a] = res;
    return res;
}
int main(){
    long long T;
    cin >> T;
    for(int  i= 0; i < T; i++){
        cin >> N >> A >> B >> C >> D;
        m.clear();
        cout << dfs(N) << endl;
    }
}

Measured memory_bytes: 4440
#include<bits/stdc++.h>
using namespace std;
         
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
const int N = 100001; 


void solve(){
    string s;cin>>s;
    int n=s.size();
    int ans=0;
    rep(i,0,n){
    	ans=ans+s[i]-'0';
    	ans=ans%9;
    }
    if(ans==0)cout<<"Yes";
    else cout<<"No";
    return;
}
         
signed main(){
        IOS;    
       

        int t=1;
        // cin>>t;
        // fac[0] = 1; 
        // for (int i=1 ; i<=2000001; i++) fac[i] = fac[i-1]*i%mod; 
        rep(i,0,t){
            solve();
            cout<<"\n";
        //   cout<<" * "<<t<<"\n";
        }
    //    return 0;
}

Measured memory_bytes: 3752
program d
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64)::n,i,j,ans
    integer(int64):: dn(1000000)=0, bn(0:5050)
    logical:: pn(1000000) = .true. 


    read*, n
    pn(1) = .false.

    do i=2,1000000
        if (pn(i)) then
            j=2
            do while(i*j <= 1000000)
                pn(i*j) = .false.
                j=j+1
            end do
        end if
    end do

    do i=2,1000000
        if (pn(i)) then
            do while(mod(n,i) == 0)
                n=n/i
                dn(i) = dn(i)+1
            end do
        end if
    end do
    ans = 0

    if (n > 1) ans=ans+1
    bn(:) = 0
    do i=100,1,-1
        bn((i*(i+1))/2) = i
    end do
    do i=2,5050
        bn(i) = max(bn(i),bn(i-1))
    end do

    do i=1,1000000
        ans=ans+bn(dn(i))
    end do
    print'(i0)', ans

end program d

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

int main()
{
  string str;
  for(int k=0;k<5;k++){
    int a=0,b=0;
    cin >> str;
    if(str=="EOF") break;
    for(int i=0;i<(int)str.size()-2;i++){
      if(str[i+1]=='O'&&str[i+2]=='I'){
        if(str[i]=='J') a++;
        else if(str[i]=='I') b++;
      }
    }
    cout << a << endl;
    cout << b << endl;
  }
  return 0;
}


Measured memory_bytes: 3036
#include <cstdio>
#include <string>
#include <string.h>
#include <unordered_map>

using namespace std;

long sum(long n) {
  if (n == 0) return 0;
  return n + sum(n - 1);
}

int main() {
  int n;
  scanf("%d", &n);
  unsigned char arr[n][26];
  memset(arr, 0, n * 26);

  unordered_map<string, long> hoge;

  for (int i = 0; i < n; ++i) {
    char box[12];
    scanf("%s", &box[0]);
    char tmp[26];
    memset(tmp, 0, 26);
    for (int j = 0; j < 10; ++j) {
      tmp[(unsigned char)box[j] - 0x61]++;
    }
    string str = "";
    for (int j = 0; j < 26; ++j) {
      str += (char)(tmp[j] + 0x61) + to_string((int)tmp[j]);
    }
    if (hoge.find(str) == hoge.end()) {
      hoge.insert(make_pair(str, 0));
    } else {
      hoge[str]++;
    }
  }

  long cnt = 0;

  auto itr = hoge.begin();
  for (itr; itr != hoge.end(); itr++) {
    cnt += sum(itr->second);
  }

  printf("%ld\n", cnt);

  return 0;
}


Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    string lis[] = {"Sunny", "Cloudy", "Rainy"};
    string c;
    cin >> c;
    rep(i, 3) if (lis[i]==c) cout << lis[(i+1)%3] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int fact[MAX_N];
int ifact[MAX_N];

int power(int x, int n) {
	int res = 1LL;
	while (n > 0) {
		if (n & 1) (res *= x) %= MOD;
		(x *= x) %= MOD;
		n >>= 1;
	}
	return res % MOD;
}

int inv(int x) {
	return power(x, MOD - 2);
}

int nCr(int n, int r) {
	if (n < 0 || r < 0 || r > n) return 0;
	if (r > n / 2) r = n - r;
	return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;
}

void init_fact() {
  fact[0] = ifact[0] = 1;
	for (int i=1; i<MAX_N; ++i) {
		(fact[i] = fact[i - 1] * i) %= MOD;
		ifact[i] = inv(fact[i]);
	}
}

signed main() {
  INIT;
  VAR(int,n,m,k);

  init_fact();

  int ans = 0;
  // x(右)方向の和を求める
  // xi: x方向の2マスの差
  REP(xi, m) {
    int dx = (xi+1)*(m-xi-1)*n*n;
    (ans += dx * nCr(n*m-2, k-2)) %= MOD;
  }

  // y(下)方向の和を求める
  // yi: y方向の2マスの差
  REP(yi, n) {
    int dy = (yi+1)*(n-yi-1)*m*m;
    (ans += dy * nCr(n*m-2, k-2)) %= MOD;
  }

  OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 4992
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let s: Vec<char> = iter.next().unwrap().chars().collect();
    let c0 = s.iter().filter(|&c| *c == '0').count();
    let c1 = s.iter().filter(|&c| *c == '1').count();
    println!("{}", std::cmp::min(c0, c1) * 2);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int main() {

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

	string s; cin>>s;
	if(s=="ABC")
		cout<<"ARC";
	else cout<<"ABC";

	return 0;
}

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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMinimum(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMaximum(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */

int main() {


    ll N;
    cin >> N;

    /**
     * 1. まず大きい桁数から9が2つ以上続く場合はそれらの9を用いることは確定されるので例外として処理
     * 2. 99999(...)99XYZZZ ->  999(...)98999
     *    つまり，9以外の数字が最初に出てきたらその数-1をして以下9づめが最も大きい数字になる．
     */
    std::string S = std::to_string(N);
    int digit = S.length();
    bool f = true;
    int c;
    for (int i = 0; i < digit; ++i) {
        char temp = S[i];
        if (temp == '9') {
            continue;
        }
        if (i == 0) {
            c = 0;
            break;
        } else {
            c = i - 1;
            break;
        }
    }
//    cout << c << endl;

    ll num = 0;
    for (int i = 0; i < digit; ++i) {
        if (i == c) {
            if (S[i] == '1') {
                continue;
            }
            ll n = (S[i] - '1') * pow(10, digit - (i + 1));
            num += n;
        } else {
            if (digit - i == 1) { num += 9; }
            else {
                num += 9 * pow(10, digit - (i + 1));
            }
        }
//        cout << num << endl;

    }
//    cout << num << endl;
    ll sum = 0;
    ll dig;
    while (num) {
        dig = num % 10;
        sum = sum + dig;
        num = num / 10;
    }

    ll ss = sum;
    ll um = 0;

    while (N) {
        dig = N % 10;
        um = um + dig;
        N = N / 10;
    }

    ll ans = max(um, ss);

    cout << ans << endl;

}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.conv;
import std.numeric;
import std.math;
import std.string;

void main()
{
	auto tokens = split(chomp(readln()));
	auto n = to!int(tokens[0]);
	auto m = to!int(tokens[1]);
	int[][] nodes;
	nodes.length = n;
	foreach (i; 0..m)
	{
		auto tokens2 = split(chomp(readln()));
		auto a = to!int(tokens2[0]) - 1;
		auto b = to!int(tokens2[1]) - 1;
		nodes[a] ~= b;
		nodes[b] ~= a;
	}
	
	int search(int pos, int[] open)
	{
		if (open.length == 0) return 1;
		int cnt;
		foreach (next; nodes[pos])
		{
			auto oi = countUntil(open, next);
			if (oi == -1) continue;
			cnt += search(next, remove(open.dup, oi));
		}
		return cnt;
	}

	int[] open_start;
	foreach (i; 1..n) open_start ~= i;
	auto result = search(0, open_start);
	
	writeln(result);
	stdout.flush();
}

Measured memory_bytes: 508
try:
    
    while True:
        N=list(str(input()))
        
        M=int(input())
    
        for i in range(M):
            H=int(input())
            for j in range(H):
                A=N[0]
                N.remove(A)
                N.append(A)
                j+=1
            
        for k in range(len(N)):  
            print(N[k],end='')
        
        print()
        
except EOFError:
    pass


Measured memory_bytes: 5620
import java.util.*;
import java.lang.Math;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int A = in.nextInt();
		int B = in.nextInt();
		
		int number1 = (int) Math.ceil(A/0.08);
		int number2 = (int) Math.ceil(B/0.1);
		
		if(number1 > number2) {
			if (Math.floor(number1*0.1) == B) {
				System.out.println(number1);
			} else {
				System.out.println("-1");
			}
		} else if (number2 > number1) {
			if (Math.floor(number2*0.08) == A) {
				System.out.println(number2);
			} else {
				System.out.println("-1");
			}
		} else {
			System.out.println(number1);
		}
		
	}
}


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

long long MOD=998244353ll;

long long dp[333][99999];
long long dp1[333][99999];

int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for(auto &i:a)cin >> i;
	
	dp[0][0]=1;
	
	for(int i=0;i<N;i++)for(int j=0;j<=90000;j++){
		if(j>=a[i])dp[i+1][j]+=dp[i][j-a[i]];
		dp[i+1][j]+=dp[i][j]*2;
		dp[i+1][j]%=MOD;
	}
	
	dp1[0][0]=1;
	for(int i=0;i<N;i++)for(int j=0;j<=90000;j++){
		if(j>=a[i])dp1[i+1][j]+=dp1[i][j-a[i]];
		dp1[i+1][j]+=dp1[i][j];
		dp1[i+1][j]%=MOD;
	}
	
	long long ans=1;
	int sum=accumulate(a.begin(),a.end(),0);
	for(int i=0;i<N;i++)ans=(ans*3)%MOD;
	for(int j=(sum+1)/2;j<=sum;j++)ans=(ans+(MOD-dp[N][j])*3)%MOD;
	if(sum%2==0)ans=(ans+dp1[N][sum/2]*3)%MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 470400
from bisect import bisect_left
INF = 10**18
A, B, Q = map(int, input().split())
als = [int(input()) for i in range(A)]
bls = [int(input()) for i in range(B)]
als = [-INF]+als+[INF]
bls = [-INF]+bls+[INF]

for i in range(Q):
  x = int(input())
  ai = bisect_left(als,x)
  bi = bisect_left(bls,x)
  res = INF
  for S in [als[ai], als[ai-1]]:
    for T in [bls[bi], bls[bi-1]]:
      d1, d2 = abs(S-x)+abs(T-S), abs(T-x)+abs(S-T)
      res = min(res,d1,d2)
  print(res)

Measured memory_bytes: 14568
#include <bits/stdc++.h>
#define FILES                    \
	ifstream cin( "input.txt" ); \
	ofstream cout( "input.txt" );
#define FAST                             \
	std::ios_base::sync_with_stdio( 0 ); \
	std::cin.tie( 0 );                   \
	std::cout.tie( 0 );
#define FIXED cout << fixed << setprecision( 20 )
#define pb push_back
#define eps 1e-9
#define mod 1000000007
#define int long long
using graph = std::vector<std::vector<int>>;
using pll = std::pair<int, int>;
using ll = long long;
namespace my {
	int max( int x ) {
		return x;
	}
	template<typename... Args>
	int max( int x, Args... args ) {
		int y = max( args... );
		return ( x < y ) ? y : x;
	}
	int min( int x ) {
		return x;
	}
	template<typename... Args>
	int min( int x, Args... args ) {
		int y = min( args... );
		return ( x < y ) ? x : y;
	}
	int max( std::vector<int>& t ) {
		int mx = -1e18;
		for( int i = 0; i < t.size(); i++ ) {
			mx = std::max( mx, t[i] );
		}
		return mx;
	}
	int min( std::vector<int>& t ) {
		int mn = 1e18;
		for( int i = 0; i < t.size(); i++ ) {
			mn = std::min( mn, t[i] );
		}
		return mn;
	}
}	// namespace my

void z_f( std::vector<int>& z, std::string& s ) {
	int l = 0, r = 0;
	for( int i = 1; i < s.size(); i++ ) {
		if( r >= i ) {
			z[i] = std::min( r - i + 1, z[i - l] );
		}
		int& x = z[i];
		while( i + x < s.size() && ( s[i + x] == s[x] ) ) {
			++x;
		}
		if( i + x - 1 > r ) {
			l = i;
			r = i + x - 1;
		}
	}
}
void solve() {
	std::string s;
	std::cin >> s;
	int count = 0;
	for( int i = 0; i < s.size(); i++ ) {
		count += ( s[i] == 'R' );
	}
	if( count == 3 ) {
		std::cout << 3;
	} else if( count == 0 ) {
		std::cout << 0;
	} else if( count == 2 && s[1] == 'R' ) {
		std::cout << 2;
	} else {
		std::cout << 1;
	}
}
main() {
	int t = 1;
	FAST;
	// std::cin >> t;
	while( t-- ) {
		solve();
	}
}

Measured memory_bytes: 3668