akhauriyash/Code-Regression huggingface dataset:
import sys,io
from functools import lru_cache
#read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
def mp(arg):
  return map(int,arg.split())
n=read()
h=list(reads())
@lru_cache(None)
def cost(k):
    if k==0:
        return 0
    elif k==1:
        return abs(h[0]-h[1])
    return min(cost(k-1)+abs(h[k-1]-h[k]),cost(k-2)+abs(h[k-2]-h[k]))
print(cost(n-1))

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int n, tmp;
	cin >> n;
	unordered_map<int, int> m;
	REP(i, 0, n){
		cin >> tmp;
		++m[tmp];
	}
	ll ans = 0;
	for(auto it = m.begin(); it != m.end(); it++){
		if(it->F > it->S) ans += it->S;
		else ans += (it->S - it->F);
	}
	cout << ans;


}


Measured memory_bytes: 4260
n,m=[int(i) for i in input().split()]
a_to_b=[0]*n
for i in range(m):
    a,b=[int(j) for j in input().split()]
    if a==1:
        a_to_b[b]+=1
    if b==n:
        a_to_b[a]+=1
if 2 in a_to_b:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

int main() {
  int n, t;
  cin >> n >> t;
  int times[n];
  int interval;
  int stopTime = 0;
  cin >> times[0];
  for(int i = 1; i < n; i++) {
    cin >> times[i];
    interval = times[i] - times[i - 1];
    if(t < interval) {
      stopTime += interval - t;
    }
  }
  int overall = times[n - 1] - times[0] + t;
  int ans = overall - stopTime;
  cout << ans << endl;
  return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  int ans = 0;
  for (int i = a; i <= b; i++) {
    if (c % i == 0) {
      ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}


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

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

int main(){
  int N; cin >> N;
  int total = findSumOfDigits(N);
  if(N % total == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int w, h;
    cin >> w >> h;
    do
    {
        vector<vector<vector<P>>> g(h, vector<vector<P>>(w, vector<P>()));
        int ls = 2 * h - 1;
        rep(i, ls)
        {
            int y = i / 2;
            if (i % 2 == 0)
            {
                rep(j, w - 1)
                {
                    int wall;
                    cin >> wall;
                    if (!wall)
                    {
                        g[y][j].emplace_back(P(y, j + 1));
                        g[y][j + 1].emplace_back(P(y, j));
                    }
                }
            }
            else
            {
                rep(j, w)
                {
                    int wall;
                    cin >> wall;
                    if (!wall)
                    {
                        g[y][j].emplace_back(P(y + 1, j));
                        g[y + 1][j].emplace_back(P(y, j));
                    }
                }
            }
        }

        queue<P> q;
        q.push(P(0, 0));
        vector<vector<int>> d(h, vector<int>(w, -1));
        d[0][0] = 1;
        while (q.size())
        {
            P n = q.front();
            q.pop();
            int ny = n.first,
                nx = n.second;
            if (n == P(h - 1, w - 1))
            {
                break;
            }

            for (P t : g[ny][nx])
            {
                int ty = t.first, tx = t.second;
                if (d[ty][tx] < 0)
                {
                    d[ty][tx] = d[ny][nx] + 1;
                    q.push(t);
                }
            }
        }

        cout << max(0, d[h - 1][w - 1]) << endl;

        cin >> w >> h;
    } while (w != 0 && h != 0);

    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll n; cin>>n;
  ll a[n]; rep(i, n) cin>>a[i];
  ll cnt=0;
  for(ll i=1; i<n-1; i++){
    if(min(min(a[i-1], a[i]), a[i+1])!=a[i]&&
        max(max(a[i-1], a[i]), a[i+1])!=a[i]) cnt++;
  }
  cout << cnt;
}

Measured memory_bytes: 3480
C = list(list(map(int,input().split())) for _ in range(3))
a = C[0][0] + C[1][1] + C[2][2]
b = C[0][2] + C[1][0] + C[2][1]
c = C[0][1] + C[1][2] + C[2][0]
if a == b == c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9192
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int k = Integer.parseInt(scanner.nextLine());
        if (k % 2 == 0) {
            System.out.println((k / 2) * (k / 2));
        } else {
            System.out.println((k / 2) * ((k / 2) + 1));
        }
    }
}


Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<vector>
#include<set>
using namespace std;

#define ll long long
#define in ({ll x=0;int o=0,c=getchar();for(;!isdigit(c);c=getchar()) o=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';o?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})
#define instring ({string s;char c=getchar();while(c==' '||c=='\n') c=getchar();while(c!=' '&&c!='\n') s+=c,c=getchar();s;})

#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define ROF(i,a,b) for(auto i=b;a<=i;i--)
#define rr(x) " "<<#x<<'='<<x<<" "

#define bitnum(x) __builtin_popcountll(x)
#define bitl(x) (64-__builtin_clzll(x))
#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))

#define mt make_tuple
#define pi pair<int,int>
#define x first
#define y second

#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define allv(a) a.begin(),a.end()
#define endv(a) (int)a.size()-1

#define ifnot(x) if(!(x))
#define middle(a,b) (a+(b-(a))/2)
#define bp(x) ((x)*(x))
#define pw2(x) (1ll<<x)

#define Min(a,b) ({bool o=false;if(a>b) {a=b;o=true;};o;})
#define Max(a,b) ({bool o=false;if(a<b) {a=b;o=true;};o;})
////////////////////////////////////////// HUX
int a[5],n;
main()
{
    n=in;
    FOR(i,1,n) a[i%2]++;
    cout<<fixed<<setprecision(6)<<(double)a[1]/n;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int i = 1, x;
		while(true) {
			x = sc.nextInt();
			if(x == 0)
				break;
			System.out.println("Case " + i++ + ": " + x);

		}
	}
}



