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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            ostr << *itr;
            // ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    ostr << p.first << ", " << p.second;
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll x(n); x[i]=a;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF (ll)1e+12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    char a = 'a';

    ll n;
    cin >> n;

    vvc ans(1, vc(1,'a'));
    vll typ(1, 1);
    REP(i,n-1){
        vvc at;
        vll tt;
        REP(j,ans.size()){
            REP(k,typ[j]){
                vc elm = ans[j];
                elm.emplace_back((char)(a+k));
                at.emplace_back(elm);
                tt.emplace_back(typ[j]);
            }
            vc elm = ans[j];
            elm.emplace_back((char)(a+typ[j]));
            at.emplace_back(elm);
            tt.emplace_back(typ[j]+1);
        }
        ans = at;
        typ = tt;
    }
    cout << ans << endl;
    // cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 15668
/*
     ॐ त्र्यम्बकं यजामहे सुगन्धिं पुष्टिवर्धनम् |
     उर्वारुकमिव बन्धनान्मृत्योर्मुक्षीय माऽमृतात् ||
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define double         long double
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;

void solve()
{
     string s, t; cin >> s >> t;
     t.pop_back();
     if (t == s)
          cout << "Yes";
     else
          cout << "No";

}

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

#ifndef ONLINE_JUDGE
     freopen("input.txt",  "r",  stdin);
     freopen("output.txt", "w", stdout);
#endif

     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

Measured memory_bytes: 3844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{

    class Program
    {
        static void Main(string[] args)
        {
            char[] str = Console.ReadLine().ToCharArray();

            for(int i = 0; i < str.Length; i++)
            {
                //??§????????????
                if (char.IsUpper(str[i]))
                {
                    str[i] = char.ToLower(str[i]);
                }
                else
                {
                    str[i] = char.ToUpper(str[i]);
                }
            }
            Console.WriteLine(str);
        }
    }
}

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

int main(){
	string s,t;
	cin >> s;
	cin >> t;
	
	string ss = s + s;
	vector<vector<int>> locate(26);
	rep(i,ss.size()){
		locate[ss[i] - 'a'].push_back(i);
	}
	
	ll res = 0;
	int p = 0;
	rep(i,t.size()){
		int nowch = t[i] - 'a';
		if(locate[nowch].empty()){
			cout << -1 << endl;
			return 0;
		}
		int np = *lower_bound(locate[nowch].begin(), locate[nowch].end(), p)+1;
		res += np - p;
		p = np;
		if(p >= s.size()) p -= s.size();
	}
	
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1980
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long int ll;
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define deb(x) cout<<"Debug\t"<<#x<<"="<<x<<endl;
#define deb2(x,y) cout<<"Debug\t"<<#x<<"="<<x<<"\t"<<#y<<"="<<y<<endl;
#define deb3(x,y,z) cout<<"Debug\t"<<#x<<"="<<x<<"\t"<<#y<<"="<<y<<"\t"<<#z<<"="<<z<<endl;
#define deb4(x,y,z,w) cout<<"Debug\t"<<#x<<"="<<x<<"\t"<<#y<<"="<<y<<"\t"<<#z<<"="<<z<<"\t"<<#w<<"="<<w<<endl;
#define mod 1000000007
#define vi vector<ll>
#define pll pair<ll,ll>
#define vivi vector<vector<ll>> 
#define vipa vector<pair<ll,ll>>
#define pb push_back 
#define pf push_front
#define pll pair<ll,ll>


int main()
{
    ios;    
    ll t,i,n,m,j,x,y,pos,ans,sum,mini,k,diff;string s;
    vi v;
    v.pb(0);
    for(i=1;i<=12;i++)
    v.pb(v.back()+pow(26,i));

    /*for(i=0;i<12;i++)
    cout<<v[i]<<" ";
    cout<<endl;*/

    cin>>x;    
    vi an;
    while(x>0)
    {
        for(i=0;i<v.size();i++)
        if(v[i]==x)
        {
            while(i--)
            an.pb(25);
            goto here;
        }
        else if(v[i]>x)
        break;
        else
        continue;

        i--;
        //deb2(x,v[i]);
        if(!v[i])
        {
            //cout<<(char)(x-1+'a');
            an.pb(x-1);
            break;
        }
        if(x%26)        
        {
           // cout<<(char)(x%26-1+'a');        
            an.pb(x%26-1);
        }
        else
        {
           // cout<<(char)(x%26-1+26+'a');   
            an.pb(x%26+26-1);
        }
        
        if(x%26==0)
        x=x/26-1;
        else
        x=x/26;
      //  cout<<endl;
    }
    here:{}

    cout<<endl;
    reverse(an.begin(),an.end());
    for(auto z:an)
    cout<<(char)(z+'a');
    cout<<endl;
}

