akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

/*
const int N=;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
*/

int sum(int x){
	int res=0; 
	while(x)res+=x%10,x/=10;
	return res;
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin);
//	freopen("my.out","w",stdout);
#endif
	int n,ans=1e9;cin>>n;
	rep(i,1,n-1){
		cmin(ans,sum(i)+sum(n-i)); 
	}
	printf("%d\n",ans);
	return 0;
}

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

//
#define int long long
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int K;
  cin >> K;

  int n = 50;
  int v[51];
  for (int i = 0; i < 50; i++) {
    v[i] = 49 + K / 50;
  }

  int k = K % 50;
  for (int i = 0; i < k; i++) {
    v[i] += n;
    for (int j = 0; j < n; j++) {
      if (j != i) v[j]--;
    }
  }

  cout << n << endl;
  for (int i = 0; i < n; i++) {
    cout << v[i];
    if (i != n - 1) cout << " ";
    if (i == n - 1) cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
n=int(input())
list=[int(input()) for _ in range(n)]
for i in range(n):
    for j in range(3):
        if list[i]==a1[j]:
            a1[j]=101
        elif list[i]==a2[j]:
            a2[j]=101
        elif list[i]==a3[j] :
            a3[j]=101

if a1[0]==a2[0]==a3[0]==101:
    print("Yes")
elif a1[1]==a2[1]==a3[1]==101:
    print("Yes")
elif a1[2]==a2[2]==a3[2]==101:
    print("Yes")
elif a1[0]==a1[1]==a1[2]==101:
    print("Yes")
elif a2[0]==a2[1]==a2[2]==101:
    print("Yes")
elif a3[0]==a3[1]==a3[2]==101:
    print("Yes")
elif a1[0]==a2[1]==a3[2]==101:
    print("Yes")
elif a1[2]==a2[1]==a3[0]==101:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int M = scn.nextInt();
		int[] F = new int[M];
		for(int i = 0;i < N;i++) {
			int K = scn.nextInt();
			for(int j = 0;j < K;j++) {
				F[scn.nextInt()-1] ++;
			}
		}
		int ans = 0;
		for(int i = 0;i < M;i++) {
			if(F[i] == N)ans++;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 22100
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String T = sc.next();
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<S.length();i++){
            sb.append(S.charAt(i));
            sb.append(T.charAt(i));
        }
        System.out.println(sb);
    }

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


Measured memory_bytes: 21588
from collections import Counter


def solve(string):
    n, *ss = string.split()
    d = Counter("".join(sorted(s)) for s in ss)
    return str(sum([v * (v - 1) // 2 for v in d.values()]))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 27852
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1, 0);
    for (int i = 1; i < n; i++)
    {
        int temp;
        cin >> temp;
        a[temp]++;
    }

    for (int i = 1; i <= n; i++)
    {
        cout << a[i] << endl;
    }

    return 0;
}

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

int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a>k  ||d-a>k ||c-a>k ||b-a>k){
    cout<<":("<<endl;
  }
  else {
    cout<<"Yay!"<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <thread>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


//セグ木
ll dat[2560000], sz;

void init(ll n) {
	sz = 1;
	while (sz < n)sz *= 2;
	REP(i, sz * 2 - 1) dat[i] = INF; //初期値
}

void update(ll k, ll a) { //場所(0-indexed), 値
	k += sz - 1;
	dat[k] = a;
	while (k > 0) {
		k = (k - 1) / 2;
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]); //更新
	}
}

ll query(ll a, ll b, ll k, ll l, ll r) { //[a, b) 呼ぶとき (a, b, 0, 0, sz)
	if (r <= a or b <= l)return INF;
	if (a <= l and r <= b)return dat[k];
	ll v1 = query(a, b, k * 2 + 1, l, (l + r) / 2);
	ll v2 = query(a, b, k * 2 + 2, (l + r) / 2, r);
	return min(v1, v2); //戻り値
}

#define PP pair<P, ll>
ll n, m;

int main() {
	init(110000);
	cin >> n >> m;
	vector<PP> s;
	REP(i, m) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		s.push_back(PP(P(b, a), c));
	}
	sort(ALL(s));
	update(0, 0);
	REP(i, m) {
		ll a = s[i].first.second, b = s[i].first.first, c = s[i].second;
		update(b, min(query(a, b, 0, 0, sz) + c, query(b, b + 1, 0, 0, sz)));
		
	}
	ll ans = query(n - 1, n, 0, 0, sz);
	if (ans == INF)cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 9076
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in range(len(l)):
    for j in range(i+1,len(l)):
        for k in range(j+1,len(l)):
            if  l[i] + l[j] > l[k] and l[i] < l[j] + l[k] and l[i] + l[k] > l[j] and l[i] != l[j] and l[i] != l[k] and l[j] != l[k]:
                cnt += 1
