akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, P[110];

// dp[i][j] := i ???????????§???????????£???????°???? j ????????????????????¨??????
// 500 ??????????????§?????¨?????????????¶?????????????????°????
pii dp[110][50000];

signed main() {
    while(cin >> N, N) {
        rep(i,0,N) cin >> P[i];
        rep(i,0,110) rep(j,0,50000) dp[i][j] = pii(-1, INF);

        dp[0][0] = pii(0, 0);
        rep(i,0,N) rep(j,0,50000) {
            if(dp[i][j].first == -1) continue;
            chmax(dp[i+1][j], dp[i][j]);

            int change = (1000 - (P[i] % 1000)) % 1000;
            int getcoin = (j + change >= 500);
            int next_money = j + change - 500 * getcoin;
            chmax(dp[i+1][next_money], pii(dp[i][j].first + getcoin, dp[i][j].second - P[i]));
        }

        pii ans(-1, INF);
        rep(i,0,50000) chmax(ans, dp[N][i]);
        printf("%lld %lld\n", ans.first, -ans.second);
    }
    return 0;
}

Measured memory_bytes: 89136
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7


N = ri()
S = rs()

cnt = 0
for i in range(N-2):
    if S[i:i+3] == 'ABC':
        cnt += 1
print(cnt)


Measured memory_bytes: 38256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>

int main() {
  int N;
  scanf("%d", &N);
  std::queue<std::pair<int, int > > queue;
  int target = (N%2==0)?N+1:N;
  for (int i=1; i<=N; i++){
    for (int j=i+1; j<=N; j++){
      if (i==j) continue;
      if (i+j==target) continue;
      queue.push(std::make_pair(i, j));
    }
  }
  std::cout << queue.size() << std::endl;
  while(queue.size()>0){
    auto top = queue.front();
    queue.pop();
    std::cout << top.first << " " << top.second << std::endl; 
  }
  return 0;
}


