akhauriyash/Code-Regression huggingface dataset:
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

vector<vector<vector<ll>>> A(300,vector<vector<ll>>(300));
vector<char> B;

vector<ll> & dfs(ll l,ll r){
    if(!A[l][r].empty()){return A[l][r];}
    if(l==r){return A[l][r];}
    ll sum=0;
    ll cnt=0;
    for(ll i=l;i<r;i++){
        if(B[i]=='('){sum++;}
        else if(B[i]==')'){sum--;}
        if(sum<0){return A[l][r];}
        if(sum==0){cnt++;}
    }
    if(sum!=0){return A[l][r];}
    if(l+1<r && cnt==1){return A[l][r]=dfs(l+1,r-1);}
    //cout<<l<<" "<<r<<endl;
    for(ll i=l;i<r;i++){
        vector<ll> &L=dfs(l,i);
        vector<ll> &R=dfs(i+1,r);
        if(B[i]=='*'){
            for(auto &I:L){
                for(auto &T:R){A[l][r].push_back(I*T);}
            }
        }
        else if(B[i]=='/'){
            for(auto &I:L){
                for(auto &T:R){if(T!=0){A[l][r].push_back(I/T);}}
            }
        }
        else if(B[i]=='+'){
            for(auto &I:L){
                for(auto &T:R){A[l][r].push_back(I+T);}
            }
        }
        else if(B[i]=='-'){
            for(auto &I:L){
                for(auto &T:R){A[l][r].push_back(I-T);}
            }
        }
    }
    return A[l][r];
}

bool isNum(char c){return '0'<=c && c<='9';}

int main(){
    string s;
    while(cin>>s){
        if(s=="#"){break;}
    for(auto &I:A){
        for(auto &T:I){T.clear();}
    }
    ll k=0;
    stack<ll> S;
    B.clear();
    for(int i=0;i<s.size();i++){
        if(isNum(s[i])){k*=10; k+=s[i]-'0';}
        else{
            if(i>0 && isNum(s[i-1])){
                A[B.size()][B.size()]={k};
                k=0;
            }
            B.push_back(s[i]);
        }
    }
    if(isNum(s.back())){A[B.size()][B.size()]={k}; k=0;}
    dfs(0,B.size());
    set<ll> st;
    for(auto &I:A[0][B.size()]){st.insert(I);}
    cout<<st.size()<<endl;
    /*
    for(int i=0;i<=B.size();i++){
        for(int t=0;t<=B.size();t++){
            cout<<i<<" "<<t<<endl;
            for(auto &I:A[i][t]){cout<<I<<" ";}
            cout<<endl;
        }
        cout<<endl;
    }
    */
    }
    
    return 0;
}



Measured memory_bytes: 5308
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <functional>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
using ll = long long;
const ll mod = 1000000007;
string al = "abcdefghijklmnopqrstuvwxyz";
//bool less_sec(const pair<int, int>&a, const pair<int, int>&b) {
//	return a.second > b.second;
//}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, T; cin >> N >> T;
	vector<int> v;
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		v.push_back(a);
	}
	ll cnt = 0;
	for (int i = 0; i < N; ++i) {
		if (i == N - 1) {
			cnt += T; break;
		}
		if (v[i + 1] - v[i] >= T) cnt += T;
		else cnt += v[i + 1] - v[i];
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<sstream>
#include<cstdio>
#include<map>
#include<set>
#include<cstdlib>
#include<vector>
#include<deque>
#define inf (1<<29)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX 100
using namespace std;
int N;
string alpha[MAX];
string  beta[MAX];
string s,t;

string replaceAll(string s, string f, string t) {
  string r;
  for (int p = 0; (p = s.find(f)) != s.npos; ) {
    r += s.substr(0, p) + t;
    s = s.substr(p + f.size());
  }
  return r + s;
}

struct P
{
  string s;
  int cost;
  P(string s = "",int cost = -inf):s(s),cost(cost){}
};

int main()
{
  /*
  string s = "nariXXXnarinanariYO"; // これを
  string f = "nari";                // 置換したいstring
  string t = "ir";                  // 置換するstring
  cout << replaceAll(s,f,t) << endl;
  */
  while(cin >> N,N)
    {
      rep(i,N)
	cin >> alpha[i] >> beta[i];
      cin >> s >> t;
      deque<P> deq;
      int mincost = inf;
      int tsize = t.size();
      set<string> memo;
      deq.push_back(P(s,0));
      while(!deq.empty())
	{
	  P p = deq.front(); deq.pop_front();
	  if(tsize < p.s.size())continue;
	  if(p.s == t)
	    {
	      mincost = p.cost;
	      break;
	    }

	  if(memo.find(p.s) == memo.end())
	    memo.insert(p.s);
	  else 
	    continue;	    


	  rep(i,N)
	    {
	      string pres = p.s;
	      pres = replaceAll(pres,alpha[i],beta[i]);
	      deq.push_back(P(pres,p.cost+1));
	    }
	}
      cout << (mincost == inf?-1:mincost) << endl;
    }
  return 0;
}

Measured memory_bytes: 1832
#include <stdio.h>

int main() {
	int x, j, count = 0;
	scanf("%d", &x);
	j = x / 2;
	char str[x], half1[j] = {}, half2[j] = {};
	scanf("%s", str);
	
	if(x % 2 != 0) {
		printf("No");
		return 0;
	}
	int sh = j;
	for(int i = 0; i < j; i++) {
		half1[i] = str[i];
		half2[i] = str[sh];
		sh++;
	}
	for(int i = 0; i < j; i++) {
		if(half1[i] == half2[i]) {
			count++;
		} else {
			printf("No");
			break;
		}
	}
	if(count == j) {
		printf("Yes");
	}
	
	return 0;
}

Measured memory_bytes: 1692
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;

int main(){
	int n;
	cin >> n;
	
	while(n>1000){
		n = n-1000;
	}
	
	cout << 1000-n <<endl;
	
	return 0;
}


Measured memory_bytes: 3628
# include<iostream>
#include<vector>
#include<queue>
#include<functional>
#define INF 2e6

typedef std::pair<int, int> P;

# define MAX_E 45
# define MAX_V 10

int V, E;

struct edge{
	int to, cost;
	edge() = default;
	edge(const edge &)= default;
	edge& operator = (const edge&) = default;
	edge(int _t, int _c) : to(_t), cost(_c) {}
};

std::vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s){
	std::priority_queue<P, std::vector<P>, std::greater<P>> Q;
	std::fill(d, d + V+1, INF);
	d[s] = 0;
	Q.push(P(0, s));
	while (!Q.empty()){
		P p = Q.top(); Q.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < G[v].size(); ++i){
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				Q.push(P(d[e.to], e.to));
			}
		}
	}
}