print(cnt)

Measured memory_bytes: 73888
//agc008_a.cpp
//Sat Oct 27 11:03:15 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int x,y;
	cin >> x >> y;

	if (x>y){
		if (x>=0 && y>0){
			cout << abs(abs(x)-abs(y))+2 << endl;
		}else if (x<0 && y<=0){
			cout << abs(abs(x)-abs(y))+2 << endl;
		}else{
			cout << abs(abs(x)-abs(y))+1 << endl;
		}
	}else{
		if (x>=0 && y>0){
			cout << y-x << endl;
		}else if (x<0 && y<=0){
			cout << y-x << endl;
		}else {
			cout << 1+abs(abs(y)-abs(x)) << endl;
		}
	}

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long n;
long h[100005];
long dp[100005];

int main(){
	scanf("%ld", &n);
	for(int i = 1; i <= n; i++){
		scanf("%ld", &h[i]);
	}
	dp[1] = 0;
	dp[2] = std::abs(h[2] - h[1]);
	for(int i = 3; i <= n; i++){
		dp[i] = std::min(dp[i-1] + std::abs(h[i-1] - h[i]), dp[i-2] + std::abs(h[i-2] - h[i]));	
	}
	printf("%ld\n", dp[n]);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main() {
int n;
cin>>n;
int ans=0;
for(int i=0; i<=25; i++){
    for(int j=0; j<=15; j++){
        if(4*i+7*j==n) ans=1;
    }
}
if(ans==1)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String s = scan.next();

		int ans = 1;
		String temp = s.substring(0,1);
		for(int i = 1; i < n; i ++) {
			if(s.substring(i, i + 1).equals(temp))
				continue;
			ans++;
			temp = s.substring(i, i + 1);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 33580
import sys

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))

n = max(A)

if n % 2 == 0:
    nn = n // 2
else:
    nn = (n + 1) // 2

minA = n
aa = n
for a in A:
    if abs(a - nn) <= minA:
        minA = abs(a - nn)
        aa = a
print(n, aa)


Measured memory_bytes: 14432
#include <bits/stdc++.h>
using namespace std;
typedef signed long long lint;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  lint n;
  cin >> n;
  set< lint > a;
  for (lint i=0; i<n; ++i) {
    lint ai;
    cin >> ai;
    auto key = a.find(ai);
    if (key != a.end()) a.erase(key);
    else a.insert(ai);
  }
  cout << a.size() << endl;
  return 0;
}


Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_124
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            string s = Read();
            int cnt1 = 0;
            for(int i = 0; i < s.Length; i++)
            {
                if (i % 2 != s[i] - '0') cnt1++;
            }
            int cnt2 = 0;
            for(int i = 0; i < s.Length; i++)
            {
                if ((i+1) % 2 != s[i] - '0') cnt2++;
            }
            WriteLine(Min(cnt1, cnt2));
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int N, M, Q;
vector<int> a;
vector<int> b;
vector<int> c;
vector<int> d;
int A[10];
long long maxv;
long long maxp;

void dfs(int aa, int num)
{
#if 0
        for (int i = 0; i < N; ++i) {
                cout << A[i] << " ";
        }
        cout << endl;
#endif
        if (num > 1) {
                if (aa < A[num-2]) return;
        }
        A[num-1] = aa;
        if (num == N) {
                long long ans = 0;
                for (int i = 0; i < Q; ++i) {
                        if ((A[b[i]-1] - A[a[i]-1]) == c[i]) {
                                ans += d[i];
                        }
                }
                if (maxv < ans) maxv = ans;
                if (ans == maxp) {
                        cout << ans << endl;
                        exit(0);
                }
                return;
        }

        for (int i = 1; i <= M; ++i) {
                dfs(i, num+1);
        }

}

int main()
{
        maxp = 0;
        cin >> N >> M >> Q;
        for (int i = 0; i < Q; ++i) {
                int t1, t2, t3, t4;
                cin >> t1 >> t2 >> t3 >> t4;
                a.push_back(t1);
                b.push_back(t2);
                c.push_back(t3);
                d.push_back(t4);
                maxp += t4;
        }

        for (int i = 0; i < N; ++i) {
                A[i] = 0;
        }
        maxv = -1;
        dfs(1, 1);
        cout << maxv << endl;


}


Measured memory_bytes: 3636
// D - Practical Skill Test
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,n) for(int i=0;i<(n);++i)

