akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

int main()
{
	int N, M, C;
	cin >> N >> M >> C;
	
	vector<int> B(M);
	for (int i = 0; i < M; i++)
	{
		cin >> B.at(i);
	}

	vector<vector<int>> A(N, vector<int>(M));
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			cin >> A.at(i).at(j);
		}
	}


	int val;
	int cnt = 0;

	for (int i = 0; i < N; i++)
	{
		val = 0;

		for (int j = 0; j < M; j++)
		{
			val += (A.at(i).at(j) * B.at(j));
		}
		if (val + C > 0)
		{
			cnt++;
		}
	}

	cout << cnt << endl;
}

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

ll dp[105][100010];

int main(){
    int n,x;
    cin>>n>>x;
    vector<int>w(n),v(n);
    rep(i,n)cin>>w[i]>>v[i];
    rep(i,105)rep(j,100010)dp[i][j]=0;
    rep(i,n)for(int j=0; j<=x; ++j){
        if(j-w[i]>=0){
            dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
        }
        else{
            dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
        }
    }
    cout<<dp[n][x]<<endl;
}

Measured memory_bytes: 85684
#include<iostream>

using namespace std;

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

	if (b == 'A') {
		cout << 'T' << endl;
	}
	else if (b == 'T') {
		cout << 'A' << endl;
	}
	else if (b == 'C') {
		cout << 'G' << endl;
	}
	else if (b == 'G') {
		cout << 'C' << endl;
	}

	return 0;
}

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

int main() {
	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		int pm[1000], pe[1000], pj[1000];
		for(int i=0; i<n; i++){
			cin >> pm[i] >> pe[i] >> pj[i];
			if(pm[i]==100 || pe[i]==100 || pj[i]==100 || pm[i]+pe[i]>=180 || pm[i]+pe[i]+pj[i]>=240){
				cout << "A" << endl;
			}
			else if(pm[i]+pe[i]+pj[i]>=210){
				cout << "B" << endl;
			}
			else if(pm[i]+pe[i]+pj[i]>=150 && pm[i]>=80 || pe[i]>=80){
				cout << "B" << endl;
			}
			else cout << "C" << endl;
			
		}
	}
	return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
