akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n;
	while (cin >> n, n) {
		vector<pair<int, bool>> jikoku;
		REP(i, n) {
			string s;
			cin >> s;
			jikoku.push_back({ (s[0]-'0')*36000+ (s[1] - '0') * 3600 + (s[3] - '0') * 600 + (s[4] - '0') * 60 + (s[6] - '0') * 10 + (s[7] - '0') * 1,true });
			cin >> s;
			jikoku.push_back({ (s[0] - '0') * 36000 + (s[1] - '0') * 3600 + (s[3] - '0') * 600 + (s[4] - '0') * 60 + (s[6] - '0') * 10 + (s[7] - '0') * 1,false });
		}
		SORT(jikoku);
		int cnt = 0;
		int ans = 0;
		REP(i, n * 2) {
			if (jikoku[i].second) {
				cnt++;
			}
			else {
				cnt--;
			}
			ans = max(ans, cnt);
		}
		cout << ans << endl;
	}

}

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

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++)
        cin >> H[i];

    int ans = 1;
    int highest = H[0];
    for (int i = 1; i < N; i++) {
        if (H[i] >= highest) {
            highest = H[i];
            ans++;
        }
    }

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


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

int main()
{
    long long n, m;
    std::cin >> n >> m;

    std::vector<long long> a(n);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        sum += a[i];
    }

    long long count = 0;
    for (auto t : a) {
        if (t * 4 * m >= sum) {
            count++;
        }
    }

    std::cout << (count >= m ? "Yes" : "No") << std::endl;
}


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

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

  int nums[4];
  for (int i = 3; i >= 0; --i)
  {
    nums[i] = input % 10;
    input /= 10;
  }

  for (int f = 0; f < 8; ++f)
  {
    int total = nums[0];
    for (int i = 0; i < 3; ++i)
    {
      if (f & (1 << i))
      {
        total += nums[i + 1];
      }
      else
      {
        total -= nums[i + 1];
      }
    }
    if (total == 7)
    {
      cout << nums[0];
      for (int i = 0; i < 3; ++i)
      {
        if (f & (1 << i))
        {
          cout << "+" << nums[i + 1];
        }
        else
        {
          cout << "-" << nums[i + 1];
        }
      }
      cout << "=7" << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
#define pb push_back

const int N = 1e5 + 5;
const int MAX = (1 << 18);

ll z, n;
ll tab[N + 5], tree[2 * MAX + 5], pref[N + 5];

void Update(int x){
	x += MAX;
	while(x >= 1){
		tree[x] ++;
		x /= 2;
	}
}

ll Query(int x, int y){
	x += MAX;
	y += MAX;
	ll res = tree[x];
	if(x != y){
		res += tree[y];
	}
	while(x / 2 != y / 2){
		if(x % 2 == 0){
			res += tree[x + 1];
		}
		if(y % 2 == 1){
			res += tree[y - 1];
		}
		x /= 2;
		y /= 2;
	}
	return res;
}

void Prep(const int &v){
	fill(tree, tree + MAX + MAX + 2, 0);
	fill(pref, pref + N + 1, 0);
	pref[0] = N;
	for(int i=1; i<=n; i++){
		if(tab[i] <= v){
			pref[i] --;
		}else{
			pref[i] ++;
		}
		pref[i] += pref[i - 1];
	}
}

bool Check(const int &v){
	Prep(v);
	ll res = 0;
	Update(N);
	for(int i=1; i<=n; i++){
		res += Query(pref[i] + 1, 2 * N + 1);
		Update(pref[i]);	
	}
	//cout << v << " " << res << "\n";
	if(z % 2 == 0){
		return 2 * res >= z + 2;
	}
	if(z % 2 == 1){
		return 2 * res >= z + 1;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> tab[i];
		//tab1[i] = tab[i];
	}
	//sort(tab1 + 1, tab1 + n + 1);
	z = (n * (n + 1)) / 2;
	int p = -1;
	int k = 1000000001;
	while(p + 1 < k){
		int mid = (p + k) / 2;
		//cout << mid << "\n";
		if(Check(mid)){
			k = mid;
		}else{
			p = mid;
		}
	}
	cout << k << "\n";
	
	return 0;
}

Measured memory_bytes: 5888
#!/usr/bin/env python3
import sys
import numpy as np

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(X: int, Y: int):
    for i in range(1,X+1):
        j = X-i
        if (2*i+4*j)==Y or (4*i+2*j)==Y:
            print(YES)
            return
    print(NO)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


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

const long long INF = LLONG_MAX;

int main()
{
	int n, k;
	cin >> n >> k;
	
	vector < long long > h(n);
	
	for(int i = 0; i < n; i++)
	{
		cin >> h[i];
	}
	
	vector < long long > dp(n);
	
	dp[0] = 0;
	
	for(int i = 1; i < n; i++)
	{
		dp[i] = INF;
	}
	
	for(int i = 0; i < n - 1; i++)
	{
		for(int j = 1; j <= min(n - i, k); j++)
		{
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	
	cout << dp[n - 1];
	
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;
import java.lang.*;
import java.math.*;

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

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] height = new int[n];
        int[] cost = new int[n];
        for (int i = 0; i < n; i++) {
            height[i] = sc.nextInt();
        }
        cost[0] = 0;
        for (int i = 1; i < n; i++) {
            if (i == 1) {
                cost[i] = Math.abs(height[i]-height[i-1]);
            } else {
                cost[i] = Integer.MAX_VALUE;           
                for (int j = 1; j <= k; j++) {
                    if (i - j >= 0) {
                        int tmp = cost[i-j] + Math.abs(height[i]-height[i-j]);
                        if (tmp < cost[i]) {
                            cost[i] = tmp;
                        }
                    }
                }
            }
        }
        System.out.println(cost[n-1]);
        sc.close();
    }
}


Measured memory_bytes: 60996
#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	A, B, K = getlist()
	if A > K:
		print(A - K, B)
	elif A + B > K:
		print(0, B - (K - A))
	else:
		print(0, 0)

	


if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mod 1000000007
#define inf 1e18
#define inp(arr,n) for(int i=0;i<n;i++) cin>>arr[i]
#define fr(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a,b;
    cin>>a>>b;
    cout<<(a*b)<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REP(i,a,b) for(ll i=(a);i<(b);++i)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

vector<ll> A;

int main(){
    ll  N,X,T=0,C=0;
    cin >> N;
    rep(i,N){
        cin >> X;
        A.pb(X);
    }
    rep(i,N){
        if(A[i]==0){
            T=0;
        }
        else if((T+A[i])%2==0){
            C+=(T+A[i])/2;
            T=0;
        }
        else{
            C+=(T+A[i])/2;
            T=1;
        }
    }
    cout << C << endl;
}

Measured memory_bytes: 1400
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String t = sc.nextLine();
    
    int ans = 1001;

    for(int i=0; i<s.length()-t.length()+1; i++){
        String sub = s.substring(i, i+t.length());
        int sum = 0;
        for(int j=0; j<t.length(); j++){
            if(t.charAt(j) != sub.charAt(j)){
                sum++;
            }
        }
        ans = Math.min(sum, ans);
    }
    System.out.println(ans);
   
    sc.close();
    return;
  }
  
}


