akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int,int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int main() {
	int n;
	while (cin >> n, n) {
		map<P, int> mp;
		pair<P,P> a[20001] = {};
		rep1(i, n) {
			int x, y; char t;
			cin >> x >> y >> t;
			mp[{x, y}] = i;
			a[i].first = { x,y };
			if (t == 'x') {
				mp[{x + 1, y}] = i;
				a[i].second = { x + 1,y };
			}
			else {
				mp[{x, y + 1}] = i;
				a[i].second = { x,y + 1 };
			}
		}
		int used[20001] = {};
		bool f = true;
		rep1(i, n) {
			if (used[i])continue;
			queue<int> q;
			q.push(i);
			used[i] = 1;
			while (!q.empty()) {
				int now = q.front(); q.pop();
				int x = a[now].first.first;
				int y = a[now].first.second;
				int z = used[now];
    			rep(k, 4) {
					int nx = x + dx[k]; int ny = y + dy[k];
					if (now == mp[{nx, ny}])continue;
					int num = mp[{nx, ny}];
					if (num>0) {
						if (a[num].first == P{nx, ny}) {
							if (used[num] > 0 && used[num] != z) {
								f = false; break;
							}
							else if(used[num]==0){
								used[num] = z; q.push(num);
							}
						}
						else {
							if (used[num] > 0 && used[num] != 3-z) {
								f = false; break;
							}
							else if (used[num] == 0) {
								used[num] = 3 - z; q.push(num);
							}
						}
					}
				}
				if (!f)break;
				x = a[now].second.first;
				y = a[now].second.second;
				rep(k, 4) {
					int nx = x + dx[k]; int ny = y + dy[k];
					if (now == mp[{nx, ny}])continue;
					int num = mp[{nx, ny}];
					if (num>0) {
						if (a[num].first == P{ nx, ny }) {
							if (used[num] > 0 && used[num] != 3-z) {
								f = false; break;
							}
							else if (used[num] == 0) {
								used[num] = 3 - z; q.push(num);
							}
						}
						else {
							if (used[num] > 0 && used[num] != z) {
								f = false; break;
							}
							else if (used[num] == 0) {
								used[num] = z; q.push(num);
							}
						}
					}
				}
			}
			if (!f)break;
		}
		if (f)cout << "Yes" << endl;
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 13436
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <cstdint>
#include <string.h>
#include <queue>
#include <bitset>
#include <limits>
#include <list>
#include <array>

using namespace std;

#define N_MAX (100000)

int main()
{
    int N;
    uint64_t H, W;
    cin >> N >> H >> W;
    int count = 0;
    for(int i=0; i<N; ++i) {
        uint64_t A, B;
        cin >> A >> B;

        if(H <= A && W <= B) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import math
a,b,h,m=map(float,input().split())
h=h*math.pi/6.0
h=h+m/60*math.pi/6.0
m=m*math.pi/30.0
t=min(2*math.pi-abs(h-m),abs(h-m))
c=(a*a+b*b-2*a*b*math.cos(t))**0.5
print(c)

Measured memory_bytes: 9532
#include <iostream>

using namespace std;

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

  int max_diff = -1000000000 + 1;
  int min_value;
  int current_value;

  cin >> current_value;
  min_value = current_value;

  for (int i = 1; i < n; i++) {
    cin >> current_value;

    if (max_diff < (current_value - min_value)) {
      max_diff = current_value - min_value;
    }

    if (current_value < min_value) {
      min_value = current_value;
    }
  }

  cout << max_diff << endl;
}


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

using namespace std;

int main()
{
  int A,B,K;
  cin >> A >> B;
  if((A+B)%2 == 0){
   K = (A+B)/2;
    cout << K << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
  
}
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <random>
#include <time.h>
#include <chrono>
#include <cmath>
using namespace std;

int main() {
    int X, Y;
    cin >> X >> Y;
    cout << X + Y / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(n-1, -1, -1):
    # ans += max(min(A[i], B[i]), min(A[i+1], B[i]), min(A[i]+A[i+1], B[i]))
    if A[i] + A[i+1] <= B[i]: # どちらも倒しきれる場合
        ans += A[i] + A[i+1]
        A[i], A[i+1] = 0, 0
    else: # どちらかが倒しきれない場合
        ans += B[i] # 倒せるのはB[i]体のみ
        A[i] = A[i] + min(A[i+1] - B[i], 0) 
print(ans)

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

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

typedef long long ll;

using namespace std;

int A[2 * 100000];

ll choose2(ll n) {
  return n * (n - 1) / 2;
}

int main() {
  int N;
  cin >> N;
  map<int, int> m;
  REP(i, N) {
    cin >> A[i];
    m[A[i]]++;
  }
  ll total = 0;
  for (const auto it : m) {
    total += choose2(it.second);
  }
  REP(i, N) {
    ll n = m[A[i]];
    cout << (total - choose2(n) + choose2(n - 1)) << endl;
  }
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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 INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll l, r, d;
    cin>>l>>r>>d;
    cout<<r / d - (l - 1) / d<<endl;
}

Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll k; cin >> k;
    ll sum = 0;
    reps(i,k)reps(j,k)reps(l,k){
        sum += gcd(i,(gcd(j, l)));
    }

    cout << sum << endl;
}

Measured memory_bytes: 3652
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

#[derive(Clone, Debug, Default)]
struct S {
    level_diff: i32,
    min_level: i32,
}

//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        s: [Bytes;n],
    }
    let mut v = Vec::with_capacity(n);
    for i in 0..n {
        let mut level_diff = 0;
        let mut min_level = 0;
        for j in 0..s[i].len() {
            if s[i][j] == b'(' {
                level_diff += 1;
            } else {
                level_diff -= 1;
                min_level = min(min_level, level_diff);
            }
        }
        v.push(S {
            level_diff,
            min_level,
        });
    }

    v.sort_unstable_by_key(|x: &S| {
        // 上り坂 → 平坦 → 下り坂 の順
        if x.level_diff > 0 {
            // 左から見た穴が浅い順
            -x.min_level
        } else if x.level_diff == 0 {
            10000000
        } else {
            // 右から見た穴が浅い順
            20000000 + x.min_level-x.level_diff
        }
    });

    let mut level = 0;
    for x in &v {
        if level + (*x).min_level < 0 {
            println!("No");
            return;
        }
        level += (*x).level_diff;
    }

    println!("{}", if level == 0 { "Yes" } else { "No" });
}


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

using namespace std;

int main(){
    string abc,s;
    abc = "abcdefghijklmnopqrstuvwxyz";
    cin >> s;
    int x;
    for(int i=0;i<26;i++){
        if(s[0]==abc[i]){
            x = i;
            break;
        }
    }
    cout << abc[x+1] << endl;
    return 0;
}

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

using namespace std;

static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX + 1];

int solve() {
    int ans = 0;

    bool V[MAX];
    for (int i = 0; i < n; ++i) {
        B[i] = A[i];
        V[i] = false;
    }
    sort(B, B + n);
    for (int i = 0; i < n; ++i) {
        T[B[i]] = i;
    }
    for (int i = 0; i < n; ++i) {
        if (V[i]) {
            continue;
        }
        int cur = i;
        int S = 0;
        int m = VMAX;
        int an = 0;
        while (true) {
            V[cur] = true;
            ++an;
            int v = A[cur];
            m = min(m, v);
            S += v;
            cur = T[v];
            if (V[cur]) {
                break;
            }
        }
        ans += min(S + (an - 2) * m, m + S + (an + 1) * s);
    }

    return ans;
}

int main() {
    scanf("%d", &n);
    s = VMAX;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &A[i]);
        s = min(s, A[i]);
    }
    int ans = solve();
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 3296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,t;
  cin >> n >> t;
  ll ans=0;
  ll temp=0;
  for(ll i=0;i<n;i++) {
    ll time;
    cin >> time;
    if(temp<=time) {
      ans+=t;
      temp=time+t;
    }
    else {
      ans+=max(0LL,time+t-temp);
      temp=max(temp,time+t);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if ((b - a) % 2 == 0) {
			System.out.println("Alice");
		} else {
			System.out.println("Borys");
		}
	}
}


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

