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

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> v;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        v.push_back(a);
    }
    vector<int> maxa(n-k+1);
    for(int i=0; i<k; i++){
        maxa[0] += v[i];
    }
    for(int i=1; i<n-k+1; i++){
        maxa[i] = maxa[i-1] + v[i+k-1] - v[i-1];
    }
    int maxnum = *max_element(maxa.begin(), maxa.end());
    double d = (maxnum + k) / 2.0;
    cout<<fixed<<setprecision(10) << d;
}

Measured memory_bytes: 1908
-- https://github.com/minoki/my-atcoder-solutions
import Data.List (unfoldr)
import Data.Char (isSpace)
import qualified Data.ByteString.Char8 as BS

main = do
  [x,y] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let a :: Int
      a = case x of
            3 -> 100000
            2 -> 200000
            1 -> 300000
            _ -> 0
  let b = case y of
            3 -> 100000
            2 -> 200000
            1 -> 300000
            _ -> 0
  let c = case (x,y) of
            (1,1) -> 400000
            _ -> 0
  print $ a+b+c


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;
constexpr int D = 12805;
constexpr int D2 = 25610;
using bs = bitset<D2>;

bs dp[90][90];

int main() {
    int H,W; cin >> H >> W;
    vector<vector<int>> A(H,vector<int>(W));
    rep(i,H)rep(j,W) cin >> A[i][j];
    rep(i,H)rep(j,W) {
        int x; cin >> x;
        A[i][j] = abs(A[i][j] - x);
    }

    dp[0][0][D - A[0][0]] = 1;
    dp[0][0][D + A[0][0]] = 1;
    rep(i,H)rep(j,W) {
        if (i > 0) {
            dp[i][j] |= dp[i - 1][j] << A[i][j];
            dp[i][j] |= dp[i - 1][j] >> A[i][j]; 
        }
        if (j > 0) {
            dp[i][j] |= dp[i][j - 1] << A[i][j];
            dp[i][j] |= dp[i][j - 1] >> A[i][j];
        }
    }
    int ans = INF;
    rep(i,D2) {
        if (dp[H - 1][W - 1][i]) {
            ans = min(ans,abs(i - D));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 24704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc71
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = new int[N];
            long[] E = new long[2];
            E[0] = 0;
            E[1] = 0;
            int f = 0;
            string[] str = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(str[i]);

            }
            Array.Sort(A);
            for(int i = N - 1; i >= 1; i--)
            {
                if (A[i] == A[i - 1])
                {
                    E[f] = (long)A[i];
                    f++;
                    i--;
                }
                if (f == 2)
                {
                    break;
                }
            }
            Console.WriteLine((long)E[0] * E[1]);
        }
    }
}


Measured memory_bytes: 20448
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		System.out.println(a*b);
		saori.close();
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


Measured memory_bytes: 32392
N,M=map(int,input().split())
ab=[list(map(int,input().split())) for l in range(N)]
ct=0
ct1=0
ct2=0
money=0
l=[]
id=[]
for i in range(N):
    l.append(ab[i][0])
id=sorted(range(len(l)),key=lambda k: l[k])
l.sort()
while ct<M:
    while ct2<ab[id[ct1]][1]:##
        money+=l[ct1] #l[ct1]
        #print(money,l[ct1])
        ct+=1
        ct2+=1
        if ct==M:
            break
    ct1+=1
    ct2=0
print(money)



Measured memory_bytes: 33800
S = input()
Slist = list(S)
Slen = len(Slist)
AnsLis = []
for i in range(Slen-2):
    AnsLis.append(int(Slist[i]+Slist[i+1]+Slist[i+2]))
min = 10000
Anslen = len(AnsLis)
for i in range(Anslen):
    if abs(AnsLis[i]-753)<min:
        min = abs(AnsLis[i]-753)
print(min)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    vector< int > points(n, 0);
    vector< int > a(q);
    for (int i = 0; i < q; i++) {
        cin >> a[i];
        points[a[i] - 1]++;
    }
    for (int i = 0; i < n; i++) {
        //正解回数Xとすると最終的な得点はK-Q+X
        //これが正 -> X > Q-K
        if (points[i] > q - k) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




int main() {

    int N; cin >> N;
    vector<ll> a(3*N);
    rep(i, 3*N) cin >> a[i];
    Sort(a);
    Reverse(a);
    ll ans = 0;
    rep(i,2*N) {
        if (i % 2 == 1) ans += a[i];
    }
    out(ans);

    return 0;
}










Measured memory_bytes: 2560
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		int max;
		if(A < B) {
			max = A;
			A = B;
			B = max;
		}
		if(A < C) {
			max = A;
			A = C;
			C = max;
		}
		for(int i = 0;i < K;i++) {
			A = A * 2;
		}
		System.out.println(A+B+C);
		sc.close();
	}
}

