akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] s = new String[n];
    
    for (int i = 0;i<n;i++){
      String city = sc.next();
      int point = sc.nextInt();
      int num = i + 1;
      s[i] = city + " " + 1 / (double)point + " " + num;
    }
    
    Arrays.sort(s);
    
    for (String j : s){
      System.out.println(j.split(" ")[2]);
    }
  }
}

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int N, K;
	string S;
	cin >> N >> K >> S;
	int sw = 0;
	char bef = 'x';
	int r= 0, l = 0;
	REP(i , N){
		if(i > 0 && S[i] != bef){
			sw++;
			if(S[i] == 'L') l++;
			else r++;
		}
		bef = S[i]; 
	}
	//cout << sw << endl;
	char target, into;
	if(S[0] == 'L') {
		target = 'R';
		into = 'L';
	}
	else {
		target = 'L';
		into = 'R';
	}
	int rest = K;
	//bef = 'x';
	bool changing = false;
	REP(i, N){
		if(rest > 0 && changing == false && S[i] == target){
			changing = true;
		}

		if(changing){
			if(S[i] == target) S[i] = into;
			else {
				rest--;
				changing = false;
			}
		}
	}
	//cout << S <<endl;
	sw = 0;
	bef = 'x';
	REP(i , N){
		if(i > 0 && S[i] != bef){
			sw++;
		}
		bef = S[i]; 
	}
    cout << N - (sw + 1) << endl;
}

