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

int n;
vector<int> S(1000000);

int binarySearch(int key) {
    int left = 0;
    int right = n;
    int mid;
    while (left < right) {
        mid = (left + right) / 2;
        if (key == S[mid]) return 1;
        if (key > S[mid]) left = mid + 1;
        else if (key < S[mid]) right = mid;
    }
    return 0;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> S.at(i);
    }
    int q, ans = 0;
    cin >> q;
    for ( int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (binarySearch(t)) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
	string S;
	cin >> S;
	
	int result = 0;

	for (int i = 0; i < S.size()/2; i++) {
		if (S[i] != S[S.size() - 1 - i]) {
			result++;
		}
	}
	cout << result << endl;
}

Measured memory_bytes: 256
s=input();t=input()
u=[];c=0
for i in range(len(s)):
  v=[s[i],t[i]]
  if v not in u:
    u.append(v)
for k in range(len(u)):
  for m in range(len(u)):
    if u[k][0]==u[m][0]:
      if u[k][1]!=u[m][1]:c+=1
for p in range(len(u)):
  for q in range(len(u)):
    if u[p][1]==u[q][1]:
      if u[p][0]!=u[q][0]:c+=1
if c==0:print('Yes')
else:print('No')

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define maxn (int)(2e5)
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;

long lcm(long a, long b){
    return a/__gcd(a,b)*b;
}
int main() {
    /*BEFORE SUBMIT, CHECK
    sample i/o format
    statements for debugging are removed/comment out
    global values / stl containers are initialized/cleared for each test (if needed)
    all array size are sufficient
    loop variable or output value doesn't cross min/max limit of input
    */
    
    long a,b;
    while(scanf("%ld %ld",&a, &b)==2){
        printf("%ld\n", lcm(a,b));        
    }   
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
from collections import Counter
a = Counter(a)
lis = []

for i,j in a.items():
    lis += [i]*(j//2)

#print(lis)

lis.sort(reverse=True)
if len(lis) <= 1:
    ans = 0
else:
    ans = lis[0]*lis[1]

print(ans)

Measured memory_bytes: 22196
#include<bits/stdc++.h>
using namespace std;
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i, a, n) for( i=a; i<n;i++)
typedef long long ss;
ss arr[10000007];
int main()
{
	start;
	ss n ; cin >> n;
	for(int i = 2; i <= n; i++)
	{
		for(int j = i; j <=n; j+=i)
		{
			arr[j]++;
		}
	}
	ss ans = 0;
	for(int i = 2; i <= n; i++)
	ans += i*(arr[i]+1);
	cout << ans+1 << endl;
		
}

Measured memory_bytes: 81732
S = input().split()
A = list(map(int, input().split()))
Z = input()
 
if S[0] == Z:
  X = A[0] - 1
  Y = A[1]
  print("{} {}".format(X, Y))
if S[1] == Z:
  X = A[0]
  Y = A[1] - 1
  print("{} {}".format(X, Y))
  


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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

int main(){
  ll A,B,K;
  cin >> A >> B >> K;
  if(A<K&&(A+B)>K){
    cout << 0 << " " << B-(K-A) << endl;
    return 0;
  }
  if((A+B)<=K){
    cout << 0 << " " << 0 << endl;
    return 0;
  }
  if(A>=K){
    cout << A-K << " " << B << endl;
    return 0;
  }
  
}
      
  
  
  

Measured memory_bytes: 256
using System;

public class ITP1_1_C
{
    public static void Main(string[] args)
    {
//        var exStdIn = new System.IO.StreamReader( "input.txt" );
//        System.Console.SetIn( exStdIn );

        string[] str = Console.ReadLine().Split(' ');

        var a = int.Parse(str[0]);
        var b = int.Parse(str[1]);

        var area = a * b;
        var perimeter = a * 2 + b * 2;

        Console.WriteLine("{0:d} {1:d}", area, perimeter);
    }
}



Measured memory_bytes: 19960
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
 
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=(res*x);
        }
        x=(x*x);
        y=y/2;
    }
    return res;
}
 
 
int main(){
 
/* #ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/
   
ll n,i;
sfl(n);
ll a[n];
f(i,0,n)sfl(a[i]);

vec<ll>dp(n);
dp[0]=0;
dp[1]=abs(a[1]-a[0]);
f(i,2,n){
dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
}

cout<<dp[n-1];

 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
   return 0;
 }

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

long long mod = 998244353;
long long mod_pow(int a, int b) {
  long long v = a;
  for (int i=0; i<b-1; i++) {
    v *= a;
    v %= mod;
  }
  return v;
}
int main() {
  int n;
  cin>>n;
  int d[n];
  for (int i=0; i<n; i++) cin>>d[i];
  if (d[0] != 0) {
    cout<<0<<endl;
    return 0;
  }
  map<int, int> m;
  for (int i=0; i<n; i++) {
    ++m[d[i]];
  }
  long long ans = 1;
  int cnt = 1;
  for (int i=1; i<n; i++) {
    ans *= mod_pow(m[i-1], m[i]);
    ans %= mod;
    cnt += m[i];
    if (cnt == n) {
      break;
    }
  }
  cout<<ans<<endl;
} 

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;


ll modinv(ll a, ll m) {
	ll b=m, u=1, v=0;
	while(b) {
		ll t=a/b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	u %= m;
	if(u<0)
		u += m;
	return u;
}

map<ll,ll> primes(ll n){
    map<ll, ll> r;
    for(int i=2; i*i<=n; i++){
        while(n %i ==0){
            r[i]++;
            n /= i;
        }
    }

    if(n != 1) r[n] = 1;
    return r;
}

ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

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

    ll n, x=1, ans=0;
    cin >> n;
    vll a(n);
    map<ll,ll> l;

    REP(i,n){
        cin >> a[i];
        map<ll,ll>r = primes(a[i]);

        for(auto p: r){
            if(!l.count(p.first)) l[p.first] = p.second;
            else l[p.first] = max(l[p.first], p.second); 
        }
    }

    for(auto p:l){
        REP(i,p.second){
            x *= p.first;
            x %= mod;
        }
    }
    // cout << x << endl;
    REP(i,n){
        ans += x * modinv(a[i], mod);
        ans %= mod;
    }

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



Measured memory_bytes: 1024
from bisect import bisect_left, bisect_right

n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
    ans += bisect_left(a, b[i]) * (n - bisect_right(c, b[i]))
print(ans)


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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    string s;
    int cnt=0;
    cin >> s;
    for (int i = 0; i < 6 ; ++i) {
        if(s[i] == '1')
            cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
import numpy as np
 
N = int(readline())
XY = np.array(read().split(),np.int64)
 
X = XY[::2]; Y = XY[1::2]
 
dx = X[:,None] - X[None,:]
dy = Y[:,None] - Y[None,:]
 
dist_mat = (dx * dx + dy * dy) ** .5
 
answer = dist_mat.sum() / N
print(answer)

Measured memory_bytes: 27276
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    readln.chomp.to!long.pipe!"a<1200".pipe!(a => a?"ABC":"ARC").writeln;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		for(int i = s.length() - t.length() ; i >= 0 ; i--) {
			String temp = s.substring(i, i + t.length());
			boolean ok = true;
			for(int j = 0 ; j < temp.length() ; j++) {
				if(!(temp.charAt(j) == '?' || temp.charAt(j) == t.charAt(j))) {
					ok = false;
				}
			}
			if(ok) {
				String ret = s.substring(0, i) + t + s.substring(i + t.length());
				System.out.println(ret.replaceAll("\\?", "a"));
				return;
			}
		}
		System.out.println("UNRESTORABLE");
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> L(N+1);
  L.at(0)= 2;
  L.at(1)= 1;
  for(int i=2; i<=N;i++){
    L.at(i) = L.at(i-2)+L.at(i-1);
  }
  cout << L.at(N) << endl;

}

Measured memory_bytes: 3624
import java.util.Scanner;
import java.util.Vector;

public class Main {
	static int a[];
	static int dp[];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		dp = new int[k+1];
		dp[0] = 1;
		a = new int[n];
		for (int i=0;i<n;i++) 
			a[i]=sc.nextInt();
		
		for (int i=0;i<=k;i++) {
			f(i);
		}
		System.out.println(dp[k]==2?"First":"Second");
	}
	private static int f(int k) {
		if (dp[k]>0) return dp[k];
		int ans = 1;
		for (int i=0;i<a.length;i++) {
			if (k>=a[i]) {
				int l = 3 - f(k-a[i]);
				if (ans<l) ans = l;
			}
		}
		dp[k] = ans;
		return ans;
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <stack>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int inf=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
int M,N;
char F[1000][1000],f[2][2];
bool u[1000][1000];
int main(){
	cin>>M>>N;
	FOR(i,0,M){
		FOR(j,0,N){
			cin>>F[i][j];
		}
	}
	FOR(i,0,2){
		FOR(j,0,2){
			cin>>f[i][j];
		}
	}
	int cnt=0;
	FOR(i,0,M-1){
		FOR(j,0,N-1){
			if(F[i][j]==f[0][0]&&F[i][j+1]==f[0][1]&&F[i+1][j]==f[1][0]&&F[i+1][j+1]==f[1][1]){
				u[i][j]=true;u[i][j+1]=true;
				u[i+1][j]=true;u[i+1][j+1]=true;
				cnt++;
			}
		}
	}
	int ma=cnt;
	FOR(i,0,M-1){
		FOR(j,0,N-1){
			int x,y;
			int c=0;
			char cc;
			FOR(k,0,2){
				FOR(l,0,2){
					if(F[i+k][j+l]!=f[k][l]){
						c++;
						x=i+k;
						y=j+l;
						cc=f[k][l];
					}
				}
			}
			if(c==1){
				if(u[x][y]==false){
					c=0;
					char mem=F[x][y];
					F[x][y]=cc;
					if(x-1>=0&&y-1>=0&&F[x-1][y-1]==f[0][0]&&F[x-1][y]==f[0][1]&&F[x][y-1]==f[1][0]&&F[x][y]==f[1][1]){
						c++;
					}
					if(x-1>=0&&y+1<N&&F[x-1][y]==f[0][0]&&F[x-1][y+1]==f[0][1]&&F[x][y]==f[1][0]&&F[x][y+1]==f[1][1]){
						c++;
					}
					if(y-1>=0&&x+1<M&&F[x][y-1]==f[0][0]&&F[x][y]==f[0][1]&&F[x+1][y-1]==f[1][0]&&F[x+1][y]==f[1][1]){
						c++;
					}
					if(x+1<M&&y+1<N&&F[x][y]==f[0][0]&&F[x][y+1]==f[0][1]&&F[x+1][y]==f[1][0]&&F[x+1][y+1]==f[1][1]){
						c++;
					}
					F[x][y]=mem;
					ma=max(ma,c+cnt);
				}else{
					c=0;
					if(x-1>=0&&y-1>=0&&F[x-1][y-1]==f[0][0]&&F[x-1][y]==f[0][1]&&F[x][y-1]==f[1][0]&&F[x][y]==f[1][1]){
						c--;
					}
					if(x-1>=0&&y+1<N&&F[x-1][y]==f[0][0]&&F[x-1][y+1]==f[0][1]&&F[x][y]==f[1][0]&&F[x][y+1]==f[1][1]){
						c--;
					}
					if(y-1>=0&&x+1<M&&F[x][y-1]==f[0][0]&&F[x][y]==f[0][1]&&F[x+1][y-1]==f[1][0]&&F[x+1][y]==f[1][1]){
						c--;
					}
					if(x+1<M&&y+1<N&&F[x][y]==f[0][0]&&F[x][y+1]==f[0][1]&&F[x+1][y]==f[1][0]&&F[x+1][y+1]==f[1][1]){
						c--;
					}
					char mem=F[x][y];
					F[x][y]=cc;
					if(x-1>=0&&y-1>=0&&F[x-1][y-1]==f[0][0]&&F[x-1][y]==f[0][1]&&F[x][y-1]==f[1][0]&&F[x][y]!=f[1][1]){
						c++;
					}
					if(x-1>=0&&y+1<N&&F[x-1][y]==f[0][0]&&F[x-1][y+1]==f[0][1]&&F[x][y]!=f[1][0]&&F[x][y+1]==f[1][1]){
						c++;
					}
					if(y-1>=0&&x+1<M&&F[x][y-1]==f[0][0]&&F[x][y]!=f[0][1]&&F[x+1][y-1]==f[1][0]&&F[x+1][y]==f[1][1]){
						c++;
					}
					if(x+1<M&&y+1<N&&F[x][y]!=f[0][0]&&F[x][y+1]==f[0][1]&&F[x+1][y]==f[1][0]&&F[x+1][y+1]==f[1][1]){
						c++;
					}
					ma=max(ma,c+cnt);
				}
			}else{
				continue;
			}
		}
	}
	cout<<ma<<endl;
	return 0;
}


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

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

  ll cnt = 0, ans = 0;
  REP(i, 0, S.length()) {
    if (S[i] == 'W') {
      ans += cnt;
    } else {
      cnt++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
N,K = map(int,input().split())
a = []
M = 0
for i in range(N):
  a.append(list(map(int,input().split())))
a.sort()
for i in range(N):
    K = K-a[i][1]
    if K <= 0:
        print(a[i][0])
        break

Measured memory_bytes: 27916
N, Q = map(int,input().split())
S = input()
a =[0] * N
for i in range(N-1):
    if S[i] == "A" and S[i + 1] == "C":
        a[i + 1] = a[i] + 1
    else:
        a[i + 1] = a[i]
l, r = 0, 0
b = [0] * Q
for i in range(Q):
    l, r = map(int, input().split())
    b[i] = a[r-1] - a[l-1]
for i in range(Q):
    print(b[i])


Measured memory_bytes: 10324
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#include <list>
#include <deque>
#include <set>
#include <map>
#include <cstdlib>
using namespace std;
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-9
int read()
{
	int x = 0; char ch = getchar();
	for(;ch<'0'||ch>'9';ch = getchar());
	for(;ch>='0'&&ch<='9';ch = getchar()) x = (x<<3)+(x<<1)+(ch^48);
	return x;
}
int n,a[220];
int ans;
int main()
{
	n = read();
	for(int i=1;i<=(n<<1);i++) a[i] = read();
	sort(a+1,a+n+n+1);
	for(int i=1;i<=(n<<1);i+=2) ans += a[i];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n : usize,
        mut a : [usize; n]
    };
    a.sort();
    let mut check = [0; 1000001];
    let mut res = 0;
    for i in 0..n {
        if check[a[i]] != 0 { continue }
        if i == n-1 || a[i] != a[i+1] { res += 1 }
        let mut idx = a[i];
        while idx <= 1000000 {
            check[idx] = 1;
            idx += a[i];
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 8948
while 1:
    n = input()
    if n == 0: break
    l = [input(),1]
    for i in range(n-1):
        x = input()
        if i % 2 == 1:
            if l[-2] == x: l[-1] += 1
            else: l += [x]; l += [1]
        else:
            if l[-2] == x: l[-1] += 1
            else:
                if len(l) > 2:
                    l[-3] += l[-1] + 1
                    l = l[:-2]
                else:
                    l[-2] = x
                    l[-1] += 1
    ans = 0
    for i in range(len(l)/2):
        if l[i*2] == 0: ans += l[i*2 + 1]
    print ans

Measured memory_bytes: 9364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
constexpr int IINF = INT_MAX;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};

int n, a, b, c, d, x[105], y[105];

int bfs(int si, int sj, int gi, int gj){
    int dmin[105][105];
    for(int i=0;i<=100;i++) fill(dmin[i], dmin[i]+101, IINF/3);
    deque<P> que;
    que.push_back({si, sj});
    dmin[si][sj] = 0;
    while(!que.empty()){
        P p = que.front();
        que.pop_front();
        int pi = p.first, pj = p.second;
        if(pi == gi && pj == gj) return dmin[gi][gj];
        for(int k=0;k<4;k++){
            int ni = pi+di[k], nj = pj+dj[k];
            if(ni < 1 || ni > 100) continue;
            if(nj < 1 || nj > 100) continue;
            if(dmin[ni][nj] < IINF/3) continue;
            if(a <= nj && nj <= c && b <= ni && ni <=d){
                dmin[ni][nj] = dmin[pi][pj];
                que.push_front({ni, nj});
            }
            else{
                dmin[ni][nj] = dmin[pi][pj] + 1;
                que.push_back({ni, nj});
            }
        }
    }
    return dmin[gi][gj];
}

int main() {
    while(cin >> n , n){
        cin >> a >> b >> c >> d;
        for(int i=0;i<=n;i++){
            cin >> x[i] >> y[i];
        }
        int ans = 0;
        for(int i=0;i<n;i++){
            ans += bfs(y[i], x[i], y[i+1], x[i+1]);
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3272
lines = []
while line = gets
  lines << line.chomp.split(' ').map(&:to_i)
end

members = []
i = 0
lines[0][0].times do
  members[i] = 0
  i += 1
end

lines[1].each do |l|
  members[l.to_i - 1] += 1
end

members.each do |m|
  pp m.to_i
end

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

void solve() {
    long long int a, b, c, d;
    
    cin >> a >> b >> c >> d;
    
    long long int maxi = -1e18;
    maxi = max(maxi, a*c);
    maxi = max(maxi, a*d);
    maxi = max(maxi, b*c);
    maxi = max(maxi, b*d);
    
    cout << maxi << endl;
}

int main() {
	// your code goes here
	
	solve();
	
	return 0;
}


Measured memory_bytes: 3612
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner s=new Scanner (System.in);
		
		int n=s.nextInt();
		s.nextLine();
		for(int j=0;j<n;j++){
			char c[]=s.nextLine().toCharArray();
			for(int i=0;i<c.length-6;i++){
				if(c[i]=='H'&&c[i+1]=='o'&&c[i+2]=='s'&&c[i+3]=='h'&&c[i+4]=='i'&&c[i+5]=='n'&&c[i+6]=='o'){
					c[i+6]='a';
					i+=6;
				}
			}
			System.out.println(new String(c));
		}
	}
}

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

int main(){
    int x;
    cin >> x;
    int y = x / 100, z = x % 100;
    if (z % 5 == 0)
    {
        if (z / 5 <= y)
        {
            cout << 1 << endl;
            return 0;
        }
        
    }
    else
    {
        if (z / 5 + 1 <= y)
        {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
using namespace std;

int main(){
//  FILE*fin=fopen("a.in", "r");
  FILE*fin=stdin;
  int a, b, c;
  fscanf(fin, "%d%d%d ", &a, &b, &c);
  if(a==b)
    printf("%d", c);
  else
    if(b==c)
      printf("%d", a);
    else
      printf("%d", b);

  return 0;
}


Measured memory_bytes: 384
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string().chars().collect::<Vec<char>>();

    for i in 0..s.len()/2{
        if s[i] != s[s.len()-1-i]{
            println!("No");
            return;
        }
    }

    for i in 0..(s.len()-1)/2{
        if s[i] != s[(s.len()-1)/2-1-i]{
            println!("No");
            return;
        }
    }


    for i in (s.len()+3)/2..s.len()/2{
        if s[i] != s[s.len() -1 -i]{
            println!("No");
            return;
        }
    }


    println!("Yes");
}


Measured memory_bytes: 4352
from collections import deque
H, W = map(int,input().split())
S = []
for _ in range(H):
    S.append(input())

ans = 0

hjkl = [(0, -1), (1, 0), (-1, 0), (0, 1)]
def bfs(h, w):
    parents = [[0] * W for _ in range(H)]
    queue = deque()
    queue.append((h, w))
    parents[h][w] = 1
    while queue:
        pos = queue.popleft()
        now_dist = parents[pos[0]][pos[1]]
        for i, j in hjkl:
            y, x = pos[0] + i, pos[1] + j
            #  print(0 <= y <= H-1, 0 <= x <= W-1 , not parents[y][x], S[y][x] == ".")
            if 0 <= y <= H-1 and 0 <= x <= W-1 and not parents[y][x] and S[y][x] == ".":
                parents[y][x] = now_dist + 1
                queue.append((y, x))
                tmp_ans = now_dist
    return tmp_ans
                
for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            continue
        else:
            now = bfs(h, w)
            if now > ans:
                ans = now

print(ans)


Measured memory_bytes: 3444
#include <stdio.h>

void call(int N);

int main(void) {
  int n;
  scanf("%d", &n);

  call(n);

  return 0;
}

void call(int N) {
  int i = 0;

  while(++i <= N) {
    int x = i;

    if(x % 3 == 0) {
      printf(" %d", i);
      continue;
    }

    while(x) {
      if(x % 10 == 3) {
        printf(" %d", i);
        break;
      }
      x /= 10;
    }
  }

  printf("\n");
}



Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
const int maxn=55;
char m[maxn][maxn];
int dx[8]={0,1,1,1,0,-1,-1,-1},dy[8]={1,1,0,-1,-1,-1,0,1};
int main()
{
	int r,c;scanf("%d%d",&r,&c);
	for(int i=1;i<=r;i++)scanf("%s",m[i]+1);
	for(int i=1;i<=r;i++)
		for(int j=1;j<=c;j++)
		{
			if(m[i][j]!='.')continue;
			int tmp=0;
			for(int d=0;d<8;d++)
			{
				int x=i+dx[d],y=j+dy[d];
				if(x<0||x>r||y<0||y>c)continue;
				if(m[x][y]=='#')tmp++;
			}
			m[i][j]=tmp+'0';
		}
	for(int i=1;i<=r;i++)puts(m[i]+1);
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

    int n = sc.nextInt();

    List<Integer> ds = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      int d = sc.nextInt();
      ds.add(d);
    }

    int heal = 0;
    for (int i = 0; i < ds.size() - 1; i++) {
      for (int j = i + 1; j < ds.size(); j++) {
        heal += ds.get(i) * ds.get(j);
      }
    }

    System.out.println(heal);
  }
}


Measured memory_bytes: 21844
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))

import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


n = onem()

s = []

for i in range(n):
    s.append(l())

s.sort(key = lambda x:x[1])
t = 0
for i in range(n):
    if t + s[i][0] > s[i][1]:
        print("No")
        exit()
    else:
        t += s[i][0]
print("Yes")










Measured memory_bytes: 114172
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

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

vector<int> to[2501];

int main(void){
    int N,M,P;
    cin>>N>>M>>P;
    vector<int> A(M);
    vector<int> B(M);
    vector<int> C(M);
    rep(i,M){
        cin>>A[i]>>B[i]>>C[i];
        A[i]--;B[i]--;
        C[i]-=P;C[i]*=-1;

        to[A[i]].push_back(B[i]);
    }

    vector<long long> distance(N,INT64_MAX-100005ll);
    distance[0]=0;
    rep(i,N-1){
        rep(k,M){
            int u=A[k];
            int v=B[k];
            if(distance[v]>distance[u]+C[k]){
                distance[v]=distance[u]+C[k];
            }
        }
    }
    vector<int> from_start;
    vector<bool> b1(N,false);
    queue<int> q1;

    b1[0]=true;
    q1.push(0);
    while(q1.size()){
        int u=q1.front();
        q1.pop();

        for(int v:to[u]){
            if(b1[v]){continue;}
            b1[v]=true;
            from_start.push_back(v);
            q1.push(v);
        }
    }
    
    vector<bool> can_goal(N,false);
    can_goal[0]=true;
    for(int s:from_start){
        vector<bool> b2(N,false);
        queue<int> q2;
        b2[s]=true;
        q2.push(s);
        while(q2.size()){
            int u=q2.front();
            q2.pop();
            if(u==N-1){
                can_goal[s]=true;
                break;
            }

            for(int v:to[u]){
                if(b2[v]){continue;}
                b2[v]=true;
                q2.push(v);
            }
        }
    }

    long long ans=max(0ll,-distance[N-1]);

    rep(i,M){
        int u=A[i];
        int v=B[i];
        if(distance[v]>distance[u]+C[i]){
            if(can_goal[v]){
                ans=-1;
                break;
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }

        int max = 0;
        int total = 0;
        for (int i = 0; i < n; i++) {
            total += a[i];
            int tmp = total;
            for (int j = n-1; j >= i; j--) {
                tmp += b[j];
            }
            max = Math.max(max, tmp);
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 22868
r,g,b,n = [int(x) for x in input().split()]

ans = 0

for x in range(n//r + 1):
    for y in range(n // g + 1):
        if (n - (r * x + g * y)) % b == 0 and (n - (r*x + g*y)) >= 0:
            ans += 1
print(ans)


Measured memory_bytes: 40556
N = gets.to_i
A = gets.split.map(&:to_i)
q = gets.to_i
m = gets.split.map(&:to_i)

def solve(i, m)
  return true if m == 0
  return false if i >= N
  res = solve(i+1, m) | solve(i+1, m - A[i])
  return res
end

m.each do |m|
  if solve(0, m)
    puts 'yes'
  else
    puts 'no'
  end
end


Measured memory_bytes: 6872
#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int a, b, c, x;
    cin >> a >> b >> c >> x;

    ll ans = 0;
    REP(i, a + 1) REP(j, b + 1) REP(k, c + 1) {
        if (500 * i + 100 * j + 50 * k == x) ans++;
    }

    print(ans);

}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
  
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  int h,w,x;
  cin>>h>>w>>x;

  if(x%max(h,w)!=0){
    cout<<x/max(h,w)+1<<'\n';
  }
  else{
    cout<<x/max(h,w)<<'\n';
  }
  return 0;
}


Measured memory_bytes: 256
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
k = int(input())
a, b = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

for i in range(a, b+1):
    if i % k == 0:
        print("OK")
        sys.exit()

print("NG")


Measured memory_bytes: 9560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll N, M; cin >> N >> M;
    vector<ll> A(N),B(N);
    map<ll,ll> C;
    for(ll i = 0; i < N; i++)
    {
        cin >> A.at(i) >> B.at(i);
        C[A.at(i)] += B.at(i);
    }
    sort(A.begin(),A.end());
    ll ans = 0;
    ll cnt = 0;
    ll judge;
    for(ll i:A)
    {
        if(judge != i)
        {
        ans += i*C[i];
        cnt += C[i];
        }
        judge = i;
        if(cnt >= M)
        {
            cout << ans - (cnt - M)*i << endl;
            break;
        }
    }
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define ms(x, v) memset(x, v, sizeof(x))
using namespace std;
ll s[100], n;

int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    rep1(i, n) cin >> s[i];

    ll sum, ans = 0;
    do
    {
        sum = 0;

        rep1(i, n)
        {
            ll num = s[i] / n;
            sum += num;
            s[i] %= n;
            s[i] -= num;
        }

        rep1(i, n) s[i] += sum;

        ans += sum;

    } while(sum);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	if(s=="Sunny")puta("Cloudy");
	else if(s=="Cloudy")puta("Rainy");
	else puta("Sunny");
	return 0;
}

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

int main() {
	int n, q;
	string s;
	cin >> n >> q >> s;

	vector<int> ac_a(n + 1, 0);
	for(int i = 0; i < s.length(); i++) {
		if(s[i] == 'A' && s[i + 1] == 'C') {
			ac_a[i + 1] = ac_a[i] + 1;
		} else {
			ac_a[i + 1] = ac_a[i];
		}
	}

	int l, r;
	for(int i = 0; i < q; i++) {
		cin >> l >> r;
		cout << ac_a[r - 1] - ac_a[l - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 1408
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <cstdio>

typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 9)
#define INF (1 << 29)

int a[MAXN][MAXN];

int h, w;
int m[MAXN][MAXN];
int n;

int ind(int x, int y) {
	return (x - 1) * w + (y - 1);
}

void addedge(int cur, int x, int y) {
	if (!m[x][y]) {
		return;
	}
	int nnext = ind(x, y);
	a[cur][nnext] = 1;
	a[nnext][cur] = 1;

}

void addedges(int x, int y) {
	if (!m[x][y]) {
		return;
	}
	int cur = ind(x,y);
	addedge(cur, x + 1, y);
	addedge(cur, x - 1, y);
	addedge(cur, x, y - 1);
	addedge(cur, x, y + 1);
}

void floyd() {
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (a[i][j] > a[i][k] + a[k][j]) {
					a[i][j] = a[i][k] + a[k][j];
				}
			}
		}
	}
}

int main() {
	memset(a, 63, sizeof(a));
	scanf("%d %d\n", &h, &w);
	for (int i = 1; i <= h; i++) {
		string s;
		cin >> s;
		for (int j = 1; j <= w; j++) {
			if (s[j - 1] == '.') {
				m[i][j] = 1;
			} 
		}
	}
	n = h * w;
	for (int i = 0; i < n; i++) {
		a[i][i] = 0;
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			addedges(i, j);
		}
	}
	floyd();	
	
	int ret = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if ((a[i][j] < INF) && (a[i][j] > ret)) {
				ret = a[i][j];
			}
		}
	}
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 4640
m=int(input())
ans=[]
for i in range(m):
  train=input()
  index=len(train)
  count=0
  tmp_a=set([])
  for i in range(1,index):
    tmp_a.add(train[:i]+train[i:])
    tmp_a.add(train[i:]+train[:i])
    tmp_a.add(train[:i][::-1]+train[i:])
    tmp_a.add(train[i:][::-1]+train[:i])
    tmp_a.add(train[:i]+train[i:][::-1])
    tmp_a.add(train[i:]+train[:i][::-1])
    tmp_a.add(train[:i][::-1]+train[i:][::-1])
    tmp_a.add(train[i:][::-1]+train[:i][::-1])
  ans.append(len(tmp_a))
for i in ans:
  print(i)







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

int main()
{
int i;
int a;
int N;
int iLenS;
int iLenT;
char S[ 110 ];
char T[ 110 ];

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> S;
	cin >> T;

	iLenS = strlen( S );
	iLenT = strlen( T );
	sort( S, S + iLenS );
	sort( T, T + iLenT, greater<char>() );

	i = strcmp( S, T );
	if( i < 0 )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}






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

using namespace std;

int main (int argc, char const *argv[]) {
    string str; cin >> str;
    int n = 0, s = 0, e = 0, w = 0;
    for (int i = 0; i < str.size(); ++i) {
        if (str[i] == 'N') ++n;
        if (str[i] == 'S') ++s;
        if (str[i] == 'E') ++e;
        if (str[i] == 'W') ++w;
    }

    if (n > 0 and s > 0 and e == 0 and w == 0) {
        printf("Yes\n");
    } else if (n == 0 and s == 0 and e > 0 and w > 0) {
        printf("Yes\n");
    } else if (n > 0 and s > 0 and e > 0 and w > 0) {
        printf("Yes\n");
    } else printf("No\n");
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
void solve(long long N, long long K){
  ll now=1;
  rep(i,N){
    if(K<now)now+=K;
    else now*=2;
  }
  op(now)
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
# N, X, T = map(int, input().split())
from functools import reduce
N = int(input())
An = list(map(int, input().split()))

b = 0
sum = 0

for i in range(N):
  if An[i] > b : 
    b = An[i]
  else:
    sum += b - An[i]

print(sum)

Measured memory_bytes: 33528
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  cin >> str;
  cout << ((str.substr(2,1) == str.substr(3,1)) && (str.substr(4,1) == str.substr(5,1)) ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long int;
using namespace std;

int main() {
    fastIO;
    lint a, b;
    cin >> a >> b;
    if ((a - b) % 2 == 0)
        cout << abs(a + b) / 2;
    else
        cout << "IMPOSSIBLE";
}

Measured memory_bytes: 3572
import sys
input = sys.stdin.readline
N=int(input())
h = list(map(int, input().split()))#[int(input()) for _ in range(N)]
dp=[0]+[abs(h[1]-h[0])]+[10001]*(N-2)

for i in range(2,N):
    dp[i]=min(
        dp[i-1]+abs((h[i]-h[i-1])),
        dp[i-2]+abs((h[i]-h[i-2]))
    )

print(dp[-1])

Measured memory_bytes: 51348
#include<stdio.h>
#define COUNT_RESET 0
#define LOOP_RESET 0
unsigned short serch_word(unsigned char * str1, unsigned char * str2);
unsigned short s_scan_word(unsigned char * str, unsigned short length_max);

int main(){
	unsigned char str1[10], str2[1000];
	unsigned short long1, long2;
	unsigned short count = 0;
	unsigned char end_sentence[] = {"END_OF_TEXT\n"};
	unsigned short i;
	
	for(i = 0;i < 10;i++){
		str1[i] = 0;
	}
	for(i = 0;i < 1000;i++){
		str2[i] = 0;
	}
	
	long1 = s_scan_word(str1, 1000);
	
	while(1){
		long2 = s_scan_word(str2, 1000);
		if(serch_word(end_sentence, str2) == 1){
			break;
		}
		
		for(i = 0;i < long1;i++){
			str1[i] |= 0x60;
		}
		for(i = 0;i < long2;i++){
			str2[i] |= 0x60;
		}
		if(long1 == long2){
			count += serch_word(str1, str2);
		}
		for(i = 0;i <= long2;i++){
			str2[i] = 0;
		}
	}
	
	printf("%d\n", count);
	return 0;
}

/* 関数名：文字列入力 */
/* 概要：文字列を入力する。入力された文字列の長さを返す */
/* 引数：文字列を格納する配列の先頭アドレス、その配列の大きさ */
/* 戻り値：入力された文字列の長さ */
unsigned short s_scan_word(unsigned char * str, unsigned short length_max)
{
	unsigned short usW_C_count_text = COUNT_RESET;  	/* 文字列長カウンタ */
	unsigned short usW_C_i;                         	/* ループ変数 */

	/* 文字列の入力 */
	for(usW_C_i = LOOP_RESET;usW_C_i < length_max;usW_C_i++){
		scanf("%c", str + usW_C_i);
		/* 入力終了の処理 */
		if((*(str + usW_C_i) == ' ') || (*(str + usW_C_i) == '\n')){
			break;
		}
		/* 文字数をカウント */
		usW_C_count_text++;
	}

	/* 文字列長を返す */
	return usW_C_count_text;
}

unsigned short serch_word(unsigned char * str1, unsigned char * str2)
{
	unsigned char * word = str1, * sent = str2;
	unsigned int frg = 0;
	unsigned int i = 0;
	while(1){
		if(*(word + i) == '\n'){
			frg =1;
		}
		if(*(word + i) != *(sent + i)){
			break;
		}
		i++;
	}
	
	return frg;
}


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

#define ll long long
#define ld long double
#define pi 3.14159265359

int main(){
    int N; cin >> N;
    int X = N % 10;
    if (X == 3) {
        cout << "bon" << endl;
    }
    else if (X == 0 || X == 1 || X == 6 || X == 8) {
        cout << "pon" << endl;
    }
    else {
        cout << "hon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll mod = 1000000007;
ll n, m;
class union_find {
public:
	vector<int>par;
	vector<int>size;

	union_find(int n) : par(n), size(n, 1) {
		for (int i = 0; i < n; i++) {
			par[i] = i;//最初の親は自分自身
		}
	}
	void init(int n) {
		par.resize(n);
		size.assign(n, 1);
		for (int i = 0; i < n; i++) {
			par[i] = i;//最初の親は自分自身
		}
	}
	//木の根を求める
	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = root(par[x]);
		}
	}
	//xとyが同じ集合に属すか否か
	bool same(int x, int y) {
		return(root(x) == root(y));
	}
	//xとyの属する集合を併合
	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y)return false;//根が同じならもう併合済み
		//併合するときは"小さい方"を"大きい方"に併合させる
		if (size[x] < size[y]) {
			swap(x, y);
		}
		size[x] += size[y];
		par[y] = x;
		return true;
	}

	int getSize(int x) {
		return size[root(x)];
	}
};

