akhauriyash/Code-Regression huggingface dataset:
use proconio::{fastout, input, marker::Usize1};
use std::{
    cmp::{self, Reverse},
    collections::BinaryHeap,
};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        s: usize,
        uvabs: [(Usize1, Usize1, usize, u64); m],
        cds: [(usize, u64); n],
    }

    let graph = {
        let mut graph = vec![vec![]; n];
        for (u, v, a, b) in uvabs {
            graph[u].push((v, a, b));
            graph[v].push((u, a, b));
        }
        graph
    };

    let mut dp = vec![vec![u64::max_value(); 2451]; n];
    dp[0][cmp::min(s, 2450)] = 0;

    let mut queue = BinaryHeap::from(vec![(Reverse(0), 0, cmp::min(s, 2450))]);
    while let Some((_, cur_node, cur_coins)) = queue.pop() {
        macro_rules! cur_time(() => (dp[cur_node][cur_coins]));

        let (c, d) = cds[cur_node];
        macro_rules! next_coins(() => (cmp::min(cur_coins + c, 2450)));
        macro_rules! next_time(() => (dp[cur_node][next_coins!()]));
        if cur_time!() + d < next_time!() {
            next_time!() = cur_time!() + d;
            queue.push((Reverse(next_time!()), cur_node, next_coins!()))
        }

        for &(next_node, a, b) in &graph[cur_node] {
            macro_rules! next_coins(() => (cur_coins - a));
            macro_rules! next_time(() => (dp[next_node][next_coins!()]));
            if cur_coins >= a && cur_time!() + b < next_time!() {
                next_time!() = cur_time!() + b;
                queue.push((Reverse(next_time!()), next_node, next_coins!()));
            }
        }
    }

    for dp in &dp[1..] {
        println!("{}", dp.iter().min().unwrap());
    }
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
ll P = 1000000007;

ll dp[101010] = {0};

class C {
public:
  int n;
  vector<long long> fac, inv, facInv;

  long long power(long long e, long long x) {
    if (x == 0)
      return 1;
    if (x == 1)
      return e;
    if (x % 2 == 0)
      return power((e * e) % P, x / 2);
    return (e * power(e, x - 1)) % P;
  }

  C(int n_) {
    n = n_;
    fac.resize(n + 1);
    inv.resize(n + 1);
    facInv.resize(n + 1);
    fac[0] = fac[1] = 1;
    for (int i = 2; i <= n; i++)
      fac[i] = (i * fac[i - 1]) % P;
    inv[0] = inv[1] = 1;
    for (int i = 2; i <= n; i++)
      inv[i] = power(i, P - 2);
    facInv[0] = facInv[1] = 1;
    for (int i = 2; i <= n; i++)
      facInv[i] = (inv[i] * facInv[i - 1]) % P;
  }

  long long comb(int N, int K) {
    if (N < K || K < 0 || N < 0)
      return 0;
    if (N == 0 || K == 0 || K == N)
      return 1;
    return ((fac[N] * facInv[K]) % P * facInv[N - K]) % P;
  }

  long long hcomb(int N, int K) {
    if (N == 0 && K == 0)
      return 1;
    return comb(N + K - 1, K);
  }

  long long mul(long long a, long long b) { return (a * b) % P; }

  long long add(long long a, long long b) { return (a + b) % P; }

  // find c
  // where a^c = b (mod P)
  long long dlp(long long a, long long b) {
    long long m = ceil(sqrt(P));
    map<long long, long long> mp;
    for (int i = 0; i < m; i++)
      mp[power(a, i)] = i;
    long long ainvm = power(power(a, m), P - 2);
    cout << m << endl;
    for (int i = 0; i < m; i++) {
      if (mp.find(b) != mp.end()) {
        return i * m + mp[b];
      }
      b = mul(b, ainvm);
    }
    return -1;
  }
};

C cmp(101010);

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();

  ll ans = cmp.power(3, n - 1) % P;

  int c = 1;
  for (int i = 1; i < n; i++) if (s[i] == '1') c++;
  ans += cmp.power(2, c);
  ans %= P;

  c = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] == '1') {
      ans += (cmp.power(2, c) * cmp.power(3, n - 1 - i)) % P;
      ans %= P;
      c++;
    } else {

    }
  }

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


Measured memory_bytes: 2944
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[][] x = new int[N][3];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 3; j++) {
                x[i][j] = sc.nextInt();
            }
        }
        int[][] dp = new int[N][3];
        dp[0][0] = x[0][0];
        dp[0][1] = x[0][1];
        dp[0][2] = x[0][2];
        for(int i = 0; i < N - 1; i++) {
            for(int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (k==j) continue;
                    dp[i+1][k] = Math.max(dp[i+1][k], dp[i][j] + x[i+1][k]);
                }
            }
        }
        int ans = 0;
        for(int k = 0; k < 3; k++) {
            ans = Math.max(ans, dp[N-1][k]);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 98732
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    string s, t;
    cin >> s >> t;

    int r = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i]) r++;
    }

    cout << r << endl;

    return 0;
}

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

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


    string P;
    for (int j = 0; j < N ; ++j) {
        int p;
        cin >> p;
        P += to_string(p);
    }
    string Q;
    for (int j = 0; j < N ; ++j) {
        int q;
        cin >> q;
        Q += to_string(q);
    }

    vector<int> order;
    for (int i = 0; i < N ; ++i)  order.push_back(i+1);

    int dp = -1;
    int dq = -1;
    int index = 1;
    do {
        string t;
        for (auto o: order) {
            t += to_string(o);
        }

        if (P == t) {
            dp = index;
        }
        if (Q == t) {
            dq = index;
        }

        if (dp != -1 && dq != -1) {
            break;
        }
        index++;
    } while (next_permutation(order.begin(), order.end()));

    cout << abs(dp - dq) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <functional>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int A[SIZE];