Measured memory_bytes: 384
def resolve():
    N, K = list(map(int, input().split()))
    V = list(map(int, input().split()))
    start = (K+1)//2 if K%2==1 else K//2
    maxvalue = 0
    for npop in range(start, K+1):
        if npop >= N:
            npush = K - N
            negs = sorted([v for v in V if v < 0])
            posis = [v for v in V if v >= 0]
            maxvalue = max(maxvalue, sum(posis)+(sum(negs)-sum(negs[:npush])))
            continue

        for nleft in range(npop+1):
            nright = npop-nleft
            picked = V[:nleft] + V[N-nright:]
            negs = sorted([v for v in picked if v < 0])
            posis = [v for v in picked if v >= 0]
            npush = min(K-npop, len(negs))
            maxvalue = max(maxvalue, sum(posis)+(sum(negs)-sum(negs[:npush])))
    print(maxvalue)
            


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 39792
#include<stdio.h>
int main(){
  char s[1010]={0};
  int i;
  fgets(s,1000,stdin);
  for(i=0;s[i];i++){
    if(s[i+0]=='a'&&s[i+1]=='p'&&s[i+2]=='p'&&s[i+3]=='l'&&s[i+4]=='e'){
      i+=4;
      printf("peach");
    }
    else if(s[i+0]=='p'&&s[i+1]=='e'&&s[i+2]=='a'&&s[i+3]=='c'&&s[i+4]=='h'){
      i+=4;
      printf("apple");
    }
    else printf("%c",s[i]);
  }
  return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <map>
#define MAX 200000

using namespace std;
typedef long long int ll;
ll A[MAX+1];
int main(void){
  int N;
  ll ans = 0;
  cin >> N;
  map<ll,int> people;
  for(int i=1;i<=N;i++){
    ll tmp;
    cin >> tmp;
    A[i] = tmp;
  }
  people[1+A[1]] = 1;
  for(int i=2;i<=N;i++){
    ll num = i - A[i];
    int cand = people[num];
    ans = ans + cand;
    people[i+A[i]] += 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 27864
#include <iostream>
#include <iomanip>
#define  _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main() {
	double r;

	cin >> r;

	cout << fixed << setprecision(6) << r*r*(M_PI) << " " << 2*r*M_PI << endl;

	return 0;
}


Measured memory_bytes: 3252
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#define my_max zhi5968
typedef long long ll;
using namespace std;

int main()
{
	int n;
	cin>>n;
	for(int i=0;i<30;i++)
		for(int j=0;j<20;j++)
			if(4*i+7*j==n)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
/****15-Sept-2020*****/
#include<bits/stdc++.h>
using namespace std;
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define ss              set<string> //insert() .top()
#define si              set<int>
#define pii             pair<int,int>
#define vi              vector<int> //push_back()
#define mii             map<int,int>
#define pq              priority_queue<int> //insert()
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define m(arr,n,type)   type *arr=new type[n];
#define TestCase(x)            int x; cin>>x; while(x--)
#define FOR	        for(int i=0;i<n;i++)
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))
#define Mamun           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*erase(start_index,delete_length)*/
/*int myfun(int a,int b)
{
    return a>b;
}
*/
/*sort(vect.rbegin(),vect.rend())*/

void solve(){
    int n; cin>>n;
    for(int i=0;i<=10000;i+=1000){
    if(i>=n){
        cout<<i-n<<endl;
        return;}}

}


//int32_t main()
int main()
{
    Mamun;
    //freopen("input.txt","r",stdin);
      solve();
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<int, int>p;
struct edge { int to, cost; };
std::vector<edge>v[1000];
typedef std::vector<std::vector<int>>ma;
ma d;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool f = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";

int main() {
	ll n, k, ans = 0;
	std::cin >> n >> k;
	for (int i = k+1;i <= n;i++) {
		ll p = n / i;
		ans += p*(i - k);
		ll r = n - p*i;
		ans += max(0, r - k + 1);
	}
	if (k == 0)ans -= n;
	std::cout << ans << std::endl;
}

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

int div_cnt(int n) {
  int c = 0;
  for (int i = 1; i <= n; i++) {
    if (n%i==0) c++;
  }
  return c;
}

int main() {
  int N;
  cin >> N;
  
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (i%2!=0 && div_cnt(i) == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int sum = 0;
  rep(i, N){
    cin >> A.at(i);
    sum += A.at(i);
  }
  int cnt = 0;
  rep(i, N){
    if(A.at(i)*4*M >= sum){
      cnt++;
    }
  }
  if(cnt >= M){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

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

	vector<int> c(26);
	vector<vector<int>> s(D, vector<int>(26));
	vector<int> t(D);
	vector<vector<int>> last(D, vector<int>(26, 0));
	vector<int> sat(D);

	for (int i = 0; i < 26; i++) {
		cin >> c[i];
	}

	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) {
			cin >> s[i][j];
		}
	}

	for (int i = 0; i < D; i++) {
		cin >> t[i];
	}

	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) {
			if (i == 0) {
				last[i][j] = 0;
			} else {
				last[i][j] = last[i - 1][j];
			}
		}
		last[i][t[i] - 1] = i + 1;
		if (i == 0) {
			sat[i] = s[i][t[i] - 1];
		} else {
			sat[i] = s[i][t[i] - 1] + sat[i - 1];
		}
		int satisfaction = 0;
		for (int j = 0; j < 26; j++) {
			satisfaction += c[j] * (i + 1 - last[i][j]);
		}
		sat[i] -= satisfaction;
	}

	for (int i = 0; i < D; i++) {
		cout << sat[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

    ll operator"" _64(unsigned long long x){ return ll(x); }
    ull operator"" _64u(unsigned long long x){ return ull(x); }

    template<class T>
    vector<T> make_vector(int n, T t){
        return vector<T>(n, t);
    }
    template<class ...Ts>
    auto make_vector(int n, Ts ... ts){
        return vector<decltype(make_vector(ts...))>(n, make_vector(ts...));
    }

    template<class T>
    ostream& operator<<(ostream& os, const vector<T>& v){
        for (auto &&x : v) { os << x << ' '; } cout << endl; return os ;
    }
}
using namespace utils;

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

class solver{
    istream& is;
    ostream& os;

public:
    solver(istream& I, ostream& O) :is(I), os(O) {}
    void run(){
        ll A, B;
        is >> A >> B;
        if(!is) return;
        ll g = gcd(A, B);
        set<int> ps;
        for (int i = 2; i <= sqrt(g) + 1; ++i) {
            if(g % i == 0){
                ps.insert(i);
                while(g % i ==0) g /= i;
            }
        } // end i
        if(g > 1) ps.insert(g);
        os << ps.size() + 1 << endl;
    }
};

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_D.txt";
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int loop = 0;
    while(fs) {
        loop++;
        cout << '#' << loop << "#------\n";
        solver(fs, cout).run();
    }
    if(loop <= 1) {
        cout << "===" << endl;
        while(cin) solver(cin, cout).run();
    }
#else
    solver(cin, cout).run();
#endif
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		B_KEYENCE_String solver = new B_KEYENCE_String();
		solver.solve(1, in, out);
		out.close();
	}

	static class B_KEYENCE_String {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			String s = in.next();
			for (int i = 0; i <= s.length(); i++) {
				for (int j = i; j <= s.length(); j++) {
					String a = s.substring(0, i);
					String b = s.substring(j);
					if ((a + b).equals("keyence")) {
						out.println("YES");
						return;
					}
				}
			}
			out.println("NO");
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

	}
}



