akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

struct edge {
	int from, to, cost;
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, m, p;
	cin >> n >> m >> p;
	vector<edge> graph;
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		graph.pb({ a,b,p - c });
	}
	vector<int> dis(n, inf);
	dis[0] = 0;
	set<int> st;
	rep(cnt, n) {
		rep(i, m) {
			edge e = graph[i];
			if (dis[e.from] != inf && dis[e.to] > dis[e.from] + e.cost) {
				dis[e.to] = dis[e.from] + e.cost;
				if (cnt >= n - 1) st.insert(e.to);
			}
        }
	}
	queue<int> que;
	vector<bool> ok(n);
	que.push(0); ok[0] = true;
	while (!que.empty()) {
		int q = que.front(); que.pop();
		for (edge i : graph) {
			if (i.from == q) {
				if (!ok[i.to]) {
					ok[i.to] = true;
					que.push(i.to);
				}
			}
		}
	}
	queue<int> que2;
	vector<bool> ok2(n);
	que2.push(n - 1); ok2[n - 1] = true;
	while (!que2.empty()) {
		int q = que2.front(); que2.pop();
		for (edge i : graph) {
			if (i.to == q) {
				if (!ok2[i.from]) {
					ok2[i.from] = true;
					que2.push(i.from);
				}
			}
		}
	}
	rep(i, n) {
		if (ok[i] && ok2[i] && st.count(i)) {
			cout << -1 << '\n';
			return 0;
		}
	}
	cout << max(-dis[n - 1], 0) << '\n';
}

Measured memory_bytes: 512
#include <stdio.h>
  
int main(){
  int data[10];
  int i,j,temp;

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

  for(i=0;i<10;i++){
    for(j=i+1;j<10;j++){
      if(data[j]>data[i]){
         temp = data[i];
         data[i] = data[j];
         data[j] = temp;
      }
    }
  }

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

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

ll N ;
vector<pair<ll,ll> > ball;
map<pair<ll,ll>, ll > idx;
map<pair<ll,ll>, bool> check;
vector<pair<ll,ll> > sample;

bool used[60];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N ;
    rep(i, N){
        ll x, y ;
        cin >> x >> y ;
        ball.pb(mp(x,y));
        idx[mp(x,y)] = i ;
        check[mp(x,y)] = true;
    }
    
    rep(i, N)rep(j, N ){
        if(i == j) continue;
        ll p = ball[i].first - ball[j].first;
        ll q = ball[i].second - ball[j].second;
        
        sample.pb(mp(p,q));
    }
    rmsame(sample);
    
    ll ans = 0;
    rep(n, sample.size()){
        ll p = sample[n].first;
        ll q = sample[n].second;
        
        //cerr << "DEBUG" << p << "  " << q << endl;
        rep(i, ball.size()) used[i] = false;
        
        vector<pair<ll,ll>  > lines;
        rep(i, ball.size()){
            pair<ll,ll> now = ball[i];
            pair<ll,ll> dist = mp(now.first + p, now.second + q);
            if(check[dist] == true) lines.pb(mp(idx[now], idx[dist]));
        }
        rmsame(lines);
        ans = max(ans, (ll)lines.size());
    }
    
    cout << N-ans << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

using namespace std;

#define ll long long




void solve() {

	int x;
	cin >> x;
	if(x >= 30) {
		cout << "Yes";
	}
	else {
		cout << "No\n";
	}

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--) 
		solve();

	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){

	int K,S,X,Y,count = 0 ;
	scanf("%d %d",&K,&S);


	for(int i=0; i<=K; i++){
		for(int j=0; j<=K; j++){
			if(( (S-i-j) >= 0 )&&( (S-i-j) <= K ) ){ 
				count ++;
			}else{

			}
		}
	}			
	
	printf("%d",count);

	return 0;


}

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