int main()
{
	int n,L;
	scanf("%d %d",&n,&L);
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	for(int i=0;i+1<n;i++)
	{
		if(A[i]+A[i+1]>=L)
		{
			puts("Possible");
			int l=0,r=n-1;
			for(int j=0;j<n-1;j++)
			{
				if(l<i)
				{
					printf("%d\n",l+1);
					l++;
				}
				else
				{
					printf("%d\n",r);
					r--;
				}
			}
			return 0;
		}
	}
	puts("Impossible");
	return 0;
}


Measured memory_bytes: 1152
n=int(input())
s=[0]*n
info=[0]*n
for i in range(n):
    ss=list(input())
    now=0
    mi=0
    for sss in ss:
        if sss=="(":
            now+=1
        else:
            now-=1
            mi=min(mi,now)
    info[i]=(mi,now)
#info.sort(key=lambda x:(x[1]>=0)*2+(x[0]>=0),reverse=True )

info0 = []
info1 = []
for i,inf in enumerate(info):
    if inf[1]>=0:
        info0.append(inf)
    else:
        info1.append(inf)
info0.sort(key=lambda x:x[0],reverse=True)
info1.sort(key=lambda x:x[1]-x[0],reverse=True)


ans=True
now=0
for inf in info0:
    if now+inf[0]>=0:
        now+=inf[1]
    else:
        ans=False
for inf in info1:
    if now+inf[0]>=0:
        now+=inf[1]
    else:
        ans=False
if now!=0:
    ans=False
    
print(ans*"Yes"+(1-ans)*"No")

Measured memory_bytes: 180332
#include<bits/stdc++.h>
#define mx 5005
#define inf 100000000000005
using namespace std;

int t, i;
bitset<26> bt[26][10000], m;
string s, ans;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s;
  for(i = s.size()-1; i >= 0; i--){
    bt[s[i] - 'a'][t] = m;
    m.set((int)(s[i] - 'a'));
    if(m.all()){
      t++;
      m.reset();
    }
  }
  while(t+1){
    for(i = 0; m[i]; i++);
    ans.push_back((char)('a' + i));
    if(t--) m = bt[i][t];
  }
  cout << ans << '\n';
}


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

namespace id_0500cs
{
    class Player
    {
        private int _score = 0;
        public void AddScore(int val)
        {
            _score += val;
        }
        public int GetScore()
        {
            return _score;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var n = 0;
            while (true)
            {
                n = int.Parse(Console.ReadLine());
                if (n == 0) break;

                Player a = new Player();
                Player b = new Player();
                foreach(var i in Enumerable.Range(0, n))
                {
                    var vs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                    var AWin = vs[0] > vs[1];
                    var BWin = vs[0] < vs[1];
                    var Draw = vs[0] == vs[1];
                    var WiningPoints = vs[0] + vs[1];
                    var DrawPoints = vs[0];

                    if (AWin)
                    {
                        a.AddScore(WiningPoints);
                    }
                    if (BWin)
                    {
                        b.AddScore(WiningPoints);
                    }
                    if (Draw)
                    {
                        a.AddScore(DrawPoints);
                        b.AddScore(DrawPoints);
                    }
                }
                Console.WriteLine("{0} {1}", a.GetScore(), b.GetScore());
            }
        }
    }
}



Measured memory_bytes: 9672
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
const int maxn = 1<<21, mod = 1e9 + 7;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, x, c = 0, ans = 0;
	cin >> n >> x;
	for(int t, i = 0; i < n; i++) {
		cin >> t;
		if(c <= x) ans++;
		else break;
		c += t;
	}
	cout << ans + (c<=x);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n;
  cin >> n;

  map<ll, ll> mp;
  FOR(i, 1, 200) {
    FOR(j, 1, 200) {
      FOR(k, 1, 200) {
        mp[i * i + j * j + k * k + i * j + j * k + k * i]++;
      }
    }
  }
  rep(i, n) cout << mp[i + 1] << '\n';

  




  
  return 0;
}

Measured memory_bytes: 13992
"use strict";