using namespace std;

int main() {
  string S; cin >> S;
  int ans = 0;
  bool cont = true;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == 'R' && cont) {
      cont = true;
      ans++;
    } else if (S.at(i) == 'R' && !cont) {
      cont = true;
      ans = 1;
    } else {
      cont = false;
    }
  }

  cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define allpt(v) (v).begin(), (v).end()


const int mod = 1e9 + 7;
const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

template <typename T>
void show1dvec(vector<T> v)
{
    int n = v.size() - 1;
    rep(i, n) cout << v[i] << wsp;
    cout << v[n] << rt;
    return;
}

void shave(vector<int> &v, int n)
{
    vector<int> x, y;
    int n_sq = sqrt(n) + 1;
    for (int i = 3; i < n + 1; i += 2)
    {
        x.push_back(i);
    }
    for (int i = 3; i < n_sq; i += 2)
    {
        for (auto itr = x.begin(); itr != x.end(); itr++)
        {
            if (*itr == i || *itr % i != 0)
                y.push_back(*itr);
        }
        x.clear();
        x = y;
        y.clear();
    }
    if (n >= 2)
        x.insert(x.begin(), 2);

    for (auto itr = x.begin(); itr != x.end(); itr++)
    {
        v.push_back(*itr);
    }
}

int get756(vector<int> const &v)
{
    int n = v.size();
    
    int a, b, c, ret;
    ret = 0;
    rep(i, n - 2) rep2(j, i + 1, n - 1) rep2(k, j + 1, n)
    {
        if (v[i] >= 4 && v[j] >= 4 && v[k] >= 2)
            ret++;
        if (v[i] >= 4 && v[j] >= 2 && v[k] >= 4)
            ret++;
        if (v[i] >= 2 && v[j] >= 4 && v[k] >= 4)
            ret++;
    }

    rep(i, n - 1) rep2(j, i + 1, n)
    {
        if (v[i] >= 14 && v[j] >= 4)
            ret++;
        if (v[i] >= 4 && v[j] >= 14)
            ret++;
        if (v[i] >= 24 && v[j] >= 2)
            ret++;
        if (v[i] >= 2 && v[j] >= 24)
            ret++;
    }

    if (v[0] >= 74) ret++;
    return ret;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    const int m = 100;
    int n, k, p, ans;
    ans = 0;
    cin >> n;
    vector<int> v;
    shave(v, 100);
    k = v.size();
    vector<int> u(k, 0);

    rep2(i, 1, n + 1)
    {
        p = i;
        rep(j, k)
        {
            while (p % v[j] == 0)
            {
                u[j]++;
                p /= v[j];
            }
        }
    }

    ans = get756(u);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    vector<ll> X(M);
    rep(i,M){
        cin >> X[i];
    }
    sort(all(X));
    vector<ll> L(M-1);
    rep(i,M-1){
        L[i]=X[i+1]-X[i];
    }
    sort(all(L));
    reverse(all(L));
    if(N>=M)cout << 0;
    else{
        ll sum=X[M-1]-X[0];
        rep(i,N-1){
            sum-=L[i];
        }
        cout << sum;
    }


}