int i,N[7],T,F,R,t;
char S[105];
int main()
{
    for(i=1;i<=6;i++)scanf("%d",N+i);
    gets(S);
    gets(S);
    for(T=1,F=2,R=3,i=0;S[i];i++)
    {
        switch(S[i])
        {
        case 'N':t=T,T=F,F=7-t;break;
        case 'E':t=R,R=T,T=7-t;break;
        case 'S':t=F,F=T,T=7-t;break;
        case 'W':t=T,T=R,R=7-t;break;
        }
    }
    printf("%d\n",N[T]);
    return 0;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
type I = usize;

fn main() {
    input!{
      n: usize,
    }
    for i in n.. {
        let mut s: Vec<char> = i.to_string().chars().collect();
        s.sort();
        s.dedup();
        if s.len() == 1 {
            return println!("{}", i);
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <numeric>// deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {

	int A, B;
	cin >> A >> B;
	if (A < 9 && B < 9) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}


}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	var t int64
	fmt.Scan(&n, &t)

	ts := make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&ts[i])
	}

	var ans int64
	var tmp int64
	var start int64
	for i := 0; i < n; i++ {
		if i == n-1 {
			ans += tmp
			ans += t
			break
		}
		diff := int64(ts[i+1] - ts[i])
		if diff <= t {
			tmp = ts[i+1] - start
		} else {
			ans += tmp
			ans += t
			tmp = 0
			start = ts[i+1]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4992
N, A, B = map(int,input().split())
X = list(map(int,input().split()))
NewX = []
for i in range(N-1):
  NewX.append((X[i+1]-X[i])*A)
ans = 0
for i in NewX:
  ans+=min(i, B)
print(ans)
  

Measured memory_bytes: 19988
/**********************************
	author:  mariogzsl
**********************************/

#include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,b,a) for(int i=b-1;i>=a;i--)
#define f first
#define s second
#define puts(x) cout<<x<<endl
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
#define MOD 1000000007

ll dp[101][5][5][5];
int n;
ll dfs(int i, int p0, int p1, int p2){
    if(i==n) return 1;
    if(dp[i][p0][p1][p2]!=-1)return dp[i][p0][p1][p2];
    ll ans = 0;
	FOR(j,1,5){
        if(p0==1 && p1==2 && j==3)continue;
        if(p0==1 && p2==2 && j==3)continue;
        if(p1==1 && p2==2 && j==3)continue;
        if(p1==2 && p2==1 && j==3)continue;
        if(p1==1 && p2==3 && j==2)continue;
        ans = (ans+dfs(i+1, p1, p2, j))%MOD;
    }
 
    return dp[i][p0][p1][p2] = ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	memset(dp, -1, sizeof(dp));
	cout << dfs(0, 0, 0, 0) << endl;
	return 0;
} 



Measured memory_bytes: 384
#include<stdio.h>

#define INF -1
#define WHITE 0
#define GRAY 1
#define BLACK 2

int A[1000][1000],d[1000],color[1000],Q[1000],top=1,tail=1,n,v,u;

void bfs(int);

int main(){

  int i,j,k;

  // printf("wa-i1\n");

  scanf("%d",&n);

  //printf("wa-i2\n");

  for(i=1;i<=n;i++){

    A[i][i]=0;

  }
  

  for(i=1;i<=n;i++){
  
    scanf("%d%d",&u,&k);

    //printf("wa-i3\n");
    
    for(j=0;j<k;j++){

      scanf("%d",&v);
      
      A[u][v]=1;

    }
  }

  // for(i=1;i<=n;i++){
  // for(j=1;j<=n;j++){

  //  printf("%d ",A[i][j]);

  //}
  //printf("\n");

  //}

  

 

    // printf("wa-i5\n");
		
    bfs(1);


    
  

  // printf("wa-i6\n");
  
  for(i=1;i<=n;i++){

    printf("%d %d\n",i,d[i]);

  }

  return 0;
}

void bfs(int s){

  int i,u1;

  // printf("wa-i6\n");

  for(i=1;i<=n;i++){

    color[i] = WHITE;
    d[i] = INF;
    
  }

  //printf("wa-i7\n");

  // printf("s: %d\n",s);
  
  color[s] = GRAY;
  d[s] = 0;

  //printf("wa-i8\n");
  
  for(i=1;i<=n;i++){

    Q[i]=INF;
  }

  //printf("wa-i9\n");
  
  tail++;
  Q[tail-1]=s;

  while(tail != top){

    //printf("wa-i10\n");
    top++;
    u1=Q[top-1];

    //printf("Q[top-1]: %d\n",Q[top-1]);

    for(i=1;i<=n;i++){

      //printf("wa-i11\n");

      if(A[u1][i]==1 && color[i]==WHITE){

	//printf("<wa-iwa-iwai>u1:%d,i: %d\n",u1,i);
	color[i]=GRAY;
	d[i]= d[u1] + 1;

	

	//	printf("d[%d]=%d\n",i,d[i]);

	tail++;
	Q[tail-1]=i;
      }
      
    }

    color[u1] = BLACK;
  }

}

Measured memory_bytes: 996
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    string s; cin >> s;
    vector<int> flag(26, 0);
    REP(i, 0, s.size()){
        flag[s[i]-'a']++;
    }
    if(s.size() != 26){
        cout << s;
        REP(i, 0, 26){
            if(flag[i] == 0){
                cout << (alpha[i]) << endl;
                return 0;
            }
        }
    }else{
        int ma = -1;
        vector<char> lis;
        lis.pb(s[25]);
        for(int i = 24; i >= 0; i--){
            int f = 0;
            char mc;
            sort(ALL(lis));
            REP(l, 0, lis.size()){
                if(lis[l] > s[i]){
                    f = 1;
                    mc = lis[l];
                    break;
                }
            }
            if(f == 1){
                REP(l, 0, i){
                    cout << s[l];
                }
                cout << mc << endl;
                return 0;
            }else{
                lis.pb(s[i]);
            }
        }
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
import math
a, b, c = map(int, input().split())
x = 2*a*b
y = a**2+b**2+c**2 -2*a*c-2*b*c
if c-a-b <=0:
	print ("No")
	exit()
if x < y:
	print ("Yes")
else:
	print ("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	ll X;
	cin >> X;
	for (ll A = -1000LL; A < 1000LL; A++)
	{
		for (ll B = -1000LL; B < 1000LL; B++)
		{
			if (pow(A, 5LL) - pow(B, 5LL) == X)
			{
				cout << A << " " << B << endl;
				return (0);
			}
		}
	}
}



Measured memory_bytes: 4028
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100100100;//10^17
const ll MOD = 1000000007;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


ll mpow(ll x, ll n){//繰り返し二乗法 計算量O(logN)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans * x % MOD;
        x = x * x % MOD;
        n  = n >> 1;
    }
    return ans;
}

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



int main(){
    int N;
    cin >> N;
    map<string, int> m;
    rep(i, N){
        string str;
        cin >> str;
        m[str]++;
    }
    int ans = 0;
    for(auto x : m){
        ans++;
    }

    cout << ans << endl;

} 

Measured memory_bytes: 19156
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
q = int(input())
BC = [list(map(int, input().split())) for _ in range(q)]

CA = Counter(A)

s = sum(A)

for b, c in BC:
  heri = CA[b] * b
  hue = CA[b] * c
  s += (- heri + hue)
  CA[c] += CA[b]
  CA[b] = 0
  print(s)

Measured memory_bytes: 40304
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	
	int x=max(a,b);
	int y=min(a,b);
	if(c<=x && c>=y)
	{
		cout<<"Yes";
	}
	else
	cout<<"No";
	cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 998244353;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n, s;
  cin >> n >> s;
  vl a(n);
  rep(i, n) cin >> a[i];
  vector<mint> dp(s + 3010, 0);
  mint ans = 0;
  dp[0] = 1;
  rep(i, n) {
    for(int j = s; j >= 0; j--) dp[j + a[i]] += dp[j];
    dp[0] += 1;
    ans += dp[s];
  }
  cout << ans.x << endl;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N;
  cin >> N;
  vector<vi32> a(N, vi32(N));
  cin >> a;
  vi64 dp(bit32(N), -1e18);
  function<i64(int S)> rec = [&](int S) {
    if (dp[S] != -1e18) return dp[S];
    i64 ret = 0;
    rep(i, N) rep(j, i) {
      if ((S & bit32(i)) && (S & bit32(j))) ret += a[i][j];
    }
    for (int T = (S - 1) & S; T > 0; T = (T - 1) & S) {
      amax(ret, rec(T) + rec(S ^ T));
    }
    return dp[S] = ret;
  };
  cout << rec(bit32(N) - 1) << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int main(){
  int A,B;
  cin>>A>>B;
  cout<<(A+B)%24<<endl;
  return 0; 
}

Measured memory_bytes: 256
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
puts_yesno n.to_s.index("7")

Measured memory_bytes: 14420
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;


int main() {
	int n;
	cin >> n;
	set<int> s;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		auto it = s.find(a);
		if (it != s.end()) {
			s.erase(it);
		}
		else {
			s.insert(a);
		}

	}

	cout << s.size() << endl;
}

Measured memory_bytes: 4864
import math
N = int(input())
ta = []
for _ in range(N):
    ta.append(list(map(int,input().split())))
for i in range(1,N):
    c = max(-(-ta[i-1][0]//ta[i][0]),-(-ta[i-1][1]//ta[i][1]))
    ta[i][0] = ta[i][0]*c
    ta[i][1] = ta[i][1]*c
print(sum(ta[N-1]))

Measured memory_bytes: 3316
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#include<set>
using namespace std;
int n,a[100005],b[100005],c[100005];
int dp[100005][3];
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	    scanf("%d%d%d",&a[i],&b[i],&c[i]);
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for(int i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
		dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
		dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}


Measured memory_bytes: 2560
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;

    cin >> n >> s;
    int ct= 1;
    for(int i =1; i < n; ++i)
    {
        if(s[i] != s[i-1])
            ct++;
    }
    cout << ct;


    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
P D[100005];
int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  for (int i=0; i<N; i++) {
    cin >> D[i].first >> D[i].second;
  }
  sort(D, D+N);
  priority_queue<int> q;
  ll ret = 0;
  int idx = 0;
  for (int i=1; i<=M; i++) {
    while (idx < N && D[idx].first <= i) {
      q.push(D[idx].second);
      idx++;
    }
    if (!q.empty()) {
      ret += q.top();
      q.pop();
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 1660
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int a=sc.nextInt()*sc.nextInt();
	int b=sc.nextInt()*sc.nextInt();
	if(a>b)System.out.println(a);
	else if(a==b)System.out.println(b);
	else System.out.println(b);
	sc.close();
  }
}


Measured memory_bytes: 35568
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[s.length()-1]=='s')
    {
        s.push_back('e');s.push_back('s');
    }
    else
    {
        s.push_back('s');
    }
    cout<<s;
    
}

Measured memory_bytes: 3628
// https://beta.atcoder.jp/contests/abc071
// status:
// tag:

#define SUBMIT
//#define DEBUG

#include <bits/stdc++.h>

using namespace std;
using ui64 = uint64_t;

const ui64 MOD = 1000000007;

int N;
char s[2][52];

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(52
RvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn
RLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn
)");
#endif
    int N;
    stream >> N;
    for (int y = 0; y < 2; ++y) {
        for (int x = 0; x < N; ++x) {
            stream >> s[y][x];
        }
    }

    string prev = "none";
    // 最初の色は3通り
    uint64_t ans = 1 * 3;
    int x = 0;
    while (true) {
        if (N <= x) break;

        // 2x1のドミノ
        if (s[0][x] == s[1][x]) {
            if (prev == "v") (ans *= 2) %= MOD;
            else (ans *= 1) %= MOD;

            x++;
            prev = "v";
        }
        // 1x2のドミノ
        else {
            if (prev == "h") (ans *= 3) %= MOD;
            else (ans *= 2) %= MOD;

            x += 2;
            prev = "h";
        }
    }

    cout << ans << endl;
#ifdef DEBUG
    for (int i = 1; i <= N; ++i) cout << p[i] << " ";
    cout << endl;
#endif
    return 0;
}

