akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int l;
    vector<int> ans;
    cin >> l;
    l--;
    int paths = 0;
    //cout << "20 60" << endl;
    int length = l;
    int now = 1;
    while(length > 0){
        if(length % 2 == 1){
            paths += 2;
            ans.push_back(now);
            ans.push_back(now + 1);
            ans.push_back(length / 2 + 1);
            ans.push_back(now);
            ans.push_back(now + 1);
            ans.push_back(0);
            //cout << now << " " << now + 1 << " " << length / 2 + 1<< endl;
            //cout << now << " " << now + 1 << " " << 0 << endl;
            length = length / 2;
        } else {
            paths += 3;
            ans.push_back(now);
            ans.push_back(20);
            ans.push_back(length);
            //cout << now << " " << 20 << " " << length << endl;
            length--;
            ans.push_back(now);
            ans.push_back(now + 1);
            ans.push_back(length / 2 + 1);
            ans.push_back(now);
            ans.push_back(now + 1);
            ans.push_back(0);
            //cout << now << " " << now + 1 << " " << length / 2 + 1<< endl;
            //cout << now << " " << now + 1 << " " << 0 << endl;
            length = length / 2;
        }
        now++;
    }
    if(now < 20){
        paths++;
        ans.push_back(now);
        ans.push_back(20);
        ans.push_back(0);
        //cout << now << " " << 20 << " " << 0 << endl;
    }
    cout << 20 << " " << paths << endl;
    for(int i = 0; i < 3 * paths; i++){
        cout << ans[i];
        if((i + 1) % 3 == 0){
            cout << endl;
        } else {
            cout << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

/*
    SegmentTree<int> seg(f, def) のように宣言する
    RMQの場合 : 
    auto f = [](int a, int b){return min(a, b);};
    def = INF;
*/
template <typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;
    int n;
    vector<Monoid> dat;
    F f;
    Monoid def; //初期値かつ単位元

    SegmentTree(F f, Monoid def) : f(f), def(def) {}

    void build(vector<Monoid> vec){ //元配列vecをセグメントツリーで表現する
        int siz = vec.size();
        n = 1;
        while (n < siz) n *= 2;
        dat.resize(2 * n - 1, def);
        for (int i = 0; i < siz; i++) dat[i + n - 1] = vec[i]; //最下段に値をいれる
        for (int i = n - 2; i >= 0; i--) dat[i] = f(dat[2 * i + 1], dat[2 * i + 2]); //下の段から順番に値をいれる
    }

    void update(int k, Monoid x){
        k += (n - 1); //最下段のノードにアクセスする
        dat[k] = x; //最下段のノードを更新したら、下の段から順番に値をいれる
        while (k > 0){
            k = (k - 1) / 2;
            dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }

    //[a, b)の区間クエリを実行
    Monoid query(int a, int b){
        return query(a, b, 0, 0, n);
    }

private:
    Monoid query(int a, int b, int k, int l, int r){
        if (r <= a || b <= l) return def; //要求区間と対象区間が交わらなければ、def
        if (a <= l && r <= b) return dat[k]; //要求区間が対象区間を完全に含んでいれば、対象区間を答えの計算に使う
        //要求区間が対象区間の一部を含んでいれば、
        Monoid vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        Monoid vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
};

signed main(){
    int n;
    cin >> n;
    vector<P> vec(n);
    REP(i,n){
        cin >> vec[i].second >> vec[i].first;
    }
    sort(ALL(vec));
    vector<ll> vec1(n), vec2(n);
    REP(i,n){
        vec1[i] = vec[i].first;
        vec2[i] = vec[i].second;
    }
    auto f1 = [](ll a, ll b){return min(a, b);};
    auto f2 = [](ll a, ll b){return max(a, b);};
    SegmentTree<ll> seg1(f1, LINF);
    SegmentTree<ll> seg2(f2, (ll)0);
    seg1.build(vec1);
    seg2.build(vec2);
    ll ans = 0;
    REP(i,n - 1){
        ll sum = 0;
        sum += max((ll)0, seg1.query(0, i + 1) - seg2.query(0, i + 1) + 1);
        sum += max((ll)0, seg1.query(i + 1, n) - seg2.query(i + 1, n) + 1);
        ans = max(ans, sum);
    }
    REP(i,n){
        ll sum = 0;
        sum += vec[i].first - vec[i].second + 1;
        sum += max((ll)0, seg1.query(0, n) - seg2.query(0, n) + 1);
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8304
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			int N = scan.nextInt();
			Long[]A = new Long[N];
			for(int i = 0;i<N;i++)A[i] = scan.nextLong();

			Arrays.sort(A,Collections.reverseOrder());

			long sum = A[0];
			int stock = 2;
			int s = 1;
			long max = A[s];


			if(N==2) {
				System.out.println(A[0]);
				return;
			}

			for(int i = 2;i<N;i++) {
				sum+=max;
				stock--;
				if(stock==0) {
					stock = 2;
					s++;
					max = A[s];
				}
			}

			System.out.println(sum);



		}


	}


}


Measured memory_bytes: 65112
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1E9 + 7;

long long dp[100001][13];

int main(){
    string S;
    cin >> S;
    dp[0][0] = 1;

    rep(i, S.size()){
        if(S[i] == '?'){
            rep(j, 10){
                rep(k, 13){
                    // 上の桁の余りが0~12のすべての場合について計算
                    dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
                    dp[i + 1][(k * 10 + j) % 13] %= MOD;
                }
            }
        }

        else{
            int D = S[i] - '0';
            rep(k, 13){
                // 上の桁の余りが0~12のすべての場合について計算
                dp[i + 1][(k * 10 + D) % 13] += dp[i][k];
                dp[i + 1][(k * 10 + D) % 13] %= MOD;
            }
        }
    }
    cout << dp[S.size()][5] << endl;
}

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

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

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int N)
{
    int ans = 0;

    for (int i = 1; i <= N; ++i)
    {
        auto s = to_string(i);

        if (s.size() % 2)
            ++ans;
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    auto ans = solve(N);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
using namespace std;
int main(){
	double x1,y1,x2,y2,a,b,c,ans;
	cin>>x1>>y1>>x2>>y2;
	a=x1-x2;
	b=y1-y2;
	ans=sqrt(a*a+b*b);
	printf("%.8f",ans);
	
}

Measured memory_bytes: 3268
#include<iostream>
#include<algorithm>
#include<bitset>
using namespace std;
typedef long long ll;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int AB = A + B;
	int CD = C + D;

	if (AB > CD) cout << "Left" << endl;
	if (AB == CD) cout << "Balanced" << endl;
	if (AB < CD) cout << "Right" << endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;


class Program
{
    static void Main(string[] args)
    {
        long a, b, c, d;
        string[] str = Console.ReadLine().Split(' ');
        a = long.Parse(str[0]);
        b = long.Parse(str[1]);
        c = long.Parse(str[2]);
        d = long.Parse(str[3]);

        long countC = b / c - (a - 1)/ c;
        long countD = b / d - (a - 1) / d;
        long lcd = Lcm(c, d);
        long CountCD = b / lcd - (a - 1) / lcd;

        Console.WriteLine("{0}", b - a + 1 - countC - countD + CountCD);
    }

    public static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;

        return Gcd(b, a % b);
    }

    public static long Lcm(long m, long n)
    {
        return m * n / Gcd(m, n);
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,a,b;
int main(){
  cin>>n>>a>>b;
  if(abs(a-b)%2==0)cout<<"Alice"<<endl;
  else cout<<"Borys"<<endl;
}

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

using namespace std;

using ll = long long;

int main(){
    ll a, b;
    cin >> a >> b;
    ll ans = 1;
    ll cnt  = 0;
    while(ans < b){
        ans += a - 1;
        cnt++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
int INF = 1e9+7;
#define rep(i, n) for(auto i=0;i<(n);i++)

int main(int argc, char **argv)
{
  vi v(3);
  v[0] = 1;
  char x, y, c;
  while (cin >> x >> c >> y) {
    swap(v[x-'A'], v[y-'A']);
  }
  rep (i, 3) {
    if (v[i])
      cout << char('A'+i) << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
/***************************************************************
	File name: AtCoder074E.cpp
	Author: ljfcnyali
	Create time: 2019年10月08日 星期二 08时41分45秒
***************************************************************/
#include<bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i ) 
#define mem(a) memset ( (a), 0, sizeof ( a ) ) 
#define str(a) strlen ( a ) 
#define pii pair<int, int>
#define int long long
typedef long long LL;

const int maxn = 310;
const int Mod = 1e9 + 7;

int f[maxn][maxn][maxn], n, m, ans;
bool vis[maxn][maxn][maxn];

inline void Solve(int l, int r, int x)
{
    if ( x == 1 ) 
    {
        REP(i, l, r - 1) REP(j, 0, r - 1) vis[r][i][j] = vis[r][j][i] = true;
        return ;
    }
    if ( x == 2 )
    {
        REP(i, l, r - 1) REP(j, l, r - 1) vis[r][i][j] = true;
        REP(i, 0, l - 1) REP(j, 0, l - 1) vis[r][i][j] = true;
        return ;
    }
    REP(i, 0, l - 1) REP(j, 0, r) vis[r][j][i] = vis[r][i][j] = true;
}

signed main()
{
    scanf("%lld%lld", &n, &m);
    REP(i, 1, m)
    {
        int l, r, x; scanf("%lld%lld%lld", &l, &r, &x);
        Solve(l, r, x);
    }
    f[1][0][0] = 1;
    REP(i, 1, n - 1)
    {
        REP(j, 0, i - 1)
            REP(k, 0, max(0ll, j - 1))
            {
                if ( vis[i][j][k] || !f[i][j][k] ) continue ;
                f[i + 1][j][k] = (f[i + 1][j][k] + f[i][j][k]) % Mod;
                f[i + 1][i][k] = (f[i + 1][i][k] + f[i][j][k]) % Mod;
                f[i + 1][i][j] = (f[i + 1][i][j] + f[i][j][k]) % Mod;
            }
    }
    REP(i, 0, n - 1) REP(j, 0, max(0ll, i - 1)) if ( !vis[n][i][j] ) ans = (ans + f[n][i][j]) % Mod;
    printf("%lld\n", (ans * 3) % Mod);
    return 0;
}

Measured memory_bytes: 254336
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

int MaximumSum(vi a, int n) 
{ 
  
    int dp[n + 1][2]; 
      
    // Intitialising the dp table 
    memset(dp, 0, sizeof(dp)); 
  
    // Base case 
    dp[2][1] = a[1]; 
    dp[2][0] = a[0]; 
  
    for (int i = 3; i < n + 1; i++) { 
        // When i is odd 
        if (i & 1) { 
            int temp = max({ dp[i - 3][1], 
                             dp[i - 3][0],  
                             dp[i - 2][1], 
                             dp[i - 2][0] }); 
              
            dp[i][1] = a[i - 1] + temp; 
            dp[i][0] = max({ a[i - 2] + dp[i - 2][0], 
                             a[i - 2] + dp[i - 3][1], 
                             a[i - 2] + dp[i - 3][0], 
                             a[i - 3] + dp[i - 3][0] }); 
        } 
  
        // When i is even 
        else { 
            dp[i][1] = a[i - 1] + max({ dp[i - 2][1], 
                                        dp[i - 2][0], 
                                        dp[i - 1][0] }); 
              
            dp[i][0] = a[i - 2] + dp[i - 2][0]; 
        } 
    } 
    // Maximum of if we pick last element or not 
    return max(dp[n][1], dp[n][0]); 
} 

void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int x,y;
    cin>>n;
    vi a(n);
    rep(i,0,n) cin>>a[i];
    cout<<MaximumSum(a,n);
}
 
 
signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


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

const int INF = 0x3f3f3f3f;



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int n = (int) s.length();
  int m = (int) t.length();
  vector< vector<int> > dp(n + 1, vector<int>(m + 1));
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (i == 0 || j == 0) {
        dp[i][j] = 0;
      } else if (s[i - 1] == t[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }
  int idx = dp[n][m];
  string ans(idx + 1, ' ');
  for (int i = n, j = m; i > 0 && j > 0;) {
    if (s[i - 1] == t[j - 1]) {
      ans[idx - 1] = s[i - 1];
      i--; j--; idx--;
    } else if (dp[i - 1][j] > dp[i][j - 1]) {
      i--;
    } else {
      j--;
    }
  }
  cout << ans.substr(0, dp[n][m]) << '\n';
  return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    string n;
    cin >> n;
    if (n[0] == '7' ||n[1] == '7' || n[2] == '7' ) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3596
from collections import defaultdict
from collections import deque
#import time

def main():
    # Read stdin
    #start = time.clock()
    fl = input().split(" ")
    V = int(fl[0])
    E = int(fl[1])
    R = int(fl[2])
    # Adjacency list
    G = defaultdict(list)
    for i in range(int(E)):
        s, t, w = [int(x) for x in input().split(" ")]
        G[s].append((t, w))
    # initialized
    d = {}
    INF = float('inf')
    # INF = 10001
    for i in range(V):
        d[i] = INF
    d[R] = 0
    q = deque([R])
    while q:
        # u = heappop(q)
        u = q.popleft()
        for v in G[u]:
            if d[v[0]] > d[u] + v[1]:
                d[v[0]] = d[u] + v[1]
                # heappush(q, v[0])
                q.append(v[0])
    #end = time.clock() - start
    for k in range(V):
        if d[k] == float('inf'):
            print("INF")
        else:
            print(d[k])
    #print('Computation time : {}'.format(end))


if __name__ == '__main__':
    main()

Measured memory_bytes: 106872
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int mod = 1e9 + 7;

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

/*-------------------------------------------*/

int n;
ll dp[1 << 16], a[16][16];

ll f(int S) {
    if(dp[S] != -1) return dp[S];

    dp[S] = 0;
    rep(i, n) if(S >> i & 1) rep(j, i) if(S >> j & 1) dp[S] += a[i][j];

    for(int T = S - 1 & S; T > (S ^ T); T = T - 1 & S)
        chmax(dp[S], f(T) + f(S ^ T));

    return dp[S];
}

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

    cin >> n;
    rep(i, n) rep(j, n) cin >> a[i][j];
    rep(i, 1 << n) dp[i] = -1;

    cout << f((1 << n) - 1) << endl;

    return 0;
}

Measured memory_bytes: 768
from collections import Counter
 
M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
  r = x = 1
  try:
    for i in range(1, n):
      p = x; x = c.get(i); n -= x
      r = r * pow(p, x, M) % M
  except:
    pass
print((r, 0)[n > 1])

Measured memory_bytes: 22636
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }




int main() {
	int n,m;
	cin >> n >>m;
	vector < vector<int>> t(n);
	rep(i, m) {
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		t[u].push_back(v);
		t[v].push_back(u);
	}
	int ans = 1;
	vector<int> already(n);
	stack<int> next;
	next.push(0);
	int index = 0;

	re:
	while (next.size()) {
		int x = next.top();
		next.pop();
		if (already[x] == 1) {
			continue;
		}
		already[x] = 1;
		rep(i, t[x].size()) {
			auto y = t[x][i];
			next.push(y);
		}
	}

	while(1) {
		if (already[index] == 0) {
			ans++;
			next.push(index);
			goto re;
		}
		index++;
		if (index == n) {
			cout << ans << endl;
			return 0;
		}
	}

	return 0;
}



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

int main(void) {
    int a, b, c;
    char d;
    int sum1 = 0, sum2 = 0;
    while (cin >> a >> d >> b >> d >> c) {
        if (a*a+b*b==c*c) ++sum1;
        if (a==b) ++sum2;
    }
    cout << sum1 << endl << sum2 << endl;
    return 0;
}



Measured memory_bytes: 2972
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

bool solve(){
  int n, a[SIZE];
  int ans = INF;
  
  scanf("%d", &n);
  if(n == 0) return false;
  for(int i=0;i<n;i++){
    scanf("%d", a+i);
  }
  sort(a, a+n);
  for(int i=1;i<n;i++)
    ans = min(ans, abs(a[i] - a[i-1]));
  

  printf("%d\n", ans);
  return true;
}

int main(){
  while(solve());
  
  return 0;
}



Measured memory_bytes: 3020
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>
#include<cassert>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

int W, H;

int field[500][500];

struct state {
	int x, y, d;
	state(int _x, int _y, int _d) : x(_x), y(_y), d(_d) {}
};

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

int solver() {
	int ans = (int)1e9;

	int gx = W-1, gy = H-1;

	queue<state> q;
	q.push(state(0, 0, 1));

	while (!q.empty()) {
		state s = q.front(); q.pop();

		if (s.d >= ans) continue;

		if (s.x == gx && s.y == gy) {
			ans = min(ans, s.d);
			continue;
		}

		for (int i=0; i<4; i++) {
			if (!(0 <= s.y + dy[i] && s.y + dy[i] < H && 0 <= s.x + dx[i] && s.x + dx[i] < W)) continue;

			if (field[s.y + dy[i]][s.x + dx[i]] == 0) {
				field[s.y + dy[i]][s.x + dx[i]] = -1;
				field[s.y + 2 * dy[i]][s.x + 2*dx[i]] = -1;
				q.push(state(s.x + 2*dx[i], s.y + 2*dy[i], s.d + 1));
			}
		}
	}

	if (ans == (int)1e9) ans = 0;
	return ans;
}

int main() {

	while (1) {
		cin >> W >> H;
		if (W == 0) break;
		W = 2*W - 1;
		H = 2*H - 1;

		memset(field, 0, sizeof(field));
		cin.ignore();

		string str;
		for (int i=0; i<H; i++) {
			getline(cin, str);

			int n = (int)str.size();
			for (int j=0; j<n; j++) {
				if (str[j] == '1') {
					field[i][j] = 1;
				}
			}
		}

		cout << solver() << endl;
	}

	return 0;
}

Measured memory_bytes: 2204
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
const long long INFll=1ll*INF*INF;
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define sz(a) int((a).size())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
long long genrand(long long L,long long R)
{
	return uniform_int_distribution<long long>(L, R)(rng);
}
//use brackets before operations if taking MOD
//use map only when necessary
//give long long to arrays and variables properly
int mul(int a, int b,int mod = MOD) {
	return int(a * 1ll * b % mod);
}
int norm(int a,int mod = MOD) {
	while(a >= mod) a -= mod;
	while(a < 0) a += mod;
	//a = (a%mod+mod)%mod;
	return a;
}
int powmod(int x,int y,int mod = MOD){
	int res = 1;
	while(y>0)
	{
		if(y&1)
			res = mul(res,x,mod);
		x = mul(x,x,mod);
		y=y>>1;
	}
	return res;
}
int inv(int a,int mod = MOD) {
	return powmod(a, mod - 2);
}
int main() {
	fast();

	int n, k, c; cin>>n>>k>>c;
	string s;
	cin>>s;
	s = ' '+s;
	vector<int> l(n+2), r(n+2);
	l[0] = -c;
	int idx = 0;
	for(int i = 1; i<=n && idx<k; i++){
		if(s[i]=='o' && i-l[idx]>c){
			idx++;
			l[idx] = i;
		}
	}
	r[k+1] = n+c+1;
	idx = k+1;
	vector<int> res;
	for(int i = n; i>=1 && idx>0; i--){
		if(s[i]=='o' && r[idx] - i>c){
			idx--;
			r[idx] = i;
			if(l[idx]==i){
				res.pb(i);
			}
		}
	}
	reverse(all(res));
	for(auto e: res){
		cout<<e<<endl;
	}
	return 0;
}

Measured memory_bytes: 4556
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

bool in(ll y, ll x, ll h, ll w){
	return 0 <= y && y < h && 0 <= x && x < w;
}

int main(){
	ll n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	ll ans = linf;
	for(int i=-100; i<=100; i++){
		ll cnt = 0;
		rep(j,n){
			cnt += (i-a[j])*(i-a[j]);
		}
		chmin(ans,cnt);
	}
	cout << ans << endl;
}

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
auto& errStream=cerr;
#ifdef LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	int n=read();
	map<int,int> cnt;
	REP(i,n){
		cnt[read()]++;
	}
	int ans=0;
	for(auto itr=cnt.rbegin();itr!=cnt.rend();itr++){
		int v=itr->first,c=itr->second;
		int s=64-__builtin_clzll(v);
		int w=0;
		REP(i,s)
			if(((v>>i)&1)==0)
				w+=(int(1)<<i);
		w++;
		if(v==w){
			ans+=c/2;
		}else{
			assert(w<v);
			if(cnt.count(w)){
				int t=min(cnt[w],c);
				ans+=t;
				cnt[w]-=t;
			}
		}
	}
	print(ans);
}


Measured memory_bytes: 12800
S = gets.chomp.split('')
ans=true
nums=[0,0,0]
nums[0]=S.count{|s|s=='a'}
nums[1]=S.count{|s|s=='b'}
nums[2]=S.count{|s|s=='c'}
min=nums.min
nums=nums.map{|n|n-=min}
puts nums.max<2 ? "YES" : "NO"

Measured memory_bytes: 22636
#include <bits/stdc++.h>
using namespace std;
inline int read(){
    int x = 0; char c = getchar();
    while (!isdigit(c)) c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0',c = getchar();
    return x;
}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
int n,m;
int main(){
	n = read(),m = read();
	if (n==m) puts("Yes"); else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include<random>
#include<iostream>
using namespace std;

int o[10];
int oo[100];
int ooo[1000];

int main() {
	int N;
	char S[30001];
	cin >> N;
	cin >> S;
	for(int i=0;i<10;i++){
		o[i] = 0;
	}
	for(int i=0;i<100;i++){
		oo[i] = 0;
	}
	for(int i=0;i<1000;i++){
		ooo[i] = 0;
	}

	for(int i=0;i<N;i++){
		int p = S[i]-'0';
		for(int i=0;i<100;i++){
			if(oo[i] == 1){
				ooo[i*10+p] = 1;
			}
		}
		for(int i=0;i<10;i++){
			if(o[i] == 1){
				oo[i*10+p] = 1;
			}
		}
				o[p] = 1;
	}

	int ans = 0;
	for(int i=0;i<1000;i++){
		if(ooo[i] == 1){
			ans += 1;
		}
	}
	cout << ans << "\n";
}

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

using T=long long int;
class SegmentTree{
    vector<T> dat;
    int N;
    T E;
    function<T(T,T)> merge;
    T query_impl(int a,int b,int k,int l,int r);
    public:
    SegmentTree(int N,function<T(T,T)> merge,T E);
    void update(int pos,T val);        
    T query(int a,int b);
};

SegmentTree::SegmentTree(int N,function<T(T,T)> merge,T E):E(E),merge(merge){
    this->N=1;
    while(this->N<N){
        (this->N)*=2;
    }
    dat.assign(this->N*2-1,E);
}

void SegmentTree::update(int pos,T val){
    pos+=N-1;
    dat[pos]=val;
    while(pos!=0){
        int par=(pos-1)/2;
        int c1=par*2+1;
        int c2=par*2+2;
        dat[par]=merge(dat[c1],dat[c2]);
        pos=par;
    }
}

T SegmentTree::query(int a,int b){
    assert(a<=b);
    return query_impl(a,b,0,0,N);
}

T SegmentTree::query_impl(int a,int b,int k,int l,int r){
    if(a<=l && r<=b) return dat[k];
    if(r<=a || b<=l) return E;
    int mid=(l+r)/2;
    T c1v=query_impl(a,b,k*2+1,l,mid);
    T c2v=query_impl(a,b,k*2+2,mid,r);
    return merge(c1v,c2v);
}

T mymin(T lhs,T rhs){
    return min(lhs,rhs);
}
int main(){
    int n,q;
    cin>>n>>q;
    int a,b;
    cin>>a>>b;
    a--,b--;
    vector<int> x(q+1);
    x[0]=a;
    for(int i=0;i<q;i++){
        cin>>x[i+1];
        x[i+1]--;
    }
    
    SegmentTree segl(n,mymin,1e15);
    SegmentTree segr(n,mymin,1e15);
    segl.update(b,-b);
    segr.update(b,b);
    T plus=0;
    for(int i=1;i<=q;i++){
        T v0=segl.query(0,x[i])+x[i];
        T v1=segr.query(x[i],n)-x[i];
        T p=min(v0,v1);
        T tmp=segl.query(x[i-1],x[i-1]+1)+x[i-1];
        if(p<tmp+abs(x[i]-x[i-1])){
            segl.update(x[i-1],p-abs(x[i]-x[i-1])-x[i-1]);
            segr.update(x[i-1],p-abs(x[i]-x[i-1])+x[i-1]);
        }
        plus+=abs(x[i]-x[i-1]);
    }
    T res=1e15;
    for(int i=0;i<n;i++){
        res=min(res,segl.query(i,i+1)+i);
    }
    cout<<res+plus<<endl;
    return 0;
}

Measured memory_bytes: 9216
#include<cstdio>
#include<algorithm>

using namespace std;

struct STU{
	int ai,bi;
}stu[55];

struct SIT{
	int xi,yi;
}sit[55];

struct DIS{
	long long dis;
	int order;
}dis[55];

bool cmp(DIS a,DIS b){
	if(a.dis==b.dis){
		return a.order<b.order;
	}
	return a.dis<b.dis;
}

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d %d",&stu[i].ai,&stu[i].bi);
	}
	for(int j=1;j<=m;j++){
		scanf("%d %d",&sit[j].xi,&sit[j].yi);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			dis[j].dis=abs(stu[i].ai-sit[j].xi)+abs(stu[i].bi-sit[j].yi);
			dis[j].order=j;
		}
		sort(dis+1,dis+m+1,cmp);
		printf("%d\n",dis[1].order);
	}
	return 0; 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >=0; --i)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<ll, ll>;


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

  vector<vector<ll> > to(n);

  //ll to[n][n];
  //  cout<< "#"<<endl;

  vector<ll> v(n);
  vector<bool> visited(n, false);
  ll a, b;
  //cout<< "#"<<endl;
  rep(i, m){
    cin >> a>>b;
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  queue<ll> q;
  q.push(0LL);
  v[0] = 0 ;
  while(!q.empty()){
    ll cur = q.front();
    q.pop();
    for(auto x: to[cur]){
      if(visited[x]==false){
	v[x] = cur;
	visited[x] = true;
	q.push(x);
      }
    }
  }

  cout << "Yes" <<endl;
  rep(i, n-1){
    cout << v[i+1] + 1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 12888
fun main(arg: Array<String>){
    val n = readLine()!!.toInt()
    val s = readLine()!!

    var ans = 0
    for(i in 1 until n){
        var max = 0
        val s1 = s.substring(0, i).toCharArray().distinct()
        val s2 = s.substring(i, n).toCharArray().distinct()

        for (j in s1){
            for(k in s2){
                if (j == k) max++
            }
        }
        if(ans < max) ans = max
    }
    println(ans)
}

Measured memory_bytes: 38048
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a<=5) System.out.println("0");
		else if(a>=6 && a<=12) System.out.println(b/2);
		else System.out.println(b);
	}

}


Measured memory_bytes: 26976
#include <iostream>
#include <string>
#include <vector>
#include "limits.h"
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <functional>
# 

#define mod 1000000000+7;
typedef long long ll;
using namespace std;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	ll a,b; cin >> a >> b;
	cout << a*b/__gcd(a,b) << "\n";
}

Measured memory_bytes: 3652
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion
void Main();

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

void Main(){
    vec<int> A(3);
    int p0=0, p1=0;
    int ans = 0;
    REP(i, 3){
        cin >> A[i];
        if(A[i]%2){
            p1++;
        }else{
            p0++;
        }
    }
    if(p1!=0 && p0!=0){
        ans++;
        REP(i, 3){
            if((A[i]%2 && p1==1) || (A[i]%2==0 && p0==1)){
                A[i]--;break;
            }
        }
    }
    sort(ALL(A));
    ans += (A[2]*2-A[0]-A[1])/2;
    cout << ans << el;
}



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

using P=pair<int,int>;

const int di[]={1,0};
const int dj[]={0,1};


int main(){
  int h,w;
  cin >> h >> w;
  int sx,sy;
  sx=0;
  sy=0;
  int gx,gy;
  gx=h-1;
  gy=w-1;
  vector<string> s(h);
  for(int i=0;i<h;++i){
    cin >> s[i];
  }
  vector<vector<int>> dist(h,vector<int>(w,1000000));
  queue<P> q;
  bool is_block=false;
  int cost=0;
  if(s[0][0]=='#'){
    dist[0][0]=1;
    is_block=true;
  }else{
    dist[0][0]=0;
  }
  q.push(P(sx,sy));
  while(!q.empty()){
    int i=q.front().first;
    int j=q.front().second;
    q.pop();
    if(s[i][j]=='#') is_block=true;
    if(s[i][j]=='.') is_block=false;
    for(int dir=0;dir<2;++dir){
      cost=0;
      int ni=i+di[dir];
      int nj=j+dj[dir];
      if(ni<0 || ni>=h || nj<0 || nj>=w) continue;
      if(s[ni][nj]=='#' && is_block==false){
        cost++;

      }
        //dist[ni][nj]=min(dist[i][j]+cost,dist[ni][nj]);
        if(dist[i][j]+cost<dist[ni][nj]){
          dist[ni][nj]=dist[i][j]+cost;
          q.push(P(ni,nj));
        }
      }
    }

  int ans=dist[gx][gy];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define inf 100000000
#define N 1000
char ch[N];
int j,a[N][N],n,i,nn,sum,x,y,ans;
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%s",ch);
		for (j=1;j<=n;j++)
			a[i][j]=ch[j-1]-'a'+1;
	}
	nn=n*2;
	for (i=1;i<=n;i++) for (j=1;j<=n;j++) a[i+n][j]=a[i][j+n]=a[i+n][j+n]=a[i][j];
	for (i=n;i>=1;i--)
	{
		x=1,y=i;sum=0;
		for (int o=0;o<n;o++) for (int p=o+1;p<n;p++)
			if (a[x+o][y+p]!=a[x+p][y+o]) sum++;
		if (sum==0) ans++;
	//	pr(x),pr(y),pr(sum);pr(ans);
		for (int j=1;j<=nn;j++)
		{
			for (int o=0;o<n;o++) if (a[x][y+o]!=a[x+o][y]) sum--;
			x++,y++;
			if (x>n||y>n) break;
			for (int o=0;o<n;o++) if (a[x+o][y+n-1]!=a[x+n-1][y+o]) sum++;
			if (sum==0) ans++;
 		//	pr(x),pr(y),pr(sum);pr(ans);
		}
	}
	for (i=n;i>1;i--)
	{
		x=i,y=1;sum=0;
		for (int o=0;o<n;o++) for (int p=o+1;p<n;p++)
			if (a[x+o][y+p]!=a[x+p][y+o]) sum++;
		if (sum==0) ans++;
	//	pr(x),pr(y),pr(sum);pr(ans);
		for (int j=1;j<=nn;j++)
		{
			for (int o=0;o<n;o++) if (a[x][y+o]!=a[x+o][y]) sum--;
			x++,y++;
			if (x>n||y>n) break;
			for (int o=0;o<n;o++) if (a[x+o][y+n-1]!=a[x+n-1][y+o]) sum++;
			if (sum==0) ans++;
 		//	pr(x),pr(y),pr(sum);pr(ans);
		}
	}
	printf("%d\n",ans);
}

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

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

  int tot = (l-1)*n+n*(n+1)/2;
  int cnt = 1;

  int mn = inf;
  for(int i = 1; i <=n; i++){
    if(mn >= abs(l+i-1)){
      mn = abs(l+i-1);
      cnt = i;
    }
  }
  cout << tot - (l+cnt-1) << endl;
    
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll x,y; cin>>x>>y;
	cout<<(abs(x-y)<=1?"Brown":"Alice")<<'\n';
}


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

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

  if(a<b) {
    int c=b;
    b=a;
    a=c;
  }

  while(b){
    int r=a%b;
    a=b;
    b=r;
  }
  cout <<a<<endl;
  
  return 0;
}

