akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;

int check(char c1, char c2){
	if(c1=='(' && c2==')') return 1;
	if(c1==')' && c2=='(') return 1;
	if(c1=='i' && c2=='i') return 1;
	if(c1=='w' && c2=='w') return 1;
	return 0;
}

bool solve(){
	string str;
	cin>> str;
	int n = str.size();
	int ans=0;
	for(int i=0; i < n/2 ;i++){
		if(!check(str[i],str[n-1-i])){
			ans++;
		}
	}
	if( n%2 && (!(str[n/2]=='i' || str[n/2]=='w')) ) {
		ans++;
	}

	cout<< ans<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    ll ans = 0; 
    for(int a = 1; a <= N; ++a){
        if((2*a)%K != 0) continue;
        int upper = (N+a)/K;
        int lower = (a+1+K-1)/K;
        int tmp = upper - lower;
        if(tmp < 0) continue;
        tmp++;
        ans += (ll) tmp*tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll INF = (1 << 30);
const ll inf = (1LL << 50LL);
const int  maxn = 1e5 + 5;
ll n, W;
ll weights[maxn], values[maxn];
ll dp[105][maxn];
ll rek(ll at, ll weight){
    if(weight == 0){
        return 0;
    }
    if(at == -1) return 0;
    if(dp[at][weight] != -1){
        return dp[at][weight];
    }
    ll ret = 0;
    if(weights[at] <= weight){
        ret = max(ret, rek(at - 1, weight - weights[at]) + values[at]);
    }
    ret = max(ret, rek(at - 1, weight));
    return dp[at][weight] = ret;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> n >> W;
    for(int i = 0; i < n; i ++){
        cin >> weights[i] >> values[i];
    }
    memset(dp, -1, sizeof dp);
    cout << rek(n - 1, W) << endl;
    return 0;
}


Measured memory_bytes: 82304
import java.io.*;
public class Main {
    public static void main(String args[]) {
        
        BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
        try {
            int x = 0;
            String str = input.readLine();
            x = Integer.parseInt(str.trim());
            System.out.println(x*x*x);
        } catch(IOException e) {
        }
    }
}

Measured memory_bytes: 24152
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=200000+5;
typedef unsigned long long LL;
int n,x,a[maxn];
LL suf[maxn];
int main(){
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=n;i>=1;i--)suf[i]=suf[i+1]+a[i];
	LL ans=-1;
	for(int k=1;k<=n;k++){
		LL s=1ll*(n+k)*x;
		int j=n-k+1,t;
		s+=5*suf[j];j-=k;
		for(t=2;j>=1;j-=k,t++)s+=(2*t+1)*(suf[j]-suf[j+k]);
		s+=(2*t+1)*(suf[1]-suf[j+k]);
		if(ans==-1)ans=s;
		else ans=min(ans,s);
	}
	printf("%lld",ans);
	return 0; 
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <map>

using namespace std;

void calc(int n, int i, const string &s, map<string, int> &m) {
  string s1, s2;
  for (int j = n-1; j >= 0; --j) { 
    int mask = 1<<j;
    if (mask & i) s1 += s[j];
    else s2 += s[j]-32;
  }
  m[s1+s2] += 1;
  // cerr << s1 << " " << s2 << endl;
};

typedef long long ll;
int main() {
  int n; cin >> n;
  string s; cin >> s;
  string s1, s2;
  for (int i = 0; i < n; ++i) { 
    s1 += s[i];
    s2 += s[2*n-1-i];
  }
  map<string, int> m1, m2;
  int n2 = 1<<n;
  for (int i = 0; i < n2; ++i) { 
    calc(n, i, s1, m1);
    calc(n, i, s2, m2);
  }
  ll ans = 0;
  for (auto it : m1) {
    // cerr << it.first << " " << it.second << endl;
    auto it2 = m2.find(it.first);
    if (it2 == m2.end()) continue;
    ans += (ll)it.second*(ll)it2->second;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 70656
#define DEBUG 1
#include <bits/stdc++.h>
using namespace std;
typedef          char      s8;
typedef unsigned char      u8;
typedef          short    s16;
typedef unsigned short    u16;
typedef          int      s32;
typedef unsigned int      u32;
typedef          long int s64;
typedef unsigned long int u64;
typedef float             f32;
typedef double            f64;
#define rep(_i, _n) for (int _i = 0; _i < (int)(_n); _i++)
#if DEBUG
#define PHERE()			{ cerr << "L" << setw(3) << __LINE__ << ": PHERE" << clock() << endl; }
#define PVAL( _var )	{ cerr << "L" << setw(3) << __LINE__ << ":" << #_var "=" << (_var) << endl; }
#else
#define PHERE()
#define PVAL( _var )
#endif


int main()
{
	//////// 入力 ////////
	int N;
	cin >> N;
	
	unordered_map<s32, s32> valCount;
	rep( i, N ) {
		s32 A;
		cin >> A;
		auto it = valCount.find( A );
		if( it == valCount.end() ) {
			valCount.insert( pair<s32, s32>(A, 1) );
		}
		else {
			it->second += 1;
		}
	}
	
	int Q;
	cin >> Q;
	/////////////////////
	
	s64 sum = 0;
	for( const auto& it : valCount ) {
		sum += it.first * it.second;
	}
	
	rep( i, Q ) {
		int B, C;
		cin >> B >> C;
		
		s64 addVal = 0;
		auto itBef = valCount.find( B );
		if( itBef != valCount.end() ) {
			addVal = (C - B) * itBef->second;
			
			auto itAft = valCount.find( C );
			if( itAft == valCount.end() ) {
				// 変更後の値はほかに無い
				valCount.insert( pair<s32, s32>(C, itBef->second) );
				valCount.erase( itBef );
			}
			else {
				// 変更後の値が既にある
				itAft->second += itBef->second;
				valCount.erase( itBef );
			}
		}
		
		//////// 出力 ////////
		sum += addVal;
		cout << sum << endl;
		/////////////////////
	}
	
	return 0;
}


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

int main() {
  bool cards[4] [13];
  int n, rank;
  char suit;
  char suits[5] = "SHCD";

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      cards[i][j] = 0;
    }
  }

  cin >> n;

  for (int k = 0; k < n; k++) {
    cin >> suit >> rank;
    if (suit == 'S') cards[0][rank - 1] = 1;
    if (suit == 'H') cards[1][rank - 1] = 1;
    if (suit == 'C') cards[2][rank - 1] = 1;
    if (suit == 'D') cards[3][rank - 1] = 1;
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      if (cards[i][j] == 0) cout << suits[i] << " " << j + 1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<double>x(N);
  vector<string> u(N);
  double JPY=0,BTC=0;
  
  for(int i=0;i<N;i++){
    cin>>x.at(i)>>u.at(i);
    if(u.at(i)=="JPY")
      JPY+=x.at(i);
    if(u.at(i)=="BTC")
      BTC+=x.at(i);
  }
  cout<<JPY+BTC*380000;
}

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

int main(){
  int D;
  cin>>D;
  
  if(D==25){
    cout<<"Christmas"<<endl;
  }
  else if(D==24){
    cout<<"Christmas Eve"<<endl;
  }
  
    else if(D==23){
      cout<<"Christmas Eve Eve"<<endl;
    }
  else if(D==22){
    cout<<"Christmas Eve Eve Eve"<<endl;
  }
}
    


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

int h, a, ans;

int main() {
  cin >> h >> a;

  if (h % a == 0) {
    ans = h / a;
  } else {
    ans = h / a + 1;
  }

  printf("%d", ans);

  return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a,b,k;
    cin >> a >> b >> k;
    ll sub = min(a , k);
    a-=sub;
    k-=sub;
    cout << a << ' ' << b - min(b , k) ;
    
    
    
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main{

public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = sc.nextInt();
  int c = sc.nextInt();
  int cnt=0;

  for(int i = a; i<=b; i++){
    if(c%i == 0){
      cnt++;
    }
  }
System.out.println(cnt);

}

}


Measured memory_bytes: 26264
import java.util.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int g=0;
		for(int i=1;i<=b;i++){
			if(a*i%b==c) {
				g=1;
				break;
			}
		}
		if(g==0)System.out.println("NO");
		else System.out.println("YES");
	}
}

Measured memory_bytes: 21972
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "string"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < (n); i++)