Measured memory_bytes: 4012
import java.util.*;

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

        long N = sc.nextLong();

        for (int i = (int) Math.sqrt(N); i >= 1; i--) {
            if (N % i == 0) {
                System.out.println((i - 1) + (N / i - 1));
                return;
            }
        }


    }
}

Measured memory_bytes: 23764
input = raw_input

k = int(input())
a, b = map(int, input().split(" "))

if b-a >= k:
    out = "OK"
else:
    ak = a % k
    bk = b % k
    if 0 in [ak, bk]:
        out = "OK"
    elif bk < ak:
        out = "OK"
    else:
        out = "NG"

print(out)

Measured memory_bytes: 64244
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    if(N == 1){
      System.out.println("Hello World");
    }else{
      int A = sc.nextInt();
      int B = sc.nextInt();
      System.out.println(A+B);
    }
  }
}


Measured memory_bytes: 20820
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>

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

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{
		string s = "";

		while(n != 0)
		{
			int t = n;

			if(n < 0) t *= -1;
			t %= 10;

			if(n < 0) t = (10 - t)%10;

			stringstream ss;
			ss << t;
			s += ss.str();

			n = (n - t)  / -10;
		}

		reverse(s.begin(),s.end());
		cout << s << endl;

	}

	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <stdlib.h>
#include <math.h>

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))

using namespace std;