function Main(input) {
    input=input.split("\n");
    var line=input.map(function(v){
                       return v.split(" ").map(Number); 
});
    var ans="";
    for(var i=0;line[i][0]+line[i][1];i++){
        line[i].sort(function(a,b){
            return a-b;
        });
        ans+=line[i].join(" ")+"\n";
    }
    console.log(ans.trim());
}
function debug(){
	var input = document.getElementById("input").value;
	Main(input);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 18788
import math
import itertools
import numpy as np

def main():
    n = int(input())
    xyls = []
    ans = 0

    for i in range(n):
        xyls.append(list(map(int, input().split())))

    pls = list(itertools.permutations(range(n)))

    nkai = math.factorial(n)
    ls = np.array([[0.0]*n]*n)

    for i in range(n):
        for j in range(n):
            tmp = 0
            tmp += (xyls[i][0] - xyls[j][0])*(xyls[i][0] - xyls[j][0])
            # print(tmp)
            tmp += (xyls[i][1] - xyls[j][1])*(xyls[i][1] - xyls[j][1])
            # print(tmp)
            tmp = tmp**0.5
            # print(tmp)
            ls[i][j] = tmp

    anssum = 0
    # print(ls)

    for i in pls:
        # print(i)
        for j in range(n-1):
            # print(ls[i[j]][i[j+1]])
            # print(i[j], i[j+1])
            # print(ls)
            # print(type(i[j]))
            anssum = anssum + ls[int(i[j])][int(i[j+1])]
            # print(anssum)

    ans = anssum / nkai
    # print(ls)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 16988
height, length, A, B = [int(s) for s in input().split()]
matrix = [[0 for t in range(length)] for s in range(height)]

for k,i in enumerate(matrix):
  if k + 1 <= B:
    for j in range(A):
      i[j] = 1
  else:
    for j in range(length - A):
      i[-(j + 1)] = 1
      
for i in matrix:
  p = ""
  for j in i:
    p += str(j)
  print(p)
  
    

Measured memory_bytes: 12788
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef pair<int,int> P;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int MOD = 1000000007;
const int INF = 2147483647;
const ll LLINF = 1LL<<60;

P f(int x){
    int a=x%10;
    int b=0;
    while(x){
        b=x;
        x/=10;
    }
    return P(a,b);
}

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

int n;
cin >> n;
map<P,int> m;
for(int i=1;i<=n;++i){
    m[f(i)]++;
}
ll ans=0;
for(int i=1;i<=n;++i){
    P p=f(i);
    P q(p.second,p.first);
    ans+=m[q];
}
fin(ans);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
n = gets.chomp.to_i
arr = gets.chomp.split(" ").map{|i|i = i.to_i}
m_sum = 0
sum = 0
mountain_rain = []
(arr.length/2).times do|ii|
  i = ii*2+1
  sum += arr[i]*2
end
arr.each do|elm|
  m_sum+=elm
end

mountain_rain << m_sum - sum

(n-1).times do|i|
  mountain_rain << 2*arr[i] - mountain_rain[i]
  #pp mountain_rain
  #printf("%d ", mountain_rain[i])
end
puts mountain_rain.join(" ")
#printf("%d\n",mountain_rain[mountain_rain.length-1])

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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

// Solution Function
void solution()
{
    // cout<<compte<<"\n";
    ll n;
    cin>>n;

    ll cnt =1;

    ll ans = 0;
    for(ll i = 1 ; i <= n ; i++)
    {
        bool c = false;
        for(ll j = 1;j<=n;j++)
        {
            if(i*j<n)
            {
                c = true;
                ans++;
            }
            else 
                break;
        }
        if(c==false)
            break;
    }
    cout << ans;
    
}
// Driver Function
int main()
{
    ll compte = 1;
   // test()
    //{
        solution();
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <stdlib.h>
long long N,W;
static long long  h[100001][3];
static long long  dp[101][100001];
long long Wg[1000],Val[1000];
long long  INF = INT_MAX;

int 
chmin(long long  *a, long long b) 
{
	 if (*a > b){
		 *a = b; //	printf("%ld\n",*a);
		 return 1; 
	 }
	 return 0;
}

int 
chmax(long long *a, long long b) 
{
	 if (*a < b){
		 *a = b; //	printf("%ld\n",*a);
		 return 1; 
	 }
	 return 0;
}

int 
main(){
	long long i,j,k;
	scanf("%lld%lld",&N,&W);
	for(i=0;i<N;i++)
	//for(j=0;j<3;j++)
	{
		scanf("%lld%lld",&Wg[i],&Val[i]);
	}
	//for(j=0;j<3;j++)
	//	dp[0][j]=0;
	
	#if 1
	for(i=0;i<N;++i){
		for(long long sum_w=0;sum_w<= W;++sum_w){
			if(sum_w-Wg[i]>=0)
        		chmax(&dp[i + 1][sum_w], dp[i][sum_w-Wg[i]] + Val[i]);
			
			chmax(&dp[i+1][sum_w],dp[i][sum_w]);
		}
    }
    #endif
	
	//int res = 0;
	//for(j=0;j<3;j++) chmax(&res,dp[N][j]);
	printf("%lld\n",dp[N][W]);
	

	
 return 0;
}

Measured memory_bytes: 78336
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		int sz = s.length();
		String t = "";
		if ( s.charAt(sz-1)=='s' ) {
			t = s.concat("es");
		} else {
			t = s.concat("s");
		}

		System.out.println(t);
	}
}