int main() {
	int n;
	cin >> n;
	int p = 1;
	while (p * (p + 1) < n * 2) ++p;
	for (int i = p; i > 0; --i) {
		if (n >= i) {
			cout << i << endl;
			n -= i;
		}
	}
	return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,m,X,Y;
  cin >> n >> m >> X >> Y;
  vector<int> x(n),y(m);
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  for(int i=0;i<m;i++){
    cin >> y[i];
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  if(x[x.size()-1]<y[0]){
    if(X<y[0]&&x[x.size()-1]<Y) cout << "No War\n";
    else cout << "War\n";
  }
  else cout << "War\n";
  return 0;
}


Measured memory_bytes: 256
n=int(input())
data=list(map(str,input().split()))
if(len(data)==1):
    print(data[0])
else:
    newdata = data[::2][::-1]+data[1::2]
    if n%2==0:
        print(' '.join(newdata[::-1]))
    else:
        print(' '.join(newdata))



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

using namespace std;

int main() {

	long long x,y;
	cin >> x >>y ;

	if (x < 1) { x = 1; }

	int counter = 0;
	while (x <= y) {
		x *= 2;
		counter++;
	}
	cout << counter << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,n,k,p,r;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&k,&p);
		r=k%p;
		if(r==0){
			r=p;
		}
		printf("%d\n",r);
	}
	return 0;
}

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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    if(n >= b) {
        cout << a * (b - 1) / b << endl;
    } else {
        cout << a * n / b << endl;
    }
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

template <class T>
inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int n,res=100;

int findSumOfDigits(int n){
    int sum = 0;
    while (n > 0){
        sum += n%10;
        n /= 10;
    }
    return sum;
}

int main(){ 
    cin >> n;
    for (int i=1;i<n;++i){
        int a = i, b=n-i;
        int sum_a = findSumOfDigits(a);
        int sum_b = findSumOfDigits(b);
        if (sum_a+sum_b<res) res=sum_a+sum_b;
    }
    cout << res << endl; 
}

