akhauriyash/Code-Regression huggingface dataset:
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let m: usize = s.next().unwrap().parse().unwrap();
	let src: usize = s.next().unwrap().parse::<usize>().unwrap() - 1;
	let dst: usize = s.next().unwrap().parse::<usize>().unwrap() - 1;
	let mut yen = vec![vec![]; n];
	let mut snuuk = vec![vec![]; n];
	for _ in 0..m {
		let src: usize = s.next().unwrap().parse::<usize>().unwrap() - 1;
		let dst: usize = s.next().unwrap().parse::<usize>().unwrap() - 1;
		let yc: i64 = s.next().unwrap().parse().unwrap();
		let sc: i64 = s.next().unwrap().parse().unwrap();
		yen[src].push(Edge { to: dst, cost: yc });
		yen[dst].push(Edge { to: src, cost: yc });
		snuuk[src].push(Edge { to: dst, cost: sc });
		snuuk[dst].push(Edge { to: src, cost: sc });
	}
	let yen = dijkstra(&yen, src);
	let snuuk = dijkstra(&snuuk, dst);
	let ans: Vec<i64> = yen.iter().rev().zip(snuuk.iter().rev()).scan(std::i64::MAX, |s, (yen, snuuk)|{
		*s = std::cmp::min(*s, yen + snuuk);
		Some(*s)
	}).collect();
	use std::io::Write;
	let out = std::io::stdout();
	let mut out = std::io::BufWriter::new(out.lock());
	for ans in ans.into_iter().rev() {
		writeln!(out, "{}", 1e15 as i64 - ans).unwrap();
	}
}

fn dijkstra(edges: &Vec<Vec<Edge>>, src: usize) -> Vec<i64> {
	let mut dist = vec![std::i64::MAX; edges.len()];
	dist[src] = 0;
	let mut q = std::collections::BinaryHeap::new();
	q.push((0, src));
	while let Some((cost, i)) = q.pop() {
		let cost = -cost;
		if dist[i] < cost { continue; }
		for e in edges[i].iter() {
			if dist[e.to] <= cost + e.cost { continue; }
			dist[e.to] = cost + e.cost;
			q.push((-dist[e.to], e.to));
		}
	}
	dist
}

#[derive(Clone, Copy)]
struct Edge {
	to: usize,
	cost: i64,
}


Measured memory_bytes: 38644
import sys
from collections import deque

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

doors = [[] for _ in range(N)]

for A, B in AB:
    doors[A-1].append(B)
    doors[B-1].append(A)
#print(doors)
#exit()

answer = [sys.maxsize for _ in range(N-1)]
distance = [sys.maxsize for _ in range(N)]
distance[0] = 0
q = deque([1])

while len(q) > 0:
  current = q.popleft()
  for nextroom in doors[current-1]:
    if distance[current-1] + 1 < distance[nextroom-1]:
        q.append(nextroom)
        distance[nextroom-1] = distance[current-1] + 1
        answer[nextroom-2] = current
    else:
        pass
if sys.maxsize in answer:
    print('No')
    exit()
print('Yes')
for a in answer:
    print(a)


Measured memory_bytes: 130412
H,W = map(int,input().split())
count = 0
ans = []
arr = []
for i in range(H):
    arr.append(list(map(int,input().split())))
for h in range(H):
    for w in range(W-1):
        if arr[h][w]%2 == 1:
            arr[h][w+1] += 1
            count += 1
            ans.append([h+1,w+1,h+1,w+2])

for h in range(H-1):
    if arr[h][W-1]%2 == 1:
        arr[h+1][W-1] += 1
        count += 1
        ans.append([h+1,W,h+2,W])

print(count)
for i in range(count):
    print(ans[i][0],ans[i][1],ans[i][2],ans[i][3])
      

Measured memory_bytes: 30264
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String s = sc.next();
			char[] c = s.toCharArray();

			int result = 0;
			for (int i = 0; i < c.length / 2; i++) {
				if (c[i] != c[c.length - 1 - i]) {
					result++;
				}
			}
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 23252
SIZE = 4500
def main():
    N = int(input())
    for n in range(SIZE+1):
        if n*(n+1) < 2 * N <= (n+1)*(n+2):
            break
    n += 1
    d = n*(n+1)//2 - N
    for i in range(1, n+1):
        if i == d: continue
        print(i)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main() {
//string s,t;
int a,b,c,i,n,t;
long double g,h,o;
    map<int,int> ma;
    map<int,int> :: iterator it;
vector<int> v;
cin>>n>>t;
for(i=1;i<=n;i++){
    cin>>a>>b;
    if(b<=t){
        ma[a] = 1;
    }
}
if(ma.size()==0){cout<<"TLE"<<endl;}
else {
    it = ma.begin();
        cout<<(*it).first<<endl;
}
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	int dif = b - a;

	int h = 0;
	for (int ii = 1; ii < dif; ++ii){
		h += ii;
	}

	cout << h - a << "\n";

	return 0;
}


