akhauriyash/Code-Regression huggingface dataset:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, m = MAP()
s = STR()
ans = []
i = n
while i > 0:
    if s[i] == '0':
        prei = i
        for j in reversed(range(1, m + 1)):
            if i - j >= 0 and s[i - j] == '0':
                ans.append(str(j))
                i -= j
                break
        if i == prei:
            print(-1)
            exit()
ans.reverse()
print(' '.join(ans))

Measured memory_bytes: 68332
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
a = [inp() for _ in range(n)]
a.sort()
res = INF
for i in range(n-k+1):
    res = min(res, a[i+k-1] - a[i])
print(res)

Measured memory_bytes: 9592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t n,k,i,ans,a,b,c;
  cin >> n;
  cin >> k;
  ans=n;
  a=n/k;
  if((n-(a*k))<ans){
    ans=n-a*k;
  }
  
  if((n-(a+1)*k)*-1<ans){
    ans=n-(a+1)*k;
    ans*=-1;
  }
  
  cout << ans << endl;
  
}


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

int main()
{
    int a, ans;
    cin >> a;
    
    if (a <= 10000) ans = 10000 - a;
    if (a <= 9000) ans = 9000 - a;
    if (a <= 8000) ans = 8000 - a;
    if (a <= 7000) ans = 7000 - a;
    if (a <= 6000) ans = 6000 - a;
    if (a <= 5000) ans = 5000 - a;
    if (a <= 4000) ans = 4000 - a;
    if (a <= 3000) ans = 3000 - a;
    if (a <= 2000) ans = 2000 - a;
    if (a <= 1000) ans = 1000 - a;
    
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main() {
    int n, k;
    cin >> n >> k;
    int v[n];
    for (int i = 0; i < n; i++) cin >> v[i];
    int ans = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k - x; y++) {
            int z = k - (x + y);
            priority_queue<int, vector<int>, greater<int>> que;
            int sum = 0;
            for (int i = 0; i < min(x, n); i++) {
                sum += v[i];
                que.push(v[i]);
            }
            for (int i = n - 1; i >= max(0, n - y) && que.size() < n; i--) {
                sum += v[i];
                que.push(v[i]);
            }
            for (int i = 0; i < z && !que.empty(); i++) {
                int t = que.top(); que.pop();
                if (t >= 0) break;
                sum -= t;
            }
            ans = max(ans, sum);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3584
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int[][] grid;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		grid = new int[2][n];
		for(int i =0; i <2; i++){
			for(int j =0; j < n; j++){
				grid[i][j] = sc.nextInt();
			}
		}
		memoGrid = new int[2][n];
		Arrays.fill(memoGrid[0], 0);
		Arrays.fill(memoGrid[1], 0);
		move(0,0,0);
		System.out.println(memoGrid[1][n-1]);

	}
	private static int[][] memoGrid;

	private static void move(int i, int j, int score){
		int length = memoGrid[0].length;
		score += grid[i][j];
		if(score < memoGrid[i][j]) return;
		memoGrid[i][j] = score;
		boolean canDown = i == 0;
		boolean canRight = j < length-1;
		if(canDown){
			if(canRight) move(i+1,j+1,score);
			move(i+1,j,score);
		}
		if(canRight) move(i, j+1, score);
	}
}

Measured memory_bytes: 21844
#include "stdio.h"

int N, X, L, R = 0;

int main(void){
  int i = 0;
  scanf("%d %d\n", &N, &X);
  while(i < N){
    scanf("%d ", &L);
    R += L;
    if(R > X){
      break;
    }else{
      i++;
    }
  }
  printf("%d", i + 1);
}

Measured memory_bytes: 128
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def lcm(a,b):return a*b//gcd(a,b)
l=a[0]
for i in range(1,n):
  l=lcm(l,a[i])
ans=0
l%=mod
for i in range(n):
  ans+=l*pow(a[i],mod-2,mod)
  ans%=mod