template <typename T, typename E> class SegmentTree {
  private:
    using F = function<T(T, T)>;
    using G = function<T(T, E)>;
    int sz;
    const F f;
    const G g;
    const T id;
    vector<T> dat;

  public:
    SegmentTree(F f, G g, T id) : f(f), g(g), id(id) {}
    void init(int n) {
        for(sz = 1; sz < n;)
            sz <<= 1;
        dat.assign(sz << 1, id);
    }
    void build(const vector<T> &v) {
        int n = v.size();
        init(n);
        for(int i = 0; i < n; i++)
            dat[sz + i] = v[i];
        for(int i = sz; --i;)
            dat[i] = f(dat[i << 1], dat[i << 1 | 1]);
    }
    void update(int k, E x) {
        k += sz;
        dat[k] = g(dat[k], x);
        while(k >>= 1)
            dat[k] = f(dat[k << 1], dat[k << 1 | 1]);
    }
    T query(int l, int r) const {
        T vl = id, vr = id;
        for(l += sz, r += sz; l < r; l >>= 1, r >>= 1) {
            if(l & 1) vl = f(vl, dat[l++]);
            if(r & 1) vr = f(dat[--r], vr);
        }
        return f(vl, vr);
    }
};

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

    int N, Q;
    cin >> N >> Q;

    auto f = [](int a, int b) { return a + b; };
    SegmentTree<int, int> seg(f, f, 0);
    seg.init(N);

    int c, x, y;
    while(Q--) {
        cin >> c >> x >> y;
        if(c)
            cout << seg.query(x - 1, y) << "\n";
        else
            seg.update(x - 1, y);
    }
}


Measured memory_bytes: 3804
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