Measured memory_bytes: 36476
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <vector>
typedef long long int ll;
using namespace std;
int main() {
	int a,b,c;
	cin >> a>>b>>c;
	if(b/a>c){
		cout << c<< endl;
	}else{
		cout<< b/a<< endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while (sc.hasNext()) {
      int d = sc.nextInt();
      int sum = 0;
      for(int i = 1; i < 600/d; i++) {
        sum += i*i*d*d*d;
      }
      System.out.println(sum);
    }
  }
}

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

// using mint = modint1000000007;
// using mint = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    Int a, b, c, d;
    cin >> a >> b >> c >> d;
    print(max({a * c, a * d, b * c, b * d}));
}

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


Measured memory_bytes: 3636
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        long count = 0;
        for (int i = 0; i < n; i++) {
            int l = scanner.nextInt();
            int r = scanner.nextInt();
            count += r - l + 1;
        }
        System.out.println(count);
    }
}

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

ll n,m,x;
ll h[114514];
struct edge
{
    ll to,cost;
};
vector<edge>graph[114514];
ll dist[114514];
const ll INF = 1145141919810893;
using P = pair<ll,ll>;
void dijkstra()
{
    fill(dist,dist+114514,INF);
    dist[0] = 0;
    priority_queue<P,vector<P>,greater<P>>que;
    que.emplace(0,0);
    while(!que.empty())
    {
        P p = que.top(); que.pop();
        ll length = p.first;
        ll from = p.second;
        if(dist[from] < length)continue;
        ll height = x - length;
        if(height < 0)height = 0;
        for(auto e : graph[from])
        {
            if(height - e.cost > h[e.to])
            {
                //too high
                e.cost = height - h[e.to];
            }
            else if(height - e.cost < 0)
            {
                //too low
                e.cost = e.cost + e.cost - height;
            }
            if(dist[e.to] > dist[from] + e.cost)
            {
                dist[e.to] = dist[from] + e.cost;
                que.emplace(dist[e.to],e.to);
            }
        }
    }
}

void putedge(ll a,ll b,ll t)
{
    REP(i,2)
    {
        if(h[a] >= t)
        {
            graph[a].push_back({b,t});
        }
        swap(a,b);
    }
}

