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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

const int N = 2e5 + 10;
ll dp[3][N];

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    vi v; vscan;
    dp[0][0] = dp[1][0] = dp[2][0] = v[0];
    dp[0][1] = dp[1][1] = dp[2][1] = v[1];
    for(i = 2; i < n; i++){
        dp[0][i] = dp[0][i-2] + v[i];
        dp[1][i] = max(dp[1][i-2], dp[0][i-3]) + v[i];
        dp[2][i] = max(dp[2][i-2], dp[1][i-3]) + v[i];
    }
    if(n & 1){
        ll ans = dp[0][n-3];
        ans = max3(dp[0][n-2], dp[1][n-2], ans);
        ans = max3(dp[0][n-1], dp[1][n-1], max(ans, dp[2][n-1]));
        cout << ans << endl;
    }
    else cout << max3(dp[0][n-2], dp[0][n-1], dp[1][n-1]) << endl;
    return 0;
}


Measured memory_bytes: 8800
function main()
  
  X, Y = map(x -> parse(Int, x), split(readline()))
  
  ans = false

  for i in 0:X
    if 2i + 4(X-i) == Y || 2(X-i) + 4i == Y
      ans = true
    end
  end
  
  if ans
    println("Yes")
  else
    println("No")
  end
  
end

main()

Measured memory_bytes: 161976
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

