akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int r, d, x, ans = 0;
    cin >> r >> d >> x;
    for(int i = 0; i < 10; i++){
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  int N = S.size();
  int cnt1 = 0;
  // 010101...
  for(int i = 0;i < N;i++){
    if(i%2 == 0 && S.at(i) == '1') cnt1++;
    if(i%2 == 1 && S.at(i) == '0') cnt1++;
  }
  int cnt2 = 0;
  // 101010...
  for(int i = 0;i < N;i++){
    if(i%2 == 0 && S.at(i) == '0') cnt2++;
    if(i%2 == 1 && S.at(i) == '1') cnt2++;
  }
  
  cout << min(cnt1, cnt2) << endl;
  
  return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;


int main() {
  int A, B, C;
  cin >> A >> B >> C;

  int max_value = max(A, max(B, C));
  int sum = A + B + C;

  int res = max_value * 10 + (sum - max_value);

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <sstream>
using namespace std;

const string op = "+-*/";

int main(){
  string s;

  while(getline(cin,s)){
    stringstream ss;
    ss << s;
    stack<double> st;
    while(ss >> s){
      int t = op.find(s);
      if(t >= 0){
	double b = st.top();st.pop();
	double a = st.top();st.pop();
	switch(t){
	case 0: st.push(a+b);break;
	case 1: st.push(a-b);break;
	case 2: st.push(a*b);break;
	case 3: st.push(a/b);break;
	}
      } else {
	st.push(atoi(s.c_str()));
      }
    }
    printf("%.8f\n",st.top());
  }
  return 0;
}

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

const int N = 1e5+1 , M = 5e3+5;

int n , mod = 1e9+7 , sol;
vector<int> adj[N];
long long dp[N][3];

long long solve(int x , int col , int p)
{
    if(dp[x][col]!=-1)
        return dp[x][col];
    long long ret = 1;
    for(auto u : adj[x])
    {
        if(u==p)
            continue;
        long long ge = ( solve(u , 0 , x)%mod + (1-col)*solve(u , 1 , x)%mod )%mod ;
        ret = ( (ret%mod) * (ge%mod) )%mod;
    }
    return dp[x][col]=ret;
}

int main()
{
    memset(dp , -1 ,sizeof dp);
    cin>>n;
    for(int i = 0;i<n-1;i++)
    {
        int t1 , t2;
        cin>>t1>>t2;
        adj[t1].push_back(t2);
        adj[t2].push_back(t1);
    }
    sol = solve(1 , 0 ,1) + solve(1 , 1 ,1);
    cout<<sol%mod;
    return 0;
}


Measured memory_bytes: 16384
def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())
    s = 0
    l = {i:0 for i in range(1,100001)}

    A.sort()
    for num in A:
        l[num] += 1
        s += num



    for _ in range(Q):
        B, C = map(int, input().split())
        num_of_before = l[B]
        l[C] += num_of_before
        s = s + num_of_before * (C-B)
        print(s)
        l[B] = 0


if __name__ == '__main__':
    main()



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

int main(){
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  int A12 = (A1-A2<0 ? -(A1-A2) : A1-A2);
  int A23 = (A2-A3<0 ? -(A2-A3) : A2-A3);
  int A31 = (A3-A1<0 ? -(A3-A1) : A3-A1);
  int min = 300;
  int costs[3] = {A12, A23, A31};
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      if(i!=j) {
        min = (costs[i]+costs[j] < min ? costs[i]+costs[j] : min);
      }
    }
  }
  
  cout << min << endl;
  
  return 0;
}

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

