akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
long long gcd(long long x, long long y){
    return x % y == 0 ? y : gcd(y, x%y);
}
 
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
 
int main(void){
    ll N,M; cin >> N >> M;
    ll a[N]; REP(i,N) cin >> a[i];
 
    ll fact = 2;
    while(a[0]%fact == 0){
        fact <<= 1;
    }
    fact >>= 1;
    bool flag = false;
    REP(i,N){
        if(a[i]%fact != 0 || a[i]%(2*fact) == 0){
            flag = true;
            break;
        }
    }
    if(flag){
        cout << 0 << endl;
        return 0;
    }
    
    REP(i,N) a[i] /= 2;
 
    ll l = 1;
    REP(i,N) l = lcm(l, a[i]);
    ll ans = M/l;
    if(ans % 2 == 0) ans = ans/2;
    else ans = ans/2 + 1;
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 4388
import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
    public static int n, cnt = 0;
    public static String x;
    public static BigInteger bg;
    public static int a, b, c;
    public static int A, B, C;
    public static int pop(int x) {
        int cnt = 0;
        while (x > 0) {
            if (x % 2 == 1) {
                cnt++;
            }
            x /= 2;
        }
        return cnt;
    }
    public static int f(int x) {
        int cnt = 0;
        while (x > 0) {
            int p = pop(x);
            x %= p;
            cnt++;
        }
        return cnt;
    }
    public static void main(String[] args) throws IOException {
        BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);

        n = Integer.parseInt(rd.readLine());
        x = rd.readLine();
        bg = new BigInteger(x, 2);
        for (int i = 0; i < n; i++) {
            if (x.charAt(i) == '1') {
                cnt++;
            }
        }
        if (cnt - 1 >= 1) {
            a = Integer.parseInt(bg.mod(new BigInteger(cnt + "").subtract(BigInteger.ONE)) + "");
        }
        if (cnt >= 1) {
            b = Integer.parseInt(bg.mod(new BigInteger(cnt + "")) + "");
        }
        c = Integer.parseInt(bg.mod(new BigInteger(cnt + "").add(BigInteger.ONE)) + "");
        int[] ans = new int[n];
        for (int i = n - 1; i >= 0; i--) {
            if (i == n - 1) {
                A = B = C = 1;
            } else {
                A *= 2;
                B *= 2;
                C *= 2;
                if (cnt - 1 >= 1) {
                    A %= (cnt - 1);
                }
                if (cnt >= 1) {
                    B %= cnt;
                }
                C %= (cnt + 1);
            }
            int katya = cnt;
            if (x.charAt(i) == '0') {
                katya++;
            } else {
                katya--;
            }
            if (katya == 0) {
                ans[i] = 0;
            } else {
                int init;
                if (katya == cnt - 1) {
                    init = (a - A + (cnt - 1)) % (cnt - 1);
                } else if (katya == cnt) {
                    init = 80085;
                } else {
                    init = (c + C) % (cnt + 1);
                }
                ans[i] = f(init) + 1;
            }
        }
        for (int x : ans) {
            System.out.print(x + " ");
        }
        pw.println();

        pw.flush();
        pw.close();
    }
}

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

int a[100][100];
int N,u,k,col;
int main() {
	cin >> N;
	for(int i=0; i<N; ++i) {
		cin >> u >> k;
		for(int l=0; l<k; ++l) {
			cin >> col;
			a[u-1][col-1] = 1;
		}
		cout << a[i][0];
		for(int l=1; l<N; ++l) {
			cout << " " << a[i][l];
		}
		cout << endl;
	}
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
#include<string>
#include<iomanip>
#include <numeric>
#include <limits>
using namespace std;
 
int main()
{
int n,k,m=0; cin>>n>>k; int a[n];
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<k;i++)
{
    m+=*max_element(a,a+n);
    a[std::max_element(a,a+n) - a]=0;
}
cout<<m;
return 0;
}

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

typedef long long ll;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

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

    cout<<a-b+1<<endl;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
X = LIST()

ans = INF
for i in range(1, 101):
	spot = i
	tmp = 0
	for j in range(N):
		tmp += (X[j]-spot)**2
	if tmp < ans:
		ans = tmp
print(ans)


