akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	vector<int> a(n+1), b(n+1);
	for(int i = 1; i <= n; ++i) a[i] = b[i] = n;
	ll black = (ll)(n-2) * (n-2);
	int h = n, w = n;
	while(q--){
		int t, x;
		cin >> t >> x;
		if(t == 1){
			if(x < w){
				for(int i = x; i < w; ++i) b[i] = h;
				w = x;
			}
			black -= b[x] - 2;
		}
		else{
			if(x < h){
				for(int i = x; i < h; ++i) a[i] = w;
				h = x;
			}
			black -= a[x] - 2;
		}
	}
	cout << black << endl;
	return 0;
}


Measured memory_bytes: 4740
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
    ll N;
    vector<ll> A;
    cin >> N;

    rep(i, 0, N){
        ll temp;
        cin >> temp;
        A.push_back(temp);
    }
    while (A.size() > 1){
        sort(begin(A), end(A));
        while (A[0] == 0){
            A.erase(begin(A));
        }
        rep(i, 1, A.size()){
            A[i] %= A[0];
        }
    }
    cout << A[0] << endl;

    return 0;
}

Measured memory_bytes: 1400
program main
  implicit none
  character(len=10) :: S
  integer :: y
  integer :: m
  integer :: d
  read(*,'(A)') S
  
  read(S(1:4),*) y
  read(S(6:7),*) m
  read(S(9:10),*) d
  
  if ( m >= 5 ) then
     write(*,*) 'TBD'
  else 
     write(*,*) 'Heisei'
  end if
  stop
end program main


Measured memory_bytes: 768
#include<stdio.h>
#define MAX 100
#define NIL -1
#define WHITE 1
#define GREY 2
#define BLACK 3
#define INF (1<<21)

int G[MAX][MAX],c[MAX],p[MAX],d[MAX],n;
int prim(){
  int i,u,min,count=0;
  for(i=0;i<n;i++){
    c[i]=WHITE;
    p[i]=NIL;
    d[i]=INF;
  }
  d[0]=0;
  while(1){
    min=INF;
    u=NIL;
    for(i=0;i<n;i++){
      if(c[i]!=BLACK && d[i]<min){
        min=d[i];
        u=i;
      }
    }
    if(u==NIL) break;
    c[u]=BLACK;
    for(i=0;i<n;i++){
      if(c[i]!=BLACK && G[u][i]!=NIL){
	if(d[i]>G[u][i]){
	  d[i]=G[u][i];
	  p[i]=u;
	  c[i]=GREY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i]!=NIL) count+=G[i][p[i]];
  }
  return count;
}
  int main(){
    int i,j;
    scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) scanf(" %d",&G[i][j]);
  }
 
  printf("%d\n",prim());
  return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll,ll> P;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i, n) FOR(i,0,n)
#define IINF 1e9

// bit全探索
int main(void){
    int d,g,ans = IINF;
    cin >> d >> g;
    vector<int> p(d+10);
    vector<ll> c(d+10);
    REP(i,d) cin >> p[i] >> c[i];
    
    FOR(b,0,(1 << d)){
        int res = 0,num = 0,mnum = -1;
        REP(i,d){
            if((b >> i) & 1){
                res += (c[i] + 100 * (i+1) * p[i]);
                num += p[i];
            }
            else{
                mnum = i;
            }
        }
        if(res < g){
            int m = 100 * (mnum + 1);
            int need = (g - res + (m - 1)) / m ;
            if(need >= p[mnum]) continue;
            num += need;
            res += need * m;
        }
        if(res >= g) ans = min(ans,num);
        
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int INF = 1 << 27;
const ll MOD = 1e9+7;

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

int main() {
  int N, K;
  scanf("%d %d", &N, &K);
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }

  vector<vector<int>> dp(N, vector<int>(K + 1, 0));
  for (int i = 0; i < N; i++) {
    dp[i][0] = 1;
  }
  for (int j = 0; j <= min(a[0], K); j++) {
    dp[0][j] = 1;
  }
  for (int i = 1; i < N; i++) {
    for (int j = 1; j <= K; j++) {
      dp[i][j] = ((dp[i][j-1] + dp[i-1][j]) % MOD - (j - 1 - a[i] >= 0 ? dp[i-1][j - 1 - a[i]] : 0) + MOD) % MOD;
    }
  }

  printf("%d\n", dp[N-1][K]);
}


Measured memory_bytes: 39808
#include <bits/stdc++.h>
using namespace std;
int a[1000];
int main() {
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n == 0 && m == 0)
      break;
    for (int i = 0; i < n; i++)
      cin >> a[i];
    sort(a, a + n);
    if (a[n - 1] + a[n - 2] < m) {
      cout << a[n - 1] + a[n - 2] << endl;
      continue;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int p = lower_bound(a, a + n, m - a[i]) - a;
      while (p >= 0 && (a[i] + a[p] > m || i == p))
        p--;
      if (p >= 0 && a[i] + a[p] > ans)
        ans = a[i] + a[p];
    }
    if (ans)
      cout << ans << endl;
    else
      cout << "NONE" << endl;
  }
}


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

