akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int imos[1001000]={0};
    int gotiusa; cin>>gotiusa;
    vector<pii>v;
    rep(i,gotiusa){
        int tiya,rize; cin>>tiya>>rize;
        imos[tiya]++; imos[rize+1]--;
        v.push_back(pii(tiya,rize));
    }
    rep(_,1001000)
    if(_)imos[_]+=imos[_-1];
    int ans=0;
    rep(i,1001000){
        if(imos[i]>=i-1)cmax(ans,i-1);
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 7772
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

int main(void) {
    int n;
    std::scanf("%d", &n);
    if (n / 10 == 9 || n % 10 == 9) {
        std::puts("Yes");
    }
    else {
        std::puts("No");
    }
    return 0;
}

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


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

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
const int N=1e6+6;
ll sieve[N];
ll mark[N];
void work()
{
  rep(i,N)
  {
    if(sieve[i])
    {
      if(sieve[i]>=2) mark[i]=1;
      for(ll j=2;i*j<N;j++) mark[i*j]=1;
    }
  }
}
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n;
    cin>>n;
    vector<ll> a(n+1);
    repA(i,1,n)
    {
      cin>>a[i];
      sieve[a[i]]+=1;
    }
    work();
    ll ans=0;
    repA(i,1,n)
    {
      if(!mark[a[i]]) ans++;
    }
    cout<<ans<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 20160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<vector<ll>> Matrix;

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a, b);}

long long fastpow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret *= x;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x *= x;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  bool f = false;
  rep(i, n) {
    cin >> a[i];
    if (a[i] == 0) {
      f = true;
    }
  }
  if (f) {
    cout << 0 << endl;
    return 0;
  }

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

  ll ans = 1;
  ll limit = fastpow(10, 18);
  rep(i, n) {
    ans *= a[i];
    if (ans > limit) {
      cout << -1 << endl;
      return 0;
    }
    if(i != n-1 && limit/ans < a[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3992
import sys
readline = sys.stdin.readline

n = int(readline())
s = readline().rstrip()

from collections import deque
q = deque([])

ss = set(s)

for i in ss:
    q.append(["",0,str(i)])

ans = 0
while q:
    num, ind, target = q.popleft()
    #print(num, ind, target)
    while ind < len(s):
        if s[ind] == target: #s[ind]が０から9の中のどれかを見てる
            break
        ind += 1
    else:
        continue
    num += target
    if len(num) == 3:
        ans += 1
        continue
    sss = set(s[ind+1:])
    for i in sss:
        q.append([num, ind +1, str(i)]) #出現した数字に関するキューを追加（例：一回目は024）

print(ans)

Measured memory_bytes: 9536
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

typedef priority_queue<int, vector<int>, greater<int>> minPq;
typedef priority_queue<int> maxPq;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<int> vll;
typedef pair<ll, ll> pll;
const int INF = 1e9 + 7;
void init() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef _DEBUG
    freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#endif
}

int main() {
    init();
    int N, W;
    cin >> N >> W;
    vector<ll> ww(N), vv(N);
    for(int i = 0; i < N; ++i){
        cin >> ww[i] >> vv[i];
    }
    ll t[N+1][W+1];
    for(int i = 0; i<W+1; ++i)t[0][i] = 0;
    for(int i = 1; i < N+1; ++i){
        for(int j = 0; j < W+1; ++j){
            if(j-ww[i-1] >= 0) t[i][j] = max(t[i-1][j],t[i-1][j-ww[i-1]]+vv[i-1]);
            else t[i][j] = t[i-1][j];
        }
    }
    cout << t[N][W] << endl;
}


Measured memory_bytes: 79232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

public class Main {

  final int INF = 100_000_000;
  int W, H;
  Square[][] map;
  int[][] d;
  int[] rx = {0,0,-1,1}, ry = {-1,1,0,0}; // up,down, left, right
  Deque<Square> deq = new ArrayDeque<>();

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

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines;
      StringBuilder buf = new StringBuilder();
      
      while(true) {
        lines = in.readLine().split(" ");
        W = Integer.parseInt(lines[0]);
        H = Integer.parseInt(lines[1]);

        if(W == 0 && H == 0) break;

        map = new Square[H][W];

        String line = "";
        for(int i=0; i<H; i++) {

          if(i != 0)
            line = in.readLine();
          for(int j=0; j<W; j++) {
            if(i == 0) {
              map[i][j] = new Square(j,i);
            }
            else {
              map[i][j] = new Square(j,i);
              map[i][j].wall[0] = map[i-1][j].wall[1]
              = line.charAt(j<<1) == '0' ? true : false;
            }
          }

          line = in.readLine();
          for(int j=1; j<W; j++) {
            map[i][j-1].wall[3] = map[i][j].wall[2]
            = line.charAt((j<<1)-1) == '0' ? true : false;
          }
        }
        d = new int[H][W];
        for (int[] a : d)
          Arrays.fill(a, INF); 

        int ans = bfs();
        buf.append(ans != INF ? ans : 0).append('\n');
        deq.clear();
      }

      System.out.print(buf);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  private int bfs() {

    d[0][0] = 1;
    deq.offer(map[0][0]);

    while(!deq.isEmpty()) {
      Square cur = deq.poll();

      if(cur.x == W-1 && cur.y == H-1) break;

      for(int i=0; i<4; i++) {
        int nx = cur.x + rx[i], ny = cur.y + ry[i];

        if(0 <= nx && nx < W && 0 <= ny && ny < H
          && cur.wall[i] && d[ny][nx] == INF) {

            deq.offer(map[ny][nx]);
            d[ny][nx] = d[cur.y][cur.x] + 1;
          }
      }
    }

    return d[H-1][W-1];
  }
}

class Square {
  int x,y;
  boolean[] wall;

  public Square() {
    wall = new boolean[4];
  }
  public Square(int x, int y) {
    this.x = x;
    this.y = y;
    wall = new boolean[4];
  }
}


Measured memory_bytes: 33060
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

// -----------------------------------------------------------------------------------------------------

// -----------------------------------------------------------------------------------------------------

let main() =
    let [| a; b |] = reada int
    seq {
        for i in 1 .. 10000 do
            let f = float i
            let eight = f * 0.08 |> int
            let ten = f * 0.1 |> int
            if eight = a && ten = b then yield i
    }
    |> Seq.tryHead
    |> function
    | Some(x) -> x
    | _ -> -1
    |> puts
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int n,m,p,a,b;
const int MAX_N = 8;
const int MAX_M = 30;
const double INF = 1e10;
int t[MAX_N];
int d[MAX_M][MAX_M];
double dp[1<<MAX_N][MAX_M];
void solve() {
    rep(i,1<<n) fill(dp[i],dp[i]+m,INF);
    rep(i,MAX_M) rep(j,MAX_M) d[i][j] = -1;
    rep(i,n) cin>>t[i];
    rep(i,p) {
        int x,y,z;
        cin>>x>>y>>z;
        x--;
        y--;
        d[x][y] = d[y][x] = z;
    }

    dp[(1<<n)-1][a-1] = 0.0;
    double ret = INF;

    for(int S = (1<<n)-1; S>=0;S--) {
        ret = min(ret,dp[S][b-1]);
        rep(v,m) rep(i,n) {
            if(S>>i&1) {
                rep(u,m) {
                    if(d[v][u] == -1) continue;
                    dp[S&~(1<<i)][u] = min(dp[S&~(1<<i)][u],dp[S][v]+(double)d[v][u]/t[i]);
                }
            }
        }
    }
    if(ret == INF) {
        cout<<"Impossible"<<endl;
    }
    else {
        cout<<ret<<endl;
    }

}

int main() {
    while(cin>>n>>m>>p>>a>>b) {
        if(n+m+p+a+b==0) return 0;
        solve();
    }

    return 0;
}

Measured memory_bytes: 1296
#include <stdio.h>
int main(void){
    int i;
    char s[20];

    scanf("%s",s);

    for(i=0;i<=4;i++){
        putchar(s[i]);
    }
    putchar(' ');
    for(i=6;i<=12;i++){
        putchar(s[i]);
    }
    putchar(' ');
    for(i=14;i<=18;i++){
        putchar(s[i]);
    }
    
    return 0; 
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
  char cur = 'A';
  char x, y;
  while (scanf("%c,%c ", &x, &y) == 2) {
    if (x == cur) {
      cur = y;
    } else if (y == cur) {
      cur = x;
    }
  }
  printf("%c\n", cur);
}

Measured memory_bytes: 0
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void)
{
  int n;
  long long  h[100010];
  long long  dp[100010];
  long long INF=1<<30;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",&h[i]);
  }

  for(int i=0;i<100010;i++){
    dp[i]=INF;
  }


  dp[0]=0;
  for(int i=1;i<n;i++){
    if(dp[i]>dp[i-1]+abs(h[i]-h[i-1])){
      dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
    }
    if(i>1){
      if(dp[i]>dp[i-2]+abs(h[i]-h[i-2])){
        dp[i]=dp[i-2]+abs(h[i]-h[i-2]);
      }
    }
  }

  printf("%lld\n",dp[n-1]);
  return 0;
}