int main()
{
    cin >> n >> m >> x;
    REP(i,n)
    {
        cin >> h[i];
    }
    REP(j,m)
    {
        ll a,b,t;
        cin >> a >> b >> t;
        --a;--b;
        putedge(a,b,t);
    }
    dijkstra();
    ll ans = dist[n - 1];
    if(ans >= INF)
    {
        cout << -1 << endl;
        return 0;
    }
    ll height = x - ans;
    if(height < 0)height = 0;
    cout << ans + (h[n - 1] - height) << endl;
    return 0;
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
 
string solve(vector<int>& v, int k)
{
    bool dp[k+1];
    memset(dp, 0, sizeof dp);
 
    for(int i = 1; i <= k; i++)
    {
        for(auto move =v.begin();move<v.end();move++)
        {
            if(*move > i)
                continue;
            if(dp[i - *move] == 0)
                dp[i] = 1;
        }
    }
    
    return dp[k] ? "First" : "Second";
}
 
int main() {
   int n,k;
   cin >> n >> k;
   vector<int> v(n);
   for(int i =0; i<=n; i++)
    cin>>v[i];
   cout<<solve(v, k);
   return 0;
}


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


int main(void) {
   int N;
   cin>>N;
   int A[N];
   for (int i = 0; i < N;i++) cin>>A[i];

   int ans = 0;
   for (int i = 0; i < N-2;i++) {
      if (A[i] < A[i+1] && A[i+1] < A[i+2]) ans++;
      if (A[i+2] < A[i+1] && A[i+1] < A[i]) ans++;
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 1;
const int inf = 1e9 + 7;
signed main () {
    int a, b;
    cin >> a >> b;
    int x = __gcd(a, b);
    int ans = 0;
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) {
            while (x % i == 0) x/=i;
            ans++;
        }
    }
    if (x > 1) ans++;
    cout << ans + 1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    typedef pair<ll, ll> l_l;
    typedef pair<int , int> i_i;
    typedef vector<ll> vl;
    typedef vector<int> vi;
    typedef vector<char> vec;
    typedef vector<bool> veb;
    typedef vector<string> ves;
    typedef vector<vector<ll>> vvl;
    typedef vector<vector<int>> vvi;
    typedef vector<vector<char>> vvec;
    typedef vector<vector<bool>> vveb;
    typedef vector<vector<string>> vves;
    #define rep(i,n) for(int i=0;i<(int)(n);i++)
    #define rep1(i,n) for(int i=1;i<(int)(n);i++)
    #define rep2(i,n) for(int i=2;i<(int)(n);i++)
    #define repk(i,k,n) for(int i=k;i<(int)(n);i++)
    #define fs first
    #define sc second
    #define pb push_back
    #define pp pop_back
    #define all(a) a.begin(),a.end()
    #define rall(a) a.rbegin(),a.rend()
    #define maxel(a) *max_element(all(a))
    #define minel(a) *min_element(all(a))
    #define acc accumulate
    #define EPS (1e-7)
    #define INF (1e9)
    #define PI (acos(-1))
    #define mod (1000000007)
    typedef long long int64;
    //const int64 INF = 1LL << 58;
    #define dame { puts("-1"); return 0;}
    #define YES { cout << "YES" << endl; return 0; }
    #define NO { cout << "NO" << endl; return 0; }
    #define Yes { cout << "Yes" << endl; return 0; }
    #define No { cout << "No" << endl; return 0; }
    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; }
    int dx[] = {0, 0, -1, 1};
    int dy[] = {1, -1, 0, 0};
     
    int K = 100000;
     
    int main(){
    	cin.tie(0);
    	ios::sync_with_stdio(false);	
     
      	int k;
      	cin >> k;
      	vl a(K);
      	queue<ll> q;
      	rep1(i,10){ q.push(i);}
      	int kari= 0;
      	while(true){
          	kari++;
        	ll x = q.front();
          	
          	q.pop();
          	repk(i,-1,2){
				ll d = x%10 +i; 
            	if(d < 0 || 9 < d){continue;}
              	q.push(10*x+d);
            }
          	if(kari == k){cout << x << endl;break;}	
        }
      	return 0;
    }

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

using namespace std;

int main(void)
{
	int N;
	cin >> N;
	int A[N];
	int i;
	long long int sum = 0;
	for(i = 0; i < N; i ++){
		cin >> A[i];
		sum += A[i];
	}
	long long int lsum = 0;
	long long int rsum = 0;
	i = 0;
	while(1){
		lsum += A[i];
		i++;
		if(lsum+A[i] > sum / 2){
			break;
		}
	}
	rsum = sum - lsum;
	long long int ans = 0;
	ans = rsum - lsum;
	lsum += A[i];
	rsum -= A[i];
	if(ans > lsum - rsum){
		ans = lsum - rsum;
	}
	
	cout << ans << endl;
	
	return 0;
}




Measured memory_bytes: 1152
#include <stdio.h>

int main(){
  int aaa[100],gyo,i,j,temp;

  scanf("%d",&gyo);

  for(i=0;i<gyo;i++){
    scanf("%d",&aaa[i]);
  }

  for(i=0;i<gyo;i++){
    for(j=i;0<j;j--){
      if(aaa[j-1]>aaa[j]){
	temp=aaa[j];
	aaa[j]=aaa[j-1];
	aaa[j-1]=temp;
      }
      else break;
    }

    for(j=0;j<gyo-1;j++){
      printf("%d ",aaa[j]);
    }
    printf("%d\n",aaa[gyo-1]);
  }

  return 0;
}



Measured memory_bytes: 2068
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,k,l,sum=0,i;
    cin>>n>>k;
    priority_queue<int,vector<int>,greater<int>> p;
    for (i=0;i<n;i++)
    {
        cin>>l;
        p.push(l);
        sum+=l;
        if (p.size()>k)
        {
            sum-=p.top();
            p.pop();
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().strip().split()))
min1=min(a)
min2=min1

for i in a:
    amari=i%min1
    if amari!=0:
        if amari<min1:
            min1=amari
lop=True
while lop:
    if min1==min2:
        ans=min1
        lop=False
    elif min1<min2:
        min2=min2%min1
        if min2==0:
            ans=min1
            lop=False
    elif min1>min2:
        min1=min1%min2
        if min1==0:
            ans=min2
            lop=False
print(ans)



Measured memory_bytes: 14252
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){  
  int w,h;cin>>w>>h;
  int x,y;cin>>x>>y;
  int kazu=0;
  if(x*2==w&&y*2==h)kazu=1;
  double res=h*w/2.0;
  printf("%.12lf ",res);
  cout<<kazu<<"\n";
  return 0;
}