int main()
{
  int N;
  cin >> N;
  int cnt = 0;
  int min = N + 1;
  for (int i = 0; i < N; ++i)
  {
    int P;
    cin >> P;
    if (P < min)
    {
      ++cnt;
      min = P;
    }
  }
  cout << cnt;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint h, w, k;

const int FACT_MAX = 20000005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

int main(void)
{
  cin >> h >> w >> k;
  make_fact();

  llint ans = 0, tmp = 0;
  if(k >= 2){
    for(int i = 0; i <= k-2; i++){
      tmp += (k-i-1) * fact[k-2] % mod * (i+1) % mod, tmp %= mod;
    }
    tmp *= 2 * comb(h+w-2, k-2) % mod, tmp %= mod;
    tmp *= h * w % mod, tmp %= mod;
    ans += tmp, ans %= mod;
  }

  tmp = 0;
  for(int i = 0; i <= k-1; i++){
    tmp += fact[k-1] * (i+1) % mod, tmp %= mod;
  }

  tmp *= (h + w) % mod, tmp %= mod;
  tmp *= comb(h+w-1, k-1), tmp %= mod;
  ans += tmp, ans %= mod;

  ans += comb(h+w, k) * fact[k] % mod * k % mod, ans %= mod;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 312704
import numpy as np
N = int(input())
dp = np.zeros((N+1, 3), dtype=int)
for i in range(1, N+1):
    a, b, c = list(map(int, input().split(' ')))
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c
print(np.max(dp[-1]))

Measured memory_bytes: 14772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

bool is_prime[1000010];

int main() {
    int n;
    cin >> n;
    vector<int> p(n),q(n),tmp(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> q[i];
    }
    for (int i = 1; i <= n; ++i) {
        tmp[i-1] = i;
    }
    int cnt = 0,ansp,ansq;
    do{
        if(p == tmp){
            ansp = cnt;
        }
        cnt++;
    }while(next_permutation(tmp.begin(),tmp.end()));
    sort(tmp.begin(),tmp.end());
    cnt = 0;
    do{
        if(q == tmp){
            ansq = cnt;
        }
        cnt++;
    }while(next_permutation(tmp.begin(),tmp.end()));
    cout << abs(ansp-ansq) << endl;
    return 0;
}

Measured memory_bytes: 3600
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Foldable
import           Data.Maybe
import qualified Data.Sequence         as Seq

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [n, h] <- getIntList

  let parseInputs n ma bs | n == 0 = return (ma, bs)
                          | otherwise = do
                              [a, b] <- getIntList
                              parseInputs (n-1) (max ma a) (b:bs)

  (ma, bs) <- parseInputs n 0 []

  let bs' = Seq.unstableSortBy (flip compare) $ Seq.filter (> ma) $ Seq.fromList bs

      checkBs Seq.EmptyL    nb hp = (nb, hp)
      checkBs (b Seq.:< rs) nb hp | hp <= 0 = (nb, hp)
                                  | otherwise = checkBs (Seq.viewl rs) (nb+1) (hp-b)

      (nb, hp) = checkBs (Seq.viewl bs') 0 h

      ans | hp <= 0 = nb
          | otherwise = nb + (hp + ma - 1) `div` ma

  print ans


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

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

    	dice = new Dice[2];

    	for(int i = 0; i < 2; i++){
    		dice[i] = new Dice();
    	}

    	for(int i = 0; i < 2; i++){
    		for(int j = 0; j < 6; j++){
    			dice[i].surface[j] = scan.nextInt();
    		}
    	}

    	
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4; j++){
			    for(int k = 0; k < 4; k++){
			   		dice[1].spinVertical();
					//?????¢??????????????´????????????????????????
			    		if(Arrays.equals(dice[0].surface, dice[1].surface)) {
			    			System.out.println("Yes");
			    			return;
			    		}
			        }
			    	dice[1].spinHorizontal();
		    	}
			dice[1].spinVertical();	
		}
    	System.out.println("No");
     }
}