Measured memory_bytes: 5816
#include<bits/stdc++.h>
using namespace std;typedef long long int ll;
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
// Returns LCM of array elements 
ll findlcm(int arr[], int n) 
{ 
    // Initialize result 
    ll ans = arr[0]; 
  
    // ans contains LCM of arr[0], ..arr[i] 
    // after i'th iteration, 
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    string s;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    int x=findlcm(arr,n),sum=0;
    for(int i=0;i<n;i++)
      {
          sum+=(x/arr[i]);
      }
      cout<<fixed<<setprecision(10)<<(double)x/(double)sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    sort(s.begin(), s.end());

    int ans = 1;
    for(int i=1;i<n;i++){
        if(s[i] != s[i-1]){
            ans++;
        }
    }

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

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H, W; cin >> H >> W;
    vector<string> ans;
    int ch[4];
    int grid[H][W]; rep(i, H) rep(j, W) cin >> grid[i][j];
    rep(i, H){
        rep(j, W){
            if(j == W-1){
                if(grid[i][j] % 2 == 1 && i < H-1){
                    grid[i][j]--;
                    grid[i+1][j]++;
                    ch[0] = i+1; ch[1] = j+1; ch[2] = i+2; ch[3] = j+1;
                    string s = "";
                    rep(k, 4){
                        s += to_string(ch[k]);
                        if(k < 3) s += ' ';
                    }
                    ans.push_back(s);
                }
            }
            else if(grid[i][j] % 2 == 1){
                grid[i][j]--;
                grid[i][j+1]++;
                //cout << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl;
                ch[0] = i+1; ch[1] = j+1; ch[2] = i+1; ch[3] = j+2;
                string s = "";
                rep(k, 4){
                    s += to_string(ch[k]);
                    if(k < 3) s += ' ';
                }
                ans.push_back(s);
            }
        }
    }
    cout << ans.size() << endl;
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 11892
#include<iostream>
#pragma GCC optimize "trapv"
using namespace std;
#define ll long long int
#define endl "\n"
int h[100000];
int dp[100000];
int n;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		dp[i] = -1;
	}
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}


	dp[0] = 0;
	for (int i = 1; i < n; i++)
	{
		if (i == 1)
		{
			dp[i] = abs(h[1] - h[0]);
		}
		else
		{
			dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2]);
		}
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 3972
while 1:
    h,w=map(int,input().split())
    if h==0 and w==0:
        break
    for i in range(h):
        s=""
        for j in range(w):
            if abs(i-j)%2==0:
                s+="#"
            else:
                s+="."
        print(s)
    print()


Measured memory_bytes: 5612
from itertools import combinations

N = int(input())
MARCH = [0] * 5
for i in range(N):
    S = input()
    if S[0] == 'M':
        MARCH[0] += 1
    if S[0] == 'A':
        MARCH[1] += 1
    if S[0] == 'R':
        MARCH[2] += 1
    if S[0] == 'C':
        MARCH[3] += 1
    if S[0] == 'H':
        MARCH[4] += 1
ans = 0
for x in combinations(MARCH,3):
    ans += x[0]*x[1]*x[2]
print(ans)

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

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

    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
        cout<<"Bad";
    }else{
        cout<<"Good";
    }
}

Measured memory_bytes: 256
// clang-format off
	#include <bits/stdc++.h>
	using namespace std; using ll = long long; using uint = unsigned int;
	#define SFINAE(x, ...)	template <class, class = void> struct x : false_type {}; template <class T> struct x<T, void_t<__VA_ARGS__>> : true_type {};
	SFINAE(DefaultIO, decltype(cout << declval<T &>()))
	SFINAE(IsTuple, typename tuple_size<T>::type)
	SFINAE(Iterable, decltype(begin(declval<T>())))
	template <class T> constexpr char Space(const T &) { return (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' '; }
	template <auto &os> struct Writer {
		template <class T> void Impl(T const &t) const {
			if constexpr (DefaultIO<T>::value) os << t;
			else if constexpr (Iterable<T>::value) { int i = 0; for (auto &&x : t) ((i++) ? (os << Space(x), Impl(x)) : Impl(x)); }
			else if constexpr (IsTuple<T>::value) apply([this](auto const &... args) { int i = 0; (((i++) ? (os << ' ', Impl(args)) : Impl(args)), ...);}, t);
			else static_assert(IsTuple<T>::value, "No matching type for print");
		}
		template <class F, class... Ts> auto &operator()(F const &f, Ts const &... ts) const { return Impl(f), ((os << ' ', Impl(ts)), ...), os << '\n', *this; }
	};
	template <auto &is> struct Reader {
		template <class T> auto& operator()(T &t) const {
			if constexpr (DefaultIO<T>::value) is >> t;
			else if constexpr (Iterable<T>::value) for (auto &x : t) (*this)(x);
			else if constexpr (IsTuple<T>::value) apply([this](auto &... args) { ((*this)(args), ...); }, t);
			else static_assert(IsTuple<T>::value, "No matching type for read");
			return *this;
		}
	};
	#ifdef NARUT_LOCAL
	#define Debug(...) cerr << "\033[0;31m", Writer<cerr>{}(__VA_ARGS__), cerr << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] constexpr Reader<cin> Cin; [[maybe_unused]] constexpr Writer<cout> Cout;
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)
// clang-format on