int main()
{
  int N, i, j;
  cin >> N;
  pair<int, int> p[N];
  for (i = 0; i < N; i++) {
    cin >> j;
    p[i].first = - 1 * j;
    p[i].second = i + 1;
  }
  sort(p, p + N);
  for (i = 0; i < N; i++) {
    if (p[0].second == i + 1)
      cout << p[1].first * (- 1) << endl;
    else
      cout << p[0].first * (- 1) << endl;
  }
  return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#define element 10

using namespace std;

int height[element];
int number;
int main()
{
 for(int i=0;i<element;++i)
 {
  cin >> height[i];
 }
 for(int i=0;i<element;++i)
 {
  for(int j=i;j<element;++j)
  {
   if(height[i]<height[j])
   {
    number = height[i];
    height[i] = height[j];
    height[j] = number;
   }
  }
 }
 printf("%d\n%d\n%d\n",height[0],height[1],height[2]);
 return 0;
}

Measured memory_bytes: 0
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int64_t A[210000];
int64_t S[210000];
int32_t leftsp[210000];
int32_t rightsp[210000];

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> N;
    for (int32_t i = 0; i < N; i++)
    {
        in >> A[i];
    }
    for (int32_t i = 1; i <= N; i++)
    {
        S[i] += S[i-1] + A[i-1];
    }
    leftsp[2] = 1;
    for (int32_t i = 3; i <= N; i++)
    {
        leftsp[i] = leftsp[i-1];
        auto nowdiff = std::abs(S[leftsp[i]] - (S[i] - S[leftsp[i]]));
        auto nextdiff = std::abs(S[leftsp[i]+1] - (S[i] - S[leftsp[i]+1]));
        while (nextdiff < nowdiff && leftsp[i]+1 < i) {
            nowdiff = nextdiff;
            ++leftsp[i];
            nextdiff = std::abs(S[leftsp[i] + 1] - (S[i] - S[leftsp[i] + 1]));
        }
    }

    rightsp[N-2] = N-1;
    for (int32_t i = N-3; i >= 0; --i)
    {
        rightsp[i] = rightsp[i + 1];
        auto nowdiff = std::abs((S[rightsp[i]] - S[i]) - (S[N] - S[rightsp[i]]));
        auto nextdiff = std::abs((S[rightsp[i]-1] - S[i]) - (S[N] - S[rightsp[i] - 1]));
        while (nextdiff < nowdiff && rightsp[i] - 1 > i) {
            nowdiff = nextdiff;
            --rightsp[i];
            nextdiff = std::abs((S[rightsp[i] - 1] - S[i]) - (S[N] - S[rightsp[i] - 1]));
        }
    }

    int64_t res = 1000000000200000;
    for (int32_t i = 2; i <= N-2; i++)
    {
        int64_t arr[4] = {
            S[leftsp[i]],(S[i] - S[leftsp[i]]),
            (S[rightsp[i]] - S[i]), (S[N] - S[rightsp[i]])
        };
        auto minmax = std::minmax_element(arr, arr + 4);
        auto tmp = (*minmax.second) - (*minmax.first);
        res = std::min(res, tmp);
    }
    out << res << endl;


    return 0;
}
#endif


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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    int N;
    vector<int> A;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        int temp;
        cin >> temp;
        if (temp % 2 == 0)
        {
            if (temp % 3 == 0 || temp % 5 == 0)
            {
            }
            else
            {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}



Measured memory_bytes: 764
n=int(input())
a=list(map(int,input().split()))
half=sum(a)/2
count=0
mid=0
tag=0
for i in range(len(a)):
  count+=a[i]
  if count>=half:
    mid=a[i]
    tag=i
    break
right=sum(a[:(tag+1)])-half
left=mid-right
alpha=min(right,left)
if alpha==0:
  print(0)
else:
  print(int(alpha*2))



Measured memory_bytes: 88016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n) { int a; cin >> a; mp[a]++; }
    ll ans = 0;
    for (auto e : mp) {
        ans += (e.F > e.S ? e.S : e.S - e.F);
    }
    out(ans);
}



Measured memory_bytes: 4736
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

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

using namespace std;
using namespace __gnu_pbds;

#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

int main()
{
	FAST_IO;

    string a, b = "";
    cin >> a;
    b += a[0] + 1;
    cout << b << endl;
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

using edge=struct {int to,cap,cost,rev;};
using G=vector<vector<edge>>;
const int inf=1<<29;

void add_edge(G &graph,int a,int b,int c,int d){
	graph[a].push_back({b,c,d,int(graph[b].size())});
	graph[b].push_back({a,0,-d,int(graph[a].size()-1)});
}

int min_cost_flow(G &graph,int s,int t,int f){
	int res=0;
	while(f){
		int n=graph.size(),update;
		vector<int> dist(n,inf),pv(n,0),pe(n,0);
		dist[s]=0;

		rep(loop,n){
			update=false;
			rep(v,n)rep(i,graph[v].size()){
				edge &e=graph[v][i];
				if(e.cap>0 && chmin(dist[e.to],dist[v]+e.cost)){
					pv[e.to]=v,pe[e.to]=i;
					update=true;
				}
			}
			if(!update) break;
		}

		if(dist[t]==inf) return -1;

		int d=f;
		for(int v=t;v!=s;v=pv[v]) chmin(d,graph[pv[v]][pe[v]].cap);
		f-=d,res+=d*dist[t];

		for(int v=t;v!=s;v=pv[v]){
			edge &e=graph[pv[v]][pe[v]];
			e.cap-=d;
			graph[v][e.rev].cap+=d;
		}
	}
	return res;
}

int main(void){
	int n,m,f;
	cin >> n >> m >> f;
	G graph(n);
	rep(i,m){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		add_edge(graph,a,b,c,d);
	}
	cout << min_cost_flow(graph,0,n-1,f) << endl;
	return 0;
}

Measured memory_bytes: 3244
n, k, q = map(int,input().split())
a = list()
for i in range(q):
    a.append(int(input()))
p_list = [k-q] * n

for i in range(q):
    p_list[a[i]-1] += 1

ans = list()
for i in range(len(p_list)):
    if p_list[i] > 0:
         ans.append("Yes")
    else:
        ans.append("No")

for p in ans:
    print(p)


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

int main() {
  int n, t, a;
  std::cin >> n;
  std::cin >> t >> a;
  double dif = 1e10, index;

  for (int i = 0; i < n; i++) {
    int h;
    std::cin >> h;
    const auto t_i = t - static_cast<double>(h) * 0.006;
    if (std::abs(a - t_i) < dif) {
      dif = std::abs(a - t_i);
      index = i + 1;
    }
  }

  std::cout << index << std::endl;
  return 0;
}


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

int main(int argc, char *argv[], char *envp[]){
	int A, B;
	cin >> A >> B;
	if(A - 2*B < 0){
		cout << 0 << endl;
	}else{
		cout << A - 2 * B << endl;
	}
	return 0;
}

Measured memory_bytes: 256
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
	let s = read_line();
	let start = s.find("A").unwrap() + 1;
	let end = s.rfind("Z").unwrap() + 2;
	let s = s.split("").collect::<Vec<&str>>();
	println!("{:?}",&s[start..end].len());

	}