/*
???????????????Dice
??????:?????????????????¢?????????
     ?????¢?????????????????¢?????\?????????
*/
class Dice{
	int[] surface = new int[6];

	public void spinVertical (){
		int temp3 = surface[0];
		surface[0] = surface[1];
		surface[1] = surface[5];
		surface[5] = surface[4];
		surface[4] = temp3;
	}

	public void spinHorizontal(){
		int temp2 = surface[0];
		surface[0] = surface[3];
		surface[3] = surface[5];
		surface[5] = surface[2];
		surface[2] = temp2;
	}
}

Measured memory_bytes: 26152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0; i<x; i++)
#define repn(i,x) for(int i=1; i<=x; i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main() {
    string s;
    cin >> s;
    int o = 0;
    int x = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'o')
            o++;
        else
            x++;
    }
    int remain = 15 - s.length();
    if (o + remain >= 8)
        cout << "YES";
    else
        cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b; cin>>a>>b;
    string s; cin>>s;
    for(int i=0; i<s.size(); i++){
        if(i==a){
            if(s.at(i) != '-'){
                cout<<"No"<<endl;
                return 0;
            }
        }else{
            if(!(s.at(i)-'0'>=0 and s.at(i)-'0'<=9)){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::cmp::*;

#[allow(dead_code)]
fn getline() -> Vec<String> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok().unwrap();
    s.split(' ').map(|x| x.trim().to_string()).collect::<Vec<String>>()
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>(s: &String) -> T {
    s.parse().ok().unwrap()
}

fn solve() -> String {
    let a = &getline()[0].chars().collect::<Vec<_>>();
    let b = &getline()[0].chars().collect::<Vec<_>>();
    match a.len().cmp(&b.len()) {
        Ordering::Greater => "GREATER".to_string(),
        Ordering::Less => "LESS".to_string(),
        Ordering::Equal => {
            for i in 0..a.len() {
                match a[i].cmp(&b[i]) {
                    Ordering::Greater => return "GREATER".to_string(),
                    Ordering::Less => return "LESS".to_string(),
                    Ordering::Equal => ()
                }
            }
            "EQUAL".to_string()
        }
    }
}
        
fn main() {
    println!("{}", solve());
}


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

ll 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(){
  int a, b;
  cin >> a >> b;

  if (( a + b) % 3 != 0 ){
    cout << 0 << endl;
    return 0;
  }

   int n =  (2 * b - a) / 3;
   int m = (2 * a - b)/ 3;

  if ( n < 0 || m < 0){
    cout << 0 << endl;
    return 0;
  }

  COMinit();
  cout << COM(n+m, m) << endl;

  return 0;
}

Measured memory_bytes: 47104
#include<stdio.h>

int main(){
	int a[100];
	int n;
	scanf("%d\n",&n);
	for(int i = 0; i < n;i++)scanf("%d ",&a[i]);
	for(int i = 0; i < n-1; i++) printf("%d ",a[n-i-1]);
	printf("%d\n",a[0]);
	return 0;
}



Measured memory_bytes: 2108
n = int(input())
a = [int(item) for item in input().split()]

time1, time2, time4 = 0, 0, 0
for item in a:
    if item % 4 == 0:
        time4 += 1
    elif item % 2 == 0:
        time2 += 1
    else:
        time1 += 1

if (time1 + time2 % 2 + time4) % 2 == 1:
    time4 += 1

if time1 + time2 % 2 > time4:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 14380
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int n;

void dfs(string s, char x){
    if(s.size() == n){
        cout << s << endl;
        return;
    }
    else{
        for(char c = 'a'; c <= x; c++){
            char y;
            if(x == c) y = x+1;
            else y = x;
            dfs(s + c, y);
        }
    }
}

int main(){
    cin >> n;
    dfs("", 'a');
}


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

const int N = 2e3 + 1;
const int mod = 1e9 + 7;

int fpow (int a, int b) { int ret = 1; while (b) { if (b & 1) ret = 1ll * ret * a % mod; a = 1ll * a * a % mod; b >>= 1; } return ret; }
int add (int a, int b) { return (a += b) >= mod ? a - mod : a; }
int sub (int a, int b) { return (a -= b) >= 0 ? a : a + mod; }
int mul (long long a, int b) { return a * b % mod; }
int inv (int a) { return fpow(a, mod - 2); }


int dp[N][N];

int main () {
	int n;
	scanf("%d", &n);
	dp[0][0] = 1;
	for (int i = 1; i <= n; i ++) {
		for (int j = 3; j <= n; j ++) 
			dp[i][j] = dp[i - 1][j - 3];
		for (int j = 1; j <= n; j ++)
			dp[i][j] = add(dp[i][j], dp[i][j - 1]);
	}
	int ans = 0;
	for (int i = 1; i <= n; i ++)
		ans = add(ans, dp[i][n]);
	printf("%d\n", ans);
}

Measured memory_bytes: 19216
import itertools as it

N, M = list(map(int, input().split()))
s = []
for i in range(M):
    s_i = [int(a) for a in input().split()]
    s.append(s_i[1:])
p = [int(a) for a in input().split()]
ans = 0
for i in it.product(range(2), repeat=N):
    # each configuration of switches
    is_flash = []
    for j in range(M):
        # each flash condition
        cond = s[j]  # [1, 2]...
        num = 0
        for light in cond:
            num += i[light - 1]
        if num % 2 == p[j]:
            is_flash.append(True)
        else:
            is_flash.append(False)
    if all(is_flash):
        ans += 1
print(ans)


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

int main(){
	int n; cin >> n;
	vector<double> X(n);
	vector<double> Y(n);
	double len;
	double D;
	double sum1 = 0.0;
	double sum2 = 0.0;
	double sum3 = 0.0;
	double D_inf = -1.0;
	double max =-1.0;

	for(int i=0; i<n; i++)
		cin >> X[i];
	for(int i=0; i<n; i++)
		cin >> Y[i];

	for(int i=0;i<n;i++){
		D = abs(X[i]-Y[i]);
		sum1 += D;
		sum2 += pow(D,2.0);
		sum3 += pow(D,3.0);
		if(D_inf<D)
			D_inf=D;
	}
	cout << fixed << setprecision(8) << sum1 << endl; 
	cout << fixed << setprecision(8) << sqrt(sum2) << endl;
	cout << fixed << setprecision(8) << pow(sum3, 1.0/3.0) << endl;
	cout << fixed << setprecision(8) << D_inf << endl;

	return 0;
}

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

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

const int MX = (int)5e5 + 10;
const int mod = 998244353;

int main(int argc, char* argv[]){

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

    // registerGen(argc, argv, 1);

    int l, r;
    cin >> l >> r;

    int res = 2019;
    for(int i = 0; i <= min(r - l, 2019); ++i){
        int fs = (l + i) % 2019;
        for(int j = 0; j <= min(r - l, 2019); ++j){
            if(i == j) continue;
            int sc = (l + j) % 2019;
            res = min(res, (fs * sc) % 2019);
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

  if(a+b==15){
    cout<<"+"<<endl;
  }else
  if(a*b==15){
    cout<<"*"<<endl;
  }else{
    cout<<"x"<<endl;
  }
}


Measured memory_bytes: 768
// --------------
// Tejas Pandey  |
// 13 - 08 - 20  |
// Atcoder BC 175|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int ans = 0;
  int a[n];
  for(int i = 0;i < n;i++) cin >> a[i];
  for(int i = 0;i < n;i++)
	for(int j = i + 1;j < n;j++)
		for(int k = j + 1;k < n;k++){
			if(a[i] == a[j] || a[j] == a[k] || a[i] == a[k]) continue;
			if(a[i] + a[j] > a[k] && a[j] + a[k] > a[i] && a[i] + a[k] > a[j]) ans++;
		}
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        String s = in.next();
        String t = in.next();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            sb.append(s.charAt(i)).append(t.charAt(i));
        }
        out.println(sb);
    }


}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer      tokenizer;

    public InputReader(InputStream stream){
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
struct edge{ll to,cost;};
const int inf = 1<<28;
const ll INF = 1LL<<62;
const int COMBMAX = 500005;
const ll MOD = 1e9+7;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;++i)
#define repf(i,n) for(int i=0;i<=n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define eachdo(v, e) for(const auto& e : v)
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (ll)distance(v.begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (ll)distance(v.begin(), upper_bound((v).begin(), (v).end(), e))
ll mpow(ll a, ll n,ll mod=MOD){ll res=1;while(n>0){if(n&1)res=res*a%mod;a=a*a%mod;n>>=1;}return res;}
template<class T1, class T2> ll bcount(T1 v, T2 a){return upper_index(v,a)-lower_index(v,a);} 
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<class T> 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;}
template<class T> void debug2(T v){rep(i,v.size()){rep(j,v[i].size())cout<<v[i][j]<<" ";cout<<endl;}}
template<class T> void rdv(T &v){rep(i,v.size())cin>>v[i];}
template<class T> void rdvv(T &v){rep(i,v.size()){rep(j,v[i].size())cin>>v[i][j];}}
// multimap
// mmap.emplace(key,value);
// auto ngw = list.equal_range("");
// for(auto e = ngw.first; it != ngw.second ; ++e)

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> a(N), f(N); 
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> f[i];
    sort(all(a));
    sort(all(f));
    reverse(all(a));
    ll l = -1, r = INF;
    while(r - l > 1){
        ll mid = (r + l)/2;
        ll cnt = 0;
        rep(i, N){
            if (mid >= a[i] * f[i]) continue;
            cnt += a[i] - (mid / f[i]);
        }
        if (cnt <= K){
            r = mid;
        }else{
            l = mid;
        }
        // cout << l << " " << r << " " <<  mid <<" " << cnt << endl;
    }

    cout << r << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k;
  string s,t;
  cin >> n >> k >> s;
  t = s[k-1];
  transform(t.begin(), t.end(), t.begin(), ::tolower);
  s[k-1] = t[0];
  cout << s;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2 * pow(10, 5);

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

    int N;
    cin >> N;
    int A[MAX];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int C[MAX];
    int cnt = 0;
    for (int i = N; i >= 1; i--) {
        int s = 0;
        for (int j = 2 * i; j <= N; j += i) {
            s += C[j - 1];
            s %= 2;
        }
        C[i - 1] = A[i - 1] ^ s;
        cnt += C[i - 1];
    }

    cout << cnt << endl;
    bool flg = false;
    for (int i = 0; i < N; i++) {
        if (C[i] == 1) {
            if (flg) cout << " ";
            cout << i + 1;
            flg = true;
        }
    }
    if (flg) cout << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec.at(i);
    }
    sort(vec.begin(),vec.end());
    cout<<vec.at(n-1)-vec.at(0)<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

enum Tenki
{
    Sunny,
    Cloudy,
    Rainy
};

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

    bool honest = true;

    if (a == 'H' && b == 'D') {
        honest = false;
    }
    if (a == 'D' && b == 'H') {
        honest = false;
    }

    if (honest) {
        cout << "H" << endl;
    } else {
        cout << "D" << endl;
    }
}

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