Measured memory_bytes: 3212
s = gets

index = 0
result = true

while index < s.size-1
  if s[index] == "d"
    if s[index..index+6] == "dreamer" && s[index+7] != "a"
      index += 7
      next
    elsif s[index..index+4] == "dream"
      index += 5
      next
    else
      result = false
      break
    end
  elsif s[index] == "e"
    if s[index..index+5] == "eraser"
      index += 6
      next
    elsif s[index..index+4] == "erase"
      index += 5
      next
    else
      result = false
      break
    end
  else
    result = false
    break
  end
end

puts result ? "YES" : "NO"

Measured memory_bytes: 1916
// <------------- Template -----------------------> //


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(2);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 
 
typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAX5]; ll visit[] = {};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, q, m;
string s, t, d;
ll sum = 0;
ll cou = 0;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b,x;
	cin >> a >> b >> x;
	if(x < a || a+b < x) cout<<"NO";
	else cout<<"YES";
}

int main() {
	fastio; randomINT;
	//cin>>T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 5944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
using ll = long long;
const int INF=1001001001;
const int MAX_N = 200005;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int x = 1;
  vector<int> dp(n);
 rep(i, n){
   if(i == 0) dp[0] = (s[n-1]-'0');
   else{ 
     x = 10*x % 2019; 
     dp[i] = (dp[i-1] + x*(s[n-i-1]-'0')%2019)%2019;
    }
 }
  
  map<int, ll> mod;  
  rep(i, n){
    if(mod.count(dp[i])) mod.at(dp[i])++;
    else mod[dp[i]] = 1;
  }
  
 ll ans = 0;
  for(auto m : mod){
    ans += m.second*(m.second-1)/2;
	if(m.first==0) ans += m.second;
  }
  cout << ans << endl;
  
  return 0;
}
    
  
   