Measured memory_bytes: 512
/**
*    created: 03.07.2020 02:33:59
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    int sum = 0;
    string s = to_string(n);
    int l = s.size();
    auto ctoi = [&] (char c) {
        if (c >= '0' && c <= '9') return c - '0';
        return -1;
    };
    rep(i,l) sum += ctoi(s[i]);
    if (n % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3700
import collections

n = int(input())
ls = [int(input()) for _ in range(n)]

c = collections.Counter(ls)
ls_s =c.most_common()

ans = 0

for i in range(len(ls_s)):
    if ls_s[i][1] % 2 == 1:
        ans += 1

print(ans)

Measured memory_bytes: 21360
n,a,b =map(int,input().split())
def f(x):
    sum = 0
    for i in str(x):
        sum += int(i)
    return sum
data = []
for i in range(1,n+1):
    if a <= f(i) <= b:
        data.append(i)
print(sum(data))        

Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;
 
int main()
{
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    ll res=0;
    res+=(a+9)/10*10;
    res+=(b+9)/10*10;
    res+=(c+9)/10*10;
    res+=(d+9)/10*10;
    res+=(e+9)/10*10;
    int in[5]={a%10,b%10,c%10,d%10,e%10};
    sort(in,in+4);
    int mi = 10;
    rep0(i,5){
        if(in[i]!=0){
            mi=in[i];
            break;
        }
    }
    cout << res-10+mi << endl;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int n, k; cin >> n >> k;
    vector<vector<int>> g(n);
    rep(i, n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<bool> seen(n);
    vector<int> depth(n);
    vector<int> ith(n);
    queue<int> que;
    que.push(0);
    seen[0] = true;
    depth[0] = 0;
    while (que.size()) {
        int u = que.front();
        que.pop();
        int i = 0;
        for (auto v: g[u]) {
            if (!seen[v]) {
                seen[v] = true;
                depth[v] = depth[u] + 1;
                ith[v] = i;
                i++;
                que.push(v);
            }
        }
    }

    ll ans = 1;
    rep(i, n) {
        ans *= max(0, k - min(2, depth[i]) - ith[i]);
        ans %= MOD;
    }
    cout << ans << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    
    vector<char> c;
    for(int i=0;i<s.at(0).size();i++){
        c.push_back(s.at(0).at(i));
    }
    
    for(int i=0;i<n;i++){
        if(c.size()==0){
            break;
        }
        string t=s.at(i);
        for(int j=0;j<c.size();j++){
            bool judge=true;
            for(int k=0;k<t.size();k++){
                if(c.at(j)==t.at(k)){
                    judge=false;
                    t.erase(t.begin()+k);
                    k--;
                    break;
                }
            }
            if(judge){
                c.erase(c.begin()+j);
                j--;
            }
        }
    }
    
    if(c.size()!=0){
        sort(c.begin(),c.end());
        for(int i=0;i<c.size();i++){
            cout << c.at(i);
        }
        cout << endl;
        return 0;
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
N=int(input())
S=list(input())
for i in range(len(S)):
    if (ord(S[i])+N)>90:
        S[i]=chr(ord(S[i])+N-90+64)
    else:
        S[i]=chr(ord(S[i])+N)
for j in range(len(S)):
    print(S[j],sep='',end='')

Measured memory_bytes: 4596
#include<bits/stdc++.h>
#define in inline
#define re register
using namespace std;
in int read() {
    re int t=0;
    re char v=getchar();
    while(v<'0'||v>'9')v=getchar();
    while(v>='0'&&v<='9') {
        t=(t<<3)+(t<<1)+(v^48);
        v=getchar();
    }
    return t;
}
int n,m,ans,k;
bool vis[100002];
signed main(){
    n=read();m=read();
    while(m--){
        k=read();
        while(k--)vis[read()]=1;
    }
    for(re int i=1;i<=n;++i)if(!vis[i])++ans;
    printf("%d",ans);
}

Measured memory_bytes: 3768
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    while (1)
    {
        int h, w, dia, ans=30000, s=300, sw, d, dw;
        bool same=false;
        cin>>h>>w;
        if (h==0 && w==0) break;
        dia=h*h+w*w;
        for (int i=1; i<151; i++)
        {
            for (int j=i+1; j<151; j++)
            {
                if (i==h && j==w) continue;
                if (i*i+j*j>dia) if (i*i+j*j<ans) { ans=i*i+j*j; d=i; dw=j; }
                if (i*i+j*j==dia && i>h) { same=true; if (s>i) { s=i; sw=j; } }
            }
        }
        if (same) cout<<s<<' '<<sw<<'\n';
        else cout<<d<<' '<<dw<<'\n';
    }
    return 0;
}



Measured memory_bytes: 3092
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();     
        int N = r.i();
        int[][] xy = new int[N][];
        HashMap<String, Integer> hm = new HashMap<>();
        for(int i = 0; i < N; i++)
            xy[i] = r.ii();
        for(int i = 0; i < N-1; i++){
            int x0 = xy[i][0];
            int y0 = xy[i][1];
            for(int j = i+1; j < N; j++){
                int dx = x0-xy[j][0];
                int dy = y0-xy[j][1];
                if(dx < 0){
                    dx = -dx;
                    dy = -dy;
                } else if(dx == 0 && dy < 0){
                    dy = -dy;
                }
                String key = dx+" "+dy;
                if(hm.containsKey(key)){
                    hm.put(key, hm.get(key)+1);                    
                } else{
                    hm.put(key, 1);
                }
            }                
        }
        String key = "";
        int max = 0;
        for(String k : hm.keySet()){
            int temp = hm.get(k);
            if(max < temp){
                max = temp;
                key = k;
            }
        }
        int cost = N-max;
        println(cost);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 23252
import sys
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()))

n=int(input())
a=[0 for _ in range(n)]
for i in range(n):
    a[i]=input()
print(len(set(a)))

Measured memory_bytes: 103688
#include<bits/stdc++.h>
using namespace std;
void read() {}
template<class T, class... Arg>
void read(T &x, Arg&&... args) {
	cin >> x;
	read(args...);
}
void print_err() {
	cerr << "\n";
}
template <class T, class... Arg>
void print_err(T x, Arg&&... args) {
	cerr << x << " ";
	print_err(args...);
}
template<class T>
void print_container(T &cont) {
	for (auto iter : cont) {
		cerr << iter << " ";
	}
	cerr << "\n";
}
#ifdef local
#define debug(...) print_err(__VA_ARGS__)
#define debug_c(container) print_container(container)
#else
#define debug(...)
#define debug_c(container)
#endif
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define vl vector<ll>
#define vpll vector<pair<ll,ll>>
#define mll map<ll,ll>
#define mllrev map<ll,ll,greater<int>>
#define ps(x,y) fixed<<setprecision(y)<<x//it will give upto y decimal places
#define w(t) ll t;cin>>t;while(t--)
#define fo(i,n) for(ll i=0;i<n;++i)
#define foab(i,a,b) for(ll i=a;i<b;++i)
#define inp cin>>
#define pr cout<<
#define pqb priority_queue<ll>//max heap
#define pqs priority_queue<ll,vl,greater<int>>//min heap
#define mk(arr,n,type) type *arr=new type[n];
#define all(A) (A).begin(),(A).end()
#define fastio ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define mem(a,val) memset(a,val,sizeof(a))
template<class T>
void debug_arr(T arr, ll st, ll en) {
	foab(i, st, en) {
		cerr << arr[i] << " ";
	}
	cerr << endl;
}
template<class T>
void read_arr(T arr, ll n) {
	fo(i, n) {
		cin >> arr[i];
	}
}
template<class T>
void read_c(T &arr, ll n) {
	fo(i, n) {
		cin >> arr[i];
	}
}
void CP() {
	fastio
#ifdef local
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
	return;
}
char* stringTOCharArray(string str) {
	ll n = str.length();
	mk(ch, n + 1, char);
	strcpy(ch, str.c_str());
	return ch;
}
class Graph {
public:
	list<ll> *adj_list;
	ll v;
	Graph(ll v) {
		this->v = v;
		adj_list = new list<ll>[v];
	}
	void add_edge(ll u, ll v, bool bidirectional = true) {
		adj_list[u].push_back(v);
		if (bidirectional) {
			adj_list[v].push_back(u);
		}
	}
	void print();
	void connected_compo();
	void dfs(vector<vector<ll>> vect, ll k1, ll k2, ll n);
	void bfs(ll v, bool visited[]);
};
const int d4i[4] = { -1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1};
const int d8i[8] = { -1, -1, 0, 1, 1, 1, 0, -1}, d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};
void solve() {
	ll n, x, t;
	read(n, x, t);
	ll temp = n / x;
	if (((temp)*x) == n) {
		cout << temp*t << endl;
	} else {
		cout << (temp + 1)*t << endl;
	}
	return ;
}
int main() {
	CP();
	// w(t) {
	solve();
	// }
	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

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

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF= 1e20;

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();

int main() {
	LL a,b,c;
  cin>>a>>b>>c;
	if (a+b>=c)coutY();
	else coutN();
	return 0;
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	for (int c = 0; c < n; ++c)
	{
		int s;
		scanf("%d", &s);
		printf("Case %d:\n", c+1);
		for (int i = 0; i < 10; ++i)
			printf("%d\n", s = s*s/100 % 10000);
	}

	return 0;
}

Measured memory_bytes: 0
# coding: utf-8
_ = input()
n = list(map(int, input().split()))

op_cnt = len(n) - 1  # すき間の個数

out = 1000000
for t in range(len(n)-1):
    s1 = sum(n[:t+1])
    s2 = sum(n[t+1:])
    
    out = min(abs(s1-s2), out)
    #print(t, out,s1, s2)

print(out)

Measured memory_bytes: 38512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <valarray>
#include <utility>
#include <set>

using namespace std;

#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 rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<=(int)(n);i++)
#define INF 500000000  //
#define INFLL 1000000000000000000  //
#define MOD (1e9)+7

typedef long long int ll;

// a 0x61  z 0x7a  0 0x30

int main() {
    string s;
    cin >> s;
    bool suc = true;

    while (!s.empty()) {

        if (s.length() < 5) {

            suc = false;
            break;

        } else if (s.substr(0, 5) == "dream") {

            s.erase(s.begin(), s.begin() + 5);
            
            if (s[0] == 'e' && s[1] == 'r' && s.substr(0, 5) != "erase") {
                s.erase(s.begin());
                s.erase(s.begin());
            }

        } else if (s.substr(0, 5) == "erase") {

            s.erase(s.begin(), s.begin() + 5);
            if (s[0] == 'r') s.erase(s.begin());

        } else {

            suc = false;
            break;

        }
    }

    cout << (suc ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 512
program battle
  implicit none
  integer :: a, b, c, d
  read(*,*) a, b, c, d
  do
    c = c-b
    if (c <= 0) then
      write(*,'(a)') "Yes"
      stop
    end if
    a = a-d
    if (a <= 0) then
      write(*,'(a)') "No"
      stop
    end if
  end do
end program battle

Measured memory_bytes: 2920
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

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

    cout << a + b + c - max(a, max(b, c)) << endl;
    return 0;
}


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

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
    int N,M;
    cin >> N >> M;
    UnionFind uf(N);
    rep(i,M){
      int a,b;
      cin >> a >> b;
      a--;b--; //頂点番号をデクリメント
      uf.unite(a,b);
    }
    set<int> root;
    rep(i,N){
        int a = uf.find(i);
        root.insert(a);
    }
    auto ans = *root.end()-1;
    cout << ans << endl; 
}


Measured memory_bytes: 7660
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static final void main(String[] args) {
        new Main().solve();
        out.flush();
    }

    // ========================================================================= //

    public void solve() {
        int n = sc.nextInt();
        double[] t = new double[n];
        double[] v = new double[n + 1];
        for (int i = 0; i < n; i++) t[i] = sc.nextDouble();
        for (int i = 0; i < n; i++) v[i] = sc.nextDouble();
        v[n] = 0.0;

        double ans = 0.0, curV = 0.0;
        for (int i = 0; i < n; i++) {
            for (double j = 0; j < t[i]; j+=0.5) {
                boolean up = true, eq = true;
                double  tc = t[i] - j;
                for (int k = i + 1; k < n + 1; k++) {
                    if (curV + 0.5 - tc >= v[k]) up = false;
                    if (curV - tc >= v[k]) eq = false;
                    if (k < n) tc += t[k];
                }

                if (up && curV + 0.5 <= v[i]) {
                    ans += curV * 0.5 + 0.125;
                    curV += 0.5;
                }
                else if (eq) {
                    ans += curV * 0.5;
                }
                else {
                    ans += curV * 0.5 - 0.125;
                    curV -= 0.5;
                }
            }
        }
        out.println(ans);
    }
}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n,k; cin>>n>>k;
  int a[10]={};
  REP(i,k){
    int x; cin>>x;
    a[x]=1;
  }
  for(int i=n; i<100000; i++) {
    string s=to_string(i);
    for(int j=0; j<(int)s.size(); j++) {
      if(a[s[j]-'0']==1) goto E;
    }
    cout<<i<<endl; break; E:;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n, d, x;
    cin >> n >> d >> x;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int cnt = 0;
    rep(i, n) {
        int day = 1;
        while (day <= d) {
            day += a[i];
            cnt++;
        }
    }
    cout << cnt + x << endl;
}

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

int main(){

  int n;
  int ans=0;
  std::cin >> n;


  for (int i = 1; i <=n ; i+=2) {
    int temp=i;
    int na=0;
    // printf("%d\n",i);
    for (int j = 1; j <= i ; j++) {
      if(temp%j==0){na++;}
    }
    if(na==8)ans++;

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



  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
map<int, int> mp;
int n,m;
int res=0;
vector<int> v;
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++)
	{
		int x;
		cin >>x;
		mp[x-1]++;
	}
	if (mp.size()<=m)
	{
		cout <<"0";
		return 0;
	}
	for (map<int, int>::iterator it=mp.begin();it!=mp.end();it++)
	    v.push_back(it->second);
	sort(v.begin(),v.end());
	for (int i=0;i<v.size()-m;i++) res+=v[i];
	cout <<res;
	return 0;
}

Measured memory_bytes: 10748
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}



template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


template< typename T >
struct LowLink {
  const WG<T> &g;
  vector< int > used, ord, low;
  vector< int > articulation;
  vector< pair< int, int > > bridge;
 
  LowLink(const WG<T> &g) : g(g) {}
 
  int dfs(int idx, int k, int par) {
    used[idx] = true;
    ord[idx] = k++;
    low[idx] = ord[idx];
    bool is_articulation = false;
    int cnt = 0;
    for(auto &e : g[idx]) {
      if(!used[e.to]) {
        ++cnt;
        k = dfs(e.to, k, idx);
        low[idx] = min(low[idx], low[e.to]);
        is_articulation |= ~par && low[e.to] >= ord[idx];
        if(ord[idx] < low[e.to]) bridge.emplace_back(minmax(idx, (int) e.to));
      } else if(e.to != par) {
        low[idx] = min(low[idx], ord[e.to]);
      }
    }
    is_articulation |= par == -1 && cnt > 1;
    if(is_articulation) articulation.push_back(idx);
    return k;
  }
 
  virtual void build() {
    used.assign(g.size(), 0);
    ord.assign(g.size(), 0);
    low.assign(g.size(), 0);
    int k = 0;
    for(int i = 0; i < g.size(); i++) {
      if(!used[i]) k = dfs(i, k, -1);
    }
  }
};



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

  int n,m;
  cin>>n>>m;
  WG<int> es(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    es[a].PB(edge<int>(b,0));
    es[b].PB(edge<int>(a,0));
  }

  LowLink<int> lowlink(es);
  lowlink.build();
  sort(all(lowlink.bridge));
  for(P p:lowlink.bridge){
    cout<<p.F<<' '<<p.S<<endl;
  }


}


Measured memory_bytes: 7668
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
using namespace std;

int main() {
    int n;
    cin >> n;
    cout << (n/2)*(n/2 + n%2) << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int main() {
	int m, f, b;
	cin >> m >> f >> b;
	
	if (m + f < b) puts("NA");
	else cout << max(b - m, 0) << endl;
	
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int x,y,z;
	cin >> x >> y >> z;
	cout << z <<' ' << x << ' ' << y << endl;
	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

typedef long long ll;

const static long long INF = 1000000000;
int main() {
  ll n;
  cin >> n;
  vector<ll> d(n);
  for(int i=0;i<n;i++) cin >> d[i];
  ll m;
  cin >> m;
  vector<ll> t(m);
  for(int i=0;i<m;i++) cin >> t[i];
  sort(d.begin(), d.end());
  sort(t.begin(), t.end());
  ll i=0, j=0;
  bool ans = true;
  while(i<n && j<m) {
    if(t[j] == d[i]) {
      j++;
      i++;
    }
    else {
      i++;
    }
    if(j<m&&i==n) {
      ans = false;
      break;
    }
  }
  if(ans)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}



Measured memory_bytes: 3328
#include<iostream>
#include<math.h>

using namespace std;

int main(void){

    int N;
    cin >> N;

    int minVal = (int)1e+9;
    int maxVal = 0;

    for(int i = 0; i < N; ++i){
        int tmp;
        cin >> tmp;
        minVal = min(tmp, minVal);
        maxVal = max(tmp, maxVal);
    }

    cout << maxVal - minVal << endl;
   
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace std;
#define ll long long int
#define ld long double
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> in_set;
#define rep(n) for(ll i=0;i<(n);i++)
#define jrep(n) for(ll j=0;j<(n);j++)
#define krep(n) for(ll k=0;k<(n);k++)
#define all(a) (a).begin(), (a).end()
#define dpp(a) cout<<(a).first<<" "<<(a).second<<endl;
#define append push_back
#define mod 1000000007
#define ff first
#define ss second
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fast ios::sync_with_stdio(0);
ll pw(ll x,ll y,ll p=mod){ll r=1; x=x%p;while(y>0){ if(y&1)r=(r*x)%p;
y=y>>1;x=(x*x)%p;} return r; } 
 
void solve(ll ts){
	//ll n=2; vector<ll> arr(n); rep(n) cin>>arr[i];
    ll n; cin>>n; vector<ll> arr(n),brr(n);
    rep(n) cin>>arr[i]; rep(n) cin>>brr[i];
    map<ll,vector<ll>> mp; set<ll> st;
    rep(n) if(arr[i]==brr[i]){
        st.insert(arr[i]); mp[arr[i]].append(i);
    }
    while(st.size()>1){
        ll a=*st.begin(); st.erase(a); ll b=*st.begin(); st.erase(b);
        ll ia=mp[a].back(); ll ib=mp[b].back(); mp[a].pop_back(); mp[b].pop_back();
        swap(brr[ia],brr[ib]);
        if(mp[a].size()) st.insert(a);
        if(mp[b].size()) st.insert(b);
    }
    if(st.size()==1){
        ll tr=*st.begin(); vector<ll> trr=mp[tr];
//        for(auto i:trr) cout<<i<<" "; cout<<endl;
        rep(n) if(arr[i]!=tr && brr[i]!=tr && trr.size()>0){
            swap(brr[i],brr[trr.back()]);
            trr.pop_back();
        }
        if(trr.size()==0) st.erase(tr);
    }
    if(st.size()==0){
        cout<<"Yes\n";
        for(auto i:brr) cout<<i<<" "; cout<<endl;
    } else cout<<"No\n";
} 
 
//
int main(){
    ffast
    ll t=1;
   // cin>>t;
    rep(t) solve(i+1);
}
 
 
// *p.find_by_order(n) : nth value (0 indexed)
// p.order_of_key(7): index of 7 (0 indexed)

Measured memory_bytes: 37504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn= new Scanner(System.in);
		 String s= scn.next();
		 if(s.charAt(1)=='B'){
			 System.out.println("ARC");
		 }else{
			 System.out.println("ABC");
		 }

	}

}

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

using namespace std;
using vi = vector<int>;

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

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

  int A[N];
  int sum = 0;
  rep(i, N) {
    cin >> A[i];
    sum += A[i];
  }
  vi factors;
  for (int i = 1; i * i <= sum; ++i) {
    if (sum % i == 0) {
      factors.push_back(i);
      if (i * i != sum)
        factors.push_back(sum / i);
    }
  }
  all(sort, factors);
  all(reverse, factors);

  vi B(N);
  for (const auto& factor : factors) {
    int sum = 0; // 前のほう
    int sum2 = 0; // 後ろのほう
    rep(i, N) {
      B[i] = A[i] % factor;
      sum2 += (factor - B[i]) % factor;
    }
    all(sort, B);
    if (sum == sum2) {
      cout << factor << endl;
      return 0;
    }
    rep(i, N) {
      sum += B[i];
      sum2 -= (factor - B[i]) % factor;
      if (sum == sum2) {
        if (sum <= K) {
          cout << factor << endl;
          return 0;
        }
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    string op;
    cin>>a>>op>>b;
    if(op=="+"){
        cout<<a+b<<endl;
    }
    else{
        cout<<a-b<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int w,h,n,x[110],y[110],a[110];
    cin >> w >> h >> n;
    int minx=0,miny=0,maxx=w,maxy=h;
    for(int i=0; i < n; i++) cin >> x[i] >> y[i] >> a[i];
    for(int i=0; i < n; i++){
        switch(a[i]){
            case 1:
                minx = max(minx,x[i]);
                break;
            case 2:
                maxx = min(maxx,x[i]);
                break;
            case 3:
                miny = max(miny,y[i]);
                break;
            case 4:
                maxy = min(maxy,y[i]);
                break;
            default: ;
        }
    }
    cout << (max(maxx-minx,0) * max(maxy-miny,0)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lol long long
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a==1) a+=13;
    if(b==1) b+=13;
    if(a>b) cout<<"Alice\n";
    else if(a==b) cout<<"Draw\n";
    else cout<<"Bob\n";
    

    return(0);
}

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

const int MAX=200;

int state[MAX],d[MAX],f[MAX],N;
vector<int> T[MAX];
stack<int> S;

void DFS(){
    int time=0,count=0;
    while(count!=N){
        for(int j=0;j<N;j++){
            if(state[j]==0){
                S.push(j);
                state[j]=1;
                time++;
                d[j]=time;
                break;
            }
        }
    while(S.size()){
        int a=S.top();
        bool flag=true;
        for(int i=0;i<T[a].size();i++){
            if(state[T[a][i]]==0){
                S.push(T[a][i]);
                state[T[a][i]]=1;
                time++;
                d[T[a][i]]=time;
                flag=false;
                break;
            }
        }
            if(flag){
                time++;
                state[a]=2;
                count++;
                f[a]=time;
                S.pop();
            }
            
        }
    }
    for(int i=0;i<N;i++){
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
}

int main(){
   
    int u,k,a;cin>>N;
    
    for(int i=0;i<N;i++){
        state[i]=0;
        d[i]=0;
        f[i]=0;
    }
    
    for(int i=0;i<N;i++){
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++){
            cin>>a;
            a--;
            T[u].push_back(a);
        }
    }
    DFS();
}



Measured memory_bytes: 3156
#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 <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a==c&&a%2==0&&b%2==0&&c%2==0){
        cout<<-1;
        return 0;
    }
int count=0;
while(1){
    ll p=a,q=b,r=c;
    if(a%2==1||b%2==1||c%2==1){cout<<count;return 0;}
    b=p/2+r/2;
    a=q/2+r/2;
    c=p/2+q/2;
    count++;
}
cout<<count;
return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

vector<int> S[100001];
vector<int> E[100001];
bool complete[100001];

int main()
{
	int N, M, a, b;
	int ans = 0;
	stack<int> visited;

	cin >> N >> M;

	repc(i, 1, M) {
		cin >> a >> b;
		S[a].push_back(i);
		E[b].push_back(i);
	}

	repc(i, 1, N) {
		bool end = false;

		rep(j, (int)E[i].size()) {
			if (!complete[E[i][j]]) end = true;
		}

		if (end) {
			ans++;
			while (!visited.empty()) {
				int p = visited.top(); visited.pop();
				complete[p] = true;
			}
		}

		rep(j, (int)S[i].size()) visited.push(S[i][j]);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
#define lowbit(x) (x & -x)
using namespace std;

const int _ = 3e5 + 10;
int N, M, d;
struct node {
	int l, r, len;
} a[_];

struct BIT {
	int c[_];
	void insert(int x, int y) {
		for ( ; x <= M + 1; x += lowbit(x)) c[x] += y;
	}
	int query(int x) {
		int y = 0;
		for ( ; x; x -= lowbit(x)) y += c[x];
		return y;
	}
} tr;

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= N; ++i) {
		scanf("%d%d", &a[i].l, &a[i].r);
		a[i].len = (a[i].r - a[i].l + 1);
	}
	sort(a + 1, a + N + 1,
			 [](node a, node b) -> bool { return a.len < b.len; });
	for (int d = 1, p = 1; d <= M; ++d) {
		while (p <= N && a[p].len < d) {
			tr.insert(a[p].l, 1);
			tr.insert(a[p].r + 1, -1);
			++p;
		}
		int ans = N - p + 1;
		for (int i = d; i <= M; i += d)
			ans += tr.query(i);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <cstdio>
using namespace std;
string G[] = {"meiji",
	      "taisho",
	      "showa",
	      "heisei"};

int Gnum[] = {1868,1912,1926,1989};
int YEAR(int year){
  if(19890108 <= year){
    return 3;
  }else if(19261225 <= year ){
    return 2;
  }else if( 19120730 <= year ){
    return 1;
  } else if( 18680908 <= year   ){
    return 0;
  }
  return 4;
}
int main(){
  long long int tosi,mon,day;
  while( cin >> tosi >> mon >> day ){
    long long int gen = YEAR(tosi*10000 + mon*100 + day);
    if(gen == 4)cout << "pre-meiji" << endl;
    else cout <<  G[gen] << ' ' << tosi - Gnum[gen]+1 <<' '<< mon <<' '<< day << endl; 

      }
  return 0;
}

Measured memory_bytes: 1200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Amazing Mazes
 */