Measured memory_bytes: 256
/*
 
anchal24
 
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define INF 1000000000  
#define MOD 1000000007
#define M 998244353
#define N 1000010
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define trr(c,i) for(typeof((c).rbegin() i = (c).rbegin(); i != (c).rend(); i++)
 
# define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
 
//Variables Start
 
//Variables End
 
ll modularExponentiation(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%MOD,n/2);
    else                             //n is odd
        
        return (x*modularExponentiation((x*x)%MOD,(n-1)/2))%MOD;
 
}
ll modInverse(ll n) 
{ 
    return modularExponentiation(n,MOD-2); 
}

int main()
{
        ios;
    ll s;
    ll sum=0;

        cin>>s;
    
   for(ll i=1; i<=s;i++)
    	{
    		if(i%3==0 || i%5==0)
    		{}
    			else sum=sum+i;
    	}
    
    
    
    cout<<sum;
    
   
     return 0;
}


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

using namespace std;

int main(){
   long long a,b,k,z,y,nilai1,nilai2;
   scanf("%lld %lld %lld", &a,&b,&k);
   getchar();
   if(a<=k){
      nilai1=0;
      nilai2=b-k+a;
      if(nilai2<0){
         nilai2=0;
      }
   }
   else{
      nilai1=a-k;
      nilai2=b;
   }
   cout<<nilai1<<" "<<nilai2<<endl;
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const ll MAX_N = 1e5 + 10;
vector<pair<ll, ll> > g[MAX_N];
ll cost[MAX_N], dp[MAX_N];

void dfs(ll x, ll p) {
    for(auto it : g[x]) {
        if(it.first == p) {continue;}
        dp[it.first] = dp[x] + it.second;
        dfs(it.first, x);
    }
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin >> n;
    for(ll i = 0; i < n - 1; i ++) {
        ll a, b, c;
        cin >> a >> b >> c;
        g[a].push_back({b, c});
        g[b].push_back({a, c});
    }
    dfs(1, 0);
    for(int i = 1; i <= n; i ++) {
        cout << (dp[i] & 1) << endl;
    }
    return 0;
}



Measured memory_bytes: 13288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 100010;
int n, m, x[M], b[M], a[M], tmp[M], ans[M], t;
ll k;
bool vis[M];
int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n;i++) {
        scanf("%d", &x[i]);
    }
    scanf("%d%lld", &m,& k);
    for (int i = 1; i < n;i++) {
        b[i] = i;
    }
    for (int i = 1; i <= m;i++) {
        scanf("%d", &a[i]);
        swap(b[a[i]], b[a[i] - 1]);
    }
    for (int i = 1; i < n;i++) {
        if(vis[i]) {
            continue;
        }
        vis[i] = 1;
        t = 1;
        tmp[t] = i;
        for (int j = b[i]; j != i;j=b[j]) {
            vis[j] = 1;
            tmp[++t] = j;
        }
        int tt = k % t;
        for (int j = 1; j <= t;j++) {
            ans[tmp[j]] = tmp[(j - 1 + tt) % t + 1];
        }
     }
     ll sum = x[1];
        printf("%lld\n", sum);
        for (int i = 1; i < n;i++) {
            sum += x[ans[i] + 1] - x[ans[i]];
            printf("%lld\n", sum);
        }
        return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const int N=2e5+5;
ll A[N],B[N];
ll n,m;
ll cal(ll);
 
void init();
void work();
ll cal1(ll);
ll ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    ll k;
    cin>>n>>k;k=(ll)n*(n-1)-k*2+1;
    for(int i=1;i<=n;i++) cin>>A[i];m=n;
    for(int i=1;i<=n;i++) B[i]=A[i];
    sort(B+1,B+m+1);
    ll l=-1e18-100,r=1e18+100,mid;
    while(l<r){
        mid=(l+r+1)/2;
        if(cal(mid)-cal1(mid)>=k) l=mid;
        else r=mid-1;
    }
    cout<<l;
}
ll cal1(ll x)
{
	ll ans=0;
	for(int i=1;i<=n;i++)if(A[i]*A[i]>=x)ans++;
	return ans;
}
ll cal(ll x){
    ll re=0;
    for(int i=1;i<=n;i++){
        if(A[i]==0){
            re+=x>0?0:m;
        }else if(A[i]>0){
            ll t=ceil((long double)x/A[i]);
            re+=m-(lower_bound(B+1,B+m+1,t)-B-1);
        }else{
            ll t=floor((long double)x/A[i]);
            re+=upper_bound(B+1,B+m+1,t)-B-1;
        }
    }
    return re;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define faf ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define nt _int128
 
long double PI =3.14159265358979323846;
 
 
ll modo=1e9+7;
const ll inf=1e13;
const ll ms=1e5 +5;

int dp[105][100005]={false};
ll ar[105][2];
int main()
{
    faf;
    ll n;
    ll w;
    cin>>n>>w;
    int i;
    for(i=1;i<=n;i++)
    {
     cin>>ar[i][0]>>ar[i][1];   
    }
      int lim=1e5;
    int j;
    for(i=0;i<=n;i++)for(j=0;j<=lim;j++)dp[i][j]=-1;
    
    dp[0][0]=0;
  
    int pp;
    int kk;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<=lim;j++)
        {
            if(dp[i-1][j]!=-1)
            {
                dp[i][j]=true;
                dp[i][j]=dp[i-1][j];
            }
        }
        for(j=0;j<=lim;j++)
        {
            if(dp[i-1][j]!=-1)
            {
              kk=j+ar[i][1];
              
             
              pp=dp[i-1][j]+ar[i][0];
              if(pp<=w){
              if(dp[i][kk]==-1)
              {
                  dp[i][kk]=pp;
              }
              else
              {
                  dp[i][kk]=min(dp[i][kk],pp);
              }
              }
            }
        }
    }
    int ans=0;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=lim;j++)
        {
            if(dp[i][j]!=-1)ans=max(ans,j);
        }
    }
  
    cout<<ans;
    
    
    return 0;
}

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

using namespace std;

const int maxn = 1e5 + 7;

int ac[maxn];
int wa[maxn];

int main()
{
    int n, m;
    cin >> n >> m;
    int correct = 0, penalty = 0;
    for (int i = 0; i < m; i++)
    {
        int x;
        string s;
        cin >> x >> s;
        if (!ac[x])
        {
            if (s == "WA")
            {
                wa[x]++;
            }
            else
            {
                ac[x] = 1;
                correct++;
                penalty += wa[x];
            }
        }
    }

    cout << correct << " " << penalty << endl;
}

Measured memory_bytes: 1024
n = int(input())
a = [0] + list(map(int,input().split())) + [0]

S = 0
for i in range(1,n+2):
    S += abs(a[i] - a[i-1])

for i in range(1,n+1):
    result = S + abs(a[i-1] - a[i+1]) - abs(a[i-1] - a[i]) - abs(a[i+1] - a[i])
    print(result)

Measured memory_bytes: 20508
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll N;
    cin >> N;
    ll T, A;
    cin >> T >> A;
    vector<ll> H(N);
    ll ind = -1;
    double min_diff = INF;
    for(size_t i=0;i<N; i++)
    {
        cin >> H[i];
        double degree_diff = double(abs(T - 0.006*H[i] - A));
        if(min_diff > degree_diff)
        {
            min_diff = min(min_diff, degree_diff);
            ind=i;
        }
    }
    cout << ind+1 << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3608
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	return scanInt(sc)
}

func resolve(n int) int {
	return lucas(n)
}

func lucas(n int) int {
	v := make([]int, n+1)
	v[0], v[1] = 2, 1
	for i := 2; i <= n; i++ {
		v[i] = v[i-1] + v[i-2]
	}
	return v[n]
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    char[] me = s.toCharArray();
    int east = 0;
    for(int i = 1 ; i < n ; ++i){
      if(me[i]=='E') east++;
    }
    //System.out.println(east);
    
    int min = east;
    for(int i = 1 ; i < n ; ++i){
      if(me[i]=='E') east--;
      //else west++;
      if(me[i-1]=='W') east++;
      //else west--;
      //System.out.println(east);
      min = Math.min(min,east);
    }
    

    System.out.println(min);
    
  }
}

Measured memory_bytes: 42996
n,a,b,c,d=map(int,input().split())
s=input()
if s[a-1:max(c,d)].count("##")>0:
    print("No")
elif c<d:
    print("Yes")
else:
    if "..." in s[b-2:d+1]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3572
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 10000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int n;
	cin >> n;
	int isprime[1000] = { };
	FOR(i, 2, 1000){
		for(int j = 2; j * j <= i; j++){
			if(i % j == 0) isprime[i] = 1;
		}
	}
	ll ans = 1;
	FOR(i, 2, 1000){
		if(isprime[i] == 0){
			ll tmp = 0;
			ll x = n;
			while(x != 0){
				tmp += (x / i);
				x /= i;
			}
			ans = (ans * (tmp + 1)) % MOD;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import math
A,B,C=[],[],[]
for i in range(5):
  a=int(input())
  A.append(a)
  B.append(a%100%10)
B=[9 if i==0 else i for i in B]
C=list(map(lambda x:math.ceil(x/10)*10,A))
print(sum(C)-C[B.index(min(B))]+A[B.index(min(B))])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ht,st,ha,sa;
    cin>>ht>>st>>ha>>sa;
    int f=1;
    while(ht>0&&ha>0)
    {
        if(f)
        {
            ha=ha-st;
            f=0;
        }
        else
        {
            ht=ht-sa;
            f=1;
        }
        
    }
    if(ht>0)
    cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
	int a,b;
	while(cin>>a>>b){
		if(a<b){
			cout<<"a < b"<<endl;
		}else if(a>b){
			cout<<"a > b"<<endl;
		}else if(a==b){
			cout<<"a == b"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3024
#include<stdio.h>
int min(int a,int b){
  if(a>b){
    return b;
  }else{
    return a;
  }
}
int main(void)
{
  int p,q,r;
  scanf("%d %d %d",&p,&q,&r);

  printf("%d\n",min(q+r,min(p+q,p+r)));
  return 0;
}


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

long long n;
vector<long long> a, b;
priority_queue<pair<int, int>> pq;

long long solve();

int main() {
  cin >> n;
  a.resize(n);
  b.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i) cin >> b[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long cnt = 0;
  for(int i = 0; i < n; ++i)
    if(b[i] != a[i]) pq.push({b[i] - a[i], i});
  while(!pq.empty()) {
    pair<int, int> now = pq.top();
    pq.pop();
    if(now.first == 0) break;
    long long mnum = b[(now.second + 1) % n] +
                     b[(now.second - 1 + n) % n],
              nowc;
    nowc = (b[now.second] - a[now.second]) / mnum;
    cnt += nowc;
    b[now.second] -= nowc * mnum;
    if(nowc <= 0) return -1;
    if(b[now.second] == a[now.second]) continue;
    pq.push({b[now.second] - a[now.second], now.second});
  }
  return cnt;
}


Measured memory_bytes: 5620
n = int(input())
def factorize(n):
    b = 2
    fct = [(1,1)]
    while b * b <= n:
        cnt =0
        while n % b == 0:
            n //= b
            cnt +=1
        if cnt >=1:
            fct.append((b,cnt))
        b = b + 1
    if n > 1:
        fct.append((n,1))
    return fct

primes = [0]*(n+1)
for i in range(1,n+1):
    for num,cnt in factorize(i):
        if num==1:continue
        primes[num] +=cnt
ans = 1
mod = 10**9+7
for cnt in primes:
    ans = ans*(cnt+1)%mod
print(ans)


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

using namespace std;

typedef unsigned long long ullong;

const long M = 1000000007;

ullong power(ullong n, ullong m) {
	if (m == 0)
		return 1;

	ullong res = power(n, m / 2);
	if (m % 2 == 0) {
		res = res * res % M;
	} else {
		res = (res * res % M) * n % M;
	}

	return res;
}

int main() {

	int m, n;
	scanf("%d %d", &m, &n);

	cout << power(m, n) << endl;

	return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
const int oo = 0x3f3f3f3f;
int a , b , c , x , y;
int main(){
	cin >> a >> b >> c >> x >> y;
	int ans = 2 * oo;
	for(int i = 0 ; i <= max(2 * x , 2 * y) ; i += 2){
		int la = max(0 , x - i / 2);
		int lb = max(0 , y - i / 2);
		ans = min(ans , la * a + lb * b + i * c);
	} 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
w = gets.to_i

lines = []
result = []
gets.to_i.times { lines << gets.split(',').map(&:to_i) }

1.upto(w) do |i|
  position = i
  lines.each do |line|
    if line[0] == position
      position = line[1]
      next
    end

    if line[1] == position
      position = line[0]
      next
    end
  end

  result[position-1] = i
end

result.each { |r| puts r }



Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int N;
vector<vector<int>> memo( 100 + 1, vector<int>( 10000 + 1, -1 ) );
vector<int> vc;
int dfs( int i, int sum )
{
    if( sum % 10 != 0 )
    {
        return sum;
    }
    int &res = memo[ i ][ sum ];
    if( res != -1 )
    {
        return res;
    }
    if( i == 0 )
    {
        return sum == 0;
    }
    return res = max( dfs( i - 1, sum ), dfs( i - 1, sum - vc[ i - 1 ] ) );
}
int main()
{
    cin >> N;
    vc.resize( N );
    for( auto &x : vc )
    {
        cin >> x;
    }
    cout << dfs( N - 1, accumulate( ALL( vc ), 0 ) ) << endl;
    return 0;
}

Measured memory_bytes: 4224
# = map(int, input().split())
n = int(input())
# = input()
# = list(map(int, input().split()))

to = 0
for i in range(n):
	x, u = map(str, input().split())
	if u == "JPY":
		to += int(x)
	elif u == "BTC":
		to += float(x)*380000

print(to)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
#define INF (1 << 29)
using namespace std;
typedef long long ll;

int main() {
  int N; cin >> N;
  int p[N]; rep(i, N) {cin >> p[i]; p[i]--;};

  int result = 0;
  rep(i, N) if (p[i] == i) {
    result ++;
    if (i!=N-1) swap(p[i], p[i+1]);
    else swap(p[i], p[i-1]);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll M = 1e9 + 7;
const int iinf = 1 << 29;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mrand(ll B) {
  return (ull)rng() % B;
}

void work() {
    ll n; cin>>n;
    vector<bool> sieve(2e6, true);
    vector<ll> primes;
    for (int i = 2; i < sieve.size(); ++i) {
        if (sieve[i]) {
            primes.push_back(i);
            for (int j = i * i; j < sieve.size(); j += i)
                sieve[j] = false;
        }
    }
    vector<ll> cnt;
    ll orig_n = n;
    for (auto p : primes) {
        if (p * p > orig_n) break;
        if (n % p != 0) continue;
        cnt.push_back(0);
        while (n % p == 0) {
            ++cnt.back();
            n /= p;
        }
    }
    if (n != 1) cnt.push_back(1);
    
    ll ans = 0;
    for (auto e : cnt) {
        for (ll i = 1; i <= e; ++i) {
            e -= i;
            ++ans;
        }
    }
    if (ans == 0 && orig_n > 1LL)
        cout << "1\n";
    else
        cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}


Measured memory_bytes: 5576
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

li n, dp[100007][3], a[100007][3];

int main () {
    fastIO;
    cin >> n;
    dp[0][0]=0;
    dp[0][1]=0;
    dp[0][2]=0;
    for(li i = 0; i < n; i ++) cin >> a[i][0] >> a[i][1] >> a[i][2];
    for(li i = 0; i < n; i ++) {
        dp[i+1][0] = max(dp[i+1][0], max(dp[i][1], dp[i][2])+a[i][0]);
        dp[i+1][1] = max(dp[i+1][1], max(dp[i][0], dp[i][2])+a[i][1]);
        dp[i+1][2] = max(dp[i+1][2], max(dp[i][0], dp[i][1])+a[i][2]);
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]});
}


Measured memory_bytes: 4992
#ABC167-C
import itertools
flg = True
n,m,x = map(int,input().split())
algo = []
tmp = []
for _ in range(n):
    algo.append(list(map(int,input().split())))
    
book = list(itertools.product([0,1],repeat=n))
abi = [0 for _ in range(m)]

for pattern in book:
    #値の初期化
    abi = [0 for _ in range(m)]
    money = 0
    flg = True
    
    for i in range(len(pattern)):
        for j in range(m):
            abi[j] += algo[i][j+1] * pattern[i]
        money += algo[i][0] * pattern[i]
        
    abi_min = [p for p in abi if p < x]
        
    if len(abi_min) != 0:
        flg = False
    if flg:
        tmp.append(money)

if len(tmp) > 0:
    print(min(tmp))
else:
    print(-1)
        
        
        
        
                
            

Measured memory_bytes: 9860
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n

let f k = let t = n / k in t * (t + 1) / 2* k 

let () = Printf.printf "%d\n" @@ Array.fold_left (+) 0 @@ Array.init n @@ fun i -> f (i + 1)



Measured memory_bytes: 83068
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N, K; cin >> N >> K;
  int a[N]; rep(i,N) cin >> a[i];
  

  rep(j,min(K,1000)){
    vector<int> b(N+1,0);
    rep(i,N){
      if (i-a[i]<0) b[0]++;
      else b[i-a[i]]++;

      if (i+a[i]+1<=N) b[i+a[i]+1]--;
      else b[N]--;
    }
    rep(i,N){
      if (i==0) a[i] = b[i];
      else a[i] = a[i-1] + b[i];
    }
    
  }

  rep(i,N) {
    if (i>0) cout << " ";
    cout << a[i];
  }
  cout << endl;
  
  
  

  
  
  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 5140
A = [0,0,0,1,1,1]
s = int(input())
if s < 6:
    print(A[s])
else:
    for i in range(6,s+1):
        a = 1
        for j in range(3,i-2):
            a += A[j]
        A.append(a)
    print(A[s]%(10**9 + 7))
            

Measured memory_bytes: 9292
while true
  n, q = gets.chomp.split(" ").map(&:to_i)
  break if n == 0 && q == 0
  a = Array.new(101, 0)
  n.times do
    m, *d = gets.chomp.split(" ").map(&:to_i)
    m.times do |i|
      a[d[i]] += 1
    end
  end
  if a.max >= q then
    puts a.index(a.max)
  else
    puts 0
  end
end

Measured memory_bytes: 9088
n,m=[int(j) for j in input().split()]
a=[-int(j) for j in input().split()]
import heapq
heapq.heapify(a)
for i in range(m):
    p=heapq.heappop(a)
    p=(-p)//2
    heapq.heappush(a,-p)
print(-sum(a))

Measured memory_bytes: 14252
#include <iostream>

int main() {
	int array[5];

	for (auto& a : array)
	{
		std::cin >> a;
	}
	
	for (size_t i = 0; i < 4; i++)
	{
		int* pMax = &array[i];
		for (size_t j = i +1 ; j < 5; j++)
		{
			if (*pMax < array[j])
			{
				int tmp = *pMax;
				*pMax = array[j];
				array[j] = tmp;	
			}
		}
	}

	std::printf("%d %d %d %d %d\n", array[0], array[1], array[2], array[3], array[4]);

	return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  cin >> N;
  
  int num = N - 1;
  
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(num);
  
  int num2 = 0;
  
  int num3;
  
  for(int i = 0;i < N;++i){
    cin >> A[i];
  }
  
  for(int i = 0;i < N;++i){
    cin >> B[i];
  }
  
  for(int i = 0;i < num;++i){
    cin >> C[i];
  }
  
  for(int i = 0;i < N;++i){
    num2 = B[i] + num2;
  }
  
  for(int i = 0;i < N;++i){
    if(A[i] + 1 == A[i + 1]){
      num3 = A[i] - 1;
      num2 = C[num3] + num2;
    }
  }
  
  cout << num2 << endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        for(int i=1; i<=10000; i++){
            int[] xy = {sc.nextInt(), sc.nextInt()};
            if(xy[0]==0 && xy[1]==0) break;
            Arrays.sort(xy);
            System.out.println(xy[0] + " " + xy[1]);
            
        }
    }
}



Measured memory_bytes: 35952
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

int main(){
  int a,b;
  cin >> a >> b;
  if (a>b) {
    cout << a-1;
  } else {
    cout << a;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	int H = in.nextInt(), W = in.nextInt();
	in.nextLine();
	char[][] board = new char[H][];
	for (int i = 0; i < H; i++) {
	    board[i] = in.nextLine().toCharArray();
	}
	int[][] rows = new int[H][W], cols = new int[H][W];
	for (int i = 0; i < H; i++) {
	    for(int j = 0; j < W; j++) {
		int cnt = 0;
		while(j + cnt < W && board[i][j + cnt] != '#') {
		    cnt++;
		}
		for(int k = 0; k < cnt; k++) {
		    rows[i][j + k] = cnt;
		}
		j += cnt;
	    }
	}
	for (int i = 0; i < W; i++) {
	    for(int j = 0; j < H; j++) {
		int cnt = 0;
		while(j + cnt < H && board[j + cnt][i] != '#') {
		    cnt++;
		}
		for(int k = 0; k < cnt; k++) {
		    cols[j + k][i] = cnt;
		}
		j += cnt;
	    }
	}
	int max = 0;
	for(int i = 0; i < H; i++) {
	    for(int j = 0; j < W; j++) {
		max = Math.max(max, rows[i][j] + cols[i][j] - 1);
	    }
	}
	System.out.println(max);
    }
}



Measured memory_bytes: 95048
#include<iostream>
#include<vector>
#include<algorithm>

int main(){
  int N, K;
  std::cin >> N >> K;
  std::vector<int> l(N);
  for(int i = 0; i < N; i++) std::cin >> l.at(i);
  sort(l.begin(), l.end());
  int length = 0;
  for(int i = 0; i < K; i++) length += l.at(N - 1 - i);
  std::cout << length << std::endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	//0032 starting
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		int ds = Integer.parseInt(sc.nextLine());
		while(ds-- > 0){
			StringBuilder s = new StringBuilder(sc.nextLine());
			int pos = 0;
			int q = Integer.parseInt(sc.nextLine());
			while(q-- > 0){
				String com = sc.nextLine();
				String [] coms = com.split(" ");
				switch (coms[0].charAt(0)) {
				case 'f':
					if(coms[1].charAt(0) == 'c'){
						pos++;
						if(pos > s.length()) pos--;
					}
					else{
						pos = findFW(s, pos);
					}
					break;
				case 'b':
					if(coms[1].charAt(0) == 'c'){
						pos--;
						if(pos < 0) pos = 0;
					}
					else{
						pos = findBW(s, pos);
					}
					break;
				case 'i':
					String temp = com.substring(7);
					s.insert(pos, temp.replaceAll("\"", ""));
					pos += temp.length() - 2;
					break;
				case 'd':
					if(coms[1].charAt(0) == 'c'){
						if(pos != s.length()){
							s.deleteCharAt(pos);
						}
					}
					else{
						int res = findFW(s, pos);
						boolean flg = false;
						for(int i = pos; i <= res; i++){
							if(i == s.length())continue;
							if(s.charAt(i) != ' '){
								flg = true;
							}
						}
						if(flg){
							s.delete(pos, res);
						}
					}
					break;
				default:
					break;
				}
			}
			
			//print
			s.insert(pos, '^');
			System.out.println(s.toString());
		}
	}

	private int findFW(StringBuilder s, int pos) {
		if(s.length() == pos) return pos;
		int nowpos = pos;
		if(s.charAt(pos) == ' '){
			for(int i = pos; i < s.length(); i++){
				if(s.charAt(i) != ' '){
					nowpos = i;
					break;
				}
			}
			if(nowpos == pos){
				return s.length();
			}
		}
		for(int i = nowpos; i < s.length(); i++){
			if(s.charAt(i) == ' '){
				return i;
			}
		}
		return s.length();
	}

	private int findBW(StringBuilder s, int pos) {
		if(pos == 0) return pos;
		int nowpos = pos-1;
		if(s.charAt(nowpos) == ' '){
			for(int i = nowpos; i >= 0; i--){
				if(s.charAt(i) != ' '){
					nowpos = i;
					break;
				}
			}
			if(nowpos == pos-1){
				return 0;
			}
		}
		for(int i =nowpos; i >= 0; i--){
			if(s.charAt(i) == ' '){
				return i + 1;
			}
		}
		return 0;
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 12000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int cnt = 0;
            string s = Console.ReadLine();
            string t = Console.ReadLine();


            if (s[0] == t[0])
            {
                cnt++;
            }
            if (s[1] == t[1])
            {
                cnt++;
            }
            if (s[2] == t[2])
            {

                cnt++;
            }
            Console.WriteLine(cnt);
        }
        
    }
}


Measured memory_bytes: 11092
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
vector<pair<ll, ll>> primeFac(ll n) {
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) != t.at(i)) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3852
$memo6 = []
$memo9 = []

def count6(n)
  $memo6[n] ||= 
  if n < 6
    n
  else
    n % 6 + count6(n / 6)
  end
end

def count9(n)
  $memo9[n] ||= 
  if n < 9
    n
  else
    n % 9 + count9(n / 9)
  end
end

n = gets.to_i
ans = n
(0..n).each do |i|
  tmp = count6(i) + count9(n - i)
  ans = tmp if ans > tmp
end
puts ans

Measured memory_bytes: 3836
#include <iostream>
using namespace std;
#define N 102
struct node
{
	char a;
	bool ok;
} op[N][N];
int main()
{
	int H,W,count;
	while(cin>>H>>W)
	{
		for(int i=0;i<H;i++)
		{
			for(int j=0;j<W;j++)
			{
				cin>>op[i][j].a;
				op[i][j].ok=1;
			}
		}
		for(int i=0;i<H;i++)
		{
			count=0;
			for(int j=0;j<W;j++)
			{
				if(op[i][j].a=='.')
				{
					count++;
				}
			}
			if(count==W)
			{
				for(int j=i;j<H-1;j++)
				{
					for(int k=0;k<W;k++)
					{
						op[j][k].a=op[j+1][k].a;
					}
				}
				H--;
				i--;
			}
		}
		for(int i=0;i<W;i++)
		{
			count=0;
			for(int j=0;j<H;j++)
			{
				if(op[j][i].a=='.')
				{
					count++;
				}
			}
			if(count==H)
			{
				for(int j=i;j<W-1;j++)
				{
					for(int k=0;k<H;k++)
					{
						op[k][j].a=op[k][j+1].a;
					}
				}
				W--;
				i--;
			}
		}
		for(int i=0;i<H;i++)
		{
			for(int j=0;j<W;j++)
			{
				cout<<op[i][j].a;
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N, K = input().split()
N = int(N)
K = int(K)
A_list = [int(i) for i in input().split()]
step = K-1

for ans in range(N):
    if N <= K:
        print(ans+1)
        break
    K += step
    #print(ans)
    #print(N, K)



Measured memory_bytes: 13880
#include <stdio.h>

int main()
{
    int a,b;
    char c;

    while(1){
    scanf("%d %c %d",&a,&c,&b);

    if(c == '+')
    {
        printf("%d\n",a+b);
    }else if(c == '-')
    {
        printf("%d\n",a-b);
    }else if(c == '*')
    {
        printf("%d\n",a*b);
    }else if(c == '/')
    {
        printf("%d\n",a/b);
    }else{
    return 0;
    }
    }
    return 0;
}

Measured memory_bytes: 1028
num=int(raw_input().strip())

lst=map(int,raw_input().strip().split())
def sort(lst,idx):
    tmp=lst[idx]
    idx-=1
    while idx>=0 and lst[idx]>tmp:
        lst[idx+1]=lst[idx]
        idx-=1
    lst[idx+1]=tmp

for ii in xrange(num):
    sort(lst,ii)
    print " ".join(str(i) for i in lst)


Measured memory_bytes: 4648
import java.util.*;
import java.math.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        int[] a = new int[M + 1];
        int[] b = new int[M + 1];

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

        int[] r = new int[N + 1];
        for (int i = 1; i <= M; i++) {
            r[a[i]]++;
            r[b[i]]++;
        }

        for (int i = 1; i <= N; i++) {
            System.out.println(r[i]);
        }

        return;
    }

}

Measured memory_bytes: 22996
/* ----------------------- reclone_rk --------------------------------------------*/ 
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int mod=1e9+7;