Measured memory_bytes: 9292
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 10000000
int n,m;
int r[100005] = {0};
int dp[1 <<22] = {0};
int sum[25][100005]={0};
int an[22] = {0};
int main()
{
	
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> r[i];
		r[i]--;
		an[r[i]]++;
		sum[r[i]][i] = 1;
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			sum[i][j + 1] += sum[i][j];
		}
	}
	for(int i = 0; i < (1 << 20); i++){
		dp[i] = INF;
	}
	dp[0] = 0;
	for(int i = 0; i < (1 << m); i++){
		int cnt = 0;
		for(int l = 0; l < m ; l++){
			if((i >> l) & 1) cnt+= an[l];
		}
		for(int j = 0; j < m; j++){//j番目を並べる
			if((i >> j) & 1) continue;
			int s = dp[i];
			s += (an[j] - (sum[j][cnt+an[j]] - sum[j][cnt]));	
			dp[i | (1 << j)] = min(dp[i | (1 << j)], s);
		}
	}
	cout << dp[(1 << m) - 1] << endl;
	return 0;
}


Measured memory_bytes: 15368
#include <stdio.h>

int main(void){
	int i,j;
	int h,w;
	scanf("%d %d",&h,&w);

	while(h!=0 && w != 0){
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				printf("#");
			}
			printf("\n");
		}
		scanf("%d %d",&h,&w);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, m;
  cin >> n >> m;
  vll a(m), b(m);
  rep(i, m){
    cin >> a[i] >> b[i];
  }
  
  vp p(m);
  rep(i, m){
    p[i] = {b[i], a[i]};
  }
  sort(ALL(p));
  ll r = -INF;
  ll ans = 0;
  rep(i, m){
    if(r <= p[i].second){
      ans++;
      r = p[i].first;
    }
  }
  print(ans);
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<pair<int, int>> R(N);
  for (int i = 0; i < N; i++){
    int X, L;
    cin >> X >> L;
    R[i] = make_pair(X + L, X - L);
  }
  sort(R.begin(), R.end());
  int count = 1;
  int c = R[0].first;
  for (int i = 1; i < N; i++){
    if (R[i].second >= c){
      count++;
      c = R[i].first;
    }
  }
  cout << count << endl;
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define PB push_back
#define F first
#define S second

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

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

	int n, k; cin >> n >> k;
	vi v(n); FOR(i, n) cin >> v[i];

	if(k >= n){
		FOR(i, n) cout << n << " \n"[i==n-1];
	}else{
		vi ans(v);
		vi add(n+7, 0);
		int cnt = 0;
		for(int j = 0; j < k; j++){
			FOR(i, n){
				int l = max(i-ans[i], 0);
				int r = min(i+ans[i]+1, n);
				add[l] += 1;
				add[r] += -1;
			}
			FOR(i, n){
				if(i)
					add[i] += add[i-1];
				ans[i] = add[i];
			}
			cnt = 0;
			FOR(i, n){
				cnt += (ans[i] == n);
				add[i] = 0;
			}
			if(cnt == n){
				break;
			}
		}
		FOR(i, n) cout << ans[i] << " \n"[i==n-1];
	}
	
	return 0;
}


Measured memory_bytes: 5576
//#pragma GCC optimize(\"Ofast,no-stack-protector\")
//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx\")
//#pragma GCC target(\"avx,tune=native\")
// Neil

#include<bits/stdc++.h>

using namespace std;

typedef complex<double> base;
typedef long double ld;
typedef long long ll;