Measured memory_bytes: 35588
//author : Yogi79

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

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int n;
   cin>>n;
   double t;
   double ans = 0.00;
   while(n--)
   {
       cin>>t;
       t = 1.00/t;
       ans += t;
   }
   ans = 1.00/ans;
   cout<<ans;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
namespace IO
{
	char buf[1 << 20 | 1] , *f1 = buf , *f2 = buf , pbuf[1 << 24 | 1] , *f3 = pbuf , sta[100];
	#define gc() ((f1 == f2) && (f2 = (f1 = buf) + fread(buf,1,sizeof buf,stdin),f1 == f2) ? EOF : *f1 ++)
	#define gt() getchar()
	inline int read()
	{
		int x = 0 , f = 1; char ch = gt();
		while(ch < '0' || ch > '9')	{if(ch == '-')	f = -1; ch = gt();}
		while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = gt();}
		return x * f;
	}
	template <class T> inline void write(T x)
	{
		if(!x) return (void)(*f3 ++ = 48 , *f3 ++ = ' ');
		if(x < 0) *f3 ++ = '-' , x = ~x + 1;
		char *top = sta;
		while(x) *top ++ = x % 10 + 48 , x /= 10;
		while(top != sta) *f3 ++ = *-- top;
		*f3 ++ = ' ';
	}
	inline void put(std::string s)
	{
		int len = s.length();
		for(int i = 0;i < len;i ++) *f3 ++ = s[i];
		*f3 ++ = ' ';
	}
	inline void endline() { *f3 ++ = '\n';}
	#define flush() fwrite(pbuf,1,f3 - pbuf,stdout)
	template <class T> inline T abs(T a) { return a < 0 ? -a : a;}
	template <class T> inline T max(T a,T b) { return a > b ? a : b;}
	template <class T> inline T min(T a,T b) { return a < b ? a : b;}
	template <class T> inline void swap(T &a,T &b) { T t = a; a = b; b = t;}
}
using namespace IO;
const int N = 1e6 + 5 , mod = 998244353;
int n;
ll P[N] , E[N] , S[N];
inline int ksm(ll a,int b)
{
	ll res = 1;
	while(b)
	{
		if(b & 1) res = res * a % mod;
		a = a * a % mod; b >>= 1;
	}
	return res;
}
inline void fwt(ll *f,int x) { for(int len = 2 , k = 1;len <= n;len <<= 1 , k <<= 1) for(int i = 0;i < n;i += len) for(int j = 0;j < k;j ++) f[i + j] = (f[i + j] + f[i + j + k]) % mod , f[i + j + k] = (f[i + j] - f[i + j + k] - f[i + j + k] + mod + mod) % mod , f[i + j] = f[i + j] * x % mod , f[i + j + k] = f[i + j + k] * x % mod;}
int main()
{
	n = 1 << read(); int sum = 0;
	for(int i = 0;i < n;i ++) sum += (P[i] = read()); sum %= mod; sum = ksm(sum,mod - 2);
	for(int i = 0;i < n;i ++) P[i] = P[i] * sum % mod;
	P[0] = (P[0] - 1 + mod) % mod; S[0] = n - 1;
	for(int i = 1;i < n;i ++) S[i] = mod - 1;
	fwt(S,1); fwt(P,1);
	for(int i = 1;i < n;i ++) E[i] = S[i] * ksm(P[i],mod - 2) % mod;
	fwt(E,(mod + 1) / 2);
	int x = mod - E[0];
	for(int i = 0;i < n;i ++) printf("%lld\n",(E[i] + x) % mod);
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
  const int sqrtN = 512;
  const ll inf = (1LL<<31)-1;
  int n, q;
  cin >> n >> q;
  int bucket_sz = (n+sqrtN-1)/sqrtN;
  vector<ll> a(n, 0);
  vector<ll> bucketAdd(bucket_sz, 0);
  auto update = [&](int s, int t, int x) {
    for(int i = 0; i < bucket_sz; ++i) {
      int l = i*sqrtN, r = (i+1)*sqrtN;
      if(r <= s || t <= l) continue;
      if(s <= l && r <= t) bucketAdd[i] += x;
      else {
	for(int j = max(s, l); j < min(t, r); ++j) {
	  a[j] += x;
	}
      }
    }
  };
  auto get = [&](int k)->ll{
    return a[k]+bucketAdd[k/sqrtN];
  };
  while(q--) {
    int t;
    cin >> t;
    if(t == 0) {
      ll s, t, x;
      cin >> s >> t >> x;
      update(s-1, t, x);
    } else {
      int k;
      cin >> k;
      cout << get(k-1) << endl;
    }
  }

  return 0;
}



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

char s[300005];
int n, a[300005],b[300005];

int main() {
    cin >> n;
    scanf("%s", s + 1);
    for (int i = 1; i <= n; ++i)
        if (s[i] == '#')
            a[i] = a[i - 1] + 1;
        else a[i] = a[i - 1];
    for (int i = n; i >= 1; --i)
        if (s[i] == '.')
            b[i] = b[i + 1] + 1;
        else b[i] = b[i + 1];
    int ans = 0x3f3f3f3f;
    for (int i = 1; i <= n; ++i)
        ans = min(ans, a[i - 1] + b[i + 1]);
    cout << ans <<endl;
    return 0;
}


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


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define snd second
#define fst first
#define debug printf("--%d--\n",__LINE__)
#define ll long long int