set<string> se;
int j, y;

void dfs(int nj, int ny, string temp){
  if(j < nj || y < ny) return;
  if(j == nj && y == ny){
    se.insert(temp);
    return;
  }

  if(nj < 5 && ny <= 3 || ny < 5 && nj <= 3 || nj >= 4 && ny >= 4){
    dfs(nj + 1, ny, temp + 'A');
    dfs(nj, ny + 1, temp + 'B');
  }

  return;
}

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

  cin >> j >> y;

  dfs(0, 0, "");

  for(set<string>::iterator itr = se.begin();itr != se.end();itr++){
    cout << *itr << endl;
  }

  return 0;
}



Measured memory_bytes: 3256
import scala.io.Source.stdin

object Main extends App {
  def calc(op:String,x:Double,y:Double):Double = {
    op match {
      case "+" => x+y
      case "-" => x-y
      case "/" => x/y
      case "*" => x*y
      case _ => throw new Exception("Unexpected")
    }
  }

  def revP(a:Array[String],i:Int,l:List[Double]):Double = {
    if(i==a.length) l.head
    else if(a(i) != "-" && a(i).forall(x=>x=='-' || x.isDigit)) revP(a,i+1,a(i).toDouble::l)
    else {
      l match {
        case hd1::hd2::tl => revP(a,i+1, calc(a(i),hd2,hd1)::tl)
        case _ => throw new Exception("Unexpected")
      }
    }
  }
  stdin.getLines.foreach { s=>
    printf("%.6f\n",revP(s.split(" "),0,Nil))
  }
}

