akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

vector<vector<pll>> edges(220000);

struct Seg{
  vector<ll>mx, sum;
  Seg(){
    mx.resize(1<<19);
    sum.resize(1<<19);
  }

  void add(ll l, ll r, ll score, ll pos=1, ll bottom=0, ll top=1<<18){
    if(top <= l || r <= bottom)return;
    if(l <= bottom && top <= r){ sum[pos] += score;return; }

    ll mid = (bottom + top)/2;
    add(l, r, score, pos*2, bottom, mid);
    add(l, r, score, pos*2+1, mid, top);
    mx[pos] = max<ll>(mx[pos*2]+sum[pos*2], mx[pos*2+1]+sum[pos*2+1]);
  }

  ll mxv(ll l, ll r, ll pos=1, ll bottom = 0, ll top = 1<<18){
    if(top <= l || r <= bottom)return -INF;
    if(l<=bottom && top <= r)return mx[pos]+sum[pos];

    ll mid = (bottom + top)/2;
    return max<ll>(
      mxv(l,r, pos*2, bottom, mid),
      mxv(l,r, pos*2+1, mid, top)
    )+sum[pos];
  }
};

int main(){
  ll n,m;cin>>n>>m;
  rep(i, m){
    int l,r,a;cin>>l>>r>>a;
    edges[r].push_back({l, a});
  }

  Seg seg;

  rep1(r, n){
    ll mx = seg.mxv(0,r);
    for(auto p: edges[r]){
      ll l = p.first;
      ll a = p.second;
      seg.add(l, r+1, a);
    }
    seg.add(r, r+1, mx);
  }

  cout<<seg.mxv(0, n+1)<<endl;

  return 0;
}

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

int main() {
  int N,X; cin >> N >> X;
  int count = 0;
  int rest = X;
  int m[N]; for(int i=0;i<N;i++){
    cin >> m[i];
    count += 1;
    rest -= m[i];
  }
  sort(m,m+N);
  count += rest/m[0];
  cout << count << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1e18 + 10;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
    int n; cin >> n;
    vector<ll> V(n, -1); cin >> V[0];
    

    rept(i, 1, n){
        int a; cin >> a;
        int ng = -1, ok = n;
        while(ok - ng > 1){
            int mid = (ng + ok) / 2;
            if(V[mid] < a) ok = mid;
            else ng = mid;
        }
        V[ok] = a;
    }
    int res = 0;
    rep(i, n){
        if(V[i]==-1)break;
        res++;
    } 
    cout << res << ln;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LLINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

const int MAX = 100010;
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;
}