Measured memory_bytes: 3728
import java.util.HashMap;
import java.util.Scanner;
public class Main{
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		HashMap<Integer,Integer>hm = new HashMap<Integer,Integer>();
		
		int n = sc.nextInt();
		int p = 1000000007;
		
		for(int i = 1 ; i <= n ; i++) {
			hm.put(i, gcd(n,i));
		}
		long ans = 1;
		for(int i = 1 ; i <= n ; i++) {
			ans *= (hm.get(i)+1);  
			if(ans >= p) {
				ans = ans % p;
			}
		}
		System.out.println(ans);
	}
	private static int gcd (int n, int m ) {
		if(m == 1 || !prime(m))
			return 0;
		int count = 1;
		for(int i = m+1 ; i <= n ;i++) {
			int temp = i;
			while(temp % m == 0) {
				count++;
				temp = temp/m;
			}
		}
		return count;
	}
	
	private static boolean prime(int n) {
		if(n == 1)
			return false;
		
		if(n == 2 || n == 3) {
			return true;
		}
		double p = Math.sqrt(n);
		int temp = -1;
		
		for(int i = 2 ; i <= p ; i++) {
			if(n % i == 0) {
				temp = 0;
				break;
			}
		}
		if(temp == 0) {
			return false;
		}
		return true;
		}
	
	}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