int main(){
	int N, K;
	cin >> N >> K;
	if (N + 1 >= K * 2) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

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

using namespace std;

long long int psumA[200001];
long long int psumB[200001];
int A[200001],B[200001];

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

	int n,m,k;

	cin >> n >> m >> k;

	for(int i=1;i<=n;i++)
	{
		cin >> A[i];
	}
	for(int i=1;i<=m;i++)
	{
		cin >> B[i];
	}

	for(int i=1;i<=n;i++)
	{
		psumA[i] = psumA[i-1] + A[i];
	}
	for(int i=1;i<=m;i++)
	{
		psumB[i] = psumB[i-1] + B[i];
	}

	int res = 0;

	for(int i=0;i<=n;i++)
	{
		if(psumA[i] > k)
		{
			break;
		}
		int lo = 0;
		int hi = m;
		int Max = 0;
		long long int val = k - psumA[i];
		while(lo<=hi)
		{
			int mid = (lo + hi)/2;
			if(psumB[mid] <= val)
			{
				Max = max(Max,mid);
				lo = mid + 1;
			}
			else
			{
				hi = mid - 1;
			}
		}
		res = max(res,i + Max);
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 8312
#include<stdio.h>
int main(void)
{
	int N;
	scanf("%d", &N);
		for (int i = 1; i < 10; i++)for (int j = 1; j < 10; j++)
		{
			if (i * j == N)
			{
				printf("Yes");
				return 0;
			}
		}
		printf("No");
	
	return 0;
}

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


int main(){
  char s[10];
  cin >> s;
  sort(s,s+4);
  if(s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 764
x = int(input())
X = [int(i) for i in str(x)]
y = int(input())
dp = [[[0] * 2 for i in range(4)] for j in range(len(str(x))+1)]
dp[0][0][0] = 1

for i in range(len(str(x))):
  for j in range(4):
    for m in range(2):
      for n in range(10):
        nj = j + 1 if n != 0 else j
        if nj == 4: continue
        nm = m        
        if X[i] > n and m == 0:
          nm = 1
        if X[i] < n and m == 0:
          continue
        dp[i+1][nj][nm] += dp[i][j][m]

print(dp[len(X)][y][0]+dp[len(X)][y][1])


Measured memory_bytes: 41328
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        a: [usize1; n],
    }
    let mut aa = a.into_iter().map(|a| (a, true)).collect::<Vec<(usize, bool)>>();
    let mut now = 0;
    let mut time = 0;
    loop {
        let nowb = now;
        now = aa[now].0.clone();
        if nowb == now {
            println!("-1");
            return;
        } else if aa[now].1 == false {
            println!("-1");
            return;
        } else if now == 1 {
            println!("{}", time + 1);
            return;
        } else {
            aa[now].1 = false;
            time+=1;
        }
    }
}

Measured memory_bytes: 8444
#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 = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
ll A[MAX_N];
int C[MAX_N];
vi G[MAX_N];
bool used[MAX_N];
vector<ll> vx;
int ans;

void loop(int v) {
	used[v] = true;
	rep(i, 0, sz(G[v])) {
		int n = G[v][i];
		if(used[n]) continue;
		loop(n);
		if(C[v] < C[n]) {
			C[n] -= C[v];
			ans += C[v]; C[v] = 0;
		}
		else {
			C[v] -= C[n]; ans += C[n];
			C[n] = 0;
		}
	}
}

void solve() {
	cin >> N;
	rep(i, 0, N) {
		cin >> A[i];
		vx.pb(A[i]);
	}
	sort(all(vx));
	vx.erase(unique(all(vx)), vx.end());
	rep(i, 0, N) {
		int at = lower_bound(all(vx), A[i]) - vx.begin();
		C[at]++;
	}
	ans = 0;
	// debug(vx);
	rep(k, 0, 40) {
		int r = sz(vx) - 1;
		rep(i, 0, sz(vx)) {
			while(r > 0 && vx[i] + vx[r] > (1ll << k)) r--;
			if(i > r) break;
			if(vx[i] + vx[r] == (1ll << k)) {
				if(i != r) {
					G[i].pb(r);
					G[r].pb(i);
					// debug(i, r);
				}
			}
		}
	}
	rep(i, 0, sz(vx)) {
		if(!used[i]) loop(i);
	}
	rep(i, 0, sz(vx)) {
		rep(k, 0, 40) {
			if(vx[i] == (1ll << k)) {
				ans += C[i] / 2;
			}
		}
	}
	cout << ans << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    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: 17264
#include<bits/stdc++.h>
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  int sum=0;
  for(int i=0;i<K;i++){
    sum+=A.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll N,Z,W;
    cin >> N >> Z >> W;
    vector<ll> V(N);

    rep(i,0,N)cin >> V[i];
    if(N == 1){
        cout << abs(V[0] - W) << endl;
        return 0;
    }
    ll ans = max(abs(V[N-1] - W), abs(V[N-2] - V[N-1]));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()


int main(){
    int N;cin>>N;
    vector<int>X(N);
    vector<int>Y(N);

    rep(i,N){
        cin>>X.at(i);
        Y.at(i)=X.at(i);
    }
    sort(all(Y));
    int ans1=Y.at(N/2);
    int ans2=Y.at(N/2-1);
    rep(i,N){
        if(X.at(i)<=ans2){
            cout<<ans1<<endl;
        }else{
            cout<<ans2<<endl;
        }
    }
    
}


Measured memory_bytes: 4820
#include<stdio.h>

typedef struct{
  char c;
  int value;
}Card;

Card A[100001];
Card B[100001];

int partition(int p,int r){
  int i,j;
  Card x,z;

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

  return i+1;
  
};

void quicksort(int p, int r){
  int q;
  if(p<r){
    q = partition(p,r);
    quicksort(p,q-1);
    quicksort(q+1,r);
  }
};

int main(){
  int i,j,n,t1,t2,flag = 0;

  scanf("%d",&n);


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

  quicksort(0,n-1);
  
for(i=0;i<=n;i++){
  if(A[i].value == A[i+1].value){
    for(j=0;j<n;j++){
      if((A[i].c == B[j].c)&&(A[i].value == B[j].value)) t1 = j;
      if((A[i+1].c == B[j].c)&&(A[i+1].value == B[j].value)) t2 = j;
    }
    if(t1>t2){
      flag = 1;
      break;
    }
  }
 }




 if(flag == 1) printf("Not stable\n");
 else  printf("Stable\n");
  
  for(i=0;i<n;i++){
    
    printf("%c %d\n",A[i].c,A[i].value);
  }


  return 0;
}



Measured memory_bytes: 3336
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#define MAX 1000000
using namespace std;

typedef pair<int,int> P;
struct edge{
    int to,cost; edge(){}
    edge(int to,int cost):to(to),cost(cost){}
};

int st,gl,mone,wood_mone,cnt = 0;
int n,m,costed[101];
vector< vector<edge> > info(101);

void init(){
    for(int i=0;i<101;i++) costed[i] = MAX;
}

void add_info(){
    int a,b,c,d;
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    info[a].push_back(edge(b,c));
    info[b].push_back(edge(a,d));
}

int Dijkstra(){
    cnt++;
    priority_queue<P,vector<P>,greater<P> > que;
    if(cnt == 1){
        que.push(P(0,st));
        costed[st] = 0;
    }
    else if(cnt == 2){
        que.push(P(0,gl));
        costed[gl] = 0;
    }
    while(!que.empty()){
        P p = que.top(); que.pop();
        int now = p.second,c = p.first;
        if(now == st && cnt == 2) return c;
        else if(now == gl && cnt == 1) return c;
        for(int i=0;i<info[now].size();i++){
            edge e = info[now][i];
            if(e.cost + c < costed[e.to]){
                que.push(P(e.cost + c,e.to));
                costed[e.to] = e.cost + c;
            }
        }
    }
}

int main(){
    init();
    cin >> n >> m;
    for(int i=0;i<m;i++) add_info();
    scanf("%d,%d,%d,%d",&st,&gl,&mone,&wood_mone);
    int d = Dijkstra() + wood_mone;
    init();
    cout << mone - (Dijkstra() + d) << endl;
}

Measured memory_bytes: 1244
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
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 all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int D,G;cin>>D>>G;
    vector<ip> p(D);
    int ans = inf;
    rep(i,D)cin>>p[i].first>>p[i].second;
    for(int bit = 0; bit<(1<<D); bit++){
        int res = G;
        int cnt = 0;
        bool used[D] = {false};
        for(int i = 0; i<D; ++i){
            if(bit & (1<<i)){
                res -= (p[i].second + p[i].first*(i+1)*100);
                cnt += p[i].first; used[i] = true;
            }
        }
        bool cnot = false;
        for(int i = D-1; i>=0&& res>0; --i){
            if(!used[i]){
                if(res>(p[i].first-1)*(i+1)*100)cnot = true;
                else cnt += ceil((double)res/((i+1)*100));
                break;
            }
        }
        if(cnot)continue;
        ans = min(ans, cnt);
    }
    cout<<ans<<endl; return 0;
}


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

int main() {

  int A, B;
  cin >> A >> B;

  int answer = -1;

  for (int i = 1; i < 1010; i++){
    int a_ = floor((double) i / 100 * 8);
    int b_ = i / 10;
    if (A == a_ && B == b_){
      answer = i;
      break;
    }
  } 
  
  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 256
N = int(input())
x = []
y = []
h = []
for i in range(N):
    x_i, y_i, h_i = map(int, input().split())
    x.append(x_i)
    y.append(y_i)
    h.append(h_i)

#i:情報番号 j:求めるx座標 k:求めるy座標 l:求める高さ
for j in range(101):
    for k in range(101):
        for l in range(h[0], h[0] + 200):
            flag = 1
            for i in range(N):
                h_i_test = max(l - abs(x[i] - j) - abs(y[i] - k), 0)
                if h_i_test != h[i]:
                    flag = 0
                    break
            if flag == 1:
                print(str(j)+ " " + str(k) + " " + str(l))
                break
        if flag == 1:
            break
    if flag == 1:
        break


Measured memory_bytes: 49244
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a * b / 2 << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
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;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;


int main(){
    ll n; cin >> n;
    string s; cin >> s;
    vector<ll> w(n+1), b(n+1);
    w[0] = 0, b[0] = 0;
    Rep(i, 1, n+1){
        if(s[i-1] == '#'){
            w[i] = w[i-1];
            b[i] = b[i-1] + 1;
        }
        else{
            w[i] = w[i-1] + 1;
            b[i] = b[i-1];
        }
    }
    ll ans = INF;
    rep(i, n+1){
        chmin(ans, w[n]-w[i] + b[i]-b[0]);
    }
    cout << ans << endl;
}


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

using namespace std;

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

    vector< int > e(n + 10), w(n + 10);

    for(int i = 1; i <= n; ++i) {
        e[i] = e[i-1];
        w[i] = w[i-1];
        char c;
        cin >> c;
        e[i] += (c == 'E');
        w[i] += (c == 'W');
    }

    int best = 1e9;
    for(int i = 1; i <= n; ++i) {
        int cur = e[n] - e[i];
        cur += w[i-1];
        best = min(best, cur);
    }

    printf("%d", best);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define INF 1e16
using namespace std;

typedef long long ll;
struct edge { ll to, cost; };
typedef pair<ll,ll> P; //firstは最短距離,secondは頂点の番号

int n;
vector<edge> G1[100010],G2[100010];
ll d1[100010],d2[100010];

void dijkstra1(int s){//円での距離
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d1,d1+n,INF);
    d1[s]=0;
    que.push(P(0,s));

    while(!que.empty()){
        P p=que.top();que.pop();
        ll v=p.second;
        if(d1[v]<p.first)continue;
        for(int i=0;i<G1[v].size();i++){
            edge e=G1[v][i];
            if(d1[e.to]>d1[v]+e.cost){
                d1[e.to]=d1[v]+e.cost;
                que.push(P(d2[e.to],e.to));
            }
        }
    }
}
void dijkstra2(int s){//スヌークでの距離
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d2,d2+n,INF);
    d2[s]=0;
    que.push(P(0,s));

    while(!que.empty()){
        P p=que.top();que.pop();
        ll v=p.second;
        if(d2[v]<p.first)continue;
        for(int i=0;i<G2[v].size();i++){
            edge e=G2[v][i];
            if(d2[e.to]>d2[v]+e.cost){
                d2[e.to]=d2[v]+e.cost;
                que.push(P(d2[e.to],e.to));
            }
        }
    }
}

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

    int m,s,t;
    cin>>n>>m>>s>>t;
    s--;
    t--;

    for(int i=0;i<m;i++){
        int u,v,a,b;
        cin>>u>>v>>a>>b;
        u--;
        v--;
        G1[u].push_back(edge{v,a});
        G1[v].push_back(edge{u,a});
        G2[u].push_back(edge{v,b});
        G2[v].push_back(edge{u,b});
    }

    dijkstra1(s);
    dijkstra2(t);

    //for(int i=0;i<n;i++)cout<<d1[i]<<" ";
    //cout<<endl;
    //for(int i=0;i<n;i++)cout<<d2[i]<<" ";
    //cout<<endl;

    ll ans[n]={};
    for(int i=0;i<n;i++)ans[i]=d1[i]+d2[i];
    for(int i=n-2;i>=0;i--){
        ans[i]=min(ans[i],ans[i+1]);
    }

    ll money=1e15;
    for(int i=0;i<n;i++){
        cout<<money-ans[i]<<endl;
    }
}

Measured memory_bytes: 21488
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int N, X;
vector<int> x;

int main()
{
    cin >> N >> X;
    x.push_back(X);
    REP(i, N)
    {
        int tmp;
        cin >> tmp;
        x.push_back(tmp);
    }
    sort(x.begin(), x.end());
    int gcd = x[1] - x[0];
    REP(i, N)
    {
        gcd = __gcd(gcd, x[i + 1] - x[i]);
    }
    cout << gcd << endl;
}


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

int main() {
  string s;cin>>s;
  int cnt=0;
  rep(i, s.size()-1) {
    if (s[i+1]!=s[i]) cnt++;
  }
  cout << cnt;
}


Measured memory_bytes: 512
x,y,a,b,c = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
ans = []
for i in range(x):
    ans.append(A[i])
for i in range(y):
    ans.append(B[i])
for i in range(c):
    ans.append(C[i])
ans.sort(reverse=True)
anss = 0
for i in range(x+y):
    anss += ans[i]
print(anss)
    

            
            
    


    



Measured memory_bytes: 23328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			int N = in.nextInt();
			int[] test = new int[2*N];
			for( int i=0; i<2*N; i++)
			{
				test[i] = in.nextInt();
			}
			System.out.println(findmax(test));
		}
		in.close();
	}
	
	public static int findmax(int[] n)
	{
		quicksort(n,0,n.length-1);
		int sum = 0;
		for( int i=0; i<n.length; i=i+2)
		{
			sum += n[i];
		}
		return sum;
	}
	
    public static void quicksort(int n[], int left, int right) {
        int dp;
        if (left < right) {
            dp = partition(n, left, right);
            quicksort(n, left, dp - 1);
            quicksort(n, dp + 1, right);
        }
    }
    
    public static int partition(int n[], int left, int right) {
        int pivot = n[left];
        while (left < right) {
            while (left < right && n[right] >= pivot)
                right--;
            if (left < right)
                n[left++] = n[right];
            while (left < right && n[left] <= pivot)
                left++;
            if (left < right)
                n[right--] = n[left];
        }
        n[left] = pivot;
        return left;
    }
}

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

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0); //cinとcoutの同期切り
    ios::sync_with_stdio(false); //iostreamとstdioの同期切り

    int N;
    llong a[10010];
    cin >> N;
    for(int i = 1; i <= N; ++i){
        cin >> a[i];
    }

    int ans = 0;
    for(int i = 1; i <= N; ++i){
        while(a[i] % 2 == 0){
            a[i] = a[i] / 2;
            ++ans;
        }
    }

    cout << ans << endl;
    

    return 0;
}