/*



 */



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
  string s,u;
  int a,b,c,d,i=0;
  cin >> a >> b >> c >> d ;
  while(i<1000){
    c-=b;
    if(c<=0){
      cout <<  "Yes" << endl;  
      return 0; 
    } 
    a-=d;
    if(a<=0){
       cout <<  "No" << endl; 
       return 0; 
    }
    i++;
  } 
  
}

Measured memory_bytes: 3624
N, M = map(int, input().split())
P_Y_I = [list(map(int, input().split())) for i in range(M)]

for i in range(M):
    P_Y_I[i].append(i+1)

P_Y_I = sorted(P_Y_I, key=lambda x:x[1])

N_count = [0 for k in range(N)]
for i in range(M):
    p = P_Y_I[i][0]
    N_count[p-1] += 1
    P_Y_I[i][0] = str(p).zfill(6)
    P_Y_I[i][1] = str(N_count[p-1]).zfill(6)

P_Y_I = sorted(P_Y_I, key=lambda x:x[2])

for i in range(M):
    print(P_Y_I[i][0]+P_Y_I[i][1])

Measured memory_bytes: 44064
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<i32>();
    let (k, x) = (line[0], line[1]);

    for i in x-k+1..k+x{
        print!("{} ", i);
    }

    println!("");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n)(for i-0;i<(n);++i)
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && a != c) {
    cout << "Yes";
  } else if (c == b && a != c) {
    cout << "Yes";
  } else if (a == c && b != c) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