Measured memory_bytes: 44204
var fs = require("fs");
var line = fs.readFileSync("/dev/stdin");
var N = Number(line);
var res = 0;

for (let i = 1; i <= N; i++) {
  const n = Math.floor(N / i);
  res += (i * n * (n + 1)) / 2;
}

console.log(res);


Measured memory_bytes: 33292
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String input = in.nextLine();
		int result = 0;
		for (int i = 0; i < input.length(); ++i) {
			if (input.charAt(i) == '1') {
				result++;
			}
		}
		System.out.println(result);
		in.close();
	}
}

Measured memory_bytes: 20820
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        
        int[] arr = new int[45];
        arr[0] = 1;
        arr[1] = 1;
        
        for (int i = 2; i < 45; i++) {
            arr[i] = arr[i-1] + arr[i-2];
        }
        
        System.out.println(arr[in.nextInt()]);
    }
}



Measured memory_bytes: 26264
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

vector<int> edge[100050];
int color[100050];
int painted[100050];

void DFS(int V,int dis,int paint){
    if(painted[V]>=dis || dis<0) return;
    painted[V]=dis;
    if(color[V]==0) color[V]=paint;
    rep(i,edge[V].size()) DFS(edge[V][i],dis-1,paint);
}

int main(void){
    int N,M;
    cin >> N >> M;
    rep(i,N) painted[i]=-1;
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--,b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    int Q;
    cin >> Q;
    int v[Q],d[Q],c[Q];
    reprev(i,Q){
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }
    rep(i,Q){
        DFS(v[i],d[i],c[i]);
    }
    rep(i,N) cout << color[i] << endl;
}