/*****************************************************************************/
/*****   1秒間で処理できるfor文ループの回数                                 *****/
/*****   → 10^8 = 100,000,000 回程度                                      *****/
/*****                                                                   *****/
/*****   sort(a, a+N, greater<int>()); // a[0:N) を大きい順にソート        *****/
/*****                                                                   *****/
/*****                                                                   *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3"                *****/
/*****   std::cout << std::fixed;                                        *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3.00"             *****/
/*****                                                                   *****/
/*****************************************************************************/

Measured memory_bytes: 384
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        ab: [(usize, usize); n],
    }
    let mut l = 0;
    let mut r = 10000000000;
    while r - l > 1 {
        let m = (l + r) / 2;
        let mut left = 0;
        for i in 0..n {
            if ab[i].0 < m {
                left += 1;
            }
        }
        if 2 * left < n {
            l = m;
        } else {
            r = m;
        }
    }
    let x0 = l;

    let mut l = 0;
    let mut r = 10000000000;
    while r - l > 1 {
        let m = (l + r) / 2;
        let mut left = 0;
        for i in 0..n {
            if ab[i].1 < m {
                left += 1;
            }
        }
        if 2 * left < n {
            l = m;
        } else {
            r = m;
        }
    }
    let x1 = l;

    let mut l = 0;
    let mut r = 10000000000;
    while r - l > 1 {
        let m = (l + r) / 2;
        let mut right = 0;
        for i in 0..n {
            if m < ab[i].0 {
                right += 1;
            }
        }
        if 2 * right < n {
            r = m;
        } else {
            l = m;
        }
    }
    let y0 = r;

    let mut l = 0;
    let mut r = 10000000000;
    while r - l > 1 {
        let m = (l + r) / 2;
        let mut right = 0;
        for i in 0..n {
            if m < ab[i].1 {
                right += 1;
            }
        }
        if 2 * right < n {
            r = m;
        } else {
            l = m;
        }
    }
    let y1 = r;

    eprintln!("{} {} {} {}", x0, x1, y0, y1);
    if n % 2 == 0 {
        println!("{}", (x1 + y1) + 1 - (x0 + y0));
    } else {
        println!("{}", y1 + 1 - x0)
    }
}