Measured memory_bytes: 3580
using System;
using System.Collections.Generic;

namespace ALDS1_11C{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            var a = new List<int>[N + 1];

            for(var i = 1; i <= N; i++){
                a[i] = new List<int>();
            }

            for(var i = 1; i <= N; i++){
                var U = sr.Next<int>();
                var K = sr.Next<int>();

                for(var j = 0; j < K; j++){
                    var V = sr.Next<int>();
                    a[U].Add(V);
                    //a[V].Add(U);
                }
            }

            var dist = new int[N + 1];
            var que = new Queue<int>();
            dist[1] = 1;
            que.Enqueue(1);

            while(que.Count > 0){
                var now = que.Dequeue();
                foreach(var next in a[now]){
                    if(dist[next] == 0){
                        dist[next] = dist[now] + 1;
                        que.Enqueue(next);
                    }
                }
            }

            for(var i = 1; i <= N; i++){
                Console.WriteLine("{0} {1}", i, dist[i] - 1);
            }
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }
    }
}

Measured memory_bytes: 10820
//ABC075C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> s(n);
	int ans = 0;
	int m = 1000;
	for(int i=0;i<n;i++){
		cin >> s.at(i);
		ans += s.at(i);
		if(s.at(i)%10 != 0){
			m = min(m,s.at(i));
		}
	}
	if(ans%10 == 0){
		if(m == 1000){
			ans = 0;
		}else{
			ans -= m;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define INF2 (1e18)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m;
    cin >> n >> m;
    dsu d(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        d.merge(a, b);
    }
    int cnt = 0;
    rep(i, n) if (d.leader(i) == i) ++cnt;
    cout << (cnt-1) << endl;
    return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
using pii = pair <int, int>;
#define int ll
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = false;
int grid[120][120];
int a, b;
void print_grid()
{
    for (int i = 1; i<=100; i++)
    {
        for (int j = 1; j<=100; j++)
            printf("%c",grid[i][j]==1?'#':'.');
        printf("\n");
    }
}
int32_t main()
{
    for (int i = 1; i<=50; i++)
    {
        for (int j = 1; j<=100; j++)
        {
            grid[i][j] = 0;
            grid[i+50][j] = 1;
        }
    }
    cin >> a >> b;
    a--; b--;
    for (int i = 2; i<=49; i+=2)
    {
        for (int j = 2; j<=98; j+=2)
        {
            if (b)
            {
                grid[i][j] = 1;
                b--;
            }
        }
    }
    for (int i = 52; i<=99; i+=2)
    {
        for (int j = 2; j<=98; j+=2)
        {
            if (a)
            {
                grid[i][j] = 0;
                a--;
            }
        }
    }
    printf("100 100\n");
    print_grid();
}

Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<map>
using namespace std;
int a[100001];
map<int,bool>b;
long long ans;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)  cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		if(b[a[i]]==false)
		{
			ans++;
			b[a[i]]=true;
		}
		else {
			ans--;
			b[a[i]]=false;
		}    
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5376
hoge = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
X.append(hoge[2])
Y.append(hoge[3])
X.sort()
Y.sort()
 

if(Y[0]-X[-1]>0):
  print("No War")
else:
  print("War")

Measured memory_bytes: 3064
#include <cstdio>
#include <string>
#include <vector>
using namespace std;
static const int INFTY = (1 << 20);

int n;

struct Restrant
{
  string locate;
  int ten;
  int num;

  Restrant(string n, int t, int k)
  {
    locate = n;
    ten = t;
    num = k;
  }
};

bool cmp(const Restrant &a, const Restrant &b)
{
  if (strcmp(a.locate.c_str(), b.locate.c_str()) < 0)
  {
    return true;
  }
  else if (strcmp(a.locate.c_str(), b.locate.c_str()) > 0)
  {
    return false;
  }
  else
  {
    return a.ten > b.ten;
  }
}

int main()
{

  scanf("%d", &n);
  int p;
  char *s[n];
  char text[50];
  std::vector<Restrant> res;
  for (int i = 0; i < n; i++)
  {
    scanf("%s %d", text, &p);
    res.push_back(Restrant(text, p, i + 1));
  }
  sort(res.begin(), res.end(), cmp);
  for (int i = 0; i < n; i++)
  {
    printf("%d\n", res[i].num);
    //printf("%s %d %d\n", res[i].locate.c_str(), res[i].ten, res[i].num);
  }
  return 0;
}

Measured memory_bytes: 888
#include<cctype>
#include<string>
#include<algorithm>
#include<iostream>
#include<set>
#include<regex>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<map>
#include<functional>
#include<unordered_map>
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    long double a, b, c = 0;
    cin >> a >> b;
    c = a * b;
    cout << (uli)floor(c) << endl;

}

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

