akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T>
T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T>
T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

struct UF {
    vector<int> p;
    UF(int n)
        : p(n, -1) {
    }
    int find(int a) {
        return p[a] < 0 ? a : p[a] = find(p[a]);
    }
    bool unite(int a, int b) {
        a = find(a);
        b = find(b);
        if (a == b) return false;
        if (-p[a] < -p[b]) swap(a, b);
        p[a] += p[b];
        p[b] = a;
        return true;
    }
    bool root(int a) {
        return p[a] < 0;
    }
    bool same(int a, int b) {
        return find(a) == find(b);
    }
    int size(int a) {
        return -p[find(a)];
    }
};

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<vector<int>> E(M, vector<int>(2));
    REP(i, M) {
        cin >> E[i][0] >> E[i][1];
    }
    UF tree(N);
    ll cnt = N * (N - 1) / 2;
    vector<ll> res(M);
    RREP(i, M - 1) {
        int A = E[i][0] - 1, B = E[i][1] - 1;
        res[i] = cnt;
        if (tree.same(A, B)) {
            continue;
        }
        ll s1 = tree.size(A), s2 = tree.size(B);
        cnt -= s1 * s2;
        tree.unite(A, B);
    }
    REP(i, M) {
        cout << res[i] << endl;
    }
    return 0;
}


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

int main() {
  int a, b;
  cin >>a>>b;
  int counter=0;
  
  for (int i=a; i<=b; i++) {
    int fir = i/10000;
    int sec = (i-fir*10000)/1000;
    int fif = i%10;
    int fou = (i/10)%10;
    
    if (fir == fif && sec == fou) {
      counter++;
    }
  }
  cout << counter <<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> h(n, 0);
  rep(i, n) {
    cin >> h.at(i);
  }
  vector<int> yoi(n, 0);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    if (h.at(a) >= h.at(b)) {
      yoi[b] =  1;
    }
    if(h.at(b) >= h.at(a)) {
      yoi[a] = 1;
    }
  }
  ll ans = count(yoi.begin(), yoi.end(), 0);
  cout << ans << endl;
  return 0;
}


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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 n; vector<_f64> x, y, dinf;
        _f64 d1 = 0; _f64 d2 = 0; _f64 d3 = 0;
        cin >> n; x.resize(n); y.resize(n); dinf.resize(n);
        _foreach(e, x) { cin >> e; } _foreach(e, y) { cin >> e; }
        _rep(i, n) {
            d1 += abs(x[i] - y[i]);
            d2 += pow(abs(x[i] - y[i]), 2);
            d3 += pow(abs(x[i] - y[i]), 3);
            dinf[i] = abs(x[i] - y[i]);
        }
        d2 = sqrt(d2); d3 = cbrt(d3);
        cout << fixed << setprecision(6);
        cout << d1 << endl << d2 << endl << d3 << endl;
        cout << *max_element(_all(dinf)) << endl;
    }
    return 0;
}


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

/*
素数か〜
X足していって、調べるのかな

ある数字が素数であるかどうかは、その数字までのループで調べちゃう？
*/

bool check_prime(int X) {
    for (int i = 2; i < X; i++) {
        if (X % i == 0) {
            return false;
        }
    }
    return true;
}

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

    while (!check_prime(X)) {
        X++;
    }

    cout << X << endl;

}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x);1
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair	
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

using namespace std;
typedef long long ll;
typedef long double ld;	
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
	 
const ll MAX = 10000000;
const ll inf = 5e18-1;

int main() {
	fastio;
	char c;
	cin>>c;
	c+=1;
	cout<<c<<endl;
	return 0;
	}

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

int main(){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int xl=x2-x1,yl=y2-y1;
    cout<<x2-yl<<' '<<y2+xl<<' '<<x1-yl<<' '<<y1+xl<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include<iostream>
#include <math.h>
using namespace std;

int a, b, c;

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

  deque<int> nums;
  nums.push_back( a );
  nums.push_back( b );
  nums.push_back( c );

  sort( nums.begin(), nums.end() );

  deque<int>::iterator it = nums.begin();
  while( it != nums.end() )
    {
      cout << *it;
      ++it;
      if (it != nums.end()) {
        cout << " ";
      }
    }

  cout << endl;

  return 0;
}

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