print(ans)


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long W;
  scanf("%lld", &W);
  long long H;
  scanf("%lld", &H);
  long long x;
  scanf("%lld", &x);
  long long y;
  scanf("%lld", &y);

  cout << fixed << setprecision(9) << double(W) * double(H) / 2.0 << " "
       << ((double(W) / 2.0) == x && (double(H) / 2.0) == y) << endl;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	long long n;
	
	scanf("%lld",&n);
	
	printf("%lld",((n*(n+1))/2)-(((3*(n/3)*((n/3)+1)))/2)-(((5*(n/5)*((n/5)+1)))/2)+(((15*(n/15)*((n/15)+1)))/2));
	
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<pair<int, int>> V1(100001), V2(100001);
  for (int i = 0; i < 100001; i++) {
    V1.at(i) = {0, i};
    V2.at(i) = {0, i};
  }
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (i % 2) V1.at(A).first++;
    else V2.at(A).first++;
  }
  sort(V1.rbegin(), V1.rend());
  sort(V2.rbegin(), V2.rend());
  if (V1.at(0).second != V2.at(0).second) {
    cout << N - V1.at(0).first - V2.at(0).first << "\n", 0;
  } else {
    int ans1 = N - V1.at(0).first - V2.at(1).first;
    int ans2 = N - V1.at(1).first - V2.at(0).first;
    cout << min(ans1, ans2) << "\n";
  }
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        int[][] a = new int[N][2];
        for (int i = 0; i < N; i++) {
            a[i][0] = sc.nextInt();
            a[i][1] = i+1;
        }
        Arrays.sort(a, (o1, o2) -> o1[0]-o2[0]);
        for (int i = 0; i < N; i++) {
            if (i!=0){
                System.out.print(" ");
            }
            System.out.print(a[i][1]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 66740
/*input
2
10 30
*/
#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define MAX 100005
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define ff first
#define ss second
#define T int t;cin>>t;while(t--)
#define ld long double
using namespace std;

signed main(){
	int n;
	cin>>n;
	ld tot=0;
	while(n--){
		ld x;
		cin>>x;
		tot+=((ld)1)/x;
	}
	tot = (ld)1/tot;
	cout<<setprecision(10)<<tot<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(ll i = a; i <= (n); ++i)
#define repD(i, a, n) for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (long long) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define MAXN 5000000
const long double PI = 3.141592653589793238462643383;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<double> vd;
typedef vector<pii> vii;
const long long mod = 1000000007;
int Ceil(int a, int b){
    if(a%b==0) return a/b;
    else return (a/b)+1;
}

int main(){
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);   
    freopen("output.txt", "w", stdout);
    #endif
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int r;
    cin>>r;
    cout<<2*PI*r;
    return 0;
}

Measured memory_bytes: 3820
import sys

def main():
    S = str(input())

    if(S=="SUN"):
        print('7')

    if(S=="MON"):
        print('6')

    if(S=="TUE"):
        print('5')

    if(S=="WED"):
        print('4')

    if(S=="THU"):
        print('3')

    if(S=="FRI"):
        print('2')

    if(S=="SAT"):
        print('1')

    sys.exit()

main()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
	string g[100];
	int h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++)
	{
		cin>>g[i];
	}
	for(int i=0;i<w+2;i++)
	{
		cout<<"#";
	}
	cout<<endl;
	for(int i=0;i<h;i++)
	{
		g[i].insert(0,"#");
		g[i]+="#";
		cout<<g[i]<<endl;
	}	
	for(int i=0;i<w+2;i++)
	{
		cout<<"#";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = std::vector<int>;
using Vlli = std::vector<lli>;
using Wint = std::vector<Vint>;
using Wlli = std::vector<Vlli>;
using Vbool = std::vector<bool>;
using pii = std::pair<int, int>;
using pll = std::pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {std::make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

std::string s;
int A[4]={0, 0, 0, 0};

int main(void){
  cin >> s;
  vREP(ele, s){
    switch(ele){
      case 'N':
        A[0]++;
        break;
      case 'W':
        A[1]++;
        break;
      case 'E':
        A[2]++;
        break;
      case 'S':
        A[3]++;
        break;
    }
  }
  bool flag1 = (A[0] != 0) == (A[3] != 0),
       flag2 = (A[1] != 0) == (A[2] != 0);
  std::cout << ((flag1 and flag2) ? "Yes" : "No" ) << BR;
  return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

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

        Set set = new HashSet<Character>();
        char[] chars = s.toCharArray();
        for (char c : chars) {
            set.add(c);
        }

        for (char c = 'a'; c <= 'z'; c++) {
            if (!set.contains(c)) {
                System.out.println(s + c);
                return;
            }
        }

        while (s.length() > 1) {
            s = s.substring(0, s.length() - 1);
            set = new HashSet<Character>();
            chars = s.toCharArray();
            for (char c : chars) {
                set.add(c);
            }
            for (char c = (char) (chars[chars.length - 1] + 1); c <= 'z'; c++) {
                if (!set.contains(c)) {
                    chars[chars.length - 1] = c;
                    System.out.println(new String(chars));
                    return;
                }
            }
        }

        System.out.println("-1");
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
using namespace std;

int main(){
    int N, T; cin >> N >> T; int t[N], X;
    for (int i = 0; i < N; i++){
        cin >> t[i];
        if (i > 0){
            if (t[i]-t[i-1] < T) X += t[i]-t[i-1];
            else                 X += T;
        } else X = T;
    }

    cout << X << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll n, c, k;
  cin >> n >> c >> k;

  vector<ll> t(n);

  REP(i, n) { cin >> t[i]; }

  sort(all(t));

  int ans = 0, nc, nk = -1;

  for (int i = 0; i < n; i++) {
    if (nk < t[i] || !nc) {
      ans++;
      nc = c - 1;
      nk = t[i] + k;
    } else {
      nc--;
    }
  }

  cout << ans << "\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  ll dp[100010] = {};
  int n,m;
  cin >> n >> m;
  int a[100010] = {};
  REP(i,m) {
    int k;
    cin >> k;
    a[k] = 1;
  }
  dp[0] = 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 1) continue;
    dp[i] = (dp[i] + dp[i-1]) % MOD;
    if (i-2 >= 0) dp[i] = (dp[i] + dp[i-2]) % MOD;
  }
  cout << dp[n] << endl;
}

int main(int argc, char *argv[]){

  /*Regular*/
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }

  // /*ICPC*/
  // while (cin >> t >> d >> l, t) {
  //   solve();
  // }

  //solve();
  return 0;
}

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

#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef long long ll;

int N;
int a[1000000][3];
int dp[1000000][3];

int solve(int day, int last){

    if(day >= N) {
        return 0;
    }

    int &d = dp[day][last];

    if(last == -1){
        d=max(solve(day+1, 0) + a[day][0], max(solve(day+1, 1) + a[day][1], solve(day+1, 2) + a[day][2]));
        return d;
    }

    if(d != -1)
        return d;

    if(last == 0){
        return d=max(solve(day+1, 1) + a[day][1], solve(day+1, 2) + a[day][2]);
    }else if(last == 1){
        return d=max(solve(day+1, 0) + a[day][0], solve(day+1, 2) + a[day][2]);
    }else{
        return d=max(solve(day+1, 0) + a[day][0], solve(day+1, 1) + a[day][1]);
    }

}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> N;

    for(int i=0; i < N; i++){
        for(int j=0; j < 3; j++){
            cin >> a[i][j];
        }
    }

    memset(dp, -1, sizeof(dp));
    cout << solve(0, -1) << endl;

    return 0;
}