int main(void){
	string s;
	cin >> s;
	
	int flg = 0;
	for(int i=0;i<s.size();i++){
		if (flg==0 && s[i]=='C') flg++;
		if (flg==1 && s[i]=='F') flg++;
	}
	if (flg>=2) cout << "Yes" << endl; else cout << "No" << endl;
	
	
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll MOD2=998244353;
const double PI=acos(-1);
const ll INF=1e18;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll a;
  string b;
  cin >> a >> b;
  ll k=b.size();
  ll c=0;
  ll A=100;
  rep(i,k){
    if(b[i]!='.'){
    c+=(b[i]-'0')*A;
    A/=10;
    }
  }
  cout << c*a/100 << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define bolt ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test int t; cin>>t; while(t--)
#define ll long long
#define vi vector<ll>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend() 
const int N = 2e5+5;
const ll MAX = 1e9 +7;


int main()
{
	bolt;
	int a[2];
	cin>>a[0]>>a[1];
	
	sort(a,a+2);
	
	if(a[0] == 1)
	{
		if(a[1]==2)
		cout<<3<<"\n";
		else
		cout<<2<<"\n";
	}
	else if(a[0] == 2)
	{
		if(a[1] == 3)
		cout<<1<<"\n";
	}
	return 0;
}
	


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

int main() {
    double A,B,H,M;
    double S,L;
    double angle;   //角度
    double ans = 0;

    cin >> A >> B >> H >> M;

    // 12時ちょうどを0°とする

    // 短い針の位置
    //1hで30° 1mで0.5°
    S = H * 30 + M * 0.5; 
    // 長い針の位置
    //1mで6°
    L = 6 * M;

    angle = (S-L) / 180 * 3.1415926535;

    //余弦定理 ans^2 = A^2 + B^2 - 2AB・cosΘ
        ans = pow(A,2) + pow(B,2) - 2 * A * B * cos(angle);
        ans = sqrt(ans);

    cout << fixed << setprecision(24) << ans << endl;


}


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Io.Read<int>();
            var Alist = Io.ReadList<int>();
            var Blist = Io.ReadList<int>();
            var Clist = Io.ReadList<int>();

            var output = Blist[Alist[0] - 1];
            var prevA = Alist[0];
            foreach (var i in Enumerable.Range(1, N - 1))
            {
                var A = Alist[i];
                output += Blist[A - 1];
                if (A == prevA + 1)
                {
                    output += Clist[prevA - 1];
                }

                prevA = A;
            }

            Io.Write(output.ToString());
        }
    }

    class Io
    {
        public static string Read()
        {
            return Console.ReadLine();
        }

        public static IEnumerable<string> ReadRepeat(int count)
        {
            return Enumerable.Range(0, count).Select(_ => Read());
        }

        public static T Read<T>()
        {
            return (T)Convert.ChangeType(Read(), typeof(T));
        }

        public static IEnumerable<T> ReadRepeat<T>(int count)
        {
            return Enumerable.Range(0, count).Select(_ => Read<T>());
        }

        public static string[] ReadList(char devide = ' ')
        {
            return Read().Split(devide);
        }

        public static T[] ReadList<T>(char devide = ' ')
        {
            return ReadList(devide)
                .Select(s => (T)Convert.ChangeType(s, typeof(T)))
                .ToArray();
        }

        public static IEnumerable<T[]> ReadListRepeat<T>(int count, char devide = ' ')
        {
            return Enumerable.Range(0, count).Select(_ => ReadList<T>(devide));
        }

        public static void Write(string value)
        {
            Console.WriteLine(value);
        }
    }
}


Measured memory_bytes: 13396
def main():
    n = int(input())
    line = list(map(int,input().split()))
    if n == 0:
        if line[0] != 1:
            return -1
        else:
            return 1
    if line[0] > 0:
        return -1
    front = [0 for i in range(n+1)]
    back = [0 for i in range(n+1)]
    front[0] = 1
    for i in range(n):
        if front[i] * 2 < line[i+1]:
            return -1
        front[i+1] = min(10**30,front[i]*2-line[i+1])
    back[n] = line[n]
    for i in range(n):
        p = n - i - 1
        back[p] = back[p+1] + line[p]
    ans = 0
    for i in range(n):
        ans += line[i]
        ans += min(front[i],back[i]-line[i])
    ans += line[n]
    return ans


print(main())


Measured memory_bytes: 22504
import java.util.Scanner;