int main(){
	int H,W,D; cin>>H>>W>>D;

	int MAX = H * W;
	vi Y(MAX), X(MAX), C(MAX);

	rp(h, H) rp(w, W){ int a; cin>>a; Y[a-1] = h; X[a-1] = w; }

	for(int now=D; now<MAX; ++now){
		int pre = now - D;
		C[now] = C[pre] + abs(Y[pre] - Y[now]) + abs(X[pre] - X[now]);
	}

	int Q; cin>>Q;
	while(Q--){ int l,r; cin>>l>>r; cout<< C[r-1] - C[l-1] <<endl; }
}

Measured memory_bytes: 2176
import java.util.*;
import java.io.*;
     
public class Main{
    static PrintWriter out;
    static Scanner in;
    public static void main(String args[]){
	in = new Scanner(System.in);
	out = new PrintWriter(System.out);
	solve();
	in.close();
	out.close();
    }
     
    public static void solve(){
        int N = in.nextInt();
	String S = in.next();
	char[] C = S.toCharArray();
	int migi = 0;
	int migil = 0;
	int left = 0;
	int leftm = 0;
	for(int i=0;i<N;i++){
	    if(C[i]=='('){
		migil++;
	    }else if(C[i]==')'&&migil<=0){
		migi++;
	    }else if(C[i]==')'&&migil>0){
		migil--;
	    }

	    if(C[N-i-1]==')'){
		leftm++;
	    }else if(C[N-i-1]=='('&&leftm<=0){
		left++;
	    }else if(C[N-i-1]=='('&&leftm>0){
		leftm--;
	    }
	}
	for(int i=0;i<migi;i++)
	    out.print('(');
	for(int i=0;i<N;i++)
	    out.print(C[i]);
	for(int i=0;i<left;i++)
	    out.print(')');

	out.println();	    
    }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<bool> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}
const int Mod=998244353;
int main(){
    ll n;cin>>n;
    VI D(n);
    rep(i,n)cin>>D[i];
    map<int,int>L;
    for(auto v:D){
        L[v]++;
    }
    if(D[0]!=0){cout<<0<<endl;return 0;}
    if(L[0]!=1){cout<<0<<endl;return 0;}
ll ans=1;
for(auto m:L){
    int key=m.fi,value=m.se;
    if(key>=1){
        ans=(ans*mod_pow(L[key-1],value,Mod))%Mod;
    }
}
cout<<ans<<endl;
}

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

using namespace std;

int main() {
    int N; cin >> N;
    double p[N+1];
    for (int i=0; i<N; i++) 
        scanf("%lf", p+i+1);

    double ans[N+1][N+1];

    ans[0][0] = 1;
    for (int j=1; j<=N; j++)
        ans[0][j] = 0;

    for (int i=1; i<=N; i++) {
        ans[i][0] = ans[i-1][0] * (1-p[i]);
        for (int j=1; j<=i; j++) {
            ans[i][j] = p[i] * ans[i-1][j-1] + (1-p[i]) * ans[i-1][j]; 
        }
    }


    int q = N/2 +1;
    double ret = 0;
    for (int i=q; i<=N; i++) 
        ret += ans[N][i];

    cout.precision(10);
    cout << ret << endl;
    return 0;
}

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

int g[300][300], fr[300], p[300];
bool bad[300];

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	f(i, 0, n)f(j, 0, m)scanf("%d", g[i] + j), --g[i][j];
	f(i, 0, n)++fr[g[i][0]];
	int an = n;
	f(i, 1, m){
		pair<int, int> mx(0, 0);
		f(i, 0, m)if (fr[i] > mx.first)mx = make_pair(fr[i], i);
		an = min(an, mx.first);
		bad[mx.second] = true;
		f(j, 0, n)while (bad[g[j][p[j]]])--fr[g[j][p[j]]], ++p[j], ++fr[g[j][p[j]]];
	}
	printf("%d\n", an);
}

Measured memory_bytes: 640
#include <stdio.h>
int main(){
int H,W;

while(1){
scanf("%d %d",&H,&W);

if(H==0 && W==0)break;

for(int i=0;i<H;i++){
for(int j=0;j<W;j++){    
if((i+j)%2==0){
printf("#");}else if((i+j)%2!=0){
printf(".");
}
}
printf("\n");
}
printf("\n");
}
return 0;
}


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

// #define int long long
struct Fast {Fast() {cin.tie(0); ios::sync_with_stdio(false);}} fast;

template <typename T> inline size_t maxElement(T beginIt, T endIt) { return max_element(beginIt, endIt); }
template <typename T> inline size_t minElement(T beginIt, T endIt) { return min_element(beginIt, endIt); }
template <typename T> inline size_t maxIndex(T beginIt, T endIt) { return distance(beginIt, *max_element(beginIt, endIt)); }
template <typename T> inline size_t minIndex(T beginIt, T endIt) { return distance(beginIt, *min_element(beginIt, endIt)); }
template <typename T> inline int sum(T beginIt, T endIt) { return accumulate(beginIt, endIt, 0); }
template <typename T> inline int mean(T beginIt, T endIt) { return sum(beginIt, endIt) / distance(beginIt, endIt); }
template <typename T> inline void debug(T x) { cerr << x << " " << "(L:" << __LINE__ << ")" << endl; }

