akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef map<ll, ll> mii;
const int MOD = 1e9 + 7;

#define fastIO() \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 
 
int main() {
    int n, w, V = 0;
    cin >> n >> w;
    vi wt(n), v(n);
    for (int i = 0; i < n; ++i) {
        cin >> wt[i] >> v[i];
        V += v[i];
    }
    vi dp(V+1, MOD);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = V - v[i]; j >= 0; --j) {
            dp[j + v[i]] = min(dp[j + v[i]], dp[j] + wt[i]);
        }
    }
    ll ans = 0;
    for (int i = V; i >= 0; --i)
        if (dp[i] <= w) {
            ans = i;
            break;
        } 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
// {{{ Template for Competitive Programming
// -std=c++14 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FOR(i, a, b)  for (int(i) = (a); (i) < (b); ++(i))
#define CFOR(i, a, b) for (int(i) = (a); (i) <= (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) >= (b); --(i))
#define rep(i, n) FOR((i), 0, (n))
#define crep(i, n) CFOR((i), 0, (n))
#define rrep(i, n) RFOR((i), (n), 0)
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(ALL(x), 0)

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

const int INF = 1'010'000'000'000'000'017LL;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

using vint = vector<int>;
using pint = pair<int, int>;
// }}}

signed main() {
	int n;
	cin >> n;
	int cnt = 0;
	crep(i, n) {
		if (i == 0) continue;
		string s = to_string(i);
		if (s.size() % 2 == 1) cnt++;
	}
	cout << cnt << endl;
}



Measured memory_bytes: 256
import sys


def print_str(str, a, b):
    print(str[a:b+1])


def reverse_str(str, a, b):
    return str[:a] + str[a:b+1][::-1] + str[b+1:]


def replace_str(str, a, b, p):
    return str[:a] + p + str[b+1:]


str = sys.stdin.readline().strip()
num_commands = int(sys.stdin.readline())

for _ in range(num_commands):
    command, *args = sys.stdin.readline().strip().split()
    if command == 'print':
        print_str(str, int(args[0]), int(args[1]))
    elif command == 'reverse':
        str = reverse_str(str, int(args[0]), int(args[1]))
    elif command == 'replace':
        str = replace_str(str, int(args[0]), int(args[1]), args[2])



Measured memory_bytes: 5624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <bitset>
#include <fstream>
#include <cmath>
using namespace std;
typedef long long ll;

const int MAX_N = 100;
const int MAX_P = 21;

ll dp[MAX_N][MAX_P];		//dp[iツ氾板姪堋づ慊づづ[jツづーツ催ャツづゥツパツタツーツδ転