int main(){
    int N; cin >> N;
    int ans = 100000;
    for (int i = 1; i <=10; i++){
        if (i*1000 - N < 0) continue;
        ans = min(ans, i*1000-N);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集

int dp[10010];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int H, N; cin >> H >> N;
  
  vector<int> A(N), B(N);
  REP(i,N) cin >> A[i] >> B[i];
  REP(i,H+1) dp[i] = INT_MAX;

  dp[0] = 0;
  for(int i=0; i<N; i++){
    
    for(int j=0; j<=H; j++){
      
      if(dp[j] != INT_MAX){
        dp[min(H, j+A[i])] = min(dp[min(H,j+A[i])], dp[j] + B[i]);
      }
    }
  }
  cout << dp[H] << endl;

  return 0;
}


Measured memory_bytes: 3656
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-27 19:31:23
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

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

  int n; int64 k; cin >> n >> k;
  vector<int64> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    --a[i];
  }

  vector<int64> sum(n + 1, 0LL);
  for (int i = 0; i < n; ++i) {
    sum[i + 1] = sum[i] + a[i];
    sum[i + 1] %= k;
  }

  map<int64, int> mp;

  int64 ans = 0;

  for (int i = 0; i < n + 1; ++i) {
    ans += mp[sum[i]];
    ++mp[sum[i]];
    if (i >= k - 1) {
      --mp[sum[i - k + 1]];
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
//#define int long long
#define rep(i, l, r) for(int i = l; i <= r; ++ i)

inline int read() 
{
	char cc = getchar(); int cn(0), flus(1);
	while(cc < '0' || cc > '9') {if(cc == '-') flus = -flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - 48; cc = getchar();}
	return cn * flus;
}

const int MAXN = 1e6 + 10, INF = 2147483647;
const int Mod = 998244353, G = 3;

int n, d;
bool vis[MAXN]; 

signed main()
{
	int k = read();
//	rep(k, 1, 100010)
	int tmp = 0;
	if(!(k & 1))
	{
		printf("-1\n");
//		continue;
		return 0;
	}
	int pcs(0);
	while(1) 
	{
		pcs ++;
		tmp = tmp * 10 + 7;
		tmp %= k;
		if(vis[tmp])
		{
			printf("-1\n");
			return 0;
		}
		vis[tmp] = 1;
		if(!tmp) 
		{
			printf("%d\n",pcs);
//			return 0;
			break;
		} 
	} 
	return 0;
}

Measured memory_bytes: 4728
N = int(input())
A = input().split()
A = [int(x) for x in A]
b = []
answer = 0
count = 0
for i in range(N):
  if A[i] < 0:
    count = count + 1
  b.append(int(abs(A[i])))
  answer = answer + b[i] 
b.sort()
b.reverse()
if count % 2 == 1:
  answer = 0
  for j in range(N-1):
    answer = answer + b[j]
  answer = answer - b[j+1]
print(answer)

Measured memory_bytes: 14468
from sys import stdin

n = int(stdin.readline().rstrip())
xs = [int(x) for x in stdin.readline().rstrip().split()]
ys = [int(x) for x in stdin.readline().rstrip().split()]

count = 0

for i in range(n):
   r = min(xs[i], ys[i])
   xs[i] -= r
   ys[i] -= r
   count += r
   r = min(xs[i+1], ys[i])
   xs[i+1] -= r
   count += r
   
print(count)

Measured memory_bytes: 18396
#include <stdio.h>
int main(void){
    int i,j,tmp,a[4]={};
    
    for(i=0;i<4;i++){
        scanf("%d",&a[i]);
    }
    
    for(i=0;i<3;i++){
        for(j=0;j<3-i;j++){
            if(a[j]>a[j+1]){
                tmp=a[j];
                a[j]=a[j+1];
                a[j+1]=tmp;
            }
            
        }
    }
    
    if(a[0]==a[1] && a[2]==a[3]){
        puts("yes");
    }
    else puts("no");
    
    return 0;
}

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

int main() {

  while( true ) {

    long long int n, k;
    cin >> n >> k;
    if ( n == 0 ) break;

    bool w = false;

    vector< long long int > c;
    for ( long long int i = 0; i < k; i++ ) {
      long long int in;
      cin >> in;
      if ( in == 0 ) {
	w = true;
      }else {
	c.push_back( in );
      }
    }

    c.push_back( n + 100 );

    sort( c.begin(), c.end() );

    long long int ans = 0;
    long long int h[2] = {0};
    long long int u = -10;

    for ( long long int i = 0; i < c.size(); i++ ) {
      if ( u + 1 == c[i] ) {
	h[0]++;
      }else if ( u + 2 == c[i] && w == true ) {
	ans = max( ans, h[0] + h[1] );
	h[1] = h[0] + 1;
	h[0] = 1;
      }else {
	ans = max( ans, h[0] + h[1] );
	h[0] = 1;
	h[1] = 0;
      }
      u = c[i];
    }

    cout << ans << endl;

  }

  return 0;

}

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

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int A[200200];
int main()
{
  int K,N;
  cin>>K>>N;
  int Ans=0;
  for(int i=0;i<N;i++)
    cin>>A[i];
  for(int i=0;i<N;i++)
    Ans=max(Ans,(A[(i+1)%N]+K-A[i])%K);
  cout<<K-Ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;

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

int main()
{
long long m,n;scanf("%lld %lld",&m,&n);
printf("%lld\n",mod_pow(m,n));
}



Measured memory_bytes: 3224
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,m,q; cin>>n>>m>>q;
    vector<vector<int>> t(n,vector<int>(n,0)),s(n,vector<int>(n,0));
    rep(i,m){
        int l,r; cin>>l>>r;
        l--; r--; t[l][r]++;
    }
    rep(i,n) s[i][i]=t[i][i];
    rep(i,n-1) s[i][i+1]=t[i][i]+t[i][i+1]+t[i+1][i+1];
    rep(i,n-2){
        rep(j,n-i-2){
            s[j][j+i+2]=t[j][j+i+2]+s[j][j+i+1]+s[j+1][j+i+2]-s[j+1][j+i+1];
        }
    }
    rep(i,q){
        int a,b; cin>>a>>b;
        a--; b--;
        printf("%d\n",s[a][b]);
    }
}

Measured memory_bytes: 2944
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

type Weight = i32;
#[allow(dead_code)]
#[derive(Clone, Debug, Eq, PartialEq)]
struct Edge {
    index: usize,
    src: usize,
    dest: usize,
    weight: Weight,
}
#[allow(dead_code)]
impl Edge {
    fn new(index: usize, src: usize, dest: usize, weight: Weight) -> Edge {
        Edge {
            index: index,
            src: src,
            dest: dest,
            weight: weight,
        }
    }
}
impl std::cmp::Ord for Edge {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        (self.weight, self.src, self.dest).cmp(&(other.weight, other.src, other.dest))
    }
}
impl std::cmp::PartialOrd for Edge {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}
type Edges = Vec<Edge>;
type Graph = Vec<Edges>;
#[allow(dead_code)]
fn graph_new(n: usize) -> Graph {
    vec![vec![]; n]
}
#[allow(dead_code)]
fn add_bi_edge(graph: &mut Graph, index: &mut usize, src: usize, dest: usize, weight: Weight) {
    graph[src].push(Edge::new(*index, src, dest, weight));
    graph[dest].push(Edge::new(*index, dest, src, weight));
    *index += 1;
}
#[allow(dead_code)]
fn add_uni_edge(graph: &mut Graph, index: &mut usize, src: usize, dest: usize, weight: Weight) {
    graph[src].push(Edge::new(*index, src, dest, weight));
    *index += 1;
}

fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let mut graph = graph_new(n);
    let mut e = 0;
    for _ in 0..m {
        let a = read::<usize>() - 1;
        let b = read::<usize>() - 1;
        add_bi_edge(&mut graph, &mut e, a, b, 1);
    }
    let mut cnts = vec![0; n];
    for edge in graph[0].iter() {
        cnts[edge.dest] += 1;
    }
    for edge in graph[n - 1].iter() {
        cnts[edge.dest] += 1;
    }
    let mut ans = false;
    for i in 0..n {
        ans |= cnts[i] == 2;
    }
    println!("{}", if ans { "POSSIBLE" } else { "IMPOSSIBLE" });
}