Measured memory_bytes: 41368
// #includes {{{
#include <bits/stdc++.h>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

int N;

int main(){
	map<int,int> a;
	cin>>N;
	REP(i,N){
		int t;
		cin>>t;
		a[t]++;
	}
	map<int,int> b;
	for(auto &t:a)b[t.second%2]++;
	int ans = b[1]+b[0];
	if(b[0]%2==1)ans--;
	cout<<ans<<endl;
}


Measured memory_bytes: 4992
using System;

public class threeone
{
	static public void Main(string[] args)
	{
		string current = Console.ReadLine();
		char[] hoge = new char[3];
		int[] num = new int[3];
		int type = 0;


		for(int i = 0; i < 3; i++)
		{
			hoge[i] = current[i];
			num[i] = (int) char.GetNumericValue(hoge[i]);
		}

		if(num[0] < num[1]) //122
		{
			type = 1;

		}
		else if(num[0] == num[1]) //11?
		{
			if(num[1] < num[2])
			{
				type = 1;
			}
			else if(num[1] == num[2] || num[1] > num[2]) //111or110
			{
				type = 2; 
			}
		}
		else if(num[0] > num[1]) //211
		{
			type = 2;
		}

		switch(type)
		{
			case 1: //入力値の百の位の数の１大きい数でゾロ目
				for(int s = 0; s < 3; s++)
				{
					Console.Write(num[0] + 1);
				}
				break;

			case 2: //入力値の百の位の数でゾロ目
				for(int s = 0; s < 3; s++)
				{
					Console.Write(num[0]);
				}
				break;
		}

		return;
	}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
    ll a, b, c, d;
    cin>> a>> b>> c>> d;
    vll v(4);
    v[0] = a*c, v[1] = a*d;
    v[2] = b*c, v[3] = b*d;
    sort(all(v));
    cout<< v.back()<< "\n";
    return 0;
}
//Counting problems: Sometimes easier to find complement of the answer
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 3652
n = int(input())
k = int(input())
x = list(map(int, input().split()))
t = 0

for i in range(1,n+1):
    k1 = 0
    k2 = 0
    k1 = abs(x[i-1]-0)*2
    k2 = abs(k-x[i-1])*2
    t += min(k1, k2)

print(t)

