akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <bitset>
#include <complex>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

double dist(PDD p1, PDD p2) {
	return hypot(p1.first - p2.first, p1.second - p2.second);
}

struct circle {
	double x, y, r;
};

const double gosa = 0.000001;

int main() {
	double d1, d2, d3, d4, d5, d6; cin >> d1 >> d2 >> d3 >> d4 >> d5 >> d6;
	circle c1 = { d1,d2,d3 }, c2 = { d4,d5,d6 };

	int ans = -1;

	double dis = dist(mp(c1.x, c1.y), mp(c2.x, c2.y));
	if (abs(dis - (c1.r + c2.r)) < gosa)ans = 3;
	else if (abs(max(c1.r, c2.r) - (dis + min(c1.r, c2.r))) < gosa)ans = 1;
	else if (dis > c1.r + c2.r)ans = 4;
	else if (max(c1.r, c2.r) > dis + min(c1.r, c2.r))ans = 0;
	else ans = 2;

	Cout(ans);
}


Measured memory_bytes: 3292
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

const ll MOD = 1e9+7;
const ll INF = 1e18+7;

signed main(){
	ll k, a, b;
	cin >> k >> a >> b;
	if(k <= a || b - a < 2){
		cout << k + 1 << endl;
		return 0;
	}
	k -= a - 1;
	// 永遠に交換してればよい
	ll cou = k / 2;
	ll ans = a;
	ans += (b - a) * cou;
	if(k % 2){
		++ans;
	}
	cout << ans << endl;

	return 0;
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

vector<lint> fact, inv;

lint power(lint x, lint n){
    lint res = 1;
    while(n > 0){
        if(n & 1){
            res *= x;
            res %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;
    }
    return res;
}

lint comb(lint n, lint r){
    return fact[n] * ((inv[r] * inv[n-r]) % MOD) % MOD;
}

int main(){
    lint h, w, a, b;
    cin >> h >> w >> a >> b;
    lint siz = h + w + 5;
    fact.resize(siz);
    inv.resize(siz);
    fact[0] = 1;
    inv[0] = 1;
    REP(i, 1, siz){
        fact[i] = i * fact[i-1];
        fact[i] %= MOD;
        inv[i] = power(fact[i], MOD - 2);
    }
    lint ans = 0;
    REP(i, b, w){
        ans += comb(i+h-a-1, i) * comb(w-i-1+a-1, w-i-1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(ll i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll a, b;
	cin >> a >> b;
	
	if (a == b) {
		cout << a << endl;
		return 0;
	}
	
	ll fb = 0;
	while (b > 0) {
//		cout << "   " << b << endl;
		if (b == 1) {
			fb += 1;
			break;
		}
		if (b == 2) {
			fb += 3;
			break;
		}
		if (b == 3) {
			break;
		}
		rep(i, 100) {
//			cout << i << endl;
			if (pow(2LL, i) == b) {
				fb += b;
				b = 0;
				break;
			} else if (b == pow(2LL, i + 1) - 1) {
				b = 0;
				break;
			} else if (pow(2LL, i) < b and b < pow(2LL, i + 1) - 1) {
//				cout << " " << pow(2LL, i) << endl;
//				cout << "      " << fmod(b - pow(2LL, i) - 1, 2LL) << endl;
				fb += fmod(b - pow(2LL, i) - 1, 2LL) * pow(2LL, i);
//				cout << fmod(b - pow(2LL, i) - 1, 2LL) * pow(2LL, i) << " " << fb << endl;
				b -= pow(2LL, i);
				break;
			}
		}
	}
//	cout << fb << endl;
//	cout << "break" << endl;
	
	if (a == 0) {
		cout << fb << endl;
		return 0;
	}
	
	ll fa = 0;
	a--;
	while (a > 0) {
//		cout << "   " << a << endl;
		if (a == 1) {
			fa += 1;
			break;
		}
		if (a == 2) {
			fa += 3;
			break;
		}
		if (a == 3) {
			break;
		}
		rep(i, 100) {
//			cout << i << endl;
			if (pow(2LL, i) == a) {
				fa += a;
				a = 0;
				break;
			} else if (a == pow(2LL, i + 1) - 1) {
				a = 0;
				break;
			} else if (pow(2LL, i) < a and a < pow(2LL, i + 1) - 1) {
//				cout << " " << pow(2LL, i) << endl;
//				cout << "      " << fmod(a - pow(2LL, i) - 1, 2LL) << endl;
				fa += fmod(a - pow(2LL, i) - 1, 2LL) * pow(2LL, i);
//				cout << fmod(a - pow(2LL, i) - 1, 2LL) * pow(2LL, i) << " " << fa << endl;
				a -= pow(2LL, i);
				break;
			}
		}
	}
//	cout << fa << endl;
	
	cout << (fb xor fa) << endl;
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque
from itertools import product
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def solve(N, K, A):
    # 先手が勝つ: True, 先手が負ける: False
    dp = [False for i in range(K+1)]
    # 石が残りmin(A)未満のとき、操作不可のため負け
    for i in range(min(A)):
        dp[i] = False
    for i in range(min(A), K+1):
        for a in A:
            if i - a >= 0:
                dp[i] |= not dp[i - a]
    return 'First' if dp[K] else 'Second'


if __name__ == "__main__":
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 4212
#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
typedef long long ll;
#include<cmath>
int main(){
    ll N;
    cin >> N;
    vector<ll> A;
    rep(i,0,N) {
        ll temp;
        cin >> temp;
        A.pb(temp);
    }
    ll min = *min_element(A.begin(), A.end());
    ll max = *max_element(A.begin(), A.end());

    cout << abs(max - min) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main (void) {
    int N;
    int x;

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

    ll ans = 0;
    if (a[0] > x) {
        ans = a[0] - x;
        a[0] = x;
    }
    for (int i = 0; i < N - 1; i++) {
        if (a[i] + a[i + 1] > x) {
            ans += a[i] + a[i + 1] - x;
            a[i + 1] -= a[i] + a[i + 1] - x;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
class UnionFind
  def initialize(n)
    @size = Array.new(n + 1, 1)
    @rank = Array.new(n + 1, 0)
    @parent = []

    (0..n).each do |i|
      @parent[i] = i
    end
  end

  def find(x)
    if @parent[x] == x
      x
    else
      @parent[x] = find(@parent[x])
    end
  end

  def unite(x, y)
    x = find(x)
    y = find(y)
    return if x == y

    if @rank[x] < @rank[y]
      @parent[x] = y
      @size[y] += @size[x]
    else
      @parent[y] = x
      @size[x] += @size[y]

      @rank[x] += 1 if @rank[x] == @rank[y]
    end
  end

  def same?(x, y)
    find(x) == find(y)
  end

  def size(x)
    @size[find(x)]
  end
end

N, M, K = gets.split.map(&:to_i)
A = M.times.map { gets.split.map(&:to_i) }
B = K.times.map { gets.split.map(&:to_i) }
E = Hash.new { |h, k| h[k] = {} }
uf = UnionFind.new(N + 1)

A.each do |a, b|
  E[a][b] = E[b][a] = true
  uf.unite(a, b)
end

block_cnt = Hash.new(0)

B.each do |c, d|
  if uf.same?(c, d)
    block_cnt[c] += 1
    block_cnt[d] += 1
  end
end

puts (1..N).map { |i| uf.size(uf.find(i)) - E[i].size - block_cnt[i] - 1 }.join(' ')


Measured memory_bytes: 64576
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x;
    cin >> x;
    ll k;
    cin >> k;
    ll d;
    cin >> d;
    ll k2=k%2;
    ll times=(abs(x)/d)%2;
    if(log10(k)+log10(d)>17){
        x=x%d;
        if(x>=0&&(times+k2)%2==1){
            x-=d;
        }
        else if(x<0&&(times+k2)%2==1){
            x+=d;
        }
        cout<<abs(x)<<endl;
    }else{
        ll y=k*d;
        if(y>abs(x)){
            x=x%d;
            if(x>=0&&(times+k2)%2==1){
                x-=d;
            }
            else if(x<0&&(times+k2)%2==1){
                x+=d;
            }
            cout<<abs(x)<<endl;
        }else{
            if(x>0) cout<<abs(x-y)<<endl;
            else cout<<abs(x+y)<<endl;
        }
    }
}

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

using ll = long long;
const int mod = 1e9+7;

int add (int a, int b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

int mul (ll a, ll b) {
	a *= b;
	if (a >= mod) a %= mod;
	return a;
}

vector <int> cnt(26);
int ans;

void rec (int in, int res) {
	if (in == 26) {
		ans = add(ans, res);
		return;
	}
	rec (in+1, res);
	rec (in+1, mul(res, cnt[in]));
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	string s;
	cin >> n >> s;
	for (int i=0; i<n; i++) {
		cnt[s[i]-'a'] ++;
	}
	rec (0, 1);
	ans --;
	if (ans < 0) ans += mod;
	cout << ans;
	return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100100;

int A[MAX];

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

string f = "First";
string s = "Second";

void F()
{
	cout<<f<<endl;
	exit(0);
}

void S()
{
	cout<<s<<endl;
	exit(0);
}


int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);
	FOR (i, 0, n)
	{
		scanf("%d", &A[i]);
	}

	while(true)
	{
		int p = 0;
		int np = 0;
		int ind = -1;
		FOR (i, 0, n)
		{
			if (A[i] % 2 == 0) p++;
			else np++, ind = i;
		}

		if (p % 2 == 1) F();

		if (np == 1)
		{
			if (A[ind] == 1) S();

			A[ind]--;
			int g = 0;
			FOR (i, 0, n)
			{
				g = gcd(g, A[i]);
			}

			FOR (i, 0, n)
			{
				A[i] /= g;
			}

			swap(f, s);

			continue;
		}

		S();
	}

}


Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let s = get!(u32);
    let f = s / 100;
    let b = s % 100;
    //eprintln!("f: {}, b: {}", f, b);
    if (0 < f && f <= 12) && (0 < b && b <= 12) {
        println!("AMBIGUOUS");
    } else if (0 < f && f <= 12) && !(0 < b && b <= 12) {
        println!("MMYY");
    } else if !(0 < f && f <= 12) && (0 < b && b <= 12) {
        println!("YYMM");
    } else {
        println!("NA");
    }
}


Measured memory_bytes: 4352
def main():
    X=int(input())
    if X==1 or X==2 or X==3:
        print(1)
    else:
        li=[]
        for p in range(2,10):
            for n in range(2,100):
                if n**p<=X:
                    li.append(n**p)
                else:
                    break
        li.sort(reverse=True)
        print(li[0])
if __name__=="__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  ll n, ww;
  cin >> n >> ww;
  vll w(n), v(n);
  for (ll i = 0; i < n; i++) cin >> w[i] >> v[i];
  ll dp[100001];
  vector<vll> check(100001, vll(0));
  vll x(n, 0);
  check[0] = x;
  for (ll i = 1; i <= ww; i++) {
    dp[i] = dp[i - 1];
    ll memo = -1;
    for (ll j = 0; j < n; j++) {
      if (i < w[j]) continue;
      if (check[i - w[j]][j] == 1) continue;
      if (dp[i] < dp[i - w[j]] + v[j]) {
        dp[i] = dp[i - w[j]] + v[j];
        memo = j;
      }
    }
    if (memo != -1) {
      check[i] = check[i - w[memo]];
      check[i][memo] = 1;
    }
    else check[i] = check[i - 1];
  }
  cout << dp[ww] << endl;
}

Measured memory_bytes: 83072
A, B, K = map(int,input().split())
if B - A < 2 * K:
    for i in range(A, B + 1):
        print(i)
else:
    for i in range(A, A + K):
        print(i)
    for i in range(B - K + 1, B + 1):
        print(i)

Measured memory_bytes: 3060
#include <stdio.h>
#define inf 1145141919

int minim(int x,int y){if(x < y){return x;}return y;}

int main(void) {
	int i,j,n,m,t,length[1024],dp[1024][1024]={inf};//dp[day][point]
	for(i = 0;i <= 1023;i++){
		for(j = 0;j <= 1023;j++){if(j == 0){dp[i][j] = 0;}else{dp[i][j] = inf;}}
	}
	scanf("%d%d",&n,&m);
	for(i = 1;i <= n;i++){scanf("%d",&length[i]);}
	for(i = 1;i <= m;i++){
		scanf("%d",&t);
		for(j = 1;j <= i;j++){
			dp[i][j] = minim(dp[i-1][j],dp[i-1][j-1]+length[j]*t);
		}
	}
	printf("%d\n",dp[m][n]);
	return 0;
}

Measured memory_bytes: 4704
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;i++)
using namespace std;
const int N=1e5+5;
inline int read(){
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,a[N],ans;
bool cmp(int x,int y){return x>y;}
int main(){
	n=read();
	inc(i,1,n) a[i]=read();
	sort(a+1,a+1+n,cmp);
	inc(i,1,n){
		if(a[i+1]<i+1){
			ans=(a[i]-i)%2;
			int pd=0;
			inc(j,i+1,n) if(a[j]==i) pd++;
			ans=max(ans,pd%2);
			break;
		}
	}
	if(ans) puts("First");
	else puts("Second");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<vector<vector<char> >,int> P;
const long long int MOD = 1000000007;
const int INF = 1000000000;

int w, h;
int ww[10000], ee[10000];
int sw[10000], se[10000];

int main(){
    cin >> w >> h;
    rep(i,h){
        rep(j,w){
            char hoge;
            cin >> hoge;
            if(hoge == 'W') ww[j]++;
            else ee[j]++;
        }
    }
    rep(j,w){
        if(j == 0){
            sw[j] = ww[j];
            continue;
        }
        sw[j] = sw[j-1]+ww[j];
    }
    for(int j = w-1; j >= 0; j--){
        if(j == w-1){
            se[j] = ee[j];
            continue;
        }
        se[j] = se[j+1]+ee[j];
    }
    int ans = h*w-se[0];
    int pos = 0;
    rep(i,w-1){
        int cnt = (i+1)*h-sw[i]+(w-i-1)*h-se[i+1];
        if(ans > cnt){
            ans = cnt;
            pos = i+1;
        }
    }
    if(ans > h*w-sw[w-1]){
        pos = w;
    }
    cout << pos << " " << pos+1 << endl;
}

Measured memory_bytes: 3252
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#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 <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    int N;cin >> N;
    vector<long long> A(N),B(N);
    for(int i = 0;i<N;i++){
        cin >> A.at(i) >> B.at(i);
    }
    long long plus = 0;
    long long ans = 0;
    for(int i = N-1;i>=0;i--){
        if((A.at(i)+plus) % B.at(i) == 0) continue;
        ans += B.at(i)-((A.at(i)+plus) % B.at(i));
        plus += B.at(i)-((A.at(i)+plus) % B.at(i));
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, d = map(int, input().split())
    ans = 0
    for i in range(n):
        x, y = map(int, input().split())
        if x**2 + y**2 <= d**2:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 68700
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const double EPS = 1e-10;

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

    // 得点
    int R, S, P;
    cin >> R >> S >> P;

    string T;
    cin >> T;

    vector<char> log(N);
    vector<int> ans(N, 0);

    int i;
    for (i = 0; i < K; i++)
    {
        if (T[i] == 'r')
        {
            ans[i] = P;
            log[i] = 'p';
        }
        else if (T[i] == 's')
        {
            ans[i] = R;
            log[i] = 'r';
        }
        else
        {
            ans[i] = S;
            log[i] = 's';
        }
    }
    // K ~ MAX - K
    for (; i < T.size() - K; i++)
    {
        if (T[i] == 'r')
        {
            if (log[i - K] != 'p')
            {
                ans[i] = P;
                log[i] = 'p';
            }
            else
            {
                log[i] = T[i + K];
            }
        }
        else if (T[i] == 's')
        {
            if (log[i - K] != 'r')
            {
                ans[i] = R;
                log[i] = 'r';
            }
            else
            {
                log[i] = T[i + K];
            }
        }
        else
        {
            if (log[i - K] != 's')
            {
                ans[i] = S;
                log[i] = 's';
            }
            else
            {
                log[i] = T[i + K];
            }
        }
    }
    for (; i < T.size(); i++)
    {
        if (T[i] == 'r')
        {
            if (log[i - K] != 'p')
            {
                ans[i] = P;
            }
        }
        else if (T[i] == 's')
        {
            if (log[i - K] != 'r')
            {
                ans[i] = R;
            }
        }
        else
        {
            if (log[i - K] != 's')
            {
                ans[i] = S;
            }
        }
    }
    ll all = 0;
    for (int i = 0; i < N; i++)
    {
        // printf("%d ", ans[i]);
        all += ans[i];
    }
    // printf("\n");
    // for (int i = 0; i < N; i++)
    // {
    //     printf("%c ", log[i]);
    // }
    cout << all << endl;
    return (0);
}

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

int main(){
  string S ; 
  cin >> S ; 
  int ans = 0 ; 
  
  for(int i = 0 ; i < S.size() ; i++){
    if(S.at(i) == '+') ans++ ; 
    else ans-- ; 
  }
  cout << ans << endl ; 
}

Measured memory_bytes: 3600
#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(a)  (a).begin(),(a).end()
#define LL long long

int n;
LL k;
LL a[200000];

bool ok(LL st){
  LL cnt=0;
  REP(i,n){
    LL cut = (a[i]-1)/st;
    cnt+=cut;
    //cerr<<st<<" "<<cnt<<endl;
    if(cnt > k)return false;
  }

  return true;
}

int main(){
  cin>>n>>k;
  REP(i,n)cin>>a[i];
  
  LL lb =1,ub = 10e9;
  while(lb < ub){
    LL mid = (lb+ub)/2;
    if(ok(mid)){
      ub = mid;
    }else{
      lb = mid+1;
    }
  }
  cout<<lb<<endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> B.at(i);
  }
  int64_t sum=0;
  int64_t ans=0;
  vector<int> diff;
  for(int i=0;i<N;i++){
    if(A.at(i)>=B.at(i)){
      diff.push_back(A.at(i)-B.at(i));
    }else{
      sum+=B.at(i)-A.at(i);
      ans++;
    }
  }
  sort(diff.begin(),diff.end(),greater<int>());
  for(int i=0;i<diff.size();i++){
    if(sum<=0){
      break;
    }
    sum-=diff.at(i);
    ans++;
  }
  if(sum>0){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1660
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int H,W;
    cin >> H >> W;
    vector<string> s(H+1);
    for(int i=1;i<=H;++i){
        cin >> s[i];
        s[i] = '#' + s[i];
    }

    vector<vector<int>> left(H+2, vector<int>(W+2, 0)), right(H+2, vector<int>(W+2, W+1));
    vector<vector<int>> top(H+2, vector<int>(W+2, 0)), bottom(H+2, vector<int>(W+2, H+1));
    for(int i=1;i<=H;++i) {
        for(int j=1;j<=W;++j) {
            if(s[i][j] == '#') {
                left[i][j] = j;
                top[i][j] = i;
            } else {
                left[i][j] = left[i][j-1];
                top[i][j] = top[i-1][j];
            }
        }
    }
    for(int i=H;i>=1;--i) {
        for(int j=W;j>=1;--j) {
            if(s[i][j] == '#') {
                right[i][j] = j;
                bottom[i][j] = i;
            } else {
                right[i][j] = right[i][j+1];
                bottom[i][j] = bottom[i+1][j];
            }
        }
    }

    int ans = 0;
    for(int i=1;i<=H;++i) {
        for(int j=1;j<=W;++j) {
            if(s[i][j] == '#') continue;
            // cerr << i << ", " << j << ": " << left[i][j] << " " << right[i][j] << " " << top[i][j] << " " << bottom[i][j] << " " << j-left[i][j]+right[i][j]-j+i-top[i][j]+bottom[i][j]-j-3 << endl;
            ans = max(
                ans, 
                j-left[i][j]+right[i][j]-j+i-top[i][j]+bottom[i][j]-i-3
            );
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 67200
#include<iostream>

using namespace std ;

int main()

{
    long long int a ;
    char  s[15];

    cin>>a>>s;



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

    return 0;
}

Measured memory_bytes: 3612
import sys
X, Y = map(int, input().split())
if X*4 < Y:
    print('No')
    sys.exit()
else:
    i, j = 0, X
    while j >= 0:
        if 2*i + 4*j == Y:
            print('Yes')
            sys.exit()
        else:
            i += 1
            j -= 1
    print('No')


Measured memory_bytes: 9180
import sys

#+++++
		
def main():
	b , c = map(int, input().split())
	ret=b+(c//2)
	print(ret)
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k,n;
    cin>>k>>n;
    int a[n];
    f1(i,0,n)
    cin>>a[i];

    int ans = (a[0] - 0) + (k-a[n-1]);
    f1(i,0,n-1)
    {
        ans = max(ans, a[i+1] - a[i]);
    }
    cout<<k-ans<<endl;
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,l;
  cin >> n >> m >> l;
  long long int INF = 1e10;
  vector<vector<long long int>> r(n+1,vector<long long int>(n+1,INF));
  for(int i=1; i<=n; i++) r[i][i] = 0;
  
  for(int i=0; i<m; i++){
    int a,b,c;
    cin >> a >> b >> c;
    r[a][b] = c;
    r[b][a] = c;
  }
  
  for(int k=1; k<=n; k++){
    for(int i=1; i<=n; i++){
      for(int j=1; j<=n; j++){
        r[i][j] = min(r[i][j],r[i][k]+r[k][j]);
        r[j][i] = r[i][j];
      }
    }
  }
  
  vector<vector<long long int>> newr(n+1,vector<long long int>(n+1,INF));
  for(int i=1; i<=n; i++) newr[i][i] = 0;
  
  for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
      if(r[i][j]<=l){
        newr[i][j] = 1;
        newr[j][i] = 1;
      }
    }
  }
  
  for(int k=1; k<=n; k++){
    for(int i=1; i<=n; i++){
      for(int j=1; j<=n; j++){
        newr[i][j] = min(newr[i][j],newr[i][k]+newr[k][j]);
        newr[j][i] = newr[i][j];
      }
    }
  }
  
  int q;
  cin >> q;
  
  for(int i=0; i<q; i++){
    int s,t;
    cin >> s >> t;
    int ans;
    ans = newr[s][t]-1;
    if(ans > 1000) ans=-1;
    cout << ans << endl;
  }
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
        cout << "Possible";
    }
    else{
        cout << "Impossible";
    }
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	if err := io.writer.Flush(); err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	io := NewIo()
	defer io.Flush()
	N := io.Next()
	a := strings.Replace(N, "hi", "", -1)
	if a == "" {
		io.PrintLn("Yes")
		return
	}
	io.PrintLn("No")
}


Measured memory_bytes: 1776
#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>;

int main(){
    int n;
    cin >> n;
    int x[n];
    int max_x=0;
    rep(i, n){
        cin >> x[i];
        max_x=max(max_x, x[i]);
    }

    ll ans=1e9;
    rep(i, max_x){
        ll sum=0;
        rep(j, n){
            sum+=pow(x[j]-(i+1), 2);
        }
        ans=min(ans, sum);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#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 gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {
 
	
	ll N,X;
	cin >> N>>X;
	ll an ;
	
	vector<ll> W(N);
	
	for (ll i = 0; i < N; i++) {
		
		cin >> W.at(i);
		
		
	}
	an = W.at(0)-X;
	for (ll i = 0; i < N; i++) {

		an = gcd(an, W.at(i) - X);

	}
	
	
	cout <<abs(an)<< endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;



struct edge { int to, cost; };
struct dijkstra {
    vector<vector<edge>> g;
    vector<int> d;
    int V;
    
    dijkstra(int v){
        V = v;
        d.resize(V);
        g.resize(V);
    }
    
    void solve_d(int s){
        pq1<pii> que;
        rep(i,V) d[i] = infi;
        d[s] = 0;
        que.push({0,s});
        
        while (!que.empty()) {
            pii p = que.top();
            que.pop();
            int v = p.se;
            if(d[v] < p.fi) continue;
            rep(i,int(g[v].size())){
                edge e = g[v][i];
                if(d[e.to] > d[v] + e.cost){
                    d[e.to] = d[v] + e.cost;
                    que.push({d[e.to],e.to});
                }
            }
        }
    }
    
    int dis(int a){
        return d[a];
    }
};



int main()
{
    int N,M;
    cin >> N >> M;
    dijkstra G(3*N);
    rep(i,M){
        int u,v;
        cin >> u >> v;
        u--,v--;
        G.g[3*u].pb({3*v+1,1});
        G.g[3*u+1].pb({3*v+2,1});
        G.g[3*u+2].pb({3*v,1});
    }
    
    int s,t;
    cin >> s >> t;
    s--,t--;
    G.solve_d(3*s);
    cout << (G.dis(3*t) == infi ? -1 : G.dis(3*t)/3)<< endl;
    

    
    
    
    

    return 0;
}


Measured memory_bytes: 17792
sx, sy, tx, ty = map(int, input().split())

rangex = tx-sx
rangey = ty-sy
# 行ったりきたりで4回
for y in range(rangey):
  print("U", end="")
for x in range(rangex):
  print("R", end="")

# 帰り
for y in range(rangey):
  print("D", end="")
for x in range(rangex):
  print("L", end="")

  
print("L", end="")
for y in range(rangey + 1):
  print("U", end="")
for x in range(rangex + 1):
  print("R", end="")

print("D", end="")

# 帰り
print("R", end="")
for y in range(rangey + 1):
  print("D", end="")
for x in range(rangex+1):
  print("L", end="")

print("U", end="")

Measured memory_bytes: 4468
#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 fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll a[300000];
ll b[300000];
ll c[300000];
ll d[300000];
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

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

  int n;cin>>n;
  for(int i=1;i<=n;i++) {
    ll b;
    cin>>b;
    a[i]=b-i;
  }
  sort(a+1,a+n+1);
  ll median;
  if(n%2==1){
    median=a[n/2+1];
  }else{
    median=(a[n/2] + a[n/2+1])/2;
  }
  // P(median);
  ll sums=0;
  for(int i=1;i<=n;i++){
    ll k=a[i]-median;
    sums+=abs(k);
  }
  P(sums);
  // 1-indexed
  // 四捨五入
  // ll summ=0;
  // for(int i=1;i<=n;i++){
  //   summ+=a[i];
  // }
  // P(summ);
  // ll aa=summ/n;
  // P(aa);
  // ll bs=0,cs=0,ds=0,p1s=0,p2s=0;
  // for(int i=1;i<=n;i++){
  //   ll k=a[i]-aa-2;
  //   p1s+=abs(k);
  // }
  // for(int i=1;i<=n;i++){
  //   b[i]=a[i]-aa-1;
  //   bs+=abs(b[i]);
  // }
  // for(int i=1;i<=n;i++){
  //   c[i]=a[i]-aa;
  //   cs+=abs(c[i]);
  // }
  // for(int i=1;i<=n;i++){
  //   d[i]=a[i]-aa+1;
  //   ds+=abs(d[i]);
  // }
  // for(int i=1;i<=n;i++){
  //   ll k=a[i]-aa+2;
  //   p2s+=abs(k);
  // }
  // P(bs);
  // P(cs);
  // P(ds);
  // ll minn=min(bs, min(cs,ds));
  // ll minn2=min(p1s, p2s);
  // ll minn_all=min(minn, minn2);
  // P(minn_all);
  return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

ll black, white;
void dfs(vector<vector<char>> &S, vector<vector<int>> &used, int sh, int sw, int H, int W){
    used[sh][sw] = 1;
    if((sh + sw) % 2 == 1){
        black++;
    }
    else{
        white++;
    }
    if(sh < H-1 && used[sh+1][sw] == 0 && S[sh+1][sw] == S[sh][sw]){
        dfs(S, used, sh+1, sw, H, W);
    }
    if(sh > 0 && used[sh-1][sw] == 0 && S[sh-1][sw] == S[sh][sw]){
        dfs(S, used, sh-1, sw, H, W);
    }   
    if(sw < W-1 && used[sh][sw+1] == 0 && S[sh][sw+1] == S[sh][sw]){
        dfs(S, used, sh, sw+1, H, W);
    }
    if(sw > 0 && used[sh][sw-1] == 0 && S[sh][sw-1] == S[sh][sw]){
        dfs(S, used, sh, sw-1, H, W);
    }
}

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> S(H, vector<char> (W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if((i+j) % 2 == 0){
                if(S[i][j] == '.'){
                    S[i][j] = '#';
                }
                else{
                    S[i][j] = '.';
                }
            }
        }
    }

    vector<vector<int>> used(H, vector<int> (W, 0));
    bool check = true;
    ll ans = 0;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if(used[i][j] == 1) continue;
            black = 0;
            white = 0;
            dfs(S, used, i, j, H, W);
            ans += black * white;
        }
    }

    printf("%lld\n", ans);
}

Measured memory_bytes: 24292
import java.util.Scanner;

public class Main {

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

	void solve() {
		Scanner sc = new Scanner(System.in);
		for(int i=0;i<3;i++) {
			String S  = sc.next();
			System.out.print(S.substring(i, i+1));
		}
		System.out.println();
		sc.close();
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
vector<pair<int,int>> hen[100000];bool used[100000],t;int s[100000];
void dfs(int a){
     used[a]=true;
     for(auto&& i :hen[a]){
          if(used[i.first]){
               if(s[i.first]!=s[a]+i.second){
                    t=false;
               }
          }else {
               s[i.first]=s[a]+i.second;
               dfs(i.first);
          }
     }
}
     signed main(){
int n,m;
cin>>n>>m;
int l,r,d;
for(int i=0;i<m;i++){
     cin>>l>>r>>d;
     l--;r--;
     hen[l].push_back({r,d});
     hen[r].push_back({l,-d});
}
fill(used,used+n,false);
fill(s,s+n,0);t=true;
for(int i=0;i<n;i++)if(!used[i])dfs(i);
if(t)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
 }

 


 






    





      

        


Measured memory_bytes: 15616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int k;
  string s;
  cin >> k >> s;
  if (s.length()<=k) cout << s << endl;
  else {
    s = s.substr(0,k);
    cout << s << "..." << endl;
  }
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input =new BufferedReader(new InputStreamReader(System.in));
        long N = Long.parseLong(input.readLine());

        BigInteger result = new BigInteger("1");

        BigInteger divider = new BigInteger("1000000007");
        for (int i = 1; i <= N; i++) {
            result = result.multiply(new BigInteger(Integer.toString(i))).mod(divider);
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 42564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

ll digsum(ll n){
    ll ret = 0;
    while(n){
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

ll dig(ll n, ll k){
    return (n / powint(10, k)) % 10;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    ll k = log10(n);
    cout << max({digsum(n), 9*k+dig(n, k)-1}) << endl;
    return 0;
}

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

N = i()
A = l()
t = 1
f = 1
for i in range(N):
    t *= 3
    if A[i]%2 == 0:
        f *= 2
print(t-f)

Measured memory_bytes: 9996
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "
#define F           first
#define S           second
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll i;
    for(i=0;i<b;i++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll n,i;
    cin>>n;
    ll a[n];
    ll b[n];
    ll c[n-1];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
        cin>>b[i];
    for(i=0;i<(n-1);i++)
        cin>>c[i];
    ll ans=0;
    for(i=0;i<n;i++)
        ans+=b[a[i]-1];
    for(i=1;i<n;i++)
    {
        if((a[i]-1)==a[i-1])
            ans+=c[a[i-1]-1];
    }
    cout<<ans;
    return 0;
}




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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), sum(n+1, 0);
    map<ll, ll> mp;
    mp[0]++;
    rep(i, n) {
        cin >> a[i];
        sum[i+1] += (a[i] + sum[i]) % m;
        mp[sum[i+1]]++;
    }
    ll ans = 0;
    for (auto t : mp) {
        ans += t.second * (t.second-1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5760
n = int(input())
s = list(input())

ans_list = [0 for _ in range(n)]
ans_list[0] = s[1:].count("E")
ans = ans_list[0]

for i in range(1, n):
	if s[i-1] == "E" and s[i] == "E":
		ans_list[i] = ans_list[i-1] - 1

	elif s[i] == "W" and s[i-1] == "W":
		ans_list[i] = ans_list[i-1] + 1

	else:
		ans_list[i] = ans_list[i-1]

	if ans_list[i] < ans:
		ans = ans_list[i]

print(ans)

Measured memory_bytes: 17572