#define endl "\n"
#define pb push_back
#define pii pair<int,int>
#define pll pair< ll , ll >
#define vi vector<int>
#define vvi vector< vi >
const int MAXN=(int)(2e5+5);
const ll MOD=(ll)(1e9+7);
int t;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    string str;
    cin>>str;
    bool hasb = 1;
    while(hasb){
        hasb = 0;
        int  i = 0;
        while(str[i]=='B')  
            i++;
        str = str.substr(i);
        for(;i<str.size();i++){
            if(str[i]=='B'){
                hasb = true;
                str = str.substr(0, i-1) + str.substr(i+1);
                break;
            }
        }
        //cout<<str<<endl;
    }
    cout<<str<<endl;
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[110];
int main(){
	int a;scanf("%d%s",&a,in);
	int ret=0;
	for(int i=0;i<a;i++){
		if(in[i]=='A'&&in[i+1]=='B'&&in[i+2]=='C'){
			ret++;
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstring>
#include<vector>
#include<map>
using namespace std ;
typedef long long ll;
int main()
{
    ll x,sum=0,p;
    cin >> x ;
    sum=(ll)x/500;
    p= x - (ll)sum*500 ;
    sum=(ll)sum*1000;
    x=(ll)p/5;
    sum+=(x*5);
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 256
n, a, b, c, d = map(int, input().split())
s = input()
flag1, flag2 = False, False
if d > c:
    flag = "##" not in s[b: d] and "##" not in s[a: c]
else:
    flag = "..." in s[b - 2: d + 1]

print("Yes" if flag else "No")

Measured memory_bytes: 3572
inf=10**9+7
n,k=map(int,input().split())
h=list(map(int,input().split()))

dp=[inf]*n
dp[0]=0
for i in range(n):
  for j in range(i+1,i+k+1):
    if j<n:
      dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))
      
print(dp[-1])

Measured memory_bytes: 84764
// practice with Dukkha
#include <algorithm>
#include <iostream>
#include <cstdlib>

using namespace std;

const int N = 1000, N_ = N * N;

int oo[N_], *oj[N_];

void init(int n) {
	for (int i = 0; i < n; i++)
		oj[i] = (int *) malloc(2 * sizeof *oj[i]);
}

void link(int i, int j) {
	int o = oo[i];
	if (o >= 2 && (o & o - 1) == 0)
		oj[i] = (int *) realloc(oj[i], (o << 1) * sizeof *oj[i]);
	oj[i][oo[i]++] = j;
}

int qu[N_], cnt;
char used[N_];
int dp[N_];

bool dfs(int i) {
	if (used[i])
		return used[i] == 1;
	used[i] = 1;
	for (int o = 0; o < oo[i]; o++) {
		int j = oj[i][o];
		if (dfs(j))
			return true;
	}
	used[i] = 2;
	qu[--cnt] = i;
	return false;
}

int main() {
	int n; cin >> n;
	int n_ = n * n;
	init(n_);
	for (int i = 0; i < n; i++)
		for (int u = -1, h = 0; h < n - 1; h++) {
			int j; cin >> j, j--;
			int v = i < j ? i * n + j : j * n + i;
			if (h)
				link(u, v);
			u = v;
		}
	cnt = n_;
	for (int u = 0; u < n_; u++)
		if (dfs(u)) {
			cout << "-1\n";
			return 0;
		}
	int ans = 0;
	for (int h = 0; h < n_; h++) {
		int i = qu[h];
		int x = dp[i] + 1;
		ans = max(ans, x);
		for (int o = 0; o < oo[i]; o++) {
			int j = oj[i][o];
			dp[j] = max(dp[j], x);
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 55304
#include<stdio.h>

#define INF 1000000001
#define MAX 100000

typedef struct{
  char suit;
  int num;
}Card;

int count;

void quickSort(Card *,int,int);
int Partition(Card *,int,int);
void merge(Card *,int,int,int);
void mergeSort(Card *,int,int);

int main(){
  int i,n,flag=0;
  Card A[MAX],B[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c %d",&A[i].suit,&A[i].num);
    B[i].suit=A[i].suit;
    B[i].num=A[i].num;
  }
  
  quickSort(A,0,n-1);
  mergeSort(B,0,n);

  for(i=0;i<n;i++){
    if(A[i].num==B[i].num && A[i].suit==B[i].suit);
    else{
      flag=1;
      break;
    }
  }

  if(flag==1) printf("Not stable\n");
  else printf("Stable\n");

  for(i=0;i<n;i++) printf("%c %d\n",A[i].suit,A[i].num);
  
  
  return 0;
  
}

void quickSort(Card *A,int p,int r){
  int q;

  if(p<r){
    q=Partition(A,p,r);
    quickSort(A,p,q-1);
    quickSort(A,q+1,r);
  }
}

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

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

  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;

  return i+1;
}

void merge(Card *A,int left,int mid,int right){
  int i,j,k,n1,n2;
  Card L[250001],R[250001];
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];

  L[n1].num=INF;
  R[n2].num=INF;
  
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i].num<=R[j].num){
      A[k]=L[i];
      i++;
      count++;
    }
    else{
      A[k]=R[j];
      j++;
      count++;
    }
  }
}

void mergeSort(Card *A,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}



Measured memory_bytes: 4040
S = input()
valid_chars = set(["A", "G", "C", "T"])

max_len = 0
for start in range(len(S)):
    for end in range(start + 1, len(S) + 1):
        if all(char in valid_chars for char in S[start:end]):
            max_len = max(max_len, end - start)
print(max_len)


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

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

    int N = S.size();
    bool data[N];

    REP(i, N) data[i] = S[i] == 'W';

    ll ans = 0;
    ll l = 0;

    REP(i, N) if (data[i]) { ans += i-l; ++l; }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 772
import java.util.Scanner;

