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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;


int main() {

  string S;
  cin >> S;
  ll ans = 0;
  int prev = 0;
  vector<int> num(S.length()+1, 0);
  int j=0;
  for(int i = S.length()-1; i>=0; i--){
    num[j] += S[i] - '0';
    j++;
  }
  REP(i, S.length()+1){
    if(num[i] <= 5){
      ans += num[i];
      prev = 0;
      if(num[i] == 5 && num[i+1]>= 5) num[i+1]++;
    }else{
      ans += 10 - num[i];
      num[i+1]++;
      prev = 1;
    }
  }

  cout << ans << endl;

    
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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

bool checkprime(int a) {
  if (a == 2)
  return true;

  if (a < 2)
  return false;

  if (a % 2 == 0)
  return false;

  int i = 3;
  while (i <= sqrt(a)) {
    if (a % i == 0)
    return false;
    i += 2;
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (checkprime(a)) {
      cnt++;
    }
  }
  cout << cnt << endl;
}



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

string to_string(string s) { return '"' + s + '"'; }
string to_string(char c) { string s = "'"; s += c; return s + "'"; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } 
template <typename A>
string to_string(A v) {
    bool first = true; 
    string res = "{";
    for (const auto &x : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}"; 
    return res;
}
istream_iterator<string> eos;
void dbg_out(istream_iterator<string> it) { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(istream_iterator<string> it, Head H, Tail... T) {
    cerr << *it << " = " << to_string(H);
    if(++it != eos) cerr << ", ";
    dbg_out(it, T...);
}
#ifdef LOCAL
    #define dbg(...) { string _s = #__VA_ARGS__; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); dbg_out(_it, __VA_ARGS__); }
#else
    #define dbg(...)
#endif

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define sz(v) ((int)(v).size())
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

const int inf = (1LL << 60), mod = 998244353, nn = 3003;
int n, s;
int a[nn];
int dp[nn][nn];

// dp[i][j] -> fixing R = i, no. of left position that can be taken to get sum j

void solve(){
    cin >> n >> s;
    for(int i = 1; i <= n; ++i) cin >> a[i];

    for(int i = 1; i <= n; i++) {
        dp[i][a[i]] = i;

        for(int j = 0; j <= s; j++) {
            dp[i][j] = (dp[i][j] + dp[i-1][j]) % mod;
            if(j >= a[i]) dp[i][j] = (dp[i][j] + dp[i-1][j-a[i]]) % mod;
        }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++) {
        ans = (ans + dp[i][s]) % mod;   // For each R = i, no. of L so that sum is s 
    }
    cout << ans << '\n';
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <vector>
#include <algorithm>

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

using namespace std;

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

    vector<int> t(N), v(N);

    REP(i, N)
    {
        cin >> t[i];
    }

    REP(i, N)
    {
        cin >> v[i];
    }

    vector<int> ts(N);

    REP(i, N)
    {
        if( i == 0 ) ts[0] = t[i];
        else ts[i] = ts[i-1] + t[i];
    }

    int total_time = ts[N-1];

    vector<double> limit;

    double current_time = 0;
    REP(i, N)
    {
        REP(j, t[i] * 2)
        {
            current_time += 0.5;

            double current_min = min( total_time - current_time, (double)v[i] );

            for( int k = i+1; k < N; k++ )
            {
                current_min = min( ts[k - 1] - current_time + v[k], current_min );
            }

            limit.push_back(current_min);
        }
    }

    double current_velocity = 0;
    double sum = 0;
    REP(i, limit.size())
    {
        if( current_velocity < limit[i] )
        {
            current_velocity += 0.5;
        }
        else if( limit[i] < current_velocity )
        {
            current_velocity -= 0.5;
        }

        sum += current_velocity * 0.5;
    }

    cout << fixed << sum << endl;

    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;
int gcd(int x, int y) {
  if(x%y == 0) return y; 
  else return gcd(y, x%y);
}

vector<int> div(int x) {
  vector<int> res;
  for(int i = 1; i<=x; i++) {
    if(x%i == 0) {
      res.push_back(i);
    }
  }
  sort(res.begin(), res.end());
  reverse(res.begin(), res.end());
  return res;
}
int main() {
  int a, b, k;
  cin >> a >> b >> k;
  k--;
  cout << div(gcd(a, b))[k] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];

    int checkflg = 0, cnt = 0;

    repd(i, 1, N) {
        if (checkflg == 1 && A[i - 1] > A[i]) {
            checkflg = 0;
            cnt++;
        }
        else if (checkflg == 2 && A[i - 1] < A[i]) {
            checkflg = 0;
            cnt++;
        }
        else if (checkflg == 0) {
            if (A[i - 1] > A[i]) checkflg = 2;
            else if (A[i - 1] < A[i]) checkflg = 1;
        }
    }

    cout << cnt + 1 << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  while ( n > 0) {
    if (n % 10 == 7) {
      cout << "Yes" << endl;
      return;
    }
    n /= 10;  
  }
  cout << "No" << endl;
}
  
int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <vector>
#include <string.h>

using namespace std;

const int M = 1026527;

char dict[M][13];

int h1(int key) {
	return key % M;
}

int h2(int key) {
	return 1 + key % (M - 1);
}

int h(int key, int i) {
	return (h1(key) + i * h2(key)) % M;
}

int getChar(char ch) {
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
	else return 0;
}

long long getKey(char str[]) {
	long long sum = 0;
	int p = 1;
	for (int i = 0; i < strlen(str); i++) {
		sum += p * getChar(str[i]);
		p *= 5;
	}
	return sum;
}

int insert(char str[]) {	// 1 插入成功  0 无需插入

	long long key = getKey(str);
	
	int i = 0, index;
	while (true) {
		index = h(key, i);
		if (strcmp(dict[index], str) == 0) {
			return 0;
		}
		else if (dict[index][0] == '\0') {
			strcpy(dict[index], str);
			return 1;
		}
		i++;
	}
	return 0;
}

int find(char str[]) {		// 1成功  0失败

	long long key = getKey(str);

	int i = 0, index;
	while (true) {
		index = h(key, i);
		if (strcmp(dict[index], str) == 0) {	//	equal
			return 1;
		}
		else if (dict[index][0] == '\0') {		// fail
			return 0;
		}
		i++;
	}
	return 0;
}

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

	char cmd[10], str[13];
	
	for (int i = 0; i < M; i++)
	{
		dict[i][0] = '\0';
	}

	for (int i = 0; i < n; i++)
	{
		scanf("%s%s", cmd, str);
		if (cmd[0] == 'i') {
			insert(str);
		}
		else if (cmd[0] == 'f') {
			if (find(str)) {
				cout << "yes" << endl;
			}
			else {
				cout << "no" << endl;
			}
		}

	}


	return 0;
}



Measured memory_bytes: 16188
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd
#define eps 0.0000000000000000001
#define int ll

int d(int n){
    int s=0;
    while(n) s+=n%10,n/=10;
    return s;
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    int n,ans=INF;
    cin >> n;
    for(int i=1;i<n;i++){
        ans=min(ans,d(i)+d(n-i));
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

ll gcd(ll a, ll b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}

int main() {
  int N;
  cin >> N;
  vector<ll> T(N);
  for (int i = 0; i < N; i++) {
    cin >> T[i];
  }
  ll lcm = 1;
  for (int i = 0; i < N; i++) {
    ll g = gcd(lcm, T[i]);
    lcm = lcm / g * T[i];
  }
  cout << lcm << endl;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
    int n;
    cin >> n;
    int a[n];
    bool ok=1;
    rep(i,n){
        cin >> a[i];
        if(a[i]%2==0){
            if(a[i]%3!=0&&a[i]%5!=0){
                ok=0;
            }
        }
    }
    if(ok){
        cout<<"APPROVED"<<endl;
    }else{
        cout<<"DENIED"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    val x = readLine()!!.split(" ").map(String::toInt).sortedBy { it }
    val xd = (0 until m - 1).map { i -> Pair(i, x[i + 1] - x[i]) }
        .sortedByDescending { d -> d.second }
    val result = (n - 1 until m - 1).sumBy { i -> xd[i].second }
    println(result)
}


Measured memory_bytes: 76960
#include <bits/stdc++.h>
 
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
 
using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};
 
const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);
 
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int W;
    cin >> W;
    cout << W * 32 << endl;
    
    return 0;
}
 


Measured memory_bytes: 3032
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,i;
ll a[nmax],b[nmax],nr;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n;i++)cin>>b[i];
	for(i=1;i<=n;i++)if(a[i]<b[i])nr+=(b[i]-a[i]+1)/2,a[i]+=((b[i]-a[i]+1)/2)*2;
	for(i=1;i<=n;i++)
	{
		if(b[i]<a[i] && a[i]-b[i]<=nr)nr-=(a[i]-b[i]),b[i]=a[i];
		else if(b[i]<a[i] && a[i]-b[i]>nr)rc("No");
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int main() {
	int N, X;
	cin >> N >> X;
	vector<int> m(N);
	for (int i = 0;i < N;++i) {
		cin >> m[i];
		X -= m[i];
	}
	sort(m.begin(), m.end());
	cout << N + X / m[0] << endl;
	return 0;
}

Measured memory_bytes: 256
//#define frostbyte02
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define LLFOR(i,a,b) for (ll i=a; i<=b; i++)
#define REP(i,a,b) for (int i=a; i<b; i++)
#define FORD(i,a,b) for (int i=a; i>=b; i--)
#define fi first
#define se second
#define pb push_back
#define fastio {ios_base::sync_with_stdio(false); cin.tie(0);}
#define sqr(x) (x)*(x)
#define sqrmod(x) (((x)%MOD)*((x)%MOD))%MOD

using namespace std;
const int MOD = 1e9+7;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

int main()                                
{
#ifdef frostbyte02
        freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
#endif
        fastio
        int n; cin >> n;
        string s; cin >> s;
        int k; cin >> k;
        FOR(i,0,n-1)
        {
                if (s[i]!=s[k-1]) s[i] = '*';
        }
        cout << s;
        return 0;  
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n, l = MAP()

    m = INF
    ind=0
    s = l*n + sum(list(range(1, n + 1))) - n

    
    for i in range(1, n + 1):
        if m>abs((l+i-1)*2):
            m = min(m, abs((l+i-1)*2))
            ind=i

    print(s - l - ind + 1)

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 5164
n = int(input())
nums = []
for i in range(n):
    nums.append(int(input()))

maxv = nums[1] - nums[0]
minv = nums[0]
for j in range(1, n):
    maxv = max(maxv, nums[j]-minv)
    minv = min(minv, nums[j])

print(maxv)


Measured memory_bytes: 13588
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int r, c, num, sum_c;
	scanf("%d %d", &r, &c);

	int sum_r[1000] = {0};
	for (int i = 0; i < r; i++) {
		sum_c = 0;
		for (int j = 0; j < c; j++) {
			num = 0;
			scanf("%d", &num);
			printf("%d ", num);
			sum_c += num;
			sum_r[j] += num;
		}
		sum_r[999] += sum_c;
		printf("%d\n", sum_c);
	}
	for (int k = 0; k < c; k++) {
		printf("%d ", sum_r[k]);
	}
	printf("%d\n", sum_r[999]);

	return 0;
}


Measured memory_bytes: 2036
import java.util.Scanner;

public class Main {
	private static final int K = 26;

	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var d = sc.nextInt();
		var c = new int[K];
		var s = new int[d][K];
		for (var i = 0; i < K; i++) {
			c[i] = sc.nextInt();
		}
		for (var i = 0; i < d; i++) {
			for (var j = 0; j < K; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		var t = new int[d];
		for (var i = 0; i < d; i++) {
			t[i] = sc.nextInt();
		}
		var m = sc.nextInt();
		var md = new int[m];
		var mq = new int[m];
		for (var i = 0; i < m; i++) {
			md[i] = sc.nextInt();
			mq[i] = sc.nextInt();
		}
		sc.close();

		for (var i = 0; i < m; i++) {
			var t2 = new int[d];
			System.arraycopy(t, 0, t2, 0, d);
			t2[md[i] - 1] = mq[i];
			System.arraycopy(t2, 0, t, 0, d);
			var sum = score(c, s, t2, d);
			System.out.println(sum);
		}
	}

	private static int score(int[] c, int[][] s, int[] t, int d) {
		var sum = 0;
		var last = new int[K];
		for (var i = 0; i < d; i++) {
			var ti = t[i] - 1;
			sum += s[i][ti];
			last[ti] = i + 1;
			for (var j = 0; j < K; j++) {
				sum -= ((i + 1) - last[j]) * c[j];
			}
		}

		return sum;
	}
}


Measured memory_bytes: 60272
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <numeric>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

long long div_count(long long a) {
  long long count =0;
  while(a % 2 == 0) {
    a = a / 2;
    count ++;
  }
  return count;
}

long long semi_common_multiple(long long n, long long m, long long a[]) {
  long long base = 1;
  long long count = div_count(a[0] / 2);
  for(int i=0;i<n;i++) {
    long long half = a[i]/2;
    if(count != div_count(half))
      return 0;
    base = boost::math::lcm(half, base);
  }

  long long num = m / base; 
  if(num % 2 == 0)
    return num  / 2;
  return (num / 2) + 1;
}


int main() {
  long long n, m;
  cin >> n;
  cin >> m;
  long long a[n];
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  cout << semi_common_multiple(n, m, a);
}


Measured memory_bytes: 1024
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
 
void main() {
	auto data = readln().split();
	auto A = data[0].to!int(), B = data[1].to!int(), C = data[2].to!int();
	writeln(min(B/A, C));
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]) {
    val input = io.Source.stdin.getLines()
    println(solve(input))
  }

  def solve(input: Iterator[String]): AnyVal = {
    val Array(n, x) = input.next().split(" ").map(_.toLong)

    def burgerSize(l: Int): Long =
      (1L << (l + 2)) - 3

    def pattySize(l: Int): Long =
      (1L << (l + 1)) - 1

    def rec(x: Long, l: Int): Long = {
      val burgerL1 = burgerSize(l - 1)
      
      if (l == 0 && x >= 1)
        return 1

      if (l == 0)
        return 0

      if (x <= 1)
        return 0


      if (x <= burgerL1 + 1) {
        rec(x - 1, l - 1)
      } else if (x == burgerL1 + 2) {
        1 + pattySize(l - 1)
      } else {
        1 + pattySize(l - 1) + rec(x - burgerSize(l - 1) - 2, l - 1)
      }
    }

    rec(x, n.toInt)
  }
}