LL modpow(LL a, LL b, LL mod = kMod) {
  LL r = 1;
  while (b) {
    if (b % 2 == 1) r = r * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return r;
}

int main() {
  LL N, K; cin >> N >> K;

  vector<LL> dp(K + 1);
  dp[0] = 0;
  for (int k = 1; k <= K; ++k) {
    int x = K/k;
    dp[k] = modpow(x, N) % kMod;
  }

  LL total = 0;
  for (int k = K; k > 0; --k) {
    for (int j = 2; j * k <= K; ++j) {
      dp[k] = (dp[k] + kMod - dp[j*k]) % kMod;
    }
    LL item = dp[k] * k % kMod;
    total = (total + item) % kMod;
  }
  cout << total << endl;
}


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

vector<long long>::iterator find_nearest(vector<long long>& s, 
                                long long x) {
    return upper_bound(s.begin(),s.end(),x);
}


int main(int argc, char const *argv[])
{
    int a, b, q; cin >> a >> b >> q;
    vector<long long> s(a+2, 0uLL);
    for(int i=0;i<a;++i) {
        cin >> s[i];
    }
    s[a] = -10000000000001; s[a+1] = 10000000000001;
    sort(s.begin(), s.end());

    vector<long long> t(b+2, 0uLL);
    for(int i=0;i<b;++i) {
        cin >> t[i];
    }
    t[b] = -10000000000001; t[b+1] = 10000000000001;
    sort(t.begin(), t.end());


    long long x, s1, s2, t1, t2, ans;
    vector<long long>::iterator s2i, t2i;
    for(int i=0;i<q;++i) {
        cin >> x;
        s2i = find_nearest(s, x);
        t2i = find_nearest(t, x);
        s1 = *(s2i-1); s2 = *s2i;
        t1 = *(t2i-1); t2 = *t2i;
        ans = x - min(s1, t1); // s1, t1
        ans = min(ans, max(s2,t2) - x); // s2, t2;
        ans = min(ans, 2*min(x-s1, t2-x) + max(x-s1, t2-x)); // s1, t2
        ans = min(ans, 2*min(x-t1, s2-x) + max(x-t1, s2-x)); // s2, t1
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>

#define el endl
#define fd fixed

using namespace std;

class Dice
{
private:
  int top;
  int face;
  int right;
  int left;
  int back;
  int bottom;
public:
  void setTop(int a);
  void setFace(int a);
  void setRight(int a);
  void setLeft(int a);
  void setBack(int a);
  void setBottom(int a);
  int getTop();
  int getFace();
  int getRight();
  int getLeft();
  int getBack();
  int getBottom();
  void roll(string s);
  void rollE();
  void rollN();
  void rollS();
  void rollW();
};

void Dice::setTop(int a) {
  top = a;
}

void Dice::setFace(int a) {
  face = a;
}

void Dice::setRight(int a) {
  right = a;
}

void Dice::setLeft(int a) {
  left = a;
}

void Dice::setBack(int a) {
  back = a;
}

void Dice::setBottom(int a) {
  bottom = a;
}

int Dice::getTop() {
  return top;
}

int Dice::getFace() {
  return face;
}

int Dice::getRight() {
  return right;
}

int Dice::getLeft() {
  return left;
}

int Dice::getBack() {
  return back;
}

int Dice::getBottom() {
  return bottom;
}

void Dice::roll(string s) {
  int n = s.length();
  for (int i = 0; i < n; i++) {
    if (s[i] == 'E') rollE();
    if (s[i] == 'N') rollN();
    if (s[i] == 'S') rollS();
    if (s[i] == 'W') rollW();
  }
}

void Dice::rollE() {
  int tmp = top;
  top = left;
  left = bottom;
  bottom = right;
  right = tmp;
}

void Dice::rollN() {
  int tmp = top;
  top = face;
  face = bottom;
  bottom = back;
  back = tmp;
}

void Dice::rollS() {
  int tmp = top;
  top = back;
  back = bottom;
  bottom = face;
  face = tmp;
}

void Dice::rollW() {
  int tmp = top;
  top = right;
  right = bottom;
  bottom = left;
  left = tmp;
}

int main() {
  Dice d;
  int a[6];
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5];
  d.setTop(a[0]);
  d.setFace(a[1]);
  d.setRight(a[2]);
  d.setLeft(a[3]);
  d.setBack(a[4]);
  d.setBottom(a[5]);
  string s;
  cin >> s;
  d.roll(s);
  cout << d.getTop() << el;
  return 0;
}

Measured memory_bytes: 1208
void main() {
    string b = readln.chomp;
    b == "A" && "T".writeln;
    b == "T" && "A".writeln;
    b == "C" && "G".writeln;
    b == "G" && "C".writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 256
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
const int mxn = 1e5+5;

int32_t main(){
    int n;cin>>n;
    vc <ll> arr(n);
    for(int i=0; i<n; i++) cin >> arr[i];
    vc <ll> dp(n, inf);
    dp[0] = 0;
    for(int i=0; i<n; i++) {
        for(auto j: {i+1, i+2}) {
            if (j<n) {
                dp[j] = min(dp[j], dp[i] + abs(arr[i] - arr[j]));
            }
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
# include <cstdio>
# include <iostream>
# include <algorithm>
# include <cmath>
# include <string>
# include <cstring>
# include <iomanip>
# include <functional>
# include <numeric>
# include <map>
# include <cstdlib>
# include <queue>
# include <cctype>
using namespace std;
template <class code>inline code read(const code &a)
{
    code x=0;short w=0;char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return w?-x:x;
}
typedef long long ll;
const int N=2e5+5;
char s[N];
int l[N],r[N];
int main ()
{
	memset (l,-1,sizeof (l));
	memset (r,-1,sizeof (r));
	int n=read (n),k=read (k),c=read (c),cnt=1;
	scanf ("%s",s+1);
    for (int i=1;i<=n&&cnt<=k;++i)
	{
        if (s[i]=='x')
			continue;
        else
		{
            l[cnt++]=i;
            i+=c;
        }
    }
    cnt=k;
    for (int i=n;i>=1&&cnt;--i)
	{
        if(s[i]=='x')
			continue;
        else
		{
            r[cnt--]=i;
            i-=c;
        }
    }
    for (int i=1;i<=k;++i)
        if (l[i]==r[i]&&l[i]!=-1)
    		printf ("%d\n",l[i]);
	return 0;
}

Measured memory_bytes: 5568
mod = 10**9 + 7

n,k = map(int,input().split()) # n:0~nまでの数 k:選ぶ最低個数

sum_num = 0
for i in range(k,n+2):
  max_num = int(i*(n+n-i+1)/2)
  min_num = int(i*(i-1)/2)

  sum_num = (sum_num + (max_num-min_num + 1)) % mod

print(sum_num)

Measured memory_bytes: 9192
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int cnt = Integer.parseInt(s.nextLine());
		int[][] list = new int[cnt][cnt];
		for(int i=0 ; i<cnt ; i++) {
			String[] tmp = s.nextLine().split(" ");
			for(int j=0 ; j<Integer.parseInt(tmp[1]) ; j++) {
				list[Integer.parseInt(tmp[0])-1][Integer.parseInt(tmp[j+2])-1] = 1;
			}
		}

		for(int i=0 ; i<list.length ; i++) {
			StringBuilder sb = new StringBuilder();
			for(int j=0 ; j<list[i].length ; j++) {
				if(list[i][j]==0)
					sb.append("0 ");
				else
					sb.append("1 ");
			}
			System.out.println(sb.toString().trim());
		}
	}

}

Measured memory_bytes: 21312
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;



int main(){
  int n; cin>>n;
  long long h[110000];
  for(int i=0;i<n;i++)
  cin>>h[i];
  int ans[110000]={0};

  for(int i=0;i<n-1;i++){
    int cnt=0;
    int j=i;
    while(h[j]>=h[j+1] && j+1<n){
      cnt++;
      j++;
    }
    ans[i]=cnt;
    i=j;
  }

  int mx=0;
  for(int i=0;i<n;i++)
  if(mx<ans[i]) mx=ans[i];

  cout<<mx<<endl;
}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;

namespace ACLBeginnerContest
{
    class Program
    {
        static void Main(string[] args)
        {
            // 課題D：Friends(2020/9/26)

            //string[] str = Console.ReadLine().Split(' ');
            int K = int.Parse(Console.ReadLine());
            //int rows = int.Parse(str[1]);

            //if (rows == 0)
            //{
            //    Console.Write(1);
            //    return;
            //}

            //int[] pair;
            //int[] revsPairs;
            //int[] frends;
            //HashSet<int[]> groupArray = new HashSet<int[]>();
            //HashSet<int[]> info = new HashSet<int[]>();

            //HashSet<int> groupMember = new HashSet<int>();
            //HashSet<int> tmpGroupMember = new HashSet<int>();
            //int arraySize;
            //int gCnt;
            //int p1, p2;

            //int maxGroup = 2;

            //for (int i = 0; i < rows; i++)
            //{
            //    str = Console.ReadLine().Split(' ');
            //    pair = new int[] { p1 = int.Parse(str[0]), p2 = int.Parse(str[1]) };
            //    revsPairs = new int[] { p2, p1 };

            //    if (info.Contains(pair) || info.Contains(revsPairs)) continue;
            //    else info.Add(pair);

            //    gCnt = 0;

            //    groupMember.Clear();

            //    foreach (int[] group in groupArray)
            //    {

            //        if (!group.Contains(pair[0]) && !group.Contains(pair[1])) continue;

            //        tmpGroupMember.Clear();

            //        tmpGroupMember.UnionWith(group);
            //        tmpGroupMember.UnionWith(pair);

            //        groupMember.UnionWith(tmpGroupMember);

            //        gCnt++;

            //        if (gCnt == 2)
            //        {
            //            groupArray.Remove(group);
            //            break;
            //        }

            //    }

            //    if (gCnt == 0)
            //    {
            //        groupArray.Add(pair);
            //    }
            //    else
            //    {
            //        arraySize = groupMember.Count();
            //        frends = new int[arraySize];
            //        groupMember.CopyTo(frends);

            //        groupArray.Add(frends);
            //        if (maxGroup < arraySize) maxGroup = arraySize;
            //    }

            //}

            string str= "ACL";
            if(K==1)
            {
                Console.Write(str);

                return;
            }

            for (int i= 0;i<K-1; i++)
            {
                str = str + "ACL";
            }

            Console.Write(str);
        }
    }
}


Measured memory_bytes: 27540
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <algorithm>

using namespace std;

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

	cout << 2 * b - a << endl;
}

Measured memory_bytes: 256
# D - Wizard in Maze
import sys
from collections import deque
from typing import List, Tuple


class WarpableMaze:
    __slots__ = ["height", "width", "road", "wall", "grid"]

    def __init__(
        self,
        height: int,
        width: int,
        grid: List[str],
        road: str = ".",
        wall: str = "#",
    ) -> None:
        # Values of start and goal must be 0-origin.
        self.height = height + 4
        self.width = width + 4
        self.road = road
        self.wall = wall
        self.grid = self._flatten_grid(grid)

    def _flatten_grid(self, grid: List[str]) -> str:
        flat_grid = self.wall * self.width * 2
        for row in grid:
            flat_grid += self.wall * 2 + row + self.wall * 2
        flat_grid += self.wall * self.width * 2
        return flat_grid

    def _flatten_dxy(self, x: int, y: int) -> int:
        return self.width * x + y

    def _flatten_coordinate(self, h: int, w: int) -> int:
        return self._flatten_dxy(h + 2, w + 2)

    def bfs(self, start_2d: Tuple[int, int], goal_2d: Tuple[int, int]) -> int:
        start = self._flatten_coordinate(*start_2d)
        goal = self._flatten_coordinate(*goal_2d)

        w = self.width
        flatten = lambda *dxy: tuple(self._flatten_dxy(_dx, _dy) for _dx, _dy in dxy)
        move_to_warp = {
            -w: flatten((-2, -2), (-2, -1), (-2, 0), (-2, 1), (-1, -1)),
            w: flatten((1, 1), (2, -1), (2, 0), (2, 1), (2, 2)),
            -1: flatten((-1, -2), (0, -2), (1, -2), (1, -1), (2, -2)),
            1: flatten((-1, 1), (-2, 2), (-1, 2), (0, 2), (1, 2)),
        }

        unsearched = 1 << 30
        dist = [unsearched] * (self.height * self.width)
        dist[start] = 0
        queue = deque([start])
        while queue:
            x = queue.popleft()
            cur_dist = dist[x]
            if x == goal:
                break

            for move, warp in move_to_warp.items():
                nx = x + move
                if self.grid[nx] == self.road:
                    if dist[nx] > cur_dist:
                        dist[nx] = cur_dist
                        queue.appendleft(nx)
                    continue

                for dx in warp:
                    nx = x + dx
                    if self.grid[nx] == self.wall:
                        continue
                    if dist[nx] > cur_dist + 1:
                        dist[nx] = cur_dist + 1
                        queue.append(nx)

        return dist[goal] if dist[goal] != unsearched else -1

    def debug(self):
        print("<DEBUG>", file=sys.stderr)
        for row in zip(*[iter(self.grid)] * self.width):
            print(*row, file=sys.stderr)


def main():
    H, W, CH, CW, DH, DW, *S = open(0).read().split()
    maze = WarpableMaze(int(H), int(W), S)
    start, goal = (int(CH) - 1, int(CW) - 1), (int(DH) - 1, int(DW) - 1)
    print(maze.bfs(start, goal))
    # maze.debug()


if __name__ == "__main__":
    main()


Measured memory_bytes: 219716
import sys
from collections import defaultdict
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, K, L = map(int, input().split())

ufl = UnionFind(N)
uft = UnionFind(N)

for _ in range(K):
    p, q = map(int, readline().split())
    ufl.union(p-1, q-1)

for _ in range(L):
    r, s = map(int, readline().split())
    uft.union(r-1, s-1)

# print(uft.all_group_members())

grp = [(ufl.find(i), uft.find(i)) for i in range(N)]

# print(grp)

dd = defaultdict(int)

for g in grp:
    dd[g] += 1

ans = []

for i in range(N):
    ans.append(dd[grp[i]])

print(' '.join(map(str, ans)))

'''
cnts = [0] * N

for i in range(N):
    cnts[i] = uft.size(i)

print(' '.join(map(str, cnts)))
'''


Measured memory_bytes: 52196
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << a*b/2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

int read() {
	char ch;
	for(ch=getchar();ch<'0'||ch>'9';ch=getchar());
	int x=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

const int N=(1<<18)+5,Mo=998244353;

ll pwr(ll x,ll y) {
	ll z=1;
	for(;y;y>>=1,x=x*x%Mo)
		if (y&1) z=z*x%Mo;
	return z;
}

int n;
ll p[N],q[N];

void FWT(ll *a,int len,int flag) {
	for(int i=1;i<len;i<<=1)
		for(int j=0;j<len;j+=i<<1)
			for(int k=0;k<i;k++) {
				ll u=a[j+k],v=a[j+k+i];
				a[j+k]=(u+v)%Mo;a[j+k+i]=(u-v)%Mo;
			}
	if (flag==-1) {
		ll inv=pwr(len,Mo-2);
		for(int i=0;i<len;i++) a[i]=a[i]*inv%Mo;
	}
}

int main() {
	n=read();
	ll sum=0;
	fo(s,0,(1<<n)-1) p[s]=read(),sum+=p[s];
	ll inv=pwr(sum,Mo-2);
	fo(s,0,(1<<n)-1) p[s]=p[s]*inv%Mo;p[0]--;
	fo(s,1,(1<<n)-1) q[s]=-1;q[0]=(1<<n)-1;
	FWT(q,(1<<n),1);FWT(p,(1<<n),1);
	fo(s,1,(1<<n)-1) q[s]=q[s]*pwr(p[s],Mo-2)%Mo;
	FWT(q,(1<<n),-1);
	fo(i,1,(1<<n)-1) (q[i]-=q[0])%=Mo;q[0]=0;
	fo(i,0,(1<<n)-1) printf("%lld\n",(q[i]+Mo)%Mo);
	return 0;
}

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


int main() {
  int N,K;
  cin>>N>>K;
  double p=0;
  for(int i=1;i<=N;i++){
    int a=i;
    double x=1.00000000/N;
    
    
    
    while(a<K){
      a = a*2;
      x = x/2;
    }
    
    p+=x;
    
    
  }
  std::cout << std::setprecision(12);
  cout<<p<<endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

bool compare(string &x , string &y){
    return x < y;
}

void solve() {
    int n , l;
    cin>>n>>l;
    vector<string> data(n);
    for (int i = 0; i < n; ++i) {
        cin>>data[i];
    }
    sort(data.begin() , data.end()  , compare);
    for(auto i: data){
        cout<<i;
    }
    cout<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k;
typedef long long int ll;
int main(){
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	int *dp;
	dp=new int[n+1];
	fill(dp,dp+n+1,INT_MAX);
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j:{i+1,i+2}){
			if(j<n){
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
		}
	}
	cout<<dp[n-1];
}

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

#define int            long long int
#define float          long double
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define inf            1e18
#define set_pre(x,y)   fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
using namespace std;
int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main(){
    int n,k;
    cin>>n>>k;
    vector<int>v(n+1,0);
    for(int i=1;i<=n;i++)
        cin>>v[i];
    int dp[n+1][k+1];
    if(k==0)
    {
        cout<<1<<endl;
        return 0;
    }
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        {
            if(i==0)
                dp[i][j]=1;
            else
            dp[i][j]=0;
        }
    }
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=1;
        for(int j=1;j<=k;j++)
        {
                dp[i][j]=(dp[i][j-1]+dp[i-1][j]-((j-v[i]-1)>=0?dp[i-1][j-v[i]-1]:0))%mod;
        }
    }
    cout<<(dp[n][k]-dp[n][k-1]+mod)%mod<<endl;
}


Measured memory_bytes: 82376
import sys
from copy import copy

sys.setrecursionlimit(10**5)

# 木の根を返す
def find(x, S):
    if S[x] == x:
        return x
    else:
        S[x] = find(S[x], S)
        return S[x]

# xとyが同じ集合に属すかの判定
def same(x, y, S):
    return find(x, S) == find(y, S)

# xとyの属する集合を結合
def unite(x, y, S):
    rx = find(x, S)
    ry = find(y, S)
    if rx == ry:
        return None
    else:
        S[rx] = ry

if __name__ == '__main__':
    [N, M] = [int(i) for i in input().split()]

    S = [int(i) for i in range(N+1)]
    p = [0] + [int(num) for num in input().split()]

    for i in range(M):
        [x, y] = [int(i) for i in input().split()]
        unite(x, y, S)

    score = 0
    for i in range(1, N+1):
        if same(i, p[i], S):
            score += 1
    print(score)


Measured memory_bytes: 18328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using Pa = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    set<int> s;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        s.insert(a);
    }
    cout << (s.size()==N? "YES":"NO") << "\n";
}

Measured memory_bytes: 9600
K = int(input())

if K <= 9:
    print(K)
else:
    mylun = 9
    lunList = []

    for indx in range(1, 10):
        lunList.append(str(indx))

    while mylun < K:
        newLunList = []
        for lunItem in lunList:
            if lunItem[len(lunItem)-1] != "0":
                mylun += 1
                newLunList.append(lunItem + str( int(lunItem[len(lunItem)-1])-1 ))
                if mylun == K:
                    print(lunItem + str( int(lunItem[len(lunItem)-1])-1 ))
                    break
            
            mylun += 1
            newLunList.append(lunItem + str( int(lunItem[len(lunItem)-1]) ))
            if mylun == K:
                print(lunItem + str( int(lunItem[len(lunItem)-1]) ))
                break

            if lunItem[len(lunItem)-1] != "9":
                mylun += 1
                newLunList.append(lunItem + str( int(lunItem[len(lunItem)-1])+1 ))
                if mylun == K:
                    print(lunItem + str( int(lunItem[len(lunItem)-1])+1 ))
                    break
        
        lunList = newLunList


Measured memory_bytes: 8568
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define pb push_back
#define fs first
#define se second
#define M 1000000007
ll exp(ll a,ll p)
{
	if(p==1)
		return a;
	if(p==0)
		return 1;
	ll st=exp(a,p/2);
	st=(st*st)%M;
	if(p%2 != 0)
		st=(st*a)%M;
	return st;
} 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	vector<ll>arr(n);
	unordered_map<ll,ll>um;
	ll c=0;
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
		if(arr[i]==c+1)
			c++;
	}
	if(c!=0)
	cout<<n-c<<endl;
	else
		cout<<-1<<endl;

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const int INF = 1e9;