int gcd(int n, int m) {
  if (m == 0) return n;
  else return gcd(m, m % n);
}
int lcm(int n, int m) {
  return n * m / gcd(n, m);
}

signed main(void) {
  /* */
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  int N, M;
  array<int, 10000> A;
  string S, T;
  /* */

  cin >> N;

  if (N < 1200) cout << "ABC" << endl;
  else if (N < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  
  // cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

void rotate_S(int minase_inori[6]) {
	int hayami_saori = minase_inori[0];
	minase_inori[0] = minase_inori[4];
	minase_inori[4] = minase_inori[5];
	minase_inori[5] = minase_inori[1];
	minase_inori[1] = hayami_saori;
}

void rotate_NES(int kugimiya_rie[6]) {
	int kitamura_eri = kugimiya_rie[1];
	kugimiya_rie[1] = kugimiya_rie[3];
	kugimiya_rie[3] = kugimiya_rie[4];
	kugimiya_rie[4] = kugimiya_rie[2];
	kugimiya_rie[2] = kitamura_eri;
}

void check(const int asumi_kana[6], const int iguti_yuka[6]) {
	int sakura_ayane;
	int satou_satomi[6];
	for (sakura_ayane = 0; sakura_ayane < 6; sakura_ayane++) {
		satou_satomi[sakura_ayane] = iguti_yuka[sakura_ayane];
	}
	for (sakura_ayane = 0; sakura_ayane < 4; sakura_ayane++) {
		int tateno_kanako;
		for (tateno_kanako = 0; tateno_kanako < 6; tateno_kanako++) {
			if (asumi_kana[tateno_kanako] != satou_satomi[tateno_kanako]) break;
		}
		if (tateno_kanako >= 6) {
			puts("Yes");
			exit(0);
		}
		rotate_NES(satou_satomi);
	}
}

int main(void) {
	int mizuki_nana[6], fukuenn_misato[6];
	int horie_yui;
	for (horie_yui = 0; horie_yui < 6; horie_yui++) {
		if (scanf("%d", &mizuki_nana[horie_yui]) != 1) return 1;
	}
	for (horie_yui = 0; horie_yui < 6; horie_yui++) {
		if (scanf("%d", &fukuenn_misato[horie_yui]) != 1) return 1;
	}
	check(mizuki_nana, fukuenn_misato);
	for (horie_yui = 0; horie_yui < 4; horie_yui++) {
		rotate_NES(fukuenn_misato);
		rotate_S(fukuenn_misato);
		check(mizuki_nana, fukuenn_misato);
		rotate_S(fukuenn_misato);
		rotate_S(fukuenn_misato);
		rotate_S(fukuenn_misato);
	}
	rotate_S(fukuenn_misato);
	rotate_S(fukuenn_misato);
	check(mizuki_nana, fukuenn_misato);
	puts("No");
	return 0;
}



Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007

long long  mod = 1000000007;


bool lap[30][30];


bool overlap(int i,int j,vector<int> &x,vector<int>&y,vector<int> &r){
	int k = 0;
	k = (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]);
	if(k>= (r[i]+r[j])*(r[i]+r[j]))return 0;
	return 1;
}
int n;
char dp[1<<24];
char dfs(int s,vector<int>&c){
	if(dp[s] != -1) return dp[s];
	int k = 0;
	for(int i=0;i<n;i++){
		if(s&(1<<i)){
			k++;
		}
	}
	dp[s] = n-k;
	char res= n-k;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(c[i]==c[j]){
				if((s&(1<<i))&&(s&(1<<j))){
					bool fl =1;
					for(int p=0;p<i;p++){
						if(lap[p][i]==1&&(s&(1<<p)))fl = 0;
					}
					for(int p=0;p<j;p++){
						if(lap[p][j]==1&&(s&(1<<p)))fl = 0;
					}
					if(fl){
						res = max(res,dfs(s-(1<<i)-(1<<j),c));
					}
				}
			}
		}
	}
	return dp[s] = res;
}