Measured memory_bytes: 4324
#include <algorithm>
#include <utility>
#include <cstdio>
#include <vector>
#define pb push_back
#define MOD 1000000007
typedef long long ll;
ll F[105];
std::vector<std::pair<ll, ll> > vec[105];
int main()
{
	// freopen("AGC015-F.in", "r", stdin);
	int len = 2;
	F[0] = F[1] = 1;
	while (true)
	{
		F[len] = F[len - 1] + F[len - 2];
		if (F[len] > 2e18)
			break;
		len++;
	}
	vec[1].pb({1, 2});
	vec[1].pb({1, 3});
	for (int i = 1; i < len - 3; i++)
	{
		for (auto &it : vec[i])
		{
			auto x = it.first, y = it.second;
			while (x + y <= F[i + 3])
			{
				x += y;
				vec[i + 1].pb({y, x});
			}
		}
	}
	int cas;
	scanf("%d", &cas);
	while (cas--)
	{
		ll n, m;
		scanf("%lld%lld", &n, &m);
		if (n > m)
			std::swap(n, m);
		int ans = 1;
		while (ans + 2 < len && F[ans + 1] <= n && F[ans + 2] <= m)
			ans++;
		if (ans == 1)
			printf("1 %lld\n", n * m % MOD);
		else
		{
			ll cnt = 0;
			for (auto &it : vec[ans - 1])
			{
				auto x = it.first, y = it.second;
				if (y <= n)
					(cnt += (m - x) / y) %= MOD;
				if (y <= m)
					(cnt += (n - x) / y) %= MOD;
			}
			printf("%d %lld\n", ans, cnt);
		}
	}
	return 0;
}


Measured memory_bytes: 4096
// Ho-kago Tea Time

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

const int MOD = 998244353;

inline int fpm(int x, int y)
{
	int res = 1;
	for(; y; y >>= 1, x = (LL) x * x % MOD) if(y & 1) res = (LL) res * x % MOD;
	return res;
}

inline int inv(int x) { assert(x); return fpm(x, MOD - 2); }

const int MAXN = 18;

inline void FWT(int *f, int N, int type)
{
	for(int i = 0; i < N; ++i)
		for(int S = 0; S < 1 << N; ++S) if(!(S >> i & 1))
		{
			int X = f[S], Y = f[S | 1 << i];
			f[S] = (X + Y) % MOD;
			f[S | 1 << i] = (X - Y) % MOD;
		}

	if(type == -1)
	{
		int inv2N = inv(1 << N);
		for(int S = 0; S < 1 << N; ++S) f[S] = (LL) f[S] * inv2N % MOD;
	}
}

int n;

int g[1 << MAXN];

inline void input()
{
	n = read<int>();
	for(int S = 0; S < 1 << n; ++S) g[S] = read<int>();

	int sum = 0;
	for(int S = 0; S < 1 << n; ++S) (sum += g[S]) %= MOD;
	sum = inv(sum);
	for(int S = 0; S < 1 << n; ++S) g[S] = (LL) g[S] * sum % MOD;
}