P solve(){
	int min = INF, minv;
	for (int i = 0; i <= V; ++i){
		int sum = 0;
		dijkstra(i);
		for (int j = 0; j <= V; ++j){
			sum += d[j];
		}
		if (min > sum)min = sum, minv = i;
	}
	return P(minv, min);
}

int main(){
	while (1){
		std::cin >> E;
		if (E == 0)
			break;
		for (int i = 0; i <= V; i++)G[i].clear();
		V = 0;
		int f, t, c;
		for (int i = 0; i < E; ++i){
			std::cin >> f >> t >> c;
			G[f].push_back(edge(t, c));
			G[t].push_back(edge(f, c));
			if (V < t)
				V = t;
		}
		std::cout << solve().first<<' '<< solve().second << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll D,T,S;
    cin >> D >> T >> S;
    cout << ((T*S >= D)?"Yes":"No") << endl;
}

Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int a,b;
int n,ans;
int main()
{
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)
	cout<<"Possible"<<endl;
	else
	cout<<"Impossible"<<endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (ull i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N,ans=0;
    cin >> N;
    const auto &res = prime_factorize(N);
    for (auto p : res) {
        if(p.second>=1&&p.second<3)    ans=ans+1;
        else if(p.second>=3&&p.second<6)    ans=ans+2;
        else if(p.second>=6&&p.second<10)    ans=ans+3;
        else if(p.second>=10&&p.second<15)    ans=ans+4;
        else if(p.second>=15&&p.second<21)    ans=ans+5;
        else if(p.second>=21&&p.second<28)    ans=ans+6;
        else if(p.second>=28&&p.second<36)    ans=ans+7;
        else if(p.second>=36&&p.second<45)    ans=ans+8;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>

using namespace std;

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

  int price[n];
  int maxPrice = 0;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;

    price[i] = p;

    if (maxPrice < p) {
      maxPrice = p;
    }
  }

  int sumPrice = 0;
  bool isDicount = true;
  for (int i = 0; i < n; i++) {
    if (price[i] == maxPrice && isDicount) {
      sumPrice += (price[i] / 2);
      isDicount = false;
    }
    else {
      sumPrice += price[i];
    }
  }

  cout << sumPrice << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int MAX = 1 << 18;
const int N = 1100;
const int L = 10;

int lvl[MAX];
vector <pii> pre[N];
vector <pii> a;
void rec(int x, int l, vector <pii> v)
{	
	if(x >= a.size()) return;
	v.pb({a[x].f, a[x].s});
	if(l == L) {
		for(int i = 0; i < (1 << L); i++) {
			int ww = 0, vv = 0;
			for(int j = 0; j < L; j++) {
				if((1 << j) & i) {
					ww += v[j].s;
					vv += v[j].f; 
				}
			}
			pre[x].pb({ww, vv});
		}
		sort(all(pre[x]), [&](const pii p1, const pii p2) {if(p1.f == p2.f) return p1.s < p2.s; return p1.f < p2.f;});
		for(int i = 1; i < pre[x].size(); i++)
		pre[x][i].s = max(pre[x][i].s, pre[x][i - 1].s);
		return;
	}
	rec(2 * x, l + 1, v);
	rec(2 * x + 1, l + 1, v);
}
int main()
{
	boost;
	int n, q, x, y, i;
	cin >> n;
	a.pb({0, 0});
	
	lvl[1] = 1;
	foe(i, 2, n)
	lvl[i] = lvl[i / 2] + 1;
	
	foe(i, 1, n) {
		cin >> x >> y;
		a.pb({x, y});
	}
	rec(1, 1, {});
	cin >> q;
	while(q--) {
		int val, W;
		cin >> val >> W;
		vector <int> v;
		int ans = 0;
		if(lvl[val] < L) {
			do {
				v.pb(val);
				val /= 2;
			} while(val);
			
			int x = v.size();
			for(int i = 0; i < (1 << x); i++) {
				int ww = 0, vv = 0;
				for(int j = 0; j < x; j++) {
					if((1 << j) & i) {
						ww += a[v[j]].s;
						vv += a[v[j]].f;
					}
				}
				if(ww <= W) ans = max(ans, vv);
			}
		}
		else {
			while(lvl[val] > L) {
				v.pb(val);
				val /= 2;
			}
			int node = val;
			int x = v.size();
			for(int i = 0; i < (1 << x); i++) {
				int ww = 0, vv = 0;
				for(int j = 0; j < x; j++) {
					if((1 << j) & i) {
						ww += a[v[j]].s;
						vv += a[v[j]].f;
					}
				}
				if(ww <= W) {
					pii p = {W - ww, inf};
					ans = max(ans, vv);
					int ind = upper_bound(all(pre[node]), p) - pre[node].begin();
					--ind;
					if(ind >= 0) ans = max(ans, vv + pre[node][ind].s); 
				}
			}
		}
		cout << ans << '\n';
	}
}


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

int main(){
    int n;
    vector<int> d(100);
    int sum=0,cnt=0;
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> d.at(i);
    }
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            sum = sum + d.at(i) * d.at(j);
            //cout << cnt << ":" << d.at(i) * d.at(j) << endl; 
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] av){
    	
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	
	int[][][] data=new int[4][3][10];


	for(int i=0;i<n;i++){
	    int b=sc.nextInt();
	    int f=sc.nextInt();
	    int r=sc.nextInt();
	    int v=sc.nextInt();	    
	    	    
	    data[b-1][f-1][r-1]+=v;	    

	}
	
	for(int k=0;k<4;k++){
	for(int i=0;i<3;i++){
	    for(int j=0;j<10;j++){
		System.out.print(" "+data[k][i][j]);
	    }
	    System.out.println();
	}
	if(k!=3)
	System.out.println("####################");
	}
    
    }
}