auto Main() {
	string s,t;
	cin>>s>>t;
	int ans = 0;
	FOR(i,0,s.size()) {
		if(s[i]!=t[i])ans++;
	}
	cout << ans;	
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


Measured memory_bytes: 3772
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	vector<ll> n(5);
	cin >> N;
	rep(i, N) {
		string S;
		cin >> S;
		if (S.at(0) == 'M') {
			n.at(0)++;
		}
		if (S.at(0) == 'A') {
			n.at(1)++;
		}
		if (S.at(0) == 'R') {
			n.at(2)++;
		}
		if (S.at(0) == 'C') {
			n.at(3)++;
		}
		if (S.at(0) == 'H') {
			n.at(4)++;
		}
	}
	ll an = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = i + 1; j < 4; j++) {
			for (int k = j + 1; k < 5; k++) {
				an += n.at(i) * n.at(j) * n.at(k);
			}
		}
	}
	 cout<<an << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	string ss,t;cin>>ss>>t;
	int l=ss.size(),m=t.size();
	bool a=0;
	string ans;
	for(int i=0;i<=l-m;i++){
		int cnt=0;
		string s=ss;
		for(int j=0;j<m;j++){
			if(ss[i+j]==t[j]||ss[i+j]=='?'){
				cnt++;
				s[i+j]=t[j];
			}
		}
		//cout<<s<<"\n";
		if(cnt==m){
			a=1;
			ans=s;
		}
	}
	rep(i,l){
		if(ans[i]=='?') ans[i]='a';
	}
	if(a) cout<<ans<<"\n";
	else cout<<"UNRESTORABLE"<<"\n";

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data = scanner.nextLine();
			String[] dataArray = data.split(" ");

			int total = Integer.parseInt(dataArray[0]);
			int legs = Integer.parseInt(dataArray[1]);

			boolean hasPattern = false;
			if (legs % 2 == 0) {
				int min = 2 * total;
				int max = 4 * total;
				if (min <= legs && legs <= max) {
					hasPattern = true;
				}
			}

			System.out.println(hasPattern ? "Yes" : "No");
		}
	}
}