int main(){
	while(cin >> n && n!=0){
		vector<int>x(n),y(n),r(n),c(n);
		for(int i=0;i<(1<<24);i++){
			dp[i] = -1;
		}
		for(int i=0;i<n;i++){
			cin >> x[i] >> y[i] >> r[i] >> c[i];
		}
		for(int i=0;i<30;i++){
			for(int j=0;j<30;j++){
				lap[i][j] = 0;
			}
		}
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(overlap(i,j,x,y,r)==1){
					lap[i][j]=1;
				}
			}
		}
		while(1){
			bool flag = 1;
			for(int i=0;i<n;i++){
				for(int j=i+1;j<n;j++){
					if(lap[i][j]==0){
						for(int k=i+1;k<j;k++){
							if(lap[i][k]&&lap[k][j]){
								lap[i][j]=1;
								flag = 0;
							}
						}
					}
				}
			}
			if(flag)break;
		}
		/*for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				cout << i <<  " " << j << " " << lap[i][j] << endl;
			}
		}*/

		cout << (int)dfs((1<<n)-1,c) << endl;
	}
	return 0;
}

Measured memory_bytes: 19484
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> m(9);
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
        m[min(a[i] / 400, 8)]++;
    }
    int ans = 0;
    for (int i = 0; i < 8; i++) {
        if (m[i] > 0) {
            ans += 1;
        }
    }
    cout << max(ans, 1) << " " << ans + m[8] << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
ST = []
for _ in range(M):
    a, b = map(int, input().split())
    ST.append((a, b))

ST.sort(key=lambda x: x[1])

ans = 0
t = 0
for a, b in ST:
    if a >= t:
        t = b
        ans += 1

print(ans)

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

int dp[nn][nn];
string getLCS(string &s,string &t,int len){
    string LCS;
    int i = 0;
    int j = 0;
    while(len > 0){
        if(s[i] == t[j]){
            LCS.push_back(s[i]);
            i++; j++; len--;
        }
        else{
            if(dp[i][j+1] > dp[i+1][j])
                j++;
            else i++;
        }
    }
    return LCS;
}

int lenLCS(string &s,string &t,int i,int j){
    if(i>=s.length() || j>=t.length())
        return 0;

    if(dp[i][j] != -1)
        return dp[i][j];

    if(s[i] == t[j])
        return dp[i][j] = 1 + lenLCS(s,t,i+1,j+1);
    else
        return dp[i][j] = max(lenLCS(s,t,i,j+1), lenLCS(s,t,i+1,j));
}

string solve(string &s,string &t){
    memset(dp,-1,sizeof(dp));
    int len = lenLCS(s,t,0,0);
    return getLCS(s,t,len);
}

int32_t main() {
    string s,t;
    cin>>s>>t;

    cout<<solve(s,t);
}


Measured memory_bytes: 70912
#include <stdio.h>

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

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

	if (a == b) printf("%d\n", c);
	else if (b == c) printf("%d\n", a);
	else printf("%d\n", b);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
int r,c,m,per[50][50],on[50][50],off[50][50],dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dir[50][50][50][50];
string mp[50];
bool inn(int x,int y) { return (0<=x&&x<r&&0<=y&&y<c); }
void dfs(int sx,int sy,int x,int y,int px,int py,int id){
	dir[sx][sy][x][y]=id;
	rep(i,4){
		int nx=x+dx[i],ny=y+dy[i];
		if(!(nx==px && ny==py)&&inn(nx,ny)&&mp[nx][ny]=='.') dfs(sx,sy,nx,ny,x,y,id);
	}
}
int before[50][50];
int main(){
	cin>>r>>c>>m;
	rep(i,r) cin>>mp[i];
	rep(i,r) rep(j,c) cin>>per[i][j];
	rep(i,r) rep(j,c) cin>>on[i][j];
	rep(i,r) rep(j,c) cin>>off[i][j];
	rep(i,r) rep(j,c) if(mp[i][j]=='.'){
		rep(k,4){
			int ni=i+dx[k],nj=j+dy[k];
			if(inn(ni,nj)&&mp[ni][nj]=='.') dfs(i,j,ni,nj,i,j,k);
		}
	}
	int a,b,x,y;
	cin>>a>>b;
	int ans=0,t=0;
	rep(i,m-1){
		cin>>x>>y;
		while(!(a==x&&b==y)){
			t++;
			if(before[a][b]==0) ans+=on[a][b];
			else {
				ans+=min((t-before[a][b])*per[a][b],off[a][b]+on[a][b]);
			}
			int d=dir[a][b][x][y];
			before[a][b]=t;
			a+=dx[d],b+=dy[d];
		}
	}
	t++;
	if(before[a][b]==0) ans+=on[a][b];
	else {
		ans+=min((t-before[a][b])*per[a][b],off[a][b]+on[a][b]);
	}
	before[a][b]=t;
	rep(i,r) rep(j,c) if(before[i][j]>0) ans+=off[i][j];
	cout << ans<< endl;
}