const double pi=acos(-1);
typedef long long ll;
const int maxn=1e4+10;
int  f[300050],vis[200050];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s,t,u;
    int a,b;
    cin >> s >>t >> a >> b >> u;
    if(s==u)
        a--;
    else 
        b--;
    cout << a << " " << b;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	char c;
	int count[26]={0};
	int i;
    while(scanf("%c",&c) != EOF){
    	if(c >= 'A' && c <= 'Z')
    		c += 'a'-'A'; //32
    	if(c >= 'a' && c <= 'z')
    		count[c-'a']++;
    }
    for(i=0; i<26; i++){
    	printf("%c : %d\n", i+'a', count[i]);
    }

	return 0;
}

Measured memory_bytes: 540
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        long x = nl();
        long y = nl();
        long ans = 0;
        while(x<=y){
            x *= 2;
            ans++;
        }
        out.println(ans);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);
    int upperBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new UpperBoundComparator<Long>());
        return ~i;
    }
    class UpperBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) > 0) ? 1 : -1;
        }
    }
    int lowerBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new LowerBoundComparator<Long>());
        return ~i;
    }
    class LowerBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) >= 0) ? 1 : -1;
        }
    }
    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

#define fi first
#define se second
#define pb push_back
#define v(T) vector<T>
#define vv(T) v(v(T))
#define sz(x) x.size()

#define times(i,n) for(int i = 0; i < n; ++i)
#define rep(i,l,r) for(auto i = l; i < r; ++i)
#define upto(i,l,r) for(auto i = l; i <= r; ++i)
#define downto(i,l,r) for(auto i = l; i >= r; --i)
#define step(i,l,r,s) for(auto i = l; i <= r; i += s)

typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef v(int) vi;
typedef vv(int) vvi;
typedef v(ll) vl;
typedef v(P) vp;
typedef v(T) vt;

template<typename T>istream& operator>>(istream& i, v(T)& v)
    {times(j, sz(v)) i >> v[j]; return i;}
template<typename T>string join(const v(T)& v, const char sep = ' ')
    {stringstream s; times(i, sz(v)) s << sep << v[i]; return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream& o, const v(T)& v)
    {if(sz(v))o << join(v); return o;}

#include <atcoder/all>
using namespace atcoder;

using S = int;
const int MAX = 300'000;

S op(S s1, S s2) {return max(s1, s2);}
S e() {return 0;}

int main() {
    int n, k;
    cin >> n >> k;
    segtree<S, op, e> seg(MAX + 1);

    times(i, n) {
        int a, l, r;
        cin >> a;
        l = max(0, a - k);
        r = min(MAX, a + k) + 1;

        seg.set(a, seg.prod(l, r) + 1);
    }

    cout << seg.all_prod() << endl;
}


Measured memory_bytes: 8524
import math

length = int(input())
array = str(input()).split(" ")
for index in range(len(array)):
    array[index] = int(array[index])
narray = []
narray.append(array[0])
for index in range(1, len(array)):
    narray.append(min(array[index-1],array[index]))
narray.append(array[-1])
sum = 0
for element in narray:
    sum += element
print(sum)


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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()

int main(){
    ll n, k;
    cin >> n >> k;
    vector<pii> a(n);
    for(int i=0; i<n; ++i){
        cin >> a[i].first >> a[i].second;
    }
    sort(all(a));

    ll ans=a[0].first, z=0;
    for(int i=0; i<n; ++i){
        z+=a[i].second;

        if(z < k)
            continue;
        else{
            ans = a[i].first;
            break;
        }
    }
    cout << ans;
}