public class Main {
		public static void main(String[] args) {
			String strV, strC;
			int N, result = 0;
			int[] V = new int[20];
			int[] C = new int[20];

			Scanner scN = new Scanner(System.in);
			N = Integer.parseInt(scN.nextLine());
			strV = scN.nextLine();
			strC = scN.nextLine();

			for (int i = 0; i < N; i++) {
				V[i] = Integer.parseInt(strV.split(" ")[i]);
				C[i] = Integer.parseInt(strC.split(" ")[i]);
			}

			for (int i = 0; i < N; i++) {
				if (V[i] - C[i] > 0) {
					result += V[i] - C[i];
				}
			}

			System.out.print(result);

			scN.close();
		}
}


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

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

const ll mod = 1000000007;

int main() {
    int n,m;
    cin >> n >> m;
    ll s[n];
    rep(i,n) cin >> s[i];
    ll t[m];
    rep(j,m) cin >> t[j];

    ll dp[n+1][m+1];
    ll cum[n+1][m+1];
    rep(i,n+1) rep(j,m+1) dp[i][j] = 0, cum[i][j] = 0;

    rep(i,n) {
        rep(j,m) {
            if (s[i] == t[j]) {
                // siとtj(si=tj)を末尾に追加してできる部分列=dp[i+1][j+1](0のところが多い)
                // dp[0][0]~dp[i][j]までの全ての部分列の後に付けられるのでその個数が必要(cum[i][j])
                dp[i+1][j+1] = (cum[i][j]+1)%mod;
            }
            // cum[i+1][j+1]の計算
            cum[i+1][j+1] = (mod+cum[i+1][j]+cum[i][j+1]-cum[i][j]+dp[i+1][j+1])%mod;
        }
    }
    cout << (cum[n][m]+1)%mod << endl;
    return 0;
}


Measured memory_bytes: 66180
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MOD 1000000007
 
using namespace std;
 
int f[2005],sum[2005];
 
int main() {
  int n,m,k;
  scanf("%d%d%d",&n,&m,&k);
  m--;k--;
  f[0]=1;
  for(int i=0;i<=n;i++) sum[i]=1;
  int ans=0;
  for(int i=1;i<=(n+m)/k;i++) {
    for(int j=n;j>0;j--) {
        f[j]=sum[j];
        if (j>k) f[j]=(f[j]-sum[j-k-1]+MOD)%MOD;
        int s=k*i-j;
        if (s<=m&&j%k==n%k&&s%k==m%k) {
            ans=(ans+sum[j-1])%MOD;
            if (j>k) ans=(ans-sum[j-k-1]+MOD)%MOD;
        }
    }
    for(int j=1;j<=n;j++) sum[j]=(sum[j-1]+f[j])%MOD;
  }
  printf("%d\n",ans);
  return 0;
}

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

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

int gcdOf3(int a, int b, int c){
    int result = gcd(a, b);
    return gcd(result, c);
}

