akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

int n;
string s;
int x=0;
int a[12];
void dfs( char c, int depth){
    if(depth==n) {
        cout<<s<<endl;
        return;
    }
    char tmp;
    chmax(a[depth],(ll)(c-'a'+1LL));
    a[depth]=max(a[depth-1],(ll) c-'a'+1);
    for (int i = 0; i <= a[depth]; i++)
    {
        tmp=s[depth];
        s[depth]=(char)('a'+i);
        dfs(s[depth],depth+1);
        s[depth]=tmp;
    }
    
}

signed main()
{
  
    cin>>n;
    if(n==1){
        cout<<'a'<<endl;
        return 0;
    }
    string u;
    for (int i = 0; i < n; i++)
    {
        s.push_back('a');
        u.push_back('a');
    }
    cout<<s<<endl;
    for (int i = 0; i < n-1; i++)
    {
      s[n-1-i]= 'b';
      x=0;
      dfs('b',n-i);
      s=u.substr(0,n);
      //cerr<<i<<endl;
    }
    
    
    

    
    return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    for(int i = 1; i <= 1010; i++){
        if(floor(i * 0.08) == A && floor(i * 0.1) == B){
            cout << i;
            return 0;
        }
    }
    cout << "-1";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
int main(){
    int num[3];
    for(int i = 0; i < 3; ++i){
        std::cin >> num[i];
    }
    std::sort(num, num + 3);
    std::cout << num[0] << " " << num[1] << " " << num[2] << std::endl;
    return 0;
}

Measured memory_bytes: 3136
# ABC143 C
N = int(input())
S = input()
L = [s for s in S]

M = []
cnt = 0
ans_c = 0

if N == 1:
    print(1)
    exit()

for i in range(N-1):
    if L[i]==L[i+1]:
        cnt += 1
    else:
        ans_c += cnt
        cnt = 0
    if i == N-2:
        ans_c += cnt
print(N-ans_c)

Measured memory_bytes: 4212
#include <cstdio>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <iostream>
#define N 500

using namespace std;

int c[N], s[N], f[N];
int n;

int solve(int c[N], int s[N], int f[N], int i) {
	if (i == n-1) {
		return 0;
	}
	int ans = s[i] + c[i];
	int itv;
	for (i++;i<n-1;i++) {
		//itv = (ans > s[i]) ? (ans - s[i]) / f[i] : 0;
		//ans = s[i] + f[i] * itv + c[i];
		ans = (ans <= s[i]) ? s[i] + c[i] : ceil((double)ans / f[i]) * f[i] + c[i];
	}
	return ans;
}

int main(void) {
	cin >> n;
	int i;
	for (i=0;i<n-1;i++) {
		cin >> c[i];
		cin >> s[i];
		cin >> f[i];
	}
	for (i=0;i<n;i++) {
		cout << solve(c, s, f, i)  << endl;
	}
	return 0;
}


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

int main(void){
  string s;
  cin >> s;
  int t = 0;
  int ans = 0;
  for(int i = 0;i < 3;i++){
        if(s[i] == 'R'){
              t++;
        }
        else{
              ans = max(ans,t);
              t = 0;
        }
  }
  ans = max(ans,t);
  cout << ans << endl;
}


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

int n;
int a[200000];
int b[200000];

signed main() {
	int i;
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	
	if (n % 2 == 0) {
		for (i = 0; i < n / 2; i++) b[i] = n - 2 * i;
		for (i = 0; i < n / 2; i++) b[n / 2 + i] = 1 + 2 * i;
	}
	else {
		for (i = 0; i < n / 2 + 1; i++) b[i] = n - 2 * i;
		for (i = 0; i < n / 2; i++) b[n / 2 + 1 + i] = 2 + 2 * i;
	}
	
	vector<int> ans;
	for (i = 0; i < n; i++) {
		ans.push_back(a[b[i] - 1]);
	}
	
	cout << ans[0];
	for (i = 1; i < n; i++) {
		cout << " " << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 4724
#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 ll long long int
#define pb push_back
#define endl "\n"
#define F first
#define S second

#define pq priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>
#define MAX  *max_element
#define MIN  *min_element
#define des_sort(v) sort(v.begin(),v.end(),greater<int>())
 
#define c_ones(number) __builtin_popcountll(number)
#define flip_bits(number) static_cast<unsigned>(~number)
 
#define all(X) X.begin(),X.end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(itr,n) for(itr=n.begin();itr!=n.end();itr++)
 
#define FLUSH fflush(stdout)
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb_ds tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define mod 1000000007
#define INF 1e18
 
const double PI = acos(-1);
 
bool compare(pair<int,int>a , pair<int,int>b){
	return a.first==b.first ? a.second<b.second : a.first < b.first;
}
 
struct hash_pair{ 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    }
};

int main(){
	string a,b;
	cin>>a>>b;
	int n=a.length(),m=b.length();
	ll dp[n+1][m+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i==0||j==0){
				dp[i][j]=0;
			}
			else if(a[i-1]==b[j-1]){
				dp[i][j] = 1+dp[i-1][j-1];
			}
			else{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	int c = dp[n][m];
//	cout<<c<<endl;
	char ans[c];
	int i=n,j=m;
	while(i>0&&j>0){
		if(a[i-1]==b[j-1]){
			ans[c-1]=a[i-1];
			i--;j--;c--;
		}
		else if(dp[i-1][j]>dp[i][j-1])i--;
		else j--;
	}
	rep(i,dp[n][m])cout<<ans[i];
	cout<<endl;
}

Measured memory_bytes: 73940
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
#define ll long long 
#define il inline
const int maxn=1010;
int mx=0,tmp=0;
char s[maxn],t[maxn]; int n,m;
int main(){
    scanf("%s%s",(s+1),(t+1)); 
    n=strlen(s+1); m=strlen(t+1);
    for (int i=1;i<=n-m+1;++i){
        tmp=0;
        for (int j=1;j<=m;++j){
            if (s[i+j-1]==t[j]) ++tmp;
        }
        mx=max(tmp,mx);
    }
    printf("%d",m-mx);
}

Measured memory_bytes: 3824
N, K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(K):
    B = [0] * N
    for j in range(N):
        if A[j] == 0:
            continue
        if j - A[j] < 0:
            B[0] += 1
        else:
            B[j - A[j]] += 1
        B[j] -= 1
        if j + 1 <= N-1:
            B[j + 1] += 1
        if j + A[j] + 1 <= N-1:
            B[j + A[j] + 1] -= 1
    
    for j in range(N-1):
        B[j+1] += B[j]
        B[j] += 1
    B[-1] += 1
    
    A = B[:]
    
    if all([i == N for i in A]):
        break

print(*A)

Measured memory_bytes: 172604
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
typedef long long ll;
using namespace std;
ll intpow(int n,int m){
    if(m==0)return 1;
    return n*intpow(n,m-1);
}
ll gcd(ll n,ll m){
    n = max(n,m);
    m = min(n,m);
    if(n%m == 0)return m;
    return gcd(m,n%m);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}

int main(){
    int n;
    cin >> n;
    vector<int>h;
    h.resize(n);
    
    for(int i=0;i<n;i++)cin >> h[i];
    map<int,vector<int>>memo;
    for(int i=0;i<n;i++)memo[h[i]].push_back(i);
    auto itr=memo.end();
    auto itr1=memo.end();
    vector<int>l;
    l.resize(memo.size()-1);
    int h1,h2;
  itr1--;
    for(int i=0;i<memo.size()-1;i++){
        h1 = itr1->first;
        itr1--;
        h2 = itr1->first;
        l[i]=h1 - h2;
    }
  
    int sum=0;
    for(int i=0;i<memo.size()-1;i++){
        itr--;
       itr1 = itr;
      itr1--;
        int cnt=1;
      memo[itr1->first].push_back(memo[itr->first][0]);
        for(int j=0;j+1<itr->second.size();j++){
            if(memo[itr->first][j] + 1 != memo[itr->first][j+1])cnt++;
          memo[itr1->first].push_back(memo[itr->first][j+1]);
        }
      sort(memo[itr1->first].begin(),memo[itr1->first].end());
        sum += l[i]*cnt;
    }
    itr--;
    sum += itr->first;
    cout <<sum<<endl;
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String stVal = scan.nextLine();

		String[] test = stVal.split(" ");
		System.out.println(Integer.parseInt(test[0]) * Integer.parseInt(test[1]));


		scan.close();
	}

}

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

int main() {
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<int64_t> p(a);
  for(int i=0; i<a; i++){
    int x;
    cin >> x;
    p.at(i)=x;
  }
  vector<int64_t> q(b);
  for(int i=0; i<b; i++){
    int x;
    cin >> x;
    q.at(i)=x;
  }
  vector<int64_t> r(c);
  for(int i=0; i<c; i++){
    int x;
    cin >> x;
    r.at(i)=x;
  }
  sort(p.begin(),p.end());
  sort(q.begin(),q.end());
  sort(r.begin(),r.end());
  reverse(p.begin(), p.end());
  reverse(q.begin(), q.end());
  reverse(r.begin(), r.end());
  int64_t ans;
  for(int i=0; i<x; i++){
    ans += p.at(i);
  }
  for(int i=0; i<y; i++){
    ans += q.at(i);
  }
  vector<int64_t> vec;
  for(int i=0; i<x; i++){
   vec.push_back(p.at(i));
  }
  for(int i=0; i<y; i++){
   vec.push_back(q.at(i));
  }
  sort(vec.begin(),vec.end());
  for(int i=0; i<c; i++){
    if(vec.at(i)>=r.at(i)) break;
    ans += r.at(i)-vec.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4724
import numpy as np

q = int(input())
lr = []
for i in range(q):
    li, ri = map(int, input().split())
    lr.append([li, ri])

range_max = 100000
tf = np.ones(range_max, dtype=int)
tf[0] = 0

i = 1
while True:
    if i == int(range_max ** (1 / 2)) + 1:
        break
    if not tf[i]:
        i += 1
        continue

    tmp = np.arange(i, range_max, i + 1)
    tf[tmp[1:]] = 0
    i += 1

counter = 0
counter_list = [0]
for i in range(2, 100000, 2):
    if tf[i] == 1 and tf[i//2] == 1:
        counter += 1
    counter_list.append(counter)

for i in range(q):
    left = lr[i][0]//2
    right = lr[i][1]//2
    res = counter_list[right] - counter_list[left]
    if left > 0 and counter_list[left] - counter_list[left-1] == 1:
        res += 1
    print(res)


Measured memory_bytes: 30652
a = []

for _ in range(3):
    a.append(list(map(int, input().split())))

n = int(input())

b = []
for _ in range(n):
    b.append(int(input()))

patterns = (
    [[a[i][i] for i in range(3)], [a[2 - i][i] for i in range(3)]]
    + [[a[0][i], a[1][i], a[2][i]] for i in range(3)]
    + [[a[i][0], a[i][1], a[i][2]] for i in range(3)]
)

answer = "No"
for a0, a1, a2 in patterns:
    if a0 in b and a1 in b and a2 in b:
        answer = "Yes"
        break

print(answer)

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

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

typedef long long ll;

const ll INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

/*
#define MAX 10000
#define NIL -1
struct Node { int p, l, r; };
struct Node T[MAX];
*/

int main() {

    ll dp[100007];
    ll h[100007];

    int n, k;
    cin >> n >> k;

    rep(i, n) cin >> h[i];

    rep(i, 100007) dp[i] = INF;
    dp[0] = 0;

    for (int i = 0; i < n; i++){
        for (int j = 1; j <= k; j++){
            chmin(dp[i+j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    cout << dp[n - 1] << endl;

    return 0;
}


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

using namespace std;

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

ll A[100100];
ll B[100100];
ll ans[10];
int main(){
    ll H, W, N;
    cin >> H >> W >> N;
    map<pair<ll, ll>, int> ma;
    REP(i,N){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        for(ll y = a-1; y <= a+1; y++){
            for(ll x = b-1; x <= b+1; x++ ){
                if(y < 0 || y >= H) continue;
                if(x < 0 || x >= W) continue;
                ma[make_pair(y, x)]++;
            }
        }
    }

    ll num = (H-2)*(W-2);
    ll sum = 0;
    for(auto&& p : ma){
        auto pp = p.first;
        ll x = pp.second;
        ll y = pp.first;
        if(x == 0 || x == W-1) continue;
        if(y == 0 || y == H-1) continue;
        int z = p.second;
        ans[z]++;
        sum++;
    }

    cout << num-sum << endl;
    for(int i = 1; i < 10; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 56448
N = gets.chomp.to_i
D = N.times.map{gets.chomp.split.map(&:to_i)}

(0...N-2).each do |i|
  if D[i][0] == D[i][1] &&  D[i+1][0] == D[i+1][1] && D[i+2][0] == D[i+2][1]
    puts "Yes"
    exit
  end
end

puts "No"

Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl;
#define all(x) (x).begin(),(x).end()

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main()
{
    ll n,m,ansq = 0,ansp = 0;
    cin >> n >> m;
    vector<bool> f1(n + 2,false),f2(n + 2,false);
    vector<pair<ll, bool>> P(m);
    rep0(i, m){
        ll p;
        string s;
        cin >> p >> s;
        if(s == "AC"){
            P[i] = make_pair(p, true);
            f2[p] = true;
        }else{
            P[i] = make_pair(p, false);
        }
    }
    
    rep0(i, m){
        if(!f1[P[i].first]){
            if(P[i].second){
                ++ansq;
                f1[P[i].first] = true;
            }else if(f2[P[i].first]){
                ++ansp;
            }
        }
    }
    pf(ansq)
    pf(ansp)
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

int L[2020][2020], R[2020][2020], U[2020][2020], D[2020][2020];
char maze[2020][2020];
string A[2020];
int H, W;
ll ans = 0;
signed main() {
	/*cin.tie(0);
	ios::sync_with_stdio(false);*/
	cin >> H >> W;
	REP(i, H) {
		cin >> A[i];
	}
	REP(i, H) {
		L[i][0] = -1;
		FOR(j,1, W) {
			if (A[i][j - 1] == '#') {
				L[i][j] = j - 1;
			}
			else {
				L[i][j] = L[i][j - 1];
			}
		}
	}
	REP(i, H) {
		R[i][W - 1] = W;
		for (int j = W - 2; j >= 0; j--) {
			if (A[i][j + 1] == '#') {
				R[i][j] = j + 1;
			}
			else {
				R[i][j] = R[i][j + 1];
			}
		}
	}
	REP(j, W) {
		U[0][j] = -1;
		FOR(i, 1, H) {
			if (A[i - 1][j] == '#') {
				U[i][j] = i - 1;
			}
			else U[i][j] = U[i - 1][j];
		}
	}
	REP(j, W) {
		D[H - 1][j] = H;
		for (int i = H - 2; i >= 0; i--) {
			if (A[i + 1][j] == '#') {
				D[i][j] = i + 1;
			}
			else D[i][j] = D[i + 1][j];
		}
	}
	REP(i, H) {
		REP(j, W) {
			if (A[i][j] == '#')continue;
			ll res = 0;
			res += j - L[i][j];
			res += R[i][j] - j;
			res += i - U[i][j];
			res += D[i][j] - i;
			res -= 3;
			ans = max(res, ans);
			//pe(i)pe(j)print(res);
		}
		
	}
	print(ans);
}


Measured memory_bytes: 133504
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  string s; int K;
  cin >> s >> K;
  set<string> t;
  rep(start, s.size()) {
    for (int span = 1; span <= K; span++) {
      t.insert(s.substr(start, span));
    }
  }
  int count = 1;
  for (auto i = t.begin(); i != t.end(); i++, count++) {
    if (count == K) {
      cout << *i << endl;
      return 0;
    }
  }
  return 0;
}


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

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

    int sum = 0;
    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        sum += (r - l + 1);
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
bool isAL(char ch){ return ('A'<=ch&&ch<='Z'); }
bool isAl(char ch){return ('a'<=ch&&ch<='z');}
char change(char ch){
  if(isAl(ch))ch=ch-'a'+'A';
  return ch;
}

char change2(char ch){
  if(isAL(ch))ch=ch-'A'+'a';
  return ch;
}

string str,type;
vector<string> t;

int main(){
  while(1){
    cin>>str>>type;
    if(type=="X")break;
    t.clear();
    string tmp="";
    tmp.push_back(str[0]);
    str.push_back('_');
    for(int i=1;i<(int)str.size();i++){
      if(str[i]=='_'){
	t.push_back(tmp);
	tmp="";
      }else if(isAL(str[i])){
	t.push_back(tmp);
	tmp="";
	tmp.push_back(str[i]);
      }else{
	tmp.push_back(str[i]);
      }
    }
    for(int i=0;i<(int)t.size();i++){
      if(type=="L"){
	if(i)t[i][0]=change(t[i][0]);
	else t[i][0]=change2(t[i][0]);
      }else if(type=="U"){
	t[i][0]=change(t[i][0]);
      }else{
	t[i][0]=change2(t[i][0]);
      }
      
      if(i)cout<<(type=="D"?"_":"");
      cout<<t[i];
    }
    cout<<endl;
  }
  return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

typedef pair<double, int> P;

int main() {
    int N, C;
    cin >> N >> C;
    vector<vector<P>> A(C, vector<P>());
    rep(i, N) {
        int s, t, c;
        cin >> s >> t >> c;
        c--;
        A[c].push_back(make_pair(s, t));
    }

    vector<vector<P>> B(C, vector<P>());
    rep(c, C) {
        sort(A[c].begin(), A[c].end());
        rep(i, A[c].size()) {
            if (i == 0 || B[c].back().second != A[c][i].first) {
                B[c].push_back(make_pair(A[c][i].first, A[c][i].second));
            } else {
                B[c].back().second = A[c][i].second;
            }
        }
    }

    vector<P> ev;
    rep(c, C) {
        rep(i, B[c].size()) {
            ev.push_back(make_pair(B[c][i].first - 0.5, 1));
            ev.push_back(make_pair(B[c][i].second, -1));
        }
    }
    sort(ev.begin(), ev.end());

    int ans = 0;
    int tmp = 0;
    for (auto e: ev) {
        if (e.second == 1) {
            tmp++;
            chmax(ans, tmp);
        } else {
            tmp--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9840
#include <iostream>

using namespace std;

int main ()
{
  int num;
  cin >> num;
  int result = 0;
  for (int i = 1; i <= num; ++i) {
    int n;
  	cin >> n;
    if (i % 2 == 1 && n % 2 == 1) ++result;
      
  }

  cout << result;

}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		long k = sc.nextLong();
		
		
		long []num = new long [1000001];
		
		for(int i = 0; i < n ;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			num[a] += b;
		}
		
		long sum = 0;
		int ans = 0;
		
		for(int i = 1 ; i < 1000001 ; i++) {
			sum += num[i];
			if(sum >= k) {
				ans = i;
				break;
			}
		}
		
		System.out.println(ans);
		
		
	}

}


Measured memory_bytes: 98644
fun main(args: Array<String>) {

    val s = readLine()!!
    val c = (s.length) / 2

    var ans = 0
    for (i in 0 until c) {
        if (s[i] != s[s.length - 1 - i]) {
            ans++
        }
    }
    println(ans)
}

Measured memory_bytes: 33780
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
inline void IO() {
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
}

int main(int argc, char const *argv[])
{
	//IO();
	FAST_IO
	
	int n; cin >> n;
	vector<ll> a(n);
	ll sum = 0, i = 0;
	unordered_map<ll,ll> hmap;
	for(auto &x : a) {
		cin >> x; sum += x; hmap[x]++;
	}

	int q; cin >> q;
	while(q--) {
		ll x, y; cin >> x >> y;
		if(hmap.count(y) > 0) {
			sum -= hmap[x]*x;
			sum += hmap[x]*y;
			hmap[y] += hmap[x]; hmap[x] = 0;
		}
		else {
			sum -= hmap[x]*x;
			sum += hmap[x]*y;
			hmap[y] = hmap[x]; hmap[x] = 0;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 7804
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

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

  int N;

  std::vector<int> a;
  int sum[100005];
  std::fill(sum, sum + 100001, 0);

  cin >> N;
  a.resize(N + 2, 0);

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

  for (int i = 0; i < int(a.size()) - 1; ++i) {
    sum[i + 1] = sum[i] + abs(a[i] - a[i + 1]);
  }

  for (int i = 1; i <= N; ++i) {
    int ans = sum[i - 1] + abs(a[i - 1] - a[i + 1]) + sum[N + 1] - sum[i + 1];
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>

typedef struct {
  int s;
  int t;
} A;

int compar(const void* a, const void* b)
{
  if (((A*)a)->s > ((A*)b)->s) {
    return 1;
  } else if (((A*)a)->s < ((A*)b)->s) {
    return -1;
  } else {
    if (((A*)a)->t > ((A*)b)->t) {
      return 1;
    } else if (((A*)a)->t < ((A*)b)->t) {
      return -1;
    }
  }
  return 0;
}

int main()
{
  int i, j, n, s, t, left, right, nans=0;

  fscanf(stdin, "%d", &n);
  A *a = (A*)malloc(sizeof(A)*n);
  for (i=0; i<n; i++)
    fscanf(stdin, "%d %d", &(a[i].s), &(a[i].t));

  qsort(a, n, sizeof(A), compar);

  left=-1;
  j=0;
  int ll=a[n-1].t;
  while (left<ll) {
    right = ll+1;
    for (i=j; i<n; i++) {
      s = a[i].s;
      t = a[i].t;
      if (s>right) break;
      if (s>left && t<right) {
        right = t;
        j=i;
      }
    }
    if (right== ll+1) break;
    left = right;
    nans++;
  }
  printf("%d\n", nans);
  return 0;
}



Measured memory_bytes: 2992
open System

let S = Console.ReadLine() |> Seq.toArray
let T = Console.ReadLine() |> Seq.toArray

let result str1 str2 = 
    let rec subR accum index =
        let tempS = Array.sub str1 index (Array.length str2)
        let diff = Array.map2 (fun c1 c2 -> if c1 = c2 then 1 else 0)  tempS str2 |> Array.sum
        if index = str1.Length - str2.Length then
            max accum diff
        else 
            subR (max accum diff) (index+1)
    subR 0 0 

printfn "%i" ((Array.length T) - (result S T))

Measured memory_bytes: 42848
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});
process.stdin.on('end', () => {
  const rects = content
    .trim()
    .split('\n')
    .map(line => line.split(' ').map(n => parseInt(n, 10)));

  for (const rect of rects) {
    if (rect[0] !== 0 || rect[1] !== 0) {
      console.log(drawReact(rect));
    }
  }
});

const drawReact = ([h, w]) =>
  '#'
    .repeat(w)
    .concat('', '\n')
    .repeat(h);


Measured memory_bytes: 16056
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<string.h>
using namespace std;
typedef long long ll;
const int maxn = 5005;
const int maxm = 10005;
const int mod = 1000000009;
ll n, a,b;


int main(){
	scanf("%d%d%d", &n, &a, &b);
	ll mi = a*(n-1)+b, ma = b*(n-1)+a;
	ll ans = ma - mi + 1;
	if (a > b||(n==1&&b!=a))ans = 0;
	if (ans < 0)ans = 0;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool check(long long int n) {
    if (n==1) {
        return false;
    } else if (n==2) {
        return true;
    } else if (n%2==0) {
        return false;
    } else {
        double SqrtNum2=sqrt(n);
        for (int i=3;i<=SqrtNum2;i+=2) {
            if (n%i==0) {
                return false;
            }
        }
        return true;
    }
}
int main(void){
    long long int n;
    cin>>n;
    std::map<long long int, long long int> map;
    if (check(n)==false) {
        double SqrtNum=sqrt(n);
        for (int i=2;i<=SqrtNum;i++) {
            if (n%i==0) {
                while (n%i==0) {
                    map[i]++;
                    n/=i;
                }
            }
        }
        if (n!=1) {
            map[n]++;
        }
    } else {
        map[n]++;
    }
    long long int ans=0;
    for (auto itr=map.begin();itr!=map.end();itr++) {
        long long int tmp=1;
        while (itr->second>=tmp) {
            ans++;
            itr->second-=tmp;
            tmp++;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

const int MAX = 10000000;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/****** define constant end ********/

/****** define variable start ******/
ll a;
/******* define variable end *******/
int solve() {
	cin >> a;
	cout<< a + a * a + a * a * a << endl;
	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;
#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

/*

*/
int main()
{
    IOS
    string a,b;
    cin>>a>>b;
    //cout<<a<<" "<<b<<endl;
    vector<int> v(256,0);
    for(int i=0;i<a.size();i++)
    {
        v[a[i]-'a']++;
    }

    for(int i=0;i<b.size();i++)
    {
        v[b[i]-'a']--;
    }

    ll ct=0;

    // for(int i=0;i<v.size();i++)
    // {
    //     if(v[i]<0 || v[i]>0) ct++;
    // }
    //cout<<ct;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]!=b[i])
        {
            ct++;
        }
    }
    cout<<ct<<endl;

    return 0;
}


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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}

const int N = 1e3 + 1e2, Mod = 1e9 + 7;

inline int fpm(int x, int power) {
	int res = 1;
	for (; power; power >>= 1, x = 1ll * x * x % Mod)
		if (power & 1) res = 1ll * res * x % Mod;
	return res;
}

int f[N][N], fac[N], ifac[N], Pow[N];

void Fac_Init(int maxn) {
	fac[0] = ifac[0] = 1;
	For (i, 1, maxn) fac[i] = 1ll * fac[i - 1] * i % Mod;
	ifac[maxn] = fpm(fac[maxn], Mod - 2);
	Fordown (i, maxn - 1, 1) ifac[i] = ifac[i + 1] * (i + 1ll) % Mod;
}

int main () {

	File();

	int n = read(), a = read(), b = read(), c = read(), d = read();

	Fac_Init(n);

	f[a - 1][0] = 1;
	For (i, a, b) {
		For (j, 0, n) f[i][j] = f[i - 1][j];
		Pow[0] = 1;
		For (j, 1, n) Pow[j] = 1ll * Pow[j - 1] * ifac[i] % Mod;

		For (j, c * i, n) For (k, c, min(d, j / i))
			f[i][j] = (f[i][j] + 1ll * f[i - 1][j - i * k] * Pow[k] % Mod * ifac[k]) % Mod;
	}
	printf ("%lld\n", 1ll * f[b][n] * fac[n] % Mod);

	return 0;

}

Measured memory_bytes: 4608
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val s = sc.next()
        val t = sc.next()
        var ans = Int.MAX_VALUE
        for (i in 0..s.length - t.length) {
            var cnt = 0
            for (j in t.indices) {
                if (s[i + j] != t[j]) cnt++
            }

            ans = Math.min(ans, cnt);
        }

        println(ans)
    }
}

class MyScanner {
    private var ptr = 0
    private var l = listOf<String>()

    fun next(): String {
        while (l.size <= ptr) {
            l = readLine()!!.split(' ')
            ptr = 0
        }
        return l[ptr++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun list(): List<String> {
        ptr = l.size
        return readLine()!!.split(' ')
    }

    fun intList() = list().map { s -> s.toInt() }
    fun longList() = list().map { s -> s.toLong() }
    fun doubleList() = list().map { s -> s.toDouble() }

    fun array() = list().toTypedArray()
    fun intArray() = intList().toIntArray()
    fun longArray() = longList().toLongArray()
    fun doubleArray() = doubleList().toDoubleArray()
}


Measured memory_bytes: 37936
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int ans=0;
  char s[100],t[100];
  scanf("%s%s",&s,&t);
  for(int a=0;a<=2;a++)
    if(s[a]==t[a])ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 int n;
 string s;
 set<string> x;
 char p='#';
 cin >> n;
 while(n--)
 {
  cin >> s;
  if(x.find(s)!=x.end())
  {
   cout << "No";
   return 0;
  }
  if(p=='#');
  else if(p!=s[0])
  {
   cout << "No";
   return 0;
  }
  p=s[s.length()-1];
  x.insert(s);
 }
 cout << "Yes";
 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int a, b,d,r;
	double f;

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

	d = a / b;
	r = a % b;
	f = (double)a / b;

	printf("%d %d %f\n", d, r, f);
	
	return 0;
}


Measured memory_bytes: 2112
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int A = sc.nextInt();
			int B = sc.nextInt();
			int T1 = 0;
			if (1<=N & N<=20) {
				if (1<=A & N<=100) {
					T1 = N * A;
				}
			}
			
			if (T1 >= B) {
				System.out.println(B);
			} else {
				System.out.println(T1);
			}
		}
	}


Measured memory_bytes: 23764
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
using namespace std;
using T = tuple<int,int,string>;
vector<T> V;
int main(){
    int N,Q;
    while(cin>>N>>Q,N){
        V.clear();
        for(int i=0;i<N;i++){
            string name;
            int era, west;
            cin>>name>>era>>west;
            V.emplace_back(west,era,name);
        }
        sort(V.begin(), V.end());
        for(int i=0;i<Q;i++){
            int query;
            cin>>query;
            auto lb = lower_bound(V.begin(), V.end(), T(query,0,""));
            if(lb==V.end()){
                cout<<"Unknown"<<endl;
            }else{
                string name;
                int era,west;
                tie(west,era,name) = *lb;
                if(query<west-era+1){
                    cout<<"Unknown"<<endl;
                }else{
                    cout<<name<<' '<<era-(west-query)<<endl;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3268
a = []
for i in range(3):
    a1, a2, a3 = list(map(int, input().split()))
    a.append(a1)
    a.append(a2)
    a.append(a3)
    
n = int(input())

for i in range(n):
    b = int(input())
    for j in range(9):
        if a[j] == b:
            a[j] = 0
        
if a[0] == 0 and a[1] == 0 and a[2] == 0:
    print('Yes')
elif a[3] == 0 and a[4] == 0 and a[5] == 0:
    print('Yes')
elif a[6] == 0 and a[7] == 0 and a[8] == 0:
    print('Yes')
elif a[0] == 0 and a[3] == 0 and a[6] == 0:
    print('Yes')
elif a[1] == 0 and a[4] == 0 and a[7] == 0:
    print('Yes')
elif a[2] == 0 and a[5] == 0 and a[8] == 0:
    print('Yes')
elif a[0] == 0 and a[4] == 0 and a[8] == 0:
    print('Yes')
elif a[2] == 0 and a[4] == 0 and a[6] == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
 
modulo = 10 ** 9 + 7
 
S = input()
 
def nleft(S, a, reverse=False):
    """各位置について，それより左の文字列に含まれる文字 a の総数.
       左に'?'が含まれるときは，それらに文字を入れて得られるすべての
       文字列に渡って，文字 a の個数を合計する. """
 
    def rng():
        if reverse: return range(len(S) - 1, -1, -1)
        return range(len(S))

    # a の個数
    n = [0] * len(S)
    c = 0
    for i in rng():
        n[i] = c
        if S[i] == a:
            c += 1

    q = 0      # '?'の個数
    pow3q = 1  # 3 ** q
    for i in rng():
        if q > 0:
            n[i] *= pow3q         # ?の埋め方の数だけ増やす
            n[i] += pow3q1 * q    # ?に入る'C'の個数
            n[i] %= modulo
        if S[i] == '?':
            q += 1
            pow3q1 = pow3q
            pow3q  = pow3q * 3 % modulo
    return n
 
left  = nleft(S, 'A')
right = nleft(S, 'C', reverse=True)
 
# 各文字が'B'のときのABC数を計算
abc = 0
for i in range(0, len(S)):
    if S[i] in 'B?':
        abc += left[i] * right[i]
 
abc = int(abc) % modulo
print(abc)


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

using namespace std;

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b && b==c)
		cout<<"No"<<endl;
	else if(a!=b && b!=c && a!=c)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
}

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

using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int n,m,mx,cnt[1000],sign[1000];
int a[1000][1000],Ans;
int main()
{
	n=read(); m=read(); Ans=n;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) a[i][j]=read();
	for(int _=1;_<=m;_++)
	{
		memset(cnt,0,sizeof cnt);
		for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
		{
			if(!sign[a[i][j]])
			{
				cnt[a[i][j]]++;
				break;
			}
		}int p=0; for(int i=1;i<=m;i++)
			if(cnt[i]>cnt[p]) p=i;
		Ans=min(Ans,cnt[p]); sign[p]=1;
	}
	cout << Ans << endl;
	return 0 ;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <cctype>
//小文字を大文字 c-0x20;


#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define vvll(z,a,b) vector<vector<ll>>z(a,vector<ll>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
using namespace std;


int main(){
  string str;cin>>str;
  int q;cin>>q;
  rep(i,q){
    string s;
    int a,b;
    cin>>s>>a>>b;
    if(s=="replace"){
      string p;cin>>p;
      
        int k=0;
      for(int j=a;j<=b;j++){
       
          str[j]=p[k];
          k++;
      }
     
    }else if(s=="print"){
      
        
      for(int j=a;j<=b;j++){
          cout<<str[j];
      }
      cout<<endl;
    }else if(s=="reverse"){
      
        int h=b-a+1;
        vector<char>hu(h);
        int k=0;
         for(int j=a;j<=b;j++){
           
          hu.at(k)=str.at(j);
          k++;
      }
      reverse(hu.begin(),hu.end());
       k=0;
 for(int j=a;j<=b;j++){
   
          str.at(j)=hu.at(k);
          k++;
      }
    }

  }
  
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 50;

main() {
  ll K; cin >> K;
  ll a[N];
  for (int i = 0; i < N; i++) {
    a[i] = N - 1;
  }
  ll q = K / N;
  int r = K % N;
  for (int i = 0; i < N; i++) a[i] += q;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < N; j++) {
      if (j == i) {
        a[j] += N;
      } else {
        a[j]--;
      }
    }
  }
  cout << N << endl;
  for (int i = 0; i < N; i++) cout << a[i] << ( (i == N - 1) ? '\n' : ' ' );
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;

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

    if (B % A == 0)
        cout << A + B << endl;
    else
        cout << B - A << endl;
    return (0);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  long a, b, c, d;
  scanf("%ld%ld%ld%ld", &a, &b, &c, &d);
  long calc[] = { a * c, a * d, b * c, b * d };
  long ret = calc[0];
  for(int i = 0;i < 4;i++) {
    if(ret < calc[i]) {
      ret = calc[i];
    }
  }
  printf("%ld\n", ret);
  return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll x;

    cin >> x;
   
       for(ll i = -1000; i <= 1000; i++){
           for(ll j = -1000; j <= 1000; j++){
               if(i * i * i * i * i - j * j * j * j * j == x){
                   cout << i << " " << j << endl;
                   return 0;
               }
           }
       }
    
}

Measured memory_bytes: 3640
A = []
B = []
C = []
n, m, l = list(map(int, input().split()))
for a in range(n):
    cTmp = []
    for b in range(l):
        cTmp.append([])
    C.append(cTmp)
for i in range(n):
    A.append(list(map(int, input().split())))
for j in range(m):
    B.append(list(map(int, input().split())))
for x in range(n):
    for y in range(l):
        cTmp2 = 0
        for z in range(m):
            cTmp2 += A[x][z] * B[z][y]
        C[x][y] = cTmp2
for i in range(n):
    for k in range(l-1):
        print(C[i][k], end=" ")
    print(C[i][l-1])


Measured memory_bytes: 7452
#include<stdio.h>
int main(){
  int n,ans = 0;
  scanf("%d",&n);
  long long int a;
  for(int i = 0;i < n;i++){
    scanf("%lld",&a);
    while(a % 2 < 1){
      a /= 2;
      ans++;
    }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
import scala.math.min
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    
    // 距離を初期化
    val towns, roads, fuelCapacity = sc.nextInt
    val distMap = Array.fill[Int](towns+1, towns+1){fuelCapacity+1}
    for(i <- 1 to roads) {
      val from, to, dist = sc.nextInt
      distMap(from)(to) = dist
      distMap(to)(from) = dist
    }
    // WF法で最短距離を算出
    for(k <- 1 to towns) {
      for(i <- 1 to towns) {
        for(j <- 1 to towns) {
          distMap(i)(j) = min(distMap(i)(j), distMap(i)(k) + distMap(k)(j))
        }
      }
    }
    // 無補給移動可能マップを作成
    val steps = distMap.map{_.map{v => if(v <= fuelCapacity) 1 else fuelCapacity}}
    // WF法で最短補給ステップマップを算出
    for(k <- 1 to towns) {
      for(i <- 1 to towns) {
        for(j <- 1 to towns) {
          steps(i)(j) = min(steps(i)(j), steps(i)(k) + steps(k)(j))
        }
      }
    }
    val q = sc.nextInt
    for(i <- 1 to q) {
      val s, t = sc.nextInt
      val step = steps(s)(t)
      if (step >= fuelCapacity) {
        println("-1")
      } else {
        println(step-1)
      }
    }
  }
}

Measured memory_bytes: 106196
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n],b[n],c[n-1],count=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]--;
  }
  for(int i=0;i<n;i++)cin>>b[i];
  for(int i=0;i<n-1;i++)cin>>c[i];
  for(int i=0;i<n;i++){
    count+=b[a[i]];
    if(i>0&&a[i]==a[i-1]+1)count+=c[a[i-1]];
  }
  cout<<count<<endl;
}

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

int main(){
  int N,Q ;
  double K ;
  int A[100001],tensu[100001] ;

  int i,j;

  cin >> N >> K >> Q ;

  for(i=0;i<100001;i++){
    tensu[i] = K-Q;
  }

  for(i=0;i<Q;i++){
    cin >> A[i] ;
    A[i] = A[i]-1 ;
  }

  for(i=0;i<Q;i++){
    tensu[A[i]] ++ ;
  }

  for(i=0;i<N;i++){
    if(tensu[i]>0) cout << "Yes" << endl;
    else cout << "No" <<endl;
  }

}


Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
    int A,B,K;

    scanf("%d %d",&A,&B);

    if(A%2==B%2)
    {
        K = (A+B)/2;
        printf("%d\n",K);
    }

    else
    {
        printf("IMPOSSIBLE\n");
    }

    return 0;

}

Measured memory_bytes: 128
# 一点更新、区間取得
class segment_():
    def __init__(self,n,ide_ele,segfunc):
        #####単位元######要設定0or1orinf
        self.ide_ele = ide_ele
        ####################
        self.num = 1 << n.bit_length()
        self.seg = [self.ide_ele] * 2 * self.num
        self.segfunc = segfunc

    def update(self, k, r):
        k += self.num
        self.seg[k] = r
        while k:
            k >>= 1
            self.seg[k] = self.segfunc(self.seg[k * 2], self.seg[k * 2 + 1])

    # 値xに1加算
    def update1(self, k):
        k += self.num
        self.seg[k] += 1
        while k:
            k >>= 1
            self.seg[k] = self.segfunc(self.seg[k * 2], self.seg[k * 2 + 1])

    def updateneg1(self, k):
        k += self.num
        self.seg[k] -= 1
        while k:
            k >>= 1
            self.seg[k] = self.segfunc(self.seg[k * 2], self.seg[k * 2 + 1])

    def query(self, p, q):
        # qは含まない
        if q < p:
            return self.ide_ele
        p += self.num;
        q += self.num
        res = self.ide_ele
        while p < q:
            if p & 1 == 1:
                res = self.segfunc(res, self.seg[p])
                p += 1
            if q & 1 == 1:
                q -= 1
                res = self.segfunc(res, self.seg[q])
            p >>= 1;
            q >>= 1
        return res
      
import sys
input = sys.stdin.readline
from operator import itemgetter

N,M,Q = map(int,input().split())
S = segment_(N+1,0,lambda a, b: a+b)
chk = []
for i in range(M):
  L,R = map(int,input().split())
  chk.append((1,L,R,i))
for i in range(Q):
  l,r = map(int,input().split())
  chk.append((2,l,r,i))
  
chk.sort(key=itemgetter(2))
ans = [0]*Q
for a,l,r,i in chk:
  if a == 1:
    S.update1(l)
  else:
    ans[i] = S.query(l,r+1)
    
for i in ans:
  print(i)

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

int n,x,mi;
double t,a,h,hoge = 100000000;

int main(void) {
    cin >> n >> t >> a;
    for (x=1 ; x<=n ; x++) {
        cin >> h;
        if (hoge > abs(a-(t-h*0.006))){
            mi = x;
            hoge = abs(a-(t-h*0.006));
        }
    }
    cout << mi << "\n";




}


Measured memory_bytes: 256
N, K, S = map(int, input().split())

ans = []

if S == 1000000000:
    for i in range(N):
        if K > 0:
            ans.append(S)
            K -= 1
        else:
            ans.append(1)
else:
    for i in range(N):
        if K > 0:
            ans.append(S)
            K -= 1
        else:
            ans.append(1000000000)

print(" ".join(str(i) for i in ans))


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

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      String s = sc.next();
      List<Integer> arr = new ArrayList<>();
      for(int i = 0; i < s.length(); i++) {
        int flag = 1;
        if(s.charAt(i) == 'L')
          flag = -1;
        int cnt = 1;
        while(i < s.length() - 1 && s.charAt(i) == s.charAt(i+1)) {
          cnt++;
          i++;
        }
        arr.add(cnt * flag);
      }

      int[] leftSum = new int[arr.size()];
      for(int i = 1; i < arr.size(); i++)
        leftSum[i] = leftSum[i-1] + Math.abs(arr.get(i-1)) - 1;
        
      int[] rightSum = new int[arr.size()];
      for(int i = rightSum.length - 2; i >= 0; i--)
        rightSum[i] = rightSum[i+1] + Math.abs(arr.get(i+1)) - 1;

      int maxSum = 0;
      int replaceCnt = 0;
      int sum = 0;
      for(int i = 0, leftIdx = 0; i < arr.size(); i++) {
        int num = arr.get(i);
        if(num < 0) replaceCnt++;
        sum += Math.abs(num);
        while(replaceCnt > k) {
          int leftNum = arr.get(leftIdx++);
          if(leftNum < 0) replaceCnt--;
          sum -= Math.abs(leftNum);
        }
        
        maxSum = Math.max(maxSum, sum + leftSum[leftIdx] + rightSum[i] - 1);
      }

      replaceCnt = 0;
      sum = 0;
      for(int i = 0, leftIdx = 0; i < arr.size(); i++) {
        int num = arr.get(i);
        if(num > 0) replaceCnt++;
        sum += Math.abs(num);
        while(replaceCnt > k) {
          int leftNum = arr.get(leftIdx++);
          if(leftNum > 0) replaceCnt--;
          sum -= Math.abs(leftNum);
        }
        
        maxSum = Math.max(maxSum, sum + leftSum[leftIdx] + rightSum[i] - 1);
      }
      
      System.out.println(maxSum);
  }
}

Measured memory_bytes: 26980