/**
 * @author f-morozov
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = scanner.nextInt();
        int[] heights = new int[count];
        int[] values = new int[count];
        for (int i = 0; i < count; ++i) {
            heights[i] = scanner.nextInt();
        }
        for (int i = 0; i < count; ++i) {
            values[i] = scanner.nextInt();
        }

        FenwickTree fenwickTree = new FenwickTree(count);

        for (int i = 0; i < count; ++i) {
            long value = fenwickTree.max(heights[i] - 1) + values[i];
            fenwickTree.update(heights[i] - 1, value);
        }
        System.out.println(fenwickTree.max(count - 1));
    }

    public static class FenwickTree {
        private final List<Long> values;

        public FenwickTree(int size) {
            this.values = new ArrayList<>(Collections.nCopies(size, 0L));
        }

        long max(int right) {
            long result = 0;
            for (int i = right; i >= 0; i = (i & (i + 1)) - 1) {
                result = Math.max(result, values.get(i));
            }
            return result;
        }

        void update(int pos, long value) {
            for (int i = pos; i < values.size(); i = i | (i + 1)) {
                values.set(i, Math.max(values.get(i), value));
            }
        }
    }
}


Measured memory_bytes: 148356
#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

signed main() {
	ll n; string s; cin >> n >> s;
	ll j = 0, jo = 0, ans = 0;
	rep(h, n) {
		if (s[h] == 'J') { j++; }
		else if (s[h] == 'O') { jo += j; }
		else { ans += jo; }
	}
	ll i = 0, oi = 0;
	for (int h = n - 1; h >= 0; h--) {
		if (s[h] == 'I') { i++; }
		if (s[h] == 'O') { oi += i; }
	}
	j = 0; ll ji = 0;
	rep(h, n) {
		if (s[h] == 'J') { j++; }
		else if (s[h] == 'I') { i--; }
		ji = max(ji, j * i);
	}
	cout << max(jo, max(oi, ji)) + ans << endl;
	return 0;
}


Measured memory_bytes: 3360
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define en end()
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int N=1e6+2;
long long  mod=1e9+9;
int t,j,cs=0,n,a,b,i,dxx[]={1,0,0,-1},dyy[]={0,-1,1,0},k,m,inf=1e9;
string s;

int main()
{
    scanf("%d",&n);
    vi v(n);
    for(int& it:v)
        scanf("%d",&it);
    vi dp(n,inf);
    dp[0]=0;
    rep(i,n-1){
        for(int j:{i+1,i+2}){
            if(j<n){
               // cout<<dp[j]<<endl;
                dp[j]=min(dp[j],dp[i]+abs(v[i]-v[j]));

            }

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



Measured memory_bytes: 4036
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let count_500: u32 = iter.next().unwrap().parse().unwrap();
    let count_100: u32 = iter.next().unwrap().parse().unwrap();
    let count_50: u32 = iter.next().unwrap().parse().unwrap();
    let amount: u32 = iter.next().unwrap().parse().unwrap();

    let mut result = 0;
    for c500 in 0..count_500 + 1 {
        for c100 in 0..count_100 + 1 {
            for c50 in 0..count_50 + 1 {
                if 500 * c500 + 100 * c100 + 50 * c50 == amount {
                    result += 1;
                }
            }
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        d: i64,
    }
    println!("{}", (b - a + 1) - (lambda(b, c, d) - lambda(a - 1, c, d)));
}

fn lambda(i: i64, c: i64, d: i64) -> i64 {
    // println!("gcd:{}", gcd(c, d));
    return (i / c) + (i / d) - (i / (lcm(c, d)));
}

fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

fn lcm(x: i64, y: i64) -> i64 {
    x * (y / gcd(x, y))
}


Measured memory_bytes: 2156
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<ll> enum_prime(ll N){
	deque<bool> is_prime(N+1,true);
	vector<ll> P;
	for(ll i=2;i<=N;i++){
		if(is_prime[i]){
			for(ll j=i*i;j<=N;j+=i){
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int X=in();
	auto P=enum_prime(1000000);
	sort(ALL(P));
	auto res = lower_bound(ALL(P),X);

	out(*res);
	return 0;
}


Measured memory_bytes: 2424
#include <iostream>
    using namespace std;
     
    int main() {
    	int n,d,x,b,sum=0;
    	cin>>n>>d>>x;  
    	for(int i=0;i<n;i++){
    		int a;
    		cin>>a;
    		b=(d-1)/a+1;
    		sum+=b;
    		
    	}
    	cout<<x+sum<<endl;
    	return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
const ll MOD = 1e9 + 7;
// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;

// 素因数分解
map<ll, ll> prime_factor(ll n){
	map<ll, ll> res;
	for(ll i = 2; i*i <= n; i++){
		while(n % i == 0){
			res[i]++;
			n /= i;
		}
	}
	if(n > 1) res[n]++;
	return res;
}


void mainsolve(){
	ll n;
	cin >> n;

	vector<ll> a(n);
	rep(i,n) cin >> a[i];

	map<ll,ll> lcmmp;
	rep(i,n){
		map<ll,ll> mp = prime_factor(a[i]);
		for(auto itr = mp.begin(); itr != mp.end(); itr++){
			P now = *itr;
			if(lcmmp[now.first] < now.second) lcmmp[now.first] = now.second;
		}
	}

	mint lcm = 1;
	for(auto itr = lcmmp.begin(); itr != lcmmp.end(); itr++){
		P now = *itr;
		rep(i,now.second){
			lcm *= now.first;
		}
	}

	mint res = 0;
	rep(i,n) res += lcm / a[i];
	cout << res << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch);
long long getKey(char a[]);
int h1(int key);
int h2(int key);
int find(char a[]);
int insert(char a[]);

int main(){
  int i,n;
  char a[L], b[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", b, a);

    if ( b[0] == 'i' ){
      if (insert(a)){

      }
    } else {
      if (find(a) ){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  return 0;
}

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

long long getKey(char a[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(a); i++ ){
    sum += p*(getChar(a[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char a[]){
  long long key, i, h;
  key = getKey(a);
  for ( i = 0;; i++){
    h = (h1(key)+i*h2(key))%M;
    if( strcmp(H[h],a) == 0 ) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char a[]){
  long long key, i, h;
  key = getKey(a);
  for ( i = 0; ; i++ ){
    h = (h1(key)+i*h2(key))%M;
    if( strcmp(H[h],a) == 0 ) return 1;
    else if ( strlen(H[h]) == 0 ){
      strcpy(H[h], a);
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 16048
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	ll x;
	cin >> x;
	printf("%lld\n", x / 500 * 1000 + x % 500 / 5 * 5);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
string inp[200005];
int n;
int mxcnt,cnt;
string tmp;
inline void read(int &x)
{
	int f;char c;
	for (f=1,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for (x=0;c<='9'&&c>='0';c=getchar()) x=x*10+(c&15);x*=f;
}
inline int mx(int _x,int _y)
{
	return _x>_y?_x:_y;
}
inline bool cmp(string p,string q)
{
	return p<q;
}
int main()
{
	read(n);
	for(int i=1;i<=n;i++)
		cin>>inp[i];
	sort(inp+1,inp+n+1,cmp);
	cnt=1;
	tmp=inp[1];
	for(int i=2;i<=n;i++)
	{
		if(tmp==inp[i])
		{
			cnt++;
		}
		else
		{
			mxcnt=mx(mxcnt,cnt);
			cnt=1;
			tmp=inp[i];
		}
	}
	mxcnt=mx(mxcnt,cnt);
	cnt=1;
	tmp=inp[1];
	for(int i=2;i<=n;i++)
	{
		if(tmp==inp[i])
		{
			cnt++;
		}
		else
		{
			if(cnt==mxcnt)
			{
				cout<<tmp;
				puts("");
			}
			cnt=1;
			tmp=inp[i];
		}
	}
	if(cnt==mxcnt)
	{
		cout<<tmp;
		puts("");
	}
	return 0;
}



Measured memory_bytes: 14208
import sys
def input(): return sys.stdin.readline().strip()

def main():
    X, K, D = map(int, input().split())
    if X < 0: X *= -1
    if X >= K * D:
        print(X - K * D)
        return
    q, rem = X // D, X % D
    if q % 2 == K % 2:
        print(rem)
    else:
        print(D - rem)




if __name__ == "__main__":
    main()


Measured memory_bytes: 61880
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> LR(M, vector<int>(2));

	for (int i = 0; i < M; ++i) {
		cin >> LR[i][0] >> LR[i][1];
	}

	int count = 0;
	int left  = 1;
	int right = N;
	for (int i = 0; i < M; ++i) {
		if (left < LR[i][0]) {
			left = LR[i][0];
		}
		if (right > LR[i][1]) {
			right = LR[i][1];
		}

		if (left > right) {
			right = left - 1;
			break;
		}
	}

	cout << right - left + 1 << endl;
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 main(void){
    i64 a,b,c;
    scanf("%lli%lli%lli",&a,&b,&c);
    i64 m=a*7LL+b;
    i64 n=c/m;
    i64 o=(c-n*m+a-1LL)/a;
    if(o>7LL) o=7LL;
    printf("%lli\n",n*7LL+o);
    return 0;
}



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

int main() {
        int k, ans;
        ans = -1;
        cin >> k;
        int sevens = 7%k;
        rep(i,k) {
                if (sevens % k == 0) {
                        ans = i+1;
                        break;
                }
                sevens *= 10;
                sevens += 7;
                sevens %= k;
        }
        cout << ans << endl;
}

Measured memory_bytes: 3636
<?php
// 入力
fscanf(STDIN, '%d %d', $n, $l);
$absmin = 10000;
$sum = 0;
for ($i = 0; $i < $n; $i++) {
    $aji = $l + $i;
    $sum += $aji;
    if (abs($aji) < abs($absmin)) $absmin = $aji;
}
echo ($sum - $absmin).PHP_EOL;

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

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

   string s;
   cin >> s;
   int n,cnt = 1;
   cin >> n;

   rep(i,s.size()){
      if(cnt == 1) cout << s[i];
      cnt++;
      if(cnt == n + 1){
         cnt = 1;
      }else{
         continue;
      }
   }
   cout << endl;

   return 0;
}

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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }


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

    vector<string> s(n);
    for(int in=0;in<n;in++) {
        cin >> s.at(in);
    }

    //cout << s.at(1).at(s.at(1).size());
    //cout << s.at(1);

    for(int in=0;in<n-1;in++) {
        // cout << s.at(in).at(s.at(in).size()-1) << " " << s.at(in+1).at(0) << endl;
        if(s.at(in).at(s.at(in).size()-1)!=s.at(in+1).at(0)) {
            cout << "No" << endl;
            return 0;
        }
    }

    for(int in=0;in<n;in++) {
        for(int jn=in+1;jn<n;jn++) {
            if(s.at(in)==s.at(jn)) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    string s; cin>>s;
    int64_t K; cin>>K;

    rep(i,0,s.size()){
        int64_t n='z'-s.at(i)+1; //'a'までに必要な数
        if(n<26 && n<=K){
            s.at(i)='a';
            K-=n;
        }
    }

    K%=26;
    s.back()+=K;
    cout<<s<<endl;
}

Measured memory_bytes: 512
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		// 計算
		String result = "NG";
		for(int i = a; i <= b; i++){
		    if(i%k == 0) result = "OK";
		}
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 27092
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	x := scanInt()
	y := scanInt()
	z := scanInt()
	fmt.Println(z, x, y)
}

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}
func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}
func main() {
	sc.Split(bufio.ScanWords)
	solve()
}


Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int main()
{
	int n,A,B,C,D;
	scanf("%d", &n);
	D = n % 10; n /= 10;
	C = n % 10; n /= 10;
	B = n % 10; n /= 10;
	A = n % 10; n /= 10;
	if (A + B + C + D == 7) printf("%d+%d+%d+%d=7", A, B, C, D);
	else if (A - B + C + D == 7) printf("%d-%d+%d+%d=7", A, B, C, D);
	else if (A + B - C + D == 7) printf("%d+%d-%d+%d=7", A, B, C, D);
	else if (A + B + C - D == 7) printf("%d+%d+%d-%d=7", A, B, C, D);
	else if (A - B - C + D == 7) printf("%d-%d-%d+%d=7", A, B, C, D);
	else if (A - B + C - D == 7) printf("%d-%d+%d-%d=7", A, B, C, D);
	else if (A + B - C - D == 7) printf("%d+%d-%d-%d=7", A, B, C, D);
	else if (A - B - C - D == 7) printf("%d-%d-%d-%d=7", A, B, C, D);
	return 0;
}

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

int main() {
  int n,m,ans=0;
  cin >> n >> m;
  vector<vector<int>> v(m,vector<int>(n+2,0));
  r(i,m){
    cin >> v[i][1];
    r(j,v[i][1])cin>>v[i][2+j];
  }
  r(i,m)cin>>v[i][0];
  for(int bit=0; bit < (1<<n);bit++){
    r(i,m+1){
      if(i==m)ans++;
      else{
        int bit2=0;
        r(j,v[i][1])bit2=bit2^bitset<10>(bit)[v[i][2+j]-1];
        if(bit2!=v[i][0])break;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, _begin, _end) for (end = _ end, begin = _begin, __typeof(end) i = (begin) - ((begin) > (end)); != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class CRectangleCutting {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int H,W,x,y;
//    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    cin >> H >> W >> x >> y;
    cout << .5*H*W << " " << (2*x == H && 2*y == W) << endl;
}
};


#undef int
int main() {
	CRectangleCutting solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
            in.tie(0); ios::sync_with_stdio(0); out<<fixed<<setprecision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int k,a,b;
signed main()
{
	cin>>k>>a>>b;
	if(2>=(b-a)){
		cout<<1+k<<endl;
	}else{
		int cur=1;
		int cha=a-1;
		if(cha>0)k-=cha,cur+=cha;
		cout<<cur+(k&1)+(b-a)*(k>>1)<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a < b) {
            if (b < c) {
                System.out.printf("%d %d %d\n", a, b, c);
            }else if(a < c){
                System.out.printf("%d %d %d\n", a, c, b);
            }else{
                System.out.printf("%d %d %d\n", c, a, b);
            }
        }else {
            if (a < c) {
                System.out.printf("%d %d %d\n", b, a, c);
            } else if (b < c) {
                System.out.printf("%d %d %d\n", b, c, a);
            } else {
                System.out.printf("%d %d %d\n", c, b, a);
            }
        }
    }
}



Measured memory_bytes: 26288
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, A, B;

void solve() {
	cin >> N >> A >> B;
	if((B - A) % 2 == 0) cout << "Alice\n";
	else cout << "Borys\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n;
    cin >> n;
    vector<int> a(3 * n);
    in_arr(int, a, 3 * n);
    sort(a.begin(), a.end());
    ll sum = 0;
    rep(i, n){
        sum += a[3 * n - i * 2 - 2];
    }
    cout << sum << endl;
    return 0;
}


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

#define int long long

#define ii pair<int, int>
#define fi first
#define sc second
#define set unordered_set
#define map unordered_map
#define all(x) (x).begin(), (x).end()

signed main() {
#ifdef _DEBUG
	//freopen("in", "r", stdin);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	double a, b, c, d; cin >> a >> b >> c >> d;
	//cout << ceil(c/b) << ' ' << ceil(a/d) << '\n';
	if (ceil(c/b) > ceil(a/d)) cout << "No";
	else cout << "Yes";
}


Measured memory_bytes: 3724
#include <cstdio>

int main()
{
  int n;
  char s[101];
  scanf("%d%s", &n, s);
  int r = 0;
  for (char *p = s; *p; ++p)
  {
    if (*p == 'R') ++r;
  }
  puts(r > n - r ? "Yes" : "No");
  return 0;
}
    

Measured memory_bytes: 128
import sys
import math
#a,b= map(int,input().split())
#li= [int(x) for x in input().split()]
a=int(input())
S=input()
x=0
for i in S:
  x=ord(i)+a
  if x<91:
    print(chr(x),end="")
  else:
    print(chr(x-26),end="")




Measured memory_bytes: 4468
#include<queue>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> P;
struct edge{
  ll to;
  ll cost;
  edge(ll t,ll w) : to(t),cost(w){}
};
int main(){
  vector<vector<edge> > g(100010);
  const ll INF=1000000000000000;
  priority_queue<P,vector<P>,greater<P> > que;
  ll n,m,u,V,s,t,i,j;
  ll ds[100010][5],ns[100010][5];
  scanf("%lld %lld\n",&n,&m);
  for(i=0;i<m;i++){
    scanf("%lld %lld\n",&u,&V);
    u--,V--;
    g[u].push_back(edge(V,1));
  }
  scanf("%lld %lld\n",&s,&t);
  s--,t--;
  for(i=0;i<n;i++){
    for(j=0;j<3;j++){
      ds[i][j]=INF,ns[i][j]=0;
    }
  }
  ds[s][0]=0;ns[s][0]=1;
  que.push(make_pair(0,pll(s,0)));
  while(!que.empty()){
    if(ns[t][0]==1){
      break;
    }
    P p=que.top();
    ll v=p.second.first,w=p.second.second;
    que.pop();
    for(i=0;i<g[v].size();i++){
      edge us=g[v][i];
      if(ds[us.to][(w+us.cost)%3]>ds[v][w]+us.cost && ns[us.to][(w+us.cost)%3]==0){
        ds[us.to][(w+us.cost)%3]=ds[v][w]+us.cost;
        que.push(make_pair(ds[us.to][(w+us.cost)%3],pll(us.to,(w+us.cost)%3)));
      }
    }
    ns[v][w]=1;
  }
  if(ds[t][0]==INF){
    printf("-1\n");
  }
  else{
    printf("%lld\n",ds[t][0]/3);
  }
  return 0;
}

Measured memory_bytes: 14068
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	string s1, s2, s3;
	cin>>s1>>s2>>s3;
	string ans;
	ans.resize(3);
	ans[0] = s1[0];
	ans[1] = s2[0];
	ans[2] = s3[0];
	REP(i, 3) {
		cout<<(char)('A' + (ans[i] - 'a'));
	}
	cout<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <ctime>


#ifndef M_PI
#define M_PI 3.141592653589
#endif
#define int long long
#define double long double
#define f(variable, start, end) for (int variable = start; variable < end; ++variable)
#define be(a) a.begin(), a.end()
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define nor cout << "NO\n"; return
#define yesr cout << "YES\n"; return
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>


using namespace std;


template<typename T, typename E>
vector<T> &operator>>(vector<T> &v, E a) {
    v.push_back(a);
    return v;
}

//pair output
template<typename E>
ostream &operator<<(ostream &os, pair<E, E> &t) {
    os << t.first << ' ' << t.second;
    return os;
}

//"map" pair output
template<typename E>
ostream &operator<<(ostream &os, pair<const E, E> &t) {
    os << t.first << ' ' << t.second;
    return os;
}

//vector output
template<typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
    for (T i : vec) {
        os << i << ' ';
    }
    return os;
}

//2 dimensional vector output
template<typename T>
ostream &operator<<(ostream &os, vector<vector<T> > &vec) {
    for (vector<T> i : vec) {
        os << i << '\n';
    }
    return os;
}

//vector<pair<T, E>> output
template<typename T, typename E>
ostream &operator<<(ostream &os, vector<pair<T, E>> &vec) {
    for (pair<T, E> i : vec) {
        os << i.first << ' ' << i.second << '\n';
    }
    return os;
}

vi sa, sb;

bool can(int n, vi &a, vi &b, int k) {
    int mn = INT64_MAX;
    f(i, 0, n + 1) {
        int mins = 0;
        if (i > (int) a.size()) {
            continue;
        }

        mins += sa[i];

        if (n - i > (int) b.size()) {
            continue;
        }

        mins += sb[n - i];

        if (mins < mn) {
            mn = mins;
        }
    }
    return mn <= k;
}

int32_t main() {
    cin.tie(NULL);
    cout.tie(NULL);
    cout.setf(ios::fixed);
    cout.precision(10);
    ios_base::sync_with_stdio(false);
#ifdef TIME
    int32_t start = clock();
#endif

    int n, m, k;

    cin >> n >> m >> k;

    vi a(n), b(m);

    sa.resize(n + 1);
    sb.resize(m + 1);

    f(i, 0, n) {
        cin >> a[i];
        sa[i + 1] = sa[i] + a[i];
    }

    f(i, 0, m) {
        cin >> b[i];
        sb[i + 1] = sb[i] + b[i];
    }

    int l = 0, r = n + m + 1;

    while (r != l + 1) {
        int lr = (l + r) / 2;
        if (can(lr, a, b, k)) {
            l = lr;
        } else {
            r = lr;
        }
    }

    cout << l;


#ifdef TIME
    cout << "\ntime: " << (clock() - start) / (CLOCKS_PER_SEC * 1.0);
#endif

    return 0;
}

Measured memory_bytes: 9532
#include <iostream>
#include <set>

using namespace std;

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

    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import collections
N = int(input())
a_list = [int(input()) for i in range(N)]

counter = collections.Counter(a_list)
val_array = np.array(list(counter.values()))
mod2_array = val_array % 2

ans_dict = collections.Counter(mod2_array)
ans = ans_dict[1]
print(ans)


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

using namespace std;

typedef long long ll;



int main(void){
    string s;
    cin >> s;
    string ans = "No";
    for(ll i = 0; i < 3; i++){
        if(s[i] == '7'){
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int q=0;q<n;q++){
        string s,t;
        cin>>s>>t;
        int ss=s.length(),ts=t.length();
        int dp[ss+5][ts+5];
        for(int i=0;i<ss+5;i++){
            for(int j=0;j<ts+5;j++)dp[i][j]=0;
        }
        for(int i=0;i<ss;i++){
            for(int j=0;j<ts;j++){
                if(s[i]==t[j]){
                    dp[i+1][j+1]=dp[i][j]+1;
                }else{
                    dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
                }
            }
        }
        cout<<dp[ss][ts]<<endl;
    }
}


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

using namespace std;
using ll = long long;

int n, b, e, a[200001], ord[200001];
ll k;
bool used[200001];

vector<int> v;

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

	int now = 1;
	while(1){
		if(used[now]){
			b = ord[now]-1;
			e = v.size()-1;
			break;
		}else{
			v.push_back(now);
			ord[now] = v.size();
			used[now] = true;
			now = a[now];
		}
	}

	if(e-b+1 == v.size()){
		cout << v[k%v.size()] << endl;
	}else{
		if(k < v.size()){
			cout << v[k] << endl;
		}else{
			k -= b;
			int c = k%(e-b+1);
			cout << v[b+c] << endl;
		}
	}
}

Measured memory_bytes: 5936
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,X;
  cin >> N >> X;
  vector<int> m(N);
  int m_sum = 0;
  int m_min = 10000;
  for(int i=0;i<N;i++){
    cin >> m.at(i);
    m_sum += m.at(i);
    if(m_min > m.at(i)){
      m_min = m.at(i);
    }
  }
  int X_remain = X - m_sum;
  cout << X_remain / m_min + N << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[25][25], all, n, u, v;
const ll N = 1e5 + 5, mod = 1e9 + 7;
ll dp[2][N];
vector<int> g[N];
void dfs(int curr, int par) {
	ll r1 = 1, r0 = 1;
	for(int x : g[curr]) {
		if(x != par) {
			dfs(x, curr) ;
			r1 = (r1 * dp[0][x]) % mod;
			r0 = (r0 *(dp[0][x]+dp[1][x]))%mod;
		}
	}
	dp[0][curr] = r0, dp[1][curr] = r1;
}
int main() {
	cin >> n;
	for(int i=1;i<n;i++) {
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1, 0);
	cout << (dp[0][1] + dp[1][1]) % mod << '\n';
	return 0;
}

Measured memory_bytes: 14208
def main():
    N = int(input())
    *A, = map(int, input().split())

    def accumulate(a):
        s = 0
        for x in a:
            s += x
            yield s

    *acc, = accumulate(A)
    acc.pop()

    tot = sum(A)

    ans = -1
    for x in acc:
        if ans > (abs_ := abs(tot - x - x)) or not (~ans):
            ans = abs_

    print(ans)


if __name__ == '__main__':
    main()


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

int H[100005], dp[100005];

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    
    int N;
    cin >> N;
    
    for(int i=1; i<=N; i++)
        cin >> H[i];
    
    dp[2] = abs(H[2] - H[1]);
    
    for(int i=3; i<=N; i++)
        dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]));
    
    cout << dp[N] << "\n";
    return 0;
}

Measured memory_bytes: 1024
H, W = list(map(int, input().split()))
S = [input() for _ in range(H)]

X = [[0 for _ in range(W)] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            for di in [-1, 0, 1]:
                for dj in [-1, 0, 1]:
                    if i + di in range(H) and j + dj in range(W):
                        X[i + di][j + dj] += 1

for i in range(H):
    w = []
    for j in range(W):
        if S[i][j] == '#':
            w.append("#")
        else:
            w.append(str(X[i][j]))
    print("".join(w))


Measured memory_bytes: 3064
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll H,W;cin>>H>>W;
    string s[H];REP(i,H)cin>>s[i];
    string w;
    REP(i,W)w.push_back('#');
    w.push_back('#');w.push_back('#');
    cout<<w<<"\n";
    REP(i,H){
        cout<<'#';
        cout<<s[i];
        cout<<"#\n";
    }
    cout<<w<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int sn,i,k=0;
	string s,ss;
	cin>>s;
	ss="CODEFESTIVAL2016";
	sn=s.length();
	for(i=0;i<sn;i++){
		if(s[i]!=ss[i]) k++;
		
	}
	cout<<k<<endl;
}

Measured memory_bytes: 256
n=int(input())
a= list(map(int,input().split()))
a_sorted=sorted(a)
notmatch=0
for i in range(n):
  if a[i]!=a_sorted[i]:
    notmatch+=1
if notmatch ==2 or notmatch==0:
  print("YES")
else:
  print ("NO")

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<deque>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
using namespace std;
struct Edge
{
     int next;
     int v;
     int w;
}s[400005];
int head[100005],vis[100005],d[100005];
int cnt=0;
void deal(int u,int v,int w)
{
     s[cnt].v=v;
     s[cnt].w=w;
     s[cnt].next=head[u];
     head[u]=cnt++;
}
bool flag=false;
void dfs(int x)
{
     if(d[x]!=-2000000005)
     {
          if(abs(d[x])>1000000000)
          {
               flag=true;
               return ;
          }
     }
     if(flag) return ;
     for(int i=head[x];~i;i=s[i].next)
     {
          int v=s[i].v;
          if(d[v]!=-2000000005)
          {
               if(d[x]+s[i].w!=d[v])
                    flag=true;
          }
          else
          {
               d[v]=d[x]+s[i].w;
               if(!vis[v])
               {
                    vis[v]=1;
                    dfs(v);
               }

          }
     }
}
int main()
{
     int n,m;
     scanf("%d%d",&n,&m);
     for(int i=1;i<=n;i++)d[i]=-2000000005;
     memset(head,-1,sizeof(head));
     for(int i=0;i<m;i++)
     {
          int a,b,c;
          scanf("%d%d%d",&a,&b,&c);
          deal(a,b,c);
          deal(b,a,-c);
     }
     for(int i=1;i<=n;i++)
     {
          if(flag) break;
          if(!vis[i])
          {
               d[i]=0;
               vis[i]=1;
               dfs(i);
          }
     }
     if(flag) printf("No\n");
     else printf("Yes\n");
     return 0;
}


Measured memory_bytes: 7936
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class Main {
	
    public static void main(String[] a){
    	
    	BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		String line;
		int numDS = -1;
		int aSide = -1;
		int bSide = -1;
		int cSide = -1;
		
		ArrayList <String> results = new ArrayList<String>();
		
		//get number of data sets
    	try {
			while ((line = stdin.readLine()) != null && 
					line.length()!= 0) {
				
				String[] checker = line.split(" ");
				
				if (checker.length == 1){
					numDS = Integer.parseInt(checker[0]);
				} else if (checker.length == 3){
				
					int temp1 = Integer.parseInt(checker[0]);
					int temp2 = Integer.parseInt(checker[1]);
					int temp3 = Integer.parseInt(checker[2]);
					
					if (temp1 < 1 || temp1 >1000 ||
						temp2 < 1 || temp2 >1000 ||
						temp3 < 1 || temp3 >1000){
						results.add("NO");
					} else {
						//get the highest number and place to cSide
						if (temp1 > temp2 && temp1> temp3){
							cSide = temp1;
							aSide = temp2;
							bSide = temp3;
						} else if (temp2 > temp1 && temp2 > temp3){
							cSide = temp2;
							aSide = temp1;
							bSide = temp3;
						} else {
							cSide = temp3;
							aSide = temp2;
							bSide = temp1;
						}
						
						//Pythagorean
						if ((cSide*cSide) == ((aSide*aSide)+(bSide*bSide))){
							results.add("YES");
						} else {
							results.add("NO");
						}
						
						if (results.size() == numDS){
							break;
						}
					}
				}
			}

			//print result
			for (String s: results){
				System.out.println(s);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			//e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			//e.printStackTrace();
		}
    }
}

Measured memory_bytes: 26196