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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        string x; _i64 ans; const char base = '0';
        while(cin >> x && x != "0") {
            ans = 0; _foreach(e, x) { ans += e - base; } cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3228
#include<iostream>
using namespace std;
int a[200005];
int lmax[200005];
int rmax[200005];
int main(void)
{
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> a[i];
    for(int i=1;i<=n;i++)
        lmax[i]=max(lmax[i-1],a[i-1]);
    for(int i=n;i>=1;i--)
        rmax[i]=max(rmax[i+1],a[i+1]);
    for(int i=1;i<=n;i++)
        cout << max(lmax[i],rmax[i]) << '\n';
    return 0;
}


Measured memory_bytes: 3968
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int const mxn=2e5+5;

ll a[mxn];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin >> n;
	for(int i=0; i<n; i++)cin >> a[i];
	map<ll, int>pls,minus;
	for(int i=0; i<n; i++){
		pls[a[i]+i]++;
		minus[a[i]-i]++;
	}
	ll ans = 0;
	for(auto &x:pls){
		ll cur = x.fi;
		int cnt = x.se;
		cur *= -1;
		int cnt2 = minus[cur];
		ans += ll(cnt)*cnt2;
	}
	cout << ans << endl;
}	


Measured memory_bytes: 39332
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;

void main(){
   auto A=readln.split.to!(int[]),a=A[0],b=A[1],c=A[2];
	if(a+b>=c)writeln("Yes");
	else writeln("No");
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  int c = 0;
  int prev = v[0];
  int seq = 1;
  for (int i = 1; i < n; i++) {
    if (prev == v[i]) {
      seq += 1;
    } else {
      if(seq < prev) {
        c += seq;
      } else {
        c += seq - prev;
      }
      seq = 1;
      prev = v[i];
    }
  }
  if(seq < prev) {
    c += seq;
  } else {
    c += seq - prev;
  }
  cout << c << endl;
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const int MX = 1e6+5;


struct Sieve { // 篩
    int n;
    vector<int> f, primes;
    Sieve(int n=1):n(n), f(n+1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i*i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x) { return f[x] == x;} // 素数判定
    set<int> factorList(int x, set<int> &res) { // 素因数列挙
        
        while (x != 1) {
            res.insert(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<P> factor(int x, vector<P> &res) { // 素因数分解 int        
        
        for(int &p : primes) {
            int y = 0;
            while(x % p == 0) x /= p, y++;
            if(y != 0) res.emplace_back(p,y);
        }
        return res;
    }
    vector<pair<ll, int>> factorll(ll x) { // 素因数分解 long long 
        vector<pair<ll, int>> res;
        for(int p : primes) {
            int y = 0;
            while(x % p == 0) x /= p, y++;
            if(y != 0) res.emplace_back(p,y);
        }
        if(x != 1) res.emplace_back(x,1);
        return res;
    }
};


int main(){
    
    int n;
    cin >> n;
    V<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));

    Sieve sve(MX);

    V<bool> seen(MX);
    bool ok = true;
    rep(i,n) {
        set<int> factor;
        sve.factorList(a[i], factor);
        for(int x : factor) {
            // cout << x << endl;
            if(seen[x]) {
                ok = false;
                break;
            }
            else seen[x] = true;
        }
    }
    if(ok) {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    int g = a[0];
    Rep(i,n-1) {
        g = gcd(g,a[i]);
    }
    if(g == 1) {
        cout << "setwise coprime" << endl;
    }
    else {
        cout << "not coprime" << endl;
    }
}

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

char s[52][52];
	
int main() {
	int w, h;
	cin >> h >> w;
	
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			cin >> s[i][j];
		}
	}
	
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			if(s[i][j] == '#'){
				cout << '#';
				continue;
			}
			
			int c = 0;
			for(int k = -1; k <= 1; k++){
				for(int l = -1; l <= 1; l++){
					if(k == 0 && l == 0){
						continue;
					}
					
					if(s[i+k][j+l] == '#'){
						c++;
					}
				}
			}
			
			cout << c;
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
  int n;
  while(cin >> n, n){
    vector< vector<int> > V(31);
    int f, d;
    for(int i = 0; i < n; ++i){
      cin >> f;
      for(int j = 0; j < f; ++j){
	cin >> d;
	V[d].push_back(i);
      }
    }
    bool M[n][n];
    for(int i = 0; i < n; ++i){
      fill(M[i],M[i]+n,false);
      M[i][i] = true;
    }
    bool g = false;
    for(int i = 0; i < 31; ++i){
      bool t[n];
      fill(t,t+n,false);
      for(int j = 0; j < (int)V[i].size(); ++j){
	for(int k = 0; k < n; ++k){
	  t[k] |= M[V[i][j]][k];
	}
      }
      g = true;
      for(int j = 0; j < n; ++j)
	g &= t[j];
      if(g){
	cout << i << endl;
	break;
      }else{
	for(int j = 0; j < (int)V[i].size(); ++j){
	  for(int k = 0; k < n; ++k){
	    M[V[i][j]][k] = t[k];
	  }
	}
      }
    }
    if(!g) cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3144
#include <iostream>
using namespace std;
int main(void)
{
  int ans = 0;
  int a = 0;
  for (int i = 0; i < 3; i++)
  {
    cin >> a;
    ans += a;
  }
  if (ans >= 22) cout << "bust";
  else cout << "win";
  return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 200005
const ll MOD = 1000000007;

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

	ll n,k;
	string s;
	ll val[3];
	cin>>n>>k>>val[0]>>val[2]>>val[1];
	cin>>s;
	ll best[n];
	for(int i=0;i<n;i++){
		if(s[i] == 'r')
			best[i] = 1;
		else if(s[i] == 'p')
			best[i] = 2;
		else
			best[i] = 0;
	}

	// RPS
	ll dp[n][3];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++){
		if(i<k){
			dp[i][best[i]] = val[best[i]];
		}
		else{
			for(int j=0;j<3;j++){
				dp[i][j] = max(dp[i-k][(j+1)%3],dp[i-k][(j+2)%3]);
				if(j == best[i])
					dp[i][j] += val[best[i]];
			}
		}
	}

	ll ans = 0;
	for(int i=n-1;i>=n-k;i--)
		ans += max(dp[i][0],max(dp[i][1],dp[i][2]));
	cout<<ans<<endl;
}

Measured memory_bytes: 3664
use std::io::Write;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let mut ans = vec!['.'; 2 * n];

    sc.write("?");
    for i in 1..=n {
        sc.write(" ");
        sc.write(i);
    }
    sc.write("\n");
    let left = sc.chars()[0];

    let mut l = 0;
    let mut r = n;
    while r - l > 1 {
        let m = (r + l) / 2;
        sc.write("?");
        for i in 0..n {
            sc.write(" ");
            sc.write(m + i + 1);
        }
        sc.write("\n");
        let result = sc.chars()[0];
        if result == left {
            l = m;
        } else {
            r = m;
        }
    }
    let right = if left == 'R' { 'B' } else { 'R' };

    ans[l] = left;
    ans[l + n] = right;
    for i in 0..(2 * n) {
        if l <= i && i <= l + n {
            continue;
        }
        sc.write("? ");
        sc.write(i + 1);
        for i in 1..n {
            sc.write(" ");
            sc.write(l + i + 1);
        }
        sc.write("\n");
        ans[i] = sc.chars()[0];
    }

    let mut red = vec![];
    let mut blue = vec![];
    for i in 0..(2 * n) {
        if ans[i] == 'R' && red.len() * 2 + 1 < n {
            red.push(i);
        }
        if ans[i] == 'B' && blue.len() * 2 + 1 < n {
            blue.push(i);
        }
    }
    assert_eq!(red.len(), n / 2);
    assert_eq!(blue.len(), n / 2);

    for i in 0..(2 * n) {
        if ans[i] != '.' {
            continue;
        }
        sc.write("? ");
        sc.write(i + 1);
        for &r in red.iter() {
            sc.write(" ");
            sc.write(r + 1);
        }
        for &r in blue.iter() {
            sc.write(" ");
            sc.write(r + 1);
        }
        sc.write("\n");
        ans[i] = sc.chars()[0];
    }

    sc.write("! ");
    for &ans in ans.iter() {
        sc.write(ans);
    }
    sc.write("\n");
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
        self.1.flush().unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main() {
	int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
	cout << min(min(a, b), c) + min(d, e) - 50 << endl;
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  if(s=="Sunny") cout << "Cloudy" << endl;
  if(s=="Cloudy") cout << "Rainy" << endl;
  if(s=="Rainy") cout << "Sunny" << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll MOD=1e9+7;
const ll MOD2=1e9+9;
const ll N=1e5+5;
const ld pi=3.14159265359;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()

ll nxt[N][30],chk[30],l=0,r=2e5;
string s,t;

bool ok(string a,string b){
	REP(i,SZ(a))chk[a[i]-'a']=1;
	REP(i,SZ(b)){
		if(!chk[b[i]-'a'])return 0;
	}
	return 1;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	REP(i,N)REP(j,30)nxt[i][j]=MOD;
	cin>>s>>t;
	if(!ok(s,t)){cout<<-1;return 0;}
	for(ll i=SZ(s)-1;i>=0;i--){
		REP(j,26)nxt[i][j]=nxt[i+1][j];
		nxt[i][s[i]-'a']=i+1;
	}
	ll id=0;
	REP(i,SZ(t)){
		if(nxt[id%SZ(s)][t[i]-'a']==MOD){id=(id/SZ(s))*SZ(s)+SZ(s);}
		id=nxt[id%SZ(s)][t[i]-'a']+(id/SZ(s))*SZ(s);
	}
	cout<<id<<"\n";
	return 0;
}




Measured memory_bytes: 24144
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   int n,r;
   cin>>n>>r;
   n>=10? cout<<r:cout<<r+100*(10-n);
   




return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
#define MOD 1000000007
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
//最大公約数
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
//最小公倍数
int lcm(int a,int b){
   return a*b/gcd(a,b);
}
bool prime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0)
        return false;
    }
    return true;
}
int main(){
    string s;
    cin>>s;
    while(s.size()>3)
    s.pop_back();
    cout<<s<<endl;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    blue_card_count = int(input())
    blue_cards = list()

    for i in range(blue_card_count):
        blue_cards.append(input())

    red_card_count = int(input())
    red_cards = list()

    for i in range(red_card_count):
        red_cards.append(input())

    count_max = 0

    set_blue_card = set(blue_cards)

    for blue_card in set_blue_card:
        candidate = blue_cards.count(blue_card) - red_cards.count(blue_card)
        if candidate > count_max:
            count_max = candidate

    print(count_max)


Measured memory_bytes: 3060
(defun main ()
  (let ((n (read))
        (ans 0))
    (dotimes (i n)
      (if (/= 0 (rem (1+ i) 3))
          (if (/= 0 (rem (1+ i) 5))
              (setf ans (+ ans (1+ i))))))
    (format t "~d~%" ans)))
          
(main)


Measured memory_bytes: 24316
#include <stdio.h>

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


Measured memory_bytes: 128
s = input()
l = len(s)
count = 0

# print(s[0:1])

for i in range(l//2):
    if s[i:i+1] != s[l-1-i:l-i]:
#        print(s[i:i+1]+' '+s[l-1-i:l-i])
        count += 1
print(count)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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; }
template<typename T>
void ppp(T n){cout << n << endl;}
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) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;