int main() {
    int K;
    cin>>K;
    long gcd_sum = 0;
    for(int i=0; i<K; i++)
        for(int j=0; j<K; j++)
            for(int k=0; k<K; k++){
                gcd_sum += gcdOf3(i+1,j+1,k+1);
            }
    cout<<gcd_sum<<endl;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f

using namespace std;

struct Edge {
  int t,f,next;
  Edge() {}
  Edge(int a,int b,int c):t(a),f(b),next(c) {}
};

Edge e[1000000];
int head[200005],vs,vt,tot=-1;

inline void addEdge(int x,int y,int z) {
  e[++tot]=Edge(y,z,head[x]);
  head[x]=tot;
  e[++tot]=Edge(x,0,head[y]);
  head[y]=tot;
}

namespace Flow {
	
int d[200005],cur[200005];
queue <int> q;

bool bfs() {
  while (!q.empty()) q.pop();
  memset(d,255,sizeof(d));
  d[vs]=0;cur[vs]=head[vs];
  q.push(vs);
  while (!q.empty()) {
  	int x=q.front();q.pop();
  	for(int i=head[x];i!=-1;i=e[i].next)
  	  if (e[i].f&&d[e[i].t]==-1) {
  	  	  int u=e[i].t;
  	  	  d[u]=d[x]+1;
  	  	  cur[u]=head[u];
  	  	  if (u==vt) return 1;
  	  	  q.push(u);
		}
  }
  return 0;
}

int dfs(int x,int a) {
  if (x==vt||!a) return a;
  int ans=0;
  for(int &i=cur[x];i!=-1;i=e[i].next)
    if (e[i].f&&d[e[i].t]==d[x]+1) {
    	int u=e[i].t;
    	int f=dfs(u,min(a,e[i].f));
    	if (f) {
    		e[i].f-=f;
    		e[i^1].f+=f;
    		ans+=f;
    		a-=f;
    		if (!a) break;
		}
	}
  return ans;
} 

int maxflow() {
  int ans=0;
  while (bfs())
    ans+=dfs(vs,inf);
  return ans;
}
	
}

vector <int> bel[100005];
bool vis1[100005],vis2[100005];
int id[100005],nxt[100005];

queue <int> q;

bool solve(int n) {
  for(int i=1;i<n;i++)
    for(int j=head[n+i];j!=-1;j=e[j].next)
      if (e[j].t&&!e[j].f) {
      	int u=e[j].t;
      	id[i]=u;
      	vis1[u]=1;
	  }
  for(int i=1;i<=n;i++)
    if (!vis1[i]) q.push(i);
  int cnt=0;
  while (!q.empty()) {
  	int x=q.front();q.pop();
  	cnt++;
  	for(int i=0;i<bel[x].size();i++)
  	  if (!vis2[bel[x][i]]) {
  	  	  int u=bel[x][i];
  	  	  vis2[u]=1;
  	  	  nxt[u]=x;
  	  	  q.push(id[u]);
		}
  }
  return cnt==n;
}

int main() {
  memset(head,255,sizeof(head));
  int n;
  scanf("%d",&n);
  vs=0;vt=2*n;
  for(int i=1;i<n;i++) {
  	int x;
  	scanf("%d",&x);
  	addEdge(vs,n+i,1);
  	for(int j=1;j<=x;j++) {
  		int y;
  		scanf("%d",&y);
  		addEdge(n+i,y,1);
  		bel[y].push_back(i);
	  }
  }
  for(int i=1;i<=n;i++) addEdge(i,vt,1);
  if (Flow::maxflow()<n-1) {
  	puts("-1");
  	return 0;
  }
  if (!solve(n)) {
  	puts("-1");
  	return 0;
  }
  for(int i=1;i<n;i++) printf("%d %d\n",id[i],nxt[i]);
  return 0;
}

Measured memory_bytes: 21760
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
 
    const lines = input.split('\n')
    const [N, K] = lines[0].split(' ').map(BigInt)
    const A = [null, ...lines[1].split(' ').map(Number)]

    const r = []
    let c = 0n
    let n = 1

    while (c < K) {
        n = A[n]
        c++
        if (r[n]) {
            break
        } else {
            r[n] = c
        }
    }

    if (r[n] === c) {
        console.log(n)
        return
    }

    const t = (K - (c - 1n)) % (c - r[n]) || c - r[n]

    c = 1n
    while (c < t) {
        n = A[n]
        c++
    }

    console.log(n)
 
})(input)


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

using namespace std;

int main(){
  int64_t N,K;
  cin >> N >> K;
  int64_t n = N%K;
  if(n>abs(n-K)) n = abs(n-K);
  cout << n << endl;
  return 0;
}


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


using namespace std;


const int MAX = 1e5+5;


int main() {
    
    vector<bool> is_prime(MAX, true);
    is_prime[0] = false;
    is_prime[1] = false;

    for (int i=2; i<=MAX; i++) {
        if (!is_prime[i]) continue;

        for (int j=2; i*j<=MAX; j++) {
            is_prime[i*j] = false;
        }
    }

    int x; cin >> x;
    for (int i=x; i<=MAX; i++) {
        if (is_prime[i]) {
            cout << i << endl;
            break;
        }
    }

    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 N = sc.nextInt();
		int M = sc.nextInt();
		
		long[][] map = new long[N][2];
		for (int i = 0; i < N; i++) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			map[i][0] = a;
			map[i][1] = b;
		}
		
		long[][] points = new long[M][2];
		for (int i = 0; i < M; i++) {
			long c = sc.nextLong();
			long d = sc.nextLong();
			points[i][0] = c;
			points[i][1] = d;
		}
		
		for (int i = 0; i < N; i++) {
			long a = map[i][0];
			long b = map[i][1];
			int point = -1;
			long min = Long.MAX_VALUE;
			for (int j = 0; j < M; j++) {
				long c = points[j][0];
				long d = points[j][1];
				long km = Math.abs(a-c) + Math.abs(b-d);
				if (min > km) {
					point = j+1;
					min = km;
				}
			}
			
			System.out.println(point);
		}
	}
	
}


Measured memory_bytes: 21844
// AOJ 585 Nearest Two Points
// 2017.9.24 bal4u
// 2018.3.17

#include <stdio.h>

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define INF     1e6
#define EPS     1e-5
#define RANGE	110
#define SIN     0.70710678118654752440084436210485    // Sin(45)
#define COS     0.70710678118654752440084436210485    // Cos(45)
#define SINCOS  SIN