inline void solve()
{
	static int f[1 << MAXN], h[1 << MAXN];

	(g[0] -= 1) %= MOD;

	for(int S = 0; S < 1 << n; ++S) h[S] = -1;
	(h[0] += 1 << n) %= MOD;

	FWT(h, n, +1);
	FWT(g, n, +1);

	for(int S = 1; S < 1 << n; ++S) f[S] = (LL) h[S] * inv(g[S]) % MOD;
	f[0] = 0;
	FWT(f, n, -1);

	for(int S = 1; S < 1 << n; ++S) (f[S] -= f[0]) %= MOD;
	f[0] = 0;

	for(int S = 0; S < 1 << n; ++S) printf("%d\n", (f[S] + MOD) % MOD);
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 5888
package main

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

func main() {
	fmt.Printf("%d\n", resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) (int, int, []query) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines

	n, m, q := scanInt(sc), scanInt(sc), scanInt(sc)
	qs := make([]query, q)
	for i := 0; i < q; i++ {
		qs[i] = query{
			a: scanInt(sc),
			b: scanInt(sc),
			c: scanInt(sc),
			d: scanInt(sc),
		}
	}
	return n, m, qs
}

type query struct {
	a, b, c, d int
}

func resolve(n, m int, qs []query) int {
	result := 0
	for seq := range seqs(n, m) {
		sum := 0
		for _, q := range qs {
			if seq[q.b-1]-seq[q.a-1] == q.c {
				sum += q.d
			}
		}
		if result < sum {
			result = sum
		}
	}
	return result
}

func seqs(n, m int) chan []int {
	ch := make(chan []int)
	go func() {
		_seq(1, m, n, []int{}, ch)
		close(ch)
	}()
	return ch
}

func _seq(s, e int, n int, r []int, ch chan []int) {
	if n == 0 {
		dst := make([]int, len(r))
		copy(dst, r)
		ch <- dst
		return
	}
	for i := s; i <= e; i++ {
		_seq(i, e, n-1, append(r, i), ch)
	}
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 6288
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
using Int = long long;
const auto MOD = 1000000007LL;
int main() {
    Int n;
    cin >> n;
    auto a = vector<Int>(3, 0);
    Int ans = 1;
    rep(i, n) {
        Int x;
        cin >> x;
        if (x == 0) {
            if (a[0] == 0) {
                a[0] = 1;
                ans *= 3;
                ans %= MOD;
            } else if (a[1] == 0) {
                a[1] = 1;
                ans *= 2;
                ans %= MOD;
            } else if (a[2] == 0) {
                a[2] = 1;
            } else {
            	puts("0");
            	return 0;
            }
        } else {
            if (x == a[0] && x == a[1] && x == a[2]) {
                ans *= 3;
                ans %= MOD;
                a[0]++;
            } else if (x == a[0] && x == a[1]) {
                ans *= 2;
                ans %= MOD;
                a[0]++;
            } else if (x == a[1] && x == a[2]) {
                ans *= 2;
                ans %= MOD;
                a[1]++;
            } else if (x == a[2] && x == a[0]) {
                ans *= 2;
                ans %= MOD;
                a[2]++;
            } else if (x == a[0]) {
                a[0]++;
            } else if (x == a[1]) {
                a[1]++;
            } else if (x == a[2]) {
                a[2]++;
            } else {
            	puts("0");
            	return 0;
            }
        }
    }

    cout << (ans%MOD) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int Maxn = 100010;
struct node {
	int y, next;
}a[Maxn*2]; int first[Maxn], len;
void ins(int x, int y) {
	len++;
	a[len].y = y;
	a[len].next = first[x]; first[x] = len;
}
int n, m, bsum[Maxn], bs[Maxn], size[Maxn], ans;
int dfn[Maxn], id, co[Maxn], fzx, fzy;
int p[Maxn], pl;
bool state;
int _abs(int x) { return x < 0 ? -x : x; }
void dfs(int x, int fk) {
	dfn[x] = ++id; bsum[x] = co[x] == 1 ? 1 : 0; size[x] = 1;
	for(int k = first[x]; k; k = a[k].next){
		int y = a[k].y;
		if((k+1)/2 == (fk+1)/2) continue;
		if(dfn[y] == 0){
			co[y] = co[x]^1;
			dfs(y, k);
			if(state == false && dfn[y] <= dfn[fzx] && dfn[fzx] <= dfn[y]+size[y]-1 && (dfn[y] > dfn[fzy] || dfn[fzy] > dfn[y]+size[y]-1)) p[++pl] = 2*bsum[y]-size[y];
			else ans += _abs(size[y]-2*bsum[y]);
			bsum[x] += bsum[y];
			size[x] += size[y];
		} else {
			fzx = x; fzy = y;
			if(co[y] != co[x]) state = false;
		}
	}
}
void dfs2(int x, int fk) {
	dfn[x] = ++id; bsum[x] = co[x] == 1 ? 1 : 0; size[x] = 1;
	bs[x] = bsum[x];
	if(x == fzx || x == fzy) bs[x] += (n-2*bsum[0])/2;
	for(int k = first[x]; k; k = a[k].next){
		int y = a[k].y;
		if((k+1)/2 == (fk+1)/2) continue;
		if(dfn[y] == 0){
			co[y] = co[x]^1;
			dfs2(y, k);
			ans += _abs(size[y]-bsum[y]-bs[y]);
			bsum[x] += bsum[y];
			bs[x] += bs[y];
			size[x] += size[y];
		}
	}
}
void case1() {
	ans = 0;
	memset(dfn, 0, sizeof(dfn)); id = 0;
	state = true; dfs(1, 0);
	if(bsum[1]*2 != n){ printf("-1\n"); return; }
	printf("%d\n", ans);
}
void case2() {
	if(bsum[1]%2 != (n-bsum[1])%2){ printf("-1\n"); return; }
	bsum[0] = bsum[1]; ans = 0;
	memset(dfn, 0, sizeof(dfn)); id = 0;
	dfs2(1, 0);
	printf("%d\n", ans+_abs(n-2*bsum[0])/2);
}
void case3() {
	if(bsum[1]*2 != n){ printf("-1\n"); return; }
	sort(p+1, p+pl+1);
	int o;
	for(int i = 1; i <= pl; i++) p[i] <<= 1;
	if(pl%2 == 0) o = (p[pl>>1]+p[(pl>>1)+1])>>1;
	else o = p[(pl+1)>>1];
	for(int i = 1; i <= pl; i++) ans += _abs(p[i]-o)>>1;
	ans += _abs(o)>>1;
	printf("%d\n", ans);
}
int main() {
	int i, j, k, T;
	T=1;
	while(T--){
		scanf("%d%d", &n, &m);
		len = 0; memset(first, 0, sizeof(first));
		for(i = 1; i <= m; i++){
			int x, y;
			scanf("%d%d", &x, &y);
			ins(x, y); ins(y, x);
		}
		if(n == m+1) case1();
		else {
			memset(dfn, 0, sizeof(dfn)); id = 0;
			state = true; pl = 0; ans = 0; dfs(1, 0);
			if(state == 1) case2();
			else case3();
		}
	}
	return 0;
}


Measured memory_bytes: 8704
inputs = input().split(' ')
inputs2 = input().split(' ')
inp1=[int(a) for a in inputs]
inp2=[int(a) for a in inputs2]

# inp1 = [12,3]
# inp2 = [4,56,78,901,2,345,67,890,123,45,6,789]


sums = sum(inp2)
rest = 1/(4*inp1[1])

inp2.sort()
inp2.reverse()

result = []

for i in range(inp1[1]):

	if inp2[i] > sums*rest or inp2[i] == sums*rest:
		result.append(int(inp2[i]))



if len(result)>inp1[1] - 1:
	print("Yes")
else:
	print("No")






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

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

  int ans = 0;
  int remainder = 0;
  for (int i = 0; i < K; i++) {
    ans++;
    // 第1項 "7" と第2項 "77" の関係は a[2] = a[1] * 10 + 7 となる
    // 余りも同様であり、 第2項の余りは、第1項の余りに10を掛けたものに+7したものとなる
    //
    // 剰余はK未満となるため、「第1項の余りに10を掛けたものに+7したもの」の値がK以上の場合を想定して、
    // mod(K) を求める
    remainder = (remainder * 10 + 7) % K;
    // Kの倍数の場合、余りが0となるので、ここで試行を終了する
    if (remainder == 0) { break; }
    // K回試行して、Kの倍数が登場しなかった場合は、存在しないと判断して-1とする
    //
    // NOTE:
    // mod(K) の値は K-1 以下の値を取りうる
    //
    // K=9 の場合、余りは 7 -> 5 -> 3 -> 1 -> 8 -> 6 -> 4 -> 2 -> 0 と9種類のユニークな値を経由して 0 に到達する。
    // 毎回 0〜K-1 の値の中でユニークな値に遷移し、最後に0に到達するため、これが試行回数が最大となる。
    //
    // K=6 の場合、余りは 1 -> 5 -> 3 -> 1 -> 5 -> 3 とループし、0 に到達することがない。
    // 剰余の値として1回目と同じ値が4回目に登場する。
    // 剰余の値は以下の式を元に算出しているため、4回目以降も1〜3回目と同じインプットで、
    // 同じアウトプットが算出されるため、同じ数の遷移を辿ることになる。
    //
    //   r[n+1] = (r[n] * 10 + 7) % K
    //
    if (i == K-1) { ans = -1; }
  }

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


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        long[] ans = new long[87];
        ans[0] = 2;
        ans[1] = 1;
        for (int i = 2; i <= 86; i++)
        {
            ans[i] = ans[i - 1] + ans[i - 2];
        }
        Console.WriteLine(ans[n]);
    }
}

Measured memory_bytes: 13140
import java.math.BigInteger;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        System.out.println(bouquet(n, a, b));
    }

    public static int bouquet(int n, int a, int b) {
        int m = 1_000_000_007;
        BigInteger bigM = BigInteger.valueOf(m);
        BigInteger m2 = BigInteger.valueOf(1_000_000_005);
        BigInteger res = BigInteger.valueOf(2).modPow(BigInteger.valueOf(n), bigM);
        HashSet<Integer> neededFactorials = new HashSet<>();
        HashMap<Integer, BigInteger> calculatedFactorials = new HashMap<>();
        HashSet<Integer> neededTops = new HashSet<>();
        HashMap<Integer, BigInteger> calculatedTops = new HashMap<>();
        neededFactorials.add(a);
        neededFactorials.add(b);
        neededTops.add(n - a + 1);
        neededTops.add(n - b + 1);
        calculatedFactorials.put(0, BigInteger.ONE.modInverse(bigM));
        long tmp = 1;
        for (int i = 1; i <= Math.max(a, b); i++) {
            tmp = tmp * i % m;
            if (neededFactorials.contains(i)) {
                calculatedFactorials.put(i, BigInteger.valueOf(tmp).modInverse(bigM));
            }
        }
        tmp = 1;
        for (int i = n; i > n - Math.max(a, b); i--) {
            tmp = tmp * i % m;
            if (neededTops.contains(i)) {
                calculatedTops.put(i, BigInteger.valueOf(tmp));
            }
        }
        return res.subtract(
                calculatedTops.get(n - a + 1).multiply(calculatedFactorials.get(a))
        ).subtract(
                calculatedTops.get(n - b + 1).multiply(calculatedFactorials.get(b))
        ).subtract(BigInteger.ONE).mod(bigM).intValue();
    }
}


