akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mod ((long long)(1e9 + 7))
vector<long long> fact;
vector<long long> factInv;

long long pow_mod(long long a, long long b) {
  long long ret = 1;
  while (b > 0) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
    b = b >> 1;
  }
  return ret;
}

void comb_init(long long n) {
  fact.resize(n + 1);
  factInv.resize(n + 1);
  fact[0] = 1;
  for (long long i = 1; i <= n; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
    fact[i] %= mod;
  }
  factInv[n] = pow_mod(fact[n], mod - 2);
  for (long long i = n - 1; i >= 0; i--) {
    factInv[i] = factInv[i + 1] * (i + 1) % mod;
  }
}

long long comb(long long n, long long r) {
  if (n == 0 && r == 0) return 1;
  if (r > n) return 0;
  long long ret = factInv[n - r] * factInv[r] % mod;
  return ret * fact[n] % mod;
}

int main(void) {
  long long K;
  cin >> K;
  string S;
  cin >> S;
  long long N = S.length();
  comb_init(N + K - 1);
  long long ans = 0;
  for (long long i = N - 1; i <= N + K - 1; i++) {
    ans += (((comb(i, N - 1) * pow_mod(25, i - (N - 1))) % mod) *
            pow_mod(26, N + K - 1 - i)) %
           mod;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35652
n = gets.to_i
until n == 0
 sum = 1
 while n > 0
  sum *= n
  n -= 1
 end
 strsum = sum.to_s
 strspl = strsum.split("")
 lengthind = strspl.length - 1
 ans = 0
 while lengthind != 0
 if strspl[lengthind] == "0"
  ans += 1
 elsif strspl[lengthind] != "0"
  break
 end
 lengthind -= 1
 end

 puts ans


 n = gets.to_i
end


Measured memory_bytes: 113200
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#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 FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    map<string, int> ma;
    ma[s] = a; ma[t] = b;
    string S;
    cin >> S;
    ma[S]--;
    cout << ma[s] << ' ' << ma[t];
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N, X;
    in2(N, X);

    vi L(N);
    rep(i, N) in(L[i]);

    int d = 0;
    int count = 1;
    rep(i, N)
    {
        d += L[i];

        if (d > X) break;

        count++;
    }

    outl(count);

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

bool is_prime(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return n != 1;
}

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

  vector<int> a;
  repp(i, 1, 5555) {
    int temp = 10 * i + 1;
    if (is_prime(temp))
      a.pb(temp);
  }

  rep(i, N) {
    cout << a[i];
    if (i == N - 1)
      cout << endl;
    else
      cout << ' ';
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        while (s.length() > 0) {
            s = s.substring(0, s.length() - 2);
            String s1 = s.substring(0, s.length() / 2);
            String s2 = s.substring(s.length() / 2 , s.length());
            if (s1.equalsIgnoreCase(s2)) {
                System.out.println(s.length());
                return;
            }
        }
    }

}

Measured memory_bytes: 20948
/*	
*  Sachin Mittal
*/
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,j,n) for(int i=j;i<n;i++)
#define F first
#define S second
#define lb lower_bound
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
#define debug(x) cout << #x << " = " << x << '\n';
using namespace std;

void solve()
{
    int n;cin>>n;
    map<int,int> m;
    rep(i,0,n-1)
    {
    	int x;cin>>x;
    	m[x]++;
    }
    rep(i,1,n+1)
    {
    	cout<<m[i]<<'\n';
    }
}

int32_t main(){

ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t=1;
//cin>>t;
while(t--)
{
	solve();
}
}

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

using namespace std;