int main()
{
	int N;
	cin>>N;

	vector<int> num(N);
	for(int i = 0; i < N; i++) cin>>num[i];

	for(int i = 0; i < MAX_P; i++)
		dp[0][i] = (i == num[0] ? 1 : 0);

	for(int i = 1; i < N-1; i++){
		for(int j = 0; j < MAX_P; j++){
			dp[i][j] = 0;
			if(0 <= j+num[i] && j+num[i] < MAX_P) dp[i][j] += dp[i-1][j+num[i]];
			if(0 <= j-num[i] && j-num[i] < MAX_P) dp[i][j] += dp[i-1][j-num[i]];
		}
	}
	
	cout<<dp[N-2][num[N-1]]<<endl;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

#define mod 1000000007
#define INF 1000000000
#define SIZE 100000

int main(){
  int n,m,p,d[SIZE];
  int ans = INF;
  
  scanf("%d%d%d",&n,&m,&p);
  
  for(int i=0;i<m;i++){
    scanf("%d",&d[i]);
    d[i]+=n-p;
    d[i]%=n;
  }

  sort(d,d+m);

  for(int i=0;i<m-1;i++){
    int calc;

    calc = d[i] + n-d[i+1] + min(d[i],n-d[i+1]);

    ans = min(ans,calc);
  }
  
  ans = min(ans,d[m-1]);
  ans = min(ans,n-d[0]);

  printf("%d\n",ans*100);
  
  return 0;
}

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

using namespace std;
const int NMAX = 1001;
int vis[NMAX];
int main(int argc, char const *argv[])
{
	int n,k,d;
	scanf("%d%d",&n,&k);
	while(k--)
	{
		scanf("%d",&d);
		while(d--)
		{
			int p;
			scanf("%d",&p);
			vis[p]++;
		}
	}
	int ans = 0;
	for(register int i = 1;i <= n;i++)
		ans += vis[i] == 0;
	printf("%d\n",ans );
	return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, count = 0;
    cin >> N;
    vector<int> p(N, 0);
        for (int i = 0; i < N; i++) {
            cin >> p[i];
        }
        for(int i=0;i<N;i++) {
            if (p[i] != i + 1)count++;
        }
        if(count<=2)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import fractions

N,M=map(int,input().split())
S=input()
T=input()

L=N*M//fractions.gcd(N,M)

N_step=L//N
M_step=L//M
X_step=N_step*M_step//fractions.gcd(N_step,M_step)

flag=True
for i in range(L//X_step):
    if S[M_step*i]!=T[N_step*i]:
        flag=False

if flag:
    print(L)
else:
    print(-1)

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

int main() {
	int x, n;
	cin >> x >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	int absmin = 100000;
	for (int i = 0; i <= 101; i++) {
		bool f = true;
		for (int j = 0; j < n; j++) {
			if (i == p[j]) {
				f = false;
			}
		}
		if (f) {
			absmin = min(absmin, abs(i - x));
		}
	}
	int ans = 1000000;
	for (int i = 0; i <= 101; i++) {
		bool f = true;
		for (int j = 0; j < n; j++) {
			if (i == p[j]) {
				f = false;
			}
		}
		if (f) {
			if (abs(i - x) == absmin) {
				ans = min(ans, i);
			}
		}
	}
	cout << ans << endl;
	return 0;
}




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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long llint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double pi = 3.14159265358979323846;

// conversion
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();
}

//
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
//

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

  int n, m;
  cin >> n >> m;
  int ans = m * (m - 1) / 2;
  ans += n * (n - 1) / 2;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.SplitInt32();
            var X = line[0];
            var Y = line[1];
            return X + Y / 2;
        }

        IEnumerable<long> GetYakusu(long num)
        {
            long amari;
            var sqrt = (long)Math.Sqrt(num);
            for (long l = 1; l <= sqrt; l++)
            {
                var d = Math.DivRem(num, l, out amari);
                if (amari == 0)
                {
                    yield return l;
                    yield return d;
                }
            }
        }

        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
    }

    public class ConsoleReader
    {
        public virtual string String() => Console.ReadLine(); public int Int32() => int.Parse(String()); public long Int64() => long.Parse(String()); public ulong UInt64() => ulong.Parse(String()); public double Double() => double.Parse(String()); public string[] Split() => String().Split().ToArray(); public int[] SplitInt32() => String().Split().Select(int.Parse).ToArray(); public long[] SplitInt64() => String().Split().Select(long.Parse).ToArray(); public ulong[] SplitUInt64() => String().Split().Select(ulong.Parse).ToArray(); public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray(); public IEnumerable<string> Repeat(int count) { for (int i = 0; i < count; i++) yield return String(); }
        public IEnumerable<int> RepeatInt32(int count) { for (int i = 0; i < count; i++) yield return Int32(); }
        public IEnumerable<long> RepeatInt64(int count) { for (int i = 0; i < count; i++) yield return Int64(); }
        public IEnumerable<string[]> RepeatSplit(int count) { for (int i = 0; i < count; i++) yield return Split(); }
        public IEnumerable<int[]> RepeatSplitInt32(int count) { for (int i = 0; i < count; i++) yield return SplitInt32(); }
    }
}


Measured memory_bytes: 11348
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n,k,q = i2()
ls = [k-q]*n 
for _ in range(q):
	a = i()
	ls[a-1] += 1 

for j in range(n):
	if ls[j] > 0:
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 11712
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n, k;
    std::cin >> n >> k;
    std::vector<int> a(n), nxt(n, -1), prev(200010, -1), fst(200010, -1);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        if (prev[a[i]] < 0) {
            fst[a[i]] = i;
            prev[a[i]] = i;
        } else {
            nxt[prev[a[i]]] = i;
            prev[a[i]] = i;
        }
    }
    for (int i = 0; i < n; i++) if (nxt[i] < 0) nxt[i] = fst[a[i]];
    std::deque<std::pair<int, int>> q { { 0, -1 } };
    auto c = std::make_pair(0, 0);
    while (true) {
        auto x = nxt[c.second];
        if (x <= c.second) ++c.first;
        c.second = x;
        q.push_back(c);
        if (c.second == n - 1) break;
        c.second++;
    }

    auto t = q.back().first + 1;
    auto r = k % t;

    std::deque<int> ret;
    std::set<int> ss;
    if (r > 0) {
        auto it = q.begin();
        while (it->first < r) it++;
        --it;
        for (int i = it->second + 1; i < n; i++) {
            if (!ss.count(a[i])) {
                ret.push_back(a[i]);
                ss.insert(a[i]);
            } else {
                while (true) {
                    int v = ret.back();
                    ret.pop_back();
                    ss.erase(v);
                    if (v == a[i]) break;
                }
            }
        }
    }

    for (auto e : ret) std::cout << e << " ";
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 16512
import sys
from functools import lru_cache
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, W = map(int, input().split())
MEIJI = [input() for _ in range(H)]


@lru_cache(maxsize=None)
def dfs(r, c, cnt, iswhite=True):
    # if r == H - 1 and c == W - 1:
        # return cnt

    now = '.' if iswhite == True else '#'

    ans = 200

    if MEIJI[r][c] != now:
        if iswhite == True:
            cnt += 1

        iswhite = not (iswhite)

    if r == H-1 and c == W - 1:
        return cnt
    if r < H-1:
        ans = min(dfs(r + 1, c, cnt, iswhite), ans)
    if c < W-1:
        ans = min(dfs(r, c + 1, cnt, iswhite), ans)

    return ans