int main() {
	
	cin >> n >> m;
	int a, b;
	union_find tree(n);
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--; b--;
		if (!tree.same(a, b)) {
			tree.unite(a, b);
		}
	}
	ll count = 0;
	for (int i = 1; i < n; i++) {
		if (!tree.same(0, i)) {
			tree.unite(0, i);
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 4048
number = input().split(" ")
N = int(number[0])
K = int(number[1])
word = input()
words = []
for i in word:
	words.append(i)
if words[K-1] == "A":
	words[K-1] = "a"
elif words[K-1] == "B":
	words[K-1] = "b"
else:
	words[K-1] = "c"
for i in words:
	print(i,end="")

Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;

ll dp[25000000];

int main() {
  ll n, g[2], s[2], b[2], ans = 0LL, a = 0LL;
  scanf("%lld", &n);
  for (int i = 0; i < 2; i++) {
    scanf("%lld%lld%lld", &g[i], &s[i], &b[i]);
  }
  for (int i = 0; i <= n; i++) {
    a = max(a, dp[i]);
    if (i + g[0] <= n) {
      dp[i + g[0]] = max(dp[i + g[0]], dp[i] + g[1] - g[0]);
    }
    if (i + s[0] <= n) {
      dp[i + s[0]] = max(dp[i + s[0]], dp[i] + s[1] - s[0]);
    }
    if (i + b[0] <= n) {
      dp[i + b[0]] = max(dp[i + b[0]], dp[i] + b[1] - b[0]);
    }
  }
  a = max(a, dp[n]) + n;
  for (int i = 0; i <= n; i++) {
    dp[i] = 0LL;
  }
  for (ll i = 0; i <= a; i++) {
    ans = max(ans, dp[i] + a);
    if (i + g[1] <= a) {
      dp[i + g[1]] = max(dp[i + g[1]], dp[i] + g[0] - g[1]);
    }
    if (i + s[1] <= a) {
      dp[i + s[1]] = max(dp[i + s[1]], dp[i] + s[0] - s[1]);
    }
    if (i + b[1] <= a) {
      dp[i + b[1]] = max(dp[i + b[1]], dp[i] + b[0] - b[1]);
    }
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 195456
import java.util.Scanner;

public class Main{
    public  static void main(String[] args) {
    	try (Scanner sc = new Scanner(System.in)) {
    		int N=sc.nextInt();
    		int[] t=new int[100001];
    		int[] x=new int[100001];
    		int[] y=new int[100001];
    		for(int i=0; i<N; i++) {
    			t[i+1]=sc.nextInt();
    			x[i+1]=sc.nextInt();
    			y[i+1]=sc.nextInt();
    		}
    		boolean can=true;
    		for(int i=0; i<N; i++) {
    			int dt=t[i+1]-t[i];
    			int dist=Math.abs(x[i+1]-x[i])+Math.abs(y[i+1]-y[i]);
    			if(dt<dist) {
    				can=false;
    			}
    			if(dist%2!=dt%2) {
    				can=false;
    			}
    		}
    		if(can)	System.out.println("Yes");
    		else	System.out.println("No");
    	}
    }
}

Measured memory_bytes: 90924
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define ll long long

int main() {
    ll d;
    cin >> d;
    ////////
    vector<vector<ll>> s(365, vector<ll>(26, 0));
    vector<int> c(26);
    vector<ll> t(d, 1);
    for(int i = 0; i < 26; i++) cin >> c[i];
    for(int i = 0; i < d; i++) {
        ll tmp = 0;
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
            /*if(tmp < s[i][j]) {
                tmp = s[i][j];
                t[i] = j+1;
            }
            */
        }
    }

    /////////////////
    /*
    for(int i = 0; i < d; i++) {
        t[i] = i+1;
    }
    */
    //for(int i = 0; i < d; i++) cin >> t[i];
    ll mx_v = 0;
    vector<ll> swap_set;
    vector<pair<int, int>> p(d);
    for(int i = 0; i < d; i++) {
        mx_v = -1;
        int ni = i, nj = 0;
        for(int j = 0; j < 26; j++) {
            if(s[i][j] > mx_v) {
                mx_v = s[i][j];
                ni = i;
                nj = j;
            }
        }
        swap_set.push_back(mx_v);
        p[i] = make_pair(ni, nj);
        //p.push_back(make_pair(ni, nj));
    }

    ///////////////
    ll m;
    m = d;
    //cin >> m;
    vector<pair<int, int>> dq(m);
    for(int i = 0; i < m; i++) {
        //cin >> dq[i].first >> dq[i].second;
        dq[i].first = p[i].first+1;
        dq[i].second = p[i].second+1;
        //cout << dq[i].first << " " << dq[i].second << endl;
    }
    vector<ll> ans(d, 0);
    ll v = 0;
    //ll tmp = 0;
    map<ll, ll> mp;
    priority_queue<ll> que;
    vector<vector<ll>> list(m, vector<ll>(d, 1));
    //int num = 0;
    for(int k = 0; k < m; k++) {
        //
        //tmp = t[dq[k].first-1];
        //cout << dq[k].first-1 << " " << t[dq[k].first-1] << endl;
        t[dq[k].first-1] = dq[k].second; 

        /////////////////////
        vector<ll> last(26, 0);
        for(int i = 0; i < d; i++) {
            //if(t[i]-1 >= 26) cout << "t: " << t[i]-1 << endl;
            v += s[i][t[i]-1];//-1
            //v += s[t[i]-1][];
            //v += 
            last[t[i]-1] = i+1;//-1
            for(int j = 0; j < 26; j++) {
                v -= c[j]*((i+1)-last[j]);
            }    
        }
        //cout << v << endl;
        que.push(v);
        mp[v] = k;
        for(int i = 0; i < d; i++) {
            //list[k].push_back(t[i]);
            list[k][i] = t[i];
            //cout << t[i] << endl;
        }
        v = 0;
    }

    //cout << mp[que.top()] << endl;
    //cout << list[0].size() << endl;
    //cout << m << endl;
    ll tmp = que.top();
    for(int i = 0; i < m; i++) {
        //cout << list[mp[que.top()]][i] << endl;
        cout << list[mp[tmp]][i] << endl;
        //cout << que.top() << endl;
        //que.pop();
        /*
        cout << "i: " << i << endl;
        for(int j = 0; j < list[i].size(); j++) {
            cout << list[i][j]+1 << endl;
        }
        */
        
    }

    return 0;
}

Measured memory_bytes: 4772