public class Main {

	static final int DIR[][] = {
			{0, -1},
			{1, 0},
			{0, 1},
			{-1, 0},
	};

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int w, h;
			w = parseInt(line.substring(0, line.indexOf(' ')));
			h = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((w | h) == 0) break;

			int[][] maze = new int[h][w];
			int[][] moveH = new int[h][w - 1];
			int[][] moveV = new int[h - 1][w];

			for (int i = 0; i < 2 * h - 1; i++) {
				line = br.readLine();
				if (i % 2 == 0) {
					StringTokenizer st = new StringTokenizer(line.substring(1));
					for (int j = 0; j < moveH[0].length; j++) {
						moveH[i / 2][j] = parseInt(st.nextToken());
					}
				} else {
					StringTokenizer st = new StringTokenizer(line);
					for (int j = 0; j < moveV[0].length; j++) {
						moveV[i / 2][j] = parseInt(st.nextToken());
					}
				}
			}

			//solve
			Deque<int[]> q = new ArrayDeque<>();

			q.offer(new int[]{0, 0});
			maze[0][0] = 1;

			while (!q.isEmpty()) {

				int y, x;
				y = q.peek()[0];
				x = q.peek()[1];
				q.poll();

				if (y == h - 1 && x == w - 1) break;

				for (int i = 0; i < DIR.length; i++) {
					int ny, nx;
					ny = y + DIR[i][0];
					nx = x + DIR[i][1];
					if (0 <= ny && ny < h && 0 <= nx && nx < w && maze[ny][nx] == 0) {
						if (i % 2 == 0 && moveH[ny][(nx + x) / 2] == 1) {
							continue;
						} else if (i % 2 != 0 && moveV[(ny + y) / 2][nx] == 1) {
							continue;
						}
						q.offer(new int[]{ny, nx});
						maze[ny][nx] = maze[y][x] + 1;
					}
				}
			}
			System.out.println(maze[h - 1][w - 1]);
		}
	}
}