Measured memory_bytes: 45308
import itertools

N, M, Q = list(map(int, input().split()))

abcd = [[int(0) for I in range(4)] for II in range(Q)]
for i in range(Q):
    abcd[i] = list(map(int, input().split()))

pat = list(itertools.combinations_with_replacement(range(1, M+1), N))

ans=0
for x in pat:
    tmp=0
    for xx in abcd:
        if x[xx[1]-1] - x[xx[0]-1] == xx[2]:
            tmp+=xx[3]
    
    if ans<=tmp:
        ans=tmp

print(ans)


Measured memory_bytes: 21472
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define int long long
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
    const int MAX =200005;
const int MOD =1000000007;

signed main(){
  int n;
  cin>>n;
  int a,b;
  vector<int> hen[n];
  for(int i=0;i<n-1;i++){
    cin>>a>>b;
    a--;b--;
    hen[a].push_back(b);
    hen[b].push_back(a);
  }
  int iro[n]={},ans=0;
  queue<int> que[2][2];
  que[0][0].push(0);
  iro[0]=1;
  que[1][0].push(n-1);
  iro[n-1]=-1;
  while(!que[0][0].empty()||!que[1][0].empty()){
    while(!que[0][0].empty()){
      for(auto&& i: hen[que[0][0].front()])if(iro[i]==0){
        iro[i]=1;
        ans++;
        que[0][1].push(i);
        
      }
      que[0][0].pop();
    }
     swap(que[0][0],que[0][1]);
   while(!que[1][0].empty()){
      for(auto&& i: hen[que[1][0].front()])if(iro[i]==0){
        iro[i]=1;
        ans--;
        que[1][1].push(i);
        
      }
      que[1][0].pop();
    }
     swap(que[1][0],que[1][1]);
  
  }
  if(ans>0)cout<<"Fennec"<<endl;
  else cout<<"Snuke"<<endl;

}