Measured memory_bytes: 19328
def make_divisors(n):
    divisors = [n]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors


def main():
    N = int(input())
    if N == 2:
        print(1)
        exit()
    n = make_divisors(N)
    m = make_divisors(N - 1)
    cnt = len(m)
    for i in n:
        tmp = N
        while tmp % i == 0:
            tmp //= i
        if tmp % i == 1:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
module Main where

import Control.Applicative
import Control.Monad

main = do
 n <- (read:: String -> Int) <$> getLine
 [d, x] <- map (read:: String -> Int) . words <$> getLine
 a <- map (read:: String -> Int) . lines <$> getContents
 print $ count d x a

count:: Int -> Int -> [Int] -> Int
count d x a = let choco = do
                           interval <- a
                           [1, (interval + 1)..d]
              in x + length choco



Measured memory_bytes: 892
def main():
    N = int(input())
    x = [0]*N
    y = [0]*N
    h = [0]*N
    k = N
    
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
        if(h[i] > 0):
            k = min(k, i)
    
    for Cx in range(101):
        for Cy in range(101):
            tmp = abs(x[k]-Cx)+abs(y[k]-Cy)+h[k]
            for i in range(N):
                if(h[i] != max(tmp-abs(x[i]-Cx)-abs(y[i]-Cy), 0)):
                    break
                if(i == N-1 and tmp > 0):
                    print(Cx, Cy, tmp)
                    quit()               
main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int arr[upperlimit];
int main() {
	int n;
	sd(n);
	ll sum=0;
	for(int i = 1; i <= n; i++){
		sd(arr[i]);
		sum +=arr[i]-1;
	}
	plld(sum);
	return 0;
}

Measured memory_bytes: 256
#Python Competetive Programming Template

from sys import stdin, stdout
from math import *

testing = True