int main(){

    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    multiset<int> m;
    rep(i, n){
        int idx = n-i-1;
        auto it = m.upper_bound(a[idx]);
        if(it != m.end()){
            m.erase(it);
        }
        m.insert(a[idx]);
    }
    ppp(m.size());

    return 0;
}


Measured memory_bytes: 5760
#include<stdio.h>

int PRT(int *,int,int);

int main(){
int i,j,q,A[100000],n;

scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  q = PRT(A,0,n-1);
for(i=0;i<q;i++){
    printf("%d ",A[i]);
}
printf("[%d]",A[q]);

for(i=q+1;i<n;i++){
    printf(" %d",A[i]);
}
printf("\n");
return 0;
}

int PRT(int *A,int p,int r){
    int i,j,x,tmp;

    x = A[r];
    i = p - 1;
    for(j = p; j<r; j++){
        if(A[j] <= x){
            i++;
            tmp = A[j];
            A[j] =  A[i];
            A[i] = tmp;
        }
    }
            tmp = A[i+1];
            A[i+1] =  A[r];
            A[r] = tmp;
    return i+1;
}


Measured memory_bytes: 2144
import java.io.*;
import java.util.* ;

public class Main {

    static int n,k ;
    static int [] w,v ;
    static long dp[][] ;