namespace Test01
{
    class Program
    {
        
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int N = input[0];
            int K = input[1];
            int Q = input[2];

            int[] p = (new int[N]).Select(x => K - Q).ToArray();
            for(int i = 0; i < Q; i++)
            {
                int a = int.Parse(Console.ReadLine()) - 1;
                p[a]++;
            }

            for(int i = 0; i < N; i++)
            {
                if (p[i] > 0) Console.WriteLine("Yes");
                else Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 19420
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define INF 1e9

using vb=vector<bool>;
using vvb=vector<vb>;

int main(){
	int n,m,a[3];
	while(cin>>n>>m>>a[0]>>a[1]>>a[2]){
		vvb z(n,vb(n,false));
		auto e=z;
		rep(_,m){
			int p,q; cin>>p>>q;
			e[p-1][q-1]=true;
		}

		vector<vvb> d(3);
		auto f=e;
		rep(l,*max_element(a,a+3)){
			rep(p,3) if(l==a[p]-1) d[p]=f;
			auto next=z;
			rep(k,n)rep(i,n)rep(j,n){
				next[i][j] = next[i][j] or (f[i][k] and e[k][j]);
			}
			f=next;
		}
		
		unordered_set<int> g;
		g.insert(n-1);
		rep(t,1000){
			unordered_set<int> ng;
			rep(i,n) if(!g.count(i)){
				bool ok=true;
				rep(p,3) ok&=[=]{bool r=false; rep(j,n) r|=(g.count(j) and d[p][i][j]); return r;}();
				if(ok) ng.insert(i);
			}
			if(ng.size()==0){
				cout<<"IMPOSSIBLE"<<endl;
				break;
			} else if(ng.count(0)){
				cout<<t+1<<endl;
				break;
			}
			g.insert(all(ng));
		}
	}
	return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(void){
	int n,m;
	string s,t;
	cin>>n;
	if(n<1200){
		cout<<"ABC"<<endl;
	}else if(n<2800){
		cout<<"ARC"<<endl;
	}else{
		cout<<"AGC"<<endl;
		
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int dx, dy;

  dx = abs(x2 - x1);
  dy = abs(y2 - y1);

  int x3, y3, x4, y4;

  if (x2 >= x1){
    if (y2 >= y1){
      x3 = x2 - dy;
      y3 = y2 + dx;
      x4 = x3 - dx;
      y4 = y3 - dy;
    }
    else {
      x3 = x2 + dy;
      y3 = y2 + dx;
      x4 = x3 - dx;
      y4 = y3 + dy;
    }
  }
  else {
    if (y2 >= y1){
      x3 = x2 - dy;
      y3 = y2 - dx;
      x4 = x3 + dx;
      y4 = y3 - dy;
    }
    else {
      x3 = x2 + dy;
      y3 = y2 - dx;
      x4 = x3 + dx;
      y4 = y3 + dy;
    }
  }

  cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;


  return 0;
}


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

public class MainClass
{
	public const long Giri = 1000000007;
	
	public static void Main(string[] args)
	{
		//string[] d = Input();
		int r = int.Parse(Console.ReadLine());
		Console.WriteLine(3*r*r);
	}

	public static long GCD(long a, long b)
	{
		if(b == 1)
			return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

}



Measured memory_bytes: 13140
n,q = map(int,input().split())

ans = (n-2)**2
rm = n
um = n
ruse = [-1]*(n+1)
uuse = [-1]*(n+1)

for _ in range(q):
    a,x = map(int,input().split())
    if a == 1:
        if uuse[x] >= 0:
            ans -= uuse[x]-2
        else:
            dif = um - 2
            ans -= dif
            for i in range(x,n+1):
                if uuse[i] >= 0:
                    break
                uuse[i] = um
            rm = min(rm,x)
    else:
        if ruse[x] >= 0:
            ans -= ruse[x]-2
        else:
            dif = rm - 2
            ans -= dif
            for i in range(x,n+1):
                if ruse[i] >= 0:
                    break
                ruse[i] = rm
            um = min(um,x)
print(ans)

Measured memory_bytes: 77936
#include <iostream>
#include <limits>
#include <cfenv>
#include <cmath>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <list>
#include <random>
#include <functional>


#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::pair<int, int>;

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;
}



// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




// D[i] = 最初の注文からi分終了時で得られる最大の満足
constexpr int N = 3000;
std::array<lli, 2 * N + 1> D;
std::vector<std::pair<int, int>> A;
std::vector<bool> S;





int main(void){
    int n, t; scanf("%d%d", &n, &t);
    A.resize(n); REP(i, n) scanf("%d%d", &A[i].first, &A[i].second);
    std::sort(A.begin(), A.end());
    REP(i, n){
        int x = A[i].first, y = A[i].second;
        for(int j = t - 1; j >= 0; --j){
            if(D[j + x] < D[j] + y) D[j + x] = D[j] + y;
        }
    }
    lli res = 0;
    for(lli p : D) if(res < p) res = p;
    printf("%lld\n", res);
    
    return 0;
}



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

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

	int N;
	cin >> N;
	vector<int> A( N );
	for( auto& v: A ) { cin >> v; }

	int result = 0;
	for( int i = 0; i < N-1; ++i ) {
		for( int j = i+1; j < N; ++j ) {
			result = max( result, abs( A[i] - A[j] ) );
		}
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    char ans = '0';
    map<char, int> mp;
    for (char c: s) {
        mp[c]++;
    }
    if (mp.size()==26) {
        cout << "None" << endl;
        return 0;
    }
    rep(i, 26) {
        if (mp['a'+i]==0) {
            ans = 'a'+i;
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

int num[11][7] = {{0,1,1,1,1,1,1},
		  {0,0,0,0,1,1,0},
		  {1,0,1,1,0,1,1},
		  {1,0,0,1,1,1,1},
		  {1,1,0,0,1,1,0},
		  {1,1,0,1,1,0,1},
		  {1,1,1,1,1,0,1},
		  {0,1,0,0,1,1,1},
		  {1,1,1,1,1,1,1},
		  {1,1,0,1,1,1,1},
		  {0,0,0,0,0,0,0}}; 
int main(){

  int n;
  while(1){
    cin >> n;
    if(n==-1) break;
    int pre =10,next;
    for(int i=0;i<n;i++){
      cin  >> next;
      for(int j=0;j<7;j++){
	if(num[pre][j] != num[next][j]) cout << "1";
	else cout << "0";
      }
      pre = next;
      cout << "\n";
    }

  }

}

Measured memory_bytes: 1120
s=input()
s=s[:-1]

for i in range(len(s)):
    s_1=s[:len(s)//2]
    s_2=s[len(s)//2:]
    if all(s.count(x)%2 == 0 for x in s) and s_1 == s_2 or len(s) == 2:
        print(len(s))
        break
    else:
        s=s[:-1]

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	long a[100] = {0};
	long n,i,j;
	int show = 0;
	
	scanf("%d", &n);
	
	if(n == 0){
		printf("0\n");
		return(0);
	}
	if(n == 1){
		printf("1\n");
		return(0);
	}
	
	a[99] = 1;
	for(i = 1 ; i <= n; i++){
		for(j = 0; j <= 99; j++){
			a[j] *= i;
			if(a[j] >= 1000000){
				a[j-1] += a[j]/1000000;
				a[j] %= 1000000;
			}
		}
	}
	for(i = 0; i < 100; i++){
		if(a[i] != 0 && !show){
			printf("%d", a[i]);
			show = 1;
		}
		else if(show == 1){
			printf("%06d", a[i]);
		}
	}
	printf("\n");
	
	return(0);
}

Measured memory_bytes: 608
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int a;
    int b;
    int d;
    int r;
    double f;
    
    cin >> a >> b;
    
    d = a / b;
    
    r = a % b;
    
    f = (double)a / (double)b;
    
    printf("%d %d %.8lf", d, r, f);
    
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;
typedef long long ll;

string S, T;

int main(){
  cin >> S >> T;
  string new_T = T.substr(0, S.size());
  if (S == new_T) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1000000007;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

void solve(){
    int N; cin >> N;
    vector<ll> A(N);
    for (int i=0;i<N;++i) cin >> A[i];
    string S; cin >> S;

    vector<ll> bases;
    for (int i=N-1;i>=0;--i){
        for (ll base:bases) A[i]=min(A[i],A[i]^base);
        if (A[i]>0){
            if (S[i]=='0') bases.emplace_back(A[i]);
            else {
                cout << 1 << '\n';
                return;
            }
        }
    }

    cout << 0 << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T; cin >> T;
    for (;T--;){
        solve();
    }
}

Measured memory_bytes: 3624
#include <cstdio>
#include <vector>
#include <set>

using namespace std;

int main() {
    int n, k, i, j;
    vector <int> v;
    vector <pair<int, pair<int, int>>> ans;
    set <int> s;
    set <int>::iterator it;
    
    scanf("%d %d", &n, &k);
    
    for (i = n; i < n * 2; i++) s.insert(k + i);
    
    for (i = 0; i < n; i += 2) v.push_back(k + i);
    for (i = 1; i < n; i += 2) v.push_back(k + i);
    
    for (i = n * 2, j = 0; i < n * 3; i++, j++) {
        int x = k + i, y = v[j], z;
        
        it = s.upper_bound(x - y);
        
        if (it == s.begin()) {
            puts("-1");
            
            return 0;
        }
        
        it--;
        z = *it;
        s.erase(z);
        
        ans.push_back(make_pair(y, make_pair(z, x)));
    }
    
    for (i = 0; i < ans.size(); i++) printf("%d %d %d\n", ans[i].first, ans[i].second.first, ans[i].second.second);
    
    return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    string S;
    cin >> S;

    string ans = "";
    rep (i, S.size()) {
        if (S[i]+N > 'Z') {
            ans += S[i]+N-26;
        } else {
            ans += S[i]+N;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

class eratosthenes {
public:
	vector<int> prime_n;
	bool prime[500001];

	eratosthenes() {
		fill(prime, prime + 500001, true); //素数
		prime[0] = prime[1] = false;
		for (int i = 2; i < 500001; i++) {
			if (prime[i] == true) {
				prime_n.push_back(i);
				for (int j = 2; i * j < 500001; j++) {
					prime[i * j] = false;
				}
			}
		}
	}
};

int main(){
    int n;
    cin >> n;
    eratosthenes p;

    int cnt = 0;
    int idx = 0;
    while(cnt < n){
        if(p.prime_n[idx] % 5 == 1) {
            cout << p.prime_n[idx] << " ";
            cnt++;
        }
        idx++;
    }
    cout << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long int lli;

//不正解

int main()
{   
    lli L, R;
    cin >> L >> R;
    if(R - L > 2018){
        cout << 0 << endl;
    } else {
        int min = 2018;
        for(int i = L; i < R; i++){
            for(int j = i + 1; j <= R; j++){
                if(min > (((i % 2019) * (j % 2019)) % 2019)){
                    min = ((i % 2019) * (j % 2019)) % 2019;
                }
            }
        }
        cout << min << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    
    
    int s, hours, minutes, seconds;
    std::cin >> s;
    
    if(s >= 0 && s <= 86400)
    {
       //m = (sec -(3600*h))/60;
        seconds = s % 60;
        hours = s / 3600;
        minutes = (s - (3600 * hours)) / 60;

        std:: cout << hours << ":" << minutes << ":" << seconds << std::endl;
    }

    return 0;
}



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

int main()
{
    int n, m;

    while( cin >> n >> m )
    {
        if( n + m == 0 )
            break;
        
        int* a = new int[n];
        int* b = new int[m];
        int* c = new int[n+m];

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

        for( int i = 0; i < m; i++ )
            cin >> b[i];

        int i = 0, j = 0;
        while( i < n && j < m )
        {
            if( a[i] < b[j] )
            {
                c[i+j] = a[i];
                i++;
            }
            else
            {
                c[i+j] = b[j];
                j++;
            }
        }
        while( i < n )
        {
            c[i+j] = a[i];
            i++;
        }
        while( j < m )
        {
            c[i+j] = b[j];
            j++;
        }

        int ma = c[0];
        for( i = 0; i < n + m - 1; i++ )
            ma = ma > c[i+1] - c[i] ? ma : c[i+1] - c[i];

        cout << ma << endl;

        delete a, b, c;
    }

    return 0;
}


Measured memory_bytes: 3364
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll dp[405][405];
int a[405];
ll sum[405];
  
ll find(int l, int r) {
  if (l == r) return 0;
  if (dp[l][r] == -1) {
    dp[l][r] = 1e18;
    for (int i = l; i < r; i++) {
      dp[l][r] = min(dp[l][r], find(l, i) + find(i + 1, r));
    }
    dp[l][r] += sum[r] - sum[l - 1];
  }
  return dp[l][r];
}

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

  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum[i] = a[i] + sum[i - 1];
  }
  memset(dp, -1, sizeof(dp));
  cout << find(1, n) << '\n';

  return 0;
}

Measured memory_bytes: 1536
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        n:usize,
        m:usize,
        a:[usize;m],
    }

    let sum:usize = a.iter().sum();

    println!("{}", if sum <= n { (n - sum) as i64 } else { -1 });
}


Measured memory_bytes: 2256
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 500100, MAXK = 23;
const ll MOD = 998244353;
const int INF = 1e9+10;
const ld PI = asin(1) * 2;

void setIO () {
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

int n;
int a[MAXN];

int main() {
	setIO();

    cin >> n;
    FOR(i, 1, n) cin >> a[i];

    int s = 0;
    FOR(i, 1, n) s = s^a[i];

    FOR(i, 1, n) cout << (s^a[i]) << " ";
    cout << "\n";


    return 0;
}


Measured memory_bytes: 4440
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const long long N = 5001;
long long n, a[N], b[N], x, ans;

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

	cin >> n >> x;
	for(long long i = 0; i < n; i++)
		cin >> a[i], b[i] = a[i];

	long long ans = n * a[1] + n * x;

	for(long long nr = 0; nr <= n; nr++) {
		long long ret = nr * x;
		for(long long i = 0; i < n; i++) {
			b[i] = min(b[i], a[(i + nr) % n]);
			ret += b[i];
		}
		ans = min(ans, ret);
	}

	cout << ans << '\n';
}	

	

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

int main(){
    int t,r,c,R,C,flag,i,j,k,l;
    t = 1;
    while(t--){
        cin>>R>>r;
        C = R;
        c =r;
        char a[R][C];
        for(i=0;i<R;i++){
            for(j=0;j<C;j++){
                cin>>a[i][j];
               // cout<<a[i][j]<<" ";
            }
           // cout<<"\n";
        }
        char b[r][c];
        for(i=0;i<r;i++){
            for(j=0;j<c;j++){
                cin>>b[i][j];
               // cout<<b[i][j]<<" ";
            }
           // cout<<"\n";
        }
        flag=0;
        int final=0;
        for(i=0;i<=R-r;i++){
           // cout<<"H";
            for(j=0;j<=C-c;j++){
                if(a[i][j]==b[0][0]){
                   // cout<<a[i][j]<<" "<<b[0][0]<<" "<<i<<" "<<j<<"\n";
                    flag=1;
                    for(k=0;k<r;k++){
                        if(flag==0)
                            break;
                        for(l=0;l<c;l++){
                            if(b[k][l]==a[i+k][j+l]){
                                if(k==r-1&&l==c-1)
                                    final=1;
                                flag=1;
                            }
                            else{
                                flag=0;
                                break;
                            }
                        }
                    }
                }
            }
        }
        if(final==0)
            cout<<"No\n";
        if(final)
            cout<<"Yes\n";
    }
    return 0;
}

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

int main(){
	LL n, m, k;
	cin >> n >> m >> k;
	LL ok = 0;
	for(LL i = 0; i <= n; i++){
		for(LL j = 0; j <= m; j++){
			if(k == (i*j + (n-i)*(m-j))) ok = 1;
		}
	}
	if(ok){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ITP1_7_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var words = Console.ReadLine().Split(' ');
                var n = int.Parse(words[0]);
                var sum = int.Parse(words[1]);
                if (n == 0 && sum == 0)
                {
                    return;
                }
 
                var count = 0;
                for (var i = 1; i <= (n - 2); ++i)
                {
                    for (var j = i + 1; j <= (n - 1); ++j)
                    {
                        var remain = sum - (i + j);
                        if (j < remain && remain <= n)
                        {
                            ++count;
                        }
                    }
                }
                Console.WriteLine(count);
            }
        }
    }
}

Measured memory_bytes: 5620
#include<iostream>
#include<list>
#include<vector>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define MAX 10000

class Node;
void dfs(int N);

class Node
{
public:
	bool IsDone = false;
	vector<int> E;
};

list<int> ans;
Node nodes[MAX];

void dfs(int N)
{
	nodes[N].IsDone = true;
	for (int i = 0; i<nodes[N].E.size(); i++)
	{
		if (nodes[nodes[N].E[i]].IsDone == false)
		{
			dfs(nodes[N].E[i]);
		}
	}
	ans.push_front(N);
}

int main()
{
	int V, E;
	cin >> V >> E;
	REP(i, E)
	{
		int s, t;
		cin >> s >> t;
		nodes[s].E.push_back(t);
	}
	REP(i, V)if (nodes[i].IsDone == false)dfs(i);
	for (auto var : ans)cout << var << endl;
	return 0;
}

Measured memory_bytes: 4180
#include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0; i<n ; ++i)
#define all(v) v.begin() , v.end()
#define sz(v) (int(v.size()))
typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef vector<pii> vp;
typedef pair<int,pii> piii;

int OO = 2e9;
const double eps = 1e-9 ;
const int N = 200005;
int mx = -1e9 , mn = 1e9 ;
double arr[N] , arr2[N];
double dd[N];

int main()
{
    ll n, m , ans = 0 , c = 0;
    cin >> n >> m;
    pair<ll,ll> tep[n];
    lp(i,n){
        cin >> tep[i].first >> tep[i].second ;
    }
    sort(tep,tep+n);
    lp(i,n){
        ans += (min(m-c,tep[i].second) * tep[i].first);
        c += min(m-c,tep[i].second);
        if(c >= m)
            break;
    }
    cout << ans << endl;




    return 0;
}


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

int main() {
	int r0, w0, c, r;
	while (cin >> r0 >> w0 >> c >> r) {
		if (!r0) break;
		int i;
		for (i = 0; ; i++) {
			if ((r0 + r * i) >= w0 * c) break;
		}
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
from functools import reduce

L, A, B, M = map(int, input().split())

MOD = M


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(
                pow(self.x, other.x, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    def __radd__(self, other):
        return ModInt(other + self.x)

    def __rsub__(self, other):
        return ModInt(other - self.x)

    def __rmul__(self, other):
        return ModInt(other * self.x)

    def __rtruediv__(self, other):
        return ModInt(other * pow(self.x, MOD - 2, MOD))

    def __rpow__(self, other):
        return ModInt(pow(other, self.x, MOD))


def iceil(a, b):
    return (a + b - 1) // b


# 等差数列を桁数が同一の要素ごとに区切る
# 区切った等差数列の各要素について、それを末尾に追加する操作を線形変換とみなす
# 線形変換はダブリングで高速に計算する
T = {}
x = A
while x <= A + B * (L - 1):
    k = len(str(x))
    r = iceil(
        min(
            10**k,
            A + B * (L - 1) + 1
        ) - x,
        B
    )
    T[k] = r
    x += r * B


def mut_mul(X, Y):
    return [
        [
            sum(X[i][k] * Y[k][j] for k in range(len(Y)))
            for j in range(len(Y[0]))
        ]
        for i in range(len(X))
    ]


def mut_pow(X, n):
    if n == 0:
        return [
            [1, 0, 0],
            [0, 1, 0],
            [0, 0, 1]
        ]
    else:
        Y = mut_pow(X, n // 2)
        return (
            mut_mul(Y, Y) if n % 2 == 0 else
            mut_mul(mut_mul(Y, Y), X)
        )


def f(p, q, k, r):
    Y = mut_pow(
        [
            [ModInt(10**k), ModInt(1), ModInt(0)],
            [ModInt(0), ModInt(1), ModInt(1)],
            [ModInt(0), ModInt(0), ModInt(1)]
        ],
        r
    )
    Z = mut_mul(
        Y,
        [
            [p],
            [q],
            [ModInt(B)]
        ]
    )
    return (Z[0][0], Z[1][0])


ans, _ = reduce(
    lambda acc, kr: f(acc[0], acc[1], kr[0], kr[1]),
    sorted(T.items()),
    (ModInt(0), ModInt(A))
)

print(ans)


Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
int k[9] ={};

int solve(int a,int l){
vector<int> b(l);
for(int i=0;i<l;i++) {
	b[i] = a%10;
	a/=10;
}
sort(b.begin(),b.end());
int res = 0;
for(int i=0;i<l;i++){
	res*= 10;
	res+= b[i];
}
int res2 =0;
for(int i=l-1;i>=0;i--){	
	res2*=10;
	res2+=b[i];
}
	return res2-res;
}


int main(){
	while(1){
		int a,l;
		cin>>a>>l;
		if(a==0&&l==0)break;
		k[0]= 1;
		for(int i=1;i<9;i++)k[i] = k[i-1]*10;
		int ans = 0;
		vector<int> b;
		b.push_back(a);
		bool flag = false;
		int tmp = a;
		for(int i=0;i<20;i++){
			tmp = solve(tmp,l);
			for(int j=0;j<b.size();j++){
				if(tmp==b[j]) {
					cout<<j<<' '<<tmp<<' '<<i-j+1<<endl;
					flag= true;
					break;
				}
			}
			if(flag) break;
			b.push_back(tmp);
			ans++;
		}
	}

	return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

#define fs first

#define sc second

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	map<int, int> mp;
	cin >> N;
	REP(i, N){
		int a;
		cin >> a;
		mp[a]++;
	}

	int res = 0;
	for(auto x : mp){
		if(x.fs < x.sc)
			res += x.sc-x.fs;
		else if(x.fs > x.sc)
			res += x.sc;
	}
	cout << res << endl;
}


Measured memory_bytes: 4736
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	char a, b;
	cin >> a >> b;
	cout << ((a == 'H') == (b == 'H') ? 'H' : 'D') << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define mod 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

mint choose(ll n, ll a) 
{
	mint x = 1, y = 1;
  rep(i, 0, a) {
  	x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

int main()
{
  ll X, Y; cin >> X >> Y;
  ll aa = 2 * X - Y;
  ll bb = 2 * Y - X;
  if (aa % 3 || aa < 0 || bb % 3 || bb < 0) {
  	cout << 0 << endl;
    return 0;
  }
  ll A = aa / 3, B = bb / 3;
  cout << choose(A + B, B) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, const char *argv[]) {
  int n, k;
  cin >> n >> k;

  // 直接結ばれる頂点対(n - 1)個の距離は1になる
  // n(n - 1) / 2 - (n - 1) = (n - 1) * (n - 2) / 2
  if (k > (n - 1) * (n - 2) / 2) {
    cout << -1 << '\n';
    return 0;
  }

  stringstream ss;
  int m = 0;
  for (int i = 1; i < n; ++i) {
    m++;
    ss << 1 << ' ' << i + 1 << '\n';
  }

  int cnt = (n - 1) * (n - 2) / 2 - k;
  for (int i = 1; i < n - 1 && cnt > 0; ++i) {
    for (int j = i + 1; j < n && cnt > 0; ++j, --cnt) {
      ss << i + 1 << ' ' << j + 1 << '\n';
      m++;
    }
  }

  cout << m << '\n';
  cout << ss.str();
}

Measured memory_bytes: 384
N = int(input())
judge = {"AC":0, "WA":0, "TLE":0, "RE":0}

for _ in range(N):
    j_input = input()
    for j in judge.keys():
        if j_input == j:
            judge[j] += 1

for j in judge.keys():
    print(j , end = " x ")
    print(judge[j])

Measured memory_bytes: 9184
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
#define MAXN 100010
#define MAXM 200010
#define MAXK 2000100
#define INF 1000000000
struct edge
{
	int u,v,c;
}e[MAXM];
bool cmp(edge a,edge b)
{
	return a.c<b.c;
}
int fa[MAXN],n,N,m,u,v,c,im[MAXN];
vector<int>A;
int Find(int x)
{
	return fa[x]==x?x:fa[x]=Find(fa[x]);
}
void Union(int x,int y)
{
	x=Find(x),y=Find(y);
	fa[x]=y;
}
int Adj[MAXK],V[MAXK],nxt[MAXK],p;
void AddEdge(int u,int v)
{
	p++;V[p]=v;nxt[p]=Adj[u];
	Adj[u]=p;
}
int dis[MAXK];
bool vis[MAXK];
void SPFA()
{
	for(int i=1;i<=N;i++)
		dis[i]=INF;
	queue<int>Q;
	Q.push(1);
	dis[1]=0;
	vis[1]=1;
	while(!Q.empty())
	{
		int u=Q.front();Q.pop();
		vis[u]=0;
		for(int i=Adj[u];i;i=nxt[i])
			if(dis[V[i]]>dis[u]+1)
			{
				dis[V[i]]=dis[u]+1;
				if(!vis[V[i]])
				{
					vis[V[i]]=1;
					Q.push(V[i]);
				}
			}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	N=n;
	for(int i=0;i<m;i++)
		scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].c);
	sort(e,e+m,cmp);
	for(int i=1;i<=n;i++)
		fa[i]=i;
	int ls=0,lc=e[0].c;
	for(int i=0;i<=m;i++)
		if(e[i].c!=lc)
		{
			for(int j=ls;j<i;j++)
				Union(e[j].u,e[j].v);
			for(int j=ls;j<i;j++)
			{
				int y=Find(e[j].v);
				if(!im[y])
					im[y]=++N,A.push_back(y);
				AddEdge(e[j].u,im[y]);
				AddEdge(im[y],e[j].u);
				AddEdge(e[j].v,im[y]);
				AddEdge(im[y],e[j].v);
			}
			for(int j=ls;j<i;j++)
				fa[e[j].v]=e[j].v,fa[e[j].u]=e[j].u;
			for(int j=0;j<A.size();j++)
				im[A[j]]=0;
			A.clear();
			ls=i,lc=e[i].c;
		}
	SPFA();
	if(dis[n]==INF) printf("-1\n");
	else printf("%d\n",dis[n]/2);
}

Measured memory_bytes: 21120