def tp(s=""):
	if testing:
		print(s)

def main():
	n, x, m = [int(i) for i in stdin.readline().split()]
	d = dict()
	a = x
	total = 0
	count = 0
	for i in range(n):
		#print("a:", a)
		count += 1
		total += a
		if a in d:
			break
		d[a] = (count, total)
		a = (a**2)%m
	else:
		print(total)
	if count != n:
		#print(d)
		looplength = count - d[a][0]
		#print("looplength:", looplength)
		loopsize = total - d[a][1]
		#print("loopsize:", loopsize)
		loopstodo = (n-count)//looplength
		total += loopstodo * loopsize
		count += loopstodo * looplength
		while count < n:
			a = (a**2)%m
			#print("a:", a)
			count += 1
			total += a
		#print(count)
		print(total)

main()

Measured memory_bytes: 20168
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int H, W; cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W)), B(H, vector<int>(W));
    for (auto &row : A) for (auto &a : row) cin >> a;
    for (auto &row : B) for (auto &b : row) cin >> b;
    using BS = bitset<80 * 2 * 80 + 1>;
    const int ZERO = 80 * 2 * 80 / 2;
    vector<vector<BS>> dp(H, vector<BS>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int t = abs(A[i][j] - B[i][j]);
            if (i == 0 && j == 0) {
                dp[i][j].set(t + ZERO);
            }
            if (i != 0) {
                dp[i][j] |= (dp[i - 1][j] << t) | (dp[i - 1][j] >> t);
            }
            if (j != 0) {
                dp[i][j] |= (dp[i][j - 1] << t) | (dp[i][j - 1] >> t);
            }
        }
    }
    int ans = 1e9;
    for (int i = 0; i < dp[H - 1][W - 1].size(); i++) {
        if (dp[H - 1][W - 1][i]) {
            ans = min(ans, abs(i - ZERO));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
int main()
{
    int a,d;
    double p,q;
    cin>>a>>d;
    int c=0;
    for(int i=1;i<=a;i++)
    {
        cin>>p>>q;
        double k=sqrt(p*p+q*q);
        if(d>=k)
            c+=1;
    }
    cout<<c<<endl;

}



Measured memory_bytes: 3752
#include <bits/stdc++.h>
#pragma GCC optimize 03
#pragma GCC optimize ("unroll-loops")
#define int long long
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
using namespace std;
const int N = 3e5 + 2e5;
const int inf = 2e9;
const int MOD = 998244353;
const int LogN = 30;

void solve() {
    int D, T, S;
    cin >> D >> T >> S;
    if (T * S >= D)
        cout << "Yes";
    else
        cout << "No";
}

signed main() {
    #ifdef local
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(0);
    solve();
}


Measured memory_bytes: 3632
X = int(input())
break_flag = 0
for i in range(120):
  for j in range(i):
    a, b = i, j
    if a**5 - b**5 == X:
      print(a, b)
      break_flag = 1
      break
    elif a**5 + b**5 == X:
      print(a, -b)
      break_flag = 1
      break
  if break_flag == 1:
    break 

Measured memory_bytes: 9108
import java.util.Scanner;
public class Main {
	static int dfs(int total, int addv, int target, int n){ return n == 0 ? total == target ? 1 : 0 : addv > 9 ? 0 : dfs(total + addv, addv + 1, target, n - 1) + dfs(total, addv + 1, target, n); }
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(true){ int n = sc.nextInt(), s = sc.nextInt(); if(n == 0 && s == 0) break; System.out.println(dfs(0, 0, s, n)); }
		}
	}
}

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

int main() {
    int i, n;
    cin >> n;
    int a[n];

    for(i=0; i<n; ++i) {
        cin >> a[i];
    }
    cout << a[n-1];
    for(i=1; i<n; ++i) {
        cout << ' ' << a[n-i-1];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3052
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
ans=0
battle=[0]*n
for i in range(n):
	if i>=k:
		if t[i]==t[i-k] and battle[i-k]==1:
			continue
		else:
			battle[i]=1
			if t[i]=="r":
				ans+=p
			elif t[i]=="s":
				ans+=r
			else:
				ans+=s
	else:
		battle[i]=1
		if t[i]=="r":
			ans+=p
		elif t[i]=="s":
			ans+=r
		else:
			ans+=s
print(ans)




Measured memory_bytes: 4084
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))

#define MOD 998244353

ll hoge(int x, int y){
    ll res = 1;
    for(int i=0; i<y; i++){
        res *= x;
        res %= MOD;
    }
    return res;
}