    static long dp (int idx , int k ){
        if (k<0){
            return -(int) 1e9 ;
        }
        if(idx == n)
            return 0 ;
        else{
            if (dp[idx][k]!=-1){
                return dp[idx][k] ;
            }
            long take = v[idx] + dp(idx+1,k-w[idx]) ;
            long leave = dp(idx+1 , k) ;
            return dp[idx][k] = Math.max(take,leave) ;
        }
    }

    public  static void main (String args [] ) throws IOException ,InterruptedException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        n = sc.nextInt() ;
        k = sc.nextInt() ;
        w = new int[n] ;
        v = new int[n] ;
        dp = new long [n][k+1] ;
        for (int i =0 ; i < n ;i ++  ) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
            Arrays.fill(dp[i],-1);
        }

        pw.println(dp(0,k));

        pw.close();
    }
     static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public Scanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }

        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }
    }
}


Measured memory_bytes: 131080
Sentense=gets.chomp

if Sentense.length%2==0 then
  Sentense.chop!.chop!
else
  Sentense.chop!
end

loop do
  if Sentense[0...Sentense.length/2].eql?(Sentense[Sentense.length/2..Sentense.length-1])
    puts Sentense.length
    break
  end
  Sentense.chop!.chop!
end

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define pb push_back
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define MAXBOOL 500000
using namespace std;