Measured memory_bytes: 24636
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    S = SS()

    white = S.count('.')
    black = 0
    ans = white + black
    for i in S:
        if i == '.':
            white -= 1
        else:
            black += 1
        ans = min(white + black, ans)

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10364
def common():
   X = raw_input()
   Y = raw_input()
  
   s = [0 for i in range(len(Y)+1)]
 
   for j in range(0, len(X)):
      t = s + []
      for k in range(0, len(Y)):
         if X[j] == Y[k]:
            s[k+1] = t[k] + 1
         elif s[k+1] < s[k]:
            s[k+1] = s[k]
  
   print s[-1]
 
q = input()
for l in range(0, q):
   common()

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

int main()
{
	int x,y;
	cin>>x>>y;
	char a[105][105];
	bool s[105][105];
	for(int i=1;i<=x;i++)
		for(int j=1;j<=y;j++)
		{
			cin>>a[i][j];
			s[i][j]=1;
		}	
	for(int i=1;i<=x;i++)
	{
		int f=1;
		for(int j=1;j<=y;j++)
		{
			if(a[i][j]=='#'){
				f=0;
				break;
			} 
		}
		if(f){
			for(int j=1;j<=y;j++)
				s[i][j]=false;
		}
	}
	for(int j=1;j<=y;j++)
	{
		int f=1;
		for(int i=1;i<=x;i++)
		{
			if(a[i][j]=='#'){
				f=0;
				break;
			} 
		}
		if(f){
			for(int i=1;i<=x;i++)
				s[i][j]=false;
		}
	}
	for(int i=1;i<=x;i++)
	{
		int f=0;
		for(int j=1;j<=y;j++)
		{
			if(s[i][j]){
				cout<<a[i][j];
				f=1;
			} 
		}
		if(f) cout<<endl;
	}
	return 0;
}

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

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, X, M;
  cin >> N >> X >> M;
  

  int L = 63;
  vector<vector<pair<int, int>>> to(L, vector<pair<int, int>>(M));

  REP(i, M){
    to[0][i].first  = (i*i)%M;
    to[0][i].second = i;
  }

  REP(l, L-1){
    REP(i, M){
      to[l+1][i].first  = to[l][to[l][i].first].first;
      to[l+1][i].second = to[l][to[l][i].first].second+to[l][i].second;
    }
  }

  int ans = 0;
  REP(l, L){
    if((N >> l)&1){
      ans += to[l][X].second;
      X = to[l][X].first;
    }
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 103232
n,k=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
x=[l[i][0] for i in range(n)]
x.sort()
y=[l[i][1] for i in range(n)]
y.sort()
ans=[]
for i1 in range(n):
  for i2 in range(i1+1,n):
    for i3 in range(n):
      for i4 in range(i3+1,n):
        ct=0
        for i5 in range(n):
          if x[i1]<=l[i5][0]<=x[i2] and y[i3]<=l[i5][1]<=y[i4]:ct+=1
        if ct>=k:
          ans.append(abs(x[i1]-x[i2])*abs(y[i3]-y[i4]))
print(min(ans))

Measured memory_bytes: 113008
ab = input().split()

a = int(ab[0])
b = int(ab[1])
num = 0

for i in range(a,b+1):
   moji = str(i)
   if moji[0] == moji[4] and moji[1] == moji[3]:
       num += 1 
     

print(num)    

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
	
	int n,m,x,a[101],i,count=0,counts=0;
	
	scanf("%d %d %d",&n,&m,&x);
	
	for(i=0;i<m;i++){
			scanf("%d",&a[i]);
			if(a[i]<x)count=count+1;
			if(a[i]>x)counts=counts+1;
			
		}
		
	if(count>counts)count=counts;
	
	printf("%d\n",count);
	
	return 0;
}


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

using namespace std;

int main(){
	string s, t; cin >> s >> t;
	int q = s.size(), r = t.size();
	int ans = 1001;
	for(int i = 0; i <= q-r; ++i){
		int t1 = 0;
		for(int j = i; j < i + r; ++j){
			if(s[j] != t[j-i]) ++t1;
		}
		ans = min(ans, t1);
	}
	cout << ans;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
const int mod = 1e9 + 7;
#define putchar putchar_unlocked
#define getchar getchar_unlocked

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int k = (n + 1) /2;
    cout << fixed << setprecision(10) << double(k) / (double)(n) << '\n';
}


Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;