Measured memory_bytes: 8440
import sys
from sys import stdin,stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
#@lru_cache(maxsize=None) #for optimizing the execution time of callable objects/functions(placed above callable functions)




try:
    for _ in range(1):
        n=int(input())
        ans=0
        for i in range(1,n+1):
            ans+=(n-1)//i
        print(ans)
            



    
except EOFError as e:
    print(e)


Measured memory_bytes: 76788
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;

template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
int main(){
	int n;
	while(cin >> n,n){
		vector<int> list;
		rep(i,n){
			int tmp;
			cin >> tmp;
			list.pb(tmp);
		}

		int count=0;
		rep(i,10000){
			bool flag=true;
			rp(i2,list){
				if(list[i2]!=i2+1){
					flag=false;
					break;
				}
			}
			if(flag){
				break;
			}
			int s=list.size();
			rp(i2,list){
				list[i2]--;
			}
			list.erase(remove(list.begin(), list.end(), 0), list.end());
			list.pb(s);

			count++;
		}
		if(!(count==10000)){
			cout << count << endl;
		}else{
			cout << -1 << endl;
		}

	}
}

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

int main() {
	int d, s;
	while (cin >> d) {
		s = 0;
		for (int i = 1;i <= (600 / d )- 1;i++) {
			s += d * d * d * i * i;
		}

		cout << s << endl;
	}

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll a, b, c, x, y, maxm = INF, ans = 0;
  bool flg = false;
  cin >> a >> b >> c >> x >> y;

  if (a + b > 2 * c) {
    ans += 2 * min(x, y) * c;
    if (x == y) {
    } else if (x > y) {
      ans += min((x - y) * a, (x - y) * 2 * c);
    } else {
      ans += min((y - x) * b, (y - x) * 2 * c);
    }
  } else {
    ans = a * x + b * y;
  }

  cout << ans << endl;
  return 0;
}


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

void solve(long long A, long long B, long long C, long long K)
{
    int n;
    if (A > K)
        n = K;
    else if (A + B > K)
        n = A;
    else
        n = A - (K - (A + B));
    cout << n << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    long long K;
    scanf("%lld", &K);
    solve(A, B, C, K);
    return 0;
}


Measured memory_bytes: 3684
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Maybe
import Data.Monoid
import Data.Foldable
import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Maybe
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import qualified Data.IntSet as IntSet