Measured memory_bytes: 1160
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
li = [0] * n
for i, v in enumerate(rl()):
    li[v-1] = str(i+1)
print(' '.join(li))




Measured memory_bytes: 23112
#include<stdio.h>

#define MAX 100

int	A[ MAX + 1 ] ;
int	B[ MAX + 1 ] ;

int main( void )
{
	int C = 0 ;
	int p ;

	int N ;
	scanf( "%d" ,&N ) ;
	do
	{
		A[ N ] = 1 ;
		B[ N ] = 0 ;

	}	while( --N ) ;

	scanf( "%d" ,&N ) ;
	while( N-- )
	{
		scanf( "%d" ,&p ) ;

		A[ p ] = 0 ;
	}

	scanf( "%d" ,&N ) ;
	while( N-- )
	{
		scanf( "%d" ,&p ) ;
		
		B[ p ] = 1 ;
	}

	scanf( "%d" ,&N ) ;
	while( N-- )
	{
		scanf( "%d" ,&p ) ;

		C += A[ p ] | B[ p ] ;
	}

	printf( "%d\n" ,C ) ;

	return 0 ;
}


Measured memory_bytes: 2076
<?php
$input = array_map('intval', explode(' ', fgets(STDIN)));
$a = $input[0];
$b = $input[1];