Measured memory_bytes: 10496
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint unsigned long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint s[505], t[505];
llint u[505], v[505];
llint ans[505][505];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> s[i];
	for(int i = 1; i <= n; i++) cin >> t[i];
	for(int i = 1; i <= n; i++) cin >> u[i];
	for(int i = 1; i <= n; i++) cin >> v[i];
	
	for(int b = 0; b < 64; b++){
		llint B = ((llint)1) << b;
		for(int i = 1; i <= n; i++){
			if(s[i] == 0 && (u[i]&B)){
				for(int j = 1; j <= n; j++) ans[i][j] |= B;
			}
			if(t[i] == 0 && (v[i]&B)){
				for(int j = 1; j <= n; j++) ans[j][i] |= B;
			}
		}
		
		bool rflag = false, cflag = false;
		vector<llint> rvec, cvec;
		for(int i = 1; i <= n; i++){
			if(s[i] == 0 && ((u[i]&B)==0)) rvec.push_back(i);
			if(t[i] == 0 && ((v[i]&B)==0)) cvec.push_back(i);
			
			if(u[i]&B) rflag = true;
			if(v[i]&B) cflag = true;
		}
		
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				if(s[i] == 1 && (u[i]&B) && t[j] == 1 && (v[j]&B)){
					ans[i][j] |= B;
				}
			}
		}
		
		llint id = 0;
		for(int i = 1; i <= n; i++){
			if(s[i] == 1 && (u[i]&B)){
				if(cflag) continue;
				if((int)cvec.size() == 0){
					cout << -1 << endl;
					return 0;
				}
				llint p = cvec[id%(int)cvec.size()];
				ans[i][p] |= B;
				id++;
			}
		}
		id = 0;
		for(int i = 1; i <= n; i++){
			if(t[i] == 1 && (v[i]&B)){
				if(rflag) continue;
				if((int)rvec.size() == 0){
					cout << -1 << endl;
					return 0;
				}
				llint p = rvec[id%(int)rvec.size()];
				ans[p][i] |= B;
				id++;
			}
		}
	}
	
	/*for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}*/
	
	for(int i = 1; i <= n; i++){
		llint a = ans[i][1], o = ans[i][1];
		for(int j = 1; j <= n; j++) a &= ans[i][j], o |= ans[i][j];
		if(s[i] == 0 && a != u[i]){
			cout << -1 << endl;
			return 0;
		}
		if(s[i] == 1 && o != u[i]){
			cout << -1 << endl;
			return 0;
		}
	}
	
	for(int i = 1; i <= n; i++){
		llint a = ans[1][i], o = ans[1][i];
		for(int j = 1; j <= n; j++) a &= ans[j][i], o |= ans[j][i];
		if(t[i] == 0 && a != v[i]){
			cout << -1 << endl;
			return 0;
		}
		if(t[i] == 1 && o != v[i]){
			cout << -1 << endl;
			return 0;
		}
	}
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 7600
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <math.h>
#include <algorithm>
#include <iomanip>
typedef long long ll;
using namespace std;