Measured memory_bytes: 35756
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int a,b,c;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	
	cin >> a >> b >> c;
	
	int poisonous=min( a+b+1,c );
	cout << poisonous + b << endl;
	
	
	
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e16+18;
const ll MAX = 100005;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a, b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n, m, arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n, arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len = v.size();
    for(int i = 0; i < len; ++i) {
        s<<v[i];
        if(i < len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len = vv.size();
    for(int i = 0; i < len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    Vec v(4);
    cin>>v[0]>>v[1]>>v[2]>>v[3];
    sort(ALL(v));
    YES((v[0] == 1 && v[1] == 4 && v[2] == 7 && v[3] == 9) );
    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>;

void Main()
{
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, s.size()){
		if(s[i] != t[i]){
			ans++;
		}
	}
	cout << ans << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3804
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
#include<time.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")
#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

string s;
int dp[1111111][2];
int N[1111111];
int n;
const int INF=222222222;

int main(){
  cin>>s;
  n=s.size();
  rep(i,n)N[i]=s[n-1-i]-'0';
  N[n]=0;

  rep(i,n+2)rep(j,2)dp[i][j]=INF;
  dp[0][0]=0;
  rep(i,n+1){
      rep(k,2){
        for(int x=0;x<10;x++){
          if(k){
            if(x-1>=N[i])
              dp[i+1][0]=min(dp[i+1][0],dp[i][k]+x+ x-1-N[i]);
            else
              dp[i+1][1]=min(dp[i+1][1],dp[i][k]+x+ x-1-N[i]+10);
          }
          else{
            if(x>=N[i])
              dp[i+1][0]=min(dp[i+1][0],dp[i][k]+x+ x-N[i]);
            else
              dp[i+1][1]=min(dp[i+1][1],dp[i][k]+x+ x-N[i]+10);
          }

        }
      }
  }
  cout<<dp[n+1][0]<<endl;
  return 0;
}


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

long long int gcd(long long int a, long long int b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

int main() {
	long long int n;
	cin>>n;
  	vector<long long int> a(n);
  	for(long long int i=0;i<n;i++){
    	cin>>a[i];
    }
  	long long int ans=a[0];
  	for(long long int i=1;i<n;i++){
			ans=gcd(ans,a[i]);
    }
  	cout<<ans<<endl;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

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

    vector<int> A;

    for (int i = 0; i <N; i++){
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }

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

    bool flag=true;

    for (int i = 0; i < N-1; i++){
        if(A[i]==A[i+1]){
            cout << "NO";
            flag=false;
            break;
        }
    }

    if(flag==true){
        cout << "YES";
    }
    
    
    return 0;
}


Measured memory_bytes: 1400
#棟、階、部屋の順
house = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

n = int(input())

i = 0
while i < n:
    b, f, r, v = map(int, input().split())
    #左から棟、階、部屋
    house[b-1][f-1][r-1] += v
    i += 1

###出力方法だけ写経した
x = 0

for i in range(4):
    if x != 0:
        print("#"*20)
    x += 1

    for a in range(3):
        for b in range(10):
            print(" %d"%(house[i][a][b]),end = "")
        print()



Measured memory_bytes: 5620
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val (t, a) = readLine()?.split(" ")?.map { it.toInt() } ?: return
    val hList = readLine()?.split(" ")?.map { it.toInt() } ?: return

    var resultH = 0
    var minDiff = Double.MAX_VALUE
    for ((i, h) in hList.withIndex()) {
        val temperature = t - h * 0.006
        val diff = Math.abs(temperature - a)
        if (diff < minDiff) {
            resultH = i + 1
            minDiff = diff
        }
    }
    println(resultH)
}

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

typedef long long ll;
//Ans=(  ( n - m ) *100 + (m)*1900  )*(2^m)

ll qpow(ll a,ll b) {
	ll ans=1;
	while(b) {
		if(b) {
			ans*=a;
		}
		b--;
	}
	return ans;
}

int main() {
	ll n,m;
	scanf("%lld%lld",&n,&m);
	ll ans;
	ans=(( (n-m) * 100 )+ m * 1900 )*qpow(2,m);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
#define ll long long int
#define pb push_back
int main() {
	ll i,j,k,c=0,n,m,d=0;
	string x,y,z;
	cin>>x>>y>>z;
	cout<<x[0]<<y[1]<<z[2];
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <stdlib.h>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <iostream>
#include <functional>
#include <cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  int N;
  int start_x = 0;
  int start_y = 0;
  int end_x, end_y, delta_x, delta_y;
  int t_past=0;
  int t_delta,t_now, delta_dist;

  scanf("%d\n", &N );
  while(scanf("%d %d %d\n",&t_now, &end_x, &end_y )!=EOF){
    delta_x = abs(end_x - start_x);
    delta_y = abs(end_y - start_y);
    delta_dist = delta_x + delta_y;
    t_delta = t_now - t_past;
      if(delta_dist%2 == t_delta%2 && delta_dist<=t_delta){
        start_x = end_x;
        start_y = end_y;
        t_past = t_now;
        continue;
      }else{
        printf("No\n");
        return 0;
      }
}
  printf("Yes\n");
	return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF 1000000001
#define MOD 998244353
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

int main(){
  string S;
  cin>>S;
  bool all=true;
  for(int i=0;i<S.size()-1;i++){
    if(S[i]!=S[i+1])all=false;
  }
  if(all){
    cout<<S.size()<<endl;
    return 0;
  }
  vector<int>c; //変化点の手前側
  for(int i=0;i<S.size()-1;i++)if(S[i]!=S[i+1])c.push_back(i);
  int Min = INF;
  for(int i=0;i<c.size();i++)Min=min(Min,max(c[i]+1,(int)(S.size()-c[i]-1)));
  cout<<Min<<endl;
  return 0;
}



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

using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  int a;
  string s;
  cin >> a;
  cin >> s;

  if(a>=3200) {
    cout << s << endl;
  }

  else if (a<3200) {
    cout << "red" << endl;
  }
  return 0;
}


Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main(){
	int a, b;
	while (cin >> a >> b){
		if (a == 0 && b == 0)return 0;
		int n;
		cin >> n;
		bool b0[20][20] = { false };
		int t[20][20];
		for (int i = 0; i < n; i++){
			int q, w; cin >> q >> w;
			b0[q][w] = true;
		}
		for (int i = 0; i < a + 1; i++){
			for (int j = 0; j < b + 1; j++) {
				if (i == 0 || j == 0)t[i][j] = 0;
				else if (b0[i][j])t[i][j] = 0;
				else if (i == 1 && j == 1)t[i][j] = 1;
				else t[i][j] = t[i - 1][j] + t[i][j - 1];
			}
		}
		cout << t[a][b] << endl;
	}
}

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1e15;
const double eps = 1e-6;
const ll MOD = 1000000007;
/*
class Node {
public:
	vector<P> frontier;
	Node* use;
	Node* unuse;
	Node(vector<P> fr) : frontier(fr) {}
	bool operator < (const Node &n) const {
		return frontier < n.frontier;
	}
};

ll solve(int n) {
	vector<Node> nodes;
	map<Node, int> node_num;

}

int main() {
	int n;
	cin >> n;
	cout << n << "x" << n << " := " << solve(n) << " 通り" << endl;
	return 0;
}
*/

int main() {
	ll n, m;
	cin >> n >> m;
	vector<string> area(m);
	for (int i = 0;i < m;i++)
		cin >> area[i];
	vector<int> cnt(n);
	for (int i = 0;i < m;i++)
		for (int j = 0;j < n;j++)
			if (area[i][j] == 'W')
				cnt[j]++;
			else
				cnt[j]--;
	vector<int> imos(n + 2);
	for (int i = 0;i < n;i++)
		imos[i + 1] = imos[i] + cnt[i];
	P ans = P(-1, -1);
	for (int i = 0;i <= n;i++)
		ans = max(ans, P(imos[i], -i));
	cout << -ans.second << " " << -ans.second + 1 << endl;
	return 0;
}



Measured memory_bytes: 4532
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	int N, H, A;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		H = nextInt();
		A = nextInt();

		int res = 0;
		if(H % A == 0) {
			res = H / A;
		}else {
			res = H / A + 1;
		}
		out.println(res);
	}

	static long modpow(long a, long n, long mod) {
	    long res = 1;
	    while (n > 0) {
	        if ((n & 1) != 0) res = res * a % mod;
	        a = a * a % mod;
	        n >>= 1;
	    }
	    return res;
	}
	static long modinv(long a, long mod) {
	    return modpow(a, mod - 2, mod);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}

	long lcm(long m, long n) {
	        return m * n / gcd(m, n);
	}

	private final int[] sizeTable = {
	        9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, Integer.MAX_VALUE
	};

	public int stringSize(int x) {
	    for (int i = 0;; i++)
	        if (x <= sizeTable[i])
	            return i + 1;
	}
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
 int main()
{	

	lli i,j,k,l,n,n1,a,b,m,q,count=0,flag=0;
	string s;
	cin >> s;
	for(i=0;i<s.size();i++){
		if(s[i]=='7'){
			flag=1;
			cout << "Yes" << '\n';
			break;
		}
	}
	if(flag==0)cout << "No" << '\n';

return 0;}


Measured memory_bytes: 3620
import sys


denum = 39

ds = [pow(2, i) for i in range(denum)]
max_ds = sum(ds)

N = input()
rr = []
for line in sys.stdin:
    x, y = line.strip().split(" ")
    rr.append((int(x) + int(y), int(x) - int(y)))

md = rr[0][0] % 2
if md == 0:
    ds = [1] + ds
Rresult = []
for u, v in rr:
    if u % 2 != md:
        result = "-1"
        break
    result = ""
    if md == 0:
        result = result + "R"
        u -= 1
        v -= 1
    u = (u + max_ds) // 2
    v = (v + max_ds) // 2
    binu = bin(u)[2:][::-1]
    binv = bin(v)[2:][::-1]
    for i in range(denum):
        ui = 0
        if i < len(binu):
            ui = int(binu[i])
        vi = 0
        if i < len(binv):
            vi = int(binv[i])
        #print(ui, vi)
        if ui == 1 and vi == 1:
            result = result + "R"
        if ui == 0 and vi == 0:
            result = result + "L"
        if ui == 1 and vi == 0:
            result = result + "U"
        if ui == 0 and vi == 1:
            result = result + "D"
    Rresult.append(result)

ds = [str(x) for x in ds]
if result == "-1":
    print(result)
else:
    print(len(Rresult[0]))
    print(' '.join(ds))
    print("\n".join(Rresult))


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int N;
    cin>>N;
    vector<ll> A(N),sum(N),pro(N,-1);
    set<ll> Se;
    rep(i,N){
        cin>>A[i];
        A[i]--;
        sum[A[i]]++;
        Se.insert(A[i]);
    }
    ll ans=0;
    for(auto x:Se){
        pro[x]=sum[x]*(sum[x]-1)/2;
        //cout<<x<<" "<<pro[x]<<endl;
        ans+=pro[x];
    }
    ll res=0;
    for(auto x:A){
        cout<<ans-pro[x]+(sum[x]-1)*(sum[x]-2)/2<<endl;
    }

    return 0;
}

//a=97,z=122

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

int main()
{
	char c,a = 'a',e = 'e',i = 'i',o = 'o',u = 'u';
	scanf("%c",&c);
	if(c == a||c == e||c == i||c == o||c == u)
		printf("vowel");
	else printf("consonant");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int p[1000005];
 
int getSum(int* BIT,int idx){
	int sum=0;
	while(idx>0){
		sum+=BIT[idx];
		idx-=(idx&-idx);
	}
	return sum;
}
 
void update(int* BIT,int N,int idx,int val){
	while(idx<=N){
		BIT[idx]+=val;
		idx+=(idx&-idx);
	}
	return;
}
 
int main() {
	memset(p,0,sizeof(p));
	
	int N,i;
	scanf("%d",&N);
	int Q;
	scanf("%d",&Q);

	int A[N+1];
	for(i=1;i<=N;i++)
	scanf("%d",&A[i]);
	
	int *BIT=new int[N+1];
	for(i=0;i<=N;i++)
	BIT[i]=0;
	
	
	vector<pair<int,pair<int,int> > > queries(Q);
	for(i=0;i<Q;i++){
		scanf("%d %d",&queries[i].second.first,&queries[i].first);
		queries[i].second.second=i;
	}
	vector<int> ans(Q,0);
	sort(queries.begin(),queries.end());
	int j=0;
	for(i=1;i<=N;i++){
		if(p[A[i]]>0)
		update(BIT,N,p[A[i]],-1);
		p[A[i]]=i;
		update(BIT,N,i,1);
		while(j<Q&&queries[j].first==i){
			ans[queries[j].second.second]=getSum(BIT,i)-getSum(BIT,queries[j].second.first-1);
			++j;
		}
		if(j==Q)
		break;
	}
	
	for(int i=0;i<Q;i++)
	printf("%d\n",ans[i]);
	// your code goes here
	return 0;
} 


Measured memory_bytes: 19352
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s, n;
  cin >> s;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == n[i]) ans++;
  }
  return cout << ans, 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
const int maxn = 9e5+5;
const int inf = 1e9;

int main(){
	int n,a,b;
	int A = 0 , B = 0 , C = 0;

	cin >> n >> a >> b;

	int now;
	for(int i = 1 ; i <= n ; i++){
		cin >> now;
		if(now <= a)A++;
		else if(now <= b)B++;
		else C++;
	}
	cout << min(A,min(B,C));
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;


int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x=a+b;
    int y=c+d;
    string s;
    if(x==y) s="Balanced";
    else if(x<y) s="Right";
    else s="Left";
    
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
 int n;
 cin >> n;
 if(n < 1000)cout << "ABC" << endl;
 else cout << "ABD" << endl;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string s,t;
    cin>>s>>t;
    cout<<t<<s<<endl;
    
    return 0;
}

Measured memory_bytes: 256
//Krunal_Mathukiya
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define li long int
#define pb push_back
#define mkp make_pair
#define nikalL return
#define chalavo continue
#define basHo break
#define umap unordered_map
#define vi vector<int>
#define fr(i,s,n) for(int i=s;i<=n;++i)
#define frr(i,s,n) for(int i=s;i>=n;--i)
#define jaldiKarNe ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
int n;
vi g[100005];
li dp[100005][2];
int vis[100005][2];
// last : was my parent black?
li fn(int node,int par,int last) {
	if(vis[node][last]) return dp[node][last];
	vis[node][last]=1;
	if(par && g[node].size()==1) {
		if(last) return dp[node][last]=1;
		else return dp[node][last]=2;
	}
	li b=1,w=1;
	for(auto child:g[node]) {
		if(child==par) continue;
		li black=0,white=0;
		white=fn(child,node,0);
		if(!last) black=fn(child,node,1);
		b=(b*black)%mod;
		w=(w*white)%mod;
	}
	return dp[node][last]=(b+w)%mod;
}
int main() {
	jaldiKarNe;
	cin>>n;
	fr(i,1,n-1) {
		int u,v;
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
	}
	int leaf=-1;
	fr(i,1,n) {
		if(g[i].size()==1) {
			leaf=i;
			break;
		}
	}
	if(n==1) cout<<"2\n";
	else cout<<fn(leaf,0,0);
}

Measured memory_bytes: 20720
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }

    let red = s.iter().filter(|&&c| c == '0').count();
    let blue = s.len() - red;
    println!("{}", std::cmp::min(blue, red) * 2);
}


Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		
		Scanner scan = new Scanner(System.in);
		int number = scan.nextInt();
		int length = scan.nextInt();
		String[] ary = new String[number];
		
		for (int i = 0; i < number; i++) {
			ary[i] = scan.next();
		}

		scan.close();
		Arrays.sort(ary);
		
		for (String str : ary) {
			System.out.print(str);
		}
	}
}

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