Measured memory_bytes: 27416
from collections import deque
H, W = map(int, input().split())
grid = []
for _ in range(H):
    array = input()
    grid.append(array)
# print(grid)
#もともとの黒いマス目の数をカウント
count = 0
for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            count+=1
# print(count)

dist = [[-1]*W for _ in range(H)]
# print(dist)

dist[0][0] = 0
dy = [0,0,1,-1]
dx = [-1,1,0,0]
que = deque()
que.append([0,0])

while que:
    y,x = que.popleft()
    for i in range(4):
        vy = y + dy[i] 
        vx = x + dx[i] 
        if vy < 0 or H <= vy or vx < 0 or W <= vx:
            continue
        if dist[vy][vx] != -1 or grid[vy][vx] == '#':
            continue
        dist[vy][vx] = dist[y][x] + 1
        que.append([vy,vx])

if dist[-1][-1] == -1:
    print(-1)
else:
    print(H*W-dist[-1][-1]-count-1)

Measured memory_bytes: 42864
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int h,w;
		while(true){
			h=sc.nextInt();
			w=sc.nextInt();
			if(h!=0&&w!=0){
				for(int i=0;i<h;i++){
					for(int j=0;j<w;j++){
						System.out.printf("#");
					}
					System.out.println();
				}
				System.out.println();
			}
			else{
				break;
			}
		}
	}
}


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