Measured memory_bytes: 30164
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
    int N, K; cin >> N >> K;
    vector<int> A, B;

    for(int i = 0; i < N; i++){
        int x; cin >> x;
        if(x == 0)K--;
        else if(x > 0) A.push_back(x);
        else if(x < 0) B.push_back(x*(-1));
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    ll ans = 1e18;
    /*
    if(A.size() >= K && B.size() >= K){
        ans = min(A[K-1], B[K-1]);
        cout << ans << endl;
        return 0;
    }*/
    
    int ptrr = K-1;
    if(A.size() < K) ptrr = A.size()-1;
    int ptrl = K-(ptrr+1)-1;
    int r, l;
    ll tmp;
    if(ptrr == -1 && ptrl == -1){
        cout << 0 << endl;
        return 0;
    }

    while(ptrr >= -1){
            
        if(ptrl == B.size()) break;
        //cout << "ddddd" << endl;
        if(ptrl == -1){
            r = A[ptrr];
            l = A[0];
            tmp = r;
            ans = min(ans, tmp);
        }
        else if(ptrr == -1){
            r = B[0];
            l = B[ptrl];
            tmp = l;
            ans = min(ans, tmp);
        }
        else{
            r = A[ptrr];
            l = B[ptrl];
            tmp = r + l + min(r, l);
            ans = min(ans, tmp);
        }
        ptrr--;
        ptrl++;
        //cout << l << " " << r << " " << tmp << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 100010
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

int main()
{
    RUN_FAST; cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int l;
    double tmp;
    cin >> l;

    tmp=(double)l/3.00;
    tmp=tmp*tmp*tmp;
    cout << tmp << endl;
    return 0;
}


Measured memory_bytes: 3776
#include<iostream>
#include<algorithm>
#include <cstring>
using namespace std;
long long n,a,b;
long long  c[51000000];
bool pd(int mid)
{
    long long shanghai=b*mid;
    long long sum=0;
    for (long long i=0;i<n;i++)
    {
        if (c[i]>shanghai)
        {  if (c[i]%(a-b)!=0)
            sum=sum+ (c[i]-shanghai)/(a-b)+1;
        else sum=sum+(c[i]-shanghai)/(a-b);
        }
    }
    if (sum<=mid) return false;
    else return true;
}
int main()
{
    cin>>n>>a>>b;
    for (long long i=0;i<n;i++)
        cin>>c[i];
        long long f=1e9;
    long long start=0,endd=1e9;
    while (start<=endd)
    {
        long long mid=(start+endd)>>1;
        if (!pd(mid))
        {
            endd=mid-1;
            f=min(f,mid);
        }
        else start=mid+1;
    }
    cout<<f<<endl;
    return 0;
}


Measured memory_bytes: 1024
import itertools
n = int(input())
data = {}
for x in range(n):
    data[x] = []
    for y in range(int(input())):
        k, l = map(int, input().split())
        data[x].append((k - 1, l))

ans = 0
for i in itertools.product([1,0], repeat=n):
    h = True
    for x in range(n):
        if i[x] == 1:
            for g in data[x]:
                if i[g[0]] != g[1]:
                    h = False
        if h == False:
            break
    if h == True:
        ans = max(ans, sum(list(i)))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <functional> 
#include <vector>
#include <cstring>

using namespace std;

int main(){

    int cnt=100,n;
    cin >> n;

    for(int i=0;i<n;i++){
        int a,b=0;
        cin >> a;
        while(a%2 == 0){
            ++b;
            a = a/2;
        }
        cnt = min(cnt,b);
    }
    cout << cnt;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var s = Console.ReadLine().ToArray();
            var ans = new List<string>();
            var memo = "";
            ans.Add(s[0].ToString());
            for (int i = 1; i < s.Length; i++)
            {
                if (memo == "")
                {
                    if (ans[ans.Count-1] != s[i].ToString()) ans.Add(s[i].ToString());
                    else memo += s[i].ToString();
                }
                else
                {
                    if (ans[ans.Count - 1] != memo + s[i])
                    {
                        ans.Add(memo + s[i]);
                        memo = "";
                    }
                    else memo += s[i];
                }
            
            }
            Console.WriteLine(ans.Count);


            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 27860
# -*- coding: utf-8 -*-
# Luis Yoichi Morales January 2019

#from sys import stdin

#N= int(raw_input())
#h=[]
#h.extend( map(int, stdin.readline().split())   )

N = input()
h = map(int, raw_input().split())



ans = h[0]
for i in range(1,N):
  ans += max(0, h[i]-h[i-1])
  #print i, max(0,h[i]-h[i-1]), h[i], h[i-1]
#print N, h
print ans

Measured memory_bytes: 2568
#include<iostream>
int main(){
  int k,s;
  int x,y;
  int counter=0;
  std::cin >> k >> s;
  for(x=0;x<=k;x++){
    for(y=0;y<=k;y++){
      if(s-x-y>=0 && s-x-y<=k){
        //std::cout << "x y = " << x << " " << y << "\n";
        counter++;
      }
    }
  }
  std::cout << counter << "\n";
  return 0;
}


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

const int d = 10;

bool less_mod(int lhs, int rhs) {
  if ((lhs - rhs) % d != 0) {
    return lhs % d < rhs % d;
  }
  else {
    return lhs < rhs;
  }
}

int main() {
  int n, div10, score;
  div10 = 0;
  score = 0;
  cin >> n;
  vector<int> vec(n);
  for (int i=0; i<n; i++) {
    cin >> vec[i];
    score += vec[i];
    if (vec[i] % d == 0){
      div10++;
    }
  }
  // cout << "total: " << score << endl;
  sort(vec.begin(), vec.end(), less_mod);
  if(score % d != 0){
    cout << score << endl;
  }
  else if(div10 == n){
    score = 0;
    cout << score << endl;
  }
  else {
    score -= vec[div10];
    cout << score << endl;
  }
  return 0;
}

Measured memory_bytes: 256
using System;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int x = int.Parse(str[0]), y = int.Parse(str[1]);
            Console.Write(x * y + " ");
            Console.WriteLine(x * 2 + y * 2);
        }
    }
}