int main(){
    int64_t H,W;
    cin >> H >> W;
    int64_t h,w;

    
    if(H%2==1){
        h = H/2 + 1;
    }else{
        h = H/2;
    }
    
    if(W%2==1){
        w = W/2 + 1;
    }else{
        w = W/2;
    }

    
    if(W == 0){
        cout << 0;
        exit(0);
    }else if(H==1 or W==1){
        cout << 1;
        exit(0);
    }
    
    
    if(H%2 == 1 and W%2 == 0){
        cout << h*w + (h-1)*w;
    }else if(W%2 == 1 and H%2 == 0){
        cout << h*w + (w-1)*h;
    }else if(H%2 == 1 and W%2 == 1){
        cout << h*w + (h-1)*(w-1);
    }else{
        cout << h*w + h*w;
    }
}

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

int main() {
	
	int n;
	cin >> n;
	
	vector<string> s(n);
	map<string, ll> smap;
	ll ans = 0;
	rep(i, n){
		cin >> s.at(i);
		sort(s.at(i).begin(), s.at(i).end());
		smap[s.at(i)]++;
	}
	
	for(auto p: smap){
		ans += p.second * (p.second - 1) / 2;
	}
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

const ll INF = 1ll<<60;
// Dinic http://www.prefield.com/algorithm/graph/dinic.html
struct dinic{
  struct edge{int to;ll cost;};
  int n;
  vector< vector<edge> > G;
  vector<vl> flow, capacity;
#define RESIDUE(s,t) (capacity[s][t]-flow[s][t])
  vi level;
  vector<bool> finished;
  dinic(int _n){
    n = _n;
    G.assign(n,vector<edge>());
    flow.assign(n,vl(n,0));
    capacity.assign(n,vl(n,0));
    level.assign(n,0);
    finished.assign(n,false);
  }
  void add_edge(int from,int to,ll cost){
    assert(0<=from && from<n);
    assert(0<=to && to<n);
    G[from].push_back((edge){to,cost});
    G[to].push_back((edge){from,0ll});  // 逆に流すフローのためのダミー辺
  }
  ll dfs(int u, int t, ll cur){
    if(u==t || cur==0) return cur;
    if(finished[u]) return 0;
    finished[u] = true;
    REP(i,G[u].size()){
      edge e = G[u][i];
      if(level[e.to] > level[u]){
        ll f = dfs(e.to, t, min(cur, RESIDUE(u,e.to)));
        if(f>0){
          flow[u][e.to] += f;
          flow[e.to][u] -= f;
          finished[u] = false;
          return f;
        }
      }
    }
    return 0;
  }
  ll calc(int s, int t){
    REP(i,n)REP(j,n)flow[i][j]=capacity[i][j]=0;
    REP(u,n)REP(j,G[u].size()){
      edge e = G[u][j];
      capacity[u][e.to] += e.cost;
    }
    ll total = 0;
    while(true){
      REP(i,n)level[i] = -1;
      level[s] = 0;
      queue<int> Q; Q.push(s);
      int d = n;
      while(!Q.empty()){
        int u = Q.front(); Q.pop();
        REP(i,G[u].size()){
          edge e = G[u][i];
          if(RESIDUE(u,e.to) > 0 && level[e.to] == -1){
            Q.push(e.to);
            level[e.to] = level[u] + 1;
          }
        }
      }
      REP(i,n)finished[i]=false;
      bool flag = false;
      while(true){
        ll f = dfs(s,t,INF);
        if(f==0)break;
        total += f;
        flag = true;
      }
      if(!flag)break;
    }
    return total;
  }
};

int n,m;
char u[525];

int main(){
  scanf("%d%d",&n,&m);
  dinic D(n+2);
  const int S = n;
  const int T = n+1;
  scanf("%s",u);
  REP(i,n){
    int a;
    scanf("%d",&a);
    if(u[i]=='L'){
      D.add_edge(S,i,0);
      D.add_edge(i,T,a);
    }else{
      D.add_edge(S,i,a);
      D.add_edge(i,T,0);
    }
  }
  REP(i,m){
    int s,t,b;
    scanf("%d%d%d",&s,&t,&b);
    --s;--t;
    if(s>t)swap(s,t);
    D.add_edge(s,t,b);
  }
  printf("%lld\n",D.calc(S,T));
  return 0;
}



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

int main() {
	ll n,count=0;
	cin>>n;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			if(n/i-1>i) count+=n/i-1;
			else break;
		}
	}
	cout<<count<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import sys