farthest :: V.Vector IntSet.IntSet -> Int -> Int
farthest graph !origin = U.maximum d
  where
    d = U.create $ do
      let n = V.length graph
      vec <- UM.replicate n (-1 :: Int)
      let bfs !depth !seen !set
            | IntSet.null set = return ()
            | otherwise = do
                forM_ (IntSet.toList set) $ \i -> do
                  UM.write vec i depth
                let seen' = set `IntSet.union` seen
                let next = foldMap_IntSet (graph V.!) set `IntSet.difference` seen'
                bfs (depth + 1) seen' next
      bfs 0 IntSet.empty (IntSet.singleton origin)
      return vec

solve :: V.Vector IntSet.IntSet -> Bool
solve graph = fromMaybe False $ runST $ runMaybeT $ do
  let n = V.length graph
  result <- UM.replicate n (0 :: Int)
  let dfs !p !i !c = do
        c' <- UM.read result i
        case c' of
          0 -> do
            UM.write result i c
            forM_ (IntSet.toList $ graph V.! i) $ \j -> do
              when (j /= p) $ do
                dfs i j (-c)
          _ | c' == c -> return ()
            | otherwise -> mzero
  dfs (-1) 0 1
  return True

main = do
  n <- readLn
  s <- V.replicateM n BS.getLine
  -- s V.! i `BS.index` j
  let graph :: V.Vector IntSet.IntSet
      graph = V.create $ do
        g <- VM.replicate n IntSet.empty
        V.forM_ (V.indexed s) $ \(i,r) -> do
          forM_ [0..n-1] $ \j -> do
            let c = r `BS.index` j
            when (c == '1') $ do
              VM.modify g (IntSet.insert j) i
        return g
  if solve graph then do
    let y = maximum $ map (farthest graph) [0..n-1]
    print (y + 1)
  else
    putStrLn "-1"

foldMap_IntSet :: (Monoid n) => (Int -> n) -> IntSet.IntSet -> n
foldMap_IntSet f set = go set
  where
    go set = case IntSet.splitRoot set of
               [] -> mempty
               [x] -> foldMap f (IntSet.toList x)
               xs -> foldMap go xs


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