Measured memory_bytes: 384
S = input()
ABC = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

for i in range(len(ABC)):
 if ABC[i] not in S:
  print(ABC[i])
  exit()
else:
  print("None")

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

#define MOD 1000000007

int main(){
    char s;
    cin >> s;
    s++;
    cout << s << endl;
}

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

using namespace std;

int main(void){
    
    int n,k;
    cin >> n >> k;
    
    double result = 0;
    for(int i=1; i<=n; i++) {

        int num = i;
        int count = 0;
        while(1) {
            if(num >= k) break;
            count++;
            num *= 2;
        }
        result += 1.0/n * pow(1.0/2.0, count);
//        cout << result << " " << count << endl;
    }

    cout << setprecision(12) << result << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int arr[100005];
bool visited[100005];
long long ans;
long long MOD=1e9+7;
int n;
int brr[100005]={0};
int main()
{
    scanf("%d",&n);
    bool flag=true;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&arr[i]);
        brr[arr[i]]++;
    }
    if(n%2==0)
    {
        if(brr[0]>=1)
        {
            printf("0\n");
            return 0;
        }
        for(int i=1;i<=n-1;i+=2)
        {
            if(brr[i]!=2)
            {
                printf("0\n");
                return 0;
            }
        }
    }
    else
    {
        if(brr[0]!=1)
        {
            printf("0\n");
            return 0;
        }
        for(int i=2;i<=n-1;i+=2)
        {
            if(brr[i]!=2)
            {
                printf("0\n");
                return 0;
            }
        }
    }
    ans=1;
    for(int i=1;i<=n/2;i++)
        ans=((ans%MOD)*2)%MOD;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

