akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
const int mod = 1e9 + 7;

ll N, M;
vector<ll> a, b;

int main() {
    cin >> N >> M;
    a.resize(M);
    b.resize(M);
    rep(i, M) cin >> a[i] >> b[i];
    
    vector<P> v(M);
    rep(i, M) {
        v[i] = P(b[i], a[i]);
    }
    sort(v.begin(), v.end());
    // rep(i, M) {
    //     printf("%d %d\n", v[i].first, v[i].second);
    // }

    ll ans = 1;
    ll pos = v[0].first;
    for (ll i = 1; i < M; i++) {
        // printf("i: %d pos: %d left: %d\n", i, pos, v[i].second);
        if (pos <= v[i].second) {
            pos = v[i].first;
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int main(){
	// sengen
	LL a,b,c,d;
	// nyuryoku
	cin >> a >> b >> c >> d;
	LL x,y;
	LL ans;
	// keisan
	ans = max(a*c,a*d);
	ans = max(ans,max(b*c,b*d));
	// syutsuryoku
	cout << ans << endl;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  //less_equal
             tree_order_statistics_node_update> oset; 
typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int MAXK = 2e3 + 2;
#define sz(x) (int)(x).size()
#define f first
#define s second

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

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

cout << c - min(a - b, c);


}


Measured memory_bytes: 256
n, k = map(int, input().split())

dict_num = {}
for i in range(n):
    a, b = map(int, input().split())
    if a in dict_num:
        dict_num[a] += b
    else:
        dict_num[a] = b

array = []
for n, t in dict_num.items():
    array.append([n, t])

array.sort()

cnt = 0
for a in array:
    cnt += a[1]
    if cnt >= k:
        print(a[0])
        break


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

int main() {
  int K,X,A,B;
  cin >>K>>X;
  A=X-(K-1);
  B=X+(K-1);
    for (int i = A; i < B+1; i++) {
 
    if (i == B) {
      cout << B;
      cout<<" ";
      break;
    }
 
    cout << i;
    cout<<" ";
  }
}

Measured memory_bytes: 256
N = int(input())
S = input()

from bisect import *
from collections import defaultdict

res = defaultdict(list)

for i in range(len(S)):
    s = S[i]
    res[int(s)].append(i)

for i in range(10):
    res[i].append(10000000)
ans = set()
for i in range(10):
    for j in range(10):
        for k in range(10):
            if len(res[i]) > 1 and len(res[j]) > 1 and len(res[k]) > 1:
                tmp = str(i) + str(j) + str(k)
                # print(i, j, k)
                f = res[i][0]
                s_i = bisect_left(res[j], f + 1)
                if s_i != len(res[j]) - 1:
                    s = res[j][s_i]
                else:
                    continue
                t_i = bisect_left(res[k], s + 1)
                if t_i != len(res[k]) - 1:
                    t = res[k][t_i]
                else:
                    continue
                if f < s < 10000000 and s < t < 10000000:
                    ans.add(tmp)
print(len(ans))


Measured memory_bytes: 4704
//In the name of Allah 
#include <bits/stdc++.h>
 
using namespace std; 
 
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define int long long
 
const int N=1e5+100;
 
int a[N],cnt[N];
 
int32_t main(){
	ios::sync_with_stdio(0);cin.tie(0);	
	int n; 
	cin>>n; 
	srand(time(NULL));
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum%(n*(n+1)/2LL)!=0)return cout<<"NO\n",0;
	sum/=(n*(n+1))/2; 

	if(n==1)return cout<<"YES\n",0;
	int test=0;
	for(int i=0;i<n;i++){
		int c=a[(i-1+n)%n]-a[i];
		if((c+sum)%n!=0)return cout<<"NO\n",0; 
		cnt[i]=(c+sum)/n;
		if(cnt[i]<0)return cout<<"NO\n",0;
		test+=cnt[i];
	}
	if(test!=sum)return cout<<"NO\n",0; 

	int t=0,ans=0;
	for(int i=0;i<n;i++){
		ans+=t; 
		ans+=cnt[i];
		t+=cnt[i];
		a[i]-=ans;
	}
	for(int i=0;i<n;i++){
		t-=cnt[i];
		ans-=cnt[i]*n;
		ans+=t; 
		a[i]-=ans;
	}
	for(int i=0;i<n;i++){
		if(a[i]!=0)return cout<<"NO\n",0;
	}
	cout<<"YES\n";
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

int main(){
  string A, B;

  cin >> A >> B;

  if(A == B){
    cout << "EQUAL" << endl;
  }else{
    if(A.size() < B.size()){
      cout << "LESS" << endl;
    }else if(A.size() > B.size()){
      cout << "GREATER" << endl;
    }else{
      for(int i = 0; i < A.size(); i++){
        if(A[i] < B[i]){
          cout << "LESS" << endl;
          break;
        }else if(A[i] > B[i]){
          cout << "GREATER" << endl;
          break;
        }
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precise cout.precision(8); cout << fixed;
#define seed srand(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
using namespace std;

void solve() {
    ll N, i, ans = 0; cin >> N;
    vector<ll> cnt(100001, 0);
    for(i = 0; i < N; i += 1) {
        ll x; cin >> x;
        cnt[x] += 1;
        ans += x;
    }
    ll Q; cin >> Q;
    while(Q--) {
        ll B, C; cin >> B >> C;
        ans += (cnt[B] * (C - B));
        cnt[C] += cnt[B];
        cnt[B] = 0;
        cout << ans << endl;
    }
}

int main() {
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4048
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
    int n;
    cin>>n;
    int zoro = 0;

    rep(i,n)
    {
        int a,b;
        cin>>a>>b;
        if(a==b) zoro ++;
        else zoro =0;

        if(zoro==3)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3132
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

int main(void) {
  int a, b;
  scanf("%d %d",&a,&b);
  if (0 >= a && 0 <= b)
    printf("Zero\n");
  else if (a > 0)
    printf("Positive\n");
  else
    printf((b-a+1)%2 == 0 ? "Positive\n" : "Negative\n");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a,b,c;
  int x=0,y=0;

  scanf("%d %d %d",&a,&b,&c);
  
  for(int x = a ; x <= b ; x++){

    if (c%x == 0) {
      y++;
    }
  }
  printf("%d\n",y);

  return 0;
}
      

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int n,m,k[11],a[11][11],b[11],ans=0,u[11];
vi t;
void dfs(int d,vi v){
	if(d==n){
		fo(i,0,n)u[i]=0;
		fo(i,0,v.size())u[v[i]]=1;
		fo(i,0,m){
			int x=0;
			fo(j,0,k[i])x+=u[a[i][j]-1];
			if(x%2!=b[i])return;
		}
		ans++;
		return;
	}
	dfs(d+1,v);
	v.pb(d);
	dfs(d+1,v);
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n>>m;
	fo(i,0,m){
		cin>>k[i];
		fo(j,0,k[i])cin>>a[i][j];
	}
	fo(i,0,m)cin>>b[i];
	t.clear();
	dfs(0,t);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, T int
	fmt.Scan(&N, &T)

	ts := make([]int, N)
	for i := range ts {
		fmt.Scan(&ts[i])
	}

	var ans int
	for i := 0; i < N-1; i++ {
		diff := ts[i+1] - ts[i]

		if diff >= T {
			ans += T
		} else {
			ans += diff
		}
	}
	fmt.Println(ans + T)
}

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

using namespace std;

void out(vector<uint16_t> A) {
    for (int i = 0; i < A.size() - 1; i++) {
        cout << A[i] << " ";
    }
    cout << A[A.size() - 1] << endl;
}

int
main(int argc, char** argv) {
    uint16_t n; cin >> n;
    vector<uint16_t> A(n);
    for (auto& a : A) {
        cin >> a;
    }
    for (uint16_t i = 1; i < n; i++) {
        out(A);
        auto v = A[i];
        auto j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
    }
    out(A);
}


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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000001
using namespace std;
typedef long long ll;

ll n,k;
ll res;

ll cub(ll x){
  return x*x*x;
}

int main() {
    ll n, k;
    cin >> n >> k;
    if(k%2){
      res = cub(n/k);
    }else{
      res = cub(n/(k/2) - n/k)+ cub(n/k);
    }
    std::cout << res << '\n';
    return 0;
}


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

struct node{
  node* l;
  node* r;
  int value;
  int priority;
  node(int x=0,int y=0){
    l=NULL;
    r=NULL;
    value=x;
    priority=y;
  }
};

typedef node* Node;

int cc=0;
node t[500005];

Node MakeNode(int x=0,int y=0){
  Node res=&t[cc];
  cc++;
  res->value=x;
  res->priority=y;
  return res;
}

Node left_rotate(Node root){
  Node right=root->r;
  root->r = right->l;
  right->l = root;
  return right;
}

Node right_rotate(Node root){
  Node left=root->l;
  root->l = left->r;
  left->r = root;
  return left;
}

Node insert(Node root,int val,int pri){
  
  if(root==NULL){
    return MakeNode(val,pri);
  }
  
  if( val < root->value ){
    root->l = insert( root->l , val , pri );

    if( root->l->priority > root->priority ){
      root = right_rotate(root);
    }
    
  }else if( val > root->value ){
    root->r = insert( root->r , val , pri );
    
    if( root->r->priority > root->priority ){
      root = left_rotate(root);
    }
    
  }else{
    
  }
  return root;
}

bool find(Node root,int target){
  if( root == NULL )return false;
  if( root->value == target )return true;
  if( root->value > target )return find(root->l,target);
  if( root->value < target )return find(root->r,target);
  return false;
}

Node erase(Node root,int target){
  if( root == NULL )return root;
  if( root->value == target ){
    
    if( root->l == NULL ){
      return root->r;
    }
    if( root->r == NULL ){
      return root->l;
    }

    if( root->l->priority > root->r->priority ){
      root = right_rotate(root);
    } else {
      root = left_rotate(root);
    }
    return erase(root,target);
  }
  
  if( root->value > target ){
    root->l=erase(root->l,target);
    return root;
  }
  if( root->value < target ){
    root->r=erase(root->r,target);
    return root;
  }

  assert(0);
}

void dfsA(Node root){
  if(root==NULL)return;
  printf(" %d", root->value);
  dfsA(root->l);
  dfsA(root->r);
}

void dfsB(Node root){
  if(root==NULL)return;
  dfsB(root->l);
  printf(" %d", root->value);
  dfsB(root->r);
}

Node T=NULL;

int main(){

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

  char str[100];
  int x,y;
  
  for(int i=0;i<m;i++){
    scanf("%s",str);
    if(str[0]=='i'){
      scanf("%d %d",&x,&y);
      T=insert(T,x,y);
      
    }else if(str[0]=='f'){
      scanf("%d",&x);
      if( find(T,x) )printf("yes\n");
      else printf("no\n");
      
    }else if(str[0]=='d'){
      scanf("%d",&x);
      if( find(T,x) ){
        T=erase(T,x);
      }
      
    }else if(str[0]=='p'){
      dfsB(T);
      printf("\n");
      dfsA(T);
      printf("\n");
      
    }else{
      assert(0);
    }

  }
  return 0;
  /*
  int tmp[10]={3,1,4,5,2,0,6,9,7,8};

  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int id;
    cin>>id;
    T=insert(T,id, tmp[id] );
  }

  T=erase(T, 7);
  
  dfs(T);
  cout<<endl;
  */

}



Measured memory_bytes: 14920
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


template<typename T>
struct SegmentTree{
private:
    int n;
    T E;
    vector<T> node;
    inline void updatef(T& x,T& y){
        x = y;
        //x += y;
        //x = max(x,y);
        //x = min(x,y);
    }
    inline T queryf(T& x,T& y){
        return min(x,y);
    }

public:
    SegmentTree(int sz,T E_):E(E_){
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E);
    }

    SegmentTree(vector<T>& A,T E_):E(E_){
        int sz=A.size();
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E);
        rep(i,sz)node[i+n-1]=A[i];
        for(int i=n-2;i>=0;--i){
            node[i]=queryf(node[2*i+1], node[2*i+2]);
        }
    }
    void update(int k,T x){
        k+=n-1;
        updatef(node[k],x);
        while(k>0){
            k=(k-1)/2;
            node[k]=queryf(node[2*k+1], node[2*k+2]);
        }
    }
       //[a,b)での和を返す
    T get(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        if(r<=a||b<=l)return E;
        if(a<=l&&r<=b)return node[k];
        T xl=get(a,b,2*k+1,l,(l+r)/2);
        T xr=get(a,b,2*k+2,(l+r)/2,r);
        return queryf(xl, xr);
    }

};
int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    vector<int> as = a, bs = b;
    sort(as.begin(),as.end());
    sort(bs.begin(),bs.end());
    rep(i,n){
        if(as[i]>bs[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    rep(i,n){
        a[i] = lower_bound(as.begin(), as.end(),a[i])-as.begin();
        b[i] = lower_bound(bs.begin(), bs.end(),b[i])-bs.begin();
    }
    vector<int> ord(n);
    rep(i,n)ord[i]=i;
    sort(ord.begin(),ord.end(),[&](int x,int y){
        return b[x]<b[y];
    });
    vector<int> c(n);
    rep(i,n)c[i]=a[ord[i]];
    SegmentTree<int> sg(c,inf);
    int cnt = 0;
    rep(i,n){
        if(bs[i]>=as[c[i]])continue;
        ++cnt;
        int ok = i, ng = n;
        while(ng-ok>1){
            int mid = (ok+ng)/2;
            int idx = sg.get(mid,n);
            if(bs[i]>=as[idx])ok=mid;
            else ng = mid;
        }
        swap(c[i],c[ok]);
        sg.update(ok,c[ok]);
    }
    if(cnt<n-1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3584
import java.util.Arrays;
import java.util.Scanner;

public class Main{
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args){
        int N, temp;
        double[] efficiency;
        Fruit[] fruits, answer;
        boolean[] check;
        while((N = sc.nextInt()) != 0){
            efficiency = new double[N];
            fruits = new Fruit[N];
            answer = new Fruit[N];
            check = new boolean[N];
            Arrays.fill(check, true);
            temp = 0;
            for(int i = 0; i < N; i++){
                fruits[i] = new Fruit(sc.next(), sc.nextInt(), sc.nextInt(), sc.nextInt(),
                        sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());
            }
            for(int i = 0; i < N; i++) efficiency[i] = fruits[i].efficiency;
            Arrays.sort(efficiency);
            outer:
            for(int i = N - 1; i >= 0; i--){
                for(int j = 0; j < N; j++)
                    if(fruits[j].efficiency == efficiency[i] && check[j]){
                        answer[temp++] = fruits[j];
                        check[j] = false;
                        continue outer;
                    }
            }

            for(int i = 0; i <= N - 2; i++){
                temp = 0;
                while(i <= N - 2 && answer[i + 1].efficiency == answer[i].efficiency){
                    i++;
                    temp++;
                }
                if(temp > 0) sortDirectory(answer, i - temp, i);
            }
            for(Fruit f : answer) System.out.println(f.name);
            System.out.println("#");
        }
    }


    static void sortDirectory(Fruit[] f, int a, int b){
        String temp;
        for(; a < b; a++){
            for(int j = b - 1; j >= a; j--){
                if(f[j + 1].name.compareTo(f[j].name) < 0){
                    temp = f[j + 1].name;
                    f[j + 1].name = f[j].name;
                    f[j].name = temp;
                }
            }
        }
    }

    static class Fruit{
        String name;
        int P, A, B, C, D, E, F, S, M, total_time, income;
        double efficiency;

        Fruit(String name, int p, int a, int b, int c, int d, int e, int f, int s, int m){
            this.name = name;
            P = p;
            A = a;
            B = b;
            C = c;
            D = d;
            E = e;
            F = f;
            S = s;
            M = m;
            calcFruitEfficiency();
        }

        void calcFruitEfficiency(){
            total_time = A + B + C + (D + E)*M;
            income = S*F*M - P;
            efficiency = (double) income/(double) total_time;
        }
    }
}

Measured memory_bytes: 45696
#include<iostream>
using namespace std;
main(){int r[6]={0},n,l,k;char c;
 for(cin>>n;n;n--){
  cin>>l>>c>>k;
  l>185?l=185:l;l<165?l=160:l;
  r[l/5-32]++;
 }
 for(int i=0;i<6;i++){
  cout<<i+1<<":";
  for(;r[i];r[i]--)cout<<"*";
  cout<<endl;
 }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef  long long  ll;
typedef vector<ll> vll;
#define meme(s) memset(s,1,sizeof(s))
#define rall(s) s.rbegin(),s.rend()
#define i(x) scanf("%lld",&(x))
typedef unordered_map<ll,ll> mll;
#define pb push_back
#define in2(x,y) i(x),i(y)
#define EL cout<<'\n'
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define all(s) s.begin(),s.end()
typedef unordered_map<ll,vll>circuit;
typedef unordered_map<ll,bool>is;
const ll MOD=1e9+7;
#define no cout<<"NO\n"
#define yes cout<<"YES\n"
#define fr(n,x) for(int n=0;n<x;n++)
#define pf(x) printf("%lld\n",(x))
const  ll mx=2e5;
const int N = 1e6+6;
#define segtree ll L=2*node,R=L+1,mid=(l+r)/2
#define cs(n) printf("Case %lld: ",(n))
typedef pair<ll,ll> pll;


int main()
{
    ll x,sm=0;
    i(x);
	for(ll n=1;n<=x;n++)
	{
		if((n%3!=0) &&(n%5!=0))sm+=n;
	}
	pf(sm);
}






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

int n, m;
priority_queue<int> Q;
long long t = 0;

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

	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;

		Q.push(a);
	}

	for (int i = 0; i < m; i++) {
		int b = Q.top();
		
		Q.pop();
		b /= 2;
		Q.push(b);
	}

	while (!Q.empty()) {
		t += Q.top();
		Q.pop();
	}

	cout << t << endl;

	return 0;
}

Measured memory_bytes: 892
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

struct edge{
  int u, v, cost;
  bool operator< (edge const& other){
	    return cost < other.cost; 
	 }	
};

const int N = 4e5 + 11;
int p[N], sz[N], color[N];
int n, m, k;
vector<edge> ret;
int weight = 0, cnt;

int get(int x){
  if (x == p[x]) return x;
  return p[x] = get(p[x]);	
}

void unite(int x, int y){
  x = get(x), y = get(y);
  if (x == y) return;
  if (sz[x] < sz[y]) swap(x, y);
  sz[y] += sz[x];
  p[y] = x;	
}

void KruskalMST(vector<edge> &edge_list){
	sort(all(edge_list));
	cnt = 0;
	for(auto it : edge_list){
	  if (get(color[it.u]) != get(color[it.v])){
		   unite(color[it.u], color[it.v]);
		   weight += it.cost;
		   cnt++;  
		}	
	 if (cnt == k - 1) {
	   cout << weight << endl;
	   exit(0);	 
	 }
	}
   cout << -1 << endl;
}


void solve(){
  	cin >> n >> m >> k;
  	vector<edge> g;
  	for(int i = 0; i < N; i++){
	    p[i] = i;
	    sz[i] = 0;	
	}
	int now = 0;
	for(int i = 0; i < n; i++){
	   	cin >> color[i];
	   	if (color[i] == 0) {
		  color[i] = now + 100000;
		  now++;	
		}
	}
  	for(int i = 0; i < m; i++){
	  int x, y, val;
	  cin >> x >> y >> val;
	  x--, y--;
	  g.push_back({x, y, val});
	}
  KruskalMST(g);
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 12916
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%MOD+MOD)%MOD){}
  mint& fix() { x = (x%MOD+MOD)%MOD; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=MOD) x-=MOD; return *this;}
  mint& operator-=(const mint& a){ if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=MOD; return *this;}
  mint operator^(int b) {mint res = 1;while(b > 0) {if(b&1) {res = (res*(*this));}*this=(*this)*(*this);b>>=1;} return res;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
typedef vector<mint> vm;
typedef vector<vm> vvm;

bool valid(int k,int W) {
  rep(i,W-2) {
    if(((k>>i)&1)&&(k>>(i+1))&1) {
      return false;
    }
  }
  return true;
}
  
int main() {
  int H,W,K;
  cin >> H >> W >> K;
  vm dp(W,0);
  dp[0] = 1;
  rep(hi,H) {
    vm dp2(W,0);
    rep(i,1<<(W-1)) {
      if(!valid(i,W)) continue;
      rep(j,W-1) {
        if((i>>j)&1) {
          dp2[j] += dp[j+1];
        }
      }
      srep(j,1,W) {
        if((i>>(j-1))&1) {
          dp2[j] += dp[j-1];
        }
      }
      rep(j,W) {
        bool th = true;
        if(j<W-1&&(i>>j)&1) {
          th=false;
        }
        if(j>0&&(i>>(j-1))&1) {
          th=false;
        }
        if(th) {
          dp2[j] += dp[j];
        }
      }
    }
    dp = dp2;
  }
  cout << dp[K-1].x << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
//cerr
using namespace std;
signed main() {
	int n, k; cin >> n >> k;
	if (n < 10)cout << k + 100 * (10 - n) << endl;
	else cout << k << endl;
}

Measured memory_bytes: 256
S=input()
if S[0]==S[1]:
    print(1,2)
    exit()
L=[S[0],S[1]]

for i in range(2,len(S)):
    s=S[i]
    if s in L:
        print(i+1-(2-L.index(s)), i+1)
        exit()
    else:
        L.pop(0)
        L.append(s)
    
print(-1, -1)


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  if(n % 2 ==1)
    cout << "No" << endl;
  else {
    bool flag = true;
    for(int i=0; i<n/2; i++) {
      if(s.at(i) != s.at(i+n/2)) {
        flag = false;
        break;
      }
    }
    if(flag)
     cout << "Yes" << endl;
    else
     cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	const int dx[4] = { 0,1,0,-1 };
	const int dy[4] = { -1,0,1,0 };
	while (1) {
		int k, i, j, rs, n, w, h;
		cin >> n;
		if (n == 0) break;
		vector<int> l(n);
		vector<int> t(n);
		vector<int> r(n);
		vector<int> b(n);
		for (i = 0; i < n; i++) {
			cin >> l[i] >> t[i] >> r[i] >> b[i];
		}
		{
			map<int, int> trans;
			for (i = 0; i < n; i++) {
				trans[l[i]] = 0;
				trans[r[i]] = 0;
			}
			i = 0;
			for (auto &p : trans) {
				p.second = i;
				i++;
			}
			w = 2 * i + 2;
			for (i = 0; i < n; i++) {
				l[i] = trans[l[i]];
				r[i] = trans[r[i]];
			}
		}
		{
			map<int, int> trans;
			for (i = 0; i < n; i++) {
				trans[t[i]] = 0;
				trans[b[i]] = 0;
			}
			i = 0;
			for (auto &p : trans) {
				p.second = i;
				i++;
			}
			h = 2 * i + 2;
			for (i = 0; i < n; i++) {
				t[i] = trans[t[i]];
				b[i] = trans[b[i]];
			}
		}
		vector2d(f, int, h, w, -1);
		for (k = 0; k < n; k++) {
			l[k] = 2 * l[k] + 1;
			r[k] = 2 * r[k] + 1;
			t[k] = 2 * t[k] + 1;
			b[k] = 2 * b[k] + 1;
			for (i = l[k]; i <= r[k]; i++) f[t[k]][i] = 0;
			for (i = l[k]; i <= r[k]; i++) f[b[k]][i] = 0;
			for (i = b[k]; i <= t[k]; i++) f[i][l[k]] = 0;
			for (i = b[k]; i <= t[k]; i++) f[i][r[k]] = 0;
		}
		/*
		for (auto d1 : f) {
			for (int d : d1) cout << d;
			cout << endl;
		}
		*/
		rs = 0;
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if (f[i][j] == -1) {
					rs++;
					queue<pair<int, int>> bfs;
					f[i][j] = rs;
					bfs.push({ i,j });
					while (!bfs.empty()) {
						int y = bfs.front().first;
						int x = bfs.front().second;
						bfs.pop();
						for (k = 0; k < 4; k++) {
							int nx = x + dx[k];
							int ny = y + dy[k];
							if (nx < 0 || w <= nx || ny < 0 || h <= ny || f[ny][nx] != -1)
								continue;
							bfs.push({ ny,nx });
							f[ny][nx] = rs;
						}
					}
				}
			}
		}
		/*
		for (auto d1 : f) {
			for (int d : d1) cout << d;
			cout << endl;
		}
		*/
		cout << rs << endl;
	}
	return 0;
}





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

string shuffle(string card, int h) {
  string tmp;
  tmp = card.substr(h, card.size() - h) + card.substr(0, h);
  return tmp;
}

int main() {
  
  while (true) {
    
    string card; cin >> card;
    
    if (card == "-") return 0;
    
    int m; cin >> m;
    
    for (int i = 0; i < m; i++) {
      int h; cin >> h;
      card = shuffle(card, h);
    }
    
    cout << card << endl;
    
  }
  
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	if (s[0] == s[1] or s[1] == s[2] or s[2] == s[3]){
		cout << "Bad";
	}
	else cout << "Good";
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = (n / (a+b)) * a;
    n %= (a+b);
    ans += min(n, a);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n, mod = 1e9 + 7;
vector< vector< int > > arr( 23, vector< int >( 23 ) );
long long dp[ 1 << 21 ][ 22 ];

long long solve( int mask, int pos, int cnt )
{
	if( pos == 0 )
	{
		return ( cnt == n ? 1 : 0 );
	}
	if( dp[ mask ][ pos ] != -1 )
	{
		return dp[ mask ][ pos ];
	}
	long long ans = 0;
	for( int i = 1; i <= n; ++i )
	{
		if( arr[ pos ][ i ] && !( mask & ( 1 << ( i - 1 ) ) ) )
		{
			ans += solve( mask | ( 1 << ( i - 1 ) ), pos - 1, cnt + 1 );
			ans %= mod;
		}		
	}
	return dp[ mask ][ pos ] = ans;
}

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n;
	for( int i = 1; i <= n; ++i )
	{
		for( int j = 1; j <= n; ++j )
		{
			cin >> arr[ i ][ j ];		
		}
	}
	memset( dp, -1, sizeof( dp ) );
	cout << solve( 0, n, 0 ) << "\n";
	return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll H, W;
    cin >> H >> W;
    vector<string> S;
    REP(i, H) 
    {
        string s;
        cin >> s;
        S.push_back(s);
    }

    map<pair<ll, ll>, vector<pair<ll, ll>>> G;
    vector<pair<ll, ll>> road;
    REP(i, H) 
    {
        REP(j, W)
        {
            pair<ll, ll> p = make_pair(i, j); 
            if (S[i][j] == '.')
            {
                if (i - 1 >= 0) if (S[i - 1][j] == '.') G[p].push_back(make_pair(i - 1, j));
                if (j - 1 >= 0) if (S[i][j - 1] == '.') G[p].push_back(make_pair(i, j - 1));
                if (i + 1 < H) if (S[i + 1][j] == '.') G[p].push_back(make_pair(i + 1, j));
                if (j + 1 < W) if (S[i][j + 1] == '.') G[p].push_back(make_pair(i, j + 1));
                road.push_back(p);
            }
        }
    }
    ll ans = 0;
    for (ll i = 0; i < road.size(); ++i)
    {
        pair<ll, ll> st = road[i];
        bool isDestination = false;
        queue<pair<ll, ll>> q;
        q.push(st);
        map<pair<ll, ll>, bool> visited;
        REPV(iter, road) visited[*iter] = false;
        map<pair<ll, ll>, ll> dist;
        dist[st] = 0;
        while(!q.empty())
        {
            pair<ll, ll> p = q.front();
            q.pop();
            visited[p] = true;
            REPV(iter, G[p])
            {
                if (!visited[*iter])
                {
                    visited[*iter] = true;
                    q.push(*iter);
                    dist[*iter] = dist[p] + 1;
                    ans = max(ans, dist[*iter]);
                }
            }
        }
    }


    cout << ans << endl;
}


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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int a;
  cin >> a;
  cout << 3*(a*a) << endl;
}


/*





















*/


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

using namespace std;
using ll=long long int;
int n,cnt;
bool ok=false;
string ans;

void dfs(int digit,int idx,int cur,string res) {
    if(idx==digit) {
        cnt++;
        //cout<<"::"<<cnt<<"\t"<<res<<endl;
        if(cnt==n) {
            ans=res; ok=true; return;
        }
        return;
    }
    if(cur==-1) {
        for(int i=1;i<=9;i++) {
            dfs(digit,idx+1,i,res+to_string(i));
        }
        return;
    }
    if(cur-1>=0) dfs(digit,idx+1,cur-1,res+to_string(cur-1));
    dfs(digit,idx+1,cur,res+to_string(cur));
    if(cur+1<10) dfs(digit,idx+1,cur+1,res+to_string(cur+1));
    return;
}

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n; string temp;
    for(int i=1;i<=20;i++) {
        if(ok) break;
        dfs(i,0,-1,temp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

void era_transform(int year, int month, int day);

int main(void)
{
    int year, month, day;
    while (scanf("%d %d %d",&year, &month, &day) != EOF) {
        era_transform(year, month, day);
    }
    return 0;
}

void era_transform(int year, int month, int day)
{
    int z = year * 10000 + month * 100 + day;// 時代判定用関数
    if (z <= 18680907) {
        printf("pre-meiji\n");
    } else if (z <= 19120729) {
        printf("meiji %d %d %d\n", year - 1867, month, day);
    } else if (z <= 19261224) {
        printf("taisho %d %d %d\n", year - 1911, month, day);
    } else if (z <= 19890107) {
        printf("showa %d %d %d\n", year - 1925, month, day);
    } else {
        printf("heisei %d %d %d\n", year - 1988, month, day);
    }
}

Measured memory_bytes: 1036
#include <stdio.h>

int main(void)
{
	int a,b,c,d,e[10000],f[10000],h,g,i,j;
	a = b = 1;
	h = g = 0;
	
	while(a != 0 && b != 0){
		scanf("%d %d",&a,&b);
		
		e[h] = a;
		f[g] = b;
		
		++g;
		++h;
		j = h;
	}
	g = h = 0;
	
	for(i = 0;i < j;++i){
		for(c = 0;c < e[g-1];++c){
			for(d = 0;d < f[h-1];++d){
				if(c == 0 || c == e[g-1]-1){
					printf("#");
				}
				else if(d == 0 || d == f[h-1]-1){
					printf("#");
				}
				else {
					printf(".");
				}
			}
			printf("\n");
		}
		if(c != 0){
			printf("\n");
		}
		++g;
		++h;
	}
	
	return(0);
}

Measured memory_bytes: 2612
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    string s; cin >> s;
    ll num_0=0,num_1=0;
    for(ll i=0;i<s.size();i++){
        if(s[i] == '0') num_0++;
        else num_1++;
    }

    cout << min(num_0,num_1) * 2 << endl;


    return 0;
}



Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>

#define ll long long
#define LL long long
#define ULL unsigned long long 
#define ull unsigned long long 
#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 int(x) int x;scanf("%d",&x);
#define double(x) double x;scanf("%lf",&x);
#define string(x) double string;cin>>x;

using namespace std;

int main()
{
	int w, n;
	int tmp[100] = {};
	scanf("%d %d", &w, &n);
	int a[100], b[100];
	int tmp_num;
	REP(i, w) {
		tmp[i] = i + 1;
	}
	for (int i = 0; i < n; i++) {
		scanf("%d,%d", &a[i], &b[i]);
	}

	for (int i = 0; i < n; i++) {
		tmp_num = tmp[a[i]-1];
		tmp[a[i]-1] = tmp[b[i]-1];
		tmp[b[i]-1] = tmp_num;
	}
	
	REP(i, w) {
		cout << tmp[i] << endl;
	}

	return 0;
}

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

int main(){
  int K;
  cin>>K;
  int A, B ; 
  cin>>A>>B;
  if(B/K!=A/K){
    cout<<"OK"<<endl;
  }else{
     if(B%K==0||A%K==0)
     {
    cout<<"OK"<<endl;
     }else{
       cout<<"NG"<<endl;
     }
  }
}


Measured memory_bytes: 3004
#include<stdio.h>
void quicksort(int a[],int s,int t){
  if(s<t){
    int i=s,j=t,p=a[(s+t)/2];
    while(1){
      while(a[i]<p)i++;
      while(p<a[j])j--;
      if(i>=j)break;
      a[i]^=a[j]^=a[i]^=a[j];
      i++;j--;
    }
    quicksort(a,s,i-1);quicksort(a,j+1,t);
  }
}
int main(){
  int n,k,i,l[50],t=0;
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++)scanf("%d",&l[i]);
  quicksort(l,0,n-1);
  for(i=1;i<=k;i++)t+=l[n-i];
  printf("%d",t);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dp[101010][110];
ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };

//long longしか使わない
//素数は1より大きい
int main() {
	string s, t;
	cin >> s >> t;
	ll n = s.length();
	ll ans = 0;
	rep(i, n) {
		if (s[i] != t[i])ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3920
#include<stdio.h>

int main(){
	
int rc[101][101]={0},R,C,i,j;

scanf("%d %d",&R,&C);
for(j=0;j<R;j++){
	for(i=0;i<C;i++){
		scanf("%d",&rc[j][i]);
		rc[j][C]=rc[j][C]+rc[j][i];
		rc[R][i]=rc[R][i]+rc[j][i];
	}
}

for(i=0;i<C;i++){
	rc[R][C]=rc[R][C]+rc[R][i];
}

for(j=0;j<=R;j++){
	for(i=0;i<=C;i++){
		printf("%d",rc[j][i]);
		if(i<C){printf(" ");
		}else{
			printf("\n");
		}
	}
}
return 0;

}

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

const int S=(1<<20)+5;
char buf[S],*bH,*bT;
inline char Get()
{
    if(bH==bT) bT=(bH=buf)+fread(buf,1,S,stdin);
    if(bH==bT) return -1;return *bH++;
}
inline int read()
{
    int x=0,fg=1;char c=Get();
    while(!isdigit(c)&&c!='-') c=Get();
    if(c=='-') fg=-1,c=Get();
    while(isdigit(c)) x=x*10+c-'0',c=Get();
    return x*fg;
}

typedef long long LL;
const int N=100010;
int num[N<<2];
int a[N],b[N],n,m,k;
LL sum[N],dp[N];
int L[N],R[N],H[N<<1];

void pushdown(int o)
{
    if(!num[o]) return;
    num[o<<1]=num[o<<1|1]=num[o];
    num[o]=0;
}

void Modify(int o,int l,int r,int nl,int nr,int x)
{
    if(nl>nr) return;
    if(l>=nl&&r<=nr){num[o]=x;return;}
    int mid=(l+r)/2;pushdown(o);
    if(nl<=mid) Modify(o<<1,l,mid,nl,nr,x);
    if(nr>mid) Modify(o<<1|1,mid+1,r,nl,nr,x);
}

int Query(int o,int l,int r,int p)
{
    if(l==r) return num[o];
    int mid=(l+r)/2;pushdown(o);
    if(p<=mid) return Query(o<<1,l,mid,p);
    else return Query(o<<1|1,mid+1,r,p);
}

LL gao(int x)
{
    int p=Query(1,1,m,x);
    return p?dp[p]+(H[L[p]]-H[x]+k)%k:0;
}

int main()
{
    n=read();k=read();
    for(int i=1;i<=n;i++)
    {
        a[i]=read();b[i]=read();
        sum[i]=sum[i-1]+a[i];
        if(b[i]==2) continue;
        if(2*a[i]>k){puts("-1");return 0;}
    }
    for(int i=1;i<=n;i++)
    {
        if(b[i]==1)
        {
            L[i]=(k-2ll*sum[i-1]%k)%k;
            R[i]=(k-2ll*sum[i]%k)%k;
        }
        else L[i]=0,R[i]=k-1;
        H[2*i]=L[i];H[2*i-1]=R[i];
    }
    sort(H+1,H+1+2*n);
    m=unique(H+1,H+1+2*n)-(H+1);
    for(int i=1;i<=n;i++)
    {
        L[i]=lower_bound(H+1,H+1+m,L[i])-H;
        R[i]=lower_bound(H+1,H+1+m,R[i])-H;
    }
    for(int i=n;i>=1;i--)
    {
        dp[i]=gao(L[i]);
        if(L[i]>R[i]) Modify(1,1,m,R[i]+1,L[i]-1,i);
        else Modify(1,1,m,1,L[i]-1,i),Modify(1,1,m,R[i]+1,m,i);
    }
    LL ans=dp[1];
    for(int i=m;i>=1;i--) ans=min(ans,gao(i));
    printf("%lld\n",ans+2ll*sum[n]);
    return 0;
}

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

int main(){
  int n;
  char A;
  for(n=0;n<4;n++){
    A=getchar();
    cout << A;
  }
  cout << " ";
  for(n=0;n<8;n++){
    A=getchar();
    cout << A;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    int n;
    cin >> n;
    vector<int> t(n+1,0);
    vector<int> x(n+1,0);
    vector<int> y(n+1,0);
    rep2(i,1,n+1) cin >> t[i] >> x[i] >> y[i];

    rep2(i,1,n+1)
    {
        int dxy = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);
        int dt = t[i]-t[i-1];
        if(dxy>dt || (dt-dxy)%2!=0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
//解説AC
int main() {
  string s;
  cin >>s;
  int cnt_a=0,cnt_b=0,cnt_c=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='a')cnt_a++;
    else if(s[i]=='b')cnt_b++;
    else cnt_c++;
  }
  if(abs(cnt_a-cnt_b)<=1&&abs(cnt_b-cnt_c)<=1&&abs(cnt_c-cnt_a)<=1)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 512
n=int(input())
ab = []
for _ in range(3):
    s=list(input())
    ab.append(s)

ans = 0

for i in range(n):
    memo = []
    for j in range(3):
        memo.append(ab[j][i])
    ans += len(set(memo))-1
    
print(ans)

Measured memory_bytes: 38384
N, M = map(int, input().split())

MOD = 1000000007

p = [0]*(N+1)
for i in range(M):
    a = int(input())
    p[a] = -1

p[N] = 1
if p[N-1] != -1:
    p[N-1] = 1

for i in range(N-2, -1, -1):
    if p[i] == -1:
        continue
    if p[i+1] == -1 and p[i+2] == -1:
        p[i] = -1
    elif p[i+1] == -1:
        p[i] = p[i+2]
    elif p[i+2] == -1:
        p[i] = p[i+1]
    else:
        p[i] = p[i+1] + p[i+2]

    if p[i] > 0:
        p[i] %= MOD

ans = p[0]
if ans < 0:
    ans = 0

print(ans)



Measured memory_bytes: 6900
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
#define MAX_INT INT_MAX

int main(){
    int r;cin>>r;cout<<3*r*r<<endl;
}

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

const long long MOD=1000000007;

int main(){
    long long n;
    long long power=1;
    cin >> n;
    for(long long i=1;i<=n;i++){
        power *= i;
        power %= MOD;
    }
    cout << power << endl;
}

Measured memory_bytes: 256
import math
import numpy as np
import queue
from collections import deque
import heapq

a,b,h,m = map(int,input().split())
deg = abs(h*30+m*0.5-m*6)
c2 = a**2+b**2-2*a*b*math.cos(math.radians(deg))
print(c2**(0.5))


Measured memory_bytes: 27264
a=[]
N=[1,5,2,3,0,4]
S=[4,0,2,3,5,1]
E=[3,1,0,5,4,2]
W=[2,1,5,0,4,3]


a= [int(i) for i in input().split()]



n = input()
b=[0]*6
for i in range(len(n)):
    for j in range(6):b[j] = a[j]
    
    if n[i] == "N":
        for j in range(6):
            a[j] = b[N[j]]    
        
    elif n[i] == "S":
        for j in range(6):
            a[j] = b[S[j]]
        
    elif n[i] == "W":
        for j in range(6):
            a[j] = b[W[j]]
        
    elif n[i] == "E":
        for j in range(6):
            a[j] = b[E[j]]

print(a[0])



Measured memory_bytes: 5612
N = int(input())
ans = 0
max_devide_count = -1

for i in range(N, 0, -1):
    
    binary_i_reverse = bin(i)[:1:-1]
    devide_count = 0
    
    for j in binary_i_reverse:
        if j == '0':
            devide_count += 1
        else:
            break
    
    if max_devide_count < devide_count:
        max_devide_count = devide_count
        ans = i

print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

#define int long long
#define rr register

#define MAXN 200010
#define inf 1e18

using namespace std;

inline int read(int &T) {
    int s = 0, f = 0;
    char ch = getchar();
    while (!isdigit(ch)) {f |= ch == '-'; ch = getchar();}
    while (isdigit(ch)) {s = s * 10 + (ch ^ 48); ch = getchar();}
    return T = f ? -s : s;
}

void print(int x) {
    if (x < 0) x = -x, putchar('-');
    if (x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

double a, b, h, m;

double pi = 3.141592653589793238462643383279;

signed main() {
    cin >> a >> b >> h >> m;
    double d = fabs((pi / 30.0) * m - ((pi / 6.0) * h + (pi / 360) * m));
    printf("%.20lf", sqrt(a * a + b * b - 2.0 * a * b * cos(d)));
}

Measured memory_bytes: 4192