Measured memory_bytes: 42048
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

int n,m;
vector<vector<int>> edge;
int cnt1=0,cnt2=0;
vector<int>memo;
bool flag=0;
void dfs(int par,int node,bool oe)
{
  //cout<<par<<" "<<node<<" "<<oe<<endl;
  if(memo[node]!=-1)
  {
    if(oe!=memo[node]){flag=1;return ;}
    else return ;
  }
  if(oe)cnt1++;
  else cnt2++;
  memo[node]=(int)oe;
  for(int nn:edge[node])
  {
    if(nn!=par)
    {
      dfs(node,nn,!oe);
    }
  }
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  cin>>n>>m;
  edge.resize(100001);
  memo=vector<int>(100001,-1);
  rep(i,m)
  {
    int a,b;
    cin>>a>>b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  dfs(-1,1,0);
  if(flag==0)
  {
    ll res=(ll)cnt1*cnt2;
    //cout<<cnt1<<" "<<cnt2<<endl;
    res-=m;
    cout<<res<<endl;
  }
  else
  {
    ll res=((ll)n*(n-1))/2;
    res-=m;
    cout<<res<<endl;
  }
  return 0;

}


Measured memory_bytes: 7040
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = '-1'


def is_anag(a, b):
    return Counter(a) == Counter(b)


N = int(input())
S = [''.join(sorted(input().rstrip())) for _ in range(N)]
counter = Counter(S)

ans = sum(x * (x - 1) // 2 for x in counter.values())
print(ans)


# for i, s in enumerate(S, start=1):
#     if s == NIL:
#         continue
#     counter = 1
#     for j in range(i, len(S)):
#         if S[j] == NIL:
#             continue
#         if is_anag(s, S[j]):
#             counter += 1
#             S[j] = NIL
#     if counter != 1:
#         ans.append(counter * (counter - 1) // 2)

# res = []
#
# for a in ans:
#     res.append(a * (a - 1) // 2)
# print(sum(ans))


Measured memory_bytes: 64092
#include <stdio.h>
int main(void)
{
    int X,Y;
    scanf("%d %d",&X,&Y);
    if(Y%4 == 0 && Y/4 <= X && X <= Y/2){
        printf("Yes");
    }else if(Y%2 == 0 && Y%4 != 0 && Y/4+1 <= X && X <= Y/2){
        printf("Yes");
    }else{
        printf("No");
    }
}

Measured memory_bytes: 1732
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 998244353;
const ll INF = 1e16;
const ll MAX_N = 300010;  // デフォルトでnの最大値は300000

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inv(ll a) {
    return modpow(a, mod-2);
}

ll fact[MAX_N];
ll invfact[MAX_N];

// main関数でinit()を呼び出してからComb()を使用する
void init() {
    fact[0] = 1;
    invfact[0] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        fact[i] = (i*fact[i-1])%mod;
        invfact[i] = inv(fact[i]);
    }
}
 
ll Comb(ll n, ll r) {
    if(r < 0 || n < 0 || n < r) {
        return 0;
    }
    ll res = fact[n];
    res = (res * invfact[r])%mod;
    res = (res * invfact[n-r])%mod;
    return res;
}

//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    
    init();
 
    ll ans = 0;
    exrep(x, 0, n) {
        if((k - a*x)%b != 0) {
            continue;
        }
        ll y = (k - a*x)/b;
        if(y < 0 || n < y) {
            continue;
        }
        ans += Comb(n, x)*Comb(n, y);
        ans %= mod;
    }
 
    out(ans);
    re0;
}

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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;

  if (S.at(K-1) == 'A') {
    S.at(K-1) = 'a';
  }
  if (S.at(K-1) == 'B') {
    S.at(K-1) = 'b';
  }
  if (S.at(K-1) == 'C') {
    S.at(K-1) = 'c';
  }

  cout << S << endl;

}

Measured memory_bytes: 256