typedef struct { double x, y; } T;
T tbl[500000+RANGE];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	if (c == '-') {	c = getchar_unlocked();
		do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int cmp(T *a, T *b)
{
	if (fabs(a->x - b->x) < EPS) {
		if (fabs(a->y - b->y) < EPS) return 0;
		if (a->y < b->y) return -1; return 1;
	}
	if (a->x < b->x) return -1;	return 1;
}

int main()
{
	int N, i, j, lim;
	int x, y;
	double dx, dy, t, ans;

	N = in();
	for (i = 0; i < N; i++) {
		x = in(), y = in();
		tbl[i].x = (x - y) * SINCOS;
		tbl[i].y = (x + y) * SINCOS;
	}
	qsort(tbl, N, sizeof(T), cmp);

	ans = INF;
	for (i = N; i < N+RANGE; i++) tbl[i].x = INF, tbl[i].y = 0;
		for (i = 0; i < N; i++) {
			lim = i+RANGE; for (j = i+1; j < lim; j++) {
			dx = tbl[i].x-tbl[j].x, dy = tbl[i].y-tbl[j].y;
			t = dx*dx + dy*dy;
			if (t < ans) ans = t;
		}
	}
	printf("%.0lf\n", ans);
	return 0;
}


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

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

    int x, y, z;
    x = y = z = -1;
    int res;
    bool exists = false;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n - i; j++) {
            int k = n - i - j;
            res = 10000 * i + 5000 * j + 1000 * k;
            if (res == sum) {
                x = i;
                y = j;
                z = k;
                break;
            }
        }
    }

    cout << x << ' ' << y << ' ' << z << endl;

    return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#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 <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = 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;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<string> S(N);
    for(int i=0; i<N; i++) cin >> S[i];

    string pat = "MARCH";
    vector<int> cnt(5);
    for(int i=0; i<N; i++) {
        int x = pat.find(S[i][0]);
        if(x == string::npos) continue;
        cnt[x]++;
    }

    ll ans = 0;
    for(int bit=0; bit<(1<<5); bit++) {
        if(__builtin_popcount(bit) != 3) continue;
        ll mul = 1;
        for(int i=0; i<5; i++) if(bit >> i & 1) mul *= cnt[i];
        ans += mul;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
    string S, respuesta;
    long long n, i;
    cin >> S;
    n=S.size();
    if(n%2==0)
    {
        for(i=0; i<n/2; i++) respuesta=respuesta+S[2*i];
    }
    else
    {
        for(i=0; i<n/2+1; i++) respuesta=respuesta+S[2*i];
    }
    cout << respuesta << endl;
    return 0;
}

Measured memory_bytes: 640
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    let M = buf_it.next().unwrap().parse::<usize>().unwrap();
    let S = (0..N).map(|_| buf_it.next().unwrap().parse::<isize>().unwrap()).collect::<Vec<_>>();
    let T = (0..M).map(|_| buf_it.next().unwrap().parse::<isize>().unwrap()).collect::<Vec<_>>();

    let MOD = 1_000_000_007;
    let mut dp = (0..N+1).map(|_| (0..M+1).map(|_| ModInt::new(1,MOD)).collect::<Vec<_>>()).collect::<Vec<_>>();
    for i in 1..N+1{
        let mut m = 0;
        for j in 1..M+1{
            dp[i][j] = dp[i-1][j] + m;
            if S[i-1]==T[j-1]{
                dp[i][j] = dp[i][j] + dp[i-1][j-1];
                m = dp[i][j-1].n;
            }
        }
    }

    println!("{}",dp[N][M].n);
}

use std::ops::{Add, Sub, Mul, Div};

#[derive(Copy, Clone)]
struct ModInt{
    n: isize,
    m: isize
}

impl ModInt {
    fn new(n:isize,m:isize) -> ModInt{
        ModInt {n:(n%m+m)%m, m:m}
    }
    fn pow_mod(a:isize,b:isize,m:isize) -> isize{
        if b==0{ return 1;}
        if b%2==1{ return a*ModInt::pow_mod(a,b-1,m)%m}
        ModInt::pow_mod(a*a%m,b/2,m)
    }
    fn inv(self) -> ModInt{
        let n = ModInt::pow_mod(self.n,self.m-2,self.m);
        ModInt::new(n,self.m)
    }
}
impl Add for ModInt{
    type Output = ModInt;
    fn add(self, other:ModInt) -> ModInt
    {
        ModInt::new(self.n+ other.n,self.m)
    }
}
impl Add<isize> for ModInt{
    type Output = ModInt;
    fn add(self, other:isize) -> ModInt
    {
        ModInt::new(self.n+ other,self.m)
    }
}
impl Sub for ModInt{
    type Output = ModInt;
    fn sub(self, other:ModInt) -> ModInt
    {
        ModInt::new(self.n-other.n,self.m)
    }
}
impl Sub<isize> for ModInt{
    type Output = ModInt;
    fn sub(self, other:isize) -> ModInt
    {
        ModInt::new(self.n-other,self.m)
    }
}
impl Mul for ModInt{
    type Output = ModInt;
    fn mul(self, other:ModInt) -> ModInt
    {
        ModInt::new(self.n*other.n,self.m)
    }
}
impl Mul<isize> for ModInt{
    type Output = ModInt;
    fn mul(self, other:isize) -> ModInt
    {
        ModInt::new(self.n*other,self.m)
    }
}
impl Div for ModInt{
    type Output = ModInt;
    fn div(self, other:ModInt) -> ModInt
    {
        other.inv() * self
    }
}
impl Div<isize> for ModInt{
    type Output = ModInt;
    fn div(self, other:isize) -> ModInt
    {
        ModInt::new(other,self.m).inv() * self
    }
}