Measured memory_bytes: 9088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace _8_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string a1 = Console.ReadLine();
            string s = Console.ReadLine();bool flag = false;
            for(int i=0;i<a1.Length; i++)
            {
                string a =(a1.Substring(i)+a1.Substring(0,i)).Substring(0,s.Length);
                if (a == s) { flag=true; }
            }Console.WriteLine(flag?"Yes":"No");
        }
    }
}

Measured memory_bytes: 8908
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void E();

int main()
{
	E();
	fflush(stdout);
	return 0;
}

template <class _T> void tp_getPrimes(_T targ, std::map<_T, _T>& primes)
{
	_T target = targ;
	_T i = 2;
	while ((i * i) <= target) {
		if ((target % i) == 0) {
			target /= i;
			primes[i]++;
		}
		else {
			i++;
		}
	}
	if (target > 1) {
		primes[target]++;
	}
}

static void E()
{
	int N;
	get(N);

	int maxNum = 0;
	std::vector<int> ai(N);
	for (int i = 0; i < N; i++) {
		get(ai[i]);
		maxNum = std::max(maxNum, ai[i]);
	}

	std::vector<std::map<int, int>> primes(N);
	for (int i = 0; i < N; i++) {
		tp_getPrimes(ai[i], primes[i]);
	}
	
	bool pairwise = true;
	std::vector<int> primeCounts(maxNum + 1, 0);
	for (int i = 0; i < N; i++) {
		for (auto it = primes[i].begin(); it != primes[i].end(); it++) {
			primeCounts[it->first]++;
		}
	}

	for (int i = 1; i <= maxNum; i++) {
		if (primeCounts[i] == N) {
			printf("not coprime\n");
			return;
		}
		else if (primeCounts[i] > 1) {
			pairwise = false;
		}
	}

	const char* ans = "pairwise coprime\n";
	if (!pairwise) ans = "setwise coprime\n";
	printf(ans);
}