int main(){
    int n; cin >> n;
    int cnt=0;
    for(int i=1;i<=n;i+=2){
        int div=0;
        for(int j=1;j<=n;j++){
            if(i % j == 0){div++;}
        }
        if(div == 8){cnt++;}
    }
    cout << cnt << endl;
}

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

s = set()
i = a
while i < b and i < a + k:
    s.add(i)
    i += 1

i = b
while i >= a and i > b - k:
    s.add(i)
    i -= 1

for x in sorted(s):
    print(x)



Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
const long double zero = 0;
int main() {
	long double A, V, B, W, T; cin >> A >> V >> B >> W >> T;
	if (V == W) {
		cout << "NO" << endl;
	}
	else {
		bool check1 = false, check2 = false;
		long double pos = (B - A) / (V - W), pos1 = (A - B) / (V + W);
		if (zero < pos && pos <= T) check1 = true;
		else if (zero < pos1 && pos1 <= T) check1 = true;
		pos = (A - B) / (V - W), pos1 = (B - A) / (V + W);
		if (zero < pos && pos <= T) check2 = true;
		else if (zero < pos1 && pos1 <= T) check2 = true;
		if (check1 && check2) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}


Measured memory_bytes: 3788
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
	int i, ans=0;
	char W[11], T[1001];
	
	scanf("%s",W);
	while(1) {
		scanf("%s",T);
		if(strcmp(T,"END_OF_TEXT") == 0) break;
		for (i=0; i<strlen(T); i++) {
			T[i] = tolower(T[i]);
		}
		if(strcmp(W,T) == 0) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 552
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath> // sqrt
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif


int main(void) {
    string str;
    cin >> str;

    int len = str.length();
    int64_t sum = 0;
    for(int pat = 0; pat < (1<<(len-1)); pat++) {
        int64_t res = 0;
        int64_t cur = str[0]-'0';
        for(int bit = 0; bit < len-1; bit++) {
            char next = str[bit+1]-'0';
            if(pat & (1<<bit)) {
                res += cur;
                cur = next;
            } else {
                cur = cur * 10 + next;
            }
        }
        res += cur;
        debug("%d -> %ld\n", pat, res);
        sum += res;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int s, w; cin >> s >> w;
    if (w>=s) puts("unsafe");
    else puts("safe");
}

Measured memory_bytes: 3696
import java.util.Arrays;
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int[] str = new int[10];
		
		for(int i=0; i<10; i++){
			str[i] = scan.nextInt();
		}
		Arrays.sort(str);
		for(int j=9; j>6; j--){
			System.out.println(str[j]);
		}
	}
} 

Measured memory_bytes: 17232
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
#include <chrono>
#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

vector<pair<int,int> > order;

const int N = 2e5;
int a[N + 5];
int res[N + 5];

void hora(int tc) {
	int n, k;
	cin>>n>>k;
	for(int i = 1;i <= n;i++) cin>>a[i];
	k = min(k, 50);
	while(k--) {
		order.clear();
		for(int i = 1;i <= n;i++) {
			order.pb({i - a[i], 1});
			order.pb({i + a[i] + 1, -1});
		}
		sort(order.begin(), order.end());
		int tot = 0;
		int l = 0;
		for(int i = 1;i <= n;i++) {
			while(l != order.size() && order[l].F <= i) {
				tot += order[l].S;
				l++;
			}
			res[i] = tot;
		}
		for(int i = 1;i <= n;i++) a[i] = res[i];
	}
	for(int i = 1;i <= n;i++) {
		if(i != 1) cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 8192
l=[list(map(int,input().split()))for i in range(3)]
from itertools import permutations as pe
for i in pe(l,r=None):
    #rは長さ、Noneでiteraterの長さ
    for j in range(2):
        now=i[0][j]
        seen=set([now])
        for a,b in i:

            if b!=now and now!=a:break
            now=b+a-now
            seen.add(now)
        else:
            if len(seen)==4:print('YES');exit()

print("NO")


Measured memory_bytes: 9188
n = int(input())

def eratosthenes(n):
    res = []
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    for i in range(n+1):
        if is_prime[i]:
            res.append(i)
    return res

prime = eratosthenes(55555)

ans = []
for p in prime:
    if p % 5 == 1:
        ans.append(p)
print(*ans[:n])

Measured memory_bytes: 40048
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long x,a=2,b=1,ans=0;
    cin>>x;
    if (x>1){
    for (long long k=2; k<=x; k++){
        if (k%2==0){
            ans=a+b;
            a=ans;
        }
        if (k%2!=0){
            ans=a+b;
            b=ans;
        }
        
    }
    cout<<ans;
    }
    if (x==1){
        cout<<"1";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N;
    cin >> N;
    string tmp;
    int cnt = 0;
    int acnt = 0;
    int bcnt = 0; 
    int check = 1;
    for (int i = 0; i < N; i++){
        cin >> tmp;
        if(tmp.at(0) == 'B') bcnt++;
        if(tmp.at(tmp.size() - 1) == 'A') acnt++;
        if((tmp.at(0) == 'B') || (tmp.at(tmp.size() - 1) == 'A') ) {
            if( !(tmp.at(0) == 'B') || !(tmp.at(tmp.size() - 1) == 'A') ){
                check = 0;
            }
        }
        for (int j = 0; j < tmp.size() - 1 ; j++)
        {
            if(tmp.at(j) == 'A' && tmp.at(j+1) == 'B'){
                cnt++;
            }
        }
    }
    if(acnt == 0 || bcnt == 0) check = 0;
    printf("%d\n", cnt + min(acnt,bcnt) - check);

    
}


Measured memory_bytes: 256
import java.util.Scanner;
	public class Main {
	 public static void main(String[] args) {
	 Scanner sc = new Scanner(System.in);
	 int a = sc.nextInt();
	 int b = sc.nextInt();
	 if(a<=9 && b<=9){
	 System.out.println(a*b);
	 }else{
	 System.out.println(-1);
	 }
	 }
	}

Measured memory_bytes: 22740
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 x = 1;
		int ans = 0;
		while (N >= x) {
			x*= K;
			ans++;
		}
		if (ans == 0) ans = 1;
		if (K == 10) ans = String.valueOf(N).length();
		System.out.println(ans);
	}
}

Measured memory_bytes: 23124
from collections import deque

h, w = map(int, input().split())
maze = [[0 if c == '#' else 1 for c in input()] for _ in range(h)]

ans = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == 0:
            continue
        costs = [[-1 for _ in range(w)] for _ in range(h)]
        costs[i][j] = 0
        q = deque([(i, j)])
        while q:
            y, x = q.popleft()
            for dx, dy in [(-1, 0), (0, 1), (1, 0), (0, -1)]:
                nx, ny = x + dx, y + dy
                if (0 <= nx < w) and (0 <= ny < h) and maze[ny][nx] and costs[ny][nx] == -1:
                    costs[ny][nx] = costs[y][x] + 1
                    q.append((ny, nx))
        for row in costs:
            ans = max(ans, max(row))

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <stack>
#include <cmath>
#include <functional>
#include <set>
#include <string>
#include <stdlib.h>
#include <utility>
 
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i = a;i<=b;i++)
#define ll long long int
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define iii pair<ii,int >
#define ff first
#define ss second
#define vi vector<int>
 