struct union_find{
  vector<int> par,r;

  union_find(int n){
  	par.resize(n);
  	r.resize(n);
  	init(n);
  }

  void init(int n){
    for(int i = 0; i < n; i++) par[i] = i;
    for(int i = 0; i < n; i++) r[i] = 0;
  }

  int find(int x){
    if(par[x] == x) return x;
    else return find(par[x]);
  }

  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(r[x] < r[y]){
      par[x] = y;
    }else{
      par[y] = x;
      if(r[x] == r[y]) r[x]++;
    }
  }

  bool same(int x,int y){
  	return find(x) == find(y);
  }
};

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

	vector<pair<int,int> > e(m);

	for(int i = 0; i < m; i++){
		cin >> e[i].first >> e[i].second;
		e[i].first--;
		e[i].second--;
	}

	int ans = 0;
	for(int i = 0; i < m; i++){
		union_find uf(n);

		for(int j = 0; j < m; j++){
			if(i!=j && !uf.same(e[j].first,e[j].second)){
				uf.unite(e[j].first,e[j].second);
			}
		}
		set<int> s;
		for(int j = 0; j < n; j++){
			if(uf.par[j]==j) s.insert(uf.par[j]);
		}
		if(s.size()>1) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 888
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var q = int.Parse(line[1]);
        var s = Console.ReadLine().Trim();
        var a = new int[n];
        for (int i = 0; i < n - 1; i++)
            if (s[i] == 'A' && s[i + 1] == 'C') a[i] = 1;
        var b = new int[n + 1];
        for (int i = 1; i <= n; i++)
            b[i] = b[i - 1] + a[i - 1];
        for (int i = 0; i < q; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var L = int.Parse(line[0]);
            var r = int.Parse(line[1]);
            Console.WriteLine(getAns(b,L,r));
        }
    }
    static int getAns (int[] b, int L , int r) => b[r - 1] - b[L - 1];
}

