akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, a) (int)(lower_bound(all(v), a) - v.begin())
#define UB(v, a) (int)(upper_bound(all(v), a) - v.begin())

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string str;
    cin >> str;
    int n = SZ(str);
    ll table[n];
    fill_n(table, n, 0);
    
    vector<int> v; // 境界RLのRの位置
    rep(i, SZ(str) - 1) {
        if (str[i] == 'R' && str[i + 1] == 'L') {
            v.eb(i);
        }
    }
    // outa(v, SZ(v));
    
    int i = 0; // 最初のRLの左のL
    while (str[i] == 'L' && i < n) i++;
    table[i - 1] = i;
    
    for (; i < SZ(str); ++i) { //どこの境界に収束するか
        // Rなら右のRLへ
        if (str[i] == 'R') {
            int it = LB(v, i);
            // out(it << v[it] + ((v[it] - i) % 2 != 0));
            table[v[it] + ((v[it] - i) % 2 != 0)]++;
        } else {
            int it = UB(v, i);
            it--;
            // out(it << v[it] + ((v[it] - i) % 2 != 0));
            table[v[it] + ((v[it] - i) % 2 != 0)]++;
        }
    }
    
    if (i != SZ(str)) { // 最後のRLの右のR
        table[n - 1] = n - 1 - i + 1;
    }
    
    outa(table, n);
}