ans = dfs(0, 0, 0, True)
print(ans)


Measured memory_bytes: 136348
N, A,B,C = map(int, input().split())
l = sorted([int(input()) for _ in range(N)])[-1::-1]

INF = 1e+10

def DFS(depth, current_a, current_b, current_c):
    if depth == N:
        if min(current_a, current_b, current_c) > 0:
            return abs(current_a - A) + abs(current_b - B) + abs(current_c - C) -30
        else:
            return INF
    
    ret0 = DFS(depth+1, current_a, current_b, current_c)
    ret1 = DFS(depth+1, current_a + l[depth], current_b, current_c) + 10
    ret2 = DFS(depth+1, current_a , current_b+ l[depth], current_c) + 10
    ret3 = DFS(depth+1, current_a, current_b, current_c + l[depth]) + 10
    
    return min(ret0, ret1, ret2, ret3)

print(DFS(0, 0, 0, 0))

Measured memory_bytes: 3064
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

int x0[205][205];
int x1[205][205];

void solve()
{
    int n, ma, mb;
    scanf("%d%d%d", &n, &ma, &mb);
    vector<int> a(n), b(n), c(n);
    int i, j;
    for (i = 0; i < n; i++) {
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
    }
    for (i = 0; i <= 200; i++) {
        for (j = 0; j <= 200; j++) {
            x0[i][j] = x1[i][j] = INF;
        }
    }

    int m = n / 2, m2 = n - m;
    for (i = 0; i < (1 << m); i++) {
        int a0 = 0, b0 = 0, c0 = 0;
        for (j = 0; j < m; j++) {
            if (i & (1 << j)) {
                a0 += a[j];
                b0 += b[j];
                c0 += c[j];
            }
        }
        x0[a0][b0] = MIN(x0[a0][b0], c0);
    }

    for (i = 0; i < (1 << m2); i++) {
        int a0 = 0, b0 = 0, c0 = 0;
        for (j = 0; j < m2; j++) {
            if (i & (1 << j)) {
                a0 += a[j+m];
                b0 += b[j+m];
                c0 += c[j+m];
            }
        }
        x1[a0][b0] = MIN(x1[a0][b0], c0);
    }

    vector < pair<pair<int, int>, int> > z;
    for (i = 0; i <= 200; i++) {
        for (j = 0; j <= 200; j++) {
            if (x0[i][j] != INF) {
                z.push_back(make_pair(make_pair(i, j), x0[i][j]));
            }
        }
    }

    int ans = INF;
    for (i = 1; i <= 400; i++) {
        int aa = ma * i, bb = mb * i;
        for (j = 0; j < (int)z.size(); j++) {
            int aa0=z[j].first.first, bb0=z[j].first.second, cc0=z[j].second;
            int aa1 = aa - aa0, bb1 = bb - bb0;
            if (aa1 >= 0 && aa1 <= 200 && bb1 >= 0 && bb1 <= 200) {
                if (x1[aa1][bb1] != LINF) {
                    ans = MIN(ans, cc0 + x1[aa1][bb1]);
                }
            }
        }
    }
    if (ans == INF) {
        printf("-1\n");
    }
    else {
        printf("%d\n", ans);
    }
    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define N 40005
using namespace std;
int n,a[N],b[N],A[N];

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    sort(a,a+n,greater<int>());
    sort(b,b+n,greater<int>());
    for(int i=0;i<n;i++)A[i]=n;
    int x=0;
    for(int i=0;i<n;i++)
      for(int j=x;j<n;j++)
	if(b[i]>=a[j]){
	  A[j]=i;
	  x=j+1;
	  break;
	}
    int cnt=0,ans=n;
    for(int i=0;i<n;i++){
      if(A[i]!=n)cnt++;
      if(i+1-cnt>(i+1)/2)ans=min(ans,i+1);
    }
    if(ans==n)cout<<"NA"<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

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

using namespace std;

//#define MULTITEST
//#define _DEBUG

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

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

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if (i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 1000 * 1000 + 13;
const int M = 1000 + 13;

int n;
int a[N];
int freq[N];

bool read() {
	if (scanf("%d", &n) != 1)
		return false;
	forn(i, n) {
		scanf("%d", &a[i]);
		freq[a[i]]++;
	}
	return true;
}


void solve() {
	bool pairwise = true;
	bool setwise = true;

	fore(i, 2, N) {
		int cnt = 0;

		for (int j = i; j < N; j += i) {
			cnt += freq[j];
			
		}
		if (cnt == n) {
			setwise = false;
		}
		if (cnt > 1) {
			pairwise = false;
		}
	}

	if (pairwise) {
		printf("pairwise coprime\n");
	}
	else if (setwise) {
		printf("setwise coprime\n");
	}
	else {
		printf("not coprime\n");
	}
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);

	int tt = clock();

#endif

	//ios::sync_with_stdio(false);
  	//cin.tie(0);
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef MULTITEST
	int tc;
	scanf("%d", &tc);
	while (tc--) {
		read();
#else
	while (read()) {
#endif
		solve();

#ifdef _DEBUG
		cerr << "TIME = " << clock() - tt << endl;
		tt = clock();
#endif

	}
	}

Measured memory_bytes: 11464
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;


class Main{
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String n =  in.next();
        char[] ch = n.toCharArray();
        int length = ch.length;
        char key =  ch[0];
        boolean flag = false;
        for (int j = 1 ; j < length ; j++){
            if(key!=ch[j]) {
                flag = true;
                break;
            }
        }
        if(flag)
            System.out.print("Yes");
        else
            System.out.print("No");



    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int main(){
  int n;
  cin >> n;
  int a[n];
  int ans = 0;
  int neg = 0;
  int pos = 0;
  REP(i, n) { cin >> a[i]; if(a[i]<0) neg++; if(a[i]>0) pos++; }
  sort(a, a+n);
  REP(i, n) ans+=abs(a[i]);
  if(a[0]>=0) ans-=2*a[0];
  if(a[n-1]<=0) ans+=2*a[n-1];
  cout << ans << endl;
  int l=0;
  int r=n-1;

  if(n==2) { cout << a[r] << " " << a[l] << endl; return 0; }
  while(a[l]>=0 && pos>1){ cout << a[l] << " " << a[r] << endl; if(a[l]!=0) pos--; a[l]-=a[r]; r--; pos--; if(a[l]!=a[r]) neg++; }
  while(a[r]<=0 && neg>1){ cout << a[r] << " " << a[l] << endl; if(a[r]!=0) neg--; a[r]-=a[l]; l++; neg--; if(a[l]!=a[r]) pos++; }
  while(pos>1) { cout << a[l] << " " << a[r] << endl; a[l]-=a[r]; r--; pos--; }
  while(l<r) { cout << a[r] << " " << a[l] << endl; a[r]-=a[l]; l++; }
  return 0;
}

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

int main(){
  string S;
  int Q;
  cin >> S >> Q;
  vector<int> query(Q);
  vector<int> F(Q);
  vector<string> C(Q);
  for(int i=0; i<Q; i++){
    cin >> query.at(i);
    if(query.at(i)==2){
      cin >> F.at(i) >> C.at(i);
    }
  }
  int one_seen=0;
  for(int i=0; i<Q; i++){
    if(query.at(i)==1) one_seen++;
    else{
      if(one_seen%2==0 && F.at(i)==2) S+=C.at(i);
      else if(one_seen%2==1 && F.at(i)==1) S+=C.at(i);
      else S.insert(0, C.at(i));
    }
  }
  if(one_seen%2==1) std::reverse(S.begin(), S.end());

  cout << S << endl;
}

Measured memory_bytes: 13440
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
typedef long long ll;
using namespace std;

int main() {
    int64_t x, y;
    cin >> x >> y;
    int n=0;
    int64_t z=y/x;
    while (z) {
        z/=2;
        n++;
    } 
    cout << n << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int a = cin.nextInt();
        int b = cin.nextInt();
        int c = cin.nextInt();
        int d = cin.nextInt();

        if (Math.Abs(a - c) <= d)
        {
            Console.WriteLine("Yes");
            return;
        }
        if (Math.Abs(a - b) <= d && Math.Abs(b - c) <= d)
        {
            Console.WriteLine("Yes");
            return;
        }
        Console.WriteLine("No");
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n, m;
  cin >> n >> m;
  map<ll, ll> road;
  rep(i, 0, m){
    ll a, b;
    cin >> a >> b;
    road[a]++;
    road[b]++;
  }
  rep(i, 1, n + 1) cout << road[i] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int n,m;
    cin >> n >> m;
    vector<int>l(m),r(m);
    rep(i,m) {
        cin >> l[i] >> r[i];
    }
    int maxl = 1;
    int minr = 1000000;
    rep(i,m) {
        maxl = max(maxl,l[i]);
        minr = min(minr,r[i]);
    }
    int ans = minr-maxl+1;
    cout << max(ans,0) << endl;
}

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

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

using namespace std;

int main(){
  int r, g, b; cin >> r >> g >> b;
  if (((r*100)+(g*10)+b)%4==0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define mod 1000000007
#define ull unsigned long long
#define mst(ss,b) memset(ss,b,sizeof(ss));
#define pl(x) cout << #x << "= " << x << endl;
const int inf = 0x3f3f3f3f;
const int N = 1e5+5;

int n, a[N];
char s[N];

int  main(){
    scanf("%d%s", &n, s+1);
    s[n+1] = s[1], s[n+2] = s[2];
    for(int i=0; i<4; i++){
        a[1] = i/2, a[2] = i%2;
        for(int j=2; j<=n+1; j++){
            int same = (((s[j] == 'o') + a[j]) == 1);
            a[j+1] = same ? a[j-1] : (1-a[j-1]);
        }
        if(a[n+1] == a[1] && a[n+2] == a[2]){
            for(int j=1; j<=n; j++)printf("%c", a[j] ? 'W' : 'S');
            return 0*puts("");
        }
    }
    puts("-1");
    return 0;
}

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

int main(){
  vector<int> a(3);
  for(int i=0; i<3;i++){
    cin >> a[i];
    }
  sort(a.begin(), a.end());
  cout<<(a[0] +a[1]) <<endl;
  return 0;
  }

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long ll;
#define ALL(V) V.begin(), V.end()
#define RALL(V) V.rbegin(), V.rend()
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}


ll Main(int N, int K, VI &H)
{
    ll ans = 0LL;
    if(N <= K) return 0LL;
    sort(RALL(H));
    REP2(i, K, N) ans += (ll)H[i];
    return ans;
}

int main(void){
    int N, K;
    cin >> N >> K;
    VI H(N);
    REP(i, N) cin >> H[i];
    cout << Main(N, K, H) << endl;
    return 0;
}

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

const ll MOD=1e9+7;

ll ad(ll x,ll y){
  return (x+y)%MOD;
}

ll mlt(ll x,ll y){
  return (x*y)%MOD;
}

int main(){
  ll n,m,a[1010],b[1010],c[1000010]={},d[1000010]={},ans=1,x=0,y=0;
  cin>>n>>m;
  fr(i,n){cin>>a[i];c[a[i]]++;}
  fr(i,m){cin>>b[i];d[b[i]]++;}
  fr(j,n*m){
    ll i=n*m-j;
    if(c[i]>1||d[i]>1){cout<<0<<endl;return 0;}
    if(c[i]&&d[i]){x++;y++;}
    else if(c[i]){
      x++;
      ans=mlt(ans,y);
    }
    else if(d[i]){
      y++;
      ans=mlt(ans,x);
    }
    else{
      ans=mlt(ans,x*y-j);
    }
  }
  cout<<ans<<endl;
}

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

int main()
{
  int A[100];
  int i=0,flag=0;
  char c;
  
  while(1){
    scanf("%c",&c);
    if('0'<=c&&c<='9'){
      if(flag==0){
	A[i]=c-48;
	flag=1;
	i++;
      }
      else if(flag==1){
	i--;
	A[i]=A[i]*10+c-48;
	i++;
      }
	
    }
    else if(c=='+'&&i>1){
      A[i-2]=A[i-2]+A[i-1];
      i--;
    }
    else if(c=='-'&&i>1){
      A[i-2]=A[i-2]-A[i-1];
      i--;
    }
    else if(c=='*'&&i>1){
      A[i-2]=A[i-2]*A[i-1];
      i--;
    }
    else if(c=='\n'){
      break;
    }
    else if(c==' '){
      if(flag==1)
	flag=0;
      }
    }    
  
  printf("%d\n",A[0]);
  return 0;
}

Measured memory_bytes: 536
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  string s;
  cin>>s;
  vector<bool> used(26);
  rep(i,s.size()){
    used[s[i]-97]=true;
  }

  rep(i,26){
    if(used[i]==false){
      cout<<(char)(i+'a')<<endl;
      return 0;
    }
  }
  cout<<"None"<<endl;
  return 0;
}


Measured memory_bytes: 512
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

plus = []
1.upto(n) do |i|
  h = a[i-1]
  plus.push(i+h+1) if i+h+1 <= n
end

hash = plus.group_by(&:itself).map{ |key, value| [key, value.count] }.to_h
ans = 0
1.upto(n) do |i|
  h = a[i-1]

  next if hash[i-h+1].nil?
  ans += hash[i-h+1]
end
p ans



Measured memory_bytes: 49512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int [] p = new int [N];
        
        for(int i=0; i<N; i++){
            p[i] = sc.nextInt();
        }
        
        Arrays.sort(p);
        
        int ans =0;
        for(int i=0; i<K; i++){
            ans += p[i];
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 38672
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int C[111][111]; // nCr の 事前計算.
int p9[5] = {1, 9, 81, 729, 6561};

// 0でない数字が, ちょうどK個あるようなものの個数を計算.
// @param N: 与えられた整数.
// @param c: 現在見ている桁.
// @param k: 0でない数字が使える残りの桁数.
// @return : 計算結果.
int recursive(string N, int c, int k){
    int ret = 0, d = N.size();
    // ex.
    // 1
    // 1
    // -> 1 が 正解だが, 3 と 出力されたため, ロジック修正.
    // if(c >= d) return 1;
    if(c >= d - 1) return N[d - 1] - '0';
    if(k == 0) return 1;
    // if(c >= d) return 1;
    // hand_03 ～ hand_05 で, WA版.
    // ex.
    // 10
    //  2
    // -> 0 が 正解だが, 1 と 出力された.
    // -> 以下の桁数チェックのロジックを追加.
    if(d - c < k) return 0;
    
    if(N[c] > '0'){
        // c桁目が, 0 だった場合, (c + 1)桁目 ～ d桁目 の中で, 1 ～ 9 を k回選択できる.
        ret += C[d - 1 - c][k] * p9[k];
        
        // c桁目が, 1 ～ (N[c] - 1) だった場合, (c + 1)桁目 ～ d桁目 の中で, 1 ～ 9 を (k - 1)回選択できる.
        ret += (N[c] - '1') * C[d - 1 - c][k - 1] * p9[k - 1];
        
        // c桁目が, N[c] だった場合, (c + 1)桁目 ～ d桁目 の中で, 1 ～ 9 を (k - 1)回選択できる.
        ret += recursive(N, c + 1, k - 1);
    }else{
        ret += recursive(N, c + 1, k);
    }
    return ret;
}

int main(){
    
    // 1. 入力情報.
    int K;
    char c[111];
    scanf("%s %d", c, &K);
    string N(c);
    int d = N.size();
    
    // 2. nCr の 事前計算.
    C[0][0] = 1;
    rep(n, 111) C[n][0] = C[n][n] = 1;
    rep(n, 110) repx(k, 1, 111) C[n + 1][k] = C[n][k - 1] + C[n][k];
    assert(C[1][1] == 1);
    assert(C[1][3] == 0);
    assert(C[3][2] == 3);
    assert(C[5][3] == 10);
    assert(C[10][3] == 120);
    assert(C[55][2] == 1485);
    assert(C[100][3] == 161700);
    
    // 3. d < K の 場合.
    if(d < K){
        puts("0");
        return 0;
    }
    
    // 4. d >= K の 場合.
    // ex.
    // 1111
    // 3
    // 
    // 1011 ～ 1099: 81通り
    // 1101 ～ 1109: 9通り
    // 1110 ～ 1110: 1通り
    // 0111 ～ 0999: 729通り
    // => 合計 820通り
    int ans = recursive(N, 0, K);
    
    // 5. 出力.
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b;
const ll maxn=1e5+100;
ll h[maxn],h2[maxn];
bool check(ll x){
	for (ll i=1;i<=n;i++) h2[i]=h[i]-b*x;
	ll s=0;
	for (ll i=1;i<=n;i++){
		if (h2[i]>0){
			s+=(h2[i]-1)/(a-b)+1;
		}
	}
	return x>=s;
}
void solve_B(){
	cin >> n >> a >> b;
	for (ll i=1;i<=n;i++) cin >> h[i];
	ll le=0,ri=2e9;
	while (le<ri){
		ll mid=(le+ri)/2;
		if (check(mid)){
			ri=mid;
		}else{
			le=mid+1;
		}
	}
	cout << le;
}
int main(){
	solve_B();
	return 0;
}

Measured memory_bytes: 1792
from copy import deepcopy
import sys
def main():
    input = sys.stdin.readline
    n, k = map(int, input().split())
    x, y = [], []
    for i in range(n):
        x_, y_ = map(int, input().split())
        x.append(x_)
        y.append(y_)
    X, Y = deepcopy(x), deepcopy(y)
    x.sort()
    y.sort()
    ans = (x[-1] - x[0]) * (y[-1] - y[0])
    for i in range(n):
        for j in range(i + 1, n):
            for K in range(n):
                for l in range(K + 1, n):
                    cnt = 0
                    x1, x2, y1, y2 = x[i], x[j], y[K], y[l]
                    for m in range(n):
                        if x1 <= X[m] <= x2 and y1 <= Y[m] <= y2:
                            cnt += 1
                    if cnt >= k:
                        ans = min(ans, (x2 - x1) * (y2 - y1))
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 74724
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
int A[114514];
int B[114514];
map<int, vector<int>> es;
map<int, int> cnt;
map<int, bool> used;

void dfs(int v) {
  used[v] = true;
  for (int u : es[v]) {
    if (used.count(u)) continue;
    dfs(u);
  }
}

int main() {
  scanf("%d", &N);

  int x = 0;
  rep(i, N) {
    scanf("%d", &A[i]);
    cnt[A[i]]++;
    x ^= A[i];
  }
  cnt[x]++;

  bool fail = false;
  bool has = false;
  int ans = 0;
  rep(i, N) {
    scanf("%d", &B[i]);
    if (B[i] == x) has = true;

    if (A[i] != B[i]) {
      es[B[i]].eb(A[i]);
      es[A[i]].eb(B[i]);
      ans++;
    }

    cnt[B[i]]--;
    //printf("B[%d]: %d, cnt[B[i]]: %d\n", i, B[i], cnt[B[i]]);
    if (cnt[B[i]] < 0) fail = true;
  }

  if (fail) {
    puts("-1");
    return 0;
  }

  if (has) ans--;
  //printf("%d\n", ans);
  //printf("x: %d c: %d\n", x, (int)has);

  for (auto p : es) {
    int v = p.first;
    if (used.count(v)) continue;
    //printf("unused: %d\n", v);
    ans++;
    dfs(v);
  }
  
  printf("%d\n", max(0, ans));
}


Measured memory_bytes: 29184
#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
vector<int> func(int n, int k) {
    vector<int> result;
    for (; k >= 1 and n != 0; k = min(k-1, n)) {
        if (n >= k) {
            n -= k;
            result.push_back(k);
        }
    }
    if (n) result.clear();
    return result;
}
int main() {
    int n; cin >> n;
    repeat (k,n+1) {
        vector<int> xs = func(n, k);
        if (not xs.empty()) {
            for (int x : xs) cout << x << endl;
            break;
        }
    }
    return 0;
}


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

int main(){
	int n;
	while(cin >> n){
		int output = 0;
		for(int a=0;a<=9;a++){
			for(int b=0;b<=9;b++){
				for(int c=0;c<=9;c++){
					for(int d=0;d<=9;d++){
						if(a+b+c+d==n){
							output++;
						}	
					}
				}
			}
		}
		cout << output << endl;
	}
}

Measured memory_bytes: 1160
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}




int main() {

  long n, p;

  cin >> n >> p;

  long pp = p;
  // cerr << n << "  " << p<<endl;
  // int ret[10000000];

  // // vector<long> ret;
  long ans = 1;


  if (n == 1)ans = p;
  if (n > 1) {
    for (int i = 2 ; pow(i,n)<= p ; ++i) {
      long ii = pow(i,n);
      if (pp % ii == 0) {
        ans *= i;
        pp/=ii;
        i--;
      }
    }
  }





  cout << ans << endl;


}




















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

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

struct info {
  ll left,right,time;
};
 
bool comp(const info& a, const info& b) {
  return a.time < b.time;
}

int main() {
  int n,q;
  cin >> n >> q;
  ll s,t,x;
  vector<info> vec(n);
  rep(i,n) {
    cin >> s >> t >> x;
    vec[i] = {x-t+1,x-s,x};
  }
  sort(vec.begin(),vec.end(),comp);
  vector<ll> ans(q,-1);
  map<ll,int> mp;
  set<ll> Set;
  ll d;
  rep(i,q) {
    cin >> d;
    d = -d;
    mp[d] = i;
    Set.insert(d);
  }
  rep(i,n) {
    while (Set.size() > 0) {
      auto itr1 = Set.lower_bound(vec[i].left);
      if (itr1 != Set.end() && (*itr1) <= vec[i].right) {
        ans[mp[(*itr1)]] = vec[i].time;
        Set.erase((*itr1));
      }
      else break;
    }
  }
  rep(i,q) printf("%lld\n",ans[i]);
  return 0;
}

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    string s,t; cin>>s>>t;
    int res = 0;
    FOR(i, 0, s.size()) res += (s[i] != t[i]);
    cout << res;

    return 0;
}

Measured memory_bytes: 3832
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;
long long int d[200][200] = {}, n, combination[55][55] = {};






int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	string str,str2,tmp;
	cout << fixed << setprecision(10);
	long long int res = 0, y, id = 0, m = 0, a[2000], b[2000], c[2000], x, k, ng[2000] = {}, left = 0, dp[100][3] = {};
	cin >> n >> x >> y;
	long double big = 0.0;

	for (int i = 1; i <= 50;i++) {
		combination[i][0] = 1;
		combination[i][i] = 1;
	}
	for (int i = 2; i <= 50; i++) {
		for (int j = 1; j<i; j++) {
			combination[i][j] = combination[i - 1][j] + combination[i - 1][j - 1];

		}
	}
	for (int i = 2; i <= 50; i++) {
		for (int j = 0; j <= i; j++) {
			combination[i][j] = combination[i - 1][j] + combination[i - 1][j - 1];
			
		}
	}


	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = n - 1; i >= n-x; i--) {
		big += a[i];
		id = a[i];
	}
	for (int i = n; i >= 1; i--) {
		if (a[i - 1] == id) { k = n - i; break; }
	}


	for (int i = 0; i < n; i++) {
		if (a[i] == id) { m++; }
	}
	if (id == a[n - 1]) {
		for (int i = x - k; i <= y - k; i++) {
			res += combination[m][i];
		}
	}
	else {
		res = combination[m][x-k];
	}

	cout << big / x << endl << res << endl;

} 


Measured memory_bytes: 256
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_D
 */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int
main()
{
  ios::sync_with_stdio(false);

  string line;
  getline(cin, line);

  int n;
  cin >> n; cin.ignore();

  for (int i = 0; i < n; i++) {
    string cmd;
    int p1, p2;
    cin >> cmd >> p1 >> p2;

    if (cmd == "replace") {
      string r;
      cin >> r;
      line.replace(p1, p2 - p1 + 1, r);
    } else if (cmd == "reverse") {
      reverse(line.begin() + p1, line.begin() + p2 + 1);
    } else if (cmd == "print") {
      cout << line.substr(p1, p2 - p1 + 1) << endl;
    }
    cin.ignore();
  }

  return 0;
}

Measured memory_bytes: 3208
inpl = lambda: list(map(int,input().split()))
def get_sequence(arr):
    if len(arr) == 0:
        return [], []
    elements = []
    nums = []
    n = 1
    prev = arr[0]
    for c in arr[1:]:
        if c == prev:
            n += 1
        else:
            elements.append(prev)
            nums.append(n)
            prev = c
            n = 1
    elements.append(prev)
    nums.append(n)
    return elements, nums

S = input()
K = int(input())
ele, num = get_sequence(S)
if len(ele) == 1:
    print(K*len(S)//2)
else:
    if ele[0]==ele[-1]:
        ans = num[0]//2 + num[-1]//2
        ans += sum(map(lambda x: x//2, num[1:-1]))*K
        ans += (num[0]+num[-1])//2 * (K-1)
    else:
        ans = sum(map(lambda x: x//2, num))*K
    print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define PI acos(-1)





const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const P& a, const P& b) {
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}

struct L : public vector<P> {
	L() {}
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};

P projection(const L &l, const P &p) {
	double t = dot(p - l[0], l[0] - l[1]) / norm(l[0] - l[1]);
	return l[0] + t*(l[0] - l[1]);
}

int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if (cross(b, c) > 0)   return +1;       // counter clockwise
	if (cross(b, c) < 0)   return -1;       // clockwise
	if (dot(b, c) < 0)     return +2;       // c--a--b on line
	if (norm(b) < norm(c)) return -2;       // a--b--c on line
	return 0;
}

bool intersectSS(const L &s, const L &t) {
	return ccw(s[0], s[1], t[0])*ccw(s[0], s[1], t[1]) <= 0 &&
		ccw(t[0], t[1], s[0])*ccw(t[0], t[1], s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
	return abs(s[0] - p) + abs(s[1] - p) - abs(s[1] - s[0]) < EPS; // triangle inequality
}

double distanceSP(const L &s, const P &p) {
	const P r = projection(s, p);
	if (intersectSP(s, r)) return abs(r - p);
	return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
	if (intersectSS(s, t)) return 0;
	return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
		min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}





int N, M, LL;
vector<P> star[100];
double d[100][100];

double dist(int a, int b)
{
	vector<L> aa, bb;

	rep(i, 0, 5) aa.push_back(L(star[a][(i * 2) % 5], star[a][((i + 1) * 2) % 5]));
	rep(i, 0, 5) bb.push_back(L(star[b][(i * 2) % 5], star[b][((i + 1) * 2) % 5]));

	double ret = INF;
	rep(i, 0, 5) rep(j, 0, 5) ret = min(ret, distanceSS(aa[i], bb[j]));
	return ret;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while (cin >> N >> M >> LL)
	{
		if (N == 0) return 0;
		M--; LL--;

		rep(i, 0, N)
		{
			star[i].clear();

			double x, y, a, r; cin >> x >> y >> a >> r;
			rep(j, 0, 5)
			{
				double thi = j * 72;
				double xx = -r * sin((a + thi) / 180.0 * PI) + x;
				double yy = r * cos((a + thi) / 180.0 * PI) + y;
				star[i].push_back(P(xx, yy));
			}
		}

		rep(i, 0, N) rep(j, 0, N) d[i][j] = INF;
		rep(i, 0, N) d[i][i] = 0;
		rep(i, 0, N) rep(j, i + 1, N) d[i][j] = d[j][i] = dist(i, j);

		rep(k, 0, N) rep(i, 0, N) rep(j, 0, N)
			d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

		printf("%.10f\n", d[M][LL]);
	}
}

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

namespace _20190616_ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            int X, A;
            String[] inputdata = Console.ReadLine().Split(' ');

            X = int.Parse(inputdata[0]);
            A = int.Parse(inputdata[1]);

            if (X < A) Console.WriteLine("0");
            else Console.WriteLine("10");

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13268
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let r: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let ans = 3 * r * r;

    println!("{}", ans);
}

Measured memory_bytes: 4352
def find(u,x):
    if u[x]<0:
        return x
    u[x] = find(u,u[x])
    return u[x]

def unite(u,a,b):
    a = find(u,a)
    b = find(u,b)
    if a == b:
        return False
    if u[b] < u[a]:
        a,b = b,a
    u[a] += u[b]
    u[b] = a
    return True

def same(u,x,y):
    return find(u,x) == find(u,y)

n = int(input())
l = list()
for i in range(n):
  x,y = map(int,input().split())
  l.append((x,y,i))
l.sort()
uf = [-1]*(n+1)
ed = list()
for i in range(n-1):
  ed.append((l[i][2],l[i+1][2],l[i+1][0]-l[i][0]))
l.sort(key=lambda x:x[1])
for i in range(n-1):
  ed.append((l[i][2],l[i+1][2],l[i+1][1]-l[i][1]))
ed.sort(key=lambda x:x[2])
ans = 0
for x,y,d in ed:
  if not same(uf,x,y):
    unite(uf,x,y)
    ans += d
print(ans)

Measured memory_bytes: 47204