Measured memory_bytes: 17800
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string up,low;
  cin >>up;
  cin >>low;
  if(up[0]==low[2] && up[1]==low[1] && up[2]==low[0]){
    cout <<"YES"<<endl;
  }
  else{
    cout <<"NO"<<endl;
  }
  return 0;
}

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

typedef long long ll;

vector<ll>path[101010];
ll depth[2][101010];

ll cnt[2][101010];

int main(){
    for(ll i = 0; i < 101010; i++){
        depth[0][i] = -1;
        depth[1][i] = -1;
    }
    ll N, M, s, t;
    cin >> N >> M >> s >> t;
    for(ll i = 0; i < M; i++){
        ll x, y;
        cin >> x >> y;
        path[x].push_back(y);
        path[y].push_back(x);
    }
    for(ll i = 0; i < 2; i++){
        queue<ll>Q;
        if(i==0){
            Q.push(s);
            depth[i][s] = 0;
        }
        else{
            Q.push(t);
            depth[i][t] = 0;
        }
        while(!Q.empty()){
            ll idx = Q.front();
            Q.pop();
            cnt[i][depth[i][idx]]++;
            for(ll j = 0; j < path[idx].size(); j++){
                ll nxt = path[idx][j];
                if(depth[i][nxt] >= 0)continue;
                depth[i][nxt] = depth[i][idx] + 1;
                Q.push(nxt);
            }
        }
    }
    ll mn = depth[1][s];
    ll ans = 0;
    for(ll a = 0; a <= N; a++){
        ll b = mn - a - 2;
        if(b < 0)continue;
        ans += cnt[0][a] * cnt[1][b];
    }
    cout << ans << endl;
    
    return 0;    
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 21;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 62;

ll n,q;
ll a[e5];
ll x[e5];
ll arg_x[e5];
ll b[e5]; // 0 --- takahashi, 1 --- aoki
ll ans[e5];
ll mem;

int main(){
  cin >> n >> q;
  for(ll i = 1;i <= n;i++) cin >> a[i];

  for(ll i = 1;i <= q;i++) cin >> x[i];
  iota(arg_x,arg_x+q+1,0ll);
  sort(arg_x+1,arg_x+q+1,[](ll a,ll b){
    return x[a] < x[b];
  });
  // for(ll i = 1;i <= q;i++) cerr << x[arg_x[i]] << " ";
  // cerr << endl;
  for(ll i = n/2+1;i <= n;i++) mem += a[i];
  ll l = n%2 ? 1 : 2;
  ll r = n/2+1;
  for(ll i = 1;i <= q;i++){
    while(r < n && abs(a[l]-x[arg_x[i]]) > abs(a[r]-x[arg_x[i]])){
      mem -= a[r];
      mem += a[l];
      r++;
      l += 2;
    }
    ans[arg_x[i]] = mem;
  }
  for(ll i = 1;i <= q;i++) cout << ans[i] << endl;

}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
vll d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}
void sortll(vll &a) {sort(a.begin(), a.end());}
void sortc(string &a) {sort(a.begin(), a.end());}
void sorts(vs &a) {sort(a.begin(), a.end());}

int main() {
  string n;
  cin >> n;
  if (n[0] == '9' || n[1] == '9') Yes();
  else No();
}