Measured memory_bytes: 4028
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int N;
    char F[5][5][5];
    int[] A, B;
    bool input() {
        scanf("%d\n", &N);
        if (N == 0) return false;
        foreach (z; 0 .. 5) {
            foreach (y; 0 .. 5) {
                foreach (x; 0 .. 5) {
                    scanf("%[01]", &F[z][y][x]);
                }
                scanf("%*[ \n]");
            }
        }
        int M;
        scanf("%d", &M);
        A = new int[M];
        foreach (i; 0 .. M) {
            scanf("%d", &A[i]);
        }
        scanf("%d", &M);
        B = new int[M];
        foreach (i; 0 .. M) {
            scanf("%d", &B[i]);
        }
        return true;
    }

    void step() {
        char nF[5][5][5];
        for (int z = 0; z < 5; z++) {
            for (int y = 0; y < 5; y++) {
                for (int x = 0; x < 5; x++) {
                    int C = 0;
                    for (int dz = -1; dz <= 1; dz++) {
                        for (int dy = -1; dy <= 1; dy++) {
                            for (int dx = -1; dx <= 1; dx++) {
                                if (dz == 0 && dy == 0 && dx == 0) continue;
                                if (0 <= z + dz && z + dz < 5 &&
                                    0 <= y + dy && y + dy < 5 &&
                                    0 <= x + dx && x + dx < 5 &&
                                    F[z + dz][y + dy][x + dx] == '1') {
                                    C++;
                                }
                            }
                        }
                    }
                    if ((F[z][y][x] == '0' ? A : B).count(C)) {
                        nF[z][y][x] = '1';
                    } else {
                        nF[z][y][x] = '0';
                    }
                }
            }
        }
        foreach (i; 0 .. 5) foreach (j; 0 .. 5) foreach (k; 0 .. 5)
            F[i][j][k] = nF[i][j][k];
    }

    void solve() {
        for (int i = 0; i < N; i++) {
            step;
        }
        foreach (i; 0 .. 5) {
            writeln(F[0][i]);
        }
        foreach (i; 1 .. 5) {
            writeln;
            foreach (j; 0 .. 5) {
                writeln(F[i][j]);
            }
        }
    }

    int T = 1;
    while (input) {
        if (T != 1) writeln;
        write("Case ", T, ":\n");
        solve;
        T++;
    }
}

Measured memory_bytes: 1072
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

s = input().split(',')
print(' '.join(s))