using namespace std;


int main(){
	int n;
	cin >> n;
	int arr[n];
	FOR(i,n)cin >> arr[i];
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	FORE(i,2,n-1){
		dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]) , dp[i-2] + abs(arr[i] - arr[i-2]));
	}
	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
unsigned gcd(unsigned a, unsigned b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}
int main(void){
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    ll m=0,g;
    rep(0,i,n){
        cin>>a[i];
        m=max(m,a[i]);
        if(i==0) g=a[i];
        else g=gcd(g,a[i]);
        //cout<<g<<endl;
    }
    ll tmp=m;
    while(tmp>0){
        if(k==tmp){
            cout<<"POSSIBLE";
            return 0;
        }
        tmp-=g;
    }
    cout<<"IMPOSSIBLE";
}

Measured memory_bytes: 1024
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void main(string[] args){ args ~= ["", ""]; string cmd = args[1]; if(cmd == "-debug") DEBUG = 1;
if(cmd == "-gen") gen; else if(cmd == "-jury") jury; else solve; } 
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ std.stdio.write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void gen(){}
void jury(){}
void solve(){
  int n = scan!int;
  int ans;
  foreach(a; 1 .. n + 1){
    ans += (n - 1) / a;
  }
  ans.print;
}

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define t_case ll test;cin>>test;while(test--)
#define left(nod) 2*nod
#define right(nod) 2*nod+1
#define ss second
#define ff first
#define pb push_back
#define pll pair<ll,ll>
#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define deb(a) cout<<#a<<": "<<a;cout<<endl;
#define deba(a) cout<<#a<<": ";for(auto it:a)cout<<it<<" ";cout<<endl;