Measured memory_bytes: 768
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
   int x;
   cin>>x;
   if(x>=400 && x<=599)
   {
   	cout<<"8";
   }
   else if(x>=600 && x<=799)
   {
   	cout<<"7";
   }
   else if(x>=800 && x<=999)
   {
   	cout<<"6";
   }
   else if(x>=1000 && x<=1199)
   {
   	cout<<"5";
   }
   else if(x>=1200 && x<=1399)
   {
   	cout<<"4";
   }
   else if(x>=1400 && x<=1599)
   {
   	cout<<"3";
   }
   else if(x>=1600 && x<=1799)
   {
   	cout<<"2";
   }
   else if(x>=1800 && x<=1999)
   {
   	cout<<"1";
   }
}


Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	int h ,w;
	while (cin >> h >> w) {
		if (h == 0 && w == 0) {
			break;
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (i % 2 == 0) {
					if (j % 2 == 0) {
						cout << "#";
					}
					else {
						cout << ".";
					}
				}
				else {
					if (j % 2 == 0) {
						cout << ".";
					}
					else {
						cout << "#";
					}
				}
				if (j == w - 1) {
					cout << endl;
				}
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
class Solution(object):
    def frog_1(self, stones):

        dp = [float('inf') for _ in range(len(stones))]
        dp[0] = 0
        for i, stone in enumerate(stones):
            for j in [i+1, i+2]:
                if j < len(stones):
                    # print('i:', i, 'j:', j)
                    dp[j] = min(dp[j], dp[i]+abs(stones[i]-stones[j]))

        # print(dp)
        return dp[-1]




if __name__ == '__main__':
    N = input()
    stones = list(map(int, input().strip().split()))
    sol = Solution()
    res = sol.frog_1(stones)
    print(res)



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

int main() {

    string s;
    cin >> s;

    int pay = 700;

    if (s[0] == 'o') pay += 100;
    if (s[1] == 'o') pay += 100;
    if (s[2] == 'o') pay += 100;

    cout << pay << endl;

    return 0;
}

Measured memory_bytes: 3600
def bubbleSort(A, N):
    flag = 1
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j][1] < A[j-1][1]:
                A[j], A[j-1] = A[j-1], A[j]
                flag = 1
    print(*A)
    return A


def selectionSort(A, N):
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j][1] < A[minj][1]:
                minj = j
        A[i], A[minj] = A[minj], A[i]

    print(*A)
    return A


def isStable(input, output, N):
    for i in range(N):
        for j in range(i + 1, N):
            for a in range(N):
                for b in range(a + 1, N):
                    if input[i][1] == input[j][1] and input[i] == output[b] and input[j] == output[a]:
                        print("Not stable")
                        return False
    print("Stable")
    return True

arr_length = int(input())
arr_num = [i for i in input().split(" ")]

isStable(arr_num, bubbleSort(list(arr_num), arr_length), arr_length)

isStable(arr_num, selectionSort(list(arr_num), arr_length), arr_length)


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int joutaisuu = 1;
    REP(i,n) joutaisuu *= 2;
    int A[20][20];
    REP(i,n) REP(j,n) cin >> A[i][j];
    
    int dp[joutaisuu + 5];
    REP(i,joutaisuu) dp[i] = - INF;
    int hoge = 1;
    dp[0] = 0;
    int mask = 1;
    while(mask < joutaisuu){
        int mask2 = mask -1;
        mask2 = (mask2 & mask);
        while(mask2 > 0){
            int tmp = 0;
            tmp += dp[mask2];
            int mask3 = mask - mask2;
            tmp += dp[mask3];
            chmax(dp[mask],tmp);
            mask2 -= 1;
            mask2 = (mask2 & mask);
        }
        int tmp = 0;
        int id1 = 0;
        int hoge = 1;
        vector<int> ids;
        while(hoge < joutaisuu){
            if( (hoge & mask) ) ids.push_back(id1);
            hoge *= 2;
            id1 ++;
        }

        itrfor(itr1,ids){
            itrfor(itr2,ids){
                tmp += A[*itr1][*itr2];
            }
        }
        tmp /= 2;
        chmax(dp[mask],tmp);

        mask ++;

    }

    cout << dp[joutaisuu - 1] << endl;

}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;