Measured memory_bytes: 9844
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<P, int> PP;
int main(){
	ll p[100001];
	p[0] = 1;
	for (ll i = 1; i < 100001; i++) {
		p[i] = p[i - 1] * i%MOD;
	}
	int n, m; cin >> n >> m;
	if (n == m) {
		cout << (ll)2 * p[n] * p[m] % MOD << endl;
	}
	else if (abs(n - m) <= 1) {
		cout << p[n] * p[m] % MOD << endl;
	}
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

vector<int> to[100010];
vector<bool> und(1000010,0);
int now;

void dfs(int x){
    //cout<<"dfs"<<endl;
    //cout<< x <<endl;
    for(auto u : to[x]){
        if(und[u]==0){
            now++;
            und[u]=1;
            dfs(u);
        }
    }
}
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(n),y(n),z(n);
    rep(i,m){
        int x;
        int y;
        int dumy;
        cin >> x >> y>>dumy;
        x--;y--;
        to[x].push_back(y);
        to[y].push_back(x);
    }
    int ans = 0;
    while(now<n){
        rep(i,n){
            if(und[i]==0){
                ans++;
                und[i]=1;
                dfs(i);
            }
        }
        bool ok = 1;
        rep(i,n){
            if(und[i]==0) ok = 0;
        }
        if(ok) break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 10112
#include<bits/stdc++.h>
using namespace std;
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
int main(){
  string s,y;cin>>s>>y;
  vsort(s);vrsort(y);
  cout<<((s<y)?"Yes":"No")<<endl;
}

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

int main() {
  int N, check_Y;
  string color;
  cin >> N;
  check_Y = 0;
  for(int i =0; i < N ;i++){
    cin >> color;
    if(color == "Y"){
      check_Y = 1;
      break;
    }
  }
  if(check_Y){
    cout << "Four" <<endl;
  }
  else{
    cout << "Three" <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
inline void IN(ut &x){cin >> x;}
inline void INA(ut n,ut x[]){REP(i,n) cin >> x[i];}
inline void INE(ut m,VI edges[]){
	ut a,b;
	REP(i,m){
		cin >> a >> b;
		edges[a].PB(b);
		edges[b].PB(a);
	}
}
inline void INEC(ut m,Vpr edges[]){
	ut a,b,c;
	REP(i,m){
		cin >> a >> b >> c;
		edges[a].PB(pr(c,b));
		edges[b].PB(pr(c,a));
	}
}
const int SIZE=5+2*1e3;
const int INF=10+1e9;
const LL p=7+1e9;
ut N,A[SIZE][SIZE];
bool isBlack[SIZE];
int hasBlack[SIZE];
bool hasBC[SIZE];
bool isT[SIZE];
int hasBlackC[SIZE];
int main(){
	cin >> N;
	bool isBlack=false;
	REP(i,N) {
		string s;
		cin >> s;
		REP(j,N){
			A[i][j]=s[j]=='#';
			isBlack|=A[i][j];
			hasBlack[i]+=A[i][j];
			hasBC[j]|=A[i][j];
			hasBlackC[j]+=A[i][j];
			if(i==j) isT[i]=A[i][j];
		} 
	}
	int ans=INF;
	REP(i,N){
		if(isT[i]){
			ans=min(ans,N*2-hasBlack[i]);
		}
		else if(hasBC[i]) ans=min(ans,N*2-hasBlack[i]);
		else ans=min(ans,N*2-hasBlack[i]+1);
	}
	REP(i,N) 
		if(hasBlackC[i]==N) ans--;
	if(!isBlack){
		cout << -1 << endl;
		return 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

ll get_ten_num(ll val) {
    ll cnt = 0;
    while(val > 0LL) {
        val /= 10LL;
        cnt++;
    }
    return cnt;
}
int main() {
    ll N;
    cin >> N;
    ll cnt = INF;
    for(ll i = 1; i * i <= N; i++) {
        if(N % i == 0LL) {
            ll B = N / i;
            cnt = min(cnt, max(get_ten_num(i), get_ten_num(B)));
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
s=list(input().split())
w=int(s[0])
h=int(s[1])
for i in range(h):
    if(i==0 or i==h-1):
        print("+"+"-"*(w-2)+"+")
        continue
    if(i==(h-1)//2):
        print("|"+"."*((w-2)//2)+s[2]+"."*((w-2)//2)+"|")
        continue
    print("|"+"."*(w-2)+"|")


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T x=0,f=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	int n,m;
	int main(){
		n=read<int>(),m=read<int>();
		printf("%d\n",n*(n-1)/2+m*(m-1)/2);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define MAX 1000000000000000000
int main() {
	//freopen("input.txt", "r", stdin);
	int a[5];
	int temp = 0;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
		if (a[i] == 0)
			temp = i + 1;
	}
	cout << temp;
	return 0;
}

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

ll N, Z, W;
vector<ll> a(2001, 0);

int main(void){
    
    cin >> N >> Z >> W;
    for(int i = 0; i < N; ++i) cin >> a[i];
    
    if(N == 1) cout << abs(a[0] - W) << endl;
    else cout << max(abs(a[N - 1] - W), abs(a[N - 1] - a[N - 2])) << endl;
    
    return 0;
}

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

namespace Exa2019A
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            long[] abc = Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
            if (abc[0] != abc[1] | abc[0] != abc[2])
            {
                Console.WriteLine("No");
                return;
            }
            Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 13268
from collections import deque

k = int(input())
q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

if k <= 9:
    print(q[k-1])
    exit()

i = 9
while 1:
    a = q.popleft()
    b = a % 10
    if b == 0:
        q.append(a * 10)
        i += 1
        if i == k:
            print(q[-1])
            exit()
        q.append(a * 10 + b + 1)
        i += 1
        if i == k:
            print(q[-1])
            exit()
    elif b == 9:
        q.append(a * 10 + b - 1)
        i += 1
        if i == k:
            print(q[-1])
            exit()
        q.append(a * 10 + b)
        i += 1
        if i == k:
            print(q[-1])
            exit()
    else:
        q.append(a * 10 + b - 1)
        i += 1
        if i == k:
            print(q[-1])
            exit()
        q.append(a * 10 + b)
        i += 1
        if i == k:
            print(q[-1])
            exit()
        q.append(a * 10 + b + 1)
        i += 1
        if i == k:
            print(q[-1])
            exit()

Measured memory_bytes: 12252
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vi cnt(9);
  rep(i,n){
    int a; cin >> a;
    cnt[min(a/400,8)]++;
  }
  int mn = 0;
  rep(i,8) if(cnt[i]) mn++;
  cout << max(1,mn) << " ";
  cout << mn+cnt[8];
  cout << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int N; cin >> N;
  int M; cin >> M;
  int A[M]; FOR(i,0,M) cin >> A[i], A[i]--;
  int B[M][N]; FOR(i,0,M) FOR(j,0,N) cin >> B[i][j], B[i][j]--;
  int p[N]; FOR(i,0,N) p[i] = 0;
  FOR(i,0,M) {
    int miss = 0;
    FOR(j,0,N) {
      if(A[i] == B[i][j]) p[j]++;
      else miss++;
    }
    p[A[i]] += miss;
  }
  FOR(i,0,N) cout << p[i] << endl;
  return 0;
}

Measured memory_bytes: 3120
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();

        if(N%K==0){
            System.out.println(0);
        }
        else{
            System.out.println(1);
        }
    }
}

Measured memory_bytes: 21844
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
    boost;
    char a;
    cin>>a;
    cout<<(char)(a+1)<<"\n";
    return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    string s,t;
    int count=0,a;
    cin >> s;
    a = s.size()/2;
    t = s;
    reverse(t.begin(),t.end());
    for(int i=0;i<a;i++){
        if(s[i] != t[i]) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define MN 110000
#define int long long
using namespace std;

int read_p,read_ca;
inline int read(){
    read_p=0;read_ca=getchar();
    while(read_ca<'0'||read_ca>'9') read_ca=getchar();
    while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
    return read_p;
}
int n,m,X,K,T[MN],la=0,Q,t,a,l[MN],r[MN],L[MN],R[MN];
signed main(){
    X=read();
    K=read();
    l[0]=0;L[0]=0;r[0]=X;R[0]=X;
    for (int i=1;i<=K;i++){
        a=read();
        T[i]=a;
        l[i]=l[i-1];r[i]=r[i-1];
        L[i]=L[i-1]-(a-la);
        R[i]=R[i-1]-(a-la);
        if (L[i]<=R[i])
        if (R[i]<=0){
            l[i]=0;L[i]=X;r[i]=0;R[i]=X;
        }else{
            if (L[i]<0)
            l[i]-=L[i],
            L[i]=0;
            
            L[i]=X-L[i];R[i]=X-R[i];
        }else
        if (L[i]<=0){
            l[i]=0;L[i]=X;r[i]=0;R[i]=X;
        }else{
            if (R[i]<0)
            r[i]+=R[i],
            R[i]=0;
            
            L[i]=X-L[i];R[i]=X-R[i];
        }
        la=a;
    }
    
    /*for (int i=0;i<=K;i++)
    printf("%d %d %d %d %d\n",i,l[i],r[i],L[i],R[i]);*/
    Q=read();
    for (int i=1;i<=Q;i++){
        t=read();a=read();
        int _l=0,_r=K,mid;
        while (_l<_r){
            if (T[mid=_l+_r+1>>1]<=t) _l=mid;else _r=mid-1;
        }
        t-=T[_l];
        if (a<=l[_l]) a=L[_l];else if (a>=r[_l]) a=R[_l];else if (L[_l]==R[_l]) a=L[_l];else
        if (L[_l]<R[_l]) a=L[_l]+(a-l[_l]);else a=L[_l]-(a-l[_l]);
        
        a-=t;
        if (a<0) a=0;
        
        if (_l&1) a=X-a;
        
        printf("%lld\n",a);
    }
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000

vector<vector<int>> temp;
vector<int> B;
vector<int> sz;
vector<int> par;

void dfs(auto &E,auto &c,int now,int parent){
	par[now] = parent;
	if(temp[c[now]].size()==0)B[now] = 0;
	else B[now] = temp[c[now]].back();
	
	for(int i=0;i<E[now].size();i++){
		int to = E[now][i];
		if(to==parent)continue;
		temp[c[now]].push_back(to);
		dfs(E,c,to,now);
		temp[c[now]].pop_back();
		sz[now] += sz[to];
	}
	return;
}

int main(){
	
	int N;
	cin>>N;
	
	vector<int> c(N);
	vector<vector<int>> ind(N,vector<int>());
	for(int i=0;i<N;i++){
		cin>>c[i];
		c[i]--;
		ind[c[i]].push_back(i);
	}
	
	vector<vector<int>> E(N,vector<int>());
	
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	temp.resize(N,vector<int>());
	B.resize(N);
	sz.resize(N,1);
	par.resize(N,-1);
	
	dfs(E,c,0,-1);
	
	for(int i=0;i<N;i++){
		for(int j=0;j<ind[i].size();j++){
			int to = ind[i][j];
			if(c[B[to]]!=i){
				sz[B[to]] -= sz[to];
			}
		}
		
		//for(int j=0;j<N;j++)cout<<sz[j]<<',';
		//cout<<endl;
		
		long long ans = 0;
		if(c[0]!=i){
			ans += (long long)sz[0] * (sz[0]+1)/2;
		}
		for(int j=0;j<ind[i].size();j++){
			for(int k=0;k<E[ind[i][j]].size();k++){
				int to = E[ind[i][j]][k];
				if(to==par[ind[i][j]])continue;
				if(c[to]==i)continue;
				ans += (long long)sz[to] * (sz[to]+1) /2;
			}
		}
		
		for(int j=0;j<ind[i].size();j++){
			int to = ind[i][j];
			if(c[B[to]]!=i){
				sz[B[to]] += sz[to];
			}
		}
		
		cout<<(long long)N*(N+1)/2 - ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 53244
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
ll k,a[200010],s[200010],ans=0;
unordered_map<int,ll> ma;


void solve(){
    cin >> n >> k;
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        s[i+1]=s[i]+a[i]-1;
        s[i+1]%=k;
    }

    rep(i,min((int)k,n+1)){
        ma[s[i]]+=1;
    }

    rep(i,n+1){
        ma[s[i]]--;
        ans+=ma[s[i]];
        if (i+k<=n) ma[s[i+k]]++;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 11592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 3000 + 100;
const int MOD = 1000000000 + 7;

int n, m;
int f[MAXN][MAXN][2]; // round / red / valid

void add(int &x, int y)
{
	x = (x + y) % MOD;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n >> m;
	for(int i = 0; i <= n; i++)
		f[0][i][0] = 1;
	for(int i = 0; i <= m - 1; i++)
		for(int j = 0; j <= n; j++)
			for(int k = 0; k <= 1; k++)
			{
				// RR
				if(j > 0)
					add(f[i + 1][j - 1][k | (j - 1 == 0)], f[i][j][k]);
				// RB
				if(j > 0)
					add(f[i + 1][j][k | (j == 1)], f[i][j][k]);
				// BR
				if(j < n)
					add(f[i + 1][j][k | (j == 0)], f[i][j][k]);
				// BB
				if(j < n)
					add(f[i + 1][j + 1][k | (j + 1 == 1)], f[i][j][k]);
			}
	int ans = 0;
	for(int i = 0; i <= n; i++)
		add(ans, f[m][i][1]);
	cout << ans << endl;

	return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(long long N, std::vector<long long> A, std::vector<long long> B){

    lli sum=0;
    for(lli i=N-1;i>=0;i--){
        sum += min(B[i],A[i+1]);
        B[i] -= min(B[i],A[i+1]);

        sum += min(B[i],A[i]);
        A[i] -= min(B[i],A[i]);
    }

    cout<<sum<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N+1);
    for(int i = 0 ; i < N+1 ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    func(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 1792
void main() {
    int[] tmp = readln.split.to!(int[]);
    int a = tmp[0], b = tmp[1];
    writeln(a <= b ? a : a - 1);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.uni;

Measured memory_bytes: 256
fun main() {
    var n = readLine()!!.toLong()
    val result = mutableListOf<Char>();

    while (n > 0) {
        n -= 1
        val pos = (n % 26).toInt()
        result.add('a' + pos)
        n /= 26L
    }

    print(result.reversed().joinToString(""))
}

Measured memory_bytes: 36444
n,a,b = map(int,input().split())
h =[0]*n
for i in range(n):
    h[i]=int(input())

def hantei(now):
    ab=a-b
    nokori = sum(kiriage( max(0,hh-now*b) ,ab)//ab  for hh in h)
    return nokori<=now
def kiriage(x,c):
    if x%c==0:
        return x
    else:
        return (x//c+1) *c

ma = 10**9 +1
mi = 1

while mi<ma:
    now=(mi+ma)//2
    which = hantei(now)
#     print(which,mi,now,ma)
    if which:
        ma=now
        ans=now
    else:
        mi=now+1
print(ans)

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

int main() {
string S;
  cin >>S;
  int ans =0;
  int memo =0;
for(int i=0;i<S.size();i++){
 if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] =='T'){
  memo++;
   ans = max(memo,ans);
 }
  else memo =0;
}
  printf("%d\n",ans);
  }


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

long long ans=0;
int tot=0,h[100005];
int n,m,x,y,S,T,k[100005],siz[100005];
int s[100005],top;
bool odd;
struct Edge{
	int x,next;
}e[200005];

inline void add_edge(int x,int y){
	e[++tot].x=y;
	e[tot].next=h[x],h[x]=tot;
}

void dfs1(int x,int fa){
	for(int i=h[x];i;i=e[i].next){
		if(e[i].x==fa)continue;
		if(siz[e[i].x]){
			if(siz[x]==siz[e[i].x])odd=true;
			S=x,T=e[i].x;
		}else{
			siz[e[i].x]=-siz[x];
			dfs1(e[i].x,x);
		}
	}
}

void dfs2(int x,int fa){
	for(int i=h[x];i;i=e[i].next){
		if(e[i].x==fa||(x==S&&e[i].x==T)||(x==T&&e[i].x==S))continue;
		dfs2(e[i].x,x);
		siz[x]+=siz[e[i].x];
		k[x]+=k[e[i].x];
	}
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		add_edge(x,y);
		add_edge(y,x);
	}
	siz[1]=1,dfs1(1,0);
	int sum=0;
	for(int i=1;i<=n;i++)sum+=siz[i];
	if(m==n-1){
		if(sum)return printf("-1"),0;
	}else{
		if(odd){
			if(sum&1)return printf("-1"),0;
			ans+=abs(sum>>1);
			siz[S]-=sum>>1,siz[T]-=sum>>1;
		}else{
			if(sum)return printf("-1"),0;
			else k[S]=1,k[T]=-1;
		}
	}
	dfs2(1,0);
	for(int i=1;i<=n;i++){
		if(k[i])s[++top]=k[i]*siz[i];
		else ans+=abs(siz[i]);
	}
	s[++top]=0;
	sort(s+1,s+top+1);
	int mid=s[top+1>>1];
	for(int i=1;i<=top;i++)ans+=abs(s[i]-mid);
	printf("%lld",ans);
}

Measured memory_bytes: 14740
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
N = inp.shift() * 1
S = inp.shift()
sumE = 0
sumW = 0
W = []
E = []
W[0] = 0
E[N] = 0
for (i=0; i<N; i++) {
    if (S[i] == 'W') {
        sumW++
    }
    if (S[N-i-1] == 'E') {
        sumE++
    }
    W[i+1] = sumW
    E[N-i-1] = sumE 
}
min = N
for (i=0; i<=N; i++) {
    if (min > W[i] + E[i+1]) {
        min = W[i] + E[i+1]
    }
}
console.log(min)


Measured memory_bytes: 19660
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))}
const main=()=>{
  let n=tn(),c=1
  for(let i=1;i<=n;i++){
    c=i*c%(10**9+7)
  }
  to(c)
}
main()

Measured memory_bytes: 7500
import java.util.Scanner;

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

	public static void solve(Scanner s) {
		String str = s.next();

		String before = str.substring(0, 4);
		String afeter = str.substring(4);

		System.out.println(before + " " + afeter);

	}
}


Measured memory_bytes: 10068
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    sum=m+f
    if m==-1 or f==-1:
        print("F")
    elif sum>=80:
        print("A")
    elif sum>=65:
        print("B")
    elif sum>=50:
        print("C")
    elif sum>=30:
        if r>=50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5596
program ABC156b
    implicit none
    integer::N
    integer,allocatable,dimension(:)::X
    integer::minx
    integer::i
    read*,N
    allocate(X(N))
    read*,X
    call heapsort(N,X)
    minX=huge(minX)
    do i=X(1),X(N)
        minx=min(minX,calc(i))
    end do
    print"(i0)",minx

contains
integer function calc(P)
    integer::P
    integer::i
    calc=0
    do i=1,N
        calc=calc+(P-X(i))**2
    end do
end function
subroutine heapsort(n,array)
  implicit none
!ここの入力は状況に応じて変更すること
  integer,intent(in) :: n
  integer,intent(inout) :: array(1:n)
  integer::i,k,j,l
  integer:: t

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo
  return
end subroutine heapsort
end program ABC156b

Measured memory_bytes: 256
n=int(input())
count=0
dual=0
startb=0
enda=0

f0=0
f1=0
f2=0

for i in range(n):
    tmp=list(input())
    if tmp[0]=="B" and tmp[-1]=="A":
        #dual+=1
        f0+=1
        startb+=1
        enda+=1
    elif tmp[0]=="B":
        startb+=1
        f1+=1
    elif tmp[-1]=="A":
        enda+=1
        f2+=1

    aflag=0
    for t in tmp:
        if aflag==1 and t=="B":
            count+=1
            aflag=0
        elif t=="A":
            aflag=1
        else:
            aflag=0
"""
while dual>0:
    if startb>enda:
        enda+=1
    else:
        startb+=1
    dual-=1
"""
count+=min(startb,enda)

#補正
if f1 ==0 and f2==0 and f0>0:
    count-=1
if count<0:
    count=0

print(count)
    

        


Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) throws Exception {
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int x=sc.nextInt();
		while(true) {
			boolean yes=true;
			for(int i=2;i<x;i++) {
				if(x%i==0) {
					yes=false;break;
				}
			}
			if(yes) {
				pw.println(x);
				pw.flush();return;
			}
			x++;
		}
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] takearr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] takearrl(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public Integer[] takearrobj(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] takearrlobj(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

constexpr int N = 85, S = N * N - 5, M = 2 * N * N;
bool dp[N][N][M];
int a[N][N], b[N][N], n, m;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  for(int i = 1; i <= n; ++i) {
    for(int j = 1; j <= m; ++j) {
      cin >> a[i][j];
    }
  }
  for(int i = 1; i <= n; ++i) {
    for(int j = 1; j <= m; ++j) {
      cin >> b[i][j];
    }
  }
  dp[0][1][S] = true;
  dp[1][0][S] = true;
  for(int i = 1; i <= n; ++i) {
    for(int j = 1; j <= m; ++j) {
      int x = a[i][j] - b[i][j];
      int y = -x;
      for(int v = 0; v < M; ++v) {
        if(dp[i - 1][j][v]) {
          dp[i][j][v + x] = true;
          dp[i][j][v + y] = true;
        }
        if(dp[i][j - 1][v]) {
          dp[i][j][v + x] = true;
          dp[i][j][v + y] = true;
        }
      }
    }
  }
  int ans = 1e9;
  for(int v = 0; v < M; ++v) {
    if(dp[n][m][v]) {
      ans = min(ans, abs(v - S));
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 97024
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
char maze[50][51];
int dist[50][50];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,1,0,-1 };
int main() {
	int H, W;
	cin >> H >> W;
	int cnt = 0;
	for (int i = 0; i < H; i++) {
		cin >> maze[i];
		for (int j = 0; j < W; j++) if (maze[i][j] == '.') cnt++;
	}
	queue<P> Q;
	Q.push(P(0, 0));
	memset(dist, -1, sizeof(dist));
	dist[0][0] = 1;
	while (!Q.empty()) {
		P p = Q.front(); Q.pop();
		if (p.first == H - 1 && p.second == W - 1) break;
		for (int i = 0; i < 4; i++) {
			int nx = p.second + dx[i], ny = p.first + dy[i];
			if (0 > nx || nx >= W || 0 > ny || ny >= H || maze[ny][nx] == '#') continue;
			if (dist[ny][nx] == -1) {
				dist[ny][nx] = dist[p.first][p.second] + 1;
				Q.push(P(ny, nx));
			}
		}
	}
	if (dist[H - 1][W - 1] == -1) {
		cout << -1 << endl;
	}
	else {
		cout << cnt - dist[H - 1][W - 1] << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int h,w;
	int i,j,len;
	int map[51][51];
	int dp[51][51];
	char gyo[51][51];
	
	scanf("%d %d",&h,&w);
	for(i=0;i<h;i++){
		scanf("%s",gyo[i]);
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			map[i][j]=gyo[i][j]-'0';
			dp[i][j]=1000;
		}
	}
	dp[0][0]=0;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(dp[i][j]+map[i][j+1]<dp[i][j+1]){
				dp[i][j+1]=dp[i][j]+map[i][j+1];
//				printf("dp[%d][%d]=%d\n",i,j+1,dp[i][j+1]);
			}
			if(dp[i][j]+map[i+1][j]<dp[i+1][j]){
				dp[i+1][j]=dp[i][j]+map[i+1][j];
//				printf("dp[%d][%d]=%d\n",i+1,j,dp[i+1][j]);			
			}
		}
	}
	printf("%d\n",dp[h-1][w-1]);
	return 0;
}

Measured memory_bytes: 620