class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.nextLine());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(scan.next());
        }

        boolean flag = true;
        int count = 0;
        while (true) {
            for (int i = 0; i < n; i++) {
                if (a[i] % 2 != 0) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                count++;
                for (int i = 0; i < n; i++) {
                    a[i] = a[i] / 2;
                }
            } else {
                break;
            }
        }
        System.out.println(count);

    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if(a==5){
		if(b==5){
			if(c==5){
				cout << "NO" << endl;
			}
			else{
				cout << "YES" << endl;
			}
		}
		else{
			if(c==5){
				cout << "YES" << endl;
			}
			else{
				cout << "NO" << endl;
			}
		}
	}
	else{
		if(b==5){
			if(c==5){
				cout << "YES" << endl;
			}
			else{
				cout << "NO" << endl;
			}
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
def ans(i, j, k):
    if i == 3:
        if j == 7:
            print(k + '=7')
            exit()
        return
    ans(i+1, j-int(n[i+1]), k+'-'+n[i+1]), 
    ans(i+1, j+int(n[i+1]), k+'+'+n[i+1])

n = input()

ans(0, int(n[0]), n[0])

Measured memory_bytes: 3060
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val K = sc.next().toInt()
        val X = Array(N) { sc.next().toInt() }
        var ans = 0
        X.forEach { x ->
            ans += arrayOf(x, K - x).min()!! * 2
        }
        pw.println(ans)
    }
}


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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

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

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

    long long mod = 1000000007;

    for (int i = 0; i < n; i++) {
        if (a[i] < 0) {
            a[i] = mod + a[i];
        }
    }

    vector<long long> inv(n + 1, 0), frac(n + 1, 0), frac_inv(n + 1, 0);
    inv[1] = 1;
    frac[0] = frac[1] = 1;
    frac_inv[0] = frac_inv[1] = 1;
    for (int i = 2; i <= n; i++) {
        inv[i] = mod - (inv[mod % i] * (mod / i)) % mod;
        frac[i] = (frac[i - 1] * i) % mod;
        frac_inv[i] = (frac_inv[i - 1] * inv[i]) % mod;
    }

    long long res = 0;
    for (int i = 0; i < n; i++) {
        if (i >= k - 1) {
            long long r = a[i];
            r *= ((((frac[i] * frac_inv[k - 1]) % mod) * frac_inv[i - (k - 1)]) % mod);
            r %= mod;
            res += r;
            res %= mod;
        }

        if (n - i - 1 >= k - 1) {
            long long r = mod - a[i];
            r *= ((((frac[n - i - 1] * frac_inv[(k - 1)]) % mod) * frac_inv[(n - i - 1) - (k - 1)]) % mod);
            r %= mod;
            res += r;
            res %= mod;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 3328
#include <iostream>


using namespace std;

int main()
{
	while(true)
	{
		int a, b;
		char op;
		cin >> a >> op >> b;
		switch(op)
		{
		case '+':
			cout << a + b << endl;
			break;

		case '-':
			cout << a - b << endl;
			break;

		case '*':
			cout << a * b << endl;
			break;

		case '/':
			cout << a / b << endl;
			break;

		case '?':
			return 0;
		}
	}
	return 0;
}


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

#define ll long long
#define pb push_back
#define fi first
#define se second
using namespace std;
const ll N = 5e5 +9;

ll a, b[N], c, n, mn=9999999, mx=-999999;
string s,t;
vector <int> v;
int main(){
    cin >> n;
    if(n < 1200){
        cout<<"ABC";
        return 0;
    }
    if(n < 2800){
        cout<<"ARC";
        return 0;
    }else{
        cout<<"AGC";
        return 0;
    }


}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, res = 0;
	cin >> n;
	vector<vector<int> > cnt(10, vector<int>(10));
	FOR (i, 1, n + 1) {
	  string s = to_string(i);
	  cnt[s[0] - '0'][s[s.size() - 1] - '0']++;
	}
	rep (i, 10) {
	  rep (j, 10) res += cnt[i][j] * cnt[j][i];
	}
	cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int h[n];
    REP(i,n){
        cin >> h[i];
    }
    int ans = 0, cnt = 0;
    REP(i,n - 1){
        if(h[i] >= h[i + 1]){
            cnt++;
            ans = max(ans, cnt);
        }else{
            cnt = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
minus = 0
sum = 0
zero = False
minimum = abs(a[0])
for i in a:
    if i == 0:
        zero = True
    if i < 0:
        minus += 1
    minimum = min(minimum, abs(i))
    sum += abs(i)
if zero:
    print(sum)
elif minus % 2 == 0:
    print(sum)
else:
    print(sum - 2 * minimum)

Measured memory_bytes: 20132
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b){ if (a<b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if (b<a){ a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  int N;
  cin >> N;

  int ans = 180 * (N-2);
  cout << ans << endl;
}

Measured memory_bytes: 256
total = {}
penalty = 0
ac_answer = 0 
n,m = map(int, input().split())
for _ in range(m):
    num,answer = input().split()

    if num in total:
        total[num].append(answer)
    else:
        total[num] = [answer]
        
for answer_value in total.values():
    if "AC" in answer_value:
        penalty += answer_value.index("AC")
        ac_answer += 1
            
print(ac_answer,penalty)

Measured memory_bytes: 30160
from collections import Counter

n, m = map(int, input().split())
dic = Counter(map(int, input().split()))
lis = sorted(dic.items(), key=lambda x: x[1], reverse=True)

res = 0
for i in range(min(m, len(lis))):
    res += lis[i][1]
print(n - res)


Measured memory_bytes: 41504
#include<stdio.h>
#define N 101
#define INF 999999
#define BLACK 1
#define WHITE 0

int d[N];
int pi[N];

void initialize(int n,int s){
  int v;
  for(v=0;v<n;v++){
    d[v]=INF;
    pi[v]=0;
  }
  d[s]=0;
}

void relax(int u,int v,int w){
  if(d[v]>d[u]+w){
    d[v]=d[u]+w;
    pi[v]=u;
  }
}

void djikstra(int n,int w[N][N],int s){
  int i,u,v,mincost,color[N];
  initialize(n,s);
  for(i=0;i<N;i++)
    color[i]=WHITE;
  while(1){
    mincost=INF;
    for(i=0;i<n;i++)
      if(color[i]!=BLACK && d[i]<mincost){
        mincost=d[i];
        u=i;
      }
    if(mincost==INF)break;
    color[u]=BLACK;
    for(v=0;v<n;v++)
      if(color[v]!=BLACK && w[u][v]!=-1)
        relax(u,v,w[u][v]);
  }
}

void print(int n){
  int i;
  for(i=0;i<n;i++)
    printf("%d %d\n",i,d[i]);
}

int main(){
  int n,i,j,u,v,k,Adj[N][N];
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      Adj[i][j]=-1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&Adj[i][v]);
    }
  }
  djikstra(n,Adj,0);
  print(n);
  return 0;
}




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


public class Main {

	static Scanner sc = new Scanner(System.in);
	static int m,n;
	static int[] p;
	public static void main(String[] args) {
		while(read())	solve();
	}

	private static void solve() {
		Arrays.sort(p);
		p = reverse(p);
		int i = 0;
		int sum = 0;
		while (m >= i + n) {
			for (int j = 0; j < n-1; j++) {
				sum += p[i + j];
			}
			i += n;
		}
		for (int j = i; j < m; j++) {
			sum += p[j];
		}
		System.out.println(sum);
	}

	private static int[] reverse(int[] in) {
		int[] out = new int[in.length];
		for (int i = 0; i < in.length; i++) {
			out[i] = in[in.length - 1 - i];
		}
		return out;
	}

	private static boolean read() {
		m = sc.nextInt();
		n = sc.nextInt();
		if(m==0 && n==0) return false;

		p = new int[m];
		for(int i=0; i<m; i++) {
			p[i] = sc.nextInt();
		}
		return true;
	}


}

Measured memory_bytes: 53500
from collections import deque

q = int(input())

L = deque()
cursor = 0
for i in range(q):
    inp = input()

    # insert
    if inp[0] == "0":
        operation, x = inp.split()
        L.appendleft(x)

    # move
    elif inp[0] == "1":
        operation, d = list(map(int, inp.split()))
        L.rotate(-d)
        cursor += d

    # erase
    else:
        L.popleft()

L.rotate(cursor)
[print(a) for a in L]


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

void GCD(vector<int>& v,int n){
    v.push_back(1);
    int p = 2;
    while(p <= n){//cout << "a";
        if(n % p == 0){
            v.push_back(p);
            //cout << p << " ";
        }
        p++;
    }
}

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    vector<int> va,vb;
    //cout << "a" << endl;
    GCD(va,a);
    //cout << "b" << endl;
    GCD(vb,b);

    int j = 0;

    int aa = va.size() - 1,bb = vb.size() - 1;

    while(k != j){//cout << "b";
        if(va[aa] == vb[bb]){
            aa--;
            bb--;
            j++;
        }else if(va[aa] < vb[bb]){
            bb--;
        }else{
            aa--;
        }
    }

    cout << va[aa + 1] << endl;
}

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

void solve(){

    int D ,T ,S;
    cin>>D>>T>>S;

    if(D<= (S*T) ){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

int main()
{
    int TestCases=1;
    while(TestCases>0){
        solve();
        TestCases--;
    }

    return 0;
}


Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int X = sc.nextInt();
		int g = gcd(X, 360);
		int ans = 360 / g;
		out.println(ans);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


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

int main() {
  string s;
  cin >> s;

  int a;

  if (s == "SUN") {
    a = 7;
  } else if (s == "SAT") {
    a = 1;
  } else if (s == "FRI") {
    a = 2;
  } else if (s == "THU") {
    a = 3;
  } else if (s == "WED") {
    a = 4;
  } else if (s == "TUE") {
    a = 5;
  } else if (s == "MON") {
    a = 6;
  }

  cout << a << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
T=[0]
X=[0]
Y=[0]

for _ in range(N):
    t, x, y = [int(i) for i in input().split()]
    T.append(t)
    X.append(x)
    Y.append(y)
for i in range(N):
    z = abs(X[i]-X[i+1])+abs(Y[i]-Y[i+1])
    if z & 1 == (T[i + 1] - T[i]) & 1 and z <= (T[i + 1] - T[i]):
        continue
    else:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 65752
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    double t, a;
    cin >> t >> a;
    double best_h = INF, best_n;

    rep(i, n) {
        double h;
        cin >> h;
        double diff = abs(a - (t - h * 0.006));
        if(best_h > diff){
            best_h = diff;
            best_n = i+1;
        }
    }
    cout << best_n << endl;
    return 0;
}



Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.split("\n");
var A=Arr[1].split(" ").map(Number);
var N=Arr[0]-0;
/*
1 insertionSort(A, N) // N個の要素を含む0-オリジンの配列A
2   for i が 1 から N-1 まで
3     v = A[i]
4     j = i - 1
5     while j >= 0 かつ A[j] > v
6       A[j+1] = A[j]
7       j--
8     A[j+1] = v
*/
console.log(A.join(" "));
for(var i=1;i<=N-1;i++){
   var v=A[i];
   var j=i-1;
   while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
}
console.log(A.join(" "));
}

Measured memory_bytes: 7908
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
using namespace std;

int A,B,C,N,l[10],ans=pow(10,9);
int func(int i,int a,int b,int c,int m){
    if(i==N){
        if(a!=0 && b!=0 && c!=0){
            m+=abs(a-A)+abs(b-B)+abs(c-C);
            ans=min(m,ans);
            return 0;
        }
        else return 0;
    }

    if(a!=0)func(i+1,a+l[i],b,c,m+10);
    else    func(i+1,a+l[i],b,c,m);
    
    if(b!=0)func(i+1,a,b+l[i],c,m+10);
    else    func(i+1,a,b+l[i],c,m);
    
    if(c!=0)func(i+1,a,b,c+l[i],m+10);
    else    func(i+1,a,b,c+l[i],m);
    
    func(i+1,a,b,c,m);

    return 0;
}

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

    func(0,0,0,0,0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    long long int N,H,W,i,j,k,ans,count,cost,tmp;
    long long int S[200010];
    long long int Ssum[200010];
    string T;
    bool flag;
    count=0;
    ans=std::pow(10,18);
    flag=false;
    cin >>N>>H;
    Ssum[0]=0;
    
    if (N==H){
        cout << "Yes"<<endl;
    }
    else{
        cout << "No"<<endl;
    
    }
    

    
    

    return 0;
    
}


Measured memory_bytes: 3624
n = int(input())
ans = ''
while True:
    q, mod = divmod(n, 26)
    if mod == 0:
        ans = 'z' + ans
        q -= 1
    else:
        ans = (chr(ord('a') + mod-1)) + ans
    if q == 0:
        break
    else:
        n = q
print(ans)
    


Measured memory_bytes: 9064
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <functional>
using namespace std;
using ll = long long;

struct SegTree {
    using F = function<int(int, int)>;
    const F f;
    const int M1;
    int sz;
    vector<int> dat;
    SegTree(int n, const F f, const int &M1) : f(f), M1(M1), sz(1) {
        while (sz < n) sz <<= 1;
        dat.assign(sz * 2, M1);
    }
    void set(int k, const int &x) { dat[k + sz] = x; }
    void build() {
        for (int k = sz - 1; k > 0; k--) {
            dat[k] = f(dat[2 * k], dat[2 * k + 1]);
        }
    }
    int get(int a, int b) {
        int L = M1, R = M1;
        for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if (a & 1) L = f(L, dat[a++]);
            if (b & 1) R = f(dat[--b], R);
        }
        return f(L, R);
    }
    int operator[](const int &k) const { return dat[k + sz]; }
};

int main() {
    int N; ll L; cin >> N >> L;
    vector<ll> left(N), right(N);
    map<long long, int> id;
    int sz = 0;
    for (int i = 0; i < N; i++) cin >> left[i] >> right[i], id[left[i]], id[right[i]];
    for (auto &p: id) p.second = sz++;
    for (int i = 0; i < N; i++) left[i] = id[left[i]], right[i] = id[right[i]];
    vector<int> cnt(sz + 1);
    SegTree seg(sz, [](int a, int b) { return max(a, b); }, 0);
    for (int i = 0; i < N; i++) {
        int l = left[i], r = right[i];
        cnt[left[i]]++, cnt[right[i]]--;
        seg.set(l, max(seg[l], r));
    }
    //---
    seg.build();
    int c = 0;
    int cur = 0;
    while (cur < sz - 1) {
        cur = seg.get(0, cur + 1);
        c++;
    }
    cout << c << " ";
    //---
    for (int i = 0; i < sz; i++) cnt[i + 1] += cnt[i];
    int mi = *min_element(cnt.begin(), cnt.begin() + sz - 1);
    cout << N - mi + 1 << endl;
    return 0;
}


Measured memory_bytes: 35476
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int n[3];
  cin >> n[0] >> n[1] >> n[2];
  sort(n, n + 3);
  cout << n[0] + n [1] << endl;
}

Measured memory_bytes: 256
using System;

namespace TestProject
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int nnn = int.Parse(Console.ReadLine());
			nnn++;
			string s = Console.ReadLine();
			int n = s.IndexOf("xx") + 1;
			n = (n == 0) ? s.Length : n;
			Console.WriteLine(n);
		}
	}
}

Measured memory_bytes: 10308