int main()
{
	int X;
	cin >> X;
	cout << 10 - X / 200 << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int n, m;
  cin >> n >> m;
  ll sum = 0;
  rep(i, m) {
    int a;
    cin >> a;
    sum += a;
  }
  if (sum > n) {
    cout << -1 << endl;
  } else {
    cout << n - sum << endl;
  }
  return 0;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}

int main(void)
{
    string s,t;
    cin>>s>>t;
    if(s[0]==t[2]&&s[1]==t[1]&&s[2]==t[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
M = 256
while 1:
    N = int(raw_input())
    if N == 0: break
    H = 1e10
    l = map(int,raw_input().split())
    for S in range(16):
        for A in range(16):
            for C in range(16):
                R = S
                O = [0]*M
                for i in range(N):
                    R = (A*R+C)%M
                    O[(l[i]+R)%M] += 1
                tmp = -sum(1.0*x/N*math.log(1.0*x/N,2) for x in O if x != 0)
                if tmp < H:
                    H = tmp
                    ans = [S,A,C]
    print " ".join(map(str,ans))

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int j = n - i;
        if (i >= j) continue;
        ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	ll N;
	cin >> N;
	cout << (N - 1) * N / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int x;
    cin >> x;
    if (x == 7 || x == 5 || x == 3){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

}


Measured memory_bytes: 256
N = int(input())

if N%2 == 0:
  print(N, N, N//2)
else:
  for h in range(3500, -1, -1):
    num = N*h*h; diff_num = N*h
    dem = 4*h*h - N*(h+h); diff_dem = 4*h - N
    for n in range(h, -1, -1):
      if dem <= 0:
        break
      if num%dem == 0:
        print(h, n, num//dem)
        quit()
      num -= diff_num
      dem -= diff_dem

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char  ch;
    cin>>ch;
    if(ch=='A')
    {
        cout<<"T"<<endl;
    } else if(ch=='T')
    {
        cout<<"A"<<endl;
    } else if(ch=='G')
    {
        cout<<"C"<<endl;
    }
    else cout<<"G"<<endl;
}



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

int main() {
  int N;
  long long Sum=0;
  cin >> N;
  rep(i, N){
    if((i+1)%3==0 | (i+1)%5==0) continue;
    else Sum+=(i+1);
  }
  cout << Sum << endl;
}

Measured memory_bytes: 3608
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (s, w) = InputLine.to_ia

  puts (s > w ? 'safe' : 'unsafe')
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14368
//
//  2.cpp
//  sample
//
//  Created by Sakiko Miyazawa on 2020/03/22.
//  Copyright © 2020 Sakiko Miyazawa. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    switch (N%10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout<<"hon"<<endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout<<"pon"<<endl;
            break;
        case 3:
            cout<<"bon"<<endl;
            break;
        default:
            break;
    }

}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int N;
char S[301][301];
int sum;

bool check(int A,int B){
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            if(S[(i+A)%N][(j+B)%N]!=S[(j+A)%N][(i+B)%N]){
                return false;
            }
        }
    }
    return true;
}

int main(){
    cin>>N;
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            cin>>S[i][j];
        }
    }

    for(int A=0;A<N;++A){
            if(check(A,0)){
                sum+=N;
            }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
using namespace std;

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

    bool ok = true;
    int X = 0, Y = 0, T = 0;
    for(int i = 0; i <=N; ++i)
        {
    int t, x, y;
    cin >> t >> x >> y;
    int u=t-T;
    int d = abs(x-X) + abs(y-Y);
    if(u < d || (u- d)%2==1 ) ok = false;
        }
      if(ok) cout << "Yes" << endl;
      else   cout << "No" << endl;
      return 0;
    }


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    N,S,Q,*q = read().split()
    S = S.decode()
    tree = SegmentTree(initial_values=S, f=lambda x,y:x|y, converter=lambda c: 1 << (ord(c)-ord('a')))
    update = tree.update
    query = tree.query
    for t, a, b in zip(*[iter(q)]*3):
        if t == b'1': update(int(a)-1, b)
        else: print(bin(query(int(a)-1, int(b))).count('1'))