import socket

if socket.gethostname() in ['N551J', 'F551C']:
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    s = read_str()
    n = len(s)
    res = 0
    w = 0
    for i in range(n - 1, -1, -1):
        if s[i] == 'B':
            res += w
        else:
            w += 1
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4264
#include<stdio.h>
#include<math.h>

int main(){
  int n;
  int i;
  
scanf("%d",&n);
 
  int A[n+1];

  for( i = 1; i <= n ; i++ ) scanf("%d",&A[i]);

  for( i = 1 ; i <= n ; i++ )
    {
    printf("node %d: key = %d, ",i,A[i]);
    if( (int)floor(i/2) != 0 ) printf("parent key = %d, ",A[((int)floor(i/2))]);
    if( 2*i <= n ) printf("left key = %d, ",A[2*i]);
    if( (2*i+1) <= n ) printf("right key = %d, ",A[(2*i+1)]);
    printf("\n");
    }      

  return 0;
}

Measured memory_bytes: 600
import qualified Data.Vector.Primitive as V
import qualified Data.Vector.Primitive.Mutable as V
import Control.Monad
import Control.Monad.State.Strict

readInts :: IO [Int]
readInts = map read . words <$> getLine

main = do

    n:q:_ <- readInts
    text <- V.fromList <$> getLine
    qs <- replicateM q readInts
    
    let table = flip evalState (0 :: Int) . V.generateM n $ \i ->
            if i /= 0 && text V.! (i-1) == 'A' && text V.! i == 'C'
            then modify' succ >> get
            else get

    forM_ qs $ \[s, e] -> print $ table V.! pred e - table V.! pred s