Measured memory_bytes: 61528
#include<bits/stdc++.h>
int popcount(int n){
    int res = 0;
    int t = 0;
    while((1 << t) <= n){
        if((1 << t) & n ) ++res;
        ++t;
    }
    return res;
}
std::vector<int>a,b,c,d;
int N,M,Q;
int ans = -1;
void solve(std::vector<int>v){
    if(v.size() == N){
        int tans = 0;
        for(int i  = 0; i < Q; ++i)
            if(v[b[i] - 1] - v[a[i] - 1] == c[i])
                tans += d[i];
        ans = std::max(ans,tans);
    } else {
        for(int i = v.back(); i <= M; ++i){
            auto u = v; u.push_back(i);
            solve(u);
        }
    }
}
int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cin >> N >> M >> Q;
    for(int i = 0; i < Q; ++i){
        int e,f,g,h;
        std::cin >> e >> f >> g >> h;
        a.emplace_back(e); b.emplace_back(f);
        c.emplace_back(g); d.emplace_back(h);
    }
    for(int i = 1; i <= M; ++i){
        std::vector<int>u(1,i);
        solve(u);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3584
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return input()
def n():
    return int(input())
def d():
    return float(input())

def ls():
    return input().split()
def ln():
    return map(int, input().split())
def ld():
    return map(float, input().split())

def fs():
    return [input() for i in range(input())]
def fn():
    return [int(input()) for i in range(input())]
def fd():
    return [float(input()) for i in range(input())]

A,B = ln()


print(A*B-A-B+1)


Measured memory_bytes: 5712
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; 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(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<string>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  string s, t;
  int a, b;
  string u;
  cin >> s >> t >> a >> b >> u;
  if (u == s) a--;
  else b--;
  printf("%d %d\n", a, b);
  return 0;
}

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

int main(){
    string s;
    cin >> s;

    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == ','){
            cout << " ";
            continue;
        }
        cout << s.at(i);
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int unsigned x;
	int unsigned y;
	int unsigned temp;
	int unsigned i;

	for(i=0; i<3000; i++)
	{
		scanf("%d%d", &x, &y);

		if( x<0 || x>10000 || y<0 || y>10000 )
		{
			return 1;
		}

		if( x == 0 && y == 0 )
		{
			break;
		}

		if( x > y )
		{
			temp = x;
			x = y;
			y = temp;
		}
		else
		{/*No Operation*/}

		printf("%d %d\n", x, y);

	}

	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, a[100001], i, num, count, ans=0;

    cin >> N;

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

    sort(a+1, a+N+1);

    if(N==1){
        if(a[1]==1) cout << 0 << endl;
        else cout << 1 << endl;
    }

    else{
        count = 1;
        for(i=2; i<=N; i++){
            if(a[i-1]==a[i]){
                count++;
            }
            else{
                if(count >= a[i-1]){
                    ans += (count-a[i-1]);
                }
                else{
                    ans += count;
                }
                count = 1;
            }
        }

        if(count >= a[N]){
            ans += (count-a[N]);
        }
        else{
            ans += count;
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
const int N = 1e5 + 10;
#define singleCase
// #define multipleCase
int n,m,mem[N];
bool pos[N];

void work() {
   fill (mem , mem + N , 1);
   pos[1] = 1;
   in(n); in(m);
   for (int i = 0, u , v ; i < m ; i++) {
      in(u); in(v);
      if (pos[u]) pos[v] = 1;
      mem[u]--;
      mem[v]++;
      if (mem[u] == 0) pos[u] = 0;
   }
   int sol = 0;
   for (int i = 1 ; i <= n ; i++) {
      sol += mem[i] > 0 && pos[i];
   }
   printf("%d\n" , sol);
   return;
}

int main() {
   #ifdef multipleCase
      int nQ; in(nQ);
      while (nQ--)
         work();
   #endif
   #ifdef singleCase
      work();
   #endif
   return 0;
}

void in(int &x) {
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c == '-') {
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	  x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 4216
import java.util.Scanner;

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

        int k = scanner.nextInt();
        int n = scanner.nextInt();

        long first = 0;
        long previous = 0;
        long max = 0;
        long sum = 0;
        for (long i = 0; i < n; i++) {
            int a = scanner.nextInt();
            if (i == 0) {
                first = a;
                previous = a;
                max = a;
                sum = a;

            } else {
                long aida = a - previous;
                previous = a;
                sum = sum + aida;
                if (aida > max) {
                    max = aida;
                }
            }
        }
        long saigo = k - sum + first;

        if (saigo > max) {
            max = saigo;
        }
        System.out.println(k - max);
    }
}


Measured memory_bytes: 64904
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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 ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  string s,t;
  cin >> s >> t;
  int ans = 0;
  int n = s.size();
  rep(i,n){
    if(s[i]!=t[i])ans++;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
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;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

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

    ll a[3][3];
    rep(i, 3)rep(j, 3) cin >> a[i][j];
    ll n;
    vll cnt(110, 0);
    cin >> n;
    rep(i, n) {
        ll b;
        cin >> b;
        cnt[b] = 1;
    }

    vvll check(3, vll(3, 0));
    rep(i, 3) rep(j, 3) if(cnt[a[i][j]] == 1) check[i][j] = 1;

    bool ok = false;
    rep(i, 3) if(check[i][0] && check[i][1] && check[i][2]) ok = true;
    rep(i, 3) if(check[0][i] && check[1][i] && check[2][i]) ok = true;
    if(check[0][0] && check[1][1] && check[2][2]) ok = true;
    if(check[0][2] && check[1][1] && check[2][0]) ok = true;

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

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


// a^n mod を計算する
long int modpow(long int a, long int n, long int mod) {
    long int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

long int modcomb(long int a, long int b, long int mod){
    long int res = 1;
    for(long int i = a; i > a - b; i--){
        res *= i % mod;
        res %= mod;
    }
    res %= mod;
    for(long int i = 1; i <= b; i++){
        long int i_inv = modpow(i, mod - 2, mod);
        res *= i_inv % mod;
        res %= mod;
    }
    res %= mod;
    // cout << res << endl;
    return res;
}



int main(){
    long int mod = 1000000007;
    long int n, a, b;
    cin >> n >> a >> b;

    if (n == 2) {
        cout << 0 << endl;
        return 0;
    }
    
    long int ans = 1;
    // 2のn乗の計算
    long int modbin[31];
    modbin[0] = 2;
    for(int i = 1; i < 31; i++){
        modbin[i] = (modbin[i-1] * modbin[i-1]) % mod;
    }
    // rep(i, 31) cout << modbin[i] << endl;
    long int num = n;
    long int bin[31];
    rep(i, 31){
        bin[i] = num & 1;
        num >>= 1;
    }
    // rep(i, 31) cout << bin[i] << endl;
    rep(i, 31) {
        if (bin[i] == 1) {
            ans *= modbin[i];
            ans %= mod;
        }
    }
    ans -= 1;
    // cout << ans - 1 <<endl;
    ans -= modcomb(n , a, mod);
    ans -= modcomb(n , b, mod);

    while (ans < 0) {
        ans += mod;
    }

    
    

    // cout << n << endl;
    // cout << a << endl;
    // cout << modcomb(n , a, mod) << endl;
    // cout << modcomb(4 , 1, mod) << endl;
    cout << ans <<endl;
    
}

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

int main() {
    int N, a, ans = 0;
    cin >> N;
    bool is_up = false, is_down = false;
    cin >> a;
    int now_head = a;
    for (int i = 1; i < N; i++) {
        cin >> a;
        if (now_head < a) is_up = true;
        else if (now_head > a) is_down = true;
        else continue;
        if (is_up && is_down) {
            ans++; 
            is_up = is_down = false;
        }
        now_head = a;
    }
    ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
    Author : Pranav_Raut.
*/

#include<bits/stdc++.h>
using namespace std;
#define input(arr,n) for(ll i=0;i<n;i++){cin>>arr[i];}
typedef long long int ll;
ll MOD = 1000000007;
ll MAXN = 100005;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll t = 1;
    while(t--)
    {
        /* JUST CODE TILL YOU CRACK IT !!! */
		ll n,k;
      	cin>>n>>k;
      	ll arr[n+k];
      	ll ans[n+k];
      	input(arr,n);
      	for(ll i=n;i<n+k;++i)
        {
        	arr[i] = arr[n-1];
      		ans[i] = 0;
        }
        ans[n-1] = 0;
      	for(ll i=n-2;i>=0;--i)
        {
          	ll minn = INT_MAX;
          	for(ll j=1;j<=k;j++)
            {
            	ll tt = abs(arr[i]-arr[i+j])+ans[i+j];
            	if(tt<minn) minn = tt;
            }
        	ans[i] = minn;
        }
        cout<<ans[0]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(n)    for(int i = 0; i < (n); ++i)
#define RREP(n)   for(int i = (n); i >= 0; --i)
#define FOR(m, n) for(int i = (m); i < (n); ++i)
#define SZ(x)       ( (int)(x).size() )
#define BIT(n)      ( 1LL << (n) )
#define EXIST(x)    ( (x).find()		!= (x).end() )
#define DEBUG(n)    cerr << #n << " : " << n << '\n';
#define PB  push_back
#define UB  upper_bound			//k <
#define LB  lower_bound			//k	<= 
#define F   first
#define S   second
#define INF 1.0e9


using namespace std;

typedef long long			ll;
typedef pair<int, int>		pii;
typedef pair<long			long, long long>   pll;
typedef vector<int>			vi;
typedef vector<double>		vd;
typedef vector<long long>   vll
;

template<class T> void chmax(T &	a, const T & b){ if( a < b ) a = b; }
template<class T> void chmin(T &	a, const T & b){ if( a > b ) a = b; }

int r_up(const int a, const int b){ return (a + b - 1) / b; }

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

struct UFT{
  vi	p;
  UFT(){}
  UFT(int N)       { p.resize( N, -1 ); }
  int	par(int a)   { if( p[a] >= 0 ){ p[a]  = par( p[a] ); return p[a]; } return a;  }
  int size(int a)  { return -p[par(a)]; }
  bool	same(int a, int b) { return par(a)	 == par(b); }
  void unite(int	a, int b){
	a	  = par(a);  b = par(b);
	if( a == b ) return;
	if( size(a) < size(b) ) swap(a,b);
	p[a] -= size(b);
	p[b]  = a;
  }
};

void pfac(int n,map<int, ll>&mil){
  FOR(2,sqrt(n)+1){
	while(n%i==0){
	  n/=i;
	  mil[i]++;
	}
  }
  if(n>1)mil[n]++;
}

int main(){
  int n;cin>>n;
  map<int,ll>mil;
  FOR(2,n+1)
	pfac(i,mil);


  int primeBox[100]={};
  for(auto it = mil.begin(); it != mil.end(); it++){
	primeBox[it->F]=it->S;
  }

  ll ans=0;

  REP(100){
	if(primeBox[i])DEBUG(primeBox[i]);
	if(primeBox[i]>=74)ans++;
  }
  
  REP(100)
	for(int j=0;j<100;++j){
	  if(i==j)continue;
	  if(primeBox[i]>=2&&primeBox[j]>=24)ans++;
	}

  REP(100)
	for(int j=0;j<100;++j){
	  if(i==j)continue;
	  if(primeBox[i]>=4&&primeBox[j]>=14)ans++;	  
	}
  REP(100){
	ll tmp=0;
	for(int j=0;j<100;++j){
	  for(int k=j+1;k<100;++k){
		if(i==j||j==k||k==i)continue;
		if(primeBox[i]>=2&&primeBox[j]>=4&&primeBox[k]>=4){tmp++;DEBUG(tmp);}
	  }
	}
	ans+=tmp;
  }
  
  cout<<ans<<endl;
	
  return 0;
}


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


int main(){
  string S;
  long N,L;
  long sum = 0;
  
  cin >> S;
  L = S.size();
  N = stol(S);

  for(int tmp = 0;tmp < (1 << L-1);tmp++){
    bitset<9> s(tmp);
    int keep = 0;
    long M = N;
    for(int i = 0;i < L-1;++i){
      if(s.test(i)){
        sum += M%(int(pow(10,i+1-keep)));
        M /= int(pow(10,i+1-keep));
        keep = i+1;
      }
    }
    sum += M;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
class UnionFind
  def initialize(n)
    @n = n
    @par = Array.new(@n).map.with_index{|x, i| i}
    @chl = Array.new(@n).map{[]}
    @con = (@n-1)*(@n-2)/2
  end
  def union(a, b)
    pa, pb = [@par[a], @par[b]]
    if pa < pb then
      absorb(a, b)
    elsif pa > pb then
      absorb(b, a)
    end
  end
  def con
    @con
  end
  
  private
  
  def absorb(pa, ch)
    par = @par[pa]
    chl = @par[ch]
    @con += (@chl[par].size * (@chl[par].size+1))/2
    @con += (@chl[chl].size * (@chl[chl].size+1))/2
    @chl[chl].each{|c|
      @chl[par] << c
      @par[c] = par
    }
    @chl[chl] = nil
    @chl[par] << chl
    @par[chl] = par
    @con -= (@chl[par].size * (@chl[par].size+1))/2
  end
end

N, M = gets.chomp.split(" ").map(&:to_i)
E = Array.new(M).map{
  gets.chomp.split(" ").map(&:to_i)
}

uf = UnionFind.new(N+1)
ans = E.reverse.map{|a, b|
  uf.union(a, b)
  uf.con
}

ans.unshift(N*(N-1)/2)
ans.pop
puts ans.reverse*?\n


Measured memory_bytes: 32508
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define PI 3.141592653589793238
#define int long long
using namespace std;
struct Point3D{
  double x,y,z;
  Point3D(){}
  Point3D(double x,double y,double z):x(x),y(y),z(z){}
  Point3D operator+(Point3D p) {return Point3D(x+p.x,y+p.y,z+p.x);}
  Point3D operator-(Point3D p) {return Point3D(x-p.x,y-p.y,z-p.z);}
  Point3D operator*(double k){return Point3D(x*k,y*k,z*k);}
  Point3D operator/(double k){return Point3D(x/k,y/k,z/k);}
  double norm(){return x*x+y*y+z*z;}
  double abs(){return sqrt(norm());}
  bool operator < (const Point3D &p) const{
    if(x!=p.x) return x<p.x;
    if(y!=p.y) return y<p.y;
    return z<p.z;
  }
  bool operator == (const Point3D &p) const{
    return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS && fabs(z-p.z)<EPS;
  }
};
istream &operator >> (istream &is,Point3D &p){
  is>>p.x>>p.y>>p.z;
  return is;
}
ostream &operator << (ostream &os,Point3D p){
  os<<fixed<<setprecision(12)<<p.x<<" "<<p.y<<" "<<p.z;
  return os;
}

typedef Point3D Vector3D;
typedef vector<Point3D> Polygon3D;

struct Segment3D{
  Point3D p1,p2;
  Segment3D(){}
  Segment3D(Point3D p1, Point3D p2):p1(p1),p2(p2){}
};
typedef Segment3D Line3D;

istream &operator >> (istream &is,Segment3D &s){
  is>>s.p1>>s.p2;
  return is;
}

struct Sphere{
  Point3D c;
  double r;
  Sphere(){}
  Sphere(Point3D c,double r):c(c),r(r){}
};

istream &operator >> (istream &is,Sphere &c){
  is>>c.c>>c.r;
  return is;
}

double norm(Vector3D a){
  return a.x*a.x+a.y*a.y+a.z*a.z;
}
double abs(Vector3D a){
  return sqrt(norm(a));
}
double dot(Vector3D a,Vector3D b){
  return a.x*b.x+a.y*b.y+a.z*b.z;
}
Vector3D cross(Vector3D a,Vector3D b){
  return Vector3D(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);
}
double getDistanceLP(Line3D l,Point3D p){
  return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}

double getDistanceSP(Segment3D s,Point3D p){
  if(dot(s.p2-s.p1,p-s.p1) < 0.0 ) return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2) < 0.0 ) return abs(p-s.p2);
  return getDistanceLP(s,p);
}

bool intersectSC(Segment3D s,Sphere c){
  double d=getDistanceSP(s,c.c);
  if(d>c.r) return 0;
  return !((abs(s.p1-c.c)<=c.r)&&(abs(s.p2-c.c)<=c.r));
}
typedef bitset<2222> BS;
signed main(){
  int n,m,r;
  while(cin>>n>>m>>r,n||m||r){
    vector<Sphere> s(n),t(m);
    for(int i=0;i<n;i++) cin>>s[i];
    for(int i=0;i<m;i++) cin>>t[i];
    Point3D e;
    cin>>e;
    BS b[m];
    double l[m];
    for(int i=0;i<m;i++){
      b[i]=0;
      for(int j=0;j<n;j++)
	b[i][j]=intersectSC(Segment3D(t[i].c,e),s[j]);
      l[i]=t[i].r/norm(t[i].c-e);
    }
    double ans=0;
    for(int i=0;i<(1<<m);i++){
      BS tmp=0;
      double res=0;
      for(int j=0;j<m;j++){
	if(i>>j&1){
	  tmp|=b[j];
	  res+=l[j];
	}
      }
      if((int)tmp.count()>r) continue;
      ans=max(ans,res);
    }
    printf("%.12f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 3156
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;


using Graph=vector<vector<int>>;//グラフ型
void dfs(const Graph &G,int v/*根*/,vector<bool> &seen){
    seen[v]=true;  //vを訪問済にする
    for(auto next_v:G[v]){ //訪問済にしたvとつながっている場所を順番に探す
        if(seen[next_v]) continue; //もし探索済みならスルー
        dfs(G,next_v,seen); //再帰的に探索
    }
}

void bfs(const Graph &G,queue<int> &que/*発見したが訪問はしていない*/,vector<int> &dist/*開始地点からの距離*/,int s/*スタート地点*/){
    
    while(!que.empty()){
        int v=que.front();//queのうち先頭のものからスタート
        que.pop();//先頭を削除
        for(int nv :G[v]){//vとつながっている点を列挙
            if(dist[nv]!=-1) continue;//発見済(=距離が格納されている)であればスルー
            dist[nv]=dist[v]+1;//vとつながっている点に距離の情報を追加
            que.push(nv);//vとつながっている点を発見済にする
        }
    }
}

unsigned int to_int(char c){
    return c-48;
}

int main(void){
    ll h,w;
    cin>>h>>w;
    if(h==1||w==1){
        cout<<1;
    }
    else if((h*w)%2==1){
        cout<<(h*w+1)/2;
    }
    else{
        cout<<h*w/2;
    }
}


Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;

    return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    int ans = INT32_MAX;
    for (int i = 0; i <= N / 6; ++i)
    {
        int subSix = N - 6 * i;
        int sixQSum = 0;
        int qSix = i;
        while(qSix > 0)
        {
            sixQSum += qSix % 6;
            qSix = qSix / 6;
        }
        for (int j = 0; j * 9 <= subSix; ++j)
        {
            int sub = subSix -  9 * j;
            int nineQSum = 0;
            int qNine = j;
            while(qNine > 0)
            {
                nineQSum += qNine % 9;
                qNine = qNine / 9;
            }
            ans = min(ans, sixQSum + nineQSum + sub);
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
from collections import defaultdict

def main():
    N = int(input())
    combs = [(S[0], S[-1]) for S in map(str, range(1, N+1))]
    d = defaultdict(int)
    for pre, suf in combs:
        d[(pre, suf)] += 1
        d[(suf, pre)]

    ans = 0
    for key, val in d.items():
        pre, suf = key
        ans += val * d[(suf, pre)]
        
    print(ans)
if __name__ == "__main__":
    main()

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

using namespace std;

int main()
{
    int n,k;
    cin>>n;
    int a[n],dp[n][3],b[n],c[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    int m=INT_MAX;
    dp[0][0]=a[0]; dp[0][1]=b[0]; dp[0][2]=c[0];
    for(int i=1;i<n;i++){
        dp[i][0] = a[i]+max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i]+max(dp[i-1][2], dp[i-1][0]);
        dp[i][2] = c[i]+max(dp[i-1][0], dp[i-1][1]);
    }
    
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
    
   
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
char s[500000];
int i,j,k,n,m,x,y,t;
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for (i=1;i<=n;i++)x=x+(s[i]=='+'?1:-1);
	printf("%d\n",x);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int a,b,k;
int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0),cout.tie(0);
	cin>>k>>a>>b;
	bool tag=0;
	for(int i=a; i<=b; i++)
		if(i%k==0) tag=1;
	puts(tag?"OK":"NG");
	return 0;
}

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


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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<ll,int>
#define Lson L, mid, ls[rt]
#define Rson mid+1, R, rs[rt]
#define sys system("pause")
const int maxn=1e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
inline ll read()
{
    ll x=0;int f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,k,t;
ll a,b,pa,pb;
int main()
{
    int i,j;
    scanf("%d",&n);
    rep(i,1,n)
    {
        scanf("%lld%lld",&a,&b);
        if(i==1)pa=a,pb=b;
        else
        {
            ll j=max((pa%a==0?pa/a:pa/a+1),(pb%b==0?pb/b:pb/b+1));
            a*=j,b*=j;
            pa=a,pb=b;
        }
    }
    printf("%lld\n",a+b);
    //system("Pause");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define ll long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
#define N 200005
vector<int> G[N];
int n;
int dep[N],vis[N],ans[N];
void dfs(int u,int fa)
{
	dep[u]=dep[fa]+1;
	for(int v:G[u])
	{
		if(v==fa) continue;
		dfs(v,u);
	}
}
void p1()
{
	int l1=n/3,l2=n/3;
	if(n%3==1) l1++;
	if(n%3==2) l1++,l2++;
	int c1=0,c2=0,c3=0;
	for(int i=1;i<=n;i++)
	{
		if(dep[i]&1)
		{
			if(l1!=c1)
			{
				c1++;
				printf("%d ",3*c1-2);
			}
			else
			{
				c3++;
				printf("%d ",3*c3);
			}
		}
		else
		{
			if(l2!=c2)
			{
				c2++;
				printf("%d ",3*c2-1);
			}
			else
			{
				c3++;
				printf("%d ",3*c3);
			}
		}
	}
}
signed main()
{
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int u=read(),v=read();
		G[u].pb(v),G[v].pb(u);
	}
	dfs(1,0);
	int l1=n/3,l2=n/3;
	if(n%3==1) l1++;
	if(n%3==2) l1++,l2++;
	int c1=0,c2=0;
	for(int i=1;i<=n;i++)
	{
		if(dep[i]&1) c1++;
		else c2++;
	}
	if(c1>=l1&&c2>=l2) p1();
	else
	{
		if(c1<l1)
		{
			int c=0;
			for(int i=1;i<=n;i++)
			{
				if(dep[i]&1)
				{
					c++;
					ans[i]=c*3;
					vis[c*3]=1;
				}
			}
			int d=0;
			for(int i=1;i<=n;i++)
			{
				if(!(dep[i]&1))
				{
					d++;
					while(vis[d]) d++;
					ans[i]=d;
				}
			}
		}
		else
		{
			int c=0;
			for(int i=1;i<=n;i++)
			{
				if(!(dep[i]&1))
				{
					c++;
					ans[i]=c*3;
					vis[c*3]=1;
				}
			}
			int d=0;
			for(int i=1;i<=n;i++)
			{
				if(dep[i]&1)
				{
					d++;
					while(vis[d]) d++;
					ans[i]=d;
				}
			}
		}
		for(int i=1;i<=n;i++) printf("%d ",ans[i]);
	}
	return 0;
}



Measured memory_bytes: 18560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}


int main() {
  string s;
  cin >> s;
  if(s=="ABC") pt("ARC");
  else pt("ABC");
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
// #pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
    ios_base::sync_with_stdio(0);
    int TESTS=1;
    cin.tie(0);
    cout.tie(0);
    // cin>>TESTS;
    while(TESTS--)
    {   
	int a[1001][1000];
        int n;
        cin>>n;
        rep(i,1,n+1){
        	rep(j,1,n) cin>>a[i][j];
        }
        int cur[n+1];
        rep(i,1,n+1) cur[i] = 1;
        int ans=0;
       	while(1){
       		int cnt = 0;
       		ans++;
       		bool mark[n+1]={};
       		rep(i,1,n+1){
       			if(cur[i]==n||mark[i]) continue;
       			if(a[a[i][cur[i]]][cur[a[i][cur[i]]]] == i && mark[a[i][cur[i]]] ==0){
       				cnt++;
       				mark[i] = 1;
       				mark[a[i][cur[i]]] = 1;
       				// trace(i,a[i][cur[i]],ans);
       				cur[a[i][cur[i]]]++;
       				cur[i]++;
       			}
       		}
       		if(cnt==0){
       			bool yes = 1;
       			rep(i,1,n+1) if(cur[i]!=n) yes = 0;
       			if(yes==0) cout<<-1;
       			else{
       				cout<<ans-1;
       			}
       			r0;
       		}
       	}
    }   
}     


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/

ll H,W,h,w;
 ll mark[25][25];
 
int main(){FAST;
cin>>H>>W>>h>>w;

for(ll i=0;i<h;i++){
	for(ll j=0;j<W;j++){
		mark[i][j]=1;
	}
}
for(ll i=0;i<w;i++){
	for(ll j=0;j<H;j++){
		mark[j][i]=1;
	}
}
ll ans=0;
for(ll i=0;i<H;i++)for(ll j=0;j<W;j++)if(!mark[i][j])ans++;
cout<<ans;
return 0;
}


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


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

  for (ll i = 1; i <= 3500; ++i) {
    for (ll j = 1; j <= 3500; ++j) {
      ll d = 4 * i * j - n * i - n * j;
      ll u = n * i * j;
      if (d != 0 && u % d == 0 && u / d > 0) {
	ll k = u / d;
	cout << i << " " << j << " " << k << '\n';
	return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
# A - One Card Poker

# Alice と Bob は 2人で1枚のポーカーをやっている
# カードの強さは以下の通り
# 弱 2 < 3 < 4 < ・・・・・ < 12 < 13 < 1 強

# 1.各プレイヤーは、トランプからカードを1枚選んで、自分の手札とします。
# 2.両プレイヤーは、手札を見せ合います。強いカードを持っているプレイヤーが勝ちです。
# 　なお、両プレイヤーの持っているカードの強さが同じ場合は引き分けです。

# Alice が持っているカードを A
# Bob   が持っているカードを B

# 勝敗を判定するプログラムを作る

# A B を標準入力から得る
A, B = map(int, input().split())
# print(A, B)

# Alice が 勝つなら Alice
# Bob   が 勝つなら Bob
# 引き分けなら Draw

if A == B:
    answer = "Draw"
elif A == 1:
    answer = "Alice"
elif B == 1:
    answer = "Bob"
elif A > B:
    answer = "Alice"
else:
    answer = "Bob"

# 結果を出力
print(answer)


Measured memory_bytes: 9108
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if(a < b){
            if((a < c) && (c < b)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            if((b < c) && (c < a)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
        
    }
}



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

int main(){
  string s, sb;
  int q;
  cin >> s >> q;
  bool ansb = true;
  for(int i=0; i<q; ++i){
    int t, f;
    cin >> t;
    if(t==1){
      if(ansb) ansb=false;
      else ansb=true;
    }
    else{
      char c;
      cin >> f >> c;
      if(f==1){
        if(ansb) sb += c;
        else s += c;
      }
      else{
        if(ansb) s += c;
        else sb += c;
      }
    }
  }
  if(ansb){
    reverse(sb.begin(),sb.end());
    cout << sb+s << endl;
  }
  else{
    reverse(s.begin(),s.end());
    cout << s+sb << endl;
  }
}

Measured memory_bytes: 1248
n,m = map(int, input().split())
height_list = list(map(int, input().split()))

heightest_list = [0] * n
for _ in range(m):
  a,b = map(int, input().split())
  heightest_list[a-1] = max(heightest_list[a-1], height_list[b-1])
  heightest_list[b-1] = max(heightest_list[b-1], height_list[a-1])

result = 0
for i in range(n):
  if height_list[i] > heightest_list[i]:
    result += 1

print(result)

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<string>> S(H, vector<string>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S[i][j];
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == "snuke") {
        cout << (char)('A' + j) << i + 1 << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256