akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;
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;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int a,b; cin >> a >> b;
    pr((a-1)*(b-1));
}



Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int H, W;
   
    while (1){
        scanf ("%d %d", &H, &W);
        if (W == 0 && W == 0){
            break;
        }

        for (int i = 1; i <= H; i++){
            for (int j = 1; j <= W; j++){
                if (i % 2 == 0){
                    if (j % 2 == 0){
                        printf("#");
                    }
                    else {
                        printf(".");
                    }
                }
                else {
                    if (j % 2 == 0){
                        printf(".");
                    }
                    else {
                        printf("#");
                    }
                }
            }
            printf("\n");
        }
        
        printf("\n");
    }

    return 0;
}
                

Measured memory_bytes: 1000
#include <bits/stdc++.h>
using namespace std;
int spot[100007];
int main()
{
    int n;
    cin >> n;
    int total = 0, ans;

    spot[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> spot[i];
    }
    for (int i = 1; i <= n; i++)
    {
        total += abs(spot[i] - spot[i - 1]);
    }
    total += abs(spot[n] - spot[0]);

    for (int i = 1; i <= n; i++)
    {
        ans = total;
        if (i != n)
        {
            ans += abs(spot[i + 1] - spot[i - 1]) - abs(spot[i] - spot[i - 1]) - abs(spot[i + 1] - spot[i]);
        }
        else
        {
            ans += abs(spot[n - 1] - spot[0]) - abs(spot[n] - spot[0]) - abs(spot[n] - spot[n - 1]);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
using namespace std;
typedef pair<string,int>P;
typedef vector<P>V;
int main(void){
	string s;
	int i;
	int cnt;
	V v1;
	P pp;
	int MAX;
	cin>>s;
	cnt=1;
	for(i=0;i<s.size();i++){
		if(s[i]!=s[i+1]){
			pp.F=s[i];
			pp.S=cnt;
			v1.PB(pp);
			cnt=0;
		}
		cnt++;
	}
	/* for(i=0;i<v1.size();i++){
		cout<<v1[i].F<<" "<<v1[i].S<<endl;
	} */
	MAX=0;
	for(i=0;i<v1.size();i++){
		if(i-1>=0&&i+1<v1.size()){
			if(v1[i].F=="O"){
				if(v1[i-1].F=="J"&&v1[i-1].S>=v1[i].S){
					if(v1[i+1].F=="I"&&v1[i].S<=v1[i+1].S){
						MAX=max(MAX,v1[i].S);
					}
				}
			}
		}
	}
	cout<<MAX<<endl;
	return 0;
}
	


Measured memory_bytes: 66368
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillDouble(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%lf", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;
const int MAX_V = 100005;

vector<int> G[MAX_V];
int d[3][MAX_V];
int n;

struct Pony {
  int value;
  int kkp;
  int idx;

  bool operator>(Pony other) const {
    return value > other.value;
  }
};

void dijkstra(int s) {
    priority_queue<Pony, vector<Pony>, greater<Pony>> que;
    fill(d[0], d[0]+n, INF);
    fill(d[1], d[1]+n, INF);
    fill(d[2], d[2]+n, INF);

    d[0][s] = 0;
    que.push(Pony({0, 0, s}));

    while (!que.empty()) {
        Pony p = que.top();
        que.pop();
        int v = p.idx;
        if (d[p.kkp][v] < p.value) continue;

        for (int i=0; i<G[v].size(); ++i) {
            int e = G[v][i];
            rep(i, 2) {
              if(d[(i+1)%3][e] > d[i][v]) {
                d[(i+1)%3][e] = d[i][v];
                que.push(Pony({d[(i+1)%3][e], (i+1)%3, e}));
              }
            }
            if(d[0][e] > d[2][v] + 1) {
              d[0][e] = d[2][v] + 1;
              que.push(Pony({d[0][e], 0, e}));
            }
        }
    }
}

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

  long m;
  cin >> n >> m;

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
  }

  int s, t;
  cin >> s>> t;
  s--;t--;

  dijkstra(s);

  cout << (d[0][t] == INF ? -1 : d[0][t]) << endl;
}


Measured memory_bytes: 7416
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  ll k, a, b;
  cin >> k >> a >> b;

  ll ans;
  if(b < a + 2 || k < a + 1){
    ans = 1 + k;
  }
  else{
    k -= a + 1;
    ans = (k / 2 + 1) * b - (k / 2) * a + (k % 2);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    string c[h];
    rep(i, h) cin >> c[i];
    int ans = 0;
    for (int i = 0; i < (1<<h); i++){
        for (int j = 0; j < (1<<w); j++){
            // cout << i << " " << j << endl;
            int num = 0;
            for (int k = 0; k < h; k++){
                if(((i >> k) & 1) == 1) continue;
                for (int l = 0; l < w; l++){
                    if(((j >> l) & 1) == 1) continue;
                    if(c[k][l] == '#') num++;
                }
            }
            if(num == k) ans++;    
            // cout << num << endl;        
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

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

int main() {
  int n;
  cin >> n;
  string S;
  cin >> S;
  vector<int> c(26);
  rep(i, S.size()) c[S[i]-'a']++;
  for(int i=1; i<n; i++) {
    vector<int> tmp(26);
    cin >> S;
    rep(j, S.size()) tmp[S[j]-'a']++;
    rep(j, 26) c[j] = min(c[j], tmp[j]);
  }
  rep(i, 26) {
    rep(j, c[i])
      cout << char('a'+i);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
ans = False
for i in range(X+1,Y-1):
    if max(x)<i and min(y)>=i:
        ans = True
        break
if ans == False:
    print("War")
else:
    print("No War")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    char r[10];
    while(cin>>r)
    {
        int d,e,f;
        d=0,e=0,f=0;
        if(r[0]=='a')
        {
            d=1;
        }
         if(r[0]=='b')
        {
            e=1;
        }
         if(r[0]=='c')
        {
            f=1;
        }
        if(r[1]=='a')
        {
            d=1;
        }
         if(r[1]=='b')
        {
            e=1;
        }
         if(r[1]=='c')
        {
            f=1;
        }
        if(r[2]=='a')
        {
            d=1;
        }
         if(r[2]=='b')
        {
            e=1;
        }
         if(r[2]=='c')
        {
            f=1;
        }

        if(d==1&&e==1&&f==1)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }


    }



    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

long long a,b,c;

int main()
{
	scanf("%lld%lld%lld",&a,&b,&c);
	for(int i=1;i<=10;i++)
	{
		c=a*c-b;
		printf("%lld\n",c);
	}
	
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    reverse(a, a + n);
    ll prev = 0, x = 0, y = 0;
    rep(i, n) {
        if (a[i] == prev) {
            if (x == 0) x = a[i];
            else {
                y = a[i];
                break;
            }
            prev = 0;
        } else {
            prev = a[i];
        }
    }
    cout << x * y << endl;
    return 0;
}

Measured memory_bytes: 1024
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)

a,b,c, k = map(int, input().split())
ans =0
if(k > 0):
    ans+= min(a,k)
    k-=a
if(k > 0):
    k-=b
if(k > 0):
    ans-=min(k,c)
print(ans)


Measured memory_bytes: 62048
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long int
#define MOD ((int)(1e9) + 7)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vector<vector<int>> A;
  for(int i=0; i<3; i++) {
    vector<int> c;
    A.push_back(c);
    for(int j=0; j<3; j++) {
      int tp; cin >> tp;
      A[i].push_back(tp); 
    }
  }
  int n;
  cin >> n;
  for(int i=0; i<n; i++) {
    int tp; cin >> tp;
    for(int a=0; a<3; a++) {
      for(int b=0; b<3; b++) {
        if(A[a][b] == tp)
          A[a][b] = 0;
      }
    }
  }
  // row
  bool flag = false;
  for(int i=0; i<3; i++) {
    if(A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0) flag = true;
  }
  // col
  for(int i=0; i<3; i++) {
    if(A[0][i] == 0 && A[1][i] == 0 && A[2][i] == 0) flag = true;
  }
  // diag
  if(A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) flag = true;
  if(A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0) flag = true;
  if(flag) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
n, y = map(int, input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if(10000*i + 5000*j + 1000*(n-i-j) == y):
            print(i, j, n-i-j)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 100;
int N, X[Nmax], Y[Nmax];
ll H[Nmax];

int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> X[i] >> Y[i] >> H[i];

	for(int x=0; x<=100; x++){
		for(int y=0; y<=100; y++){
			ll h = 1e9;
			for(int i=0; i<N; i++){
				if(H[i]==0) continue;
				if(h==1e9){
					h = abs(x-X[i])+abs(y-Y[i])+H[i];
				} else if(h != abs(x-X[i])+abs(y-Y[i])+H[i]){
					h = -1;
					break;
				}
			}
			for(int i=0; i<N; i++){
				if(H[i]>0) continue;
				if(h-abs(x-X[i])-abs(y-Y[i])>0){
					h = -1;
					break;
				}
			}
			if(h>0){
				cout << x << " " << y << " " << h << endl;
				return 0;
			}
		}
	}

	return 0;
}


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

int main(){
  int N,A; //支払い金額と硬貨の枚数の入力
  int div;
  cin >> N >> A ;
  div = N%500; //金額を500で割った値の導出
  if( div <= A ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define endl "\n"
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	map<int,int> cnt;
	for(int i=0,a;i<n-1;++i){
		cin>>a;
		cnt[a]++;
	}
	for(int i=1;i<=n;++i){
		cout<<cnt[i]<<endl;
	}
}


Measured memory_bytes: 13040
#include <stdio.h>

int main(void)
{
	int a[4], b[4];
	int hit, blow;
	int i, j;
	
	while ((scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF) && (scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]) != EOF)){
		
		hit = 0;
		blow = 0;
		
		for (i = 0; i < 4; i++){
			for (j = 0; j < 4; j++){
				if (a[i] == b[j]){
					blow++;
					if (i == j){
						blow--;
						hit++;
					}
				}
			}
		}
		
		printf("%d %d\n", hit, blow);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,n,i,j,a,b;cin >> h >> n;
  int dp[n+1][h+1] = {};
  for(i=0;i<=n;i++){
    for(j=1;j<=h;j++) dp[i][j] = 1000000000;
  }
  for(i=1;i<=n;i++){
    cin >> a >> b;
    for(j=1;j<=h;j++){
      if(j<a) dp[i][j] = min(dp[i-1][j],b);
      else dp[i][j] = min(dp[i-1][j],dp[i][j-a]+b);
    }
  }
  cout << dp[n][h] << endl;
}

Measured memory_bytes: 39296
/*
  -> ossan
  -> Do Good Die Great
*/
#include <bits/stdc++.h>
#define int long long int
#define pii pair<int, int>
#define ff first
#define ss second
#define eb emplace_back
#define pb push_back
#define MOD 1000000007
#define Hiraishin                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr);
#define tests \
    int t;    \
    cin >> t; \
    while (t--)
using namespace std;

// global

void solve()
{
    int n;
    cin >> n;
    int arr[n];
    int x = 0;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        x ^= arr[i];
    }
    for (int i = 0; i < n; i++) {
        cout << (x ^ arr[i]) << ' ';
    }
}

signed main()
{
    Hiraishin
    // tests
    solve();
    return 0;
}

Measured memory_bytes: 5216
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n, m;
    cin >> n >> m;
    vi a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    vi c(m), d(m);
    for (int i = 0; i < m; ++i) {
        cin >> c[i] >> d[i];
    }
    for (int i = 0; i < n; ++i) {
        int mini = 1000000000;
        int idx  = -1;
        for (int j = 0; j < m; ++j) {
            int di = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (di < mini) {
                mini = di;
                idx  = j;
            }
        }
        cout << idx + 1 << "\n";
    }
    return 0;
}

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

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

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;




int f[maxn];

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

    int n;
    cin>>n;
    
    for (int i=0; i<n; i++) {
	int x;
	cin>>x;
	f[x]++;
    }
    vector<ll> v; // frequencies of elems
    for (int i=0; i<maxn; i++) {
	if (f[i]) {
	    v.push_back(f[i]);
	}
    }

    sort(v.rbegin(), v.rend());
    int len = v.size();

    vector<ll> remaining(n+1, 0); // remaining[i]: remaining # of elems if we remove the top i most frequent elements.
    for (int i=len-1; i>=0; i--) {
	remaining[i] = v[i] + remaining[i+1];
    }


    auto get = [&](int m, int k) {
	return 1.0 * remaining[m] / (k-m);
    };

    for (int k=1; k<=n; k++) {
	ll res = n / k;
	int lo = 1;
	int hi = k;
	while (hi-lo>1) {
	    int mid = (lo+hi)/2;
	    assert(k>mid);
	    double resp = get(mid-1, k);
	    double resc = get(mid, k);
	    if (resp < resc) {
		hi = mid;
	    } else {
		lo = mid;
	    }
	}
	for (int m=hi-5; m<=hi+5; m++) {
	    if (k>m && m>=0) {
		res = min(res, (ll)get(m, k));
	    }
	}
	cout<<res<<"\n";
    }
    
    return 0;
}


Measured memory_bytes: 8792
s = str(input())
a = int(s[0])*10 + int(s[1])
b = int(s[2])*10 + int(s[3])
if (0 < a <= 12 and 0 <= b) and (0 <= a and 0 < b <= 12):
    print("AMBIGUOUS")
elif 0 < a <= 12:
    print("MMYY")
elif 0 < b <= 12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
# AtCoder 王国では, 5 月 5 日のような月の数と日の数が同じ日を「高橋」と言う.
# 2018 年 1 月 1 日から 2018 年 a 月 b 日までに, 「高橋」は何日あるか.
# ただし, AtCoder 王国ではグレゴリオ暦を利用しているものとする.

input = gets.chomp.split
a = input[0].to_i
b = input[1].to_i

if a <= b
    puts a
else
    puts a - 1
end

Measured memory_bytes: 1788
program two_abbreviations
  implicit none
  integer :: x, y
  character(100000) :: s, t
  integer(8) :: n, m, i
  read(*,*) n, m
  read(*,*) s
  read(*,*) t
  do i = 0_8, n-1_8
    if (mod(i*m,n) /= 0_8) cycle
    x = int(i,4)+1
    y = int(i*m/n,4)+1
    if (s(x:x) /= t(y:y)) then
      write(*,'(i0)') -1
      stop
    end if
  end do
  write(*,'(i0)') lcm(n,m)
contains
  integer(8) function lcm(a,b)
    integer(8), intent(in) :: a, b
    lcm = a/gcd(a,b)*b
  end
  integer(8) function gcd(a,b)
    integer(8), intent(in) :: a, b
    integer(8) :: x, y
    x = max(a,b)
    y = min(a,b)
    do while (y > 0_8)
      gcd = y
      y = mod(x,y)
      x = gcd
    end do
  end
end program two_abbreviations

Measured memory_bytes: 828
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int n, m, r;
int a[2009], b[2009], c[2009];
ll d[1009];

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

    cin >> n >> m >> r;

    rep(i, m) cin >> a[i] >> b[i] >> c[i];

    rep(i, n) d[i] = inf;
    d[r] = 0;

    bool update;
    rep(i, n) {
        update = false;
        rep(j, m) if(d[a[j]] < inf && chmin(d[b[j]], d[a[j]] + c[j])) update =
            true;
        if(!update) break;
    }

    if(update) {
        cout << "NEGATIVE CYCLE\n";
        return 0;
    }

    rep(i, n) {
        if(d[i] < inf)
            cout << d[i] << "\n";
        else
            cout << "INF\n";
    }

    return 0;
}


Measured memory_bytes: 3236
import java.util.Scanner;

class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int N = sc.nextInt();
		int ans = 0;
		sc.close();
		if(D==0) {
			ans = (N!=100)?N:101;			
		}
		else {
			int tmp = 1;
			for(int i=0;i<D;i++) {
				tmp *=100;
				ans = (N!=100)?tmp*N:tmp*(N+1);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <chrono>
#include <stack>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong pow(int x, int n) {
    llong ans = x;
    if (n == 0) return 1;

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

    return ans;
}

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

int main() {
    int n, m, x, a[101] = {0};
    cin >> n >> m >> x;
    if (n == 2) {
        cout << 0 << endl;
        return 0;
    }
    int tmp;
    rep(i, m) {
        cin >> tmp;
        a[tmp] = 1;
    }

    int total1, total2;

    for(int i = x; i > 0; --i) {
        total1 += a[i];
    }

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

    cout << min(total1, total2) << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec1(n);
  vector<int> vec2(n);
  rep(i,n){
    cin >> vec1.at(i);
  }
  rep(i, n){
    cin >> vec2.at(i);
  }
  
  vector<int> vec3(n);
  
  rep(i, n){
    vec3.at(i) = vec1.at(i) - vec2.at(i);
  }
  
  int sum= 0;
  rep(i, n){
    if (vec3.at(i) > 0){
      sum += vec3.at(i);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[51], B[51];
bool dp[51][51][51]; //when number 1 to r can be used, is A->B possible?
bool U[51][51]; //whether A[i] can be j

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, N) cin >> B[i];
	for(int i = 0; i <= 50; i++) dp[i][i][0] = 1;
	for(int k = 1; k <= 50; k++) {
		for(int i = 0; i <= 50; i++) {
			for(int j = 0; j <= 50; j++) {
				dp[i][j][k] = (dp[i][j][k - 1] | dp[i % k][j][k - 1]);
			}
		}
	}
	for(int i = 0; i < N; i++) {
		U[i][A[i]] = 1;
	}
	ll res = 0;
	for(int k = 50; k >= 0; k--) {
		bool found = false;
		for(int i = 0; i < N; i++) {
			bool ok = false;
			for(int j = 0; j <= 50; j++) {
				if(!U[i][j]) continue;
				// debug(j, B[i], k, dp[j][B[i]][k]);
				if(dp[j][B[i]][k]) {
					ok = true;
					break;
				}
			}
			if(!ok) {
				found = true;
				break;
			}
		}
		if(found) {
			res |= (1ll << (k + 1));
			for(int i = 0; i < N; i++) {
				for(int j = 0; j <= 50; j++) {
					if(U[i][j]) {
						U[i][j % (k + 1)] = true;
					}
				}
			}
		}
	}
	if(res >= (1ll << 51)) {
		cout << -1 << "\n";
	}
	else {
		cout << res << "\n";
	}
}
int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define eb emplace_back

typedef long long ll;
using namespace std;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
const int MAX = 2010000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

mint f(ll r,ll c){
    return (mint)COM(r+c,r);
}
mint g(ll r,ll c){
    mint res = 0;
    for(ll i = r+1;i >= 1;i--){
        res += f(i,c);
    }
    return res;
}
int main(void){
    COMinit();
    ll r1,c1,r2,c2;cin >> r1 >> c1 >> r2 >> c2;
    mint ans = 0;
    ans = g(r2,c2) - g(r1-1,c2) - g(r2,c1-1) + g(r1-1,c1-1);
    cout << ans.x << '\n';
    return 0;
}


Measured memory_bytes: 47360
//Karol Kaszuba

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double D;
typedef long double LD;
typedef vector<PII> VII;
typedef unordered_set<int> USI;
typedef unordered_set<LL> USLL;

#define FOR(i,x,y) for(auto i=(x);i<=(y);++i)
#define REP(i,x) FOR(i,0,(x)-1)
#define FORD(i,x,y) for(auto i=(x);i>=(y);--i)
#define VAR(i,c) __typeof(c) i=(c)
#define FORE(i,c) for(VAR(i,(c).begin());i!=(c).end();++i)
#define SIZE(c) (int)((c).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define EB emplace_back
#define IN insert
#define ER erase
#define MP make_pair
#define ST first
#define ND second
#define IOSYNC ios_base::sync_with_stdio(0)
#define FREOPEN(f) freopen(f, "r", stdin),freopen(f, "w", stdout)

void jebaj() {
	LL a, b;
	cin >> a >> b;
	if (a % b == 0) {
		cout << "-1\n";
	} else {
		cout << a << "\n";
	}
}

int main() {
	IOSYNC;
	int t;
	t = 1;
	while(t--) jebaj();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
int gcd(int x,int y){
  	if(x>y){return gcd(y,x);}
	if(x == 0){return y;}
    return gcd(x, y%x);
}
int main()
{
  int N, X;
  std::cin >> N >> X;
  int ans;std::cin >> ans;
  ans = std::abs(ans-X);
  for(int i = 1,e; i < N; i++){std::cin >> e;ans = gcd(ans, std::abs(e-X));}
  std::cout << ans << std::endl;
  return 0;
}

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

signed main(){
    int n, m; cin >> n >> m;
    vector<int> vec(m);
    int sum = 0;
    for (int i = 0; i < m; i++){
        int a;
        cin >> a;
        sum += a;
    }
    int ans = n - sum;
    if (ans < 0) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3712
//Disjoint Set

//Accepted 
//uva 793,273,10685
//
#include<iostream>
#include<vector>
#include <map>
#include <vector>

using namespace std;
class DisjointSet{
public:
  vector<int> rank,p;
  
  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size,0);
    p.resize(size,0);
    for(int i =0;i < size;i++){
      make_set(i);
    }
  }
  void make_set(int x){
    p[x]=x;
    rank[x]=0;
  }
  void merge(int x,int y){
    link(find_set(x),find_set(y));
  }
  void link(int x,int y){
    if (rank[x]>rank[y]){
      p[y]=x;
    }else {
      p[x]=y;
      if ( rank[x] ==rank[y])rank[y]+=1;
    }
  }
  int find_set(int x){
    if (x != p[x])p[x]=find_set(p[x]);
    return p[x];
  }
};

int main(){
  int n, k, l;
  
  cin >> n >> k >> l;
  DisjointSet road(n), train(n);
  for(int i = 0;i < k;i++){
    int a, b;
    cin >> a >> b;
    a--;b--;
    road.merge(a, b);
  }

  for(int i = 0;i < l;i++){
    int a,b;
    cin >> a>> b;
    a--;b--;
    train.merge(a,b);
  }

  map<int, vector<int> > M_road;
  for(int i = 0;i < n;i++){
    int cur = road.find_set(i);
    M_road[cur].emplace_back(i);
  }

  vector<int> ans(n, 0);
  for(auto itr = M_road.begin(); itr != M_road.end(); ++itr){
    auto ref = (*itr).second;
    map<int,int> M_cnt;
    for(auto node : ref){
      M_cnt[train.find_set(node)]++;
    }
    for(auto node:ref){
      ans[node] = M_cnt[train.find_set(node)];
    }
  }
  for(int i = 0;i < n;i++){
    if (i)cout <<"  ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 24576
// #define _GLIBCXX_DEBUG

#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <vector>
#include <chrono>
#include <cmath>

#define int long long

using namespace std;

int n, m, q;

vector<int> a;
vector<int> b;
vector<int> c;
vector<int> d;

int solve(int array[11], int index, int value) {
  if (index == n) {
    int score = 0;
    for (int i = 0; i < q; i++) {
      if (array[b[i]] - array[a[i]] == c[i]) {
        score += d[i];
      }
    }

    return score;
  }

  if (value > m) {
    return 0;
  }

  int ans = 0;

  for (int num = value; num <= m; num++) {
    array[index] = num;

    ans = max(ans, solve(array, index + 1, num));
  }

  return ans;
}

signed main() {
  cin >> n >> m >> q;

  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);

  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }

  int array[11] = { };
  cout << solve(array, 0, 1) << endl;

  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
using namespace std;
 
#define x first
typedef pair<int,int> pii;

typedef long long ll;
const int mod = 1000000007;
const int oo = 1e9;
const int base = 27;
const int N = 1001;

int n, a[N];

deque<pii> p;
ll res = -1e18;
vector<int> v1,v2,v;

int main() {
  cin >> n;
  ll a1 = 0 , a2 = 0;
  for (int i = 0; i < n; ++i)scanf("%d",a+i);
  for (int i = 0; i < n; ++i)p.push_back(make_pair(a[i],i));
  for (int i = 0; i < n; ++i){
    if(a[i]>0)
      if(i&1) a1 += a[i],v1.push_back(i);
      else a2 += a[i],v2.push_back(i);
  }
  if(!v1.size() && !v2.size()){
    for (int i = 0; i < n; ++i){
      if((i&1) == 1){
        if(!v1.size())v1.push_back(i),a1 = a[i];
        if(a[i] > a1){
          v1.clear(),v1.push_back(i);
          a1 = a[i];
        } 
      }else{
        if(!v2.size())v2.push_back(i),a2 = a[i];
        if(a[i] > a2){
          v2.clear(),v2.push_back(i);
          a2 = a[i];
        } 
      }
    }
  }
  res = max(a1,a2);
  if(res == a1)v = v1;
  else v = v2;

  vector<int> op;
  while(1){
    while(p.size() && p.front().second != v[0]){
      op.push_back(1);
      p.pop_front();
    }
    while(p.size() && p.back().second != v.back()){
      op.push_back(p.size());
      p.pop_back();
    }
    bool up = false;
    for(int i = 0 ; i < p.size(); i += 2){
      if(!binary_search(v.begin(),v.end(),p[i].second)){
        op.push_back(i+1);
        p.erase(p.begin()+(i-1));
        p.erase(p.begin()+(i-1));
        
        up = true;
        break;
      }
    }

    if(!up){
      while(p.size()>1){
        op.push_back(2);
        p.pop_front();
        p.pop_front();
      }
      break;
    }
  }
  printf("%lld\n", res);
  printf("%d\n",(int)op.size() );
  for(int i = 0 ; i < op.size();++i){
    printf("%d\n",op[i] );
  }

 // cout << ans.second.first << " " << ans.second.second << endl;
  return 0;
}

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

ll a[300][300],b[300][300];
int main(){
	int n;scanf("%d",&n);
	rep(i,n)rep(j,n){
		scanf("%lld",&a[i][j]);
		b[i][j]=a[i][j];
	}
	rep(k,n)rep(i,n)rep(j,n)b[i][j]=min(b[i][j],b[i][k]+b[k][j]);
	rep(i,n)rep(j,n){
		if(a[i][j]!=b[i][j]){
			puts("-1");
			return 0;
		}
	}
	ll cnt=0;
	rep(i,n)for(int j=i+1;j<n;j++)cnt+=b[i][j];
	rep(i,n)for(int j=i+1;j<n;j++){
		rep(k,n){
			if(i==k||j==k)continue;
			if(b[i][j]==b[i][k]+b[k][j]){
				cnt-=b[i][j];
				break;
			}
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 1664
#include <iostream>
 using namespace std;
 int main()
  { 
  	string x; 
  		cin >> x; 
  			if (x[5] - 48 == 0 && x[6] - 48 < 5) 
  				{ 	
  					if (x[8] -48 < 4) 	
  						{ 	
  							cout << "Heisei"; 
  								} 	
  								} 
  									else 
  										{ 	
  											cout << "TBD"; 	
  											} 
  											}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n;
    string s;
    cin>>n>>s;
    for(int i=0;i<s.size();i++){
        s[i]=((s[i]-'A'+n)%26)+'A';
    }
    cout<<s<<endl;
    return 0;
}

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

int main()
{
  int A,B;
  cin >> A >> B;
  if(A <= 5)
    cout << 0 << endl;
  else if(6 <= A && A <= 12)
    cout << B / 2 << endl;
  else
    cout << B << endl;
}

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

bool isOK(ll a, ll b, ll c){
    return (a+b > c && b+c >a && c+a > b);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll x,k,d; cin >> x >> k >> d;
    x = abs(x);
    ll q = x/d;
    if(k >= q+1){
        if((k-q)%2 == 0) cout << abs(x - d*q) << endl;
        else cout << abs(x -d*(q+1)) << endl;
    }else{
        cout << abs(x-d*k) << endl;
    }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin >>a>>b>>c;
  int sum = a * 10 + b + c;
  if(sum < b * 10 + a + c) sum = b * 10 + a + c;
  else if(sum < c * 10 + a + b) sum = c * 10 + a + b;
  cout <<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_N = 200010;
const int MOD = 1000000007;
typedef long long Int;

Int fac[MAX_N + 1];
Int inv[MAX_N + 1], ifac[MAX_N + 1];

Int comb(int n, int r)
{
  if (n < 0 || r < 0) return 0;
  if (n < r) return 0;
  Int ret = 1;
  ret = (ret * fac[n]) % MOD;
  ret = (ret * ifac[r]) % MOD;
  ret = (ret * ifac[n - r]) % MOD;
  return ret;
}

int main()
{
  int n, m, k;
  
  inv[1] = 1;
  fac[0] = ifac[0] = 1;
  fac[1] = ifac[1] = 1;
  for (int i = 2; i <= MAX_N - 1; i++) {
    fac[i] = (fac[i - 1] * i) % MOD;
    inv[i] = (inv[MOD % i] * (MOD - MOD / i)) % MOD;
    ifac[i] = ifac[i - 1] * inv[i] % MOD;
  }
  
  scanf("%d %d %d", &n, &m, &k);
  
  Int ans = 0;
  
  for (int i = 1; i <= m - 1; i++) {
    Int coef = (Int)n * n * (m - i) * i % MOD;
    ans = (ans + comb(n * m - 2, k - 2) * coef) % MOD;
  }
  
  for (int i = 1; i <= n - 1; i++) {
    Int coef = (Int)m * m * (n - i) * i % MOD;
    ans = (ans + comb(n * m - 2, k - 2) * coef) % MOD;
  }
  
  printf("%lld\n", ans);
  
  return 0;
}


Measured memory_bytes: 4864
/*
*
*	AUTHOR :- @soham01
*		// "WORK HARD AND NEVER GIVE UP" //
*
*/
#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define mp make_pair 
#define vi vector<long long int >
#define vb vector<bool>
#define vs vector<string>
#define vd vector<double>
#define vvi vector<vector<long long int> >
#define vp vector<pair<long long int , long long int > >
#define seti set<long long int >
#define setc set<char>
#define setd set<double>
#define mod 1000000009
#define endl '\n'
typedef long long int lli;

// ITS MY REQUEST TO PLEASE PLEASE DO LOOK AT THE CONSTRAINS GIVEN CAREFULLY
// DO CHECK FOR CORNER CASES

/*-------LET THE GAME BEGIN-----------*/

void solve()
{
	lli x,i,j,c=0,s=0;
	cin>>x;
	while(x!=0)
	{
		if(x%500==0)
		{
			x-=500;
			c++;
			//cout<<c<<"c"<<endl;
		}else if(x%5==0)
		{
			x-=5;
			s++;
		//	cout<<s<<"s"<<endl;
		}else{
			x-=1;
		}
	}
	cout<<c*1000 + s*5<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
		solve();
	return 0;
}




Measured memory_bytes: 384
import java.util.Scanner;
class Main{
    public static void main(String[] args){
		int a,b,d,r;
		double f;
		Scanner sc=new Scanner(System.in);
		a=sc.nextInt();
		b=sc.nextInt();
		d=a/b;
		r=a-b*d;
		f=(double)a/b;
		System.out.println(d+" "+r+" "+String.format("%.5f",f));
    }
}


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

int main(){
	int n;
	long long h[100005],dp[100005];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>h[i];
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
//const int MOD =  (int)1e9 + 7;
const int MOD =  998244353;
const double EPS = 1e-9;
 
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,M;
	cin>>N>>M;

	if(N%2==1)
	{
		int M1=(M+1)/2;
		int M2=M/2;

		rep(i,0,M1)
		{
			cout<<(i+1)<<" "<<(N/2-i+1)<<endl;
		}
		rep(i,0,M2)
		{
			cout<<(N/2+i+2)<<" "<<(N-i)<<endl;
		}
	}
	else
	{
		int M1=(M+1)/2;
		int M2=M/2;

		rep(i,0,M1)
		{
			cout<<(i+1)<<" "<<(N/2-i)<<endl;
		}
		rep(i,0,M2)
		{
			cout<<(N/2+i+1)<<" "<<(N-1-i)<<endl;
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b)
{
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}

int main(){
  int N;
  cin >> N;
  int b[N];
  rep(i,N-1){
    cin >> b[i];
  }
  int ans = (b[0] + b[N-2]);
  //cout << ans << endl;
  rep(i,N-2){
    ans += min(b[i],b[i+1]);
  }
  cout << ans  << endl;
}




Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define IREP(i, v) for(auto i = (v).begin(); i != (v).end(); ++i)
#define IRREP(i, v) for(auto i = (v).rbegin(); i != (v).rend(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const ll LINF = 1000000000000000000; // 1e18
const double EPS = 1E-10;

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


int main(){
    int N, m(998244353); cin >> N;
    VI D(N), cnt(N, 0);
    REP(i, N){
        cin >> D[i];
        if(!!i ^ !!D[i]){
            cout << 0 << endl;
            return 0;
        }
        ++cnt[D[i]];
    }
    ll ans(1);
    FOR(i, 1, N){
        ans = ans * cnt[D[i] - 1] % m;
        if(ans < 0) ans += m;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024