int main(){
    string s; cin >> s;
    int l,r,ans; ans = l = r = 0;
    while(l < s.size()){
        r = l;
        while(r < s.size() && (s[r] == 'A' || s[r] == 'C' || s[r] == 'G' || s[r] == 'T')) r++;
        ans = max(r - l, ans);
        l = r + 1;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  string s; cin >> s;
  if(s=="SUN") cout << 7 << endl;
  if(s=="MON") cout << 6 << endl;
  if(s=="TUE") cout << 5 << endl;
  if(s=="WED") cout << 4 << endl;
  if(s=="THU") cout << 3 << endl;
  if(s=="FRI") cout << 2 << endl;
  if(s=="SAT") cout << 1 << endl;
 
  
}

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

int func( std::string str, int &i )
{
	std::vector<int> data;
	i++;
	if ( str[i] == '[' ) {
		do { 
			data.push_back(func(str, i));
		} while(str[i] != ']');
		++i;
	} else {
		int j = i;
		for (; str[j] != ']'; j++);
		j--;
		std::string num = str.substr(i, j - i + 1);
		//std::cout << num << std::endl;
		i = j + 2;
		return std::stoi(num)/2 + 1;
	}

//	std::vector<int> perm(data.size(), 0);
//	for ( int i = 0; i < data.size() / 2 + 1; ++i ) {
//		perm[i] = 1;
//	}
//
//	int min = 0xfffffff;;
//	do{
//		int a = 0;
//		for ( int i = 0; i < data.size(); ++i ) {
//			if ( perm[i] == 1 ) {
//				a += data[i];
//			}
//		}
//		if ( min > a )  min = a;
//	} while(std::prev_permutation(perm.begin(), perm.end()));
	int min = 0;
	std::sort(data.begin(), data.end());
	for ( int i = 0;i < data.size() / 2 + 1; ++i ) {
		min += data[i];
	}

	return min;

}

int main()
{
	int N;

	std::cin >> N;

	for ( int i = 0; i < N; ++i ) {
		std::string str;
		//std::getline(std::cin, str);
		std::cin >> str;

		int j = 0;
		std::cout << func(str, j) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3252
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  1000005

ll primepow[N];
// To calculate prime factors and their powers in a number
vector<pii> primegenerator(ll n)//return vector containing prime numbers and their corresponding power
{
    vector<pii> ans;

    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        ans.pb({2,count});
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            ans.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        ans.pb({n,1}); 
    return ans;
}
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
void solve()
{
    ll n,ans=0,res=0;
    cin>>n;
    vi v(n);
    rep(i,0,n)
    {
        cin>>v[i];
        res=(res+expo(v[i],hell-2,hell))%hell;
        vector<pii>p=primegenerator(v[i]);
        for(auto u:p)
        {
            primepow[u.F]=max(primepow[u.F],u.S);
        }
    }
    ll lcm=1;
    rep(i,1,N)
    {
        lcm=(lcm*expo(i,primepow[i],hell))%hell;;
    }
    ans=(lcm*res)%hell;
    // rep(i,0,n)
    // {
    //     ans=(ans+lcm/v[i])%hell;
    // }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 7356
#include<algorithm>
#include<chrono>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
 
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {for(auto x : v) cout << x << ' '; cout << endl;}
#define printn(v, n) {for(int _i = 0; _i < n; _i++) cout << *(v + _i) << ' '; cout << endl;}
 
typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
 
const int MAXN = 1e3 + 20;

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

    int n;
    int a[MAXN], b[MAXN], c[MAXN];
    cin >> n;
    for(int i = 0; i < n ; i++) 
    	cin >> a[i];
    for(int i = 0; i < n ; i++) 
    	cin >> b[i];
    for(int i = 0; i < n - 1 ; i++) 
    	cin >> c[i];
    int res = 0;
    for(int i = 0; i < n; i++)
    	res += b[i];
    for(int i = 0; i + 1 < n; i++)
    	if(a[i + 1] == a[i] + 1)
    		res += c[a[i] - 1];
    cout << res << endl;

    return 0;
}











Measured memory_bytes: 256
#include <stdio.h>

void call(int n) {
    int i, x;
    for(i = 1; i <= n; i++) {
        if(i % 3 == 0 || i % 10 == 3) {
            printf(" %d", i);
        } else {
            x = i;
            while(x) {
                x /= 10;
                if(x % 10 == 3) {
                    printf(" %d", i);
                    break;
                }
            }
        }
    }
    printf("\n");
}

int main() {
    int n;
    scanf("%d", &n);
    call(n);
    return 0;
}

Measured memory_bytes: 1756
// Author            -  Ranadev Varma
// Codeforces Handle -  Ranadev_CaptainR
// Codechef Handle   -  ranadev
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("unroll-loops")
 
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <iterator>
#include <iomanip>
#include <set>

using namespace std ;

#define MOD 1000000007LL
#define LOD 1000000006
#define pi 3.14159

#define lol1 ios::sync_with_stdio(false)
#define lol2 cin.tie(NULL);cout.tie(NULL)

#define FOR(i,a,b)  for(int i = a ; i < b ; i++)
#define RFOR(i,a,b) for(int i = a ; i > b ; i--)

#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
    lol1;
    lol2;
    long long int n,m;
    cin >> n >> m;
    long long int in[n];
    FOR(i,0,n)
    {
    	cin >> in[i];
    }
    map<long long int,long long int> ref;
    ref[0]++;
    long long int sum=0,ans=0,count;
    FOR(i,0,n)
    {
    	sum+=in[i];
    	ref[sum%m]++;
    }
    map<long long int,long long int>::iterator it = ref.begin();
    while(it!=ref.end())
    {
        count = it->se;
        ans+=(count*(count-1))/2;
        it++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    string S;
    cin >> S;
    int cpos = 0, fpos = 0;
    string ans = "No";
    rep(i, S.size()) {
        if(S.at(i) == 'C') cpos = i + 1;
        if(S.at(i) == 'F') fpos = i + 1;
        dump(cpos);
        dump(fpos);
        if((cpos != 0 && fpos != 0) && (cpos < fpos)) {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char str[100];
    int i=0;

    scanf("%s", &str[0]);

    while(1){
        if(str[i] == 0){
            printf("Yes\n");
            return 0;
        }

        switch(i%2){
            case 0 :
                if(str[i] == 'R' || str[i] == 'U' || str[i] == 'D'){
                        break;
                }else{
                    printf("No");
                    return 0;
                }
            case 1 :
                if(str[i] == 'L' || str[i] == 'U' || str[i] == 'D'){
                    break;
                }else{
                    printf("No");
                    return 0;
                }
        }
        i++;
    }

    printf("NO\n");

    return 0;
}

Measured memory_bytes: 128
n=gets.to_i
a=gets.split.map(&:to_i)
ans=0
r=-1
l=0
sum=0
xor=0

while l<n
  until (r==n-1)||xor^a[r+1]!=sum+a[r+1]
    r+=1
    xor^=a[r]
    sum+=a[r]
  end
  d=r-l+1
  ans+=d
  sum-=a[l]
  xor^=a[l]
  l+=1
end

puts ans

Measured memory_bytes: 16412
al = [chr(ord('a') + i) for i in range(26)]

cnt = {}
for i in al:
  cnt[i] = []

for i in range(int(input())):
  k = input()
  for j in al:
    cnt[j].append(k.count(j))

ret = ""
for i in al:
  ret += i * min(cnt[i])
print(ret)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
    def ope(self, x, y):
        return x + y
    def update(self, i, v):
        while i <= self.n:
            self.data[i] = self.ope(self.data[i], v)
            i += i & -i
    def query(self, i):
        ret = 0
        while 0 < i:
            ret = self.ope(self.data[i], ret)
            i &= i - 1
        return ret
    def lower(self, w):
        if w <= 0:
            return 0
        x = 0
        k = 2**(self.n.bit_length())
        while k:
            if x + k <= self.n and  self.data[x+k] < w:
                w -= self.data[x+k]
                x += k
            k >>= 1
        return x + 1



n = int(input())
a = [int(input()) for i in range(n)]
b = sorted(list(set(a)))
d = {}
for i, j in enumerate(b):
    d[j] = i
a = [d[i] for i in a]
k = len(d)

B = BIT(k)
ans = 0
for i in a:
    i = i+1
    q = B.query(i)
    if q == 0:
        B.update(i, 1)
        ans += 1
    else:
        v = B.lower(q)
        if v != i:
            B.update(v, -1)
            B.update(i, 1)
        else:
            w = B.query(i-1)
            if w == 0:
                B.update(i, 1)
                ans += 1
            else:
                v = B.lower(w)
                B.update(v, -1)
                B.update(i, 1)
print(ans)


Measured memory_bytes: 62548
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    const int INF=(int)1e9;
    int N;
    int[,] A;
    void Solve() {
        //input
        N = io.Int;
        A = new int[N, N];
        for (int i = 0; i < N; ++i)
            for (int j = 0; j < N; ++j)
                A[i, j] = io.Int;
        //cal          
        var ans = 0L;
        for (int i = 0; i < N; ++i)
            for (int j = i+1; j < N; ++j) {
                bool f = false;
                for (int k = 0; k < N; ++k) {
                    if (k == i || k == j) continue;
                    if (A[i, k] + A[k, j] < A[i, j]) {
                        Console.WriteLine(-1);
                        return;
                    }
                    if(A[i, k] + A[k, j] == A[i, j]) {
                        f = true;
                        break;
                    }
                }
                if (!f) ans += A[i, j];
            }
        //ret
        Console.WriteLine(ans);
    }    
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}
class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];

        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 19036
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	string a,s;
	cin >> a;
	int count = 0;
	while(true){
		cin >> s;
		if(s == "END_OF_TEXT")break;
		if(s.size() == a.size()){
			string ans = "";
			for(int j = 0; j < s.size(); j++){
				if(s[j] - BC == a[j])ans += s[j] - BC;
				else if(s[j] + BC == a[j])ans += s[j] + BC;
				else ans += s[j];
			}
			if(ans == a)count++;
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, X, T;
  cin >> N >> X >> T;
  int rem = N % X;
  int ans = N / X * T;
  if(rem > 0)
  {
	 ans += T;   
  }
  cout << ans;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()


signed main() {

  int n,h;cin>>n>>h;
  int a[n],b[n];
  rep(i,0,n-1) cin >> a[i] >> b[i];

  sort(a,a+n);
  sort(b,b+n);

  int maxDam = a[n-1];
  int ans = 0;
  for(int i=n-1;i>=0;i--)if(maxDam < b[i])
  {
    h -= b[i];
    ans++;
    if(h<1)
    {
      cout << ans << endl;
      return 0;
    }
  }

  ans += (h + maxDam - 1) / maxDam;
  cout<< ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (n == i * j) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
	char ch=getchar();int f=0;
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9')
	{f=(f<<1)+(f<<3)+ch-'0';
	ch=getchar();}
	return f;
}
char s[205];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	if(n%2==0)
	n-=2;
	else n--;
	for(int i=n;i>=0;i-=2)
	{
		bool ac=1;
		for(int j=1;j<=i/2;j++)
		{
			if(s[j]!=s[(i>>1)+j])
			{
				ac=0;
				break;
			}
		}
		if(ac)
		{
			printf("%d",i);
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,k;
	std::cin >> n >> k;
	std::set<int> set;
	rep(i,k) {
		int x;
		std::cin >> x;
		set.emplace(x);
	}
	for(int x=n;x<n*10;x++) {
		// check if all digits are not in set
		bool ok = true;
		int y = x;
		while(y) {
			if(set.count(y%10)) ok=false;
			y/=10;
		}
		if(ok) {
			print(x);
			break;
		}
	}
}


Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let _N: usize = read();
    let S: String = read();
    let whiteCount = S.chars().filter(|&c| c == '.').count();
    let (ans, _blackCount, _whiteCount) = S.chars().fold(
        (std::usize::MAX, 0, whiteCount),
        |(ans, leftBlackCount, rightWhiteCount), c| {
            let (leftBlackCount, rightWhiteCount) = if c == '.' {
                (leftBlackCount, rightWhiteCount - 1)
            } else {
                (leftBlackCount, rightWhiteCount)
            };
            let ans = std::cmp::min(ans, leftBlackCount + rightWhiteCount);
            let (leftBlackCount, rightWhiteCount) = if c == '#' {
                (leftBlackCount + 1, rightWhiteCount)
            } else {
                (leftBlackCount, rightWhiteCount)
            };
            (ans, leftBlackCount, rightWhiteCount)
        },
    );
    println!("{}", ans);
}


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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

#define MAX_V 100000

#define MOD 1000000007L
#define INF 2147483647

signed main() {
	int w, h, n;
	cin >> w >> h >> n;
	int v[5] = { 0, 0, w, 0, h };
	// left, right, bottom, top
	for (size_t i = 0; i < n; i++) {
		// cout << v[1] << "," << v[2] << "," << v[3] << "," << v[4] << endl;
		int x, y, a;
		cin >> x >> y >> a;
		if (a == 1) {
			v[1] = max(v[1], x);
		} else if (a == 2) {
			v[2] = min(v[2], x);
		} else if (a == 3) {
			v[3] = max(v[3], y);
		} else if (a == 4) {
			v[4] = min(v[4], y);
		}
	}
	cout << max(0, v[2] - v[1]) * (v[4] - v[3]) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int h;
void maxHeapify(int *A,int i){
  int l=i*2+1;
  int r=i*2+2;
  int largest;
  if(l<h&&A[l]>A[i]) largest=l;
  else largest=i;
  if(r<h&&A[r]>A[largest]) largest=r;
  if(largest!=i){
    swap(A[i],A[largest]);
    maxHeapify(A,largest);
  }
}
void buildMaxHeap(int *A){
  for(int i=h/2;i>=0;i--)
    maxHeapify(A,i);
}
signed main(){
  cin>>h;
  int A[h];
  for(int i=0;i<h;i++) cin>>A[i];
  buildMaxHeap(A);
  for(int i=0;i<h;i++) cout<<" "<<A[i];
  cout<<endl;
  return 0;
}



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

int main(){

string s,t;
  cin >> s >> t;
  
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
  int a,b;
  int max=0;
  scanf("%d %d",&a,&b);
	if(a>=b){
      max+=a;
      if(max-1>b){
        max+=max-1;
      }
      else if(max-1<=b){
        max+=b;
      }
    }
  	else if(a<=b){
      max+=b;
      if(max-1>a){
        max+=max-1;
      }
      else if(max-1<=a){
        max+=a;
      }
    }
  printf("%d",max);
  return 0;
}


Measured memory_bytes: 128
ccc=[list(map(int,input().split())) for i in range(2)]


if ccc[0][0] == 1:
  print("Yes")
else:
  for idx in range(1,ccc[0][0]):
    if (ccc[1][idx-1] <= ccc[1][idx]):
      if (idx == ccc[0][0]-1):
        print("Yes")
      continue
    elif (ccc[1][idx-1]  == ccc[1][idx] + 1 ):
      ccc[1][idx] = ccc[1][idx-1]
      if (idx == ccc[0][0]-1):
        print("Yes")
      continue
    elif (ccc[1][idx-1] -1 > ccc[1][idx] ):
      print("No")
      break

Measured memory_bytes: 14400
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <string>

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define PI acos(-1.0)

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef vector <ll> vll;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int cnt[26];
	for (int i = 0; i < 26; i++)
		cnt[i] = 0;
	string str;
	cin >> str;
	ll n = str.length();
	ll ans = n * (n - 1) / 2 + 1;
	for (int i = 0; i < str.length(); i++) {
		ans -= cnt[str[i] - 'a'];
		cnt[str[i] - 'a']++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
h,w=map(int,input().split())
grid=[["#"]*(w+2)]+[["#"]+list(map(int,input().split()))+["#"] for i in range(h)]+[["#"]*(w+2)]
ans=[]
for i in range(1,h+1):
    for j in range(1,w+1):
        if grid[i][j]%2>0:
            if type(grid[i][j+1])==int:
                grid[i][j]-=1
                grid[i][j+1]+=1
                ans.append([i,j,i,j+1])
            elif type(grid[i+1][j])==int:
                grid[i][j]-=1
                grid[i+1][j]+=1
                ans.append([i,j,i+1,j])
print(len(ans))
for i in range(len(ans)):
    print(*ans[i])

Measured memory_bytes: 26204
from collections import Counter


def prime_factorization(n):
    """
    nを素因数分解して素因数のリストを返却する
    """
    if n < 2:
        return [n]

    primes = []
    while n % 2 == 0:
        primes.append(2)
        n //= 2
    i = 3
    while i ** 2 <= n:
        while n % i == 0:
            primes.append(i)
            n //= i
        i += 2
    if n != 1:
        primes.append(n)
    return primes


MOD = 10 ** 9 + 7
N = int(input())

counter = Counter()

for n in range(2, N + 1):
    for p in prime_factorization(n):
        counter[p] += 1

ans = 1
for k, v in counter.items():
    if k < 2:
        continue
    ans *= v + 1
    ans %= MOD

print(ans)


Measured memory_bytes: 9340
#include<bits/stdc++.h>
using namespace std;
 
int main() {
 int x,y;
 cin >> x >> y;
if(x>y){
   cout << "No" << endl; return 0;
}
if(y %2 !=0){
   cout << "No" << endl; return 0;
}
if(x==y){
   cout << "No" << endl; return 0;
}
if(4*x<y){
   cout << "No" << endl; return 0;
}
if(2*x>y){
   cout << "No" << endl; return 0;
}

cout << "Yes" << endl;
return 0;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
	public static void main(String []args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb;
		int rr = sc.nextInt();
		int cc = sc.nextInt();
		sc.nextLine();
		char[][] res = new char[rr+2][cc+2];
		String temp = "";
		for(int i=0; i<rr+2; i++) {
			sb = new StringBuilder();
			if(i>0 && i<rr+1) temp = sc.nextLine();
			for(int j=0; j<cc+2; j++) {
				if(i==0 || j==0 || i==rr+1 || j==cc+1) {
					sb.append('#');
				}
				else {
					sb.append(temp.charAt(j-1));
				}
			}
			System.out.println(sb.toString());
		}
	}
}

Measured memory_bytes: 21076
use std::io;

fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

// https://abc079.contest.atcoder.jp/tasks/abc079_a

fn main(){
    let line = read_line();
//    let split : Vec<&str> = line.trim().split(' ').collect();
    let split = line.trim().chars();
    let array : Vec<i32> = split.into_iter().map(|c| c.to_string().parse().unwrap()).collect();

    for i in 0..8{
        let mut sum = array[0];
        let mut output = String::new();

        output = format!("{}",array[0]);

        for j in 1..4{
            let mask = 1 << (j-1);
            let sign = if mask & i == 0 { 1 }else{ -1};
            let op = if sign == 1 {'+'}else{'-'};
            sum += sign * array[j];

            output = format!("{}{}{}",output,op,array[j]);
        }

        if sum == 7{
            println!("{}=7",output);
            break;
        }
    }

}


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

int main() {
  int n;
  cin >> n;
  int a[100010];
  int cnt,ans=0;
  for (int i=0; i<n; i++) {
    scanf("%d",a+i);
  }
  sort(a,a+n);
  int x;
  for (int i=0; i<n; i++) {
    cnt=0;
    for (int j=i; j<n&&a[j]<=a[i]+2; j++) {
      cnt++;
      if (a[i]==a[j])
	x=j;
    }
    i=x;
    ans=max(ans,cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
h, w = map(int, input().split())
a = lambda x: 1 if x=="#" else 0
S = [list(map(a, list(input()))) for _ in range(h)]
inf = 10*3
dp = [[inf]*w for _ in range(h)]
dp[0][0] = S[0][0]
for i in range(1, w):
    dp[0][i] = dp[0][i-1] + S[0][i]*(S[0][i]!=S[0][i-1])
for i in range(1, h):
    dp[i][0] = dp[i-1][0] + S[i][0]*(S[i][0]!=S[i-1][0])
for i in range(1, h):
    for j in range(1, w):
        dp[i][j] = min(dp[i-1][j]+S[i][j]*(S[i-1][j]!=S[i][j]), dp[i][j-1]+S[i][j]*(S[i][j]!=S[i][j-1]))
print(dp[-1][-1])

Measured memory_bytes: 3188
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <stack>

#define rep(i,x) for(int i=0;i<x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rep_to(a,i,x) for(int i=a;i<x;i++)

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{
		int count=0;
		for(int i=1;i<n;i++)
		{
			int sum=i;
			for(int j=i+1;j<n;j++)
			{
				sum+=j;
				if(sum>n)break;
				else if(sum==n)
				{
					count++;
					break;
				}
			}
		}
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
	int N;
	long int A[100010];
	long int B[100010];

	cin >> N;

	for (int i = 0; i < N + 1; ++i) {
		cin >> A[i];
	}
	for (int i = 0; i < N; ++i) {
		cin >> B[i];
	}

	long int ans = 0;

	for (int i = 0; i < N; ++i) {
		long int v1 = A[i];
		long int v2 = A[i + 1];
		A[i] += A[i + 1];
		A[i + 1] = 0;

		if (A[i] > B[i]) {
			if (v1 >= B[i]) {
				ans += B[i];
				A[i + 1] = v2;
			}else if (v1 < B[i]) {
				ans += B[i];
				A[i + 1] = A[i] - B[i];
			}
		}

		else if (A[i] == B[i]) {
			ans += B[i];
			A[i] = 0;
		}

		else if (A[i] < B[i]) {
			ans += A[i];
		}

	}

	cout << ans << endl;
}

Measured memory_bytes: 5120
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

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

    cout<<X+Y/2;
    return 0;
}

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

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

int main() {
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
    int n; cin >> n;

    int matching[n][n];

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

    int sz = (1 << n);
    vector<ll> dp(sz);

    dp[0] = 1;

    for (int mask = 0; mask < sz; ++mask) {
        int a = __builtin_popcount(mask);
        for (int b = 0; b < n; ++b) {
            if (matching[a][b] and !(mask & (1 << b))) {
                int new_mask = mask | (1 << b);
                dp[new_mask] += dp[mask];
                if (dp[new_mask] >= mod) dp[new_mask] -= mod;
            }
        }
    }

    cout << dp[sz-1] << "\n";
}

Measured memory_bytes: 16640
// Mon Aug 24 16:24:09 IST 2020        
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define int64              long long   

#define forn(ii,a,b)       for(int64 ii = (int)a ; ii < (int)b  ; ii++ )
#define scan(any)          for(auto &i:any) cin>>i;
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define all(x)             (x).begin(),(x).end() 
#define ff                 first
#define ss                 second
#define pppp               pair <int,int> 
#define flushOff           fflush(stdout) 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
const double pi = 3.141592653589793238;
const int INF = 2e9+7; 
// const int N = 2e5+7;
struct compare{
    bool operator()(pair <int,int> A, pair <int,int> B){
        if(A.first == B.first)
            return A.second > B.second;
        return A.first > B.first;
    }
}; 
void print(vector <int>v){
    for(int t : v){
        cout << t << ' ';
    }
    cout << '\n';
}
vector <int> res,h;
vector <vector <int>> g;
vector <bool> vis;
void dfs(int node, int parent){
    vis[node] = true;
    res.push_back(h[node]);
    for(auto child : g[node])
        if(child != parent)
        { 
            dfs(child, node);
        }
}
int tests(){   
    int X;
    cin >> X;
    forn(i,0,1000)
        forn(j,-1000,1000)
            if(i*i*i*i*i- j*j*j*j*j == X)
                return cout << i << " " << j << '\n',0;
    return 0;
}    
int main(){
    I__O ;      
    int cases = 1 ;  
    // cin >> cases ;
    while(cases--)
        tests(); 
    return 0 ; 
}
 

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define mp make_pair
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) for(ll i=0;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;
ll mod=1000000007;


int main(){
    ll h,ans=1;
    cin>>h;
    for(;;){
        if(h==1){
            cout<<ans<<endl;
            return 0;
        }
        if(ans*2+1>=h){
            cout<<ans*2+1<<endl;
            return 0;
        }
        ans=ans*2+1;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int h,n,flag=0;
    cin >> h >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        h-=a[i];
        if(h<=0){
            flag=1;
        }
    }
    if(flag==0){
        cout << "No" << '\n';
    }
    else{
        cout << "Yes" << '\n';
    }
    return 0;
}


Measured memory_bytes: 640
while True:
    H,W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        s = ""
        if i % 2 == 0:
            flg = True
        else:
            flg = False
        for j in range(W):
            if flg:
                s = s + "#"
                flg = False
            else:
                s = s + "."
                flg = True
        print(s)
    print("")


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

const int N=2E5+10,mod = 1000000007;
typedef long long LL;
int a[N];
LL res=1;

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

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

    sort(a,a+n);

    int sign=1;
    if(n==k){
        for(int i=0;i<n;i++)
            (res*=a[i])%=mod;
    }//n==k时
    else{
        int l=0,r=n-1;
        if(k%2)//奇数情况
        {
            res=a[r--],k--;
            if(res<0)sign=-1;//唯一的全负状况 取最小
        }
        while(k)//转化为偶数状态处理
        {
            LL ll = (LL)a[l]*a[l+1],rr=(LL)a[r]*a[r-1];
            if(ll*sign>rr*sign){
                res=ll%mod*res%mod;l+=2;
            }//左右两边哪个绝对值大就选哪个 全负数状态相反
            else {res=rr%mod*res%mod;r-=2;}
            k-=2;
        }
    }

    cout<<(res+mod)%mod;
    return 0;
}


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

#define int long long
#define times(n, i) uptil(0, n, i)
#define uptil(a, b, i) for(int i = (a); i < (b); ++i)
#define all(v) begin(v), end(v)

inline int moda(int a, int b) { int m = a % b; return m + (m >= 0 ? 0 : b); }

template<class T>
ostream& operator<<(ostream& o, const vector<T>& v) { for(T t: v) o << t << ','; return o; }


signed main() {
// NLTN(XW)
int N;int L;int T;cin>>N;cin>>L;cin>>T;vector<int> X(N);vector<int> W(N);times(N,Ri_0){cin>>X[Ri_0
];cin>>W[Ri_0];}

  bool rev = W[0] == 2;
  if(rev) {
    times(N, i) {
      X[i] = moda(-X[i], L);
      W[i] = 3 - W[i];
    }
  }

  // 元1がぶつかる回数
  int n_hit = 0;
  uptil(1, N, i) {
    if(W[i] == 2) {
      n_hit += T * 2 / L + (T * 2 % L > moda(X[i] - X[0], L));
      cerr << i << ' ' << n_hit << endl;
    }
  }

  vector<int> lx(N);
  times(N, i) lx[i] = moda(X[i] + (W[i] == 1 ? T : -T), L);
  int lx_sp = lx[0];
  sort(all(lx));
  int spi = distance(begin(lx), find(all(lx), lx_sp));

  int i0 = spi - n_hit;

  cerr << n_hit << ' ' << lx_sp << ' ' << spi << ' ' << i0 << endl << lx << endl;

  if(rev) {
    i0 = -1 - i0;
    reverse(all(lx));
    times(N, i) lx[i] = moda(-lx[i], L);
  }
  cerr << lx << endl;

  times(N, i) {
    // cerr << i0 + i << ' ' << N << endl;
    cout << lx[moda(i0 + i, N)] << endl;
  }

  return 0;
}


Measured memory_bytes: 3584
a=int(input())
b=list(map(int, input().split()))
c=list(range(1,a+1))
b2=[b[i]-c[i] for i in range(a)]
#print(b2)
d=sorted(b2)
#print(d)
if a%2==1:
    b3=[abs(i-d[len(d)//2]) for i in b2]
else: 
    if d[len(d)//2]<0:
        if d[len(d)//2+1]<0:
            b3=[abs(i-d[len(d)//2+1]) for i in b2]
    else:
        b3=[abs(i-d[len(d)//2]) for i in b2]
#print(b3)
print(sum(b3))

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

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

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},  {-1, 0}, { 0, -1}, 
};

vector<string> s(400);
int used[400][400];
ll ans = 0, h, w;
ll black = 0, white = 0;

void dfs(int y, int x) {
    used[y][x] = 1;
    // cerr << y << " " << x << endl;
    if(s[y][x] == '#') ++black;
    else ++white;
    
    for(int k=0;k<4;++k) {
        int yy = y + dyx[k][0], xx = x + dyx[k][1];
        if(yy < 0 || h <= yy || xx < 0 || w <= xx) continue;
        if(s[y][x] == s[yy][xx] || used[yy][xx]) continue;
        dfs(yy, xx);
    }
    return;
}


int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    cin >> h >> w;
    for(int i=0;i<h;++i) cin >> s[i];

    for(int i=0;i<h;++i) {
        for(int j=0;j<w;++j) {
            if(used[i][j]) continue;
            dfs(i, j);
            cerr << black << " " << white << endl;
            ans += black * white;
            black = 0;
            white = 0;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 18560
/*  
     author : masaow    
     g++ : 17.3.20  
*/        
#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x)               cout << x << "\n" ; 
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set ; 
const int SIZE = 1e5+7 ;  
const int MOD = 1e9 +7 ; 
const int INF = 2e9+7 ;
/*  
    time : 07 : 31    
    date : 09...02...2020
*/ 
 
int a[307] ; 
int tests(){
  int N  ;
  cin >> N ;
  unordered_map <string,int> m ; 
  string s ; 
  int i  ;
  forn(i,0,N){
    cin >> s ;
    m[s]++ ; 
  }
  vector <string> v ;
  int best  =  0 ;  
  for(auto it : m )
    best = max(best,it.s1) ;

  for(auto it : m )
    if(it.s1 == best)
      v.pb(it.f1) ;
  sort(all(v)) ;
  for(auto &x :v) 
    cout << x << '\n' ;       
  return 0 ; 
}
int main(){
    I__O ;  
    int cases = 1 ; 
    // cin >> cases;  
    while(cases--) 
      tests(); 
  return 0 ;
}
// web dev simplified
// LearnCode.Academy
/*
 g++ subminnnt.cpp -Wall -Wextra -pedantic
 -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal
 -Wconversion -Wlogical-op -Wshift-overflow=2
 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG
 -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address 
 -fsanitize=undefined -fno-sanitize-recover -fstack-protec    
*/         
         
  

Measured memory_bytes: 25284
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<int64> a(n), sum(n + 1);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
    a[i] -= i;
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; ++i) {
    sum[i + 1] = sum[i] + a[i];
  }
  int64 ret = 1LL << 60;
  for (int i = 0; i < n; ++i) {
    int64 cur = a[i] * i - sum[i];
    cur += sum[n] - sum[i] - (n - i) * a[i];
    ret = min(ret, cur);
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 3328
package main

import (
	"fmt"
)

func main() {
	var x1, y1, x2, y2 int
	fmt.Scanln(&x1, &y1, &x2, &y2)
	vx := x2 - x1
	vy := y2 - y1
	x3 := x2 - vy
	y3 := y2 + vx
	x4 := x3 - vx
	y4 := y3 - vy
	fmt.Println(x3, y3, x4, y4)
}


Measured memory_bytes: 512