Measured memory_bytes: 294136
#include "bits/stdc++.h"

using namespace std;

#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll inf = 0x3f3f3f3f;
const ll mod = 1e9+7;

const ll N = 1e5+5;
ll n,a[N],pre[N],bit[2*N];

void update(ll x){
    x += (n+1);
    for(;x<=2*n+2;x+=x&-x) bit[x]++;
}

ll query(ll x){
    ll ret=0;
    x += (n+1);
    for(;x;x-=x&-x) ret += bit[x];
    return ret;
}

bool check(ll x){
    for(ll i=1;i<=n;i++){
        pre[i]=pre[i-1]+((a[i]<=x)?1:-1);
    }
    memset(bit,0,sizeof bit);
    update(0);
    ll total=0;
    for(ll i=1;i<=n;i++){
        total += query(pre[i]-1);
        update(pre[i]);
    }
    ll all = (n*(n+1))/2;
    all = all/2+1;
    return (total>=all);
}

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

  

    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    int l=1,r=1e9,ans=0;
    while(l<=r){
        int mid=(l+r)/2;
        if(check(mid)){
            ans=mid;
            r=mid-1;
        } else {
            l=mid+1;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3328
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

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

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

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

    ll n;
    cin >> n;

    if(n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    vll pots;
    ll p = 5;
    while(p <= 100000000000000000) {
        pots.PB(p*10LL);
        p *= 5LL;
    }

    ll ans = n/10;
    for(ll pot : pots) {
        ans += n/pot;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 * 
 * https://atcoder.jp/contests/abc098/submissions/14897650 にも参考
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long[] a = new long[n];
			IntStream.range(0, n).forEach(i -> a[i] = scanner.nextLong());
			long answer = 0L, sum = 0L;
			int right = 0;
			for (int left = 0; left < n; left++) {
				while ((right < n) && (sum + a[right] == (sum ^ a[right]))) {
					sum += a[right];
					right++;
				}
				answer += right - left;
				sum -= a[left];
			}
			System.out.println(answer);
		}
	}
}


Measured memory_bytes: 63800
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int [] t = new int [n];
		int sumTime = 0;
		for (int i = 0 ; i < n ; i++) {
			t [i] = scanner.nextInt();
			sumTime += t[i];
		}
		int m = scanner.nextInt();
		for (int i = 0 ; i < m ; i++) {
			int p = scanner.nextInt() - 1;
			int sum = sumTime - t[p] + scanner.nextInt();
			System.out.println(sum);
		}
	}
} 

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