Measured memory_bytes: 22996
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#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 AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, K;
  cin >> N >> K;
  vl H(N, 0);
  vvl DP = VVL(N - K + 1, N + 1, llINF);
  DP[0][0] = 0;
  REP(i, N) { cin >> H[i]; }
  REP(i, N) {
    auto CP = DP;
    REP(j, N - K + 1) {
      if (j < N - K) {
        REP(l, i + 1) {
          ll hk = l == 0 ? 0 : H[l - 1];
          DP[j + 1][i + 1] =
              min(DP[j + 1][i + 1], CP[j][l] + max(0LL, H[i] - hk));
        }
      }
      REP(l, i + 1) { DP[j][l] = min(CP[j][l], DP[j][l]); }
    }
  }

  cout << *min_element(ALL(DP[N - K])) << endl;

  return 0;
}


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

int main(){
	int a, b;
	cin >> a >> b;
	
	int plus, minus, multiple;
	
	plus = a + b;
	minus = a -b;
	multiple = a * b;
	
	int max = plus;
	
	if( max < minus) max = minus;
	if( max < multiple) max = multiple;
	
	cout << max << endl;
	
	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

const double EPS = 1e-10;
#define equals(a, b) (fabs((a) - (b)) < EPS)

struct Point{
    double x, y;
    Point(){}
    Point(double x0, double y0){
        x = x0; y = y0;
    }

    Point operator +(const Point &p){
        return Point(x + p.x, y + p.y);
    }
    Point operator -(const Point &p){
        return Point(x - p.x, y - p.y);
    }
    Point operator *(const double &a){
        return Point(a * x, a * y);
    }
    Point operator /(const double &a){
        return Point(x / a, y / a);
    }

    double norm(){
        return x * x + y * y;
    }
    double abs(){
        return sqrt(norm());
    }

    bool operator == (const Point &p){
        return equals(x, p.x) && equals(y, p.y);
    }

    bool operator < (const Point &p){
        // if(x != p.x) return x < p.x;
        // else return y < p.y; 
        return x != p.x ? x < p.x : y < p.y ;
    }

};

typedef Point Vector;

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}

struct Circle{
    Point c;
    double r;
    Circle(){}
    Circle(Point c0, double r0){
        c.x = c0.x;
        c.y = c0.y;
        r = r0;
    }
    Circle(double x0, double y0, double r0){
        c.x = x0;
        c.y = y0;
        r = r0;
    }
};

int main(){
    Point p1, p2;
    cin >> p1.x >> p1.y;
    cin >> p2.x >> p2.y;
    Vector v0 = p2- p1;
    int Q;
    cin >> Q;
    rep(i, Q){
        Point p;
        cin >> p.x >> p.y;
        Vector v1 = p - p1;
        double r = dot(v0, v1) / v0.norm();
        Point m = p1 + v0 * r;
        Point x = m * 2.0 - p;
        printf("%.10lf %.10lf\n", x.x, x.y);
    }
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,d,ans=0;
	cin>>n>>d;
	while (n--)
	{
		ll x,y;
		cin>>x>>y;
		ll dist=(x*x+y*y);
		ll di=sqrt(dist);
		//cout<<di<<" "<<dist<<"\n";
		if (di*di<dist)di++;
		if (di<=d)ans++;
		//cout<<di<<"\n";
	}cout<<ans<<"\n";
}

Measured memory_bytes: 3604
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
  int H, W;
  scanf("%d %d", &H, &W);

  std::vector<std::vector<int>> c(10, std::vector<int>(10));
  for (auto& ci: c)
    for (auto& cij: ci) scanf("%d", &cij);

  for (int k = 0; k < 10; ++k)
    for (int i = 0; i < 10; ++i)
      for (int j = 0; j < 10; ++j)
        c[i][j] = std::min(c[i][j], c[i][k]+c[k][j]);

  int res = 0;
  for (int i = 0; i < H*W; ++i) {
    int a;
    scanf("%d", &a);
    if (a > -1) res += c[a][1];
  }

  printf("%d\n", res);
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
signed main()
{
  int a[4],i;
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  sort(a,a+3);
  for(int i=0;i<3;i++){
    cout<<a[i];
    if(i<2){
      cout<<" ";
  }
  }
  cout<<"\n";
  return(0);
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int r, g;
    cin >> r >> g;
    OUT(g*2-r)

    return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  ll X;
  cin >> X;
  ll const max = 1000000;
  for (ll i = 1; i <= max; ++i) {
    if (100 * i <= X && X <= 105 * i) {
      cout << 1 << endl;
      return 0;
    }
  }

  cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;


long long a, b, t, aa;

int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> a >> b >> t;
    aa = a;
    long long ans =0 ;
    while (aa <= t) {
        ans += b;
        aa += a;
    }
    cout << ans << '\n';
}



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