Measured memory_bytes: 20820
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] s = new int[n];
    for(int i = 0; i < n; i++) {
      s[i] = sc.nextInt();
    }
    int q = sc.nextInt();
    int[] t = new int[q];
    for(int i = 0; i < q; i++) {
      t[i] = sc.nextInt();
    }
    int count = 0;
    List<Integer> same = new ArrayList<>();
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < q; j++) {
        if(s[i] == t[j] && !same.contains(s[i])) {
          same.add(s[i]);
          count++;
        }
      }
    }
    System.out.println(count);
  }
}



Measured memory_bytes: 40864
# -*- encoding: utf-8 -*-
import sys
import re
import random
import numpy as np
from math import sqrt,log
from fractions import gcd  # python<=3.4
from collections import Counter, defaultdict


def lcm(a, b):
    return a // gcd(a,b) * b

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

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


def extgcd(a, b, c=1, d=0, e=0, f=1):
    # sys.stderr.write("extgcd(%d, %d, %d, %d, %d, %d)\n" % (a,b,c,d,e,f))
    if b == 0:
        return (a, c, e)
    else:
        q = a // b
        r = a % b
        return extgcd(b, r, d, c-q*d, f, e-q*f)

# ll extgcd(ll a, ll b, ll &x, ll &y, ll c=1, ll d=0, ll e=0, ll f=1) {
#   if (b == 0) {
#     x = c; y = e;  // dot([c,d; e,f], [1;0])
#     return a;
#   }
#   ll q = a/b, r = a%b;
#   return extgcd(b, r, x, y, d, c-q*d, f, e-q*f);  // dot([c,d; e,f], [0,1; 1,-q])
# }

def f(u, v):
    a, b = u  # a + bk
    c, d = v  # c + dk
    # sys.stderr.write("F (%d %d) , (%d %d)\n" % (a,b,c,d))
    g = gcd(b, d)
    l = lcm(b, d)
    # ax + b = cy + d
    # ax - cy = (d - b)
    # -ax + cy = b - d
    r = a-c
    # sys.stderr.write("  - %dx + %dy = (%d - %d) = %d; g = %d\n" % (b,d, a,c, a-c, g))
    if r % g != 0:
        return (0, 0)
    # if (r % g) return P(0,0);
    mag = r / g
    # // ax - by = (d - c)
    # //if (a % mag || b % mag) return P(0,0);
    # // ax - by = gcd(a,b) は出る
    # // a /= mag; b /= mag;
    # r = g;

    _a, x, y = extgcd(-b, d)
    # if x < 0:
    #     x += lcd(a, b) / x
    # sys.stderr.write(" // x=%d, y=%d; av=%d\n" % (x,y,_a))

    x *= mag
    y *= mag
    w = a + b*x
    # sys.stderr.write("  w = %d+%dx%d = %d, l=%d\n" % (a,b,x, w, l))
    w %= l
    # sys.stderr.write("  => (%dk + %d)\n" % (l, w))
    if w <= 0:
        w += l

    return (w, l)