int main()
{
	FAST;
	ll n,d;cin>>n>>d;
	ll cnt=0;
	
	for(ll i=1;i<=n;i++)
	{
		ll x,y;cin>>x>>y;
		if(sqrt((double)x*x + y*y)<=(double)d)cnt++;
	}
	cout<<cnt;
	
}


Measured memory_bytes: 3688
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		int holiday = scanner.nextInt();
		
		int homework = scanner.nextInt();
		
		List<Integer> list = new ArrayList<>();
		
		for (int i = 0; i < homework; i++) {
			
			list.add(scanner.nextInt());
		}
		
		scanner.close();
		
		int result = holiday - list.stream().mapToInt(x -> x).sum();
		
		if (result < 0) {
			System.out.println(-1);
		} else {
			System.out.println(result);
		}
		
	}

}


Measured memory_bytes: 42740
#include<stdio.h>
#include<math.h>
 
int RightTriangle(int a,int b,int c)
{
 if(pow(a,2)+pow(b,2) == pow(c,2))
 {
  return 1;
 }
 else return 0;
}
 
int main(void)
{
 int a,b,c;
 int i;
 int N;
 
 scanf("%d",&N);
 for(i = 0; i < N; i++)
 {
  scanf("%d %d %d",&a,&b,&c);
  if(RightTriangle(a,b,c)||RightTriangle(a,c,b)||RightTriangle(c,b,a))
  {
    printf("YES\n");
  }else printf("NO\n");
 }
 return 0;
}