template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void yesno(bool c) { OUT(c ? "yes" : "no"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	string A, B;
	cin >> A >> B;
	if (A.size() > B.size()) {
		OUT("GREATER");
		return 0;
	}
	else if (A.size() < B.size()) {
		OUT("LESS");
		return 0;
	}
	else {
		if (A > B) {
			OUT("GREATER");
			return 0;
		}
		else if (A < B) {
			OUT("LESS");
			return 0;
		}
	}
	OUT("EQUAL");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int N;
	scanf("%d",&N);
	int V[N];
	int C[N];
	int sum=0;
	int x;
	for(int i=0; i<N; i++){
		scanf("%d",&V[i]);
	}
	for(int i=0; i<N; i++){
		scanf("%d",&C[i]);
	}

	for(int i=0; i<N; i++){
		x= V[i]-C[i];
		if(x > 0){ sum += x; }
	}

	printf("%d\n",sum );
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int n,i,a = 0,y = 1;
	char s[8];
	scanf("%d",&n);
	for(i = 1;i <= n;i++){
		scanf("%s",s);
		if(s[0] == 'A'){a++;}
		if(s[0] == 'U' && s[1] == 'n'){
			if(a){
				a--;
			}
			else{y = 0;}
		}
	}
	if(a > 0){y = 0;}
	if(y){printf("YES\n");}
	else{printf("NO\n");}
	return 0;
}

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

int res;
int n;

void dfs(int u, int all)
{
	if(u == 4)
	{
		if(all == n) res ++;
		return;
	}
	
	for(int i = 0; i < 10; i ++ )
		dfs(u + 1, all + i);
}

int main()
{
	while(cin >> n)
	{
		res = 0;
		
		dfs(0, 0);
		
		cout << res << endl;
	}
} 


Measured memory_bytes: 3088
#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<int,int>;

int main() {
  string S;
  cin >> S;
  string ans = "Yes";
  if (S[0] == S[1] && S[0] == S[2]) {
    ans = "No";
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int N;
    int q;
    string w;
    set<string> st;
    bool flag = true;
    char pre;
    cin >> N;
    cin >> w;
    pre = w.back();
    st.insert(w);
    for (int i = 1; i < N; i++){
        cin >> w;
        if (st.find(w) != st.end()){
            flag = false;
        }
        if (pre != w[0]){
            flag = false;
        }
        st.insert(w);
        pre = w.back();
    }
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <numeric>
#define ll long long 
#define wolfe ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define elif else if
using namespace std;
int main () {
    wolfe;
    string a,b;
    cin >> a >> b;
    int n = a.size();
    int cnt = 0;
    for(int i=0 ; i<n; i++) {
        if(a[i]!=b[i]) cnt ++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3796
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(0,a+b-n)<<endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) {
        cin >> H[i];
    }
    bool ok = true;
    H[0] = true;
    for (int i=1; i<N; ++i) {
        if (H[i] > H[i-1]) H[i]--;
        if (H[i] < H[i-1]) ok = false;
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


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

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

  long long ans = 0;
  string c = "";
  for(int i = 0;i < S.size();i++) {
    if(S.at(i) == 'A') c.push_back('A');
    else if(S.at(i) == 'C') c.push_back('C');
    else if(S.at(i) == 'B') {
      if(i < S.size()-1&&S.at(i+1) == 'C') {
        c.push_back('D');
        i++;
      }else c.push_back('B');
    }
  }

  int a = 0;
  for(int i = 0;i < c.size();i++) {
    if(c.at(i) == 'A') a++;
    if(c.at(i) == 'D') ans += a;
    if(c.at(i) == 'B' || c.at(i) == 'C') a = 0;
  }

  cout << ans << endl;
  

}


Measured memory_bytes: 776
#include<iostream>
using namespace std;
int main(){
  int n,d,x,tmp;
  cin >> n >> d >> x;
  int dp[110000];
  int p[d][n];
  for(int i=0;i<d;i++){
    for(int j=0;j<n;j++){
      cin >> p[i][j];
    }
  }
  for(int i=0;i<d-1;i++){
    for(int j=0;j<x+1;j++) dp[j]=j;
    for(int j=0;j<n;j++){
      for(int k=0;k<x+1;k++){
        if(k-p[i][j]>=0) dp[k]=max(dp[k],dp[k-p[i][j]]+p[i+1][j]);
      }
    }
    tmp=0;
    for(int j=0;j<x+1;j++){
      tmp=max(tmp,dp[j]);
    }
    x=tmp;
  }
  cout << x<<endl;
}



Measured memory_bytes: 3184
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;



void main() {
    string[] input = new string[](8);

    while ((input = readln.chomp.split(" ")).length != 0) {
        auto points = input.map!(to!double);

        if (points[0] <= points[6] &&
            points[2] >= points[4] &&
            points[1] <= points[7] &&
            points[3] >= points[5]) {
            writeln("YES");
        } else {
            writeln("NO");
        }
    }
}

Measured memory_bytes: 1076
x, y = map(int, input().split())

a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]

if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
else:
    print("No")

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

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

    string s;
    cin>>s;

    string ans;
    for (char c: s)
        if (c == 'S')   ans += c;
        else if (ans.size() && ans.back() =='S')    ans.pop_back();
        else ans += c;
    cout<<ans.size()<<endl;
}


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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  int n, k; cin >> n >> k;
  string s; cin >> s;

  s[k-1] += 32;
  cout << s << endl;
  
  return (0);
}

Measured memory_bytes: 3620
/////////////////////////   _LeMur_
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n , m;
long long c[N];
long long answ;
bool used[N];
vector <int> g[N];
vector <long long> mas;
vector < pair< int,vector<long long> > > G;
multiset <long long> q;

void dfs(int v){
    used[v] = true;
    mas.push_back(c[v]);
    for(int i=0;i<(int)g[v].size();i++){
        int to = g[v][i];
        if(used[to])continue;
        dfs(to);
    }
}

int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        scanf("%lld",&c[i]);
    }
    for(int i=1;i<=m;i++){
        int a , b;
        scanf("%d%d",&a,&b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=0;i<n;i++){
        if(used[i])continue;
        dfs(i);
        G.push_back(make_pair(-(int)mas.size() , mas));
        mas.clear();
    }
    sort(G.begin() , G.end());
    for(int i=0;i<(int)G.size();i++){
        if(i == 0){
            for(int j=0;j<(int)(G[i].second).size();j++){
                q.insert(G[i].second[j]);
            }
        }
        else{
            if((int)q.size() == 0){
                cout<<"Impossible"<<endl;
                return 0;
            }
            sort(G[i].second.begin() , G[i].second.end());
            answ += G[i].second[0] + (*q.begin());
            q.erase(q.begin());
            for(int j=1;j<(int)G[i].second.size();j++){
                q.insert(G[i].second[j]);
            }
        }
    }
    cout<<answ<<endl;
	return 0;
}