def solve(N, M, ar):
    a, b = 1, 1  # a + bk
    # u = (1, 1)
    for i in range(N):
        c, d = (ar[i]//2, ar[i])  # c + dk
        a, b = f((a,b), (c,d))
        if a == b == 0: # u == (0, 0):
            return 0

    # q, p = u
    if a == 0:
        a += b

    # sys.stderr.write("u = (%d %d); range [1, %d]\n" % (a, b, M))
    if a > M:
        return 0
    cnt = 1
    dif = M - a
    cnt += dif // b
    return int(cnt)


def main():
    N, M = read_ints()
    ar = read_ints()
    print(solve(N, M, ar))

if __name__ == '__main__':
    main()


Measured memory_bytes: 25320
/* Akshat Sharma @akshat98 */
#include <iostream>
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp   make_pair
#define pb   push_back
#define F    first
#define S    second
#define ll   long long
#define MOD  1000000007
#define MAX  1000000001
#define vi 	 vector<int>
#define vl   vector<ll>
#define vpi  vector<pair<int,int> >
#define vpl  vector<pair<ll,ll> >
#define rep(i,a,b) for(i=a;i<b;i++)
#define reqp(i,a,b) for(i=a;i<=b;i++)
#define ren for(i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;


int main()
{
	#ifndef ONLINE_JUDGE
	//freopen("input_file.txt", "r", stdin);
	//freopen("output_file.txt", "w", stdout);
	#endif
	ll i,j,k,l,n,test_case,m,r,d,x;
	test_case=1;
	//cin>>test_case;
	while(test_case--){
		cin>>r>>d>>x;
		rep(i,0,10){
			x=1ll*r*x-d;
			cout<<x<<"\n";
		}

	}
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main()
{
    ll l, r; 
    cin >> l >> r;

    int ans = 2018;
    r = min(r, l + 2019);
    for(ll i = l; i <= r; i++){
        for(ll j = i+1; j <= r; j++){
            int x = i * j % 2019;
            ans = min(ans, x);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	long long N, K, MOD = 1000000007;
	cin >> N >> K;
	long long ANS = 0;
	for (long long k = K; k <= N + 1; k++) {
		long long MIN = (k - 1) * k / 2;
		long long MAX = (N + 1) * N / 2 - (N - k) * (N - k + 1) / 2;
		ANS += MAX - MIN + 1;
		ANS %= MOD;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

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

	public Main() {
		Scanner sc = new Scanner(System.in);
		int num = 1;
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			int[] x = new int[n];
			int[] y = new int[n];
			for(int i=0;i<n;i++){
				x[i] = sc.nextInt();
				y[i] = sc.nextInt();
			}
			
			solve(num, n, x, y);
			num++;
		}
	}

	public void solve(int num, int n, int[] x, int[] y) {
		double res = 0;
		for(int i=0;i<n;i++){
			res += (x[i]-x[(i+1)%n])*(y[i]+y[(i+1)%n]);
		}
		System.out.println(String.format("%d %.1f", num, Math.abs(res/2)));
	}

}

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

int main() {
  // cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int N, M, A, B = 1e9+7;
  cin >> N >> M;

  vector<int> vec(N + 1, -1);
  vec.at(0) = 1;
  vec.at(1) = 1;

  for (int i = 0; i < M; i++) {
    cin >> A;
    vec.at(A) = 0;
  }

  for (int i = 2; i < N + 1; i++) {
    if (vec.at(i) != 0) vec.at(i) = (vec.at(i - 2) + vec.at(i - 1)) % B;
  }

  cout << vec.at(N) << endl;
}

Measured memory_bytes: 640
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<"IMPOSSIBLE"<<endl;return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;//19234567892927;
const llint mmd=1e9+7;
const int big=1e12+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int n,i,gen;cin>>n;
	for(i=1;i<=n;i++){
		if(i*(i+1)/2>=n){
			for(int j=1;j<=i;j++){
				if(j!=i*(i+1)/2 -n){cout<<j<<endl;}
			}
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	long long int K,A,B;
	long long int ans = 1;
		scanf("%lld%lld%lld",&K, &A, &B);
		if (A + 2>= B) {
			ans += K;
		}
		while(!K == 0 && A + 2<B){
			if (A < B)
			{
				if (A > ans)
				{
					ans++;
					K--;
				}
				else if (ans >= A && K >= 2)
				{
					ans = ans + B - A;
					K -= 2;
				}
				else if (ans >= A && K == 1)
				{
					ans++;
					K--;
				}
			}
		}
				printf("%lld", ans);
	return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int a, b, c; cin >> a >> b >> c;
	cout << min(b/a, c) << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7724
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if((a+b) > (c+d))
        cout << "Left" << "\n";
    else if((a+b) == (c+d))
        cout << "Balanced" << "\n";
    else
        cout << "Right" << "\n";
    return 0;
}

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

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

    map<int,int> dic;


    for(int i=0; i<num; i++) {
        int val;
        cin >> val;
        dic[val] = i+1;
    }

    for(int i=1; i<=num; i++) {
        if(i != 1) cout << " ";
        cout << dic.at(i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5504
a,b,x=gets.split.map(&:to_f)
V=a*a*b

if V/2.0<=x
  h=2.0*x/a/a
  c=h-b
  d=b-c
  p Math.atan2(d,a)*180.0/Math::PI
else
  h=2.0*x/a/b
  p Math.atan2(b,h)*180.0/Math::PI
end


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

int main()
{
    long long N, ans;
    cin >> N;
    long long a = 1, b = N;
    ans = a + b - 2;
    while (a <= sqrt(N))
    {
        a += 1;
        b -= 1;
        if (N % a == 0)
        {
            b = N / a;
            long long s;
            s = a + b - 2;
            if (s < ans)
            {
                ans = s;
            }
        }
        else
        {
            continue;
        }
    }

    cout << ans << endl;
}

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

int main() {
  int r, D, x;
  cin >> r >> D >> x;
  for(int i=0; i<10; ++i){
    x = r*x - D;
    cout << x << endl;
  }
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

template<typename T>
class BITree2 {
    private:
        // 隣接する値との差分を管理する BIT
        class BITree {
            public:
                BITree() {}
                void Init(int n) {
                    m_N = n + 1;
                    m_Tree.assign(m_N, 0);
                }
                T Sum(int i) {
                    assert(i >= 1 && i < m_N);
                    T s = 0;
                    while(i > 0) { s += m_Tree[i]; i -= i & -i; }
                    return s;
                }
                void Add(int i, T x){ while(i < m_N) { m_Tree[i] += x; i += i & -i; } }
            private:
                int m_N;
                vector<T> m_Tree;
        };
    public:
        BITree2() {}
        BITree2(int n) { Init(n); }
        void Init(int n) { fenwick.Init(n); }
        // 区間 [l, r] の各要素に x を加える O(log m_N)
        void Add(int l, int r, T x) {
            assert(l <= r);
            fenwick.Add(l, x);
            fenwick.Add(r+1, -x);
        }
        // i 番目の要素の値を返す O(log m_N)
        T Get(int i) { return fenwick.Sum(i); }
    private:
        BITree fenwick;
};

ll N, K, Q;
vector<ll> A;

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

    cin >> N >> K >> Q;
    A.resize(Q);
    REP(i, Q) { cin >> A[i]; }

    BITree2<ll> tree(N);

    REP(i, N) {
        tree.Add(i+1, i+1, K);
    }
    REP(i, Q) {
        if(A[i] == 1) {
            tree.Add(A[i]+1, N, -1);
        }
        else if(A[i] == N) {
            tree.Add(1, A[i]-1, -1);
        }
        else {
            tree.Add(1, A[i]-1, -1);
            tree.Add(A[i]+1, N, -1);
        }
    }
    REP(i, N) {
        printf("%s\n", (tree.Get(i+1) > 0) ? "Yes" : "No");
    }

    return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>

int main(){
    double a,b,c,d,e,f,x,y;
    int x2,y2;
	while (scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f) != EOF)
	{
		x = (c*e-f*b)/(a*e-d*b);
		y = (c-a*x)/b;
        x2 = x*10000;
        y2 = y*10000;
        if(x2 % 10 >= 5){
            x2 = x2 + 1;
        }
        if(y2 % 10 >= 5){
            y2 = y2 + 1;
        }
        x = x2 / 10000.0;
        y = y2 / 10000.0;
		printf("%1.3f %1.3f\n",x,y);
	}
    return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <set>
using namespace std;
using ll = long long;


int main()
{
  // 整数の入力
  ll N;
  cin >> N;
  vector<ll> plusplus;
  vector<ll> plusminus;
  for(int i = 0;i < N;i++){
      ll x,y;
      cin >> x >> y;
      plusplus.push_back(x+y);
      plusminus.push_back(x-y);
  }
  sort(plusplus.begin(),plusplus.end());
  sort(plusminus.begin(),plusminus.end());
  cout << max(plusplus.back() - plusplus.front(), plusminus.back() - plusminus.front()) << endl;
  return 0;
}


Measured memory_bytes: 6644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define per(i,m,n) for(int i=m;i>=n;i--)
#define si(x) scanf("%d",&x)
#define pi(x) printf("%d",x)
#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld",x)
const int N = 1e4+10;
const int mod = 1e9+7;
const int inf = 1e9+10;
#define maxn 1000086
int n;
signed main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(max(a*d,b*c),max(a*c,b*d));
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

    private static final int MOD = 1_000_000_007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        System.out.println(Math.min(A * N, B));
    }

}


Measured memory_bytes: 22996
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

int a, b, c;
int main()
{
	while(scanf("%d %d %d", &a, &b, &c) != EOF)
	{
		if(a + b == 2 * c || a + c == 2 * b || b + c == 2 * a)
			printf("YES\n");
		else
			printf("NO\n");
	}
}

Measured memory_bytes: 128
const MOD: u64 = 1e9 as u64 + 7;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n = sc.read();
    let a: Vec<u64> = sc.vec(n);
    let mut stack = 0;
    let mut ans = 1;
    for i in 0..n {
        if 2 * stack + 1 > a[i] {
            ans *= stack + 1;
            ans %= MOD;
        } else {
            stack += 1;
        }
    }
    for i in 1..(stack + 1) {
        ans *= i;
        ans %= MOD;
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
main=do
    n<-readLn::IO Int
    putStrLn $ if n==0 then "0" else f 1 n []

f a n r
    | n==0 = r
    | odd n = f (negate a) ((n-a)`div`2) ('1':r)
    | True  = f (negate a) (n`div`2) ('0':r)


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

int main() {
  long long L,R; cin>>L>>R;
  if(L+2017<R) cout<<0<<endl;
  else{
    L%=2019; R%=2019;
    if(L>=R) cout<<0<<endl;
    else{
      int min=2018;
      for(int i=L;i<R;i++){
        for(int j=L+1;j<=R;j++){
          int x=i*j%2019;
          if(x<min) min=x;
        }
      }
      cout<<min<<endl;
    }
  }
}


Measured memory_bytes: 256
from collections import deque
N,M = map(int, input().split())
ls = deque()
k = deque()
for m in range(M):
    ls.append(deque(map(int, input().split())))
    ls[m].popleft()
p = list(map(int, input().split()))
ans = 0
for i in range (2**N):
    x = str(bin(i))
    x = x[2:]
    f = False
    while len(x) < N:
        x = "0" + x

    for j in range(M):
        tmp = 0

        for k in range(len(ls[j])):
            tmp += int(x[ls[j][k]-1])
        tmp %= 2
        if tmp != p[j]:
            f = True
            break
    if f:
        continue

    ans += 1
print(ans)

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


typedef long long ll;
typedef pair<ll,int> P;

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  ll x;
  cin >> x;
  ll a,b;
  for(ll i=-1000; i<=1000; i++){
    ll cnt = x+i*i*i*i*i;
    if(cnt==0){
      a = 0;
      b = i;
      break;
    }
    if(cnt>0){
      for(ll j=1; j<=1000; j++){
        if(cnt-j*j*j*j*j==0){
          a = j;
          b = i;
          break;
        }
      }
    }else{
      for(ll j=-1000; j<0; j++){
        if(cnt-j*j*j*j*j==0){
          a = j;
          b = i;
          break;
        }
      }
    }
  }
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 3592
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def main():
	A=[]
	for i in range(3):
		A+=list(map(int,input().split()))
	n=int(input())
	
	for i in range(n):
		b=int(input())
		for j in range(9):
			if b==A[j]:
				A[j]=0
	
	ans="No"
	
	for i in range(3):
		if A[i]==A[i+3]==A[i+6]==0:
			ans="Yes"
		if A[i*3]==A[i*3+1]==A[i*3+2]==0:
			ans="Yes"
	
	if A[0]==A[4]==A[8]==0 or A[2]==A[4]==A[6]==0:
		ans="Yes"
		
	print(ans)
	
	
	
	
	
	
	
	

if __name__ == "__main__":
	main()


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

const int64_t INF = 9999999999999;

int main(){
  int N;
  vector<int64_t> A(2000010);

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

  int64_t cur = 0; int64_t min_d = INF;
  for(int i=0; i<N; i++){
    cur += A[i];
    min_d = min(min_d, abs(total-2*cur));
  }

  cout << min_d << endl;
}

Measured memory_bytes: 15872
n, m = [int(i) for i in input().split(" ")]

a = [0 for i in range(0, m)]
b = [True for i in range(0, n + 1)]
dp = [0 for i in range(0, n + 1)]

for i in range(0, m):
    a[i] = int(input())

for i in range(0, m):
    b[a[i]] = False

dp[0] = 1

if b[1]:
    dp[1] = 1
else:
    dp[1] = 0

for i in range(2, n + 1):
    if b[i]:
        dp[i] = dp[i - 1] + dp[i - 2]
    else:
        dp[i] = 0

mod = 10**9 + 7
print(dp[n] % mod)

Measured memory_bytes: 460824
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e5 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;
 
int a[maxn];
int cnt[maxn];
 
 int getSum(int n) 
    {  
    int sum = 0; 
    while (n != 0) 
    { 
     sum = sum + n % 10; 
     n = n/10; 
    }  
 return sum; 
 }
 
int countDigit(long long n) 
{ 
    int count = 0; 
    while (n != 0) { 
        n = n / 10; 
        ++count; 
    } 
    return count; 
} 
 
 
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0;
	int len = 0;
	for(int i=0; i<n; i++){
		if(s[i] == 'R')
			len++;
		else{
			ans=max(ans,len);
			len = 0;
		}
	}
	ans=max(ans,len);
	cout << ans << "\n";
	return 0;
}



Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rall(x) x.rbegin(),x.rend()
#define mu(x) x.resize(unique(all(x))-x.begin());
#define srt(x) sort(all(x));
#define rev(x) reverse(all(x));
#define each(x,a) for(auto& x:a)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define PER(i,a,b) for(int i=a;i>=b;i--)
#define debug(x) cerr<<#x<<" "<<x<<"\n";
#define debug_v(x) { cerr<<#x<<"\n";  each(y,x) cerr<<y<<" "; cerr<<'\n';}
#define debug_vp(x) { cerr<<#x<<"\n";  each(y,x) cerr<<y.ff<<" "<<y.ss<<'\n'; cerr<<'\n';}
#ifndef BTW
	#define cerr if(false)cerr
#endif
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

int main(){
	fastio;
	double L;
	cin>>L;
	double ans=1;
	rep(i,3){
		ans*=L/3;
	}
	cout<<fixed<<setprecision(20)<<ans;
	return 0;
}

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

int main() {
	int x, y, s;
	int max, t, u;
	while(cin >> x >> y >> s, x) {
		max = 0;
		for(int i=1;i<=s;i++) {
			for(int j=1;j<=s;j++) {
				t = (int)(i*(100.0+x)/100.0) + (int)(j*(100.0+x)/100.0);
				u = (int)(i*(100.0+y)/100.0) + (int)(j*(100.0+y)/100.0);
				if(t == s)
					if(max < u)
						max = u;
			}
		}
		cout << max << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
unittest
{
	assert( [ "3 5", "4 2 1", "2 3 1" ].solve == 2 );
	assert( [ "3 8", "4 2 1", "2 3 1" ].solve == 0 );
	assert( [ "11 14", "3 1 4 1 5 9 2 6 5 3 5", "8 9 7 9 3 2 3 8 4 6 2" ].solve == 12 );
}



import std.algorithm;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto k = 0L;
	input.front.formattedRead!"%s %s"( n, k );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	input.popFront;
	auto fs = input.front.split.to!( long[] );
	
	// かかる時間が平均化するように並べ替え
	as.sort!( ( x, y ) => y < x );
	fs.sort;
	
	// k回までの修行で全員が完食できる時間を二分探索
	auto e( long x )
	{
		auto t = 0L;
		foreach( a, f; lockstep( as, fs ) )
		{
			t += ( max( 0L, a * f - x ) + f - 1 ) / f;
			if( k < t ) return false;
		}
		return true;
	}
	return bisect!e( -1L, as.front * fs.back );
}

// 単調増加or減少関数の二分探索
auto bisect( alias pred )( long ng, long ok )
if( is( typeof( pred( ng ) ) : bool ) )
{
	while( 1 < abs( ok - ng ) )
	{
		auto x = ( ok + ng ) / 2;
		if( pred( x ) ) ok = x;
		else            ng = x;
	}
	return ok;
}



Measured memory_bytes: 19312
#include<stdio.h>

 int j, num, gyou, retu, kosuu, A[150][150]={0};
 int jump, time, Det[101]={0}, End[101]={0}, back[101]={0};

void Dsearch(int jump){
 int i;
 for(i=1; i<=num; i++){
   if ( (A[jump][i] == 1) && (Det[i] == 0) ) { 
     back[i] = jump;
     A[jump][i] = 0;
     jump = i;
     time++;
     Det[i] = time;
     i = 1;
   }
   if ( (i == num) && (End[jump] == 0) ) {
     time++;
     End[jump] = time;
     jump = back[jump];
     i = 0;
   }
   if (jump == -1) {
     break;
   }
 }

}

int main(){
 int i;
 scanf("%d", &num);

 for(i=1; i<=num; i++){
   scanf("%d %d", &gyou, &kosuu);
   for(j=0; j<kosuu; j++){
     scanf("%d", &retu);
     A[gyou][retu] = 1;
   }
 }

 for(i=1;i<=num;i++){
   if(Det[i]==0){
     time++;
     Det[i]=time; 
     back[i]=-1;
     Dsearch(i);
   }  
 }

 for(i=1; i<=num; i++){
   printf("%d %d %d\n", i, Det[i], End[i]);
 }

 return 0;
}

Measured memory_bytes: 1820
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define pb push_back
 
int n,x,a[200005];
 
int32_t main(){
   cin>>n;
   for(int i=0;i<n-1;i++){
     cin>>x;
     a[x]++;
   }
   for(int i=1;i<=n;i++){
     cout<<a[i]<<endl;
   }
}

Measured memory_bytes: 4368
#include<stdio.h>
#include<string.h>

void shuffle(char a[], int b);

int main(){
  int t,b,i;
  char ini[201];
  
  while(1){
  scanf("%s",ini);
  	if(ini[0]=='-') return 0;
  scanf("%d",&t);
  	for(i=0;i<t;i++){
  	scanf("%d",&b);
  	shuffle(ini,b);
	} 
  printf("%s\n",ini);
  }
 

  
  return 0;
}

void shuffle (char a[],int b){
	int i,len;
	char temp[200];
	len=strlen(a);
	for(i=0;i<b;i++) temp[i]=a[i];
	for(i=0;i<len-b;i++) a[i]=a[i+b];
	for(i=0;i<b;i++) a[len-b+i]=temp[i];
	
  }

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

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


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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

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

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n;
  cin >> n;
  list<int> h;
  int tmp;
  for(int i=0;i<n;i++){
    cin >> tmp;
    h.push_back(tmp);
  }
  
  int total = 0;
  while(h.size()>0){
    while(h.size()>0&&h.front()==0){
      h.pop_front();
    }
    int min = 1000;
    for(auto p:h){
      if(p==0) break;
      if(p<min){
        min = p;
      }
    }
    for(auto iter=h.begin();iter!=h.end();iter++){
      if(*iter==0)break;
      *iter -= min;
    }
    if(min<1000) total += min;
  }
  cout << total;
  return 0;
}



Measured memory_bytes: 3688
# 解説AC
import numpy as np

def is_symmetric(a):
    """
    対象行列判定 O(N * N)
    """
    return np.array_equal(a, a.T)

def main():
    N = int(input())
    S = [[ord(s) - ord("a") for s in list(input())] for _ in range(N)]

    S = np.array(S)

    ans = 0
    for B in range(N):
        if is_symmetric(np.roll(S, B, axis=1)):
            ans += N

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14552
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
int main(){
	int N,A,B;
	SCD3(N,A,B);
	printf("%d %d\n",min(A,B),max(0,A+B-N));
}

Measured memory_bytes: 256
n, m = map(int, input().split())
s = set(map(int, [input() for _ in range(m)]))
MOD = 10 ** 9 + 7
a = 1 if not 0 in s else 0
b = 1 if not 1 in s else 0
for i in range(2, n + 1):
    if i in s:
        a, b = b, 0
    else:
        a, b = b, (a + b) % MOD
print(b)

Measured memory_bytes: 18336
A,B,C,D = [int(i) for i in input().split()]

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

E = lcm(C,D)

p = B-A+1

ac = p//C
if A%C+p%C >= C+1:
    ac += 1

ad = p//D
if A%D+p%D >= D+1:
    ad += 1

ae = p//E
if A%E+p%E >= E+1:
    ae += 1

print(p-(ac+ad-ae))


Measured memory_bytes: 38384
#include <stdio.h>
#define MAX 100000

int binarySearch(int);

int S[MAX], n;

int main() {
  int q, key;
  int sum = 0;
  int i;

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

  scanf("%d", &q);
  for( i = 0; i < q; i++ ) {
    scanf("%d", &key);
    if( binarySearch(key) ) sum++;
  }

  printf("%d\n", sum);
  
  return 0;
}

int binarySearch(int key) {
  int left = 0, right = n, mid;
  while ( left < right ) {
    mid = (left + right) / 2;
    if ( S[mid] == key ) return 1;
    else if( S[mid] > key ) right = mid;
    else if( S[mid] < key ) left = mid + 1;
  }
  return 0;
}

Measured memory_bytes: 988
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Magatro
{
    static int N = int.Parse(Console.ReadLine());
    static int[] P = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    static void Main()
    {
        long[] A = new long[N];
        long[] B = new long[N];
        int[] R = new int[N]; 
        for(int i = 0; i < N; i++)
        {
            R[P[i] - 1] = i + 1;
        }
for(int i = 0; i < N; i++)
        {
            A[i] = 30000 * (i + 1);
            B[i] = 30000*(N - i + 1) + R[i];
        }
        Write(A, B);
    }
    static void Write(long[] A, long[] B)
    {
        long min = A.Min();
        for(int i = 0; i < N-1; i++)
        {
            Console.Write(A[i]-min+1);
            Console.Write(" ");
        }
        Console.Write(A[N - 1]-min+1);
        Console.WriteLine();
        min = B.Min();
        for (int i = 0; i < N - 1; i++)
        {
            Console.Write(B[i]-min+1);
            Console.Write(" ");
        }
        Console.Write(B[N - 1]-min+1);
        Console.WriteLine();
    }
}


Measured memory_bytes: 7256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd

int n,a[200005],t,v[200005],ans,f[200005],s,p[200005];

unordered_map <int,int> m;

set <int> q;

vector <int> g[200005];

void DFS(int nod){
    v[nod]=1;
    for(int i : g[nod]){
        if(v[i]) continue;
        DFS(i);
        ans+=min(f[nod],f[i]);
        f[nod]-=min(f[nod],f[i]);
        f[i]-=min(f[nod],f[i]);
    }

}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        q.insert(a[i]);
    }
    for(int i=1;i<=n;i++){
        if(m[a[i]]) f[m[a[i]]]++;
        else m[a[i]]=++s,f[s]=1;
    }
    for(int i=1;i<=n;i++){
        if(v[m[a[i]]]) continue;
        for(int k=1;k<=30;k++){
            if(q.find((1<<k)-a[i])!=q.end()) g[m[a[i]]].pb(m[(1<<k)-a[i]]);
        }
        v[m[a[i]]]=1;
    }
    for(int i=1;i<=n;i++) v[i]=0;
    for(int i=0;i<=29;i++){
        if(m[(1<<i)]){
            DFS(m[(1<<i)]);
            ans+=f[m[(1<<i)]]/2;
        }
    }
    for(int i=1;i<=n;i++){
        if(!v[i]){
            DFS(i);
        }
    }
    cout << ans;
}


Measured memory_bytes: 31048
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Doragoso Ball
// 2013/04/26
public class Main{
	Scanner sc=new Scanner(System.in);

	int n, m, nb, k;
	int[] us, vs, ws;
	int s, t;
	int[] bs;

	void run(){
		for(;;){
			n=sc.nextInt();
			m=sc.nextInt();
			nb=sc.nextInt();
			k=sc.nextInt();
			if(n==0){
				break;
			}
			us=new int[m];
			vs=new int[m];
			ws=new int[m];
			for(int i=0; i<m; i++){
				us[i]=sc.nextInt()-1;
				vs[i]=sc.nextInt()-1;
				ws[i]=sc.nextInt();
			}
			s=sc.nextInt()-1;
			t=sc.nextInt()-1;
			bs=new int[nb];
			for(int i=0; i<nb; i++){
				bs[i]=sc.nextInt()-1;
			}
			solve();
		}
	}

	void solve(){
		int N=n*(1<<nb);
		@SuppressWarnings("unchecked")
		ArrayList<E>[] es=new ArrayList[N];
		for(int i=0; i<N; i++){
			es[i]=new ArrayList<E>();
		}
		int[] has=new int[n];
		fill(has, -1);
		for(int i=0; i<nb; i++){
			has[bs[i]]=i;
		}
		for(int i=0; i<m; i++){
			int u=us[i], v=vs[i];
			for(int S=0; S<1<<nb; S++){
				if(has[u]==-1||(S>>has[u]&1)==1){
					int T=S;
					if(has[v]>=0){
						T|=1<<has[v];
					}
					int uS=u*(1<<nb)+S;
					int vT=v*(1<<nb)+T;
					es[uS].add(new E(vT, ws[i]));
				}
				if(has[v]==-1||(S>>has[v]&1)==1){
					int T=S;
					if(has[u]>=0){
						T|=1<<has[u];
					}
					int vS=v*(1<<nb)+S;
					int uT=u*(1<<nb)+T;
					es[vS].add(new E(uT, ws[i]));
				}
			}
		}
		int sS=s*(1<<nb);
		if(has[s]>=0){
			sS|=1<<has[s];
		}
		ArrayList<Integer> d=kDijkstra(es, sS, k)[t*(1<<nb)+((1<<nb)-1)];
		println(""+(d.size()>0?d.get(d.size()-1):"NA"));
	}

	ArrayList<Integer>[] kDijkstra(ArrayList<E>[] es, int s, int k){
		int n=es.length;
		@SuppressWarnings("unchecked")
		ArrayList<Integer>[] d=new ArrayList[n];
		for(int i=0; i<n; i++)
			d[i]=new ArrayList<Integer>();
		PriorityQueue<P> que=new PriorityQueue<P>();
		que.offer(new P(s, 0));
		for(; !que.isEmpty();){
			P p=que.poll();
			if(d[p.v].size()>=k)
				continue;
			d[p.v].add(p.d);
			for(E e : es[p.v])
				que.offer(new P(e.to, p.d+e.cost));
		}
		return d;
	}

	class E{
		int to, cost;

		E(int to, int cost){
			this.to=to;
			this.cost=cost;
		}
	}

	class P implements Comparable<P>{
		int v, d;

		P(int v, int d){
			this.v=v;
			this.d=d;
		}

		public int compareTo(P p){
			return d-p.d;
		}
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 424256