Measured memory_bytes: 0
// O.cpp
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 22, mod = 1e9 + 7;

int n, dp[1 << MAX_N], tmp;
bool mapping[MAX_N][MAX_N];

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            scanf("%d", &tmp), mapping[i][j] = (tmp == 1);
    dp[0] = 1;
    for (int i = 1; i < (1 << n); i++)
    {
        int counter = 0;
        for (int j = 0; j < n; j++)
            if ((i >> j) & 1)
                counter++;
        for (int j = 0; j < n; j++)
            if (((i >> j) & 1) && mapping[counter][j + 1])
                dp[i] = (dp[i] + dp[i ^ (1 << j)]) % mod;
    }
    printf("%d", dp[(1 << n) - 1]);
    return 0;
}

Measured memory_bytes: 10496
#include <iostream>

using namespace std;

static const int MAX = 100;

int main() {
	int A[MAX], n, v, j;

	cin >> n;

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

	for (int k = 0; k < n; k++) {
		if (k > 0)
			cout << " ";
		cout << A[k];
	}
	cout << endl;

	for (int i = 1; i < n; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;

		for (int k = 0; k < n; k++) {
			if (k > 0)
				cout << " ";
			cout << A[k];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
long long n,k;
cin>>n>>k;
vector<int> a;
long long ans1=0;
long long  ans2=0;
for(int i=1;i<=n;i++){

  if(i%k == 0) ans1++;
  else if(k%2==0 && i%k==(k/2)) ans2++;
}
long long ans=pow(ans1,3)+pow(ans2,3);
cout<<ans<<endl;
}


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

int main()
{
    cin>>n;
    string s;cin>>s;
    ll ans=0;
    ans=(n*(n-1)*(n-2))/6;
    map<int,int> mpr,mpb,mpg;
    //int n=s.size();
    mpr[n-1]=mpb[n-1]=mpg[n-1]=0;
    if(s[n-1]=='R') mpr[n-1]++;
    else if(s[n-1]=='B') mpb[n-1]++;
    else mpg[n-1]++;

    for(int i=s.size()-2;i>-1;i--)
    {
      if(s[i]=='R') mpr[i]++;
      else if(s[i]=='B') mpb[i]++;
      else mpg[i]++;
      mpr[i]+=mpr[i+1];
      mpb[i]+=mpb[i+1];
      mpg[i]+=mpg[i+1];
    }

    

    for(int i=0;i<s.size()-2;i++)
    {
      for(int j=i+1;j<s.size()-1;j++)
      {
        if(s[i]==s[j]) ans-=n-j-1;
        else
        {
          map<char,bool> seen;
          seen[s[i]]=seen[s[j]]=true;
          if(seen['R'])
          {
            ans-=mpr[j+1];
          }
          if(seen['B'])
          {
            ans-=mpb[j+1];
          }
          if(seen['G'])
          {
            ans-=mpg[j+1];
          }
          if(j+j-i <s.size() && s[j+j-i]!=s[j] && s[j+j-i]!=s[i]) 
            {
            //cout<<" reduce "<<i<<' '<<j<<' '<<j+j-i<<endl;             
              ans--;
            }
        }
        //cout<<" at "<<i<<' '<<j<<" ans= "<<ans<<endl;
      }
    }
    cout<<ans;
}

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

//譯∵焚
int cnt_digits(ll N){
  int digits=0;
  while(N>0){
    N/=10;
    digits++;
  }
  return digits;
}

int main(void){
  ll N;
  cin >> N;
  
  // 1*N=N max(cnt_digits(1),cnt_digits(N))=cnt_digits(N)
  int ans=cnt_digits(N);
  
  for(ll A=1LL;A*A<=N;++A){
    if(N%A!=0) continue;
    const ll B=N/A;
    
    const int cur=max(cnt_digits(A),cnt_digits(B));
    
    if(ans>cur){
      ans=cur;
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3 4 6
0 0
0 2
0 3
1 1
2 1
2 3

output:
3
"""

import sys


def generate_adj_table(_edges):
    for edge in _edges:
        vx, vy = map(int, edge)
        init_adj_table[vx].append(vy)

    return init_adj_table


def graph_dfs(current, matching, visited):
    for adj in range(y_num):
        if adj in adj_table[current] and not visited[adj]:
            visited[adj] = True
            if matching[adj] == -1 or graph_dfs(matching[adj], matching, visited):
                matching[adj] = current
                return True
    return False


def mbm():
    matching = [-1] * y_num
    res = 0
    for v in range(x_num):
        visited = [False] * y_num
        if graph_dfs(v, matching, visited):
            res += 1
    # print(matching)
    return res


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    x_num, y_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    # v_num = x_num + y_num
    init_adj_table = [[] for _ in range(x_num)]
    adj_table = generate_adj_table(edges)
    print(mbm())

Measured memory_bytes: 8524
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
using namespace std;
int n,k;
char in[M];
int main()
{
    while (~scanf("%d %d", &n, &k)) {
        scanf("%s", in+1);

        int ans = n-1;
        REP(i,2,n) if(in[i] != in[i-1]) ans--;
        ans = min(n-1, ans+k*2);
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;

void solve()
{
	string str;
	int count = 0;
	while(cin >> str)
	{
		bool flag = true;
		int n = str.size();
		for(int i = 0; i < n; ++i)
		{
			if(str[i] != str[n - i - 1])
			{
				flag = false;
				break;
			}
		}
		if(flag)
		{
			++count;
		}
	}
	cout << count << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	
	int n;
	cin >> n;
	vector<string> s;
	string t;
	for(int i=0;i<n;i++){
		cin >> t;
		s.push_back(t);
	}
	sort(s.begin(), s.end());
	s.erase(unique(s.begin(), s.end()),s.end());
	cout << s.size() << endl;

	return 0;
}

Measured memory_bytes: 11664
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int x; cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
 
    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
        int N; cin >> N;
        vector<Pi> X(N + 1);
        vint ans(N * N + 1, -1);

        for (int i = 1; i <= N; i++) {
                cin >> X[i].first;
                X[i].second = i;
                ans[X[i].first] = i;
        }

        sort(begin(X) + 1, end(X));

        int cnt = 1;
        for (int i = 1; i <= N; i++) {
                int num = X[i].second - 1;
                int c = 0;
                if (num == 0) continue;
                while (cnt <= N * N) {
                        if (cnt == X[i].first) {
                                cout << "No" << endl;
                                return (0);
                        }
                        if (ans[cnt] == -1) {
                                ans[cnt] = X[i].second;
                                c++;
                                if (c == num) break;
                        }
                        cnt++;
                }
        }

        for (int i = 1; i <= N; i++) {
                int num = N - X[i].second;
                int c = 0;
                if (num == 0) continue;
                while (cnt <= N * N && ans[cnt] != -1) cnt++;
                if (cnt < X[i].first) {
                        cout << "No" << endl;
                        return (0);
                }
                while (cnt <= N * N) {
                        if (ans[cnt] == -1) {
                                ans[cnt] = X[i].second;
                                c++;
                                if (c == num) break;
                        }
                        cnt++;
                }
        }

        cout << "Yes" << endl;
        cout << ans[1];
        for (int i = 2; i <= N * N; i++) cout << " " << ans[i];
        cout << endl;
        return (0);
}

Measured memory_bytes: 2176
# https://atcoder.jp/contests/abc082/tasks/arc087_a



N = gets.to_i
as = gets.split.map(&:to_i)

num_counts = as.each_with_object(Hash.new(0)) { |s, hash| hash[s] += 1 }

ans = 0
num_counts.each do |num, count|
  ans += num > count ? count : count - num
end

puts ans


Measured memory_bytes: 14468
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;
    cin >> s;
    for ( int i = 1; i < s.size(); i ++ ) {
        if ( s[i - 1] == 'A' && s[i] == 'C' ) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a, b;

int main() {
	cin >> n;
	if(n == 1) {
		cout << "Hello World" << endl;
	} else {
		cin >> a >> b;
		cout << a + b << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256