int main(){
  int N,count=0,number=0;
  cin>>N;
  vector <int> button(N);
  for(int i=0; i<N; i++){
    cin>>button.at(i);
    button.at(i)--;
  }
  for(int j=0; j<N; j++){
    count++;
    number=button.at(number);
    if(number==1)
      break;
  }
  if(number==1)
    cout<<count<<endl;
  else
    cout<<-1<<endl;
}

Measured memory_bytes: 640
# coding: utf-8
# Your code here!

import sys

a=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
    
divisors = make_divisors(a)
b = max([i for i in divisors if i <= a**(1/2)])
print(int(a/b + b - 2))

Measured memory_bytes: 3296
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <bitset>

constexpr int ElementNumMax {1000};
constexpr int ValueMax {10000};

//数値に対応したインデックスを保持
std::array<int, ValueMax> table;

class Cycle
{
public:
    
    static constexpr int nil = -1;

    void add(int x)
    {
        c.emplace_back(x);
        
        if (localMin == nil || x < localMin)
            localMin = x;
    }

    const std::vector<int>& cycle() const
    {
        return c;
    }

    int minValue() const
    {
        return localMin;
    }

    int minCost(int globalMin) const
    {
        if (c.size() == 1)
            return 0;

        int sum {std::accumulate(c.begin(), c.end(), 0)};
        return sum + 
            std::min(localMin + (c.size() + 1) * globalMin, (c.size() - 2) * localMin);
    }

private:

    std::vector<int>    c;
    int                 localMin = nil;
};

void solve();

int main()
{
    solve();
    return 0;
}

void solve()
{
    using namespace std;

    int n;
    cin >> n;

    vector<int> vec(n);

    for (int i = 0; i < n; ++i)
    {
        cin >> vec[i];
        //テーブルに数値のインデックスを記録
        table[vec[i]] = i;
    }

    sort(vec.begin(), vec.end());

    vector<Cycle> cycles;
    
    bitset<ElementNumMax> reached {};

    int globalMin {vec[0]};

    for (int i = 0; i < vec.size(); ++i)
    {
        if (vec[i] < globalMin)
            globalMin = vec[i];

        if (reached[i])
            continue;
        
        //サイクルを作成する
        Cycle c;
        c.add(vec[i]);

        int nextIndex = table[vec[i]];
        reached[i] = true;

        //1周するまで
        while (nextIndex != i)
        {
            c.add(vec[nextIndex]);
            reached[nextIndex] = true;
            nextIndex = table[vec[nextIndex]];
        }
        
        cycles.push_back(move(c));
    }

    int sum = accumulate(cycles.begin(), cycles.end(), 0, 
        [globalMin](int init, const Cycle& c)
    {
        return init + c.minCost(globalMin);
    });

    cout << sum << endl;
}


Measured memory_bytes: 3236
import java.util.Scanner;