int main()
{
	double N, K;
	double m = 0, e = 0;
	cin >> N >> K;
	vector<double> p(N);
	for (int i = 0; i < N; i++) {
    double a;
		cin >> a;
    p[i] = (a+1)/2;
	}
	for (int s = 0; s < N; s++) {	//s -> start index
		if (s < K) {
			e += p[s];
		}else {
			e = e - p[s - K] + p[s];
		}
    if (m < e) {
			  m = e ;
		  }
	}
    cout << fixed << setprecision(10);
	cout << m << endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

const int N = 100005;
vector <int> vec[N];
int dp[N];

bool comp(int x, int y) {
    return dp[x] > dp[y];
}

void dfs(int x) {
    for (int i = 0; i < vec[x].size(); i++) {
        dfs(vec[x][i]);
    }

    sort(vec[x].begin(), vec[x].end(), comp);

    int tmp = 1;
    for (int i = 0; i < vec[x].size(); i++) {
        dp[x] = max(dp[x], dp[vec[x][i]] + tmp);
        tmp++;
    }
}

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

    int n;
    cin >> n;

    for (int i = 2; i <= n; i++) {
        int a;
        cin >> a;
        vec[a].push_back(i);
    }

    dfs(1);

    cout << dp[1] << "\n";
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define zeroend __builtin_ctz
#define ones __builtin_popcount
#define ends "\n"
#define space ' '
typedef long long ll;
typedef pair<int, int> pii;

/*
void solve(int i, int j, string s){
	if(i==0)
		ans.insert(s2.substr(0, j)+s);
	else if(j==0)
		ans.insert(s1.substr(0, i)+s);
	else if(s1[i-1]==s2[j-1])
		solve(i-1, j-1, s1[i-1]+s);
	else{
		if(dp[i-1][j]<=dp[i][j-1])
			solve(i-1, j, s1[i-1]+s);
		if(dp[i-1][j]>=dp[i][j-1])
			solve(i, j-1, s2[j-1]+s);
	}
}*/


/*
	cin >> n;
	for(int i=0; i<n; ++i)
		cin >> a[i];

	for(int i=1; i<n; ++i){
		for(int j=0; j<i; ++j){
			if(a[j]>a[i]&&low[i]<high[j]+1)
				low[i]=high[j]+1;
			else if(a[j]<a[i]&&high[i]<low[j]+1)
				high[i]=low[j]+1;
		}
		ans=max({ans, low[i], high[i]});
	}

	cout << ans << ends;


*/

const int N = 100, N2=1e5, M = 1e9+7;

int dp[N2+1];
//array<ll, 3> dp;
//set<string> ans;
//vector<int> low(N, 1), high(N, 1);
ll a[N];

ll n, x;

int main(){
	cin >> n >> x;
	for(int i=0; i<n; ++i)
		cin >> a[i];

	dp[0]=1;
	for(int i=1; i<=n; ++i){
		vector<int> pref_sum(x+1, 0);
		pref_sum[0]=1;
		for(int f=1; f<=x; ++f)
			pref_sum[f]=(pref_sum[f-1]+dp[f])%M;
		for(int j=1; j<=x; ++j){
			if(a[i-1]>=j)
				dp[j]=pref_sum[j];
			else
				dp[j]=(((pref_sum[j]-pref_sum[j-a[i-1]-1])%M)+M)%M;
		}
		// for(int g=1; g<=x; ++g)
		// 	cout << dp[g] << space;
		// cout << ends;
	}


	cout << dp[x] << ends;
}




Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;


int main() {
    ll N, Q;    string S;
    cin >> N >> Q >> S;

    vl SUM(N);
    SUM[0] = 0;
    rep(i, N-1) SUM[i+1] = SUM[i] + ('A'==S[i] and 'C'==S[i+1]);
    
    ll l, r;
    rep(i, Q) {
        cin >> l >> r;
        cout << SUM[--r] - SUM[--l] << endl;
    }
}

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

typedef long long ll;

ll a, b, c;

signed main() {
	scanf("%lld%lld%lld", &a, &b, &c);
  	if(b >= c - 2) printf("%lld\n", a + 1);
      else if(1 + a <= b) {
        printf("%lld\n", 1 + a);
        return 0;
      } else {
        ll res = a - (b - 1);
        printf("%lld\n", res / 2 * (c - b) + b + res % 2);
        return 0;
	  }
  return 0;
}

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

vector<int>E[100];
bool flag[100];
int Max;

void solve(int v, int len) {
	if (len > Max)Max = len;
	for (int u : E[v]) {
		if (!flag[u]) {
			flag[u] = true;
			solve(u, len + 1);
			flag[u] = false;
		}
	}
}
int main() {
	int n;
	while (scanf("%d", &n), n) {
		rep(i, 100)E[i].clear();
		memset(flag, 0, sizeof(flag));
		rep(i, n) {
			int a, b; scanf("%d%d", &a, &b); a--; b--;
			E[a].push_back(b); E[b].push_back(a);
		}
		Max = 0;
		rep(i, 100) {
			flag[i] = true;
			solve(i, 1);
			flag[i] = false;
		}
		printf("%d\n", Max);
	}
}

Measured memory_bytes: 3264
/*-------property of the half blood prince-----*/

#include <bits/stdc++.h>
#include <dirent.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define MIN(X,Y) X<Y?X:Y
#define MAX(X,Y) X>Y?X:Y
#define ISNUM(a) ('0'<=(a) && (a)<='9')
#define ISCAP(a) ('A'<=(a) && (a)<='Z')
#define ISSML(a) ('a'<=(a) && (a)<='z')
#define ISALP(a) (ISCAP(a) || ISSML(a))
#define MXX 10000000000
#define MNN -MXX
#define ISVALID(X,Y,N,M) ((X)>=1 && (X)<=(N) && (Y)>=1 && (Y)<=(M))
#define LLI long long int
#define VI vector<int>
#define VLLI vector<long long int>
#define MII map<int,int>
#define SI set<int>
#define PB push_back
#define MSI map<string,int>
#define PII pair<int,int>
#define PLLI pair<LLI,LLI>
#define PDD pair<double,double>
#define FREP(i,I,N) for(int (i)=(int)(I);(i)<=(int)(N);(i)++)
#define eps 0.0000000001
#define RFREP(i,N,I) for(int (i)=(int)(N);(i)>=(int)(I);(i)--)
#define SORTV(VEC) sort(VEC.begin(),VEC.end())
#define SORTVCMP(VEC,cmp) sort(VEC.begin(),VEC.end(),cmp)
#define REVV(VEC) reverse(VEC.begin(),VEC.end())
#define INRANGED(val,l,r) (((l)<(val) || fabs((val)-(l))<eps) && ((val)<(r) || fabs((val)-(r))<eps))
#define INRANGEI(val,l,r) ((val)>=(l) && (val)<=(r))
#define MSET(a,b) memset(a,b,sizeof(a))
using namespace std;
using namespace __gnu_pbds;

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction


//typedef tree < int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

string s;

int main(){
    cin>>s;
    FREP(i,0,7){
        int cur = s[0]-'0';
        int msk = 1;
        vector<char>signs;
        FREP(k,1,3){
            if(msk&i){
                //sign is +
                cur+=(s[k]-'0');
                signs.PB('+');
            }
            else{
                cur-=(s[k]-'0');
                signs.PB('-');
            }
            msk<<=1;
        }
        if(cur==7){
            FREP(k,0,signs.size()-1){
                cout<<s[k]<<signs[k];
            }
            cout<<s[3]<<"=7\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
     
using namespace std;
typedef long long ll;
const int maxlen=10010;
char S[maxlen];
int n;
 
int main() {
    int i,j; 
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    cin >> S;
    for(i=0;i<strlen(S);i++){
        S[i] = S[i] + n; 
        if (S[i] > 'Z'){
            S[i] = S[i] - 'Z' + 'A' - 1; 
        }
    }
    cout << S << endl;
}

Measured memory_bytes: 256