Measured memory_bytes: 8960
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <math.h>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18+1;
const int N = 4e5+1;
const ll mod = 1e9+7;
const int bits = 19;


int main(){
    FASTIO;
    PRECISION;

    string s,t;
    cin>>s>>t;

    if(s==t.substr(0,s.size())){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
}

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

using namespace std;
typedef long long ll;

const int N = int(1e8) + 7;

void init(){

}

void solve(){
    char c[60];
    int a, b;
    scanf("%d %d %s", &a, &b, c);
    c[b-1] += 32;
    printf("%s\n", c);
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}


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

import sys

def main():
    n, a, b = map(int, sys.stdin.readline().split())

    s = 0
    for i in range(1, n + 1):
        if a <= sum(map(int, str(i))) <= b:
            s += i

    print(s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int count, a, i, max, j;
	max = 0;
	int hoji[11] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0 };
	count = 0;
	string mojiretu;
	cin >> mojiretu;
	a = mojiretu.length();
	for (i = 0; i < a; i++)
	{
		if ((mojiretu[i] == 'A') || (mojiretu[i] == 'G') || (mojiretu[i] == 'T') || (mojiretu[i] == 'C'))
		{
			count = count + 1;
		}
		else
		{
			hoji[i] = count;
			count = 0;
		}
	}
	hoji[10] = count;
	for (j=0;j<11;j++)
	{
		if (hoji[j]>max)
		{
			max = hoji[j];
		}
			
	}
	cout << max;

	return 0;
}

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