int n;

int a[200005],sum,xors,r;
ll ans;
bool dp[200005][22];
int main(){
  cin>>n;
  REP(i,n)cin>>a[i];
  for(int l=0;l<n;l++){
    while(r<n && (sum+a[r])==(xors^a[r])){
      sum+=a[r];xors^=a[r];r++;
    }
    ans+=r-l;
    sum-=a[l];
    xors^=a[l];
    
  }

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




Measured memory_bytes: 1024
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000
  
struct Card {
  char suit;
  int value;
};
  
struct Card L[MAX/2+2], R[MAX/2+2];
  
void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(int i=0;i<n1;i++) L[i] = A[left + i];
  for(int i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}
  
void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}
  
int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}
  
void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}
  
int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;
  
  scanf("%d", &n);
  
  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }
  
  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);
  
  for(i=0;i<n;i++) {
    if(A[i].suit != B[i].suit) stable = 0;
  }
  
  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  
  return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    cout << (s<t ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int64_t n;
    cin>>n;
    vector<int64_t> a(n);
    map<int64_t,int64_t> p;
    int max=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]>max){
            max = a[i];
        }
        p[a[i]]++;
    }
    int ans=0;
    for(int i=0;i<=max;i++){
        int sum = p[i]+p[i+1]+p[i+2];
        //cout<<sum<<endl;
        if(sum>ans){
            ans = sum;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7296
#include <cstdio>
#include <utility>
#include <vector>
#include <complex>
#include <cmath>

using namespace std;

static const double EPS=1e-12;
static const double INF=1e24;

using Point=complex<double>;
using Plane=vector<Point>;

bool operator<(const Point &a, const Point &b) {
    return real(a)!=real(b)? real(a)<real(b) : imag(a)<imag(b);
}

double cross_prod(const Point &a, const Point &b) {
    return imag(conj(a)*b);
}

double dot_prod(const Point &a, const Point &b) {
    return real(conj(a)*b);
}

struct Line: public pair<Point, Point> {
    Line() {}
    Line(const Point &a, const Point &b) {
        first = a;
        second = b;
    }
};

bool is_parallel(const Line &l, const Line &m) {
    return abs(cross_prod(l.second-l.first, m.second-m.first)) < EPS;
}

bool is_orthogonal(const Line &l, const Line &m) {
    return abs(dot_prod(l.second-l.first, m.second-m.first)) < EPS;
}

int main() {
    size_t q;
    scanf("%zu", &q);
    for (size_t i=0; i<q; ++i) {
        double x, y;
        scanf("%lf %lf", &x, &y);
        Point p0(x, y);

        scanf("%lf %lf", &x, &y);
        Point p1(x, y);

        scanf("%lf %lf", &x, &y);
        Point p2(x, y);

        scanf("%lf %lf", &x, &y);
        Point p3(x, y);

        Line l(p0, p1), m(p2, p3);
        if (is_parallel(l, m)) {
            printf("2\n");
        } else if (is_orthogonal(l, m)) {
            printf("1\n");
        } else {
            printf("0\n");
        }
    }

    return 0;
}

Measured memory_bytes: 2744
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
	int n, k;
	string s;
	cin >> n >> s >> k;
	for (int i = 0; i < n; i++) {
		if (s.at(i) != s.at(k - 1)) {
			s.at(i) = '*';
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, ans = 0;
  cin >> n;
  rep(i, n) {
    ll a;
    cin >> a;
    ans += a;
  }
  ans -= n;
  cout << ans << endl;
}

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

typedef long long ll;
ll n, s, s2, cnt, mn = 1e10, a[100005];
int main()
{
	ll i;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf ("%lld", &a[i]);
		s += a[i];
		if (a[i] < 0) {
			cnt++;
			mn = min(mn, -a[i]);
			s2 += -a[i];
		} else {
			s2 += a[i];
			mn = min(mn, a[i]);
		}
	}
	if (cnt % 2 == 0) cout << s2 << endl;
	else cout << s2 - mn * 2;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	string_tolower(string &s)
{
	int n = s.size();
	rep(i, n) {
		s[i] = tolower(s[i]);
	}
}

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

	string s;
	while (cin >> s) {
		if (s == "-")
			break;
		int m;
		cin >> m;
		while (m--) {
			int h;
			cin >> h;
			s = s.substr(h) + s.substr(0, h);
		}
		cout << s << endl;
	}
}



Measured memory_bytes: 3256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        n: usize,
        s1:chars,
        s2:chars,
    }
    for i in 0..n{
        print!("{}{}",s1[i],s2[i])
    }
}

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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    string s,t;
    cin>>n>>m>>s>>t;
    ll g=__gcd(n,m),x=n/g*m;
    for(int i=0;i<=g;i++){
    	if(s[n/g*i]!=t[m/g*i]){
    		cout <<-1<<endl;
    		return 0;
    	}
    }
    cout <<x<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,w;
    cin>>n>>w;
    vector<vector<int> > input(n,vector<int>(2));
    for(int i=0;i<n;++i){
        cin>>input[i][0]>>input[i][1];
    }
    ll ninf=LLONG_MIN;
    vector<vector<ll> > dp(n+1,vector<ll>(w+1,ninf));
    dp[0][0]=0;
    ll ans=ninf;
    for(int i=1;i<=n;++i){
        for(int j=0;j<=w;++j){
            int weight=input[i-1][0];
            int value=input[i-1][1];
            if(j-weight>=0) {
                dp[i][j] = max((dp[i - 1][j - weight] < 0 ? ninf : value + dp[i - 1][j - weight]),dp[i-1][j]);
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
            ans=max(ans,dp[i][j]);
        }
    }
//    for(int i=0;i<=n;++i){
//        for(int j=0;j<=w;++j){
//            cout<<dp[i][j]<<" ";
//        }
//        cout<<endl;
//    }
    cout<<ans;
    cout<<endl;
}