const log = (...val) => console.log(...val);
function Main(input){

    if(input === 'SSS') log(0);
    if(input === 'SSR') log(1);
    if(input === 'SRS') log(1);
    if(input === 'SRR') log(2);
    if(input === 'RSS') log(1);
    if(input === 'RSR') log(1);
    if(input === 'RRS') log(2);
    if(input === 'RRR') log(3);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

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

class uint_Trie {
	struct node {
		node *p, *l, *r;
		int cnt;
		node(node *p, node *l = nullptr, node *r = nullptr) : p(p), l(l), r(r), cnt(0) {}
	};
	node *root;
	int siz;
public:
	uint_Trie() : root(new node(nullptr)) {}
	int size() {
		return root->cnt;
	}
	void insert(unsigned val) {
		// if (find(val)) return; // multiset ???????¶????
		node *t = root;
		for (int i = 30; i >= 0; i--) {
			t->cnt++;
			if (val & (1 << i)) {
				if (t->r == nullptr) {
					t->r = new node(t);
				}
				t = t->r;
			}
			else {
				if (t->l == nullptr) {
					t->l = new node(t);
				}
				t = t->l;
			}
		}
		t->cnt++;
	}
	void erase(unsigned val) {
		node *t = root, *ne;
		for (int i = 30; i >= 0; i--) {
			t->cnt--;
			if (val & (1 << i)) {
				if (t->r == nullptr) return;
				t = t->r;
			}
			else {
				if (t->l == nullptr) return;
				t = t->l;
			}
		}
		t->cnt--;
		while (t != root && t->cnt == 0) {
			ne = t->p;
			(t == ne->l ? ne->l : ne->r) = nullptr;
			delete t;
			t = ne;
		}
	}
	bool find(unsigned val) {
		node *t = root;
		for (int i = 30; i >= 0; i--) {
			if (val & (1 << i)) {
				if (t->r == nullptr) return false;
				t = t->r;
			}
			else {
				if (t->l == nullptr) return false;
				t = t->l;
			}
		}
		return true;
	}
	unsigned max() {
		assert(root->cnt >= 1);
		node *t = root;
		unsigned res = 0;
		for (int i = 30; i >= 0; i--) {
			assert(t->l != nullptr || t->r != nullptr);
			if (t->r != nullptr) {
				res |= 1 << i;
				t = t->r;
			}
			else {
				t = t->l;
			}
		}
		return res;
	}
	unsigned min() {
		assert(root->cnt >= 1);
		node *t = root;
		unsigned res = 0;
		for (int i = 30; i >= 0; i--) {
			assert(t->l != nullptr || t->r != nullptr);
			if (t->l != nullptr) {
				t = t->l;
			}
			else {
				res |= 1 << i;
				t = t->r;
			}
		}
		return res;
	}
};

int main()
{
	cin.sync_with_stdio(false);
	uint_Trie ut;
	string com;
	int k;
	while (cin >> com, com != "end") {
		if (com == "insert") {
			cin >> k;
			ut.insert(k);
		}
		else {
			int res = ut.max();
			printf("%d\n", res);
			ut.erase(res);
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}

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

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

    int nums[2];
    cin >> nums[0] >> nums[1];

    int group[3] = {0};
    rep(i, 2){
        int a = nums[i];
        if(a != 11 && a != 9 && (a % 2 == 1 || a == 8 || a == 10 || a == 12)){
            group[0] ++;
        }else if(a == 2){
            group[2] ++;
        }else{
            group[1] ++;
        }
    }

    if(group[0] == 2 || group[1] == 2 || group[2] == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int              long long
#define pb               push_back
#define mp               make_pair
#define vi               vector<int>
#define pii              pair<int,int>
#define mii              map<int,int>
#define pqb              priority_queue<int>
#define pqs              priority_queue<int, vi, greater<int>>
#define MOD              1000000007  //10^9+7
#define precision(x,y)   fixed<<setprecision(y)<<x
#define setbits(x)       __builtin_popcountll(x)  // number of 1s
#define zerobits(x)      __builtin_ctzll(x)   //number of zeroes after last 1
#define w(t)             int t; cin>>t; while(t--)
#define mk(arr,n,type)   type *arr=new type[n];
mt19937                  rng(chrono::steady_clock::now().time_since_epoch().count());   
#define shuffle(arr,n)   shuffle(arr, arr+n, rng) 


int32_t main(){ //used int32_t main because int is defined as long long above
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	string s; cin>>s;
	int cr0=0,cr1=0,cr2=0,fcr=0;
	for(int i=0;i<3;i++){
		if(i==0){
			if(s[i]=='R'){
				if(s[i+1]=='R'){
					if(s[i+2]=='R'){
						cr0++;
					}
					cr0++;
				}
				cr0++;
			}
		}
		if(i==1){
			if(s[i]=='R'){
				if(s[i+1]=='R'){
					cr1++;
				}
				cr1++;
			}
			fcr=max(cr0,cr1);
		}
		if((fcr==0&&i==2)&&s[i]=='R') fcr++;
	}
	cout<<fcr;
	return 0;
}

Measured memory_bytes: 3612
N,M = map(int, input().split())
H_list = list(map(int, input().split()))
N_list = [0]*N
for _ in range(M):
    A, B = map(int, input().split())
    if H_list[A-1] > H_list[B-1]:
        N_list[B-1] += 1
    elif H_list[A-1] < H_list[B-1]:
        N_list[A-1] += 1
    else:
        N_list[A-1] += 1
        N_list[B-1] += 1
print(N_list.count(0))

Measured memory_bytes: 20104
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int N;
    cin >> N;
    int n = 0;
    for(int num = 1; num <= N; num++){
        if(num % 2 == 0) continue;
        int count = 0;
        for(int k = 1; k <= num; k++){
            if(num % k == 0) count++;
        }
        if(count == 8) n++;
    }
    cout << n << endl;
}


Measured memory_bytes: 3684
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<String, Integer> data = new TreeMap<>();

		for (int i = 0; i < n; i++) {
			String city = sc.next();
			int point = sc.nextInt();
			data.put(city + (1100 - point), i + 1);
		}

		for (String key : data.keySet()) {
			System.out.println(data.get(key));
		}

		sc.close();
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  vector<i64> a(n);
  for (i64 i = 0; i < n; i++)
    cin >> a[i];
  i64 t = 0;
  for (i64 i = 0; i < n; i++)
    t ^= a[i];
  if (t == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

int N;

typedef long long ll;

ll T = 0,AO = 0,ans = 0;

struct Data {
  ll  A,B,C;
};

int main() {
  cin >> N;
  vector<Data> data(N);
  for ( int i = 0; i < N; i++ ) {
    cin >> data[i].A >> data[i].B;
    data[i].C = data[i].A + data[i].B;
  }

   sort(data.begin(),data.end(),[](const Data &l, const Data&r){
  				 return (l.C > r.C); });
 
  
 bool f = true;
 for ( int i = 0; i < N; i++ ) {
    if (f)  {
      T += data[i].A;
       f = false;
    }
    else {
      AO += data[i].B;
       f = true;
    }
  }
  ans = T - AO;
    cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> dp(h + 1, 1e9);
    dp[0] = 0;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        rep(j, h+1) {
            int idx = min(j + a, h);
            dp[idx] = min(dp[idx], dp[j] + b);
        }
    }
    cout << dp[h] << endl;
    return 0;
}


Measured memory_bytes: 3660
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main(void) {
    int n;
    cin >> n;
    if (n % 1000==0 ){
        cout << "0" << endl;
        return 0;
    }
    int x = n / 1000;
    int  y = x + 1;
    cout << 1000*y-n << endl;
    return 0;
}




Measured memory_bytes: 3628
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  std::string S;
  std::cin >> S;
  const i64 N = S.size();

  std::vector<i64> R, L;
  for (i64 i = 0; i < N - 1; ++i) {
    if (S[i] == 'R' && S[i + 1] == 'L') {
      R.push_back(i);
      L.push_back(i + 1);
    }
  }

  std::vector<i64> answers(N, 0);
  for (i64 i = 0; i < N; ++i) {
    switch (S[i]) {
    case 'R':
      {
        const i64 next_L = *std::upper_bound(L.begin(), L.end(), i);
        if ((next_L - i) % 2 == 0) {
          ++answers[next_L];
        } else {
          ++answers[next_L - 1];
        }
        break;
      }
    case 'L':
      {
        const i64 next_R = *std::upper_bound(R.rbegin(), R.rend(), i, std::greater<i64>());
        if ((i - next_R) % 2 == 0) {
          ++answers[next_R];
        } else {
          ++answers[next_R + 1];
        }
        break;
      }
    }
  }

  std::string delimiter = "";
  for (const i64& answer : answers) {
    std::cout << delimiter << answer;
    delimiter = " ";
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 2420
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        int x = Integer.valueOf(arr01[0]);
        int y = Integer.valueOf(arr01[1]);
        int z = Integer.valueOf(arr01[2]);

        int temp = x;
        x = y;
        y = temp;

        temp = x;
        x = z;
        z = temp;

        System.out.println(x + " " + y + " " + z);

    }

}

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

int main() {
	int N, x;
	cin >> N >> x;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	int sum = 0, cnt = 0;
	for (int i = 0; i < N; i++) {
		if (sum >= x) {
			break;
		}
		sum += a.at(i);
		cnt++;
	}
	if (sum != x) {
		cout << cnt - 1 << endl;
	} else {
		cout << cnt << endl;
	}
}

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

int main() {
    string s,t;
    cin>>s>>t;
    
   auto it = t.end();
    t.erase(--it);
    if(s == t)
    cout<<"Yes"<<endl;
    else 
    cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3624
using System;
class Program
{
    static void Main()
    {
        string z;
        string x = Console.ReadLine();
        string[] a = x.Split(' ');
        int n = int.Parse(a[0]);
        int m = int.Parse(a[1]);
        if (n < m)
        {z ="a < b"; }
        else if (n > m)
        {z ="a > b"; }
        else if(n == m)
        { z ="a == b"; }
        else { z = ""; }
        Console.WriteLine(z);
    }
}


Measured memory_bytes: 17904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
#define PI atan(1)*4
const int N = 101010;

double ans(double a,double b,double alpha)
{
	return sqrt(a*a+b*b-2*a*b*cos(alpha/180*PI));
} 
double getalpha(double h,double w)
{
	return min(abs((h*360)/12+0.5*w-w*360/60),360-abs((h*360/12)+0.5*w-w*360/60));
	
}
int main (){
	double a,b,h,w;
	cin>>a>>b>>h>>w;
	double alpha=getalpha(h,w);
	printf("%.30lf",ans(a,b,alpha));
	return 0;
} 

Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
multiset<int> ms;
int main(){
    int n, a, ans = 0;
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        scanf("%d", &a);
        auto its = ms.lower_bound(a);

        if(its != ms.begin()){
            its--;
            ms.erase(its);
        }
        else ans++;

        ms.insert(a);
    }   
    printf("%d\n", ans);
}

Measured memory_bytes: 4992
from collections import Counter

N = int(input())
a = list(map(int, input().split()))

A = [0] * (3 * N)
for i in range(N):
    A[3 * i] = a[i] - 1
    A[3 * i + 1] = a[i]
    A[3 * i + 2] = a[i] + 1

a_counter = Counter(A)
print(a_counter.most_common()[0][1])

Measured memory_bytes: 30956
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main()
{
	int N, k;
	cin >> N;
	vector<int> a(N);
	rep(i,N) cin >> a[i];
	int max = *max_element(a.begin(), a.end());
	int min = *min_element(a.begin(), a.end());
	cout << max-min <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int A , B ,sum , subtract;
    string s ;
    cin >> A >> s >> B;
    if ( s == "+"){
        sum = A + B;
        cout << sum <<endl;

    }
    else {
        subtract = A - B;
        cout << subtract <<endl ;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

#define ALL(a) (a).begin(), (a).end()

int main() {
    ll N;
    cin >> N;

    for (ll h = 1; h <= 3500; h++) {
        for (ll n = 1; n <= 3500; n++) {
            ll x = 4 * h * n - N * n - N * h,
               y = N * h * n;
            if (x > 0 and y % x == 0) {
                ll w = y / x;
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

int main()
 {
 	long long int i,j,n,sum=0,max=0;
 	cin>>n;
 	int c[n],v[n],ans[n];
 	for(i=0;i<n;i++)
 		cin>>v[i];
 	for(i=0;i<n;i++)
 		cin>>c[i];
 	
 	
 	for(i=0;i<n;i++)
 	{
 		if(v[i]>=c[i])
 			ans[i]=	v[i]-c[i];
 		else
 			ans[i]=0;
 	}
 	for(i=0;i<n;i++)
 		sum+=ans[i];
 	cout<<sum<<endl;
 }

Measured memory_bytes: 3616
<?php
// 入力
fscanf(STDIN, '%d %d %d %d', $a, $b, $c, $d);

$ans = 0;

$e = lcm($c, $d);

$ans += $b - $a +1;
$ans -= intdiv($b, $c) - intdiv($a - 1, $c);
$ans -= intdiv($b, $d) - intdiv($a - 1, $d);
$ans += intdiv($b, $e) - intdiv($a - 1, $e);

echo $ans.PHP_EOL;

function gcd($m, $n){
    if($n > $m) list($m, $n) = [$n, $m];

    if ($m % $n === 0) return $n;
    else return gcd($n, $m % $n);
}

function lcm($m, $n){
    return $m * $n / gcd($m, $n);
}

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

int main() {
    int N;
    cin >>N;
    long long mod=1000000007;
    long long count=1;
    for(int i=1;i<=N;i++){
         count*=i;
         count%=mod;
    }
    cout <<count<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	char s[110];
	int k;
	cin >> k >> s;
	int len = strlen(s);
	if (len <= k)
		cout << s << endl;
	else
	{
		s[k] = '.';
		s[k + 1] = '.';
		s[k + 2] = '.';
		s[k + 3] = '\0';
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long int
#define forr(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define oo 1000000000000000000LL
using namespace std;


void _sol(){
    int n,k; cin >> n >> k;
    vector<ll> v(n);
    forr(i,n) cin >> v[i];
    sort(v.begin(),v.end());
    ll ans = 1;
    n--;
    if(k%2){
        if( v[n] <=0 ){
            int p = n;
            while(k>0){
                ans = (ans * v[p])%mod;
                if(ans<0) ans+= mod;
                p--;
                k--;
            }
            cout << ans;
            return;
        }
        ans = (ans * v[n])%mod;
        if(ans<0) ans+= mod;
        k--;
        n--;
    }
    int i = 0;
    while(k>0){
        ll p = v[i]*v[i+1] , q = v[n]*v[n-1];
        if(p>q){
            ans = (ans * (p%mod))%mod;
            i+=2;
        }
        else{
            ans = (ans * (q%mod))%mod;
            n-=2;
        }
        k-=2;
    }
    cout << (ans+mod)%mod;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t = 1; //cin >> t;
    while(t--) _sol();
}


Measured memory_bytes: 4744
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
        int n = int.Parse(ReadLine());
        for (int i = n; i < 1000; i++)
        {
            string s = i.ToString();
            if ((s[0] == s[1]) && (s[1] == s[2])){
                WriteLine(i);
                return;
            }
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
main(){
  int n,w;
  int a[100],b[100],ans[100];
  int i,j;
  int temp;
  scanf("%d %d",&w,&n);
  for(i=0;i<w+1;i++){
    ans[i]=i;
  }
  for(i=0;i<n;i++){
    scanf("%d,%d",&a[i],&b[i]);
    temp=ans[a[i]];
    ans[a[i]]=ans[b[i]];
    ans[b[i]]=temp;
  }
  for(i=0;i<w;i++){
    printf("%d\n",ans[i+1]);
  }
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL K;
typedef pair<int,int> P;
vector<P>v;
int main(){
        cin>>N>>K;
        REP(i,N){
            int a,b;
            cin>>a>>b;
            v.push_back(P(a,b));
        }
	sort(v.begin(),v.end());
	LL count=0;
	REP(i,N){
	    count+=v[i].second;
	    if(count>=K){
	       cout<<v[i].first<<endl;
	       break;
	    }
	}
	return(0);
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int64_t> data(N + 1);
  data.at(0) = 2; data.at(1) = 1;
  
  for (int i = 2; i <= N; i++) {
    data.at(i) = data.at(i-1) + data.at(i-2);
  }
  
  cout << data.at(N) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
 
int main() {
  std::string a,b;
  std::cin>>a>>b;
  //正直
  if(a=="H"){
  	if(b=="H"){
      std::cout<<"H";
    }else{
      std::cout<<"D";
    }
  }
  //嘘つき
  else{
  	if(b=="H"){
      std::cout<<"D";
    }else{
      std::cout<<"H";
    }
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

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

void solve(string S, string T) {
  ll ans(0);
  REP(i, S.length())
    if (S[i] != T[i])
      ans++;
  cout << ans << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

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

  solve(S, T);

  return 0;
}


Measured memory_bytes: 4116
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	ll h, w;
	cin >> h >> w;
	ll c, d;
	cin >> c >> d;
	ll cc, dd;
	cin >> cc >> dd;

	vector<string> s(h);
	rep(i, h)
	{
		cin >> s[i];
	}

	vector<vector<ll>> use(h, vector<ll>(w, LINF));

	deque<pair<ll, pair<ll, ll>>> q;
	pair<ll, ll> temp;
	temp.first = c - 1;
	temp.second = d - 1;
	q.emplace_back(0, temp);

	while (!q.empty())
	{
		pair<ll, pair<ll, ll>> tmp = q.front();
		q.pop_front();

		if (s[tmp.second.first][tmp.second.second] == '#')
			continue;

		if (tmp.first < use[tmp.second.first][tmp.second.second])
		{
			use[tmp.second.first][tmp.second.second] = tmp.first;

			for (int i = -2; i < 3; i++)
			{
				for (int j = -2; j < 3; j++)
				{
					if (i == 0 && j == 0)
						continue;
					if (tmp.second.first + i < 0 || h <= tmp.second.first + i)
						continue;
					if (tmp.second.second + j < 0 || w <= tmp.second.second + j)
						continue;

					temp.first = tmp.second.first + i;
					temp.second = tmp.second.second + j;

					q.emplace_back(tmp.first + 1, temp);
				}
			}
			if (0 <= tmp.second.first - 1)
			{
				temp.first = tmp.second.first - 1;
				temp.second = tmp.second.second;
				q.emplace_front(tmp.first, temp);
			}
			if (tmp.second.first + 1 < h)
			{
				temp.first = tmp.second.first + 1;
				temp.second = tmp.second.second;
				q.emplace_front(tmp.first, temp);
			}
			if (0 <= tmp.second.second - 1)
			{
				temp.first = tmp.second.first;
				temp.second = tmp.second.second - 1;
				q.emplace_front(tmp.first, temp);
			}
			if (tmp.second.second + 1 < w)
			{
				temp.first = tmp.second.first;
				temp.second = tmp.second.second + 1;
				q.emplace_front(tmp.first, temp);
			}

		}
		else
		{
			continue;
		}

	}
	if (use[cc - 1][dd - 1] == LINF)
	{
		cout << -1 << endl;
		ret;
	}
	cout << use[cc - 1][dd - 1] << endl;

	return 0;
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

const int MOD=1e9+7;
ll dp[105][4][4][4];

bool check(int a,int b,int c){
    return (a==1 && b==2 && c==3);
}

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int n;
    cin >> n;
    memset(dp,0,sizeof(dp));

    dp[0][0][0][0]=1;

    FOR(i,0,n){
        FOR(a,0,4){
            FOR(b,0,4){
                FOR(c,0,4){
                    FOR(d,0,4){
                        //AGC, GAC, ACG, ATGC,AGTC
                        if(check(b,c,d) || check(c,b,d) || check(b,d,c)
                                || check(a,c,d) || check(a,b,d))
                            continue;

                        dp[i+1][b][c][d]=(dp[i+1][b][c][d]+dp[i][a][b][c])%MOD;
                    }
                }
            }
        }
    }

    ll res=0;

    FOR(a,0,4){
        FOR(b,0,4){
            FOR(c,0,4){
                res=(res+dp[n][a][b][c])%MOD;
            }
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int n, m;

int main() {
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i,j;
  int value[3],sum,min=300000;
  fscanf(stdin,"%d %d %d",&value[0],&value[1],&value[2]);
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      if (i==j) continue;
      sum = value[i]+value[j];
      if (sum<min){
        min=sum;
      }
    }
  }
  printf("%d\n", min);
  return 0;
}


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

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String state = "ZZZ";
        boolean a = false;
        long aCnt = 0;
        char[] C = new char[S.length()];
        long count = 0;
        for(int i = 0; i < S.length(); i++){
            char c = S.charAt(i);
            C[i] = c;
            if(c == 'A'){
                if(!a){
                    aCnt = 1L;
                    a = true;
                }else{
                    aCnt++;
                }
            }else{
                a = false;
            }
            state = state + String.valueOf(c);
            state = state.substring(1, 4);
            // ABCが揃った時点でBCAに変換
            if(state.equals("ABC")){
                state = "BCA";
                count += aCnt;
                a = true;
            }
        }
        System.out.println(count);
    }
}


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

#define SZ(c) int(c.size())
#define all(c) c.begin(), c.end()
#define rall(a) a.rbegin(),a.rend()
#define pb  push_back
#define clr(a, n) memset(a, n, sizeof a)

typedef vector<int> vi;
typedef long long ll;

vector<pair<int, int>> item;
ll n, wei;
const int sz = 1e5+5;
ll memo[101][sz];

ll knapsack (ll idx, ll w) {
	if (idx == n) {
		return 0;
	}
	if (w > wei) {
		return -1e9;
	}
	if (~memo[idx][w]) {
		return memo[idx][w];
	}
	if (item[idx].first <= w) {
		return memo[idx][w] = max(knapsack(idx+1, w),item[idx].second+knapsack(idx+1, w-item[idx].first));
	} else {
		return knapsack(idx+1, w);
	}
}

int main() {

	cin >> n >> wei;
	for (ll i = 0; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		item.pb({x, y});
	}
	clr(memo, -1);
	cout << knapsack(0, wei);
	return 0;
}


Measured memory_bytes: 79232