akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int n, m, q;
int a[55], b[55], c[55], d[55];
int ans;
void f(int p[])
{
	int v = 0;
	int i;
	for (i = 0; i < q; i++)
		if (p[b[i] - 1] - p[a[i] - 1] == c[i])
			v += d[i];
	if (ans < v)
		ans = v;
	return;
}
void g(int s[], int ss)
{
	if (ss == n)
	{
		f(s);
		return;
	}
	int i;
	if (ss == 0)
	{
		for (i = 1; i <= m; i++)
		{
			s[0] = i;
			g(s, 1);
		}
	}
	else
	{
		for (i = s[ss - 1]; i <= m; i++)
		{
			s[ss] = i;
			g(s, ss + 1);
		}
	}
	return;
}
int main()
{
	scanf("%d%d %d", &n, &m, &q);
	int i;
	for (i = 0; i < q; i++)
		scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);
	ans = 0;
	int s[10];
	g(s, 0);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1708
il = lambda: list(map(int, input().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]
def gcd(a, b):
    if a < b: return gcd(b, a)
    if b == 0: return a
    return gcd(b, a%b)

x, y = il()
a = gcd(x, y)
print(x+y-a+1)


Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>
#include <string>
#include <locale>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
    string str;
    cin >> str;
    int n;
    cin >> n;
    rep(i, n)
    {
        string order;
        int a, b;
        cin >> order >> a >> b;

        if (order == "print")
        {
            string s = str.substr(a, b - a + 1);
            cout << s << endl;
        }
        else if (order == "reverse")
        {
            string::iterator itr = str.begin();
            reverse(itr + a, itr + b + 1);
        }
        else if (order == "replace")
        {
            string p;
            cin >> p;
            string::iterator itr = str.begin();
            str.replace(itr + a, itr + b + 1, p);
        }
    }
}


Measured memory_bytes: 3204
package main

import (
	"fmt"
	"io"
	"os"
)

var (
	reader io.Reader = os.Stdin
	writer io.Writer = os.Stdout
)

func main() {
	run()
}