Measured memory_bytes: 15864
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll K,A,B;
    cin>>K>>A>>B;
    for(ll i=A;i<=B;i++){
        if(i%K==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    
    return 0;
}


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

using namespace std;

int main(int, char**) {
        unsigned long long a, b, n;
        cin >> a >> b >> n;
        unsigned long long m;
        if (n >= b) {
                m = b - 1;
        } else {
                m = n;
        }
        unsigned long long out = (a * m) / b - a * (m / b);
        cout << out << endl;
        return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

int main()
{
    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

   int l_num=0;
   int num1,num2,num3;
   int i=0;
   int check=0;
   
   scanf("%d", &l_num);
   
   while(i < l_num){
      scanf("%d %d %d", &num1, &num2, &num3);

      check = num1*num1 - num2*num2 -num3*num3;
      if(check == 0){
          puts("YES");
          i++;
          continue;
      }
      
      check = num2*num2 - num1*num1 -num3*num3;
      if(check == 0){
          puts("YES");
          i++;
          continue;
      }
      
      check = num3*num3 - num1*num1 -num2*num2;
      if(check == 0){
          puts("YES");
          i++;
          continue;
      }
      
      puts("NO");
      i++;
   }
   return 0;
}

Measured memory_bytes: 576
using System;
using System.Linq;

namespace ABC159B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string sub1 = s.Substring(0, (s.Length - 1) / 2);
            string sub2 = s.Substring((s.Length + 3) / 2-1);

            var res = "No";

            if (s == string.Join("", s.Reverse()))
            {
                if (sub1 == string.Join("", sub1.Reverse()))
                {
                    if (sub2 == string.Join("", sub2.Reverse()))
                    {
                        res = "Yes";
                    }
                }
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13268
def main():
    N, K = map(int, input().split())

    A = list(map(int, input().split()))

    count = 0
    count_ = 0
    # 内部
    for j in range(N-1):
        for i in range(j+1, N):
            if A[j] > A[i]:
                count += K*(K+1)//2
    
    # 異なるK間の個数
    B = list(reversed(A))
    for l in range(N-1):
        for m in range(l+1,N):
            if B[l] > B[m]:
                count += K*(K-1)//2

    print(int(count % (10**9+7)))


if __name__ == '__main__':
    main()



Measured memory_bytes: 3188
fun main(args: Array<String>) {
    val s = readLine()!!

    if (s.length == 2 && s[0] == s[1]) {
        println("1 2")
        return
    }

    for (c in 'a'..'z') {
        for (i in 0 .. s.length - 3) {
            val m = s.substring(i, i + 3).count { it == c }
            if (m >= 2) {
                println("${i + 1} ${i + 3}")
                return
            }
        }
    }
    println("-1 -1")
}


Measured memory_bytes: 73756