Measured memory_bytes: 1616
/******************
*  Writer: Oh no  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;

long long n,k,ans,x;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>k;
	
	x=n/k;
	ans+=x*x*x;
	if(k%2==0){
		x=(n+k/2)/k;
		ans+=x*x*x;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

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

Measured memory_bytes: 256
package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    data := []int{}
    for scanner.Scan() {
        row, _ := strconv.Atoi(scanner.Text())
        data = append(data, row)
    }
    k := data[len(data) - 1]

    for i := 0; i < len(data) - 2; i++ {
        num1 := data[i]
        for j := 1; j < len(data) - 1; j++ {
            num2 := data[j]
            if num2 - num1 > k {
                    fmt.Println(":(")
                    return
            }
        }
    }
    fmt.Println("Yay!")
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define io_ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;

int main(){
    io_
    long long int n; cin >> n;
    vector<long long int> bosses(n);
    for(int i=0;i<n-1;i++){
        int x; cin >> x;
        bosses[x-1]++;
    }
    for(int i=0;i<n;i++){
        cout << bosses[i] << "\n";
    }
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int N;

	cin >> N;
	vector<int> P(N);
	vector<int> norm(N);

	for (int i = 0; i < N; i++)
	{
		cin >> P[i];
	}
	norm = P;
	sort(all(norm));
	int sum = 0;

	for (int i = 0; i < N; i++)
	{
		if (P[i] != norm[i])
			sum++;
	}
	(sum == 2 || sum == 0) ? puts("YES") : puts("NO");
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[]args){
        Scanner cin=new Scanner(System.in);
        int num1 = cin.nextInt();
        int num2 = cin.nextInt();
        int count = 0;
        for (int i = num1; i <= num2; i++) {
        	String numstr = String.valueOf(i);
        	String f, r;
        	int len = numstr.length();
        	if (len % 2 == 0) {
        		f = numstr.substring(0, len / 2);
        		r = numstr.substring(len / 2, len);
        	} else {
        		f = numstr.substring(0, len / 2);
        		r = numstr.substring(len / 2 + 1, len);
        	}
        	if (f.equals((new StringBuffer(r)).reverse().toString())) {
        		count++;
        	}
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 38996
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long

string ma[21];
int arr[21][21];
int H, W;

int bfs(int s, int t) {
	for (int i = 0;i < H;i++) {
		for (int j = 0;j < W;j++) {
			arr[i][j] = -1;
		}
	}
	int u = 0;
	queue<tuple<int, int, int>> Q;
	Q.push(make_tuple(s, t, u));
	while (!Q.empty()) {
		tie(s, t, u) = Q.front();
		Q.pop();
		if (s < 0)continue;
		if (t < 0)continue;
		if (s >= H)continue;
		if (t >= W)continue;

		if (ma[s][t] == '#')continue;
		if (arr[s][t] >= 0)continue;
		arr[s][t] = u;
		Q.push(make_tuple(s + 1, t, u + 1));
		Q.push(make_tuple(s - 1, t, u + 1));
		Q.push(make_tuple(s, t + 1, u + 1));
		Q.push(make_tuple(s, t - 1, u + 1));
	}
	int ans = 0;
	for (int i = 0;i < H;i++) {
		for (int j = 0;j < W;j++) {
			ans = max(ans, arr[i][j]);
		}
	}
	return ans;
}

int main() {
	cin >> H >> W;
	for (int i = 0;i < H;i++)cin >> ma[i];
	
	int fa = 0;
	for (int si = 0;si < H;si++) {
		for (int ti = 0;ti < W;ti++) {
			fa = max(fa, bfs(si, ti));
		}
	}
	cout << fa << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
#define int long long
#define mod 1000000007
#define DEBUG cout<<"Hello1\n";
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))
#define deb(...) debug(#__VA_ARGS__, __VA_ARGS__);
const int N = 1e6 + 5;
const double pi =  acosl(-1);
const long long inf = 1e18 + 5;
using namespace std;
template<typename T> void debug(string s, T x) {cout << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cout << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}
template<class T> void print_container(T &container) { for (auto &t : container) { cout << t << " ";} cout << endl;}
template<class T> void printArr(T &a , int n) { for (int i = 0; i < n; i++) {cout << a[i] << " ";} cout << endl;}
typedef long long ll;
typedef pair<int, int> pii;

//Template Ends
int n;

void solve() {
	cin >> n;

	if (n >= 30) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

int32_t main() {
	IOS;



	solve();

	return 0;
}




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

int main() {
  char m[102][102];
  for (int i=0; i<102; i++) {
    for (int j=0; j<102; j++) {
      m[i][j] = '#';
    }
  }

  int h, w;
  cin >> h >> w;

  for (int i=1; i<=h; i++) {
    string tmp;
    cin >> tmp;
    for (int j=1; j<=w; j++) {
      m[i][j] = tmp[j-1];
    }
  }

  for (int i=0; i<h+2; i++) {
    for (int j=0; j<w+2; j++) {
      cout << m[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
using namespace std;
// }}} End Header

int main()
{
	lli n, A;
	cin >> n;
	vector<lli> a(n+1,0);
	loop(i, 2, n+1){
		cin >> A;
		a[A]++;
	}
	loop(i, 1, n+1){
		cout << a[i] << endl;
	}
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n, m;
  cin >> n >> m;

  if (n >= m) {
    cout << 0 << endl;
    return 0;
  }

  vector<ll> x(m);
  for (ll i = 0; i < m; ++i) {
    cin >> x[i];
  }
  sort(x.begin(), x.end());

  vector<ll> d(m-1);
  for (ll i = 1; i < m; ++i) {
    d[i-1] = x[i]-x[i-1];
  }
  sort(d.begin(), d.end(), greater<ll>());

  ll ans = 0;
  for (ll i = n-1; i < d.size(); ++i) {
    ans += d[i];
  }

  cout << ans << endl;

  return 0;
}


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

int main(){ 
  int n, m;
  cin >> n >> m;
  vector<vector<char>> a(n, vector<char>(n)), b(m,vector<char>(m));
  rep(i,n) rep(j,n) cin >> a[i][j];
  rep(i,m) rep(j,m) cin >> b[i][j];
  bool ok = false;
  for (int i = 0; i + m <= n; i++) {
    for (int j = 0; j + m <= n; j++) {
      if (a[i][j] == b[0][0]) {
        bool p = true;
        rep(s,m) rep(t,m) if (a[s + i][t + j] != b[s][t]) p = false;
        ok |= p;
      }
    }
  } 

  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
} 

Measured memory_bytes: 256
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
#define Rd(a) (a=rd())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int rd(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	c^'-'?(k=1,x=c&15):k=x=0;
	while(isdigit(Gc(c)))x=x*10+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(signed i(a);i<(b);++i)
#define Frn1(i,a,b) for(signed i(a);i<=(b);++i)
#define Frn_(i,a,b) for(signed i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
#define N (510)
#define B(a) (((a)>>k)&1)
int n,a[N][N],u[N],v[N];
bool s[N],t[N];
bool slv(int k);
signed main(){
	Rd(n);
	Frn1(i,1,n)Rd(s[i]);
	Frn1(i,1,n)Rd(t[i]);
	Frn1(i,1,n)Rd(u[i]);
	Frn1(i,1,n)Rd(v[i]);
	Frn0(k,0,64)if(!slv(k))printf("-1"),exit(0);
	Frn1(i,1,n){Frn1(j,1,n)wr(a[i][j]),Ps;Pe;}
	exit(0);
}
bool slv(int k){
	bool r0(0),r1(0),c0(0),c1(0);
	vector<signed>ar,ac,er0,er1,ec0,ec1;
	Frn1(i,1,n)if(!s[i]&&B(u[i])){r1=1;Frn1(j,1,n)a[i][j]|=1ULL<<k;}
		else if(s[i]&&!B(u[i]))r0=1;
		else ar.push_back(i);
	Frn1(j,1,n)if(!t[j]&&B(v[j])){c1=1;Frn1(i,1,n)a[i][j]|=1ULL<<k;}
		else if(t[j]&&!B(v[j]))c0=1;
		else ac.push_back(j);
	if(r0&&c1||r1&&c0)return 0;
	for(int i:ar)if(B(u[i])&&!c1)er1.push_back(i);
		else if(!B(u[i])&&!c0)er0.push_back(i);
	for(int j:ac)if(B(v[j])&&!r1)ec1.push_back(j);
		else if(!B(v[j])&&!r0)ec0.push_back(j);
	if(ar.empty())return ec0.empty()&&ec1.empty();
	if(ac.empty())return er0.empty()&&er1.empty();
	if(ar.size()==1){
		if(ec0.size()==ac.size()&&!er1.empty()||ec1.size()==ac.size()&&!er0.empty())return 0;
		if(er1.empty())for(int j:ec1)a[ar[0]][j]|=1ULL<<k;
		else{for(int j:ac)a[ar[0]][j]|=1ULL<<k;for(int j:ec0)a[ar[0]][j]^=1ULL<<k;}
		return 1;
	}
	if(ac.size()==1){
		if(er0.size()==ar.size()&&!ec1.empty()||er1.size()==ar.size()&&!ec0.empty())return 0;
		if(ec1.empty())for(int i:er1)a[i][ac[0]]|=1ULL<<k;
		else{for(int i:ar)a[i][ac[0]]|=1ULL<<k;for(int i:er0)a[i][ac[0]]^=1ULL<<k;}
		return 1;
	}
	if(ar.size()>=ac.size())Frn0(i,0,ar.size())a[ar[i]][ac[i%ac.size()]]|=1ULL<<k;
	else Frn0(j,0,ac.size())a[ar[j%ar.size()]][ac[j]]|=1ULL<<k;
	return 1;
}


Measured memory_bytes: 7372
// 0bd35dc5e428754fa574049b6be8efe0

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

const int MOD = (int) 1e9 + 7;

inline int fpm(int x, int y)
{
	int res = 1;
	for(; y; y >>= 1, x = (LL) x * x % MOD) if(y & 1) res = (LL) res * x % MOD;
	return res;
}

int n, K;

inline void input()
{
	n = read<int>(), K = read<int>();
}

vector<int> seq;
unordered_map<int, vector<int> > fact;

inline void get_fact(int N)
{
	for(int i = 1; (LL) i * i <= N; ++i) if(N % i == 0)
	{
		seq.push_back(i);
		if(i != N / i) seq.push_back(N / i);
	}

	sort(ALL(seq));
	for(auto i : seq) for(auto j : seq) if(i % j == 0 && i != j)
		fact[i].push_back(j);
}

inline void solve()
{
	get_fact(n);

	static unordered_map<int, int> f;

	for(auto i : seq)
	{
		f[i] = fpm(K, (i + 1) / 2);
		for(auto d : fact[i]) (f[i] -= f[d]) %= MOD;
	}

	int ans[2] = {0, 0};
	for(auto i : seq) (ans[i & 1] += (LL) f[i] * i % MOD) %= MOD;

	const int inv2 = (MOD + 1) / 2;
	int res = ((LL) ans[0] * inv2 % MOD + ans[1]) % MOD;
	printf("%d\n", (res + MOD) % MOD);
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll x[2][100100];

int main(void){
	int i,q,n,j,a,b,c,d;
	string s;
	for(i=0; i<2; ++i){
		cin >> s;
		n = s.l_ength();
		for(j=0; j<n; ++j){
			x[i][j+1] = (s[j]-'@');
			x[i][j+1] += x[i][j];
		}
	}
	cin >> q;
	for(i=0; i<q; ++i){
		cin >> a >> b >> c >> d;
		--a; --c;
		cout << (((x[0][a]-x[0][b]-x[1][c]+x[1][d])%3)?"NO":"YES") << endl;
	}
	return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

    lint n;
    cin >> n;

    vector<plint> a(n);

    REP(i,n){
        lint x, l;
        cin >> x >> l;
        a[i].first = x + l;
        a[i].second = x - l;
    }
    sort(ALL(a));

    lint ans=0, tmp;
    lint now = -100000000000;

    REP(i, n)
    {
        if(now<=a[i].second){
            ans++;
            now = a[i].first;
        }
    }
    
    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 1792
import math
import sys
import bisect
import array

m=10**9 + 7 
sys.setrecursionlimit(1000010)
(N,K) = map(int,input().split())
A = list( map(int,input().split())) 
# print(N,K,A)
B = list( map(lambda x: x % K, A))
C = [0]
x = 0
i = 0 
for b in B:
    x = (x + b ) % K 
    C.append((x-i-1) % K) 
    i += 1 
    
# print(B,C)

E={}


ans=0
for i in range(N+1):
    if C[i] in E:
        ans += E[C[i]]
        E[C[i]] = E[C[i]] + 1
    else:
        E[C[i]] = 1
    if i >= K-1:
        E[C[i-K+1]] = E[C[i-K+1]] - 1
        if E[C[i-K+1]] == 0:
             E.pop(C[i-K+1])

print(ans)
exit(0)

Measured memory_bytes: 48844
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdint>
#include <utility>
#include <tuple>
#include <map>    
#include <queue> 
#include <set>  
#include <stack> 
#include <deque>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset>

#include <bits/stdc++.h>
using namespace std;
struct Phanso
{
	double tuso;
	double mauso;

};

Phanso sum(Phanso, Phanso);
Phanso ketqua_tmp;
Phanso ketqua;
int main()
{

	int N;
	cin >> N;
	double tmp;
	double ans;
	tmp = 0;
	ans = 0;
	
	vector<int> s(N);
	for (int i = 0; i < N; i++) {
		cin >> s[i];

		if (N == 1) {
			cout << s[i] << endl;
			return 0;
		}

		if (i == 1) {
			Phanso f1 = { 1, s[i - 1] };
			Phanso f2 = { 1, s[i] };
			ketqua = sum(f1, f2);
			ketqua_tmp = ketqua;
		}
		else if (i > 1) {
			//Phanso f1 = { 1, s[i - 1] };
			Phanso f2 = { 1, s[i] };
			ketqua = sum(ketqua_tmp, f2);
			ketqua_tmp = ketqua;
		}
		
	}

	ans = ketqua.mauso / ketqua.tuso;
	cout << ans << endl;

	return 0;

}

Phanso sum(Phanso f1, Phanso f2)
{
	Phanso ketqua = { (f1.tuso * f2.mauso) + (f2.tuso * f1.mauso), f1.mauso * f2.mauso };
	return ketqua;

}

Phanso ans(Phanso f1, Phanso f2)
{
	Phanso ketqua = { (f1.tuso * f2.mauso) + (f2.tuso * f1.mauso), f1.mauso * f2.mauso };
	return ketqua;

}

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

int N, i;
int p[15];

int main(void) {
    cin >> N;
    for (i=0; i<N; i++) {
        cin >> p[i];
    }
    int max_p = p[0];
    int max_i = 0;
    for (i=1; i<N; i++) {
        if (max_p < p[i]) {
            max_p = p[i];
            max_i = i;
        }
    }
    
    int sum = 0;
    for (i=0; i<N; i++) {
        if (i == max_i) {
            sum += p[i] / 2;
        } else {
            sum += p[i];
        }
    }
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=250;
//ここまでテンプレ
vint X,Y;
bool onLine(int i,int j,int k){
	int ret=(X[j]-X[i])*(Y[k]-Y[i])-(Y[j]-Y[i])*(X[k]-X[i]);
	return !ret;
}
int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		int x,y;
		cin>>x>>y;
		X.pb(x);
		Y.pb(y);
	}
	set<vint> tes;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(i==j)
				continue;
			vint v;
			v.pb(i);
			v.pb(j);
			for(int k=0;k<N;k++){
				if(i==k || j==k)
					continue;
				if(onLine(i,j,k))
					v.pb(k);
			}
			sort(v.begin(),v.end());
			tes.insert(v);
		}
	}
	int di[SIZE]={1,0};
	for(int i=1;i<SIZE;i++)
		di[i]=di[i-1]*2%mod;
	ll ans=1+N;
	for(vint v:tes){
		int n=v.size();
		(ans+=di[n]-n-1)%=mod;
	}
	cout<<(di[N]+mod-ans)%mod<<endl;
	return 0;
}

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

struct edge{int s,t,c,n;}e[20010];
int n,m,tot=1,S,T,h[205],dis[205],H[205],Q[205],ans;
char ch;

void addedge(int s,int t,int c1,int c2=0)
{
	e[++tot]=(edge){s,t,c1,h[s]},h[s]=tot;
	e[++tot]=(edge){t,s,c2,h[t]},h[t]=tot;
}

bool BFS()
{
	int x,y,i,l=1,r=0;
	for (i=1; i<=T; i++)  dis[i]=0,H[i]=h[i];
	Q[++r]=T,dis[T]=1;
	while (l<=r)
		for (i=h[x=Q[l++]]; y=e[i].t,i; i=e[i].n)
			if ((e[i^1].c)&&(!dis[y]))
				{
					dis[y]=dis[x]+1,Q[++r]=y;
					if (y==S)  return 1;
				}
	return 0;
}

int DFS(int x,int a)
{
	if (x==T)  return a;
	int flow=0,t;
	for (int &i=H[x],y; y=e[i].t,i; i=e[i].n)
		if ((e[i].c)&&(dis[x]==dis[y]+1)&&(t=DFS(y,min(a,e[i].c))))
			if (e[i].c-=t,e[i^1].c+=t,flow+=t,!(a-=t))
				return flow;
	dis[x]=-1;
	return flow;
}

void work()
{
	scanf("%d %d",&n,&m),S=n+m+1,T=n+m+2;
	for (int i=1; i<=n; i++)
		for (int j=1; j<=m; j++)
			{
				do  ch=getchar();  while ((ch!='.')&&(ch!='o')&&(ch!='S')&&(ch!='T'));
				if (ch=='o')  addedge(i,j+n,1,1);
				if (ch=='S')  addedge(S,i,1<<30),addedge(S,j+n,1<<30);
				if (ch=='T')  addedge(i,T,1<<30),addedge(j+n,T,1<<30);
			}
	while (BFS())  ans+=DFS(S,1<<30);
	printf("%d",ans>=(1<<30)?-1:ans);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000
int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i = 1 ;i<=n ;i++){
    scanf("%hd",&A[i]);
  }
  for(i = 0;i<=VMAX+1;i++){
    C[i] = 0;
  }
  for(j=1;j<=n;j++){
    C[A[j]] = C[A[j]]+1;
  }
  
  for(i = 1 ;i<=VMAX+1;i++){
    C[i] = C[i]+C[i-1];
  }
  for(j=n ;j>=1 ;j--){
    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]]-1;
  }
  for(j = 1;j<n+1;j++){
    if(j ==n)
    printf("%d\n",B[j]);
    else printf("%d ",B[j]);
    }
  return 0;
}



Measured memory_bytes: 9560
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


def main():
    # sys.stdin = open("Sample.txt")
    a, b, x = Scanner.map_int()
    S = x / a

    if S >= 0.5 * a * b:
        h = (a * b - S) * 2 / a
        print(math.degrees(math.atan2(h, a)))
    else:
        h = 2 * S / b
        print(math.degrees(math.atan2(b, h)))
    return


if __name__ == "__main__":
    main()


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

int main() {
    int n;
    cin>>n;
    if(n<=1000 && n>=1) cout<<1000-n;
    if(n<=2000 && n>1000) cout<<2000-n;
    if(n<=3000 && n>2000) cout<<3000-n;
    if(n<=4000 && n>3000) cout<<4000-n;
    if(n<=5000 && n>4000) cout<<5000-n;
    if(n<=6000 && n>5000) cout<<6000-n;
    if(n<=7000 && n>6000) cout<<7000-n;
    if(n<=8000 && n>7000) cout<<8000-n;
    if(n<=9000 && n>8000) cout<<9000-n;
    if(n<=10000 && n>9000) cout<<10000-n;
	return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
  ll A,B;
 cin >> A >> B;
 cout << max({2*A-1,A+B,2*B-1}) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Stack {
	private int top;
	private int[] a;
	
	Stack(){
		this.top=0;
		a=new int[200];
	}
	
	void push(int x){
		a[top++]=x;
	}
	
	int pop(){
		top--;
		return a[top];
	}
	
}

class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		Stack S=new Stack();
		
		while(scan.hasNext()){
			String str=scan.next();

			if(str.charAt(0)=='+'){
				int a=S.pop();
				int b=S.pop();
				S.push(b+a);
			}
			else if(str.charAt(0)=='-'){
				int a=S.pop();
				int b=S.pop();
				S.push(b-a);
			}
			else if(str.charAt(0)=='*'){
				int a=S.pop();
				int b=S.pop();
				S.push(b*a);
			}
			else {
				S.push(Integer.parseInt(str));
			}
		}
		System.out.println(S.pop());
	}
}


Measured memory_bytes: 26144
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  map<int, int> M;
  for (int i = 0; i < N; i++){
    M[A[i]]++;
  }
  vector<long long> S;
  for (auto P : M){
    if (P.second >= 2){
      S.push_back(P.first);
    }
    if (P.second >= 4){
      S.push_back(P.first);
    }
  }
  S.push_back(0);
  S.push_back(0);
  sort(S.begin(), S.end());
  reverse(S.begin(), S.end());
  cout << S[0] * S[1] << endl;
}

Measured memory_bytes: 5376
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cassert>
using namespace std;

void read(int &x)
{
    int f=1;x=0;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    x*=f;
}

const int N = 5000;
char a[N+3];
char ans[N+3][N+3];
char mnc;
int n,m,num;

bool cmp(int x,int y)
{
	for(int i=1; i<=n; i++)
	{
		if(ans[x][i]<ans[y][i]) return true;
		if(ans[x][i]>ans[y][i]) return false;
	}
	return false;
}

int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",a+1);
	mnc = 'z'; for(int i=1; i<=n; i++) mnc = min(mnc,a[i]);
	if(m>=14) {for(int i=1; i<=n; i++) printf("%c",mnc); return 0;}
	int len = 0,mxl = 0;
	for(int i=1; i<=n; i++)
	{
		if(a[i]!=mnc) len = 0;
		else len++;
		if(len>mxl) {mxl = len;}
	}
	len = 0; num = 0;
	for(int i=1; i<=n; i++)
	{
		if(a[i]!=mnc) len = 0;
		else len++;
		if(i==n)
		{
			num++;
			int tmp = min(n,len*(1<<m));
			for(int j=1; j<=tmp; j++) ans[num][j] = mnc;
			for(int j=tmp+1,k=n-len; j<=n; j++,k--) ans[num][j] = a[k];
		}
		if(len==mxl)
		{
			num++;
			int tmp = min(n,len*(1<<m-1));
			for(int j=1; j<=tmp; j++) ans[num][j] = mnc;
			for(int j=tmp+1,k=i+1; j<=n; j++,k++)
			{
				ans[num][j] = a[k<=n?k:2*n+1-k];
			}
		}
	}
//	for(int i=1; i<=num; i++) {for(int j=1; j<=n; j++) printf("%c",ans[i][j]); puts("");}
	int fans = 1;
	for(int i=1; i<=num; i++)
	{
		if(cmp(i,fans))
		{
			fans = i;
		}
	}
	for(int j=1; j<=n; j++) printf("%c",ans[fans][j]); puts("");
	return 0;
}

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

int div2(int n){
    if(n % 2 != 0) return 0;
    return div2(n / 2) + 1;
}

int main(void) {
    int n, t, ans;
    cin >> n;
    ans = 0;
    for(int i = 0; i < n; i++){
        cin >> t;
        ans += div2(t);
    }
    cout << ans << endl;
    return 0;
}


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


int main()
{
    long long int a,b,k;
   cin>>a>>b>>k;
   if(k>a){
     k=k-a;
     cout<<"0"<<" ";
     if(b>=k)cout<<b-k;
     else cout<<"0";
   }
   else{
     
     cout<<a-k<<" "<<b;
   }
   
   return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define mem(a,b) memset(a,b,sizeof(a))
#define shutdown ios::sync_with_stdio(false)
#define MAX 1e18+1000//1*10^18
#define INF 0x3f3f3f3f
int main()
{
    shutdown;
    int n;
    LL a,b,ta=0,tb=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        if(a>ta){
            ta=a;
            tb=b;
        }
    }
    cout<<ta+tb<<endl;
    return 0;
}


Measured memory_bytes: 256
# C

N,M,X = map(int,input().split())

temp = []
for i in range(N):
  temp.append(list(map(int,input().split())))

ans = -1

# 全部の組み合わせをおこなう
for i in range(2**N):
  skill = [0] * M
  money = 0
  for j in range(N):  # このループが一番のポイント
    if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
      # フラグが立っていたら選ぶ
      money += temp[j][0]
      for k in range(M):
        skill[k] += temp[j][k+1]
  
  if min(skill) >= X:
    if ans == -1:
      ans = money
    else:
      ans= min(money,ans)

print(ans)




Measured memory_bytes: 9208
h, w = map(int, input().split())
mat = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    mat[i] = list(input())

flg = True
for i in range(h):
    for j in range(w):
        if mat[i][j] == "#":
            check = False
            if i != 0 and mat[i-1][j] == "#":
                check = True
            elif i != h-1 and mat[i+1][j] == "#":
                check = True
            elif j != 0 and mat[i][j-1] == "#":
                check = True
            elif j != w-1 and mat[i][j+1] == "#":
                check = True

            if not check:
                flg = False
                break

if flg:
    print("Yes")
else:
    print("No")

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

int main()
{
   string s; cin>>s;
   if(s=="SAT") cout<<1<<endl;
   if(s=="FRI") cout<<2<<endl;
   if(s=="THU") cout<<3<<endl;
   if(s=="WED") cout<<4<<endl;
   if(s=="TUE") cout<<5<<endl;
   if(s=="MON") cout<<6<<endl;
   if(s=="SUN") cout<<7<<endl;
   return 0;
}



Measured memory_bytes: 256
def bb095():
    n,x = list(map(int, input().split()))
    mn = list()
    for i in range(0,n):
        mn.append(int(input()))

    x -= sum(mn)
    mi = min(mn)
    cnt = n
    if x > 0:
        cnt += int(x/mi)

    print(cnt)

bb095()

Measured memory_bytes: 3060
// Created by: WeirdBugsButOkay
 
#include <bits/stdc++.h>
 
#define ll long long
#define ld long double
#define ff first
#define ss second
#define PI 3.14159265358979323846
#define endl '\n'
 
using namespace std;
 
void solve()
{
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	if(n == 2)
	{
		cout << a[1] << " " << a[0] << endl;
		return;
	}
	int ans = 0;
	for(int i = 0; i < n; i++)
		ans ^= a[i];
	for(int i = 0; i < n; i++)
		cout << (ans ^ a[i]) << " ";
	cout << endl;
}
 
int main()
{
	int q = 1;
	//scanf("%d", &q);
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 4392
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll k,n;cin>>k>>n;
    ll a[n];
    rep(i,0,n){
        cin>>a[i];
    }
    ll ma=0;
    rep(i,0,n-1)Max(ma,a[i+1]-a[i]);
    Max(ma,a[0]+k-a[n-1]);
    cout<<k-ma<<endl;
}







Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=10005;
const int MAXM=505;
int pr[MAXN],is[MAXN],plen;
void getpr()
{
	for(int i=2;i<MAXN;i++)
	{
		if(!is[i])pr[++plen]=i;
		for(int j=1;j<=plen&&i*pr[j]<MAXN;j++)
		{
			is[i*pr[j]]=1;
			if(!(i%pr[j]))break;
		}
	}
}
int n,vis[MAXM][MAXM],now;LL a[MAXM][MAXM],b[MAXM][MAXM];
LL gcd(LL a,LL b){return a==0?b:gcd(b%a,a);}
void get1(int x,int y)
{
	if(x>n||y>n)return ;
	vis[x][y]=1;a[x][y]*=pr[now];
	get1(x+1,y+1);
}
void get2(int x,int y)
{
	if(x<1||x>n||y<1||y>n)return ;
	vis[x][y]=1;a[x][y]*=pr[now];
	get2(x+1,y-1);
}
bool in(int x,int y){return x>=1&&x<=n&&y>=1&&y<=n;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
int main()
{
	getpr();	
	n=read();now=0;
	if(n==2)
	{
		printf("4 7\n23 10\n");return 0;
	}
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)a[i][j]=1;
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(((i+j-1)&1)&&!vis[i][j])
		++now,get1(i,j);
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(((i+j-1)&1)&&!vis[i][j])
		++now,get2(i,j);
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(!((i+j-1)&1))
	{
		if(in(i-1,j))a[i][j]=lcm(a[i][j],a[i-1][j]);
		if(in(i+1,j))a[i][j]=lcm(a[i][j],a[i+1][j]);
		if(in(i,j-1))a[i][j]=lcm(a[i][j],a[i][j-1]);
		if(in(i,j+1))a[i][j]=lcm(a[i][j],a[i][j+1]);
		++a[i][j];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)pr1(a[i][j]);
		puts("");
	}
	return 0;
}



Measured memory_bytes: 6144
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// N, Sの入力
		int N = sc.nextInt();
		String S = sc.next();
		
		// 結果の出力
		char[] charArray = S.toCharArray();
		for(char c : charArray) {
			char[] character;
			if (c + N > 'Z') {
				character = Character.toChars(c + N - 'Z' + 'A' - 1);
				System.out.print(character);
			}
			else {
				character = Character.toChars(c + N);
				System.out.print(character);
			}
		}
		
		sc.close();
	}
}


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

using namespace std;

int main(void){
    int K;
    cin >> K;
    vector<int> dist(K, -1);

    priority_queue<pair<int,int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
    dist[1] = 0;
    q.push(make_pair(dist[1], 1));
    while(!q.empty()){
        auto p = q.top(); q.pop();
        int x = p.second;
        int d = p.first;
        if(dist[x] != -1 && dist[x] < d) continue;
        if(dist[x*10%K] == -1 || dist[x*10%K] > dist[x] + 0){
            dist[x*10%K] = dist[x] + 0;
            q.push(make_pair(dist[x*10%K], x*10%K));
        }
        if(dist[(x+1)%K] == -1 || dist[(x+1)%K] > dist[x] + 1){
            dist[(x+1)%K] = dist[x] + 1;
            q.push(make_pair(dist[(x+1)%K], (x+1)%K));
        }
    }

    cout << dist[0] + 1 << endl;

    return 0;
}

Measured memory_bytes: 1276
import java.io.*;
import java.util.*;
import java.lang.*;





public class Main {
		
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		int n=sc.nextInt();
		int m=sc.nextInt();
		int a[]=new int[m];
		int b[]=new int[m];
		long link[]=new long[m];
		UnionFind UF=new UnionFind(n);
		for (int i = 0; i < m; i++) {
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
		}
		long ans=0;
		for (int i = m-1; i>=0; i--) {
			
				if(UF.same(a[i]-1,b[i]-1)) {
					link[i]=0;
					
					UF.union(a[i]-1,b[i]-1);
				}else {
					link[i]=UF.size[UF.find(a[i]-1)]*UF.size[UF.find(b[i]-1)];
					UF.union(a[i]-1,b[i]-1);
					
					
				}
				
	
		
		}
		
		for(int i=0;i<m;i++) {
			ans+=link[i];
			System.out.println(ans);
		}
	
		
				
		
		
	}
	
	

	
	
	
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}

class UnionFind{
	int parent[];
	int rank[];
	int size[];
	UnionFind(int n) {
		parent=new int[n];
		rank=new int[n];
		size=new int[n];
		for(int i=0;i<n;i++) {
			parent[i]=i;
			rank[i]=0;
			size[i]=1;
		}
	}
	
	void union(int x,int y) {
		int xRoot=find(x);
		int yRoot=find(y);


		if(xRoot!=yRoot) {
			
			if(rank[xRoot]>rank[yRoot]) {
				parent[yRoot]=xRoot;
				size[xRoot]+=size[yRoot];
				
			}else if(rank[xRoot]<rank[yRoot]){
				parent[xRoot]=yRoot;
				size[yRoot]+=size[xRoot];
				
			}else {
				parent[yRoot]=xRoot;
				rank[xRoot]++;
				size[xRoot]+=size[yRoot];
			}
		}
		
	}
	
	int find(int x) {
		if(parent[x]==x) {
			return x;
		}else {
			return find(parent[x]);
		}
		
	}
	
	boolean same(int x,int y) {
		return find(x)==find(y);
	}
	
	
	
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

const int INF = 2e9+5;

/*
    filippos
    AtCoder Regular Contest 84
    Task : B
    Given integer K, find the smallest digit sum of a multiple of k
    Solved using 0-1 BFS
    Instead of trying all digits, we eithe increase
    the last one or multiply the whole number by 10
*/