#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define prq priority_queue<int>
#define prqp priority_queue<pair<int,int>>
#define vtr vector<int>
#define INF INT_MAX
#define NINF INT_MIN
#define endl "\n"
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define pvtr vector<pair<int,int>>
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)

int gcd(int a, int b){ if(a == 0) return b; return gcd(b%a, a);}
int MOD(int n){ return ((n%mod)+mod)%mod;}
int power(int a,int b){ if(b==0)return 1LL;int s=power(a,b/2LL);s*=s;s%=mod;if(b&1LL)return (s*a)%mod;return s;}
int inv(int a){return power(a,mod-2);}
int nCr(int n,int r){if(r>n)return 0LL;if(n-r<r)r=n-r;int ans=1;for(int i=0;i<r;i++){ans*=(n-i);ans=MOD(ans);ans*=inv(i+1);ans=MOD(ans);}return ans;}

const double pi = 3.14159265358979323846;
signed main()
{   
    int a[5];
    for(int i=0; i<5; i++)
    {
        int val;
        cin>>val;
        if(val == 0)
            cout<<(i+1)<<endl;
        
    }
	return 0;
}

Measured memory_bytes: 3532
H, W = map(int, input().split())
 
ans = 0
 
if H%2==0:
  a = H // 2
  b = H // 2