int main(void)
{
	int a, b;

	cin >> a >> b;

	if (a >= 13) cout << b << endl;
	else if (a >= 6) cout << b/2 << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

int n,a[N];
ll dp[N][5];
ll rec(int i,int j){
    if(i==n and j==4) return 0;
    if(i>n) return 0;
    ll &cache=dp[i][j];
    if(cache!=1e18) return cache;
    if(j==4) return cache=a[i]+max({rec(i+4,2),rec(i+3,3),rec(i+2,4)});
    if(j==3) return cache=a[i]+max(rec(i+3,2),rec(i+2,3));
    else return cache=a[i]+rec(i+2,2);
}
signed main(){
    FastIO;
    cin>>n;
    rep(i,1,n){
        cin>>a[i];
        rep(j,0,4) dp[i][j]=1e18;
    }
    ll ans;
    if(n&1) ans=max({rec(1,4),rec(2,3),rec(3,2)});
    else ans=max(rec(1,3),rec(2,2));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 20020
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
----
-- Create n dimension array.
local function array(dimension, default_val)
    local n = dimension
    local metatables = {}
    if default_val ~= nil then
        metatables[1] = {__index = function() return default_val end}
    end
    for i=2,n do
        metatables[i] = {__index = function(parent, k)
            local child = setmetatable({}, metatables[i-1])
            rawset(parent, k, child)
            return child
        end}
    end
    return setmetatable({}, metatables[n])
end
----
local N, W = read.nn()
local ws, vs = {}, {}
for i=1,N do
    ws[i] = read.n()
    vs[i] = read.n()
end

-- tbl[n][w]
local tbl = array(2, 0)
tbl[0][0] = 0
for i=0,N-1 do
    for w, _ in pairs(tbl[i]) do
        tbl[i+1][w] = math.max(tbl[i+1][w], tbl[i][w])
        if w+ws[i+1] <= W then
            local cur_val = tbl[i+1][w+ws[i+1]]
            local try_val = tbl[i][w] + vs[i+1]
            tbl[i+1][w+ws[i+1]] = math.max(cur_val, try_val)
        end
    end
end
local ans = 0
for w, _ in pairs(tbl[N]) do
    ans = math.max(ans, tbl[N][w])
end
print(ans)

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 101
#define int ll
#define INF 1e9
int N;
int A[maxn],B[maxn],C[maxn];

int mn = INF,mx=-INF;
int mnidx,mxidx;
vpi ans;
int32_t main(){
	fast;
	
	cin>>N;
	
	bool allneg = 1, allpos = 1;
	FOR(i,1,N){
		cin>>A[i];
		B[i] = C[i] = A[i];
		if (mx < A[i]){
			mx = A[i];
			mxidx = i;
		}
		if (mn > A[i]){
			mn = min(mn,A[i]);
			mnidx = i;
		}
		
		if (A[i] > 0) allneg = 0;
		if (A[i] < 0) allpos = 0;
		
	}
		
	if (allneg){
		vpi ans;
		
		DEC(i,N-1,1){
			ans.pb(pi(i+1,i));
		}
		
		cout<<ans.size()<<'\n';
		
		aFOR(i,ans) cout<<i.f<<' '<<i.s<<'\n';
		return 0;
	}
	
	if (allpos){
		vpi ans;
		
		FOR(i,2,N){
			ans.pb(pi(i-1,i));
		}
		
		cout<<ans.size()<<'\n';
		
		aFOR(i,ans) cout<<i.f<<' '<<i.s<<'\n';
		return 0;
	}
	
	int pans = 0; vpi pvans;
	
	int tempmx = mx;
	
	while (tempmx < -mn){
		tempmx *= 2;
		pans++;
		pvans.pb(pi(mxidx,mxidx));
	}
	
	FOR(i,1,N){
		if (B[i] < 0){
			B[i] += tempmx;
			pans++;
			pvans.pb(pi(mxidx,i));
		}
	}
	
	int nans = 0; vpi nvans;
	int tempmn = mn;
	
	while (-tempmn < mx){
		tempmn *= 2;
		nans++;
		nvans.pb(pi(mnidx,mnidx));
	}
	
	FOR(i,1,N){
		if (C[i] > 0){
			C[i] += tempmn;
			nans++;
			nvans.pb(pi(mnidx,i));
		}
	}
	
	if (pans < nans){
		FOR(i,2,N){
			B[i] += B[i-1];
			pvans.pb(pi(i-1,i));
		}
		
		cout<<pvans.size()<<'\n';
		aFOR(i,pvans){
			cout<<i.f<<' '<<i.s<<'\n';
		}
	}else{
		DEC(i,N-1,1){
			B[i] += B[i+1];
			nvans.pb(pi(i+1,i));
		}
		
		cout<<nvans.size()<<'\n';
		aFOR(i,nvans){
			cout<<i.f<<' '<<i.s<<'\n';
		}
	}
	
		
	
	
	
	
	
	
	
}



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

long long int gcm(long long a,long long b){
	long long r,tmp;
	if(a<b){
		tmp=a;
		a=b;
		b=tmp;
	}
	
	r=a%b;
	while(r!=0){
		a=b;
		b=r;
		r=a%b;
	}
	return b;
}

int main(){
	long long A,B;
	cin >> A >> B;
	long long N=gcm(A,B);
	
	set<long long> s;
	s.insert(1);
	
	long long p=2;
	while(p*p<=N){
		if(N%p==0){
			if(s.count(p)==0)s.insert(p);
			N/=p;
		}
		else p++;
	}
	if(s.count(N)==0)s.insert(N);
	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 256
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll n,a;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>n>>a;
	cout<<(n*n-a);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static class Tuple {
		char type;
		int num;
		List<Integer> vals;

		Tuple(char type, int num) {
			this.type = type;
			this.num = num;
			this.vals = new ArrayList<>();
		}

		void setVals() {
			if (type == '<') {
				for (int i = 0; i <= num; ++i) {
					vals.add(i);
				}
			} else {
				for (int i = num; i >= 0; --i) {
					vals.add(i);
				}
			}
		}
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		char[] S = in.readLine().toCharArray();
		int min = 0, max = 0, current = 0;
		Deque<Tuple> deque = new ArrayDeque<>();
		deque.add(new Tuple(S[0], 1));
		for (int i = 1; i < S.length; ++i) {
			if (deque.getLast().type == S[i]) {
				deque.getLast().num++;
			} else {
				deque.addLast(new Tuple(S[i], 1));
			}
		}
		List<Tuple> list = new ArrayList<>();
		list.addAll(deque);
		for (Tuple tuple : list) {
			tuple.setVals();
		}
		Deque<Integer> vals = new ArrayDeque<>();
		vals.addAll(list.get(0).vals);
		for (int i = 0; i + 1 < list.size(); ++i) {
			Tuple prev = list.get(i);
			Tuple next = list.get(i + 1);
			if (prev.type == '<') {
				// 最後の要素を入れ替える
				int lastVal = vals.pollLast();
				vals.addLast(Math.max(lastVal, next.vals.get(0)));
				for (int j = 1; j < next.vals.size(); ++j) {
					vals.addLast(next.vals.get(j));
				}
			} else {
				for (int j = 1; j < next.vals.size(); ++j) {
					vals.addLast(next.vals.get(j));
				}
			}
		}
		long sum = 0L;
		while (!vals.isEmpty()) {
			int val = vals.pollFirst();
			sum += val;
		}
		System.out.println(sum);
	}
};

Measured memory_bytes: 67340