int main(){
    cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);

    int k; cin >> k;

    // smallest sum for each remainder
    vi sum(k, INF);

    // we visit all remainders in order of increasing sums
    deque<pii> pq;
    pq.push_back({0, 0});
    int ans = -1;

    while(!pq.empty()){
    	pii curr = pq.front(); pq.pop_front();
    	// if we found a solution
    	if(curr.second == 0 && curr.first != 0){
    		ans = curr.first;
    		break;
    	}
    	// skip useless entries
    	if(sum[curr.second] < curr.first) continue;
        // cout << curr.second << " @ " << curr.first << '\n';
    	// try to add 1
        int next_sum = curr.first + 1;
        int next_rem = (curr.second + 1) % k;
        // worth to try
        if(sum[next_rem] > next_sum){
            sum[next_rem] = next_sum;
            // 1-edge
            pq.push_back({next_sum, next_rem});
        }
        // avoid trailing zeroes
        if(curr.first == 0) continue;
        // try to mul by 10
        next_sum = curr.first;
        next_rem = (curr.second * 10) % k;
        // worth to try
        if(sum[next_rem] > next_sum){
            sum[next_rem] = next_sum;
            // 0-edge
            pq.push_front({next_sum, next_rem});
        }
    }

    // print the smallest sum found
    cout << ans;


    return cout << '\n', 0;
}