/**
 * https://abc047.contest.atcoder.jp/tasks/abc047_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int N = sc.nextInt();
		int l = 0;
		int r = W;
		int b = 0;
		int t = H;
		for(int i=0; i<N; i++){
			int x = sc.nextInt();
			int y = sc.nextInt();
			int a = sc.nextInt();
			switch(a){
			case 1: l = Math.max(l, x); break;
			case 2: r = Math.min(r, x); break;
			case 3: b = Math.max(b, y); break;
			case 4: t = Math.min(t, y); break;
			}
		}
		sc.close();
		
		System.out.println(Math.max(0,r-l)*Math.max(0,t-b));

	}

}

Measured memory_bytes: 22100
N,W=[int(x) for x in input().split()]
w=[-1 for _ in range(N)]
v=[-1 for _ in range(N)]
for i in range(N):
	w[i],v[i]=[int(x) for x in input().split()]
#Constraints W<=10^5 w[i]<=10^5 and v[i]<=10^9
dp=[0 for _ in range(W+1)]
for i in range(N):
	for w_ in range(W,w[i]-1,-1):
		dp[w_]=max(dp[w_],dp[w_-w[i]]+v[i])
print(dp[W])
# dp[w0] stores maximum value with weight =w0 and using 1...i

Measured memory_bytes: 74048
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
using namespace std ;


string s ;

void input ( ) {
    cin >> s ;
}

void solve ( ) {
    if ( s == "Sunny" ) { cout << "Cloudy\n" ; }
    if ( s == "Cloudy" ) { cout << "Rainy\n" ; }
    if ( s == "Rainy" ) { cout << "Sunny\n" ; }
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

int main(){
  std::string x,y;
  int a[1001][1001];
  int cnt=0;

  std::cin>>x;
  std::cin>>y;
  for(int j=0;j<1001;j++){
    for(int k=0;k<1001;k++){
      a[j][k]=0;
      if(j==0) a[j][k]=k;
      if(k==0) a[j][k]=j;
    }
  }

  for(int j=0;j<=x.size();j++){
    for(int k=0;k<=y.size();k++){
      // std::cout<<a[j][k];
    }
    // std::cout<<"\n";
  }
  int b00,b01,b10,b11;
  for(int j=1;j<=x.size();j++){
    for(int k=1;k<=y.size();k++){
      b00=a[j-1][k-1];
      b01=a[j][k-1]+1;
      b10=a[j-1][k]+1;
      if(x[j-1]==y[k-1]){
	if(b00<=b01 && b00<=b10) a[j][k]=b00;
	else if(b01<=b00 && b01<=b10) a[j][k]=b01;
	else a[j][k]=b10;
      }else{
	if(b00+1<=b01 && b00+1<=b10) a[j][k]=b00+1;
	else if(b01<=b00 && b01<=b10) a[j][k]=b01;
	else a[j][k]=b10;
      }
    }

  }


  for(int j=1;j<=x.size();j++){
    for(int k=1;k<=y.size();k++){
      //std::cout<<a[j][k];
    }
    //std::cout<<"\n";
  }


  std::cout<<a[x.size()][y.size()]<<"\n";

  return 0;
}


Measured memory_bytes: 7136
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(string, "s", long, "p");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto a = aryread();
    auto oddary = new long[](n);
    foreach (i; iota(n))
        oddary[i] = (a[i] % 2 ? 1 : 2);
    long rm = 1;
    foreach (e; oddary)
        rm *= e;
    writeln(3 ^^ n - rm);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 2740
n=int(input())
s=list(input())
ans=0
for i in range(10):
  for j in range(10):
    for k in range(10):
      x=[str(i),str(j),str(k)]
      cnt=0
      for y in range(len(s)):
        if s[y]==x[cnt]:
          cnt+=1
        if cnt==3:
          ans+=1
          cnt+=1
          break
print(ans)
        

Measured memory_bytes: 75172
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n,c,alice,bob;
    alice = 0;
    bob = 0;
    scanf("%d",&n);
    vector<int> a;
    
    for(int i=0;i<n;i++){
        cin >> c;
        a.push_back(c); 
    }
    

    sort(a.begin(),a.end(),greater<int>());
    for(int i=0;i*2<n;i++){
        alice += a[i*2];
    }
    for(int i=0;i*2<n-1;i++){
        bob += a[i*2+1];
    }
    cout << alice - bob << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i =0;
		int[]a = new int[50];
		int[]b = new int[50];
		int[]c = new int[50];
		while (true) {
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			if (m == -1 && f == -1 && r == -1) {
				break; }
				a[i]=m;
				b[i]=f;
				c[i++]=r;
			}
			for (int j =0; j<i; j++){
				if(a[j] == -1 || b[j] == -1){
					System.out.println("F");
				} else if(a[j]+b[j]>=80){
					System.out.println("A");
				} else if(a[j]+b[j]>=65){
					System.out.println("B");
				} else if(a[j]+b[j]>=50){
					System.out.println("C");
				} else if(a[j]+b[j]>=30){
					if(c[j]>=50){
						System.out.println("C");
					}else{
						System.out.println("D");
					}
				}else {
		System.out.println("F");
	}
}}}


Measured memory_bytes: 26428
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int maxn=2001;
const int maxk=10009;
int n,K,len[maxn];
char s[maxn][maxk];
bitset<maxk> bit[maxn+1];
pii v[2][maxk];
int main()
{
    scanf("%d%d",&n,&K);
    for (int i=1;i<=n;++i) {
        scanf("%s",s[i]);
        len[i]=strlen(s[i]);
    }
    bit[n+1][0]=1;
    for (int i=n;i>=1;--i)
        bit[i]=bit[i+1]|(bit[i+1]<<len[i]);
    int c1=0;
    for (int i=1;i<=n;++i)
        if (bit[i+1][K-len[i]])
            v[1][++c1]=pii(i,0);
    for (int o=1;o<=K;++o) {
        char mmin='z';
        for (int i=1;i<=c1;++i)
            mmin=min(mmin,s[v[o&1][i].first][v[o&1][i].second]);
        putchar(mmin);
        int ID=n+1,c2=0;
        for (int i=1;i<=c1;++i) {
            int id=v[o&1][i].first,pos=v[o&1][i].second;
            char ch=s[id][pos];
            if (ch!=mmin) continue;
            if (pos+1==len[id]) ID=min(ID,id);
            else v[(o+1)&1][++c2]=pii(id,pos+1);
        }
        for (int i=ID+1;i<=n;++i) if (K-o-len[i]>=0&&bit[i+1][K-o-len[i]])
            v[(o+1)&1][++c2]=pii(i,0);
        c1=c2;
    }
    return 0;
}

Measured memory_bytes: 15076
#include<deque>
#include<stdint.h>
#include<set>
#include<stack>
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
using namespace std;
long long n,m,i,j,c[200010],a[200010],ans,mx;
int main()
{
	cin>>n>>m;
	for (i=1;i<=n;i++) cin>>a[i];
	for (i=1;i<n;i++)
	{
		if (a[i+1]==a[i]||a[i]+1==a[i+1])
		{
			ans+=a[i+1]-a[i];
			continue;
		}
		c[a[i]+2]++;
		if (a[i+1]<a[i]) a[i+1]+=m;
		ans+=a[i+1]-a[i];
		c[a[i+1]+1]-=a[i+1]-a[i];
		c[a[i+1]+2]+=a[i+1]-a[i]-1;
		if (a[i+1]>m) a[i+1]-=m;
	}
	for (i=1;i<=2*m;i++) c[i]+=c[i-1];
	for (i=1;i<=2*m;i++) c[i]+=c[i-1];
	for (i=1;i<=m;i++) mx=max(mx,c[i]+c[i+m]);
	cout<<ans-mx;
	return 0;
} 

Measured memory_bytes: 2560
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

//R() C{} S[]
int n, m;
string in;
int r[20], c[20], s[20], dot[20];
bool rcs[21][21][21];

int main(){
	while(getline(cin, in)){
		sscanf(in.c_str(), "%d%d", &n, &m);
		if(n == 0) break;
		memset(rcs, 0, sizeof(rcs));
		
		int tr = 0, tc = 0, ts = 0;
		rep(i, n){
			getline(cin, in);
			int p = 0;
			while(p < in.size() && in[p] == '.') p++;
			r[i] = tr;
			c[i] = tc;
			s[i] = ts;
			dot[i] = p;
			
			for(; p < in.size(); p++){
				if(in[p] == '(') tr++;
				if(in[p] == ')') tr--;
				if(in[p] == '{') tc++;
				if(in[p] == '}') tc--;
				if(in[p] == '[') ts++;
				if(in[p] == ']') ts--;
			}
		}
		for(int i = 1; i < 21; i++) for(int j = 1; j < 21; j++) for(int k = 1; k < 21; k++){
			bool ok = 1;
			rep(l, n){
				if(i * r[l] + j * c[l] + k * s[l] != dot[l]){
					ok = 0;
					break;
				}
			}
			if(ok) rcs[i][j][k] = 1;
		}
		tr = tc = ts = 0;
		rep(it, m){
			vi res;
			rep(i, 21) rep(j, 21) rep(k, 21) if(rcs[i][j][k]){
				int tmp = tr * i + tc * j + ts * k;
				res.pb(tmp);
			}
			sort(all(res)); res.erase(unique(all(res)), res.end());
			cout << (res.size() == 1 ? res[0] : -1) << (it == m - 1 ? "\n" : " ");
			getline(cin, in);
			rep(p, in.size()){
				if(in[p] == '(') tr++;
				if(in[p] == ')') tr--;
				if(in[p] == '{') tc++;
				if(in[p] == '}') tc--;
				if(in[p] == '[') ts++;
				if(in[p] == ']') ts--;
			}
		}
	}
	return 0;
}

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

int main() {
  long x,a,b,k;
  cin>>x;
  k=0;
  for(long i=0; i<1001; i++){
    for(long j=0; j<=i; j++){
      if(x==i*i*i*i*i-j*j*j*j*j){
        cout<<i<<" "<<j;
        k=1;
        break;
      }
      if(x==i*i*i*i*i+j*j*j*j*j){
        b=-j;
        cout<<i<<" "<<b;
        k=1;
        break;
      }
    }
    if(k==1){
      break;
    }
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    string s;
    map<string, ll> mp;
    ll top = 0;
    REP(i, n) {
        cin >> s;
        mp[s]++;
        top = max(top, mp[s]);
    }
    vector<string> res;
    for (auto x : mp) {
        if (x.second == top) {
            res.push_back(x.first);
        }
    }
    VSORT(res);
    for (auto ss : res) {
        cout << ss << endl;
    }
    return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int h, w, n, a;
  cin >> h >> w >> n;
  vector<int> va;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    while (a--) va.push_back(i + 1);
  }

  for (int i = 0; i < h * w; ++i) {
    int r = i / w, c = i % w;
    cout << (r % 2 == 0 ? va[i] : va[(r + 1) * w - c - 1]);
    cout << (c == w - 1 ? '\n' : ' ');
  }

  return 0;
}

Measured memory_bytes: 3672
#include <stdio.h>

int main(void)
{
	int h, a;
	int count = 0;

	scanf("%d %d", &h, &a);

	//攻撃の回数を数える
	while (h > 0) {
		h = h - a;
		count++;
	}

	printf("%d", count);
}

Measured memory_bytes: 128
#include<cstdio>
    #include<iostream>
    #include<algorithm>
    #include<cmath>
    #include<cstring>
    using namespace std;
    int main()
    {
    	int n,a,b,c,d;
    	scanf("%d",&n);
    	a=n/1000;
    	b=(n-a*1000)/100;
    	c=(n-a*1000-b*100)/10;
    	d=(n-a*1000-b*100-c*10);
    	if((a==b)&&(b==c)||(b==c&&c==d)){
    			printf("Yes\n");
    	}
        	else 
        		printf("No\n");
	}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

    int len = s.size();
    int curlen;
    string sub, front, back;
    for(int i = 1; i < len; i++){
        curlen = len - i;
        if(curlen % 2 != 0) continue;
        front = s.substr(0, curlen/2);
        back = s.substr(curlen/2, curlen/2);
        
        if(front == back){
            cout << curlen << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int N;
  while(cin >>N && N){
    int cnt[3], c[3]; memset(cnt, 0, sizeof(cnt)); memset(c, 0, sizeof(c));
    REP(i, N){
      int h, m, _m;
      scanf("%d%*c%d%d",&h, &m, &_m);
      int a = h * 60 + m, b = (_m >= m ? a + _m - m : a + (60 - m) + _m);
      if(a >= 11 * 60 && a <= 14 * 60 + 59) ++c[0];
      if(a >= 18 * 60 && a <= 20 * 60 + 59) ++c[1];
      if(a >= 21 * 60 || a <= 1 * 60 + 59) ++c[2];
      if(a >= 11 * 60 && a <= 14 * 60 + 59 && b - a <= 8) ++cnt[0];
      if(a >= 18 * 60 && a <= 20 * 60 + 59 && b - a <= 8) ++cnt[1];
      if((a >= 21 * 60 || a <= 1 * 60 + 59) && b - a <= 8) ++cnt[2];
    }
    cout <<"lunch ";
    if(c[0] == 0) cout <<"no guest" <<endl;
    else cout <<(int)(cnt[0] / (double)(c[0]) * 100) <<endl;
    cout <<"dinner ";
    if(c[1] == 0) cout <<"no guest" <<endl;
    else cout <<(int)(cnt[1] / (double)(c[1]) * 100) <<endl;
    cout <<"midnight ";
    if(c[2] == 0) cout <<"no guest" <<endl;
    else cout <<(int)(cnt[2] / (double)(c[2]) * 100) <<endl;
  }
  return 0;
}

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

int main(){
  double W,H,x,y;
  cin >> W >> H >> x >> y;
  double ans = W * H * 0.5;
  cout << ans << " ";
  if ( W/2 == x && H/2 == y){
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

vector<ll> fact, invfact;
ll modpower(ll x, ll n, ll mod)
{
    ll res = 1;
    while (n)
    {
        if (n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
ll inv(ll n)
{
    return modpower(n, MOD - 2, MOD);
}
void COMinit(ll k)
{ //空っぽの配列を二つ
    k++;
    fact.resize(k, 0);
    invfact.resize(k, 0);
    fact[0] = 1;
    repi(i, k, 1)
    {
        fact[i] = fact[i - 1] * i % MOD;
    }
    invfact[k - 1] = inv(fact[k - 1]);
    repd(i, k - 2, 0)
    {
        invfact[i] = invfact[i + 1] * (i + 1) % MOD;
    }
    return;
}
ll nCk(vector<ll> &fact, vector<ll> &invfact, ll n, ll k)
{ //この関数を使う前にCOMinit
    if (k < 0 || n < k)
        return 0LL;
    return fact[n] * invfact[k] % MOD * invfact[n - k] % MOD;
}
ll com(ll n, ll k)
{
    ll iv = 1;
    ll fa = 1;
    repi(i, k, 0)
    {
        fa *= (n - i);
        fa %= MOD;
    }
    repi(i, k + 1, 1)
    {
        iv *= inv(i);
        iv %= MOD;
    }
    return fa * iv % MOD;
}

//---------main function----------

int main()
{
    ll n;
    cin >> n;
    ll r = 1;
    string ans;
    while(n > 0){
        n--;
        r = n % 26;
        ans.push_back('a' + r);
        n = n/26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int n;

    cin >> n;

    int ans = 0;
    while (n != 0)
    {
        vector<int> retime(360000);

        for (int i = 0; i < n; i++)
        {

            int h, m, s;
            int entime;
            int detime;

            scanf("%d:%d:%d", &h, &m, &s);
            retime[h * 60 * 60 + m * 60 + s]++;
            scanf("%d:%d:%d", &h, &m, &s);
            retime[h * 60 * 60 + m * 60 + s]--;
        }

        for (int i = 1; i < 360000; i++)
        {
            retime[i] += retime[i - 1];
        }

        ans = *max_element(retime.begin(), retime.end());

        cout << ans << endl;
        ans = 0;
        cin >> n;
    }
}


Measured memory_bytes: 4516
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define sf(i,s) for(i=0;s[i]!='\0';i++)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define inf INT_MAX
#define pb push_back
#define mp make_pair
#define gcd(x,y) __gcd(x,y)
#define bc(x) __builtin_popcountll(x)
//cin.ignore(1, '\n');
ll power(ll a,ll b)
{
    if(b==0)
    return 1;
    if(b==1)
    return a;
    else
    {
        ll t=power(a,b/2);
        if(b%2==0)
        return ((t%mod)*(t%mod))%mod;
        else
        return ((((t%mod)*(t%mod))%mod)*((a%mod)%mod))%mod;
    }
}
void solve()
{
  ll n,i;
  cin>>n;
  ll a[n+1],dp[n+1];
  f(i,1,n+1)
  {
      cin>>a[i];
  }
  dp[0]=0;
  dp[1]=0;
  dp[2]=abs(a[2]-a[1]);
  f(i,3,n+1)
  {
     dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
  }
  cout<<dp[n];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
ll dp1[3030],dp2[3030];
int main(){
	int n,t,s;	cin>>n>>t>>s;
	vector<int> a(n),b(n);
	rep(i,n)	cin>>a[i]>>b[i];
	ll ans=0;
	rep(i,n){
		rep(j,t){
			dp2[j]=max(dp2[j],dp1[j]);//その屋台をスキップ
			if(j<t)	dp1[j+1]=max(dp1[j+1],dp1[j]);//その時間は何もしない
			if(j+b[i]<=t){//その屋台で遊ぶ
				if(j<s&&s<j+b[i])	continue;
				dp2[j+b[i]]=max(dp2[j+b[i]],dp1[j]+a[i]);
				ans=max(ans,dp2[j+b[i]]);
			}
		}
		rep(j,3030){
			dp1[j]=dp2[j];
			dp2[j]=0;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1264
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {

	static class Pair {
		public int x, y, id;
		public Pair() {
			x = y = 0;
		}
		public Pair(int x, int y, int i) {
			this.x = x;
			this.y = y;
			id = i;
		}
	}
	
	public static void main(String[] args) throws IOException {

		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int A = in.nextInt();
		int B = in.nextInt();
		int C=in.nextInt();
		if(A==B&&B==C)out.print("No\n");
		else if(A==B)out.print("Yes\n");
		else if(B==C)out.print("Yes\n");
		else if(C==A)out.print("Yes\n");
		else out.print("No\n");
		out.flush();

	}

	static class InputReader {
		StreamTokenizer tokenizer;

		public InputReader(InputStream stream) {
			tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(stream)));
			tokenizer.ordinaryChars(33, 126);
			tokenizer.wordChars(33, 126);
		}

		public String next() throws IOException {
			tokenizer.nextToken();
			return tokenizer.sval;
		}

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

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

		public boolean hasNext() throws IOException {
			int res = tokenizer.nextToken();
			tokenizer.pushBack();
			return res != StreamTokenizer.TT_EOF;
		}
	}

}


Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iostream>
#include <deque>
#include <math.h>
#include <cstdio>
#include <functional>
#include <set>
#include <iomanip>
#include <tuple>
typedef  long long ll;
using namespace std;

int main(void) {
	ll n, a, b;
	cin >> n >> a >>b;
	ll ans = 0;

	for (int i = 1; i <= n; i++)
	{
		ll wa = 0;
		ll num = i;
		while (num > 0)
		{
			wa += num % 10;
			num /=10;
		}
		if (a <= wa && wa <= b)
		{
			ans += i;
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = sc.next();
		
		if(s.charAt(a) == '-') {
		
		}else {
			System.out.println("No");
			return;
		}
		s = s.substring(0, a) + s.substring(a+1);
		for (Character c : s.toCharArray()) {
			if(Character.isDigit(c)) {
				
			}else {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
		
	}

}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
        A[i] -= i + 1;
    }
    sort(A.begin(), A.end());
    int b = A[(n - 1) / 2];
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += abs(A[i] - b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
//------------------------------------------------------------

		Scanner sc =new Scanner(System.in);
		String s = sc.nextLine();
		sc.close();

		System.out.println(s.lastIndexOf("Z")-s.indexOf("A")+1);


//------------------------------------------------------------
	}
}

Measured memory_bytes: 24772
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= 2000; i++) {
		for (int j = 0; j <= 4000; j++) {
			int rest = y - 10000 * i - 5000 * j;
			if (rest >= 0 && rest % 1000 == 0 && i + j + rest / 1000 == n) {
				cout << i << " " << j << " " << rest / 1000 << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 3600