int main(){
	long a,b,m,n,tmp;
	
	while(cin>>a>>b){
		if(a>=b){
			m=a;
			n=b;
		}else{
			m=b;
			n=a;
		}
		
		for(;n!=0;){
			tmp=n;
			n=m%n;
			m=tmp;
		}
		
		cout<<m<<" "<<a*b/m<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
//ＧＯＥＭＯＮ＃Iridium今日 12:44
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  bool l=true;
  vector <int>vec(N);
  for (int X=0; X<N; X++){
    cin >> vec.at(X);
    if (vec.at(X)%2==0){
      if (vec.at(X)%3!=0 && vec.at(X)%5!=0){
        l=false;
      }
    }
  }
  if (l==false){
    cout << "DENIED" << endl;
  }
  else {
    cout << "APPROVED" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll r[60];
    r[0]=1;
    for(int i=1;i<60;i++){
        r[i]=2*r[i-1];
        r[i]%=MOD;
    }
    ll ans=0;
    for(int i=0;i<60;i++){
        ll cnt=0;
        for(int j=0;j<n;j++){
            if(a[j]&1)cnt++;
            a[j]/=2;
        }
        ll t=cnt*(n-cnt);
        t%=MOD;
        t*=r[i];
        t%=MOD;
        ans+=t;
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            long[] V = ReadLongs();
            long r = V[0], D = V[1], x = V[2];
            for (int i = 0; i < 10; ++i)
            {
                x = r * x - D;
                Console.WriteLine(x);
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define matrix vector < vector<double> >

using namespace std;

const double eps = 1e-9;
const double PI = acos(-1.0);
const int inf = int (1e9+7);
const ll INF = (ll) 8e18+7;
const int mod = int (1e4+7);     
const int N = int (3e5+7);    

int n;
ll ans;
string s;
vector <int> v;

ll parse(int l, int r) {
	ll res = 0;
	for(int i = l; i <= r; i ++)
		res = res * 10 + s[i] - '0';
	return res;
}

void go(int pos) {
	if(pos == n - 1) {
		int l = 0;
		for(int it: v) {
			ans += parse(l, it);
			l = it + 1;
		}
		ans += parse(l, n - 1);
		return;
	}
	go(pos + 1);
	v.pb(pos);
	go(pos + 1);
	v.pop_back();
}

int main () { 
   	//freopen("input.txt", "r", stdin);
   	//freopen("output.txt", "w", stdout);  
   	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> s;
	n = s.size();
	go(0);
	cout << ans << 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++)
#define REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;

int field[105][105];
int dp[105][105];
const int INF = 1e9+7;
int main(){
    int h,w;
    cin>>h>>w;
    REP(i,h){
        string s;
        cin>>s;
        rep(j,w){
            if(s[j]=='#'){
                field[i][j+1] = 1;
            }else{
                field[i][j+1] = 0;
            }
        }
    }
    rep(i,105)rep(j,105) dp[i][j]=INF;
    dp[1][1]=0;
    REP(i,h){
        REP(j,w){
            if(i==1&&j==1) continue;
            if(i!=1){
                if(field[i-1][j]==0&&field[i][j]==1){
                    dp[i][j]=min(dp[i-1][j]+1,dp[i][j]);
                }else{
                    dp[i][j]=min(dp[i-1][j],dp[i][j]);
                }
            }
            if(j!=1){
                if(field[i][j-1]==0&&field[i][j]==1){
                    dp[i][j] = min(dp[i][j-1]+1,dp[i][j]);
                }else{
                    dp[i][j]=min(dp[i][j-1],dp[i][j]);
                }
            }
        }
    }
    cout<<dp[h][w]+(field[1][1]==1 ? 1:0)<<endl;

    return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int R, C, K;
ll A[3005][3005], DP[3005][3005][4];

int main(){
  cin >> R >> C >> K;
  for (int i = 0; i < K; i++){
    int r, c, v; cin >> r >> c >> v;
    A[r][c] += v;
  }

  for (int i = 1; i <= R; i++){
    for (int j = 1; j <= C; j++){
      for (int k = 0; k <= 3; k++){
        DP[i][j][0] = max(DP[i][j][0], DP[i-1][j][k]);
        DP[i][j][1] = max(DP[i][j][1], DP[i-1][j][k] + A[i][j]);
        DP[i][j][k] = max(DP[i][j][k], DP[i][j-1][k]);
        if (k >= 1){
          DP[i][j][k] = max(DP[i][j][k], DP[i][j-1][k-1] + A[i][j]);
        }
      }
    }
  }
  ll ans = 0;
  for (int k = 0; k <= 3; k++){
    ans = max(ans, DP[R][C][k]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 355676
#include <stdio.h>

int gcd_euclid(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; 
    u = v;
    v = r; /* swap */
  }
  return u;
}

int main (){
 int a,b,c;
 scanf("%d%d%d",&a,&b,&c);
 
 if(c%gcd_euclid(a,b)==0){
  printf("YES");
 }else{
  printf("NO");
 }
 return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    VLL A(N),B(N);
    VP C(N);
    rep(i,N){
        cin >> A[i] >> B[i];
        C[i].F=B[i];
        C[i].S=A[i];
    }
    sort(all(C));
    ll judge=0;
    rep(i,C.size()){
        judge+=C[i].S;
        if(judge>C[i].F){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>

using namespace std;

int n, ans;

main(){
   cin >> n;
   for(int i=0;i<n;i++){
      int y, m, d;
      cin >> y >> m >> d;
      ans = 0;
      for(int j=y+1;j<1000;j++){
         if(j%3){
            ans += 195;
         }else{
            ans += 200;
         }
      }

      for(int j=m+1;j<=10;j++){
         if(y%3){
            if(j%2) ans += 20;
            else ans += 19;
         }else{
            ans += 20;
         }
      }
      if(y%3){
         if(m%2){
            ans += 20-d;
         }else{
            ans += 19-d;
         }
      }else{
         ans += 20-d;
      }
      cout << ans+1 << endl;
   }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef		vector<ll>      vll;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef       pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
int main()
{
 O_O ;
   ll a,b;
   cin>>a>>b;
   if(a<b)
    swap(a,b);
   for(ll i=0;i<a;i++)
   {
       cout<<b;
   }
   cout<<nn;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  long long ret = 0;
  for (int i = 0; i < n; i++) ret += a[i] - 1;
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 888