Measured memory_bytes: 78076
put = list(map(int,input().split()))
xdiff = put[2] - put[0]
ydiff = put[3] - put[1]
zero = put[2:4]
ans = []
for _ in range(2):
  xdiff,ydiff = -ydiff,xdiff
  zero[0] += xdiff
  zero[1] += ydiff
  ans += zero
print(' '.join(list(map(str,ans))))

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#define MAX 1000
char s1[MAX],s2[MAX];

int Size(char *x){
  int i=0;
  while(x[i]!='\0'){
    i++;
  }
  // printf("%d\n",i);
  return i;
}

void push1(int m){
  char p[MAX+1];
  int i;
  for(i=0;i<m;i++)p[i]=s1[i];
   s1[0]=' ';
  for(i=1;i<m+1;i++)s1[i]=p[i-1];
}

  void push2(int m){
  char p[MAX+1];
  int i;
  for(i=0;i<m;i++)p[i]=s2[i];
   s2[0]=' ';
  for(i=1;i<m+1;i++)s2[i]=p[i-1];
}

int max(int x,int y){
  if(x>y)return x;
  else return y;
}
int lcs(void){
  int c[MAX+1][MAX+1];
  int m,n,i,j,maxl=0;
  // m=sizeof(s1)/sizeof(s1[0]);
  // n=sizeof(s2)/sizeof(s2[0]);

  m=Size(s1);
  n=Size(s2);
  
  push1(m);
  push2(n);

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(s1[i]==s2[j]){
	c[i][j]=c[i-1][j-1]+1;
      }else {
	c[i][j]=max(c[i-1][j],c[i][j-1]);
      }
      maxl=max(maxl,c[i][j]);
    }
  }
  return maxl;
}


int main(){
 
  int n,i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",s1);
    scanf("%s",s2);
    printf("%d\n",lcs());
  }

  return 0;
  
}

Measured memory_bytes: 4508
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;    
    cin>>a>>b;
    if(a<b){
            cout<<"a < b"<<endl;
           }
    else if(a>b){
            cout<<"a > b"<<endl;
           }
    else {
          cout<<"a == b"<<endl;
         }
    }


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define PB push_back
#define F first
#define S second

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

vi graph[100007];
map<pii, int> m;

void dfs(int i, int p=-1, int c = -1){
	int k = 1;
	if(k == c) k++;
	for(auto& v : graph[i]){
		if(v != p){
			if(i < v)
				m[{i, v}] = k;
			else
				m[{v, i}] = k;
			dfs(v, i, k);
			k++;
			if(k == c) k++;
		}
	}
}

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

	int n; cin >> n;
	vector<pii> v(n-1);

	FOR(i, n-1){
		int a, b; cin >> a >> b;
		a--; b--;
		graph[a].PB(b);
		graph[b].PB(a);
		if(a > b) swap(a, b);
		v[i] = {a, b};
	}

	int ans = 0;
	FOR(i, n) ans = max(ans, (int) graph[i].size());
	cout << ans << '\n';

	dfs(0);
	FOR(i, n-1){
		cout << m[v[i]] << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 14976
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int64 N;
  int64 W;
  cin >> N >> W;
  int64 inf = (int64)1e18 + 10;
  vector<int64> w(N), v(N);
  for (int64 i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }
  debug(w);
  debug(v);
  vector<vector<int64>> dp(N + 1, vector<int64>(304771, inf));
  dp[0][0] = 0;
  for (int64 i = 0; i < N; i++) {
    for (int64 j = 0; j < 304711; j++) {  // sum of the value
      dp[i + 1][j] = dp[i][j];
      if (j >= v[i]) dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
    }
  }
  int64 ans = 0;
  for (int64 i = 0; i < 304711; i++) {
    if (dp[N][i] <= W) {
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    string s; cin >> s;
    string t;
    
    cout << (s[0]);
    cout << to_string(s.size()-2);
    cout << (s[s.size()-1]) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int x=sc.nextInt();
    int t=sc.nextInt();
    int div=(int)Math.ceil((double)n/(double)x);
    System.out.println(div*t);
  }
}

Measured memory_bytes: 35684
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef vector<lint> LIV;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976

int main(){
	string s;cin>>s;
	lint n=s.size(),c=0,ans=0;
	rep(i,n){
		if(s[i]=='T')--c;
		else ++c;
		if(c<0)++ans,++c;
	}cout<<ans*2<<endl;
}

//int main(){//平方数を1<k<=nで割ったあまりを求める
//	lint n;cin>>n;
//	LIV ans(n);
//	for(int i=1;i<=n;++i){
//		set<int> s;
//		rep(x,i)s.insert(x*x%i);
//		cout<<i<<": ";
//		for(auto x:s)cout<<x<<",";cout<<endl;
//		ans[i-1]=s.size();
//	}rep(i,n)cout<<ans[i]<<endl;
//	getchar();
//	getchar();
//}

//sub-EOF


Measured memory_bytes: 640