unordered_set<int> block_adj[100100];
unordered_set<int> friends_adj[100100];

struct UnionFind {
    vector<ll> par;  // 各元の親を表す配列
    vector<ll> siz;  // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;  // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);                     // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i;  // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) {  // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]];  // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {  // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) {  // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uftree(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uftree.unite(a, b);
        friends_adj[a].insert(b);
        friends_adj[b].insert(a);
    }
    rep(i, k) {
        int c, d;
        cin >> c >> d;
        c--;
        d--;
        if (uftree.issame(c, d)) {
            friends_adj[c].insert(d);
            friends_adj[d].insert(c);
            // block_adj[c].insert(d);
            // block_adj[d].insert(c);
        }
    }
    for (int i = 0; i < n; i++) {
        // cout << uftree.size(i) - friends_adj[i].size() + block_adj[i].size() - 1 << " ";
        cout << uftree.size(i) - friends_adj[i].size() - 1 << " ";
    }
    cout << endl;
}

Measured memory_bytes: 32256
#include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	char a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int left_index=0;
	int left_count=0;
	int right_index=1;
	int right_count=0;
	bool flag=false;
	for(int i=0;i<n;i++){
		if(a[i]=='('){
			left_index=i;
			for(int j=right_index;j<n;j++){
				if(a[j]==')' && left_index<j){
					right_index=j+1;
					flag=true;
					break;
				}
			}
			if(!flag){
				right_count++;
			}
		}
		flag=false;
	}

	left_index=n-1;
	right_index=0;
	bool flag2=false;

	for(int i=n-1;-1<i;i--){
		if(a[i]==')'){
			right_index=i;
			int t=-1;
			for(int j=left_index;-1<j;j--){
				if(a[j]=='(' && right_index>j){
					t=j;
					left_index=j-1;
					flag2=true;
					break;
				}
			}
			if(!flag2){
				left_count++;
			}
		}
		flag2=false;
	}

	for(int i=0;i<left_count;i++){
		cout<<'(';
	}

	for(int i=0;i<n;i++){
		cout<<a[i];
	}
	for(int i=0;i<right_count;i++){
		cout<<')';
	}
	cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

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