int main(){
	int n,p;
	vector<int> prime;
	bool check[MAXBOOL];
	while(cin>>n>>p,n!=-1||p!=-1){
		prime.clear();
		fill(check,check+MAXBOOL,true);
		check[0]=check[1]=false;
		loop(i,2,sqrt(MAXBOOL)){
			for(int j=i*2;j<MAXBOOL;j+=i){
				check[j]=false;
			}
		}
		int cnt=0;
		while(prime.size()<=200){
			if(check[n+1+cnt])prime.pb(n+1+cnt);
			cnt++;
		}
		vector<int> ans;
		rep(i,prime.size()){
			loop(j,i,prime.size()){
				ans.pb(prime[i]+prime[j]);
			}
		}
		sort(all(ans));
		cout<<ans[p-1]<<endl;
	}
	return 0;
}


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

#define ll long long

using namespace std;

const int MAXN = 100010;
const int MAXM = 100010;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int n, m, k;
int ans, tot, cnt;

int a[MAXN];
int head[MAXN];

string s;

inline int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while ('0' > ch || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while ('0' <= ch && ch <= '9') {s = (s << 3) + (s << 1) + ch - 48; ch = getchar();}
	return s * f;
}

struct edge {
	int to, next;
}e[MAXN * 2];

void add_edge(int x, int y) {
	e[++tot].to = y;
	e[tot].next = head[x];
	head[x] = tot;
	return;
}

int main(){
	int T;
	string s1, s2, s3;
	cin >> s1 >> s2;
	for (int i = 0; i < s2.size() - 1; i++) s3 += s2[i];
	if (s3 == s1) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



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


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

    int N;
    cin >> N;
    ll t = 0;
    int a = 0;
    for(int i=1; i<=N; i++){
      t += i;
      if(t >= N){
        a = i;
        break;
      }
    }
    t = 0;
    for(int i=a; i>0; i--){
      if(t+i <= N){
        t += i;
        cout << i << endl;
        if(t == N){
          return 0;
        }
      }
    }
}


Measured memory_bytes: 256
#include <stdio.h>

char map[21][21];