Measured memory_bytes: 29440
// https://atcoder.jp/contests/abc062/tasks/abc062_b

#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int h, w;
  vector<string> o, p;

  cin >> h >> w;

  REP(i, h)
  {
    string in;
    cin >> in;
    p.push_back(in);
  }

  string temp = "";
  REP(i, w + 2)
  {
    temp += '#';
  }

  REP(i, h + 2)
  {
    if (i == 0 || i == h + 1)
      o.push_back(temp);
    else
      o.push_back('#' + p[i - 1] + '#');
  }

  REP(i, h + 2)
  {
    cout << o[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <math.h>
long long int ans=0;
//最大公約数
long long int getgcd(long long n, long long m)
{
  int r;
  if (n > m) {
    long long t = m;
    m = n;
    n = t;
  }
  while ((r = m % n) != 0) {
    m = n;
    n = r;
  }
return n;
}

//nの階乗を計算
long long factorial(long long n){
    long long int answer = 1;
while(n > 1){
  answer *= n;
  n--;
}
    return answer;
}

//組み合わせの数nCrを計算
long long calcNumOfCombination(long long  n, long long r){
    return factorial(n) / (factorial(r) * factorial(n-r));
}
 void yes(){
   printf("Yes\n");
 }

 void no(){
   printf("No\n");
 }

int main(int argc, char* argv[]){
	long long int a = 0, b = 0,c=0;
	scanf("%lld",&a);
  scanf("%lld %lld",&b,&c);
  for (int i = b; i <= c; i++) {
    if (i%a==0) {
      printf("OK\n");
      return 0;
    }
  }
  printf("NG" );
  return 0;
}


Measured memory_bytes: 1704
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);
static const long long P = 1000000000LL+7;

int N, K;
vector<long long> A;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> K;
	int cplus = 0, czero = 0, cminus = 0;
	int odd = 0;
	if((K % 2) != 0){
		odd = 1;
	}
	for(int i=0; i<N; i++){
		long long a;
		cin >> a;
		A.push_back(a);
		if(a < 0){
			cminus++;
		}
		else if(a == 0){
			czero++;
		}
		else{
			cplus++;
		}
	}
	sort(A.begin(), A.end());
	if(K == 1){
		printf("%lld\n", A[N-1]);
		return 0;
	}
	long long ans = 1;
	//以下の場合は大きい方から順にK個の積が答え
	// - すべて0以上
	// - 負の数が1個
	// - すべてが負の数かつKが奇数の場合も同じ
	if(cminus == 0 || cminus == 1 || (cminus == N && (K % 2) == 1)){
		for(int k=0; k<K; k++){
			ans *= A[N-1-k];
			ans %= P;
			while(ans < 0){
				ans += P;
			}
		}
		ans %= P;
		printf("%lld\n", ans);
		return 0;
	}
	//0が入らざるを得ない場合は0
	if(cplus + cminus < K){
		printf("0\n");
		return 0;
	}
	int c = min(cminus, K);
	if((c % 2) != 0){
		c--;
	}
	vector<pair<long long, int>> M;
	long long u = 1;;
	for(int i = 0; ; i += 2){
		u = A[N-1-odd-i]*A[N-1-odd-(i+1)];
		if(u <= 0 || i > cplus + czero) break;
		M.push_back(make_pair(u, N-1-odd-(i+1)));
	}
	for(int i = 0; i < c; i += 2){
		u = A[i]*A[i+1];
		M.push_back(make_pair(u, -1));
	}
	sort(M.begin(), M.end());
	if(odd){
		ans = A[N-1];
	}
	else{
		ans = 1;
	}
	int pindx;
	int j = odd;
	for(int i=M.size()-1; i>=0; i--){
		if(j >= K) break;
		long long u = M[i].first;
		int v = M[i].second;
		if(v >= 0){
			pindx = v;
		}
		ans %= P;
		u %= P;
		ans *= u;
		ans %= P;
		while(ans < 0){
			ans += P;
		}
		j += 2;
	}
	int e = K - j;
	for(int i=1; i<=e; i++){
		ans *= A[pindx - i];
		ans %= P;
		while(ans < 0){
			ans += P;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 7932
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <deque>
using namespace std;
int main() {

    int m=0;
    string S;
    cin >> S;
    if (S[0] != 'A') {
        cout << "WA";
        return 0 ;
    }
    S.erase(0,1);
    for (int j = 1; j <S.size()-1 ; ++j) {
        if(S[j]=='C'){
            m++;
            S.erase(j,1);
            j--;
        }
    }
    if (m!=1){
        cout<<"WA";
        return 0;
    }
    for (int i = 0; i <S.size() ; ++i) {
        if(S[i]>=97){
            continue;
        }else{
            cout<<"WA";
            return 0;
        }
    }cout<<"AC";


}

Measured memory_bytes: 504
/*This Code Is Nude*/
#include <bits/stdc++.h>
 
#define pb push_back
#define ll long long
#define int long long
#define max(a,b) max((long long) a , (long long) b)
#define min(a,b) min((long long) a , (long long) b)

using namespace std;

const int inf = 1e12 + 10; 
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;

bool mark [maxn];
vector<int>adj[maxn];
int a[maxn];
int ans[maxn];
int psum [maxn];
int psumm[maxn];

int32_t main(){
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n , k;
	cin >> n >> k;
	psum[1] = 0;
	for(int i = 2 ; i <= n+1 ; i++)
		psum[i] = i-1 + psum[i-1];
	int ans = 0;
	for(int i = k ; i <= n+1 ; i++){
		ans = (ans + (psum[n+1] - psum [n + 1 - i]) - psum[i] + 1) % mod;
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;
using ll = long long;
const ll MOD = 1000003;

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

    a = s.at(0) - '0';
    b = s.at(1) - '0';
    c = s.at(2) - '0';
    d = s.at(3) - '0';

    ll tmp = 0;
    string op[2] = {"+", "-"};

    for (int i = 0; i <= 1; ++i) {
        if (i == 0) tmp = a + b;
        else tmp = a - b;

        for (int j = 0; j <= 1; ++j) {
            if (j == 0) tmp += c;
            else tmp -= c;

            for (int k = 0; k <= 1; ++k) {
                if (k == 0) tmp += d;
                else tmp -= d;

                if (tmp == 7) {

                    cout << to_string(a) + op[i] +
                            to_string(b) + op[j] +
                            to_string(c) + op[k] +
                            to_string(d) + "=7" << endl;
                    exit(EXIT_SUCCESS);
                }

                if (k == 0) tmp -= d;
                else tmp += d;
            }

            if (j == 0) tmp -= c;
            else tmp += c;
        }
    }
    return 0;
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())

ans = []
for i in range(a, a+k):
    if i not in ans and (a <= i and i <= b):
        ans.append(i)

for i in range(b-k+1, b+1):
    if i not in ans and (a <= i and i <= b):
        ans.append(i)
    
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
int n, m;
vector<int> divisor(int n)
{
    vector<int> res;
    for (int i = 1; i * i <= n; i++)
        if (n % i == 0)
        {
            res.push_back(i);
            if (i != n / i)
                res.push_back(n / i);
        }
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    vector<int> d = divisor(m);
    sort(ALL(d), greater<int>());
    for (int i = 0; i < d.size(); i++)
    {
        if (m / d[i] >= n)
        {
            cout << d[i] << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
int n;
cin >> n;
vector<int>dp(n,10e7),d(n);
for(int i=0;i<n;i++){
    cin >> d.at(i);
}
dp.at(0)=0;
for(int i=1;i<n;i++){
    if(i==1){
        dp.at(1)=abs(d.at(0)-d.at(1));
    }
    else{
        dp.at(i)=min(dp.at(i-1)+abs(d.at(i-1)-d.at(i)),dp.at(i-2)+abs(d.at(i-2)-d.at(i)));
    }
}
cout << dp.at(n-1)<<endl;
}



Measured memory_bytes: 1024
while True:
    i = input().split()
    m, f, r = map(int, i)

    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif m+f >= 80:
        print('A')
    elif m+f < 80 and m+f >= 65:
        print('B')
    elif m+f < 65 and m+f >= 50:
        print('C')
    elif m+f < 50 and m+f >=30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  vector<bool> expo(x+1);

  expo[1] = 1;
  repm(i,2,x+1){
    int tmp = i*i;
    while(tmp <= x){
      expo[tmp] = 1;
      tmp *= i;
    }
  }

  rep(i,x){
    if(expo[x-i]){
      cout << x-i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a<=b&&a<=c)
    {if(b<=c)
        printf("%d %d %d", a, b, c);
    else if(b>=c)
        printf("%d %d %d", a, c, b);
    }
    else if(b<=a&&b<=c)
    {if(a<=c)
        printf("%d %d %d", b, a, c);
    else if(a>=c)
        printf("%d %d %d", b ,c, a);
    }
    else if(c<=a&&c<=b)
    {if(a<=b)
        printf("%d %d %d", c, a, b);
    else if(b<=a)
        printf("%d %d %d", c, b, a);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1e9+1
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  vector<int>A(n);
  for (int i = 0; i < n; ++i)
  {
   cin >> A[i];
  }
  sort(A.begin(),A.end());
  double ans = (A[0]+A[1])/2.0;
  for (int i = 2; i < n; ++i)
  {
    ans = (ans+A[i])/2.0;
  }
  cout << ans << endl;
	return 0;
}	

Measured memory_bytes: 256
import collections

def solution():
    n = [int(x) for x in input().strip()]
    res = 0
    carry = 0
    for i in range(len(n)-1, -1, -1):
        cur = n[i] + carry
        if cur == 10:
            carry = 1
        elif 6 <= cur <= 9:
            res += 10-cur
            carry = 1
        elif cur == 5:
            if i > 0 and n[i-1] >= 5:
                carry = 1
                res += 5
            else:
                carry = 0
                res += 5
        else:
            carry = 0
            res += cur
    print(res+carry)

def main():    
    # T = int(input().strip())
    for _ in range(1):
        solution()
    

main()

Measured memory_bytes: 116580
#include<cstdio>
#include<algorithm>
using namespace std;
int Get(int n, int K) {
	if (n%K == 0)return n / K;
	if (n < K)return 0;
	int m = n / K;
	if(m > K)return Get(n - m - 1, K);
	int u = n / K*K;
	int t = n % (m + 1);
	int nxt = u / (m + 1)*(m + 1) + t;
	if (nxt > u)nxt -= (m + 1);
	return Get(nxt, K);
}
int main() {
	int T, r = 0, n, K;
	scanf("%d", &T);
	while (T--) {
		scanf("%d%d", &n, &K);
		r ^= Get(n, K);
	}
	if (r)printf("Takahashi\n");
	else printf("Aoki\n");
}

Measured memory_bytes: 256
#include <functional>
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
#include <type_traits>
namespace loquat {
template <int MOD>
class modulus_integer {
public:
	typedef modulus_integer<MOD> self_type;
private:
	int m_value;
	static self_type unsafe_construct(int x) noexcept {
		self_type y;
		y.m_value = x;
		return y;
	}
public:
	modulus_integer() noexcept
		: m_value(0)
	{ }
	modulus_integer(int x) noexcept
		: m_value(x % MOD)
	{
		if(m_value < 0){ m_value += MOD; }
	}
	int operator*() const noexcept { return m_value; }
	self_type& operator=(const self_type& x) noexcept {
		m_value = x.m_value;
		return *this;
	}
	self_type operator*(const self_type& x) const noexcept {
		return unsafe_construct(
			static_cast<long long>(m_value) * x.m_value % MOD);
	}
	self_type& operator*=(const self_type& x) noexcept {
		return (*this = *this * x);
	}
};
template <int MOD>
inline std::ostream& operator<<(
	std::ostream& os, const modulus_integer<MOD>& x)
{
	os << *x;
	return os;
}
}
using namespace std;
static const int MOD = 1000000007;
using mint = loquat::modulus_integer<MOD>;
int main(){
	ios_base::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	mint answer = 1;
	int pos = 0;
	for(int i = 0; i < 2 * n; ++i){
		if(s[i] == 'W'){
			if(pos % 2 == 0){
				answer *= pos;
				--pos;
			}else{
				++pos;
			}
		}else{
			if(pos % 2 == 0){
				++pos;
			}else{
				answer *= pos;
				--pos;
			}
		}
		if(pos < 0){
			answer = 0;
		}
	}
	if(pos != 0){ answer = 0; }
	for(int i = 1; i <= n; ++i){
		answer *= i;
	}
	cout << answer << endl;
	return 0;
}


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

int main() {
    ll n, y; cin >> n >> y;
    rep(i, n+1) {
        rep(g, n+1-i) {
            ll s = (y - i*10000 - g*5000) / 1000;
            if(s == n - i - g) {
                cout << i << ' ' << g << ' ' << s << endl;
                return 0;
            }
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<ll> vll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(s, e) for(int i=s; i<e; ++i)
#define pb push_back
#define INF 1000000000

int main(){
	IO
	int n;
	cin >> n;
	ll ans = 0LL;
	for(int a = 1; a<=n; ++a){
		for(int b = 1; b<=n; ++b){
			for(int c = 1; c<=n; ++c){
				ans+=(__gcd(a, __gcd(b, c)));
			}
		}
	}

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

Measured memory_bytes: 3664
import collections

#文字列を一文字ずつ取得したいとき
def inputStrOnebyOne():
    s = list(input())
    return s

#整数を一つずつリストに入れる
def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a

def main():
    a, b, c, d = map(int,input().split())
    if a+b > c+d:
        print("Left")
    elif a+b < c+d:
       print("Right")
    else:
        print("Balanced")

if __name__=='__main__':
    main()

Measured memory_bytes: 3436
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AandB = []
for i in range(0, X):
	for j in range(0, Y):
		AandB.append(A[i]+B[j])
AandB.sort(reverse = True)
if len(AandB) > K:
	AandB = AandB[:K]
anslist = []
for i in range(0, len(AandB)):
	tmplist = []
	for j in range(0, Z):
		tmplist.append(AandB[i]+C[j])
	anslist = anslist + tmplist
	anslist.sort(reverse = True)
	if len(anslist) > K:
		anslist = anslist[:K]
for i in range(0, K):
	print(anslist[i])

Measured memory_bytes: 103248
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0 ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
 
}

const int MAXN = 200100;
char s[MAXN];
int pre[MAXN],suf[MAXN];
int32_t main(){
  fastio;
  int n,k,c;
  cin>>n>>k>>c;
  c++;
  for(int i=1;i<=n;i++)cin>>s[i];

  pre[0] = 0;
  for(int i=1;i<=n;i++){
    pre[i] = pre[i-1];
    if(s[i]=='o' && i-c>=0){
      pre[i] = max(pre[i],1 + pre[i-c]);
    }else if(s[i]=='o' && i-c<0){
      pre[i] = max(pre[i],1LL);
    }
  }  

  suf[n+1] = 0;
  for(int i =n;i>=1;i--){
    suf[i] = suf[i+1];
    if(s[i]=='o' && i+c<=n+1){
      suf[i] = max(suf[i],1 + suf[i+c]);
    }else if(s[i]=='o' && i+c>n+1){
      suf[i] = max(suf[i],1LL);
    }
  }
  for(int i=1;i<=n;i++){
    //cout<<i<<" "<<pre[i-1]<<" "<<suf[i+1]<<endl;
    if(pre[i-1] + suf[i+1]>=k){
      //ok
    }else cout<<i<<endl;
  }

  // Math -> gcd it all // chack MAXN // check ll
  //did you check N=1? Did you mix up N,M?
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int k;
    cin>>k;
    rep(i,k) cout<<"ACL";
}

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

int check(int n){
	char ca[10];
	cout<<n<<endl;
	cin>>ca;
	if(strcmp(ca,"Vacant")==0)return -1;
	if(strcmp(ca,"Male")==0)return 0;
	if(strcmp(ca,"Female")==0)return 1;
}

int main(){
	int n;
	int i,j,k;
	int m1,m2;
	int t,a,b,c;
	cin>>n;
	m1=0,m2=n;
	t=check(0);
	while(1){
		a=(m2+m1)/2;
		b=check(a);
		if(b==-1)return 0;
		if((a-m1+t)%2==b){
			t=b,m1=a;
		}else{
			m2=a;
		}
	}
}
		
		


Measured memory_bytes: 852
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


vector<ll>v[Max+10];


ll vis[Max+10];



ll cnt=0;

void dfs(ll s,ll p)
{


     for(auto x : v[s])
     {
         if(vis[x]==0)
         {
             cnt++;
             vis[x]=1;
             dfs(x,s);
         }
     }
}
int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,q,l,r,ans=0;

      bool flag=false;

      string str;

      cin>>n>>m;

      for(i=0; i<m; i++)
      {
          cin>>a>>b;

          v[a].eb(b);
          v[b].eb(a);
      }

      ans=0;

      for(i=1; i<=n; i++)
      {
          if(vis[i]==0)
          {
              vis[i]=1;
              cnt=1;

              dfs(i,i);

              ans=max(cnt,ans);
          }
      }


      cout<<ans<<endl;




}



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

#define max(A,B) (A>B?A:B)
#define min(A,B) (A<B?A:B)
typedef long long int lli;
int main(){
  lli N, i, L_min, sqN;
  scanf("%lld",&N);
  L_min = 1e12;
  sqN = sqrt(N)+1;
  for(i=1;i<sqN;i++){
    if(N%i==0){
      L_min = min(L_min,(i-1)+(N/i-1));
      //printf("%lld %lld %lld\n",L_min,i,N/i);
    }
  }
  //printf("%lld\n",sqN);
  printf("%lld",L_min);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long r,d,n;
    scanf("%lld%lld%lld",&r,&d,&n);
    for(int i=1;i<=10;i++)
    {
        n=n*r-d;
        printf("%lld\n",n);

    }
}


Measured memory_bytes: 256
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[])
    {
        Scanner  sc=new Scanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt();
        long ans=0,te=0;
        while(t-->0)
        {
           long a=sc.nextLong(),b=sc.nextLong(),c=sc.nextLong(),x=sc.nextLong(),y=sc.nextLong();
            long max=Math.max(x,y),min=Math.min(x,y);
              if(min*(a+b)<=min*2*c)
              {
                ans+=min*(a+b);
              }
              else ans+=2*c*min;
            if(max==x)
            ans+=Math.min((max-min)*a,(max-min)*2*c);
            else ans+=Math.min((max-min)*b,(max-min)*2*c);
            pw.println(ans);
        }
           pw.close();
    }
}
  

Measured memory_bytes: 35788
s = input()
s = list(map(int, list(s)))
 
now = s[0]
cnt = 0
stack = []
for e in s:
    if now == e:
        cnt += 1
    else:
        stack.append(cnt)
        cnt = 1
        now = e
stack.append(cnt)
 
# print(stack)
 
l = len(stack)
ans = int(1e18)
if l == 1:
    ans = len(s)
else:
    cnt = 0
    for i in range(l):
        cnt += stack[i]
        ans = min(ans, max(cnt, len(s)-cnt))
 
print(ans)


Measured memory_bytes: 49904
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define N 200005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define rev(a,n) reverse(a,a+n)
using namespace std;
int n,k,a[N];
int main() {
	cin>>n>>k;
	rep1(i,1,n){
		cin>>a[i];
		if(i>k){
			if(a[i-k]<a[i]) cout<<"Yes\n";
			else cout<<"No\n";
		}
	}
	return 0;
}


Measured memory_bytes: 4352
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin >> n;

	vector<int> h(n + 1, 0);
	for(int i = 1; i <= n; i++) cin >> h[i];
	vector<int> dp(n + 1, 0);
	dp[1] = 0;
	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];
}

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

int n, curr;
int sum;

int main(){

    cin >> n;
    curr = n;
    while (curr > 0){
        sum += curr%10;
        curr -= curr%10;
        curr /= 10;
    }

    if (n % sum == 0) cout << "Yes";
    else cout << "No";

}


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


void solve(long long W, long long H, long long N, std::vector<long long> x, std::vector<long long> y, std::vector<long long> a){
    long long xs = 0, xe = W;
    long long ys = 0, ye = H;
    for (int i = 0; i < N; i++) {
      if (a[i] == 1) {
	  xs = max(xs, x[i]);
      } else if (a[i] == 2) {
	  xe = min(xe, x[i]);
      } else if (a[i] == 3) {
	  ys = max(ys, y[i]);
      } else {
	  ye = min(ye, y[i]);
      }
    }
    long long xLeft = max(xe - xs, 0ll);
    long long yLeft = max(ye - ys, 0ll);
    cout << xLeft*yLeft << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long W;
    scanf("%lld",&W);
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        scanf("%lld",&a[i]);
    }
    solve(W, H, N, std::move(x), std::move(y), std::move(a));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()
using ll = long long;
using namespace std;
using pii = pair<int, int>;
using pdi = pair<double, int>;

int N;

int main() {
	cin >> N;
	vector<int> a;
	vector<pii> p;
	for (int i = 0; i < N; i++)
	{
		int tmpa;
		cin >> tmpa;
		a.push_back(tmpa);
		p.push_back(pii(tmpa, i));
	}


	double ave = 0;
	for (int i = 0; i < N; i++)
	{
		ave += a[i];
	}
	ave /= N;

	double gap = 100000000;
	int igap;
	for (int i = 0; i < N; i++)
	{
		if (abs(a[i] - ave) < gap) {
			gap = abs(a[i] - ave);
			igap = i;
		}
	}
	cout << igap << endl;

	return 0;


}


Measured memory_bytes: 256
import java.util.*;
public class Main{

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        String p = sc.next();
        
        //文字列sを2つつなげる
        s = s + s;
        
        //文字列sの中に文字列pが含まれる場合
        if(s.contains(p)) System.out.println("Yes");
        else System.out.println("No");

    }

}



Measured memory_bytes: 26124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N;
  A = N/10;
  B = N%1000;
  if (A%111 == 0 || B%111 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

  

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

public class Magatro
{
    public void Solve()
    {
        string O = Console.ReadLine();
        string E = Console.ReadLine();
        char[] ans = new char[O.Length + E.Length];
        for(int i = 0; i < O.Length; i++)
        {
            ans[i * 2] = O[i];
        }
        for(int i = 0; i < E.Length; i++)
        {
            ans[i * 2 + 1] = E[i];
        }
        Console.WriteLine(new string(ans));
    }
}

Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int mini = 10000, maxi = -10000;
    for (int i = 0; i < n; ++i)
    {
        int a;
        cin >> a;
        mini = min(mini, a);
        maxi = max(maxi, a);
    }
    cout << maxi - mini;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
//ll arr[600001];
int main()
{
    ll n,i;
    cin>>n;
    vector<ll>v;
    unordered_map<ll,ll>mp;
    ll m,a=0;
    for(i=0;i<n;i++)
    {
        cin>>m;
        a=a^m;
    }
    if(a==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n;
    string s;
    cin >>n>>s;

    if (n % 2 != 0)
    {
        cout << "No" << endl;
        return 0;
    }

    rep(i,0,n/2)
    {
        if (s[i] != s[i+n/2])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
using System;

class Plogram
{
    static void Main()
    {
        string S = Console.ReadLine();
        string T = Console.ReadLine();
        string S2;
        string ans = "No";

        for(int i = 0; i<S.Length;i++)
        {
            S2 = S.Substring(S.Length -1 , 1) + S.Substring(0, S.Length - 1);
            if (T == S2)
            {
                ans = "Yes";
            }
            S = S2;
        }

        Console.WriteLine(ans);

    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
#define ll long long
#define trace(x) cerr << #x << " = " << x << endl
using namespace std;

/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
int main()
{
   /*
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("ouput.txt","w",stdout);
    #endif 
   */

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while(t--){
         int n;
	 cin>>n;
	 vector<int> l(n);
	 for(auto &it : l) cin>>it;
	 sort(l.begin(), l.end());
	 int count = 0;
	 for(int i = 0; i < n-2; i++){
		 for(int j = i+1; j < n-1; j++){
			 if(l[j] == l[i]) continue;
			 for(int k = j+1; k < n; k++){
				 if(l[k] == l[j] || l[k] == l[i])  continue;
				 if(l[i] + l[j] > l[k])
					 count++;
			 }
		 }
	 }
	 cout<<count<<endl;
    }
    return 0;
} 


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

int main(){
    int A;
    cin >> A;
    int B;
    cin >> B;
    int X = 0;
    int Y = 0;
    for (int i = 0; i <= B - A; i++){
        Y = i + A;
        if (Y / 10000 == Y % 10){
            if (Y / 1000 % 10 == Y / 10 % 10){
                X = X + 1;
            }
        }
    }
    cout << X << endl;
}

Measured memory_bytes: 256