int n, d, t[111111] = {}, maxi = 0;
ll ans = 1;

main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &d);
        if(!i){if(d){
            puts("0");
            return 0;
        }}else{
            if(!d){
                puts("0");
                return 0;
            }
        }
        t[d]++;
        maxi = max(maxi, d);
    }
    for(int i=1; i<=maxi; i++){
        ans *= hoge(t[i-1], t[i]);
        ans %= MOD;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include <cstdlib>
using namespace std;
int main()
{
    int x,n,cnt=0;
    cin >> x >> n;
  	int p[n],less=x-1,more=x+1;
  for(int i=0;i<n;i++){
    cin >> p[i];
    if(p[i]!=x){
      cnt+=1;
    }
  }
  if(cnt==n){
    cout << x;
    return 0;
  }
  cnt =0;
  for(int i=0;i<x;i++){
    cnt=0;
    for(int j=0;j<n;j++){
    	if(less != p[j]){
          cnt+=1;
        }
      else{
        less-=1;
        break;
      }
    }
    if(cnt==n){
     cout << less;
     return 0; 
    }
    cnt=0;
    
    for(int j=0;j<n;j++){
    	if(more != p[j]){
          cnt+=1;
        }
      else{
        more+=1;
        break;
      }
    }
    if(cnt == n){
    cout << more;
    return 0;
    }
  }
  
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int k,a,b;
    cin >> k >> a >> b;
    FOR(i,a,b+1){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define range(a,b)		substr(a,b-a+1)
#define w(x)            int x; cin>>x; while(x--)
#define trace(x) 		cerr<<#x<<": "<<x<<" "<<endl;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int x; cin >> x;

	if (x >= 30)
		cout << "Yes\n";

	else
		cout << "No\n";
	return 0;
}

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

int main()
{
  int A, B, M;
  cin>>A>>B>>M;

  vector<int> a(A);
  vector<int> b(B);
  for(int i=0; i<A; i++)  cin>>a[i];
  for(int i=0; i<B; i++)  cin>>b[i];

  int minA = *min_element(a.begin(), a.end());
  int minB = *min_element(b.begin(), b.end());
  int ans = minA + minB;
  for(int i =0; i<M; i++){
    int x, y, c;
    cin>>x>>y>>c;
    x--;  y--;
    ans = min(ans, a[x]+b[y]-c);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
map<string,bool> mp;
int main(){
int n;
cin>>n;
bool ok=true;
char memo;
for(int i=0;i<n;i++){
  string s={};
  cin>>s;
  if(i!=0&&memo!=s[0])ok=false;
  if(mp[s]){ok=false;}
   mp[s]=true;
   memo=s[s.size()-1];
}
if(ok)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
main()
{
    long int a[1000],i,j,sum=1,p=0,x,y;
    scanf("%ld%ld",&x,&y);
    while(1)
    {
        a[p]=sum;
        p++;
        sum=sum+(p+1);
        if(p==999)break;
    }
    for(i=0,j=1;i<p-1;i++,j++)
    {
        if((a[i]-x)==(a[j]-y))
        {
            printf("%ld\n",a[i]-x);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <random>
#include <map>
#include <set>
#include <boost/lexical_cast.hpp>

using namespace std;


using ULL = decltype(0ull);
constexpr auto DIV = 1000000007ull;
constexpr auto MAX = numeric_limits<ULL>::max();
int dp[100][100];

void Paint(int x, int y, int a, int W, int H) {
  if (a == 1) {
    for (int xi = 0; xi < x; ++xi) {
      for (int yi = 0; yi < H; ++yi) {
        dp[xi][yi] = 1;
      }
    }
  }
  else if (a == 2) {
    for (int xi = x; xi < W; ++xi) {
      for (int yi = 0; yi < H; ++yi) {
        dp[xi][yi] = 1;
      }
    }
  }
  else if (a == 3) {
    for (int xi = 0; xi < W; ++xi) {
      for (int yi = 0; yi < y; ++yi) {
        dp[xi][yi] = 1;
      }
    }
  }
  else {
    for (int xi = 0; xi < W; ++xi) {
      for (int yi = y; yi < H; ++yi) {
        dp[xi][yi] = 1;
      }
    }
  }
}

int Count(int W, int H) {
  int r = 0;
  for (int x = 0; x < W; ++x) {
    for (int y = 0; y < H; ++y) {
      if (dp[x][y] == 0)++r;
    }
  }
  return r;
}

int main() {
  memset(dp, 0, sizeof(int) * 100 * 100);
  int W, H, N;
  cin >> W >> H >> N;
  for (int i = 0; i < N; ++i) {
    int x, y, a;
    cin >> x >> y >> a;
    Paint(x, y, a, W, H);
  }
  cout << Count(W, H) << endl;
  return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n){
        cin>>a[i];
    }

    ll g=__gcd(a[0],a[1]);
    for (int i=2;i<n;i++) {
        g=__gcd(g,a[i]);
    }

    cout<<g<<endl;
}



Measured memory_bytes: 1024
H, W = map(int, input().split())
M = [[] for _ in range(H)]
for _ in range(H):
    S = input()
    for __ in range(W):
        M[_].append(S[__])

dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]


for i in range(H):
    for j in range(W):
        if M[i][j] == '#':
            flag = False
            for k in range(4):
                nx = j + dy[k]
                ny = i + dx[k]
                if (nx < 0) or (ny < 0) or (nx >= W) or (ny >= H):
                    continue
                elif M[ny][nx] == '#':
                    flag = True
                    break
            if not flag:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 40048
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

int main()
{
    int n, arr[105][105];

    scanf("%d", &n);

    for(int i = 1; i <= 2; i++){
        for(int j = 1; j <= n; j++){
            scanf("%d", &arr[i][j]);
        }
    }

    int Max = 0;
    for(int i = 1; i <= n; i++){
        int sum1 = 0, sum2 = 0;
        for(int j = 1; j <= i; j++){
            sum1 += arr[1][j];
        }
        for(int k = i; k <= n; k++){
            sum2 += arr[2][k];
        }

        if(sum1 + sum2 > Max){
            Max = sum1 + sum2;
        }
    }

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

    return 0;
}


Measured memory_bytes: 256
n = int(input())

# 100以下の2の乗算の数を準備
list_2_jou = [2, 2**2, 2**3, 2**4, 2**5, 2**6]
# print(list_2_jou)

# n以下　かつ　上記リストに含まれる数を出力
list_2_jou.sort(reverse=True)

for jou in list_2_jou:
    if jou <= n:
        print(jou)
        exit()

print(1)

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n + 1);
  vector<ll> b(n);

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

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll min_ab = min(a[i], b[i]);
    // a[i] -= min_ab;
    b[i] -= min_ab;
    ans += min_ab;
    if(b[i] != 0){
      ll min_ab1 = min(a[i+1], b[i]);
      a[i+1] -= min_ab1;
      // b[i] -= min_ab1;
      ans += min_ab1;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
		int ty = sc.nextInt();
		String ans="";

		int dx = tx-sx;
		int dy = ty-sy;
		for(int i=0; i<Math.abs(dx); i++){
			if( dx > 0 ){ ans +="R"; }else{ ans += "L"; }
		}
		for(int i=0; i<Math.abs(dy); i++){
			if( dy > 0 ){ ans +="U"; }else{ ans += "D"; }
		}
		for(int i=0; i<Math.abs(dx); i++){
			if( dx > 0 ){ ans +="L"; }else{ ans += "R"; }
		}
		for(int i=0; i<Math.abs(dy); i++){
			if( dy > 0 ){ ans +="D"; }else{ ans += "U"; }
		}

		if( dy > 0 ){ ans +="D"; }else{ ans += "U"; }

		for(int i=0; i<Math.abs(dx)+1; i++){
			if( dx > 0 ){ ans +="R"; }else{ ans += "L"; }
		}
		for(int i=0; i<Math.abs(dy)+1; i++){
			if( dy > 0 ){ ans +="U"; }else{ ans += "D"; }
		}

		if( dx > 0 ){ ans +="L"; }else{ ans += "R"; }
		if( dy > 0 ){ ans +="U"; }else{ ans += "D"; }

		for(int i=0; i<Math.abs(dx)+1; i++){
			if( dx > 0 ){ ans +="L"; }else{ ans += "R"; }
		}
		for(int i=0; i<Math.abs(dy)+1; i++){
			if( dy > 0 ){ ans +="D"; }else{ ans += "U"; }
		}

		if( dx > 0 ){ ans +="R"; }else{ ans += "L"; }

		System.out.println(ans);
		return;
	}
}

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

int main( int argc, char *argv[] )
{
int i;
char s[ 100 ];

	for( i = 0; i < 3; i++ )
	{
		cin >> s;
		cout << (char) ( s[ 0 ] + 'A' - 'a' );
	}

	cout << endl;

	return 0;

}




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

using namespace std;

struct Doubling
{
    const int LOG;
    vector< vector< int > > table;
    
    Doubling(int sz, int64_t lim_t) : LOG(64 - __builtin_clzll(lim_t))
    {
        table.assign(LOG, vector< int >(sz, -1));
    }

    void set_next(int k, int x)
    {
        table[0][k] = x;
    }

    void build()
    {
        for(int k = 0; k + 1 < LOG; k++) {
            for(int i = 0; i < table[k].size(); i++) {
                if(table[k][i] == -1) table[k + 1][i] = -1;
                else table[k + 1][i] = table[k][table[k][i]];
            }
        }
    }

    int query(int k, int64_t t)
    {
        for(int i = LOG - 1; i >= 0; i--) {
            if((t >> i) & 1) k = table[i][k];
        }
        return k;
    }
};


int main(void) {
    int N;
    cin >> N;
    vector<int> x(N);
    for(int i=0; i<N; i++) {
        cin >> x[i];
    }
    
    int L;
    cin >> L;
    vector<int> l(N), r(N);
    for(int i=0; i<N; i++) {
        l[i] = distance(x.begin(), lower_bound(x.begin(), x.end(), x[i] - L));
        r[i] = distance(x.begin(), upper_bound(x.begin(), x.end(), x[i] + L)) - 1;
        // cerr << l[i] << ' ' << r[i] << endl;
    }

    Doubling left(N, 1000000), right(N, 1000000);
    for(int i=0; i<N; i++) {
        left.set_next(i, l[i]);
        right.set_next(i, r[i]);
    }
    left.build();
    right.build();

    int Q;
    cin >> Q;
    while(Q--) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        if(a < b) {
            int ok = 100000;
            int ng = 0;
            while(ok > ng + 1) {
                int mid = (ok + ng) / 2;
                if(right.query(a, mid) >= b) {
                    ok = mid;
                } else {
                    ng = mid;
                }
            }
            cout << ok << endl;
        } else {
            int ok = 100000;
            int ng = 0;
            while(ok > ng + 1) {
                int mid = (ok + ng) / 2;
                if(left.query(a, mid) <= b) {
                    ok = mid;
                } else {
                    ng = mid;
                }
            }
            cout << ok << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 20512
#include <stdio.h>
int main(void){
    
    long int a,b,c,d;
    scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
    long int ans=-1000000000000000000;
    if(a*c>ans)ans=a*c;
    if(a*d>ans)ans=a*d;
    if(b*c>ans)ans=b*c;
    if(b*d>ans)ans=b*d;
    printf("%ld\n",ans);
}


Measured memory_bytes: 1736
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
class BRI{
	public:
	int N;
	vi used;
	vvi G;
	vp bridge;
	void add_edge(int s,int t){
		G[s].pb(t);
		G[t].pb(s);
	}
	BRI(int size){
		N=size;
		G=vvi(N);
	}
	int dfs(int i,int prev,int &n){
		if(used[i])return used[i];
		int m=n;
		used[i]=n++;
		rep(j,G[i].size()){
			if(prev==G[i][j])continue;
			if(used[i]<used[G[i][j]])continue;
			int res=dfs(G[i][j],i,n);
			m=min(m,res);
			if(used[i]<res)bridge.pb(pii(min(i,G[i][j]),max(i,G[i][j])));
		}
		return m;
	}
	void bri(){
		used=vi(N);
		bridge=vp(0);
		int n=1;
		dfs(0,-1,n);
		sort(all(bridge));
		rep(i,bridge.size())cout<<bridge[i].first<<" "<<bridge[i].second<<endl;
	}
};
int main(){
	int n,m;
	cin>>n>>m;
	BRI bri(n);
	while(m--){
		int a,b;
		cin>>a>>b;
		bri.add_edge(a,b);
	}
	bri.bri();
}

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

using namespace std;

int main() {
    int n,m,i,j,k;
    long min=1000000,sum=0;
    bool eflg,nflowflg;
    cin>>n>>m;
    vector<int> x(m);
    vector<int> kukan(m-1);
    for(i=0;i<m;i++){
        cin>>x[i];
    }

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

    sort(x.begin(),x.end());
    for(i=0;i<m-1;i++) {
        kukan[i]=x[i+1]-x[i];
    }
    sort(kukan.begin(),kukan.end());
    for(i=0;i<m-n;i++) {
        sum+=kukan[i];
    }






   // for_each(x.begin(), x.end(), [](int i) { cout << i << ' ';});

    cout << sum << endl;

    return 0;
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE(x) ((ll)(x).size()) 
#define MAX(x) *max_element(ALL(x)) 
#define MIN(x) *min_element(ALL(x)) 
#define ALL(x) (x).begin(),(x).end() 

#define INF 1000000000000 
#define MOD 1000000007 
#define MAXR 100000 

#define PB push_back 
#define MP make_pair 
#define F first 
#define S second 

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int n = s.length(), j, k;
    ll dp[100005][13];
    REP(i, 100005) REP(j, 13) dp[i][j] = 0;
    dp[0][0] = 1;
    REP(i, n){
        int c;
        if(s[i] == '?'){
            c = -1;
        }else{
            c = s[i] - '0';
        }
        REP(j, 10){
            if(c != -1 && c != j) continue;
            REP(k, 13){
                dp[i+1][(k*10+j)%13] += dp[i][k];
            }
        }
        REP(j, 13) dp[i+1][j] %= MOD;
    }
    cout << dp[n][5] << endl;
}

Measured memory_bytes: 10704
#include <iostream>
#include <vector>
#include <string>


int main()
{
    int n, k;
    std::cin >> n >> k;
    if ((n - 1) % (k - 1) == 0) {
        std::cout << (n - 1) / (k - 1) << std::endl;
    } else {
        std::cout << 1 + (n - 1) / (k - 1) << std::endl;
    }


    return 0;
}


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


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    int a, b;
    cin >> a >> b;
    cout << a*a  - b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int r; cin>>r;
	cout << 3*r*r;

	
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#define pb push_back
#define MAX 100100

using namespace std;

int main(){
    int numstones;
    vector <int> height;
    int limite;
    int aux;
    int dp[MAX];
    
    scanf("%d %d", &numstones, &limite);
    height.push_back(0);
    for(int i = 1; i <= numstones; i++){
        scanf("%d", &aux);
        height.push_back(aux);
    }
    /*for(int i = 0; i <= numstones; i++){
        printf("%d ", height[i]);
    }
    printf("\n");*/
    
    
    
    memset(dp, 1000000, sizeof dp);
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(height[1] - height[2]);
    for(int i = 3; i <= numstones; i++){
        for(int k = 1; k <= limite; k++){
            if(i - k >= 1){
                //printf("%d %d", dp[i], dp[i - k] + abs(height[i - k] - height[i]));
                dp[i] = min(dp[i], dp[i - k] + abs(height[i - k] - height[i]));
                //printf("dp[%d]: %d\n", i, dp[i]);
            }
        }
        //printf("\n");
    }
    printf("%d\n", dp[numstones]);
    return 0;
}

Measured memory_bytes: 1144
from functools import reduce
from operator import add 

n = input()
wl = list(map(int, input().split()))

min = 1000
for i in range(int(n)):
    if i == 0:
        continue
    sm = reduce(add, wl[:i])
    lg = reduce(add, wl[i:])
    tmp = abs(sm - lg)
    min = tmp if tmp < min else min

print(min)

Measured memory_bytes: 3828
n=int(input())
s=list(input())
l=s[:n]
r=s[n:][::-1]
d={}
e={}
for i in range(1<<n):
  s=t=u=v=''
  for j in range(n):
    if (i>>j)&1:
      s+=l[j]
      t+=r[j]
    else:
      u+=l[j]
      v+=r[j]
  d[(s,u)]=d.get((s,u),0)+1
  e[(t,v)]=e.get((t,v),0)+1
a=0
for i in d.keys():
  a+=d[i]*e.get(i,0)
print(a)

Measured memory_bytes: 174568
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, ans int
	fmt.Scan(&n)
	L := make([]int, n)
	for i := range L {
		fmt.Scan(&L[i])
	}
	sort.Ints(L)
	for i, l := range L {
		for j := i + 1; j < n; j++ {
			if l == L[j] {
				continue
			}
			for k := j + 1; k < n; k++ {
				if L[j] != L[k] && l+L[j] > L[k] {
					ans++
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1844
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, s := nextInt(), next()
	const mod = 1000000007

	cnt := map[byte]int{}
	for i := 0; i < n; i++ {
		cnt[s[i]]++
	}

	ans := 1
	for _, v := range cnt {
		ans = (ans * (v + 1)) % mod
	}

	puts(ans - 1)
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 896