Measured memory_bytes: 82812
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <numeric>


using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using pari=pair<lolo, lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORIT(it,v) for (auto it=v.begin(); it!=v.end(); ++it)
#define FORANGE(it, v) for (auto it : v)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define ALL(x) x.begin(), x.end()

int main()
{
	lolo A,P;
	cin >> A >> P;
	lolo kakera = A * 3 + P;
	lolo apple_pie = kakera / 2;
	cout << apple_pie << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

    if((a+b)%2) cout<<"IMPOSSIBLE"<<endl;
    else cout<<abs((a+b)/2)<<endl;

	return 0; 
}


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

int main()
{
    int a;
    std::cin>> a;
    std::vector< std::string > word_data( a );

    for( int i = 0; i < a; i++ )
    {
        std::cin>> word_data[i];
        std::sort( word_data[i].begin(), word_data[i].end() );
    }

    std::sort( word_data.begin(), word_data.end() );

    int64_t count = 0;
    
    for( int i = 0; i < a; i++ )
    {
        int64_t word_count = 0;
        std::string word = word_data[i];
        
        for( int r = i; r < a; r++ )
        {
            if( word == word_data[r] )
            {
                word_count += 1;
            }
            else
            {
                break;
            }
        }

        if( word_count != 1 )
        {
            count += ( word_count * ( word_count - 1 ) )/ 2;
            i += word_count - 1;
        }
    }

    std::cout<< count;
}


Measured memory_bytes: 7296
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
double N;

int main() {
  INCANT;
  cin >> N;
  cout << 2*N*PI << "\n";
  return 0;
}

Measured memory_bytes: 3804