func run() {
	var a, b int
	fmt.Fscanf(reader, "%d %d", &a, &b)

	if a&b&1 == 1 {
		fmt.Fprintln(writer, "Odd")
	} else {
		fmt.Fprintln(writer, "Even")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cstdlib>
#define _GLIBCXX_DEBUG
using namespace std;
int main()  {
    int N,X,T;
    cin >> N >> X >> T;
    int ans;
    int a;
    if(N%X==0){
        a = 0;
    }
    else{
        a = T;
    }
    ans = (N/X)*T + a;
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include<stdio.h>

int main(void)
{
	int N,T,c,t,i,ansCost=1000,flag=0;
	
	scanf("%d %d",&N,&T);

	for(i=0;i<N;i++){		
		scanf("%d %d",&c,&t);
		
		if(t<=T){
			if(c<ansCost) ansCost=c;
		}else{
			flag++;
		}
	}
	if(flag!=i)printf("%d",ansCost);
	else printf("TLE");

	return 0;
}

Measured memory_bytes: 128
class BinarySearchTree:
    def __init__(self):
        self.root = None
        self.order_list = []
    def insert(self, z):
        y = None
        x = self.root
        while x != None:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y
        if y == None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z
    def find(self, key):
        x = self.root
        while x != None:
            if key == x.key:
                return True
            elif key < x.key:
                x = x.left
            else:
                x = x.right
        return False
            
    def walk_preorder(self, node):
        if node == None:
            return None
        self.order_list.append(node.key)
        self.walk_preorder(node.left)
        self.walk_preorder(node.right)
    def walk_inorder(self, node):
        if node == None:
            return None
        self.walk_inorder(node.left)
        self.order_list.append(node.key)
        self.walk_inorder(node.right)
    def print_nodes(self):
        self.order_list = []
        self.walk_inorder(self.root)
        inorder_str = ' '.join(map(str, self.order_list))
        print(' {}'.format(inorder_str))
        self.order_list = []
        self.walk_preorder(self.root)
        preorder_str = ' '.join(map(str, self.order_list))
        print(' {}'.format(preorder_str))
        
class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None

n = int(input())
tree = BinarySearchTree()
for _ in range(n):
    command = input().split(' ')
    if len(command) == 1:
        tree.print_nodes()
    else:
        opecode, operand = command[0], int(command[1])
        if opecode == 'insert':
            node = Node(operand)
            tree.insert(node)
        elif opecode == 'find':
            exists_key = tree.find(operand)
            if exists_key:
                print('yes')
            else:
                print('no')


Measured memory_bytes: 121636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  if (k <= a) {
    cout << k << endl;
  } else if (a < k && k <= a + b) {
    cout << a << endl;
  } else {
    cout << a - (k - a - b) << endl;
  }
}

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

//+=を=+と打ってもなぜか動作してた

int min(int x,int y){
  if(x<y) return x;
  return y;
}

int max(int x,int y){
  if(x>y) return x;
  return y;
}

const int INF = 1001000000;

int main(){
  int n,x,a[200],total=0,res=0;
  cin >> n >> x;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  for(int j=0;j<n;j++){
    total+=a[j];
  //  cout << "配るのは" <<a[j] <<"totalは" << total<< endl;
    if(total>x){
      res=j;
      break;
    }
    if(total ==x){
      res=j+1;
      break;
    }
  }
  if(total<x)res=n-1;//最後の一人が多くもらう
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;
vector<ll> a;

bool check(int a, int b, int c) {
	return (a<b&&b>c) || (a > b&&b < c);
}

int main() {
	cin >> n;
	a.resize(n);
	ll ans = 0;
	ll pos = 0;
	rep(i, n) {
		cin >> a[i];
		ans += abs(a[i] - pos);
		pos = a[i];
	}
	ans += abs(pos);
	rep(i, n) {
		if (i == 0) {
			if (check(0, a[i], a[i + 1])) {
				cout << ans - abs(a[i]) - (abs(a[i] - a[i + 1])) + abs(a[i + 1]) << endl;
			}
			else cout << ans << endl;
		}
		else if (i == n - 1) {
			if (check(a[i - 1], a[i], 0)) {
				cout << ans - abs(a[i]) - (abs(a[i] - a[i - 1])) + abs(a[i - 1]) << endl;
			}
			else cout << ans << endl;
		}
		else {
			if (check(a[i - 1], a[i], a[i + 1])) {
				cout << ans - abs(a[i] - a[i + 1])
					- (abs(a[i] - a[i - 1])) + abs(a[i - 1] - a[i + 1]) << endl;
			}
			else cout << ans << endl;
		}
	}
}

Measured memory_bytes: 2048
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INI(n) scanf("%d",&n)
#define INL(n) scanf("%lld",&n)
#define INF 10000000000
#define mod 1000000007
#define X 100000
#define N 20
#define M 46
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
void Iswap(int *a,int *b){
  int t=*a;
  *a=*b;
  *b=t;
}
void Fswap(double *a,double *b){
  double t=*a;
  *a=*b;
  *b=t;
}
void Lswap(ll *a,ll *b){
  ll t=*a;
  *a=*b;
  *b=t;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void nCrReady(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (ll i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%mod)%mod;}
ll modpow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}
int main(void){
  int n;
  INI(n);
  char s[n][11];
  FOR(i,n)scanf("%s",s[i]);
  qsort(s,n,sizeof(s[0]),ssort);
  int ans=1;
  FOR(i,n-1){
    if(strcmp(s[i],s[i+1])){
      ans++;
    }
  }
  PRN(ans);
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int sum = 0;
    int max_num = 0;
    rep(i, n) {
        int tmp_num;
        cin >> tmp_num;
        max_num = max(max_num, tmp_num);
        sum += tmp_num;
    }
    if ( max_num < sum - max_num ) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(void){

    ll n, x, m;
    cin >> n >> x >> m;

    vector<int> exist(m, 0);
    exist[x] = 1;
    ll a = x, sum = x;
    ll am, rep = 0;
    for(int i = 2; i <= n; ++i){
        am = (a * a) % m;
        if(exist[am] != 0){
            rep = i;
            break;
        }else{
            a = am;
            sum += am;
            exist[am] = i;
        }
    }

    if(rep == 0){
        cout << sum << "\n";
        return 0;
    }

    ll rep_sum = 0;
    for(int i = exist[am]; i < rep; ++i){
        am = (am * am) % m;
        rep_sum += am;
    }
    sum -= rep_sum;


    n -= exist[am] - 1;
    ll am2 = am;
    ll ans = sum + n / (rep - exist[am]) * rep_sum;
    for(int i = 0; i < n % (rep - exist[am]); ++i){
        ans += am2;
        am2 = (am2 * am2) % m;
        if(am2 < 0) am2 += m;
    }

    cout << ans << "\n";

    return 0;
}


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

int main(){
        int n, m, a;
        vector<int> v;
        string ans = "Yes" ;

        cin >> n >> m;
        float t = 0;
        for (int i = 0; i < n; ++i){
                cin >> a;
                t += a ;
                v.push_back(a);
        }
        sort(v.begin(), v.end());
        if(v[n-m] < t/(4*m)){
                ans = "No";
        }
        cout << ans << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "cmath"

using namespace std;
typedef long long ll;

int main()
{
  unsigned long long a;
  long double b;
  cin >> a >> b;

  unsigned long long bb = ll(b * 100 + 0.5);
  unsigned long long before = a * bb;

  // cout << bb << endl;
  // cout << before << endl;
  cout << before / 100 << endl;
  // 1000000000000001 9.99
  // 99 0.01
  return 0;
}


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

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string s, t;
  cin >> s >> t;
  int r = 0;
  F0R(i, s.size()) {
    if (s[i] != t[i]) r++;
  }
  cout << r;
}
#endif


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

long long f(long long h){
    
    if(h==1){
        return 1;
    }else{
        return 2*f(floor(h/2))+1;
    }
}

int main()
{
    long long h;
    cin>>h;
    long long count= f(h);
    cout<<count<<endl;
    
    return 0;
}


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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 1000100010010010;
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//template<typename T> auto cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

string k;
int d;
int n;

int dp[10100][110][2];

int dfs(int i, int m, bool flag){

    if(i == n){
        if(m == 0) return 1;
        else return 0;
    }

    if(dp[i][m][flag] > -1) return dp[i][m][flag];

    int num = k[i] - '0';
    int ans = 0;
    rep(j,0,(flag ? num + 1 : 10)){
        ans += dfs(i + 1, (m + j) % d, (flag && j == num ? 1 : 0));
        ans %= mod;
    }

    return dp[i][m][flag] = ans;


}


signed main(){


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

    cin >> k >> d;
    n = k.size();
    memset(dp, -1, sizeof(dp));
    int ans = dfs(0,0,1) - 1;
    print((ans + mod) % mod);




    






    



    


    

}



Measured memory_bytes: 18560
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
d = [None,2,5,5,4,5,6,3,7,6]
ds = [(i, d[i]) for i in a] # (数、本数)
ds.sort(reverse=True)

dp = [list(0 for _ in range(m+1)) for _ in range(n+1)]
for i in range(1, n+1):
    for j,(ii,num) in enumerate(ds):
        if i-num==0 or (i-num>0 and dp[i-num][0]>0):
            item = dp[i-num][:]
            item[0] += 1
            item[j+1] += 1
#             print(item)
            dp[i] = max(dp[i], item)
ans = ""
for i,item in enumerate(dp[n][1:]):
    ans += str(ds[i][0])*item
print(ans)


Measured memory_bytes: 71264
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =9223372036854775807;//64bit 9*1e+17
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
  int N,K,sum=1;
  cin>>N>>K;
  REP(i,N) sum+=min(sum,K);
  print(sum);
  return 0;
}


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

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		
		if (a < b){
			System.out.println("a < b");
		} else if (a > b){
			System.out.println("a > b");
		} else {
			System.out.println("a == b");
		}
	}
}



Measured memory_bytes: 26116
fs = require('fs');
N = fs.readFileSync('/dev/stdin','utf-8');
c = N % 10;
if(c == '2' || c == '4' || c == '5' || c == '7' || c == '9') {
  console.log('hon');
} else if(c == '3') {
  console.log('bon');
} else {
  console.log('pon');
}


Measured memory_bytes: 29620
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
typedef pair<int,int> p;

bool chmin(p& a, p& b){
    if(a.first > b.first + b.second){
        a.first = b.first + b.second;
        return 1;
    }
    return 0;
}

p id[500][500];
int n, flag;
stack<int> stk;

p& access(int i){
    return id[i/n][i%n];
}
int value(int i){
    return id[i/n][i%n].first;
}

void update(){
    int i = stk.top();
    stk.pop();
    if((i+1)%n!=0){
        if(chmin(access(i+1), access(i))) stk.push(i+1);
    }
    if(i%n!=0 && i!=0) {
        if(chmin(access(i-1), access(i))) stk.push(i-1);
    }
    if( (i+n)<n*n ){
        if(chmin(access(i+n), access(i))) stk.push(i+n);
    }
    if((i-n)>0){
        if(chmin(access(i-n), access(i))) stk.push(i-n);
    }
}


int main(){
    cin >> n;
    int a=0;
    rep(i,n){
        rep(j,n){
            int tmp=min(a/n,a%n);
            int tmp2=min((n*n-a-1)/n, (n*n-a-1)%n);
            id[i][j].first=min(tmp,tmp2);
            id[i][j].second=1; //exist
            a++;
        }
        //rep(k,n){
        //    cout<<access(n*i+k)<< " ";
        //}
        //cout << endl;
    }

    int res=0;
    rep(i,n*n){
        int tmp;
        cin >> tmp;
        tmp--;
        res += value(tmp);
        access(tmp).second=0;//none
        //cout << tmp+1 << " : " << value(tmp) << endl;
        stk.push(tmp);
        while(!stk.empty()) update();
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 5852
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n); for (int i = 0; i < (int)(n); i++)
vector<string> input(int N) {
  vector<string> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int n;
  cin >> n;
  vector<string> w=input(n);
  
  bool flag = true
  rep(i,n-1){
    if(w[i][w[i].size()-1]!=w[i+1][0]){
      flag = false;
    }
  }
  
  if(!flag){
    cout << "No" << endl;
    return 0;
  }else{
    sort(w.begin(),w.end());
    rep(i,n-1){
      if(w[i]==w[i+1]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
/*input
1817181712114
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
#define DEC(N)	cout << std::fixed; cout << setprecision(N);
void solve()
{
	string s;
	cin >> s;
	lld cnt=0;
	map <lld,lld> m;
	m[0]=1;
	lld p=1;
	lld cc=0;
	rrep(i,s.size()-1,0){
		cc=((s[i]-'0')*p+cc)%2019;
		p*=10;
		p%=2019;
		cnt+=m[cc];
		m[cc]++;
	}
	cout << cnt << endl;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 3700
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	string s;
	cin >> s;
	
	rep(i,0,s.size()){
		if(i%2 == 0)
			cout << s[i];
	}

	P("");
	ret 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    x=LI()
    ans=0
    for i in range(5):
        if x[i]==0:
            print(i+1)

main()


Measured memory_bytes: 61704
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstring>
#include<vector>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REV(i,a,b) for(int i=(a)-1;i>=(b);i--)

using namespace std;

typedef long long ll;


int N;
bool tmp[1000000000];
int a[55];

bool isprime(int n){
  for(int i=2;i*i<=n;i++){
    if (n % i == 0) return false;
  }
  return true;
}

int main(){
  cin >> N;
  vector<int>ps;
  FOR(i,2,55555){
    if(isprime(i) && i % 5 == 1)ps.push_back(i);
    if(ps.size() == N)break;
  }
  REP(i,N-1)cout << ps[i] << " ";
  cout << ps[N-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N 100

int main(){
    int n,st=0;
    char S[N];

    scanf("%d", &n);
    scanf("%s", S);

    st = strlen(S);

    if(st <= n){
        printf("%s\n", S);
    }
    else{
        for(int i=0; i<n; i++){
            printf("%c", S[i]);
        }
        printf("...");
    }
    return 0;
}

Measured memory_bytes: 1692
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)
ul H, W;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> a(6, 0);
  REP(ii, 3) { cin >> a[2 * ii] >> a[2 * ii + 1]; }
  for (int ii = 1; ii <= 4; ++ii) {
    int cnt = 0;
    for (auto& itr : a) {
      if (itr == ii) {
        ++cnt;
      }
    }
    if (cnt == 3) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		ll s=0;
		int n;
		cin>>n;
		for(int i=1;i<=n;i++){
			if(i%3==0||i%5==0)
			continue;
			s=s+i;
		}
		cout<<s;
	}
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define MAX 105
int n,l1,l2,ans=1e9;
char S[MAX],T[MAX];
bool check(int l)
{
	for(int i=l1-l+1,j=1,k=1;k<=l;++k,++i,++j)
		if(S[i]!=T[j])return false;
	return true;
}
int main()
{
	scanf("%d",&n);scanf("%s",S+1);scanf("%s",T+1);
	l1=strlen(S+1);l2=strlen(T+1);
	for(int l=0;l1+l2-l>=n&&l<=l1&&l<=l2;++l)
		if(check(l))ans=min(ans,l1+l2-l);
	printf("%d\n",ans);
	return 0;
}


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

ll mod_pow(ll n, ll p, ll mod) {
    n %= mod;
    if (p == 0)
        return 1;
    ll res = mod_pow(n * n % mod, p / 2, mod);
    if (p % 2 == 1)
        res = res * n % mod;
    return res;
}

struct combination {
    combination(ll Nmax, ll mod) {
        (this->MOD) = mod;
        (this->Nmax) = Nmax;
        factorial.resize(Nmax + 1, 1);
        inverse_factorial.resize(Nmax + 1, 1);
        init_factorial();
    }

    ll calc(ll n, ll r) {
        if (r < 0 || r > n)
            return 0;
        ll ret = (factorial[n] * inverse_factorial[r]) % MOD;
        ret = (ret * inverse_factorial[n - r]) % MOD;
        return ret;
    }

    vector<ll> factorial;
    vector<ll> inverse_factorial;

private:
    ll MOD, Nmax;

    void init_factorial() {
        for (ll i = 1; i <= Nmax; i++) {
            factorial[i] = (factorial[i - 1] * i) % MOD;
        }
        inverse_factorial[Nmax] = mod_pow(factorial[Nmax], MOD - 2, MOD);
        for (ll i = Nmax - 1; i >= 1; i--) {
            inverse_factorial[i] = (inverse_factorial[i + 1] * (i + 1)) % MOD;
        }
    }
};

int main() {
    int N, K;
    cin >> N >> K;
    ll mod = 1e9 + 7;

    combination comb(2 * N, mod);
    if (K >= N - 1) {
        cout << comb.calc(2 * N - 1, N) << endl;
    } else {
        ll ans = 0;
        for (int k = 0; k <= K; k++) {
            ans = ans + (comb.calc(N, k) * comb.calc(N - 1, N - k - 1)) % mod;
            ans %= mod;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 6528
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
using namespace std;
int main()
{
  map<string, int> M;
  int k;
  int a,b,c,d,e;
  vector<string> S = {"a","b","c","d","e"};
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cin >> e;
  cin >> k;
  M["a"] = a;
  M["b"] = b;
  M["c"] = c;
  M["d"] = d;
  M["e"] = e;
  int info = 0;
  for(string key : S){
    for(string  key_t : S){
      if(abs(M[key] - M[key_t]) > k){
        ++info;
        break;
      }
    }
  if(info) break;
  }
  if(info) cout << ":(" << endl;  
  else cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let s = v.iter().sum::<i64>();
    if s >= 10 {
        println!("error");
    } else {
        println!("{}", s);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main(){
	int n;
	cin>>n;
	int a[n+1],b[n+1],c[n+2];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	b[0]=0;
	for(int i=1;i<=n;i++){
		b[i]=b[i-1]+a[i];
	}
	c[n]=a[n];
	a[n+1]=0;
	for(int i=n-1;i>=1;i--){
		c[i]=c[i+1]+a[i];
	} 
	int mi=100000000;
	for(int i=0;i<=n;i++){
		mi=min(mi,abs(b[i]-c[i+1]));
	}
	cout<<mi<<endl;
} 

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

int const N = 1000000;
int n;
char s[N + 1];

bool ok(int m){
	int l[2] = { 0, 1 }, r[2] = { m, m };
	--r[m & 1 ^ 1];
	f(i, 0, n)f(j, 0, 2){
		if (s[i] == '?')--l[j], ++r[j];
		else if (s[i] == '0')--l[j], --r[j];
		else ++l[j], ++r[j];
		if (l[j] < 0)l[j] += 2;
		if (r[j] > m)r[j] -= 2;
		if (l[j] > m || r[j] < 0)r[j] = 1e9;
	}
	return r[0] <= m || r[1] <= m;
}

int main(){
	scanf("%s", s);
	n = strlen(s);
	int l = 1, r = n;
	while (r > l){
		int m = l + r >> 1;
		if (ok(m))r = m;
		else l = m + 1;
	}
	printf("%d\n", l);
}

Measured memory_bytes: 4800
import java.util.*;
import java.io.*;

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

      int x = sc.nextInt();
      int n = sc.nextInt();
      int[] arr = new int[n];
      for(int i = 0; i < n; i++){
          arr[i] = sc.nextInt();
      }
      Arrays.sort(arr);
      
      int best = x;
      int minDistance = n;
      for(int i = 0; i <= 101; i++){
          boolean good = true;
          for(int j = 0; j < n; j++){
              if(arr[j] == i){
                  good = false;
                  break;
              }
          }
          if(good){
              if(Math.abs(x - i) < minDistance){
                  minDistance = Math.abs(x-i);
                  best = i;
              } else if(Math.abs(x-i) == minDistance){
                  best = Math.min(best, i);
              }
          }
      }
      System.out.println(best);
    }
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    for(int i = 0; i < n; i++)
        for(int j: {i + 1, i + 2})
            dp[j] = min(dp[j], dp[i] + abs(a[j] - a[i]));
    cout << dp[n - 1] << endl;
    return 0;
}   



Measured memory_bytes: 4764
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s.at(s.size()-1)=='s'){
    cout << s << "es" << endl;
  }else{
     cout << s << "s" << endl;
   }
  	
	return 0; 
}

Measured memory_bytes: 3016
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

const mod = 1000000007

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	s := make([][]byte, 2)
	s[0] = []byte(getString())
	s[1] = []byte(getString())

	sum := 1
	i := 0
	prev := 0
	if s[0][0] != s[1][0] { // 横
		sum = 3 * 2
		i = 2
		prev = 1
	} else { // 縦
		sum = 3
		i = 1
		prev = 2
	}
	for i < N {
		if s[0][i] != s[1][i] { // 上下に水平
			if prev == 1 {
				sum = (sum * 3) % mod
			} else {
				sum = (sum * 2) % mod
			}
			prev = 1
			i += 2
		} else {
			if prev == 2 {
				sum = (sum * 2) % mod
			}
			prev = 2
			i++
		}
	}
	out(sum)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

const long long M = 1000000007;
map<int, int> res;

void primeFactor(int n){
    for(int i = 2; i * i <= n; i++){
        while(n % i == 0){
            ++res[i];
            n /= i;
        }
    }
    if(n != 1) res[n] += 1;
}

long long numPrimeFactor(){
    long long ans = 1;
    for(auto it:res){
        ans = ans * (it.second + 1);
        ans %= M;
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    range(i,1,n + 1){
        primeFactor(i);
        //show(res.size()) for(auto it:res){ cout << it.first << ' ' << it.second << endl; }
    }

    cout << numPrimeFactor() << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
    int n;
    long long m;
    scanf("%d %lld", &n, &m);
    vector<long long> v;
    for(int i = 0 ; i < n ; i++){
        long long x;
        scanf("%lld", &x);
        v.push_back(x);
    }
    int j = 0;
    for(j = 50 ; j >= 0 ; j--) {
        if(m & (1LL<<j)) break;
    }
    long long ans = 0;
    long long tmp = 0;
    long long out = 0;
    
    for(; j >= 0 ; j--) {
        if((ans ^ (1LL<<j)) > m) continue;

        long long a = 0, b = 0;
        for(int k = 0 ; k < n ; k++) {
            a += (v[k] & (1LL<<j));
            b += (v[k] & (1LL<<j)) ^ (1LL<<j);
        }

        if(a < b) ans ^= 1LL<<j;
    }

    for(auto e: v) {
        tmp += ans ^ e;
    }

    out = tmp;

    ans = 0;
    for(int j = 0 ; j < 50 ; j++) {
        if((ans ^ (1LL<<j)) > m) break;
 
        long long a = 0, b = 0;
        for(int k = 0 ; k < n ; k++) {
            a += (v[k] & (1LL<<j));
            b += (v[k] & (1LL<<j)) ^ (1LL<<j);
        }
 
        if(a < b) ans ^= 1LL<<j;
    }
    tmp = 0;
    for(auto e: v) {
        tmp += ans ^ e;
    }

    out = max(out, tmp);

    tmp = 0;
    for(auto e: v) {
        tmp += m ^ e;
    }

    out = max(out, tmp);

    printf("%lld\n", out);
    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vect vector<ll>
#define unmap unordered_map
#define pb push_back
#define pi 3.1415926536
#define mod int(1e9+7)
#define mp make_pair
#define testcases ll t; cin>>t; while(t--)

using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    vector<int> v(n+1),dp(n+1,0);
    for(int i=1;i<=n;i++) cin>>v[i];

    dp[2]=abs(v[2]-v[1]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1024
///////////////////// author : TrEbLeCleF /////////////////////
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define For(i, a) for (int i=0; i<(a); i++)
#define FORR(i,a,b) for (int i = (b)-1; i >= a; i--)
#define Forr(i,a) for (int i = (a)-1; i >= 0; i--)
/////////////////////////// ..... ///////////////////////////
#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args){
cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }
/////////////////////////// ..... ///////////////////////////
#define int ll
#define pb(x) push_back(x)
#define print(v,s,e) for(int i = s; i < e; i++)cout << v[i]<<" ";cout<<"\n";
#define INF 1e17
#define PI 3.14159265358979323846 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
/////////////////////////// GLOBAL ///////////////////////////


/////////////////////////// GLOBAL ///////////////////////////
void solve(){
	int n,k; cin >> n >> k;
	int a[n];
	For(i,n)cin >> a[i];
	FOR(i,k,n){
		if(a[i] > a[i-k])cout << "Yes\n";
		else cout <<"No\n";
	}
}

int32_t main(){ 
	#ifndef ONLINE_JUDGE
		clock_t tStart = clock();
		freopen("TC", "r", stdin);
		//freopen("output.txt","w",stdout);
	#endif 
    ios_base:: sync_with_stdio(false); 
   	cin.tie(0); 
	int t=1;
	//cin >> t;
	for(int tt=1;tt<=t;tt++){
		//cout << "Case #"<<tt<<": ";
		solve();
	}
	#ifndef ONLINE_JUDGE
    	cerr << "\nRun Time -> "<<(double)(clock()-tStart)/CLOCKS_PER_SEC <<" sec\n";
    #endif
}

Measured memory_bytes: 5140
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int k, x;
    cin >> k >> x;
    string ans = "No";
    if(500 * k >= x) ans = "Yes";
    cout << ans << endl;
    return 0;
}

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

int main(){
  int H, N;
  cin >> H >> N;
  
  int waza[N];
  
  for(int i = 0; i<N; i++){
    cin >> waza[i];
  }
  
  bool ans = false;
  
  for(int i = 0; i < N; i++){
    H = H - waza[i];
    
    if(H <= 0){
      ans = true;
      break;
    }
  }
  
  if(ans == true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
  
    


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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;

#define MOD 1000000007
#define PI 3.14159265359
#define endl '\n'
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;

void test()
{
	int ans = 0;
	string s,t;
	cin>>s>>t;

	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
			ans++;
	}

	cout<<ans<<endl;
}

int main()
{   
fast_io();
cout << fixed << setprecision(15);
int t = 1;

//cin>>t;

for(int i = 0; i < t; i++)
{
	test();
}
return 0;
}

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

int main()
{
  uint64_t n, r = 0;
  cin >> n;
  for (uint64_t i = 1; i <= n; i++)
  {
    r += (n / i) * ((n - (n % i)) + i) / 2;
  }
  cout << r << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    for(;;){
    int N,X; cin >> N >> X;
    if(N==0 && X==0) break;
    int ans=0;
    for(int i=1;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            for(int k=j+1;k<=N;k++){
                if(i+j+k==X) ans++;
            }
        }
    }
    cout << ans << endl;
    }

    return 0;
}


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define loop(i, n) for(int i = 0;i < n;i++)
#define IINF 2e9
#define MOD 1e9+7

int main(void){

    int h, w;
    cin >> h >> w;
    vector<string> fi(h);
    loop(i, h) cin >> fi[i];

    vector<vector<int>> dp(h, vector<int>(w, IINF));

    if(fi[0][0] == '#') dp[0][0] = 1;
    else dp[0][0] = 0;

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


    loop(i, h){
        loop(j, w){
            loop(k, 2){
                int nx = j + dx[k];
                int ny = i + dy[k];
                if(w <= nx || h <= ny) continue;
                if(fi[i][j] == '.' && fi[ny][nx] == '#'){
                    dp[ny][nx] = min(dp[ny][nx], dp[i][j] + 1);
                }else{
                    dp[ny][nx] = min(dp[ny][nx], dp[i][j]);
                }
            }
        }
    }


    cout << dp[h-1][w-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int D;
  scanf("%d",&D);
  if(D==25)
  	printf("Christmas");
  if(D==24)
  	printf("Christmas Eve");
  if(D==23)
  	printf("Christmas Eve Eve");
  if(D==22)
  	printf("Christmas Eve Eve Eve");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end(), std::greater<int>()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, q, t;
    cin>>n>>k>>q;
    int p[n];
    rep(i, n){
        p[i] = k-q;
    }
    rep(i, q){
        cin>>t;
        p[t-1] += 1;
    }
    
    rep(i, n)
        if(p[i] <= 0)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		char[] array = sc.next().toCharArray();
		int onecount=0;
		int zerocount=0;
		for(int i=0;i<array.length;i++) {
			if(array[i]=='1') onecount++;
			else zerocount++;
		}
		System.out.println(Math.min(zerocount,onecount)*2);
		}
}


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

int main(){
    int n, l;
    cin >> n >> l;
    int a[n];
    for(int i = 0; i < n; i++)  a[i] = l + i;
    int sum = accumulate(a, a+n, 0);
    int ans, ma = 1<<30;
    for(int i = 0; i < n; i++){
        int tmp = sum - a[i];
        if(abs(tmp-sum) < ma){
            ma = abs(tmp-sum);
            ans = tmp;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//2
//1 4
#include <bits/stdc++.h>
using namespace std;
int x[105];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i];
	} 
	int minn=2147483647,s=0;
	for(int i=1;i<=100;i++){
		s=0;
		for(int j=1;j<=n;j++){
			s+=(x[j]-i)*(x[j]-i);
		}
		if(s<minn) minn=s;
	}
	cout<<minn;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main(int argc, char* argv[])
{
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];

  ll surplus_a = 0;
  ll surplus_b = 0;

  rep(i, n) {
    ll diff = abs(b[i] - a[i]);
    if (a[i] < b[i]) {
      if (surplus_a != 0) {
        if (surplus_a >= diff) {
          if (diff %2 == 0) {
            a[i] += diff;
            surplus_a -= diff;
            diff = 0;
            continue;
          } else {
            a[i] += diff - 1;
            surplus_a -= (diff -1);
            diff = 1;
          }
        } else {
          a[i] += surplus_a;
          diff -= surplus_a;
          surplus_a = 0;
        }
      }
      ll num = diff / 2 + diff % 2;
      a[i] += 2 * num;
      surplus_b += num;
      if (a[i] != b[i]) {
        b[i] += 1;
        surplus_b -= 1;
      }
    } else if (a[i] > b[i]) {
      if (surplus_b != 0) {
        if (surplus_b >= diff) {
          b[i] += diff;
          surplus_b -= diff;
          diff = 0;
          continue;
        } else {
          b[i] += surplus_b;
          diff -= surplus_b;
          surplus_b = 0;
        }
      }
      ll num = diff;
      b[i] += num;
      surplus_a += num * 2;
    }
  }

  // rep(i, n) {
  //   cerr << a[i] << " ";
  // }
  // cerr << endl;
  // rep(i, n) {
  //   cerr << b[i] << " ";
  // }
  // cerr << endl;

  // cerr << "surplus_a: " << surplus_a << "  surplus_b: " << surplus_b << endl;

  if (surplus_b < surplus_a) {
    cout << "No" << endl;
    return 0;
  }

  rep(i, n) {
    if (a[i] != b[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 384
#include <cctype>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define LL long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

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

int main(){
   int n;

    while(cin >> n, n){
        bool lu = false;
        bool ru = false;
        bool upf = false;
        int cnt = 0;
        while(n--){
            string str;
            cin >> str;

            if(str == "lu"){
                lu = true;
            }else if(str == "ru"){
                ru = true;
            }else if(str == "ld"){
                lu = false;
            }else if(str == "rd"){
                ru = false;
            }

            if((!upf && lu && ru) || (upf && !lu && !ru)){
                if(upf) upf = false;
                else upf = true;
                cnt++;
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 3100