int main() {
	COMinit();
	int n, k; cin >> n >> k;
	VI a(n); REP(i, n)cin >> a[i];
	sort(ALL(a), greater<ll>());
	ll ans = 0;
	REP(i, n - k + 1) {
		ans += (a[i] * COM(n - i - 1, k - 1)) % MOD;
		ans %= MOD;
	}
	reverse(ALL(a));
	REP(i, n - k + 1) {
		ans -= (a[i] * COM(n - i - 1, k - 1)) % MOD;
		if (ans < 0)
			ans += MOD;
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> vec(3);
  int no5=0,no7=0;
  for( int i=0;i<3 ;i++){
    cin >> vec.at(i);
    if( vec.at(i)==5)
      no5++;
    if( vec.at(i)==7)
      no7++;
  }
    if(no5==2 && no7==1) 
  cout << "YES" << endl;
  else
  cout << "NO" << endl;
        
}   

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

using ll = long long;
//typedef long long ll;

#define INF (1LL << 31 - 1)
#define INFLL ((1LL << 62) - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) for (int i = n; i >= 0; --i)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()

int vx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, vy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

inline bool check(int ux, int uy, int x, int y) {
  return (0 <= x and x < ux and 0 <= y and y < uy);
}

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int n, m, a, b, c;
int g[101][101], d[101][101];

int main() {
  init();
  cin >> n >> m;
  memset(d, 0x3f, sizeof d);
  memset(g, 0x3f, sizeof g);
  rep(i,n) d[i][i] = 0;
  rep(i,m) {
    cin >> a >> b >> c;
    a--, b--;
    g[a][b] = g[b][a] = c;
    d[a][b] = d[b][a] = c;
  }
  rep(k,n) rep(i,n) rep(j,n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

  int ans = 0;

  rep(i,n) {
    repi(j,i+1,n) {
      bool f = true;

      rep(k,n) {

        if (i != k and j != k and d[i][j] >= d[i][k] + d[k][j] and g[i][j] != 0x3f3f3f3f and g[i][j] > d[i][j]) {
          f = false;
          break;
        }
      }

      if (!f) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=4999999996000000001;


int main(){
    int n;
    cin>>n;
    int ac=0,wa=0,tle=0,re=0;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s=="AC") ac++;
        if(s=="WA") wa++;
        if(s=="TLE") tle++;
        if(s=="RE") re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}

Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ul unsigned long long int
#define vi vector<int>
#define vl vector<int64_t>
#define all(x) x.begin(),x.end()
#define pb push_back
#define fo(x,a,b) for(int x=a; x<b; x++)
#define rfo(x,a,b) for(int x=a; x>=b; x--)
#define fi first
#define sec second
#define mp make_pair
int sgn(int x) { return x>0 ? 1 : ( x<0 ? -1 : 0); }
typedef pair<int,int> pairs;
double pi = 3.14159265358979323846;
ll mod = 1000000007;

void solve()
{
    ll ans=0,n;
    cin>>n;
    vi a(n);
    fo(i,0,n) cin>>a[i];
    ll su=a[n-1];
    rfo(i,n-2,0)
    {
        ans=(ans+su*a[i]%mod)%mod;
        su=(su+a[i])%mod;
    }
    cout<<ans;
    cout<<"\n";
    return;
}
int main()
{
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    //cin>>t;
    //while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3972
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x, y;
		while (true) {
			x = sc.nextInt();
			y = sc.nextInt();
			if (x == 0 && y == 0)
				break;
			else if (x < y)
				System.out.println(x + " " + y);
			else {
				System.out.println(y + " " + x);
			}
		}
	}
}


Measured memory_bytes: 34984
#include <stdio.h>

int main(void)
{
  int H,W,i,j;
  
  while(1)
  {
    scanf("%d %d",&H,&W);
    
    if(H == 0 && W == 0) break;
    
    for(i = 0; i < H; i++)
    {
      for(j = 0; j < W; j++)
      {
        if(i == 0 || i == (H - 1))
        {
          putchar('#');
        }
        else if(j == 0 || j == (W - 1))
        {
          putchar('#');
        }
        else
        {
          putchar('.');
        }
      }        
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

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

const long long MOD = 1000000007;
const long long MAX = 2000000;

template <typename T> T gcd(T a, T b) { return b != 0 ? gcd(b, a % b) : a; }

template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }



int main() {
	long long N;
	cin>>N;
	string S;
	cin>>S;
	int left=0;
	int right=S.size()-1;
	int cnt=0;
	while(left<right){
		while(S[left]=='R'){
			left++;
			if(left>=right){
				break;
			}
		}
		if(left>=right){
			break;
		}
		while(S[right]=='W'){
			right--;
			if(left>=right){
				break;
			}
		}
		if(left>=right){
			break;
		}
		char l=S[left];
		S[left]=S[right];
		S[right]=l;
		cnt++;

	}
	cout<<cnt<<endl;



}


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

int main() {
  int N, A;
  cin >> N >> A;

  N = N - N / 500 * 500;
  if(N <= A) cout << "Yes" << endl;
  else cout << "No" << endl;
  // ここにプログラムを追記
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

mx,mxc = 0,0
mn,mnc = 1000000,0
for i in a:
    if mx == i:
        mxc += 1
    if mn == i:
        mnc += 1
    if mx < i:
        mx = i
        mxc = 1
    if mn > i:
        mn = i
        mnc = 1

d = mx-mn


if d > 1:
    print('No')
elif d == 1:
    if mx > mnc and 2*(mx-mnc) <= mxc:
        print('Yes')
    else:
        print('No')
elif d == 0:
    if a[0] == n-1 or 2*a[0] <= n:
        print('Yes')
    else:
        print('No')

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF (1 << 30)

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

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

#define min(a,b) ((a<b)?a:b)
#define max(a,b) ((a>b)?a:b)

int main()
{
    char s[5];
    gets(s);
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
    {
        printf("Bad");
    }
    else
    {
        printf("Good");
    }
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(Usize1, Usize1); m],
    };
    let mut e = vec![vec![]; n];
    for &(a, b) in ab.iter() {
        e[a].push(b);
        e[b].push(a);
    }

    let mut ans = vec![n; n];
    let mut sp = vec![n; n];
    let mut pq = std::collections::BinaryHeap::new();
    pq.push(std::cmp::Reverse((0, 0, 0)));
    while let Some(std::cmp::Reverse((c, u, p))) = pq.pop() {
        if c > sp[u] {
            continue;
        }
        sp[u] = c;
        ans[u] = p;
        for &v in e[u].iter() {
            if c + 1 < sp[v] {
                sp[v] = c + 1;
                ans[v] = u;
                pq.push(std::cmp::Reverse((c + 1, v, u)));
            }
        }
    }

    println!("Yes");
    for i in 1..n {
        println!("{}", ans[i] + 1);
    }
}


Measured memory_bytes: 19156
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll mod = 1000000007;

vector<ll> n_tot, n_p;
ll rec(ll n,ll x)
{
	if(n==0 && x==1)return 1;
	if(x==0 || x==1)return 0;
	else if(x <= 1+n_tot[n-1]) return rec(n-1,x-1);
	else if(x==2+n_tot[n-1]) return n_p[n-1]+1;
	else if(x < n_tot[n])return n_p[n-1]+1+rec(n-1,x-n_tot[n-1]-2);
	else return n_p[n];
}

void solve()
{
	int n; cin >> n;
	ll x; cin >> x;
	n_tot.resize(n+1);
	n_p.resize(n+1);
	rep(i, n+1)n_tot[i]=((4LL<<i)-3);
	rep(i, n+1)n_p[i]=((2LL<<i)-1);
	ll ans = rec(n,x);
	cout << ans << endl;
	return;	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    xorR = 0
    for i in range(2, N):
        xorR ^= A[i]
    rbit = [0] * 41
    K = xorR
    for i in range(41):
        rbit[i] = K % 2
        K //= 2
    
    D = A[0] + A[1] - xorR
    if D < 0 or D % 2 == 1:
        print(-1)
        return 0
    else:
        D //= 2
        if D > A[0]:
            print(-1)
            return 0

        K = D
        dbit = [0] * 41
        for i in range(41):
            dbit[i] = K % 2
            K //= 2
            
        A0 = D
        for i in range(41):
            if rbit[40 - i] == dbit[40 - i] and rbit[40 - i] == 1:
                print(-1)
                return 0
            else:
                if rbit[40 - i] == 1:
                    if A0 + pow(2, 40 - i) <= A[0]:
                        A0 += pow(2, 40 - i)
        if A0 > 0: print(A[0] - A0)
        else: print(-1)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9272
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Stack;

public class Main {
    static int ans = Integer.MAX_VALUE;
    static char[][]maze;
    static int[]X = new int[]{0,1,0,-1};
    static int[]Y = new int[]{1,0,-1,0};
    static boolean[][]find;
    static int h,w,c1,c2,d1,d2;
    static boolean findAns = false;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        h = sc.nextInt();
        w = sc.nextInt();
        c1 = sc.nextInt() - 1;
        c2 = sc.nextInt() - 1;
        d1 = sc.nextInt() - 1;
        d2 = sc.nextInt() - 1;
        maze = new char[h][w];
        find = new boolean[h][w];
        for(int i = 0;i < maze.length;i++){
            String a = sc.next();
            maze[i] = a.toCharArray();
        }
        LinkedList<int[]> stack = new LinkedList<>();
        dfs(c1,c2,stack,0);
        int count = 1;
        while (!stack.isEmpty() && ans == Integer.MAX_VALUE){
            int size = stack.size();
            for (int z = 0; z < size; z++) {
                int[] pop = stack.pollFirst();
                if(pop[0] >= 0 && pop[0] < maze.length && pop[1] >= 0 && pop[1] < maze[0].length){
                    int newX = pop[0] - 2;
                    int newY = pop[1] - 2;
                    for(int i = newX;i < newX + 5;i++){
                        for(int j = newY;j < newY + 5;j++){
                            if(i >= 0 && i < maze.length && j >= 0 && j < maze[0].length){
                                if(!find[i][j] && maze[i][j] != '#'){
                                    dfs(i,j,stack,count);
                                }
                            }
                        }
                    }
                }
            }
            count++;
        }
        if(ans == Integer.MAX_VALUE)
            System.out.println(-1);
        else
            System.out.println(ans);
    }
    private static void dfs(int beg,int end,LinkedList<int[]>queue,int count){
        if(!(beg >= 0 && beg < maze.length && end >= 0 && end < maze[0].length)){
            return;
        }
        if(find[beg][end] || maze[beg][end] == '#')
            return;
        find[beg][end] = true;
        if(beg == d1 && end == d2){
            ans = Math.min(count,ans);
            findAns = true;
        }
        queue.addLast(new int[]{beg,end});
        for(int i = 0;i < 4;i++){
            int newX = beg + X[i];
            int newY = end + Y[i];
            dfs(newX,newY,queue,count);
        }
    }
}


Measured memory_bytes: 58020
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		//int c=scan.nextInt();
		//int d=scan.nextInt();
		//int f=scan.nextInt();
		//String str=scan.next();
		boolean bool=false;
		int ans=0;
		System.out.println(a-b+1);
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<cmath>
#include<stdio.h>
#include <ctype.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<deque> //<< fixed << setprecision()
#include<queue> //priority_queue
#include<vector>
typedef long long ll;
using namespace std;
const double pi = (2 * acos(0));


struct point
{
	long double x, y;
};
double area(int x1, int y1, int x2, int y2, int x3, int y3)
{
	double a = (x2*y3) - (x3*y2) - (x1*y3) + (x3*y1) + (x1*y2) - (x2*y1);
	a /= 2;
	return fabs(a);
}

long double anyarea(point p[], int n)
{
	long double sum1 = p[n - 1].x * p[0].y, sum2 = p[n - 1].y * p[0].x;
	for (int i = 0; i < n - 1; i++)
	{
		sum1 += p[i].x * p[i + 1].y;
		sum2 += p[i].y * p[i + 1].x;
	}
	return  fabs((sum1 - sum2) * 0.5);
}

ll fastpow(ll base, ll p, ll m)
{
	if (p == 0)
		return 1;
	ll ans = fastpow(base, p / 2, m);
	ans = ((ans%m)*(ans%m)) % m;
	if (p % 2)
		ans = ((base%m)*ans) % m;
	return ans;
}
ll GCD(ll M, ll m)
{
	if (M%m == 0)
		return m;
	M %= m;
	ll x1 = M, x2 = m;
	m = min(x1, x2);
	M = max(x1, x2);
	return GCD(M, m);


}
ll lcm(ll M, ll m)
{
	return (M*m) / GCD(max(M, m), min(M, m));

}


	
int n, h[100006], ans[100006],k;
int solve(int ind)
{
	if (ind == n - 1)
		return 0;
	if (ind >= n)
		return 1e9;
	if (ans[ind] != -1)
		return ans[ind];
	int m = 1e9;
	for (int i = 1; i <= k&&i+ind<=n-1; i++)
	{
		m=min(solve(ind + i)+abs(h[ind]-h[i+ind]), m);
	}
	return ans[ind]=m;
}


int main()
	{
	cin >> n >> k;
	for (int i = 0; i< n; i++)
	{
		cin >> h[i];
		ans[i] = -1;
	}
	cout << solve(0);
	}

Measured memory_bytes: 5760
N = int(input())
V = list(map(int, input().split()))
odd_dict = {}
even_dict = {}
for i in range(N):
    if i % 2 == 0:
        if odd_dict.get(V[i]) is None:
            odd_dict[V[i]] = 1
        else:
            odd_dict[V[i]] += 1
    else:
        if even_dict.get(V[i]) is None:
            even_dict[V[i]] = 1
        else:
            even_dict[V[i]] += 1

odd_dict_sorted = sorted(odd_dict.items(), key=lambda a: a[1])
even_dict_sorted = sorted(even_dict.items(), key=lambda a: a[1])

odd_dict_max = odd_dict_sorted.pop()
even_dict_max = even_dict_sorted.pop()
if odd_dict_max[0] == even_dict_max[0] and N // 2 == odd_dict_max[1]:
    ans = N // 2
elif odd_dict_max[0] == even_dict_max[0]:
    odd_dict_max_t = odd_dict_sorted.pop()
    even_dict_max_t = even_dict_sorted.pop()
    ans = N - odd_dict_max[1] - max(even_dict_max_t[1],odd_dict_max_t[1])
else:
    ans = N - odd_dict_max[1] - even_dict_max[1]
print(ans)


Measured memory_bytes: 25800
#include <stdio.h>
 
int main(void){
  int i,j,k,n,m,l,a[100][100],b[100][100];
  long int s;
  scanf("%d%d%d",&n,&m,&l);
 
//行列A
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);
 
//行列B
  for(i=0;i<m;i++)
    for(j=0;j<l;j++)
      scanf("%d",&b[i][j]);
 
//行列C
  for(i=0;i<n;i++)
    for(j=0;j<l;j++){
      s = 0;
      for(k=0;k<m;k++)
        s += a[i][k] * b[k][j] ;
      printf("%ld", s);
      if(j+1 == l)
        printf("\n");
      else
        printf(" ");
    }
 
  return 0;
}


Measured memory_bytes: 2148
A,B,C,X,Y = map(int,input().split())

ab1 = A + B
ab1c = C*2
ans = 0
if ab1 > ab1c:
    mi = min(X,Y)
    for i in range(mi):
        ans += C*2

    if X > Y:
        for i in range(X-Y):
            ans += A
    else:
        for i in range(Y-X):
            ans += B
else:
    for i in range(X):
        ans += A
    for i in range(Y):
        ans += B

t = 0
ma = max(X,Y)
for i in range(ma):
    t +=C*2

if t < ans:
    print(t)
    exit()

print(ans)


Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;

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

fn parse_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let line = parse_line::<String>();
    let mut iter = line.split_whitespace();
    (
        iter.next().unwrap().parse().ok().unwrap(),
        iter.next().unwrap().parse().ok().unwrap(),
    )
}

fn parse_line_vec<T: FromStr>() -> Vec<T> {
    let line = parse_line::<String>();
    line.split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn println<T: ToString>(s: T) {
    println!("{}", s.to_string());
}

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

fn main() {
    let (n, x) = parse_pair::<usize, usize>();
    let l = parse_line_vec::<usize>();

    let mut acc = 0;

    for i in 0..n {
        let next = acc + l[i];
        if next > x {
            println(i + 1);
            return;
        }
        acc = next;
    }

    println(n + 1);
}


Measured memory_bytes: 4352
import numpy as np
N,M,Q = map(int,input().split())
c = [[0]*(N+1) for i in range(N+1)]
for i in range(M):
    l,r = map(int,input().split())
    c[l][r] += 1
c = np.cumsum(np.cumsum(c,axis=0),axis=1)
for i in range(Q):
    p,q = map(int,input().split())
    print(c[q][q]-c[q][p-1]-c[p-1][q]+c[p-1][p-1])


Measured memory_bytes: 18260
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	string s; cin >> s;
	int k = s.size();
	int cnt = 15 - k;
	for (char x : s)
	{
		if (x == 'o')++cnt;
	}
	if (cnt < 8)cout << "NO" << endl;
	else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,x,n) for (int i = x; i < n; i++)
using ll = long long int;
int main() {
    ll N;
    cin >> N;
    ll ans=0;
    rep2(i,1,N+1) {
        ll X = N/i;
        ans += X*(X+1)*i/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

A, B, C, D = map(int, input().split())

B_C = B // C
B_D = B // D
B_C_D = B // lcm(C, D)

A_C = (A - 1) // C
A_D = (A - 1) // D
A_C_D = (A - 1) // lcm(C, D)

B_div = B_C + B_D - B_C_D
A_div = A_C + A_D - A_C_D



print(B - A + 1 - (B_div - A_div))


Measured memory_bytes: 5076
#include <iostream>
using namespace std;
int main(void){
    int N,sum = 0;
    cin >> N;
    int d[N];
    for(int i = 0;i < N;i++){
        cin >> d[i];
    }
    for(int i = 0;i < N;i++){
        if(d[i] == 0)continue;
        for(int j = i + 1;j < N;j++){
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
  gearup;
  int n; cin >> n;
  n %= 10;
  if(n==1 || n == 0 || n == 6 || n==8)out("pon");
  else if(n==3)out("bon");
  else out("hon");
}

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

int main() {
  string s;
  cin >> s;
  bool ans = true;
  rep(i, s.size() - 1) {
    if (s.at(i) == s.at(i + 1)) ans = false;
  }
  if (ans == true) cout << "Good" << endl;
  else cout << "Bad" << endl;
}

Measured memory_bytes: 256
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e10;
const double EPS=1e-8;
const ll mod = 1000000007;
int main(){
	ll n;
	cin>>n;
	vector<ll> a;
	for(ll i1=0;i1<n;i1++){
		ll temp;
		cin>>temp;
		a.push_back(temp);
	}
	vector<ll> ball;
	ball.resize(n,0);
	ball[n-1]=a[n-1];
	ll count_ball = 0;
	if(ball[n-1]==1){
		count_ball++;
	}
	for(ll i1=n-2;i1>=0;i1--){
		ll multiplier = i1+1;
		//count already decided
		ll sum=0;
		for(ll i2=((n/multiplier)*multiplier);i2>multiplier;i2-=multiplier){
			sum += ball[i2-1];
		}
		if(sum%2==a[i1]){
			ball[i1]=0;
		}else{
			ball[i1]=1;
			count_ball++;
		}
	}
	cout<<count_ball<<endl;
	for(ll i1=0;i1<n;i1++){
		if(ball[i1]==1){
			cout<<i1+1<<" ";
		}
	}
	cout<<endl;
}


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

//Constants
const long long INF = std::numeric_limits<long long>::max();
const long long MOD = 1e9 + 7;
const long double PI = 3.141592653589793;

//MACROS
#define pb push_back
#define fi first
#define se second
#define rep(i, begin, end) for (int i = (begin); i < (end); i++)
#define per(i, begin, end) for (int i = (begin) - 1; i >= (end); i--)
typedef long long LL;
typedef pair <int,int> PII;

vector <int> g[5000];
int n, k;

int dive(int u, int p, int d) {
    int cnt = (d > k/2);
    for (auto v : g[u]) {
        if (v == p) continue;
        cnt += dive(v,u,d+1);
    }
    return cnt;
}

int u[5000], v[5000], ans = (1<<30);

int main() {
	cin >> n >> k;
    rep(i,0,n-1) {
        cin >> u[i] >> v[i];
        u[i]--, v[i]--;
        g[u[i]].pb(v[i]);
        g[v[i]].pb(u[i]);
    }

    if (k%2) {
        rep(i,0,n-1) {
            int cur = dive(u[i],v[i],0) + dive(v[i],u[i],0);
            ans = min(ans,cur);
        }
    } else {
        rep(i,0,n) {
            int cur = dive(i,-1,0);
            ans = min(ans,cur);
        }
    }
    cout << ans;
}


Measured memory_bytes: 640
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn readu() -> usize {
    read::<usize>()
}

#[allow(dead_code)]
fn readi() -> i32 {
    read::<i32>()
}

fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut ans: f64 = 0 as f64;
    let mut p: [f64; 27] = [0.0; 27];
    p[0] = 1.0;
    for i in 0..24 {
        p[i + 1] = p[i] * 0.5;
    }
    for i in 1..(n + 1) {
        for j in 0..25 {
            if (i << j) >= k {
                let v: f64 = 1f64 / (n as f64) * 0.5f64.powi(j);
                ans += v;
                break;
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define MAX_N 5005
struct data{
  int l,r;
  bool operator < (const data &p)const{ 
    return ( l == p.l ? r > p.r : l < p.l );
  }
};

int N,M,ans;
vector<data> T[MAX_N];

void calc(vector<data> &a,vector<data> &b){
  vector<data> tmp;
  sort(a.begin(),a.end());
  
  a.push_back((data){MAX_N,MAX_N-1});
  for(int i=1;i<(int)a.size();i++){
    if(a[i].r<=a[i-1].r)a[i]=a[i-1];
    else tmp.push_back(a[i-1]);
  }
  
  for(int i=1;i<(int)a.size();i++){
    if(a[i].l<=a[i-1].r+1){
      a[i].l=a[i-1].l;
      a[i].r=max(a[i].r,a[i-1].r);
    }else ans+=(a[i-1].r-a[i-1].l+1);
  }

  for(int i=0;i<(int)tmp.size();i++){
    tmp[i].r--;
    if(tmp[i].r<tmp[i].l)continue;
    b.push_back(tmp[i]);
  }
}

int main(){
  cin>>N>>M;
  for(int i=0;i<M;i++){
    int a,b,c;
    cin>>a>>b>>c;
    T[a+c].push_back((data){b,b+c});
  }
  ans=0;
  for(int i=N;i>=1;i--)calc(T[i],T[i-1]);
  cout<<ans<<endl;
  return 0;
}

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

int main() {
   int A,B;
   cin >> A >> B;
  bool flag = true;
  for(int C = 1; C<=3;C++){
    if(A*B*C %2 != 0){
      cout << "Yes" << endl;
      flag = false;
      break;
    }
  }
  if(flag) cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

int ans = 111, N;

int main(void) {
    scanf("%d", &N);

    while (1) {
    	if (ans >= N) break;
    	ans += 111;
    }
    
    printf("%d\n", ans);

	return 0;
}


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

#define MAX_N 100291

int isntPrime[ MAX_N + 1 ] = { 1, 1, 0 };

void quickSort( int *, int, int );
int median( int, int, int );
void insertionSort( int *, int );

int main( void ) {
	int i, j, N, P, cnt, p[ 22 ], sum[ 253 ];

	for ( i = 4; i <= MAX_N; i += 2 )
		isntPrime[ i ] = 1;

	for ( i = 3; i * i <= MAX_N; i += 2 )
		if ( !isntPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isntPrime[ j ] = 1;

	for ( ; scanf( "%d %d", &N, &P ), N != -1; printf( "%d\n", sum[ P - 1 ] ) ) {
		cnt = 0;
		for ( i = N + 1; cnt < 22; i++ )
			if ( !isntPrime[ i ] )
				p[ cnt++ ] = i;

		cnt = 0;
		for ( i = 0; i < 22; i++ )
			for ( j = i; j < 22; j++ )
				sum[ cnt++ ] = p[ i ] + p[ j ];

		quickSort( sum, 0, 176 );
	}

	return 0;
}

void quickSort( int *data, int l, int r ) {
	if ( l < r ) {
		int i = l, j = r, pivot = median( data[ i ], data[ ( i + j ) / 2 ], data[ j ] ), tmp;

		while ( 1 ) {
			for ( ; data[ i ] < pivot; i++ ) ;
			for ( ; pivot < data [ j ]; j-- ) ;
			if ( i >= j )
				break;

			tmp = data[ i ];
			data[ i ] = data[ j ];
			data[ j ] = tmp;

			i++;
			j--;
		}

		if ( i - l < 20 )
			insertionSort( data + l, i - l );
		else
			quickSort( data, l, i - 1 );

		if ( r - j < 20 )
			insertionSort( data + j + 1, r - j );
		else
			quickSort( data, j + 1, r );
	}
}

int median( int x, int y, int z ) {
	if ( x < y )
		if ( y < z )
			return y;
		else if ( z < x )
			return x;
		else
			return z;
	else if ( z < y )
		return y;
	else if ( x < z )
		return x;
	else
		return z;
}

void insertionSort( int *data, int n ) {
	int i, j, tmp;

	for ( i = 1; i < n; i++ ) {
		tmp = data[ i ];

		for ( j = i; j && data[ j - 1 ] > tmp; j-- )
			data[ j ] = data[ j - 1 ];

		data[ j ] = tmp;
	}
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc, char *argv[])
{
    double a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << a * b / 2 << endl;
    if (a / 2 == c && b / 2 == d)
        cout << 1 << endl;
    else
        cout << 0 << endl;

    return 0;
}

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

ans = 0
ten = 1
d = 0
cntlist = [0]*2019
cntlist[0] = 1
for i in range(n-1,-1,-1): #ステップ指定必要
    a = int(s[i])*ten%2019
    d = (d + a)%2019
    ten *= 10
    ten %= 2019
    cntlist[d] += 1

for cnt in cntlist:
    ans += cnt*(cnt-1)//2

print(ans)

Measured memory_bytes: 9312
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define f(i,x,z) for(int i=x;i<z;i++)
#define debug(x) cout<<"DEBUG------> "<<x<<endl
#define endl "\n"

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   long long a=0,b;
   
   cin>>a;
   b=a+(a*a)+pow(a,3);
   cout<<b;

  	return 0;
		
}

Measured memory_bytes: 4020
#include<iostream>
using namespace std;
#define ll long long
int main(){
  ll N,M=0;
  ll i,j;
  ll tmp;
  cin >> N;
  ll a[N+1],b[N+1];
  for(i=1;i<=N;i++){
    cin >> a[i];
    b[i]=0;
  }
  for(i=N;i>0;i--){
    tmp=0;
    j=i;
    while(j<=N){
      tmp=(tmp+b[j])%2;
      j+=i;
    }
    b[i]=(tmp+a[i])%2;
    if(b[i]==1)M++;
  }
  cout << M << endl;
  for(i=1;i<=N;i++){
    if(b[i]==1)cout << i << " ";
  }
  return 0;
}

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

using namespace std;

int main(void) {

  int H, W, N;
  cin >> H >> W >> N;

  int sr, sc;
  cin >> sr >> sc;

  int Pos[4], Lim[4];
  Pos[0] = sr - 1;
  Pos[1] = sc - 1;
  Pos[2] = W - sc;
  Pos[3] = H - sr;
  Lim[0] = H;
  Lim[1] = W;
  Lim[2] = W;
  Lim[3] = H;

  string S, T;
  cin >> S >> T;

  for (int i = 0; i < N; i++) {
    
    Pos[S[i]%5]--;
    if (Pos[S[i]%5] < 0) {
      cout << "NO" << endl;
      return 0;
    }

    if (Pos[(T[i]%5)^3]+1 != Lim[(T[i]%5)^3]) {
      Pos[(T[i]%5)^3]++;
    }
  }

  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 776
fun main(args: Array<String>) = p6()

fun p6() {
    val n = readLine()!!.toInt()
    val s = readLine()!!.map { it.toString() }

    val indexOfFirsts = (0..9).map { i -> s.indexOfFirst { it == i.toString() } }
    val indexOfLasts = (0..9).map { i -> s.indexOfLast { it == i.toString() } }
    val set = mutableSetOf<String>()
    var answer = 0

    for (leftNumber in 0..9) for (middleNumber in 0..9) for (rightNumber in 0..9) {
        val leftIndex = indexOfFirsts[leftNumber]
        val rightIndex = indexOfLasts[rightNumber]
        if (leftIndex in s.indices && rightIndex in s.indices && leftIndex + 1 < rightIndex) {
            if (s.slice(leftIndex + 1..rightIndex - 1).contains(middleNumber.toString()))
                answer++
        }
    }

    println(answer)
}


Measured memory_bytes: 72792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
#define sort(a) sort(a.begin(),a.end());
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define F first
#define S second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl "\n"
#define TC cin>>t;while(t--)
const ll MOD = 1e9+7;
const ld PI = 3.1415926535898;
const ll LLMAX = LLONG_MAX;

int main()
{
    int n,m;
    cin>>n>>m;
    int a[m];
    int s=0;
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    if(n>=s)cout<<n-s<<nl;
    else
        cout<<-1<<nl;

}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>x>>y;
      Cout((x-1)*(y-1));
     

       
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,n) for(int i=a;i<n;i++)
#define ps(x) cout<<x<<" "
#define pn(x) cout<<x<<"\n"
#define sz(a) int((a).size())
#define pb push_back
typedef vector< int > vi;
typedef pair< int,int > pairs;

int main()
{
    ll s,w;
    cin>>s>>w;
    if(w>=s)    pn("unsafe");
    else    pn("safe");
}

Measured memory_bytes: 3596
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scanf("%d %d\n", &a, &b)

	if (a+b)%3 == 0 || a%3 == 0 || b%3 == 0 {
		fmt.Println("Possible")
	} else {
		fmt.Println("Impossible")
	}
}

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

int main(){
	char str[100], c[1];
	int i, j, len, n;
	
	while(scanf("%s", str) != EOF){
		len = strlen(str);
		for(i = 0; i < len; i++){
			if(str[i] == '@'){
				c[0] = str[i+2];
				n = str[i+1] - '0';
				for(j = 0; j < n; j++){
					cout << c[0];
				}
				i += 2;
			}else {
				cout << str[i];
			}
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1148
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

vector<int> v;

int main(void){
	int n,i,m;
	cin >> n;
	for(i=0; i<20; ++i){
		if(n==(1<<i)){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	for(i=1; i<4; ++i){
		v.push_back(i);
	}
	for(i=1; i<4; ++i){
		v.push_back(i+n);
	}
	for(i=4; i+3<=n; i+=4){
		v.push_back(i);
		v.push_back(i+1);
		v.push_back(i+2);
		v.push_back(i+3);
		v.push_back(i+n);
		v.push_back(i+n+1);
		v.push_back(i+n+2);
		v.push_back(i+n+3);
	}
	m = (n/4)*4;
	if(0 < n%4 && n%4 < 3){
		cout << n+m << " " << n+m+1 << endl;
		cout << n+m+1 << " " << 1 << endl;
		cout << 1 << " " << m << endl;
		cout << m << " " << m+1 << endl;
		if(n%4 == 2){
			cout << n+m+1 << " " << n+m+2 << endl;
			cout << m+2 << " " << 2 << endl;
		}
	}else if(n%4==0){
		cout << ((m-4)^m) << " " << (m-4) << endl;
		cout << ((m-4)^m) << " " << n << endl;
		cout << (m-4) << " " << n+n << endl;

	}
	for(i=(v.l_ength()-1); i>0; --i){
		if(n%4==0 && v[i]==(m-4)){
			continue;	
		}
		cout << v[i] << " " << v[i-1] << endl;
	}
	return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
typedef pair<int,int> pii;
vector<int>g[N];
int n,k;
vector<int>dist(N,INT_MAX),vis(N,0);
int main()
{ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<n;i++){
        int u,v;cin>>u>>v;g[u].push_back(v);g[v].push_back(u);
    }
    cin>>k;
    priority_queue<pii,vector<pii>,greater<pii>>pq;
    if(k==0){
        vis[1]=1;dist[1]=1;pq.push({1,1});
    }
    while(k--){
        int u,v;cin>>u>>v;vis[u]=1;dist[u]=v;
        pq.push({v,u});
    }
    bool can=1;
    while(!pq.empty()){
        int u=pq.top().second;pq.pop();
        for(auto v:g[u]){
            if(!vis[v]){
                vis[v]=1;
                dist[v]=dist[u]+1;
                pq.push({dist[v],v});
            }
            else if(abs(dist[v]-dist[u])!=1)can=0;
        }
    }
    if(can==0){
        cout<<"No"<<endl;
    }else{
         cout<<"Yes"<<endl;
         for(int i=1;i<=n;i++)cout<<dist[i]<<'\n';
    }
    return 0;
}


Measured memory_bytes: 10856
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


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;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

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


int main() {
    ll a;
    cin >> a;
    vector<ll> z(a);
    int r = 3;
    for (int i = 0; i < a; i++) {
        cin >> z.at(i);
        if (z.at(i) == 0)r = 0;
    }
    if (r == 0) {
        cout << 0 << endl;
    }
    else {
        ll ans = 1;
        for (int i = 0; i < a; i++) {
            if (1000000000000000000 / z.at(i) < ans) {
                ans = -1;
                break;
            }
            ans *= z.at(i);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 4052
#include <iostream>

#define SIZE 100

using namespace std;

struct Card {
	char suit;
	int rank;
};

void bubbleSort(int, Card[]);
void selectionSort(int, Card[]);

int main(void) {
	int n;
	Card list1[SIZE], list2[SIZE];
	bool stable = true;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> list1[i].suit >> list1[i].rank;
		list2[i] = list1[i];
	}

	bubbleSort(n, list1);
	selectionSort(n, list2);

	for (int i = 0; i < n; i++) {
		if (i > 0) {
			cout << " ";
		}
		cout << list1[i].suit << list1[i].rank;
	}
	cout << "\nStable\n";

	for (int i = 0; i < n; i++) {
		if (i > 0) {
			cout << " ";
		}
		cout << list2[i].suit << list2[i].rank;
		if (list1[i].suit != list2[i].suit || list1[i].rank != list2[i].rank) {
			stable = false;
		}
	}
	if (stable) {
		cout << "\nStable\n";
	}
	else {
		cout << "\nNot stable\n";
	}

	cin >> n;

	return 0;
}

void bubbleSort(int n, Card list[]) {
	Card tmp;
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j >= i + 1; j--) {
			if (list[j].rank < list[j - 1].rank) {
				tmp = list[j];
				list[j] = list[j - 1];
				list[j - 1] = tmp;
			}
		}
	}
}

void selectionSort(int n, Card list[]) {
	int min;
	Card tmp;
	for (int i = 0; i < n; i++) {
		min = i;
		for (int j = i; j < n; j++) {
			if (list[j].rank < list[min].rank) {
				min = j;
			}
		}
		tmp = list[i];
		list[i] = list[min];
		list[min] = tmp;
	}
}

Measured memory_bytes: 3076
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
  int n;
  char s[101],t[101];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  for(int i=0;i<n;i++){
    cin>>t[i];
  }
  for(int i=0;i<n;i++){
    printf("%c%c",s[i],t[i]);
  }
  return 0;
}

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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;

#define endl '\n'
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;

void test()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ans=a*b>=c*d?a*b:c*d;
	cout<<ans;
}

int main()
{   
fast_io();
cout << fixed << setprecision(15);
int t = 1;

//cin>>t;

for(int i = 0; i < t; i++)
{
	test();
}
return 0;
}

Measured memory_bytes: 256