Measured memory_bytes: 83004
# -*- coding: utf-8 -*-

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    N = int(input())
    A = list(map(int, input().split()))

    return N, A

def main(N: int, A: list) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 日数（2 <= N <= 80）
        A (list): i日目の株価（100 <= A_i <= 200）
    """
    # 求解処理
    dp = [-1 for n in range(N)]
    dp[0] = 1000
    for i in range(1, N):
        dp[i] = dp[i - 1]
        for j in range(i):
            V = dp[j] // A[j]
            W = dp[j] + (A[i] - A[j]) * V
            dp[i] = max(dp[i], W)

    # 結果出力
    print(dp[N - 1])

if __name__ == "__main__":
    # 標準入力を取得
    N, A = get_input()

    # メイン処理
    main(N, A)


Measured memory_bytes: 9228
using System;

namespace ABC088_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string str1 = Console.ReadLine();
            int a = int.Parse(str1);
            string str2 = Console.ReadLine();
            int b = int.Parse(str2);
            if(a % 500 <= b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937_64 mt64(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int perm[114514];
void init() {
	perm[0] = 1;
	REP(i, 114514) {
		perm[i] = perm[i - 1] * i % mod;
	}
}
int kai_(int x, int y) {
	int a = perm[x - y], b = perm[x];
	return b * mod_pow(a, mod - 2, mod) % mod;
}
int combi(int x, int y) {
	if (y > x)return 0;
	return kai_(x, y) * mod_pow(perm[y], mod - 2, mod) % mod;
}

int n;
int wh[114514];
signed main() {
	init();
	cin >> n;
	REP(i, n + 1)wh[i] = -1;
	int k, l;
	rep(i, n + 1) {
		int a; cin >> a;
		if (wh[a] != -1) {
			k = wh[a]; l = i;
		}
		else wh[a] = i;
	}
	REP(i, n + 2) {
		int ans = combi(n + 1, i);
		int kouho = k + n - l;
		cout << (ans - combi(kouho, i - 1) + mod) % mod << endl;
	}
}

Measured memory_bytes: 2944
import sys

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


mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	n,k=map(int,input().split())
	A=list(map(int,input().split()))
	A.sort()
	
	comb=[1]
	for i in range(n-k):
		comb.append((comb[-1]*(k+i)*pow(i+1,mod-2,mod))%mod)
	ans=0
	
	for i in range(n-k+1):
		ans+=((comb[i]*A[k-1+i])-(comb[i]*A[n-k-i]))%mod
		ans=ans%mod
	print(ans)


if __name__ == "__main__":
	main()


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

#ここから累積和
s = Array.new(a.length+1)
s[0] = 0
0.upto(n-1) do |i|
  s[i+1] = s[i] + a[i]
end

h = 10**10
for i in 0..n-2 #0~iまで新井がとる
  if h > (s[n]+s[0]-2*s[i+1]).abs
    h = (s[n]+s[0]-2*s[i+1]).abs
  end
end

puts h

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

int main()
{
	long n;
	cin >> n;
	long A[n+1];
	long B[n];

	rep(i, n + 1)
		cin >> A[i];
	rep(i, n)
		cin >> B[i];
	long ans = 0;
	rep(i, n)
	{
		if (B[i] >= A[i])
		{
			B[i] -= A[i];
			ans += A[i];
		}
		else
		{
			ans += B[i];
			B[i] = 0;
		}
		if (B[i] >= A[i+1])
		{
			B[i] -= A[i+1];
			ans+= A[i+1];
			A[i+1] = 0;
		}
		else
		{
			ans += B[i];
			A[i+1] -= B[i];
			B[i] = 0;
		}
		// cout << B[i] << A[i] << ans << endl;
	}
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		boolean judge = true;

		while(judge) {
			if(judgeNum(x)) {
				judge = false;
				System.out.println(x);
			}
			x++;
		}
	}

	private static boolean judgeNum(int x) {
		for(int i = 2;i < x/2;i++) {
			if(x % i == 0){
				return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 35916
#include <stdio.h>

int main(void){
	int i,j,v,n,A[200];
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	for(i=1;i<=n-1;i++){
		for(j=0;j<n;j++){
			printf("%d",A[j]);
		if(j<n-1){
			printf(" ");
		}
		}
		printf("\n");
		v = A[i];
		j=i-1;
		while(j>= 0 && A[j]>v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] =v;
	}
	for(j=0;j<n;j++){
		printf("%d",A[j]);
		if(j<n-1){
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    int ans = 0;
    for(int i=1; i<=n; i++){
        if(i % 3 != 0 && i % 5 != 0){
            ans += i;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)n; ++i)

vector<pair<int, pair<int, int> > > g[101];
bool an[1000];
int vis[101];

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	f(i, 0, m){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		g[a].push_back(make_pair(b, make_pair(c, i)));
		g[b].push_back(make_pair(a, make_pair(c, i)));
	}
	f(i, 1, n + 1){
		f(i, 1, n + 1)vis[i] = 1e9;
		priority_queue<pair<int, pair<int, int> > > q;
		q.push(make_pair(0, make_pair(i, -1)));
		while (!q.empty()){
			int v = q.top().second.first, ed = q.top().second.second, w = -q.top().first;
			q.pop();
			if (vis[v] == w)an[ed] = true;
			if (vis[v] <= w)continue;
			vis[v] = w;
			if (ed != -1)an[ed] = true;
			f(i, 0, g[v].size()){
				int u = g[v][i].first, nw = g[v][i].second.first + w, ed = g[v][i].second.second;
				if (vis[u] < nw)continue;
				q.push(make_pair(-nw, make_pair(u, ed)));
			}
		}
	}
	int a = 0;
	f(i, 0, m)if (!an[i])++a;
	printf("%d\n", a);
}


Measured memory_bytes: 256
class union():
    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.friends = [0 for i in range(n)]
        self.blocks = [[] for i in range(n)]
        self.counts = [1] * n
        self.block_counts = [0] * n
    def find(self, n):
        if self.par[n] == n:
            return n
        else:
            return self.find(self.par[n])
    def block(self, a, b):
        self.blocks[a].append(b)
        self.blocks[b].append(a)
        if self.same(a, b):
            self.block_counts[a] += 1
            self.block_counts[b] += 1
    def unite(self, a, b):
        x = self.find(a)
        y = self.find(b)
        self.friends[a] += 1
        self.friends[b] += 1
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.counts[y] += self.counts[x]
        else:
            self.par[y] = x
            self.counts[x] += self.counts[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    def same(self, a, b):
        return self.find(a) == self.find(b)
    def optimize(self):
        self.par = list(map(self.find, self.par))
def main():
    N, M, K = map(int, input().split())
    AB = [list(map(lambda x:int(x)-1, input().split())) for i in range(M)]
    CD = [list(map(lambda x:int(x)-1, input().split())) for i in range(K)]
    u = union(N)
    unite = u.unite
    block = u.block
    for a, b in AB:
        unite(a, b)
    for c, d in CD:
        block(c, d)
    counts = u.counts
    par = u.par
    friends = u.friends
    block_counts = u.block_counts
    result = [str(counts[u.find(i)] - friends[i] - block_counts[i] - 1) for i in range(N)]
    print(" ".join(result))
main()

Measured memory_bytes: 75172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

int N;
string c;

int main() {
    cin >> N >> c;

    int cnt_r = 0, cnt_w = 0;
    REP(i, N) {
        if (c[i] == 'R') cnt_r++;
        else cnt_w++;
    }

    int min_ope = min(cnt_r, cnt_w);
    int left_w = 0, right_r = cnt_r;
    min_ope = min(min_ope, max(left_w, right_r));
    REP(i, N) {
        if (c[i] == 'R') right_r--;
        else left_w++;
        min_ope = min(min_ope, max(left_w, right_r));
    }
    PRINT(min_ope);
    return 0;
}

Measured memory_bytes: 3684
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        char s = inp.next().toCharArray()[0];
        System.out.println((char)(((int)s)+1));
    }
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#include <vector>
 
typedef long long ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;
 
using namespace std;
 
int main() {

	int n, q;
	cin >> n >> q;

	queue<int> s[n];

	int a, b, c;

	rep(i, q) {
		cin >> a >> b;

		switch(a) {

			case 0:
				cin >> c;
				s[b].push(c);
				break;

			case 1:
				if (!s[b].empty())
					cout << s[b].front() << endl;
				break;
			
			case 2:
				if (!s[b].empty())
					s[b].pop();
				break;
		}
	}


}


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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

int main()
{
  int N, K;
  cin >> N >> K;

  vl vec(N);
  rep(i,N) cin >> vec[i];

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

  long val = vec[K-1] - vec[0];
  for( int i=1; i<N-K+1; i++ ){
    val = min( val, vec[K-1+i] - vec[i]);
  }
  cout << val << endl;

  return 0;
}



Measured memory_bytes: 1024