if (($a>0)and($b>0)) {
    print 'Positive';
} elseif ((($a>0)and($b<0))or(($a<0)and($b>0))) {
    print 'Zero';
} else {
    if ((($a-$b)-1)%2==0){
        print 'Positive';
    } else {
        print 'Negative';
    }
}

Measured memory_bytes: 4728
;/**
        	C++14 (GCC 5.4.1)
**/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int count = 1;
    for(int i = 1 ; i < s.size(); i++){
        if(s[i-1] != s[i]){
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 512
import sys

# sys.stdin = open('c1.in')

M = 10 ** 9 + 7


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


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


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


def read_str():
    return input()


def is_prime(n):
    for d in range(2, n - 1):
        if n % d == 0:
            return False
    return True


def main():
    n = read_int()
    res = 1
    for p in range(2, n + 1):
        if is_prime(p):
            np = 0
            for i in range(1, n + 1):
                j = i
                while j % p == 0:
                    j //= p
                    np += 1
            res *= np + 1
            res %= M
    print(res)


main()


Measured memory_bytes: 3064
#define errOut(s) \
  { std::cerr << __LINE__ << ":" << #s << ":" << (s) << std::endl; }

#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>
//#include <boost/range/adaptors.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

int64_t solve(int64_t n, int64_t m, int64_t k, std::vector<int64_t> as,
              std::vector<int64_t> bs) {
  if (as.back() > k && bs.back() > k) {
    return 0;
  }

  int64_t aSum = 0;
  std::vector<int64_t> cumulativeAs;
  cumulativeAs.reserve(n + 1);
  cumulativeAs.push_back(0);
  for (auto const a : as) {
    aSum += a;
    cumulativeAs.push_back(aSum);
  }
  int64_t bSum = 0;
  std::vector<int64_t> cumulativeBs;
  cumulativeBs.reserve(m + 1);
  cumulativeBs.push_back(0);
  for (auto const b : bs) {
    bSum += b;
    cumulativeBs.push_back(bSum);
  }
  if (aSum + bSum <= k) {
    return n + m;
  }

  int64_t ret = 0;
  for (int i = 0; i < n + 1; i++) {
    int64_t const rest = k - cumulativeAs[i];
    if (rest < 0) {
      break;
    }
    auto const upper =
        std::upper_bound(cumulativeBs.begin(), cumulativeBs.end(), rest);
    int64_t bCount = upper - cumulativeBs.begin() - 1;
    if (bCount < 0) {
      continue;
    }
    ret = std::max(ret, i + bCount);
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  int64_t m;
  std::cin >> m;
  int64_t k;
  std::cin >> k;
  std::vector<int64_t> as(n);
  for (int i = 0; i < n; i++) {
    std::cin >> as[i];
  }
  std::vector<int64_t> bs(m);
  for (int i = 0; i < m; i++) {
    std::cin >> bs[i];
  }
  auto const res = solve(n, m, k, std::move(as), std::move(bs));
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 9520
n = int(input())
t = []
for i in range(n):
    t.append(int(input()))

# 最大公約数(greatest_common_divisor)
def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a%b)

# 最小公倍数(lowest_common_multiple)
def lcm(a, b):
  return a*b//gcd(a,b)

# 最小公倍数と、比べていない数字を比べ、最小公倍数を更新する
alcm = t[0]
for i in t[1:]:
  alcm = lcm(alcm, i)

print(alcm)

Measured memory_bytes: 3060
n = gets.to_i
a = gets.split.map(&:to_i)

sum_x = 0
sum_y = 0
x = a.map { |b| sum_x += b; sum_x }
y = a.reverse.map { |b| sum_y += b; sum_y }.reverse

ans = x.last
x.each_index do |i|
  next if i + 1 == n
  ans = [ans, (x[i] - y[i + 1]).abs].min
end

puts ans


Measured memory_bytes: 26372
#include<stdio.h>
int main(){
    int L,R,d;
    scanf("%d",&L);
    scanf("%d",&R);
    scanf("%d",&d);

    int a=0,i;
    for(L;L<=R;L++){
        if(L%d == 0){
            a++;
        }
    }

    printf("%d",a);
    return 0;
}

Measured memory_bytes: 1728
//
//  Digit Sums.cpp
//  NYU Progteam
//
//  Created by Xinyu Qu on 3/6/20.
//  Copyright © 2020 Xinyu Qu. All rights reserved.
//

#include <stdio.h>
#include <iostream>
using namespace std;

int main(){
    int a;
    cin >> a;
    string s = to_string(a);
    int res = 0;

    for(int i = 0; i < s.size(); i++){
        res += s[i] - '0';
    }

    if(a % res == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main() {
  	int L, R, d, cnt=0;
  	cin >> L >> R >> d;
	for(int i=0;i<=R-L;i++){
    	if((L+i)%d == 0){
        	cnt++;
        }
    }
  	cout << cnt << endl;
}


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

int main(){
    int N,s,a;
    s=0;
    scanf("%d",&N);
    a=N;
    while (N){
        s += N%10;
         N /= 10;
    }
    if (a%s==0){
        printf("Yes\n");
    }else{
    printf("No\n");
    }
}




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define	MAX_N 44
int dp[MAX_N+1];

int main(int argc, char* argv[]){
  int i,j,n;
  scanf("%d\n", &n);
  n = n+1;
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  dp[1] = 1;
  for (i=2;i<n;i++) {
    dp[i] = dp[i-1] + dp[i-2];
  }
  printf("%d\n", dp[n-1]);
return 0;
}

Measured memory_bytes: 600
s=int(input())
nums=[]
now=s
cnt=0
nums.append(now)
while cnt<1000100:
        cnt+=1
        if now%2==0:
                now=now//2
        else:
                now=(now*3+1)
        if now in nums:
                break
        nums.append(now)
print(cnt+1)

Measured memory_bytes: 3060
/*
 author : @itzmv
 */
#include<bits/stdc++.h>
using namespace std;

#define ll int64_t
#define llu uint64_t
#define lli long long int
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define inf (ll)(1e9)

int main()
{
    int n;
    cin >> n;
    if(n % 1000 != 0) cout << 1000 - (n % 1000);
    else cout << 0;
    return 0;
}


Measured memory_bytes: 3524