Measured memory_bytes: 1024
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
#define PI 3.14159265359
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        int a[n];
        loop(0, n)
        cin >> a[i];
        sort(a, a + n);
        int sum = 0;
        loop(0, k)
        sum += a[i];
        cout << sum << endl;
    }
    return 0;
}


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

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

    int ans = 0;
    if (n >= 10) {
        ans = r;
    } else {
        ans = r + (100 * (10 - n));
    }

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

Measured memory_bytes: 256
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

const int N = (int)1e5;

char s[N+5];

pii solve(int n){
    REP(i,1,n){
        if(i+1 <= n && s[i] == s[i+1]){
            return mp(i, i+1);
        } else if(i+2 <= n && s[i] == s[i+2]){
            return mp(i, i+2);
        }
    }
    return mp(-1, -1);
}

int main(){
    scanf("%s", s+1);
    int n = strlen(s+1);
    pii res = solve(n);
    printf("%d %d\n", res.fi, res.se);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>

#include <stdio.h>
#include <string.h>

using namespace std;

constexpr uint64_t gcd(uint64_t m, uint64_t n)
{
    return n == 0 ? m : gcd(n, m % n);
}

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

int main()
{
    uint64_t n,m;
    cin >> n >> m;
    
    string s,t;
    cin >> s >> t;

    const uint64_t l = lcm(n, m);

    map<uint64_t, char> goodstr;
    
    for(uint64_t i = 0; i < n; ++i)
    {
        goodstr[i * l / n + 1] = s[i];
    }
    
    for(uint64_t i = 0; i < m; ++i)
    {
        const auto c = goodstr[i * l / m + 1];
        if(c != '\0' && c != t[i])
        {
            cout << "-1\n";
            return 0;
        }
    }
    
    cout << l << '\n';

    return 0;
}



Measured memory_bytes: 10880
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s,ss;
	cin >> s;
	ss = s;
	reverse(s.begin(), s.end());
	if (s == ss) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 256