int main(void) {
	int hoseki_num;
	int hoseki_x,hoseki_y;
	int order_num;
	char direction[4];
	int movement;
	int robot_x,robot_y;
	int i,j;
	int ok;
	while(1) {
		scanf("%d",&hoseki_num);
		if(hoseki_num==0)break;
		for(i=0;i<=20;i++) {
			for(j=0;j<=20;j++)map[i][j]=0;
		}
		for(i=0;i<hoseki_num;i++) {
			scanf("%d%d",&hoseki_x,&hoseki_y);
			map[hoseki_y][hoseki_x]=1;
		}
		scanf("%d",&order_num);
		robot_x=robot_y=10;
		map[10][10]=0;
		for(i=0;i<order_num;i++) {
			scanf("%s%d",direction,&movement);
			switch(direction[0]) {
				case 'N':
					for(j=0;j<movement;j++,robot_y++) {
						map[robot_y][robot_x]=0;
					}
					break;
				case 'E':
					for(j=0;j<movement;j++,robot_x++) {
						map[robot_y][robot_x]=0;
					}
					break;
				case 'S':
					for(j=0;j<movement;j++,robot_y--) {
						map[robot_y][robot_x]=0;
					}
					break;
				case 'W':
					for(j=0;j<movement;j++,robot_x--) {
						map[robot_y][robot_x]=0;
					}
					break;
			}
			map[robot_y][robot_x]=0;
		}
		ok=1;
		for(i=0;i<=20;i++) {
			for(j=0;j<=20;j++) {
				if(map[i][j])ok=0;
			}
		}
		puts(ok?"Yes":"No");
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define debug(x) cout << #x << " = " << x << '\n'

using ll = long long;
using namespace std;

const int MOD = 1e9 + 7;
const int N = 1010;
char grid[N][N];
int dp[N][N], n, m;

int solve(int i, int j)
{
	if (i == 0 && j == 0)
		return 0;

	if (grid[i][j] == '#')
		return -1e9;

	int &dp = ::dp[i][j];

	if (dp != -1)
		return dp;
	dp = -1;

	int a = -1, b = -1;
	if (i > 0)
	{
		a = 1 + solve(i - 1, j);
		if (a > 0)
			dp += a;
	}

	if (j > 0)
	{
		b = 1 + solve(i, j - 1);
		if (b > 0)
			dp += b;
	}

	if (dp == -1)
		dp = -1e9;
	dp %= MOD;
	return dp;
}

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

#ifdef LOCAL_DEFINE
	freopen("in.txt", "r", stdin);
#endif

	cin >> n >> m;

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			cin >> grid[i][j];

	memset(dp, -1, sizeof(dp));

	int ans = 1 + solve(n - 1, m - 1);
	if (ans < 0)
		ans = 0;
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 5376
# def lcm(x, y):
#     return (x * y) // fragments.gcd(x, y)
#
#
# a, b = map(int, input().split())
#
# print(lcm(a, b))
a, b, c = map(str, input().split())
# a, b = map(str, input().split())
# u = input()

if (a == b) and (a == c) and (b == c):
    print("No")
elif (a == b) or (a == c) or (b == c):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
import numpy as np
n=int(input())
x=[0]*n
y=[0]*n
temp=[0]*n
for i in range(0,n):
  x[i],y[i]=map(int,input().split())
for i in range(0,n):
  for j in range(i+1,n):
    X=[abs(x[i]-x[j]),abs(y[i]-y[j])]
    temp.append(np.linalg.norm(X, ord=2))
print(sum(temp)*2/n)


Measured memory_bytes: 12488
def solve(n, a, b):
    if n < a + b - 1:
        return [-1]
    if n > a * b:
        return [-1]
    if b == 1:
        return list(range(1, n + 1))
    if a == 1:
        return list(range(n, 0, -1))

    ans = list(range(b, 0, -1))
    ans.extend(range(n - a + 2, n + 1))

    t = b
    for t in range(2 * b - 1, n - a + 1, b - 1):
        ans.extend(range(t, t - b + 1, -1))
    ans.extend(range(n - a + 1, t, -1))
    return ans


n, a, b = map(int, input().split())
print(*solve(n, a, b))


Measured memory_bytes: 19404
#include <stdio.h>
#include <string.h>

using namespace std;
typedef long long llong;

#define MAX 110
const llong mod = 1000000000 + 7;

int main()
{
  int k;
  char s[MAX];

  scanf("%d", &k);
  scanf("%s", s);
  int len = strlen(s);

  for (int i = 0; i < len; i++)
  {
    if (i >= k)
    {
      printf("...");
      break;
    }
    printf("%c", s[i]);
  }

  return 0;
}

Measured memory_bytes: 1728
from fractions import gcd
def lcm(a, b):
    return (a * b) // gcd(a, b)

def f(x):
    res = 0
    while x % 2 == 0:
        x //= 2
        res += 1
    return res

n, m = map(int, input().split())
a = [int(i) // 2 for i in input().split()]
t = f(a[0])
flag = True
for i in range(n):
    if f(a[i]) != t:
        flag = False
    else:
        a[i] >>= t
m >>= t
l = 1
for i in range(n):
    l = lcm(l, a[i])
    if l > m:
        flag = False
m //= l
print(-(-m // 2) if flag else 0)

Measured memory_bytes: 16344
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  vector<string> M = {"", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
  string S;
  cin >> S;
  for (int i = 0; i < 8; i++)
  {
    if (S == M[i])
      cout << i << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

def main():
    K = int(input())
    print(A[K-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pl = pair<int, ll>;
const int MAX_K = 100005;
const ll LINF = 1LL << 60;
using P = pair<int, int>;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)

class edge {
public:
	long long cost; int to;
	edge(long long cost, int to)
		:cost(cost), to(to) {}
};
vector<edge> e[MAX_K];
long long d1[MAX_K];

void dijkstra(int start, vector<edge> graph[], long long d[]) {
	priority_queue<Pl, vector<Pl>, greater<Pl>> que;
	fill(d, d + MAX_K, LINF);
	d[start] = 0LL;
	que.push(Pl(0LL, start));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second; //行き先
		if (d[v] < p.first)  continue;
		rep(i, graph[v].size()) {
			edge e = graph[v][i];
			if (d[v] + e.cost < d[e.to]) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
	return;
}

int main() {
	int K;
	cin >> K;
	for (int i = 0;i<K;++i) {
		e[i].push_back(edge(1LL, (i + 1) % K));
	}	
	for (int i = 1; i < K; ++i) {
		e[i].push_back(edge(0LL, (i * 10) % K));
	}
	dijkstra(1, e, d1);
	cout << d1[0] + 1LL << endl;
	return 0;
}

Measured memory_bytes: 12052
#include <iostream>
#include <cmath>

using namespace std;
long burger(long N, long X);

int main(void){
	long n, x;
	cin >> n >> x;
	cout << burger(n, x) << endl;
	return 0;
}

long burger(long N, long X){
	if(N == 0){
		return X;
	}
	else{
		if(X == 1)	return 0;
		else if(X <= 1 + pow(2,N+1)-3)	return burger(N-1,X-1);
		else if(X == 2 + pow(2,N+1)-3)	return burger(N-1,pow(2,N+1)-3)+1;
		else if(X <= 2 + 2*(pow(2,N+1)-3))	return	burger(N-1,pow(2,N+1)-3)+1+burger(N-1,X-2-(pow(2,N+1)-3));
		else if(X == 3 + 2*(pow(2,N+1)-3))	return 1+2*burger(N-1,pow(2,N+1)-3);
	}
	return -1;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

unordered_map<ll, unordered_set<ll>> joint;
unordered_map<ll, ll> aoki_distance;

void solve() {
  ll N, u, v;
  cin >> N >> u >> v;

  rep (i, N-1) {
    ll A, B;
    cin >> A >> B;
    joint[A].insert(B);
    joint[B].insert(A);
  }

  aoki_distance[v] = 0;
  queue<ll> aoki_q;
  aoki_q.push(v);
  while (aoki_q.size() > 0) {
    ll tmp = aoki_q.front();
    aoki_q.pop();
    ll dis = aoki_distance[tmp];
    for (auto it: joint[tmp]) if (aoki_distance.count(it) == 0) {
      aoki_distance[it] = dis + 1;
      aoki_q.push(it);
    }
  }

  ll first_distance = aoki_distance[u];
  // 0,1
  // 0,2 
  // 0,3 -> 1,2
  // 0,4 -> 1,3
  ll mid_distance = first_distance / 2 + 1;
  ll mid_point = u;
  while (aoki_distance[mid_point] != mid_distance) {
    for (auto it: joint[mid_point]) {
      if (aoki_distance[it] < aoki_distance[mid_point]) {
        mid_point = it;
        break;
      }
    }
  }

  queue<ll> far_queue;
  far_queue.push(mid_point);
  ll far = aoki_distance[mid_point];
  while (far_queue.size() > 0) {
    ll tmp = far_queue.front();
    far_queue.pop();
    far = max(far, aoki_distance[tmp]);
    for (auto it: joint[tmp]) {
      if (aoki_distance[tmp] < aoki_distance[it]) far_queue.push(it);
    }
  }

  cout << far - 1 << endl;
}

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


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

int main(){
  int i=0 ,n ,m ,tmp;
  while( true ){
    cin >> n >> m;
    if( n == 0 && m == 0 ){
      break;
    }
    if( n < m ){ // 降順にする
      tmp = n;
      n = m;
      m = tmp;
    }
    
    while( true ){ // ユークリッドの互除法
      n %= m;
      tmp = n;
      n = m;
      m = tmp;
      i++;
      if( m == 0 ){ // 終わり
	break;
      }
    }
    
    cout << n << " " << i <<   endl;
    i = 0;
  }
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
    int i,N,x = 0,max = 0;
    char S[101];
    
    scanf("%d",&N);
    scanf("%s",S);
    for(i=0; i<N; i++){
        if(S[i] == 'I')
            x++;
        else
            x--;
        if(x > max)
            max = x;
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		long long a,b,c,d,e;
		scanf("%lld%lld",&a,&b);
		if(a==b)
			printf("%lld\n",2*a-2);
		else
		{
			d=a>b?a:b;
			e=a<b?a:b;
			if(d-e==1)
				printf("%lld\n",2*e-2);
			else
			{
				for(c=sqrt(a*b);c*c<a*b;c++);
				c--;
				if(c*(c+1)>=b*a)
					printf("%lld\n",2*c-2);
				else
					printf("%lld\n",2*c-1);
			}
		}
	}
	return 0;
 } 

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

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



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

	cin >> a;
	cin >> b;

	int ans = 0;

	rep(i, a, b + 1) {

		int c = i % 10;
		int d = i / 10000 % 10;
		int e = i / 10 % 10;
		int f = i / 1000 % 10;
		if (c == d && e == f)ans++;


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

Measured memory_bytes: 256
n=int(input())
a=[]
b=[0]*n
t_sum=0
for i in range(n):
    s,t=input().split()
    tt=int(t)
    t_sum+=tt
    a.append(s)
    b[i]=t_sum
x=input()
print(t_sum-b[a.index(x)])

Measured memory_bytes: 3064
/*
	  Author : @evenbao
	  Created : 2020 / 07 / 12
*/

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;

#define pii pair<int , int>
#define mp make_pair
#define fi first
#define se second

const int N = 4e5 + 10;
const int INF = 2e9;

struct Edge {
		int to , w , nxt;
} E[N << 2];

int n , tot , m , S , T , cnta , cntb;
int head[N] , level[N] , ca[N] , cb[N] , a[N] , b[N] , cur[N];

template <typename T> inline void chkmax(T &x , T y) { x = max(x , y); }
template <typename T> inline void chkmin(T &x , T y) { x = min(x , y); }
template <typename T> inline void read(T &x) {
    T f = 1; x = 0;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
    for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
    x *= f;
}

inline void AddEdge(int u , int v , int w) {
		E[++tot] = (Edge) {v , w , head[u]}; head[u] = tot;
		E[++tot] = (Edge) {u , 0 , head[v]}; head[v] = tot;
}
inline bool bfs(int s) {
		queue < int > q;
		while (!q.empty()) q.pop();
		for (int i = 1; i <= m; ++i) 
				level[i] = -1;
		level[s] = 0; q.push(s);
		while (q.size()) {
				int u = q.front(); q.pop();
				for (int i = head[u]; i; i = E[i].nxt) {
						int v = E[i].to , w = E[i].w;
						if (w > 0 && level[v] == -1) {
								level[v] = level[u] + 1;
								q.push(v);
								if (v == T) return true;
						}
				}
		}
		return false;
}
inline int dfs(int u , int flow) {
		int rest = flow;
		if (u == T)
				return flow;
		for (int &i = cur[u]; i && rest; i = E[i].nxt) {
				int v = E[i].to , 
						w = E[i].w;
				if (w > 0 && level[v] == level[u] + 1) {
						int arg = dfs(v , min(rest , w));
						E[i].w -= arg; E[i ^ 1].w += arg;
						rest -= arg;
						if (!arg) level[v] = -1;
						continue;
				} 
		}
		return flow - rest;
}
inline int dinic(int s , int t) {
		int ret = 0; S = s , T = t;
		while (bfs(S)) {
				for (int i = 1; i <= m; ++i) cur[i] = head[i];
				ret += dfs(S , INF);
		}
		return ret;
}
int main() {
		
		read(n);
		for (int i = 1; i <= n; ++i) read(a[i]) , ++a[i];
		for (int i = 1; i <= n; ++i) read(b[i]) , ++b[i];
		for (int i = 1; i <= n; ++i) {
				if (!ca[i]) {
						int now = i; ++cnta;
						while (!ca[now]) ca[now] = cnta , now = a[now];
				}
		}
		for (int i = 1; i <= n; ++i) {
				if (!cb[i]) {
						int now = i; ++cntb;
						while (!cb[now]) cb[now] = cntb , now = b[now];
				}
		}
		int answer = n; tot = 1;
		for (int i = 1; i <= n; ++i) {
				if (a[i] == i && b[i] == i) --answer;
				else if (a[i] == i) AddEdge(1 , cnta + 2 + cb[i] , 1);
				else if (b[i] == i) AddEdge(ca[i] + 2 , 2 , 1);
				else {
						AddEdge(ca[i] + 2 , cnta + 2 + cb[i] , 1);
						if (a[i] == b[i]) AddEdge(cb[i] + cnta + 2 , ca[i] + 2 , 1);
				}
		}
		m = cnta + cntb + 2; 
		answer -= dinic(1 , 2);
		printf("%d\n" , answer);
	  return 0;
}



Measured memory_bytes: 14372
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

int main(void)
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(all(a));
    ll ans = 0;
    int cta = 0;
    rep(i, 0, n - 1)
    {
        if (a[n - i - 1] == a[n - i - 2])
        {
            if (ans == 0)
                ans += a[n - i - 1];
            else
                ans *= a[n - i - 1];
            i += 2;
            ++cta;
        }
        if (cta == 2)
            break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  int r,l;
  cin >> a >> b >> c >> d;
  r=a+b;
  l=c+d;
  if(r>l) cout << "Left" << endl;
  else if(r==l) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REP2(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
typedef long long ll;

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

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll l = 0;
    if(c < d){
        l = d / GCD(d, c) * c;
    }else{
        l = c / GCD(c, d) * d;
    }
    ll ac = (a - 1) / c;
    ll ad = (a - 1) / d;
    ll bc = b / c;
    ll bd = b / d;
    ll al = (a - 1) / l;
    ll bl = b / l;

    ll t = b - a + 1;
    ll ans = t - ((bc - ac) + (bd - ad)) + (bl - al);
    if(0 < ans){
        OP(ans);
    }else{
        OP(0);
    }
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 998244353
#define MAX 200001

using namespace std;

typedef long long ll;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int main()
{
    ll N, M, K;
    cin >> N >> M >> K;
    COMinit();
    vector<ll> res(N + 1);
    res[0] = 1;
    for (ll i = 1; i <= N; ++i)
    {
        res[i] = (res[i - 1] * (M - 1)) % MOD;
    }

    ll ans = 0;
    for (ll i = 0; i <= K; ++i)
    {
        ll comb = COM(N - 1, i);
        ll color = (M * res[N - 1 - i]) % MOD;
        ans += (comb * color) % MOD;
        ans = ans % MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 9532
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int N,x;
	cin>>N>>x;
	vector<int> a(N);
	int res=0;
	for(int i=0;i<N;i++){
		cin>>a[i];
		if(i!=0){
			if(a[i-1]+a[i]>x){
				res+=a[i-1]+a[i]-x;
				a[i]-= a[i-1]+a[i]-x;
			}
		}else{
			if(a[i]>x){
				res+=a[i]-x;
				a[i]-= a[i]-x;
			}
		}
	}
	cout << res << endl;
	return 0;
}

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

public class Main {

    public static void main(String[] args) {
	Main m = new Main();
	m.answer();
    }

    private Scanner scan = new Scanner(System.in);
    private final int N;
    private final int[] A;

    public Main() {
	N = Integer.parseInt(scan.next());
	A = new int[N];

	for (int i = 0; i < N; i++) {
	    A[i] = Integer.parseInt(scan.next());
	}

	scan.close();
    }

    public final void answer() {
	Arrays.sort(A);

	int ans = 0;
	boolean add = false;
	int number = 0;

	for (int i = 0; i < N; i++) {
	    if(A[i] != number) {
		if(add) ans++;
		number = A[i];
		add = true;
	    } else {
		add = !add;
	    }
	}

	if(add) ans++;

	System.out.println(ans);
    }
}


Measured memory_bytes: 48764
#include <bits/stdc++.h>
 
#define ll long long int
#define ld long double
#define pb push_back
#define pq priority_queue
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vvll vector<vector<ll>>
#define vvi vector<vector<int>>
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define MODNUM 1000000007
#define lp(i,a,b) for(ll i=a; i<b; i++)
#define all(v) v.begin(), v.end()
 
using namespace std;
 
ll mex(ll a, ll b, ll m) {
	if(b==0) return 1;
	if(b%2) return a*mex((a*a)%m,(b-1)/2,m)%m;
	else return mex((a*a)%m,b/2,m);
}
 
int x,y;
void exteu(ll a, ll m) {
	if(m==0) { x=1;y=0; }
	else {
		exteu(m,a%m);
		ll temp = x;
		x=y;
		y=temp-(a/m)*y;
	}
}
 
ll fact(ll n) 
{	ll prod=1;
	for(ll i=2; i<=n; i++) {
		prod*=i;
	}
	return prod;
}
 
ll gcd(ll a, ll b) {
	if(b==0) return a;
	return gcd(b, a%b);
}
 
// bool isprime[200001];
// void makesieve() {
// 	memset(isprime, true, sizeof(isprime));
// 	for (int i = 2; i <= sqrt(200000); ++i)
// 	{
// 		/* code */
// 		if(isprime[i]) {
// 			for (int j = i*i; j <= 200000; j+=i)
// 			{
// 				/* code */
// 				isprime[j]=false;
// 			}
// 		}
// 	}
// }
// 
// 1 2 4 5 8
void solve() {
	string s,t; cin>>s>>t;
	ll a=0;
	for (int i = 0; i < s.length(); ++i)
	{
		if(s[i]!=t[i])a++;
	}
	cout<<a;
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll TESTS=1;
	// cin >> TESTS;
	// makesieve();
	while(TESTS--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3800
H,W,K = map(int,input().split())
S = [input() for i in range(H)]

ans = [[None]*W for _ in range(H)]
v = 0
for i,row in enumerate(S):
    sp = row.split('#')
    if len(sp)==1: continue
    if len(sp)==2:
        v += 1
        for j in range(W):
            ans[i][j] = v
        continue
    j = 0
    for k,a in enumerate(sp):
        if k==len(sp)-1:
            for _ in range(len(a)):
                ans[i][j] = v
                j += 1
        else:
            v += 1
            for _ in range(len(a)+1):
                ans[i][j] = v
                j += 1

i = 0
while ans[i][0] is None:
    i += 1
for ii in range(i):
    for j in range(W):
        ans[ii][j] = ans[i][j]

for i in range(1,H):
    if ans[i][0] is None:
        for j in range(W):
            ans[i][j] = ans[i-1][j]

for row in ans:
    print(*row)

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

using namespace std;

int main()
{
    string S;
    cin>>S;
    if(S[2]==S[3] && S[4]==S[5])
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}


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

int main() 
{
	int a, b;
	cin >> a >> b;
	int c;
	if (b < 10) {
		c = a * 10 + b;
	}
	else if (b < 100) {
		c = a * 100 + b;
	}
	else {
		c = a * 1000 + b;
	}

	for (int i = 1; i < c; ++i) {
		if (c == i * i) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

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

int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    
    ll ans = a[0];
    rep(i, N){
        ans = func(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4044
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, x;
	cin >> N >> x;

	vector<Int> a(N);
	for (Int i = 0; i < N; i++) {
		cin >> a[i];
	}

	Int ans = 0;
	Int temp;
	for (Int i = 0; i < N-1; i++) {
		if (a[i] + a[i + 1] > x) {
			temp = a[i] + a[i + 1] - x;
			ans += temp;
			a[i + 1] = max(0LL, a[i + 1] - temp);
			temp -= a[i + 1];
			if (temp) {
				a[i] -= temp;
			}
		}
	}

	cout << ans << "\n";
}

Measured memory_bytes: 1024