class SegmentTree:
    def __init__(self, n=None, f=max, zero_factory=int, converter=lambda x:x, initial_values=None):
        assert(n or initial_values)
        size = n if n else len(initial_values)
        self.__f, self.__z, self.__c = f, zero_factory, converter
        self.__n = 1 << ((size - 1).bit_length())
        self.__dat = [zero_factory() for _ in range(2 * self.__n)]
        if initial_values:
            zi = self.__get_leaf(0)
            for i, v in enumerate(initial_values): self.__dat[zi + i] = converter(v)
            for i in range(zi-1, -1, -1): self.__dat[i] = f(*self.__get_children(i))

    def update(self, index, value):
        i, v = self.__get_leaf(index), self.__c(value)
        if self.__dat[i] == v: return
        self.__dat[i] = v
        while i:
            i = self.__get_parent(i)
            self.__dat[i] = self.__f(*self.__get_children(i))

    def query(self, from_inclusive, to_exclusive):
        ans = self.__z()
        if to_exclusive <= from_inclusive: return ans
        l, r = self.__get_leaf(from_inclusive), self.__get_leaf(to_exclusive) - 1
        while r - l > 1:
            if self.__is_right(l): ans = self.__f(ans, self.__dat[l])
            if self.__is_left(r): ans, r = self.__f(ans, self.__dat[r]), r-1
            l, r = l//2, self.__get_parent(r)
        ans = self.__f(ans, self.__dat[l])
        if l != r: ans = self.__f(ans, self.__dat[r])
        return ans

    def __get_leaf(self, i): return self.__n + i - 1
    def __get_parent(self, i): return (i-1)//2
    def __get_children(self, i): return (self.__dat[2*i+1], self.__dat[2*i+2])
    def __is_left(self, i): return i&1 == 1
    def __is_right(self, i): return i&1 == 0

if __name__ == '__main__':
    main()


Measured memory_bytes: 112208
#include <bits/stdc++.h>
#define MAX 100000000
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

ull dp[105][100005]={};
int main() {
  ll N,W;
  cin >> N >> W;
  vector<ull> weight(N);
  vector<ull> value(N);
  for(int i=0;i<N;i++) {cin >> weight[i] >> value[i];}
  for(int i=0;i<=N;i++) dp[i][0]=0;
  for(int i=0;i<N;i++) {
    for(int ans=0;ans<=W;ans++) {
      if(ans>=weight[i])
        dp[i+1][ans] = max(dp[i][ans-weight[i]]+value[i], dp[i][ans]);
      else
        dp[i+1][ans] = dp[i][ans];
    }
  }
  cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
from bisect import bisect_left, bisect_right


def solve(n, ab_list):
    a_list = []
    b_list = []
    for a, b in ab_list:
        a_list.append(a)
        b_list.append(b)
    a_list = sorted(a_list)
    b_list = sorted(b_list)
    v_list = list(sorted(list(set(a_list + b_list))))
    m = len(v_list)

    if n % 2 == 1:
        ok_min = 10 ** 9 + 7
        ok_max = -1
        for i in range(m):
            v = v_list[i]
            lower_count = bisect_left(b_list, v)
            higher_count = n - bisect_right(a_list, v)
            if lower_count <= n // 2 and higher_count <= n // 2:
                ok_min = min(ok_min, v)
                ok_max = max(ok_max, v)
        return ok_max - ok_min + 1
    else:
        ok_min_left = 10 ** 9 + 7
        ok_max_left = -1
        ok_min_right = 10 ** 9 + 7
        ok_max_right = -1
        for i in range(m):
            v = v_list[i]
            lower_count = bisect_left(b_list, v)
            higher_count = n - bisect_right(a_list, v)
            if lower_count <= n // 2 - 1 and higher_count <= n // 2:
                ok_min_left = min(ok_min_left, v)
                ok_max_left = max(ok_max_left, v)
            if lower_count <= n // 2 and higher_count <= n // 2 - 1:
                ok_min_right = min(ok_min_right, v)
                ok_max_right = max(ok_max_right, v)
        return (ok_max_right - ok_min_right + ok_max_left - ok_min_left) + 1


def main():
    n = int(input())
    ab_list = [list(map(int, input().split())) for _ in range(n)]
    res = solve(n, ab_list)
    print(res)


def test():
    assert solve(2, [[1, 2], [2, 3]]) == 3
    assert solve(3, [[100, 100], [10, 10000], [1, 1000000000]]) == 9991


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 76996