#define P pair<int, int>

int main() {
    int n;
    cin >> n;
    int x[n], l[n];
    for (int i = 0; i < n; i++) cin >> x[i] >> l[i];
    P ar[n];
    for (int i = 0; i < n; i++) {
        ar[i] = P(x[i] + l[i], x[i] - l[i]);
    }
    sort(ar, ar+n);
    int cur = ar[0].first, ans = 1;
    for (int i = 1; i < n; i++) {
        if (cur <= ar[i].second) {
            ans++;
            cur = ar[i].first;
        }
    }
    cout << ans << endl;
}

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

int main(int argc, char const *argv[])
{
  while(1)
  {
    int n, x;
    int ans = 0;
    cin >> n >> x;
    if(n==0 && x==0) break;

    for(int i = 1; i <= n-2; i++)
    {
      for(int j = i+1; j <= n-1; j++)
      {
        for(int k = j+1; k <= n; k++)
        {
          if(i+j+k == x)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

const int maxn=1e5+10;

int n,a[maxn], x, ans, d;

int main ()
{
	cin >> n;
	for (int i=1; i<=n; i++)
	cin >> a[i];
	a[0]=0;
	for (int i=1; i<=n; i++)
		ans+=abs(a[i]-a[i-1]);
	
	for (int i=1; i<n; i++)
	{
		int t;
		t=ans-(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))+abs(a[i+1]-a[i-1]);
		cout << t + abs (a[n]-0) << endl;
	}
	cout << ans - abs(a[n]-a[n-1]) + abs(a[n-1]-0);
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int n, poin[100010][5], memo[100010][5];

int dp(int day, int prv) {
	int ret = -1;
	if (day == n)
		return 0;
	if (memo[day][prv] != -1)
		return memo[day][prv];
	for (int k = 1; k < 4; k++) {
		if (k == prv)
			continue;
		ret = max(ret, poin[day + 1][k] + dp(day + 1, k));
	}
	memo[day][prv] = ret;
	return ret;
}

int main() {
	int ans;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j < 4; j++)
			scanf("%d", &poin[i][j]);
	memset(memo, -1, sizeof memo);
	ans = dp(0, 0);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
const int N=200010;
typedef long long LL;
typedef pair<int,int>pa;
pa a[N];
queue<pa>q;
LL ans;
int n,m,k;
int main(){
#ifdef WK
	freopen("in.txt","r",stdin);
#endif
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++){
		int aa,bb;
		scanf("%d%d",&aa,&bb);
		a[i]=make_pair(aa,bb);
	}
	sort(a+1,a+1+n);
	LL nowD=0;
	for(int i=1;i<=n;i++){
		int xx=a[i].first,yy=a[i].second;
		while(!q.empty()&&q.front().first+m<xx){
			nowD-=1ll*q.front().second*k;
			q.pop();
		}
		yy-=nowD;
		if(yy>0){
			int aa=xx+m,bb=(yy-1)/k+1;
			q.push(make_pair(aa,bb));
			nowD+=1ll*bb*k;
			ans+=bb;
		}
	}
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back

int main()
{
    string s;
    cin>>s;
    string t;
    cin>>t;
    int c=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]==t[i])
            c++;
    }
    cout<<c;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N;
  cin >> N;
  vector<vector<int>> a(N, vector<int>(3));
  for (int i=0; i<N; i++) {
    for (int j=0; j<3; j++) {
      cin >> a.at(i).at(j);
    }
  }
  
  vector<vector<int>> dp(N+1, vector<int>(3, 0));

  for (int i=0; i<N; i++) {
    for (int j=0; j<3; j++) {
      for (int k=0; k<3; k++) {
        if (j == k) continue;
          dp.at(i+1).at(k) = max(dp.at(i + 1).at(k), dp.at(i).at(j) + a.at(i).at(k) );
      }
    }
  }

    
  int res = 0;
  for (int j=0; j<3; j++) res = max(res, dp.at(N).at(j));
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 11136
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String str1 = input.readLine(); // 命令を実行する文字列
		int n = Integer.parseInt(input.readLine()); // 命令の数
		String com = "", p = "";
		int num1 = 0, num2 = 0;

		StringBuilder sb1 = new StringBuilder(str1);
		StringBuilder sb2 = new StringBuilder();

		for (int i = 0; i < n; i++) {
			String str2 = input.readLine(); // 命令を何行かで受け取る
			String[] str3 = str2.split("\n"); // 改行で文字列に分ける
			for (int j = 0; j < str3.length; j++) {
				int n1 = str3[j].indexOf(" ");
				int n2 = str3[j].indexOf(" ", n1 + 1);
				int n3 = str3[j].indexOf(" ", n2 + 1);
				// コマンドと数字に分ける
				if (n3 == -1) {
					com = str3[j].substring(0, n1);
					num1 = Integer.parseInt(str3[j].substring(n1 + 1, n2));
					num2 = Integer.parseInt(str3[j].substring(n2 + 1));
				}
				// コマンドと数字に分ける（replace）
				else {
					com = str3[j].substring(0, n1);
					num1 = Integer.parseInt(str3[j].substring(n1 + 1, n2));
					num2 = Integer.parseInt(str3[j].substring(n2 + 1, n3));
					p = str3[j].substring(n3 + 1);
				}
				// コマンド別に機能を記述（sb1は変更可能な状態の文字列 ,sb2は出力用）

				// print a b:str の a 文字目から b 文字目までを出力する
				if (com.equals("print")) {
					sb2.append(sb1.substring(num1, num2 + 1) + "\n");
				}
				// reverse a b: str の a 文字目から b 文字目までを逆順にする
				if (com.equals("reverse")) {
					String st1 = sb1.substring(0, num1);
					String st2 = sb1.substring(num2 + 1);
					sb1.delete(num2 + 1, sb1.length());
					sb1.delete(0, num1);
					sb1.reverse();
					sb1.insert(0, st1);
					sb1.append(st2);

				}
				// replace a b p: str の a 文字目から b 文字目までを p に置き換える。
				if (com.equals("replace")) {
					sb1.replace(num1, num2 + 1, p);
				}

			}

		}
		System.out.print(sb2);

	}

}

Measured memory_bytes: 20800
#include <iostream>
using namespace std;
int main() {
  long a, b, r, x, tmp;
  cin >> a >> b;
  x = a * b;

  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }

  r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  cout << (x / b);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll gcd(ll a2,ll b2){
	ll t;
	while(b2!=0){
		t=a2%b2;
		a2=b2;
		b2=t;
	}
	return a2;
}

int main() {

	ll n;
	string s[200002];
	cin>>n;
	rep(i,n)cin>>s[i];
	sort(s,s+n);

	ll t=1;
	rep(i,n-1){
		if(s[i+1]!=s[i])t++;
	}
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 9884