else:
  a = H // 2 + 1
  b = H // 2

if H==1 or W==1:
  ans = 1
elif W%2==0:
  ans = a * (W // 2) + b * (W // 2)
else:
  ans = a * (W // 2 + 1) + b * (W // 2)

print(ans)


Measured memory_bytes: 61900
#include <stdio.h>

int main() {
	long long n, a, x, ans;

	scanf("%lld\n", &n);
	ans = n;
	for (a = 1; a * a <= n; a++)
		if (n % a == 0) {
			x = a - 1 + n / a - 1;
			if (ans > x)
				ans = x;
		}
	printf("%lld\n", ans);
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    for (int i = 0; i < n; ++i) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    ll ans = 0;
    for (ll i : b) {
        ll p = lower_bound(a.begin(), a.end(), i) - a.begin();
        ll q = n - (upper_bound(c.begin(), c.end(), i) - c.begin());
        ans += p * q;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
n, k = gets.chomp.split.map(&:to_i)
ass = k.times.map do
    gets # skip d
    gets.chomp.split.map(&:to_i)
end

ss = [0] * n
ass.each do |as|
    as.each do |a|
        ss[a-1] = ss[a-1] + 1
    end
end

puts ss.select { |x| x == 0 }.count


Measured memory_bytes: 14352
import math
N,M=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
ls.sort(reverse=True)
x=ls[0]
L=int(math.log2(x))
#2**L より大きいものをわける
def cut(lst,exp):
    for ii in range(len(lst)):
        if ii+1==len(lst):
            break
        if lst[ii+1]<exp:
           break
    return ii
m=M #残り回数
b=-1
ls3=[]
while True:
    if m==0:
        break
    a=b+1
    b=cut(ls,2**L)
    ls2=ls[a:b+1]
    ls3=ls3+ls2
    ls3.sort(reverse=True)
    for j in range(len(ls3)):
        ls3[j]=ls3[j]//2
        m-=1
        if m==0:
            break
    L-=1
#    print(ls3,m,b)
#print(ls3,ls[b+1:])
s=sum(ls3)+sum(ls[b+1:])
print(s)
    

Measured memory_bytes: 14280