akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

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

    double sum;
    rep(i, N) {
        double n;
        string S;
        cin >> n >> S;
        if(S == "JPY") {
            sum += n;
        } else {
            sum += n * 380000;
        }
    }

    cout << setprecision(15) << sum << endl;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int p = abs(a[0]) + abs(a[n - 1]);
    for (int i = 1; i < n; i++) {
        p += abs(a[i] - a[i - 1]);
    }
    cout << p - abs(a[0]) - abs(a[1] - a[0]) + abs(a[1]) << "\n";
    for (int i = 1; i < n - 1; i++) {
        cout << p - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]) << "\n";
    }
    cout << p - abs(a[n - 1] - a[n - 2]) - abs(a[n - 1]) + abs(a[n - 2]) << "\n";
    return 0;
}

Measured memory_bytes: 1664
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def main():
    n = inp()
    res = 1
    for i in range(1,n+1):
        res = res * i % mod
    print(res%mod) 
if __name__ == '__main__':
    main()

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

const int maxn = 2e5 + 6;
const int lm = 23;

typedef struct mex {
	bool occ[lm];

	void init() {
		for (int i = 0; i < lm; i++) occ[i] = false;
	}
	int get() {
		for (int i = 0; i < lm; i++) if (!occ[i]) return i;
		return lm;
	}
	void add(int x) {
		if (x >= lm) return;
		occ[x] = true;
	}
} mex;


int out[maxn];
int p[maxn];
mex S[maxn];
mex T[maxn];
bool vis[maxn];
queue<int> Q;

int n;

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

	for (int i = 1; i <= n; i++) {
		out[i] = p[i] = 0; S[i].init(); T[i].init(); vis[i] = false;
	}

	for (int i = 1; i <= n; i++) {
		cin>>p[i]; out[p[i]]++;
	}

	Q = *new queue<int>();
	for (int i = 1; i <= n; i++) {
		if (out[i] == 0) Q.push(i);
	}

	while (Q.size() > 0) {
		int z = Q.front(); Q.pop(); vis[z] = true;
		int mv = S[z].get();
		int y = p[z];
		out[y]--; S[y].add(mv);
		if (out[y] == 0) Q.push(y);
	}
	
	int u = 0;

	for (int i = 1; i <= n; i++) {
		if (vis[i] == false) { u = i; break; }
	}

	for (int t = 0; t < lm; t++) {

		for (int i = 1; i <= n; i++) {
			T[i] = S[i];
		}

		int x = u, lv = t;
		while (p[x] != u) {
			int y = p[x];
			S[y].add(lv);
			x = y; lv = S[x].get();
		}
		
		// p[x] == u

		S[u].add(S[x].get());
		if (S[u].get() == t) {
			cout<<"POSSIBLE"<<endl; return 0;
		}

		for (int i = 1; i <= n; i++) {
			S[i] = T[i];
		}
	}

	cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 11392
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 
const int mxN=1e7;
int n, c[mxN+1];
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	cin >> n;
	for(int i=1; i<=n; ++i)
	{
	    for(int j=0;; j+=i)
		{
		    if(j>n)
		    break;
		    ++c[j];
		}
	}
	ll ans=0;
	for(int i=1; i<=n; ++i)
		ans+=(ll)i*c[i];
	cout << ans;
}

Measured memory_bytes: 42688
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cassert>
#include<vector>
#define ll long long
#define MOD 1000000007
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,m;
int dp[310][310][310];
int x[310],l[310],r[310];
vector<int>q[310];
bool check(int i,int r,int g,int b){
	int tmp;
//	cout<<"	check "<<i<<' '<<r<<' '<<g<<' '<<b<<'\n';
	for(int j=0;j<q[i].size();j++){
		tmp=(l[q[i][j]]<=r)+(l[q[i][j]]<=g)+(l[q[i][j]]<=b);
		if(tmp!=x[q[i][j]]) return 0;
	}
//	cout<<"	pass!\n";
	return 1;
}
void add(int &x,int y){
	x+=y;
	if(x>=MOD) x-=MOD;
} 
int main(){
	n=read();m=read();int i,j,k,lim;
	for(i=1;i<=m;i++){
		l[i]=read();r[i]=read();x[i]=read();
		q[r[i]].push_back(i);
	}
	dp[0][0][0]=1;
	int ans=0;
//	垃圾填表法，刷表法万岁(ノ￣▽￣)
//	for(lim=1;lim<=n;lim++){
//		cout<<"begin "<<lim<<'\n';
//		//red max
//		i=lim;
//		for(j=0;j<lim;j++){
//			for(k=0;k<lim;k++){
//				if((j&&j==k)||(!check(lim,i,j,k))) continue;
//				dp[i][j][k]=dp[i-1][j][k];
//				if(j) dp[i][j][k]+=dp[i][j-1][k];
//				if(k) dp[i][j][k]+=dp[i][j][k-1];
//				dp[i][j][k]%=MOD;
//				cout<<i<<' '<<j<<' '<<k<<' '<<dp[i][j][k]<<'\n';
//			}
//		}
//		//green max
//		j=lim;
//		for(i=0;i<lim;i++){
//			for(k=0;k<lim;k++){
//				if((i&&i==k)||(!check(lim,i,j,k))) continue;
//				dp[i][j][k]=dp[i][j-1][k];
//				if(i) dp[i][j][k]+=dp[i-1][j][k];
//				if(k) dp[i][j][k]+=dp[i][j][k-1];
//				dp[i][j][k]%=MOD;
//				cout<<i<<' '<<j<<' '<<k<<' '<<dp[i][j][k]<<'\n';
//			}
//		}
//		//blue max
//		k=lim;
//		for(i=0;i<lim;i++){
//			for(j=0;j<lim;j++){
//				if((j&&j==i)||(!check(lim,i,j,k))) continue;
//				dp[i][j][k]=dp[i][j][k-1];
//				if(i) dp[i][j][k]+=dp[i-1][j][k];
//				if(j) dp[i][j][k]+=dp[i][j-1][k];
//				dp[i][j][k]%=MOD;
//				cout<<i<<' '<<j<<' '<<k<<' '<<dp[i][j][k]<<'\n';
//			}
//		}
//	}
//	for(i=0;i<n;i++){
//		for(j=0;j<n;j++){
//			ans=(ans+dp[n][i][j]+dp[i][n][j]+dp[i][j][n])%MOD;
//		}
//	}
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			for(k=0;k<=n;k++){
				lim=max(i,max(j,k));
				if(!dp[i][j][k]||!check(lim,i,j,k)){
					dp[i][j][k]=0;continue;
				}
				if(lim==n){
					add(ans,dp[i][j][k]);continue;
				}
//				dp[lim+1][j][k]=(dp[lim+1][j][k]+dp[i][j][k])%MOD;
				add(dp[lim+1][j][k],dp[i][j][k]);
//				dp[i][lim+1][k]=(dp[i][lim+1][k]+dp[i][j][k])%MOD;
				add(dp[i][lim+1][k],dp[i][j][k]);
//				dp[i][j][lim+1]=(dp[i][j][lim+1]+dp[i][j][k])%MOD;
				add(dp[i][j][lim+1],dp[i][j][k]);
			}
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 114944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF (1<<30);

int main() {
  ll A, B, N;
  cin >> A >> B >> N;

  ll ans;
  if (N%B == 0) {
    N--;
    ans = (A*N/B) - A*(N/B);
  }
  else {
    ans = (A*N/B) - A*(N/B);
    N = max(0LL, N-(N%B)-1);
    ll tmp = (A*N/B) - A*(N/B);
    ans = max(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
N = int(input())

v = list(map(int,input().split()))
         
if N == 2:
  print(sum([int(i) for i in v])/2)
  exit()
  
else:
  v.sort()
  a = v[-1]
  v.pop(-1)
  r = (v[0]+v[1])/2
  for i in range(N-3):    
    r = (r+v[i+2])/2 
    
print((r+a)/2)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
    // 整数の入力
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    for(int i = K;i < N;i++){
        if (A[i-K] < A[i]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
   return 0;
}

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

int main(){
   char a;
   cin >> a;
   if(a == 'A')cout << 'A' << endl;
   else if(a == 'B')cout << 'A' << endl;
   else if(a == 'C')cout << 'A' << endl;
   else if(a == 'D')cout << 'A' << endl;
   else if(a == 'E')cout << 'A' << endl;
   else if(a == 'F')cout << 'A' << endl;
   else if(a == 'G')cout << 'A' << endl;
   else if(a == 'H')cout << 'A' << endl;
   else if(a == 'I')cout << 'A' << endl;
   else if(a == 'J')cout << 'A' << endl;
   else if(a == 'K')cout << 'A' << endl;
   else if(a == 'L')cout << 'A' << endl;
   else if(a == 'M')cout << 'A' << endl;
   else if(a == 'N')cout << 'A' << endl;
   else if(a == 'O')cout << 'A' << endl;
   else if(a == 'P')cout << 'A' << endl;
   else if(a == 'Q')cout << 'A' << endl;
   else if(a == 'R')cout << 'A' << endl;
   else if(a == 'S')cout << 'A' << endl;
   else if(a == 'T')cout << 'A' << endl;
   else if(a == 'U')cout << 'A' << endl;
   else if(a == 'V')cout << 'A' << endl;
   else if(a == 'W')cout << 'A' << endl;
   else if(a == 'X')cout << 'A' << endl;
   else if(a == 'Y')cout << 'A' << endl;
   else if(a == 'Z')cout << 'A' << endl;
   else cout << "a" << endl;
}

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

int main() {
  int l,r,d,cnt=0;
  cin >> l >> r >> d;
  for (int i = l; i <=r; i++) {
    if (i%d==0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3564
//                   ********** YATIN KWATRA **********

// AC BAKSHI RABBA

#include <bits/stdc++.h>
#define ll                      long long 
#define ld                      long double
#define ull                     unsigned long long 
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                     vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                     unordered_map                
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int> 
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define MIN                     -1e9
#define pi                      3.1415926535897932384626433832795

using namespace std;

void INPUT() 
{  
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

/*
    
   -> Check For Overflows
   -> Out of Bounds
   -> Initialisations of global arrays and variables
   -> Read the Question and the sample test cases carefully
   -> Its not Always Complex, Try to simplify
   -> write it down and try to solve
   -> Have Faith in urself and in ur approach
   -> If it seems totally out of reach, switch to next :)
   -> And Come Back later, if possible ..
*/





void solve()
{ 
  ll l,r,d;
  cin >> l >> r >> d;

  ll ans = r/d - (l-1)/d;
  cout << ans << endl;    

       
}
int main() {
    
    FIO
    INPUT();
    
    int t;
    t = 1;
    //cin >> t;
    
    while(t--)
    {
       solve();
    }
    return 0;
}


Measured memory_bytes: 3560
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    putStrLn $ map f (solve n)

solve 0 = []
solve n | m == 0 = solve (d-1) ++ [m] 
        | otherwise = (solve d) ++ [m]
    where (d,m) = n `divMod` 26

f k = head . drop k $ 'z' : ['a'..'y']

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '1') s[i] = '9';
    else if(s[i] == '9') s[i] = '1';
  }
  cout << s << endl;
}

Measured memory_bytes: 256
A = input()
B = input()
C = input()

throw = "a"
a = 0
b = 0
c = 0

while True:
    if throw == "a":
        if a == len(A):
            print("A")
            break       
        throw = A[a]
        a += 1
    elif throw == "b":
        if b == len(B):
            print("B")
            break
        throw = B[b]
        b += 1
    elif throw == "c":
        if c == len(C):
            print("C")
            break
        throw = C[c]
        c += 1

        

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
def MI():
    return map(int, input().split())

class segtree:
    # 1-indexed セグ木
    x_unit=0 # 単位元
    x_func=max  # 関数
    condition=lambda self,a,b:a>=b # max_right用に定義
    def __init__(self,n,seq): # 元のseqと要素数n
        self.n=n
        self.x=[self.x_unit]*(2*n)
        for i,j in enumerate(seq, self.n): # n番目からseqをx配列に移していく
            self.x[i] = j
        for i in range(self.n-1, 0, -1):
            self.x[i] = self.x_func(self.x[i*2], self.x[i*2+1])
    def update(self,i,j): # 1点更新
        i += self.n
        self.x[i]=j
        while i>1:
            i//=2 # 更新後、木の上へと登っていくついでに更新
            self.x[i]=self.x_func(self.x[i*2], self.x[i*2+1])
    def get(self, i): # 値を入手
        return self.x[i+self.n] 
    def fold(self,l,r): # 区間[l, r)の最小値などを取得 
        l+=self.n
        r+=self.n
        val_l=self.x_unit
        val_r=self.x_unit
        while l<r:
            if l & 1: # lが奇数
                val_l=self.x_func(val_l,self.x[l])
                l+=1 # 偶数に調節
            if r & 1: # rが奇数
                r-=1 # 開区間なので1個前は偶数番目の要素
                val_r=self.x_func(val_r,self.x[r])
            l //= 2
            r //= 2
        return self.x_func(val_l,val_r)
    def max_right(self, l, v): 
        # index lを含めて右にある値の中でa[j]>=vを満たす最小のindexを求める
        # 存在しない場合はnを出力
        r=self.n
        if self.condition(self.fold(l, r),v)==False:
            return r
        else:
            while r-l>1:
                l1=l
                r1=l+(r-l)//2
                l2=l+(r-l)//2
                r2=r
                if self.condition(self.fold(l1, r1),v)==True:
                    l=l1
                    r=r1
                else:
                    l=l2
                    r=r2
            return l
    def min_left(self, r, v): 
        # index rを含まずに左にある値の中でa[j]>=vを満たす最大のindexを求める
        # 存在しない場合は0を出力
        l=0
        if self.condition(self.fold(l, r),v)==False:
            return l
        else:
            while r-l>1:
                l1=l
                r1=l+(r-l)//2
                l2=l+(r-l)//2
                r2=r
                if self.condition(self.fold(l1, r1),v)==True:
                    l=l1
                    r=r1
                else:
                    l=l2
                    r=r2
            return r

n,k=MI()
seq=[0 for _ in range(300001)]
seg=segtree(300001,seq)
for i in range(n):
    a=int(input())
    left=seg.fold(max(a-k,0), a+1)
    right=seg.fold(a, min(a+k,300000)+1)
    seg.update(a,max(left,right)+1)
print(seg.fold(0, 300001))

Measured memory_bytes: 94568
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String S = sc.next();
		char[] a = new char[2];
		a[0] = S.charAt(0);
		int c = 0;
		int c2 = 0;
		String ans = "Yes";
		if (S.charAt(1) == a[0]) { 
			a[1] = S.charAt(2);
			if (S.charAt(3) != a[1]) {
				ans="No";
			} else if (a[1] == a[0]) {
				ans="No";
			}
		} else {
			a[1] = S.charAt(1);
			if (S.charAt(2) != a[0] && S.charAt(2) != a[1]) {
				ans="No";
			} else if (S.charAt(3) != a[0] && S.charAt(3) != a[1]) {
				ans="No";
			}
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

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

int main()
{
    string S[200010]={},B[200010]={};
    map<string,int> mp;
    int N,ans=0;
    cin>>N;

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

        mp[S[i]]++;
    }

    ans = mp.size();

    cout<< ans <<endl;

    return 0;
}

Measured memory_bytes: 31724
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

const (
	M          = 1000000007
	A, C, G, T = 0, 1, 2, 3
)

func i2c(v int) byte {
	switch v {
	case A:
		return 'A'
	case C:
		return 'C'
	case G:
		return 'G'
	case T:
		return 'T'
	}
	return byte(255)
}

func check(c0, c1, c2, c3 int) bool {
	s := []byte{i2c(c3), i2c(c2), i2c(c1), i2c(c0)}
	if bytes.Contains(s, []byte{'A', 'G', 'C'}) {
		return false
	}
	if bytes.Contains(s, []byte{'G', 'A', 'C'}) {
		return false
	}
	if bytes.Contains(s, []byte{'A', 'C', 'G'}) {
		return false
	}
	if s[0] == 'A' && s[2] == 'G' && s[3] == 'C' {
		return false
	}
	if s[0] == 'A' && s[1] == 'G' && s[3] == 'C' {
		return false
	}
	return true
}

func main() {
	defer stdout.Flush()

	n := readInt()
	dp := make([][4][4][4]int, n+1)
	dp[0][T][T][T] = 1
	for i := 1; i <= n; i++ {
		for _, p3 := range []int{A, C, G, T} {
			for _, p2 := range []int{A, C, G, T} {
				for _, p1 := range []int{A, C, G, T} {
					for _, cur := range []int{A, C, G, T} {
						if check(cur, p1, p2, p3) {
							dp[i][cur][p1][p2] = (dp[i][cur][p1][p2] + dp[i-1][p1][p2][p3]) % M
						}
					}
				}
			}
		}
	}
	sum := 0
	for _, p1 := range []int{A, C, G, T} {
		for _, p2 := range []int{A, C, G, T} {
			for _, p3 := range []int{A, C, G, T} {
				sum = (sum + dp[n][p1][p2][p3]) % M
			}
		}
	}
	println(sum)
}

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
const int MAX = 2001;
const int MOD = 1000000007;
 
 

 
signed main(){
    int n,d;
    cin>>n>>d;
    int x[n][d];
    for(int i=0;i<n;i++)for(int j=0;j<d;j++){
        cin>>x[i][j];
    }
    int ans=0,t0;
    float t=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            t=0;
            for(int k=0;k<d;k++){
                t+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            t0=signed(sqrt(t));
        
            if(sqrt(t)==t0)ans++;
            
        }
    }
    cout<<ans;
  
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,x,l,d=0,ans=1;
    
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>l;
        d += l;
        
        if(d<=x){ ans +=1; }
    }
    
    cout<<ans<<"\n";
    return 0;
}


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

using namespace std;

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

    if ((A - C) * (B - C) < 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ldb;
typedef pair<ll,ll> pll;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define V vector
#define endl "\n"
#define CLEAR(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
#define sz(x) ((ll)x.size())
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ios_tie() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(nullptr)
#define trace1(a)             cout <<#a<<":"<<a<< endl;
#define trace2(a,b)           cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<< endl;
#define trace3(a,b,c)         cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<endl;
#define trace4(a,b,c,d)       cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<" | "<<#d<<":"<<d<<endl;

const ll inf = 1e18;
const ll mod = 1e9+7;
const ll maxn = 1e5+1;
const ldb PI = acos(-1);

void lol(ll s) {cerr<<"check........................................... "<<s<<endl;}
ll power(ll x,ll y) {ll res=1; x%=mod; while(y) {if(y&1) res=(res*x)%mod; y>>=1LL; x=(x*x)%mod; }return res;}
ll inv(ll x) {return power(x,mod-2);}//(1/x)%y = x^(y-2) % y;   // pow(x,y)%m = pow(x,y%(m-1))%m
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// If you copy paste my solution I will murder you in your sleep.
void init()
{

}
V<ll> adj[maxn];
ll vis[maxn];
void dfs(ll s) {
    vis[s] = 1;
    for(auto it:adj[s]) {
        if(!vis[it]) {
            dfs(it);
        }
    }
}
void solve()
{
    ll n, m;
    cin>>n>>m;
    rep0(i,m) {
        ll u, v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    ll res = 0;
    rep1(i,n) {
        if(!vis[i]) {
            dfs(i);
            res++;
        }
    }
    cout<<res-1<<endl;
}

int main()
{
    ios_tie();
    // freopen("input.txt", "r", stdin);
    // freopen("myOut.txt", "w", stdout);
    ll _ = 1;
    // cin>>_;
    init();
    rep1(i,_)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 11108
#include<bits/stdc++.h>
#define Mo 1000000007
#define N 200000
#define mp make_pair
#define fi first
#define se second
#define pb push_back
typedef long long LL;
typedef long double LD;
using namespace std;
int p[N];

int main() {
	string s; cin >> s; int len = s.length();
	for(int i = 0; i < len / 2; i++)
		if (s[i] != s[len - i - 2]) return cout << -1 << endl, 0;
	if (s[0] != '1' || s[len - 1] == '1') return cout << -1 << endl, 0;
	int tot = 1; p[1] = 1;
	for(int i = 1; i < len - 1; i++)
		if (s[i] == '0') p[++tot] = i + 1;
		else {
			for(int j = 1; j <= tot; j++) cout << i + 1 << " " << p[j] << endl;
			tot = 1, p[1] = i + 1;
		}
	cout << len << " " << p[1] << endl;
} 


Measured memory_bytes: 2048
#include <iostream>
#include <cmath>

using namespace std;

int const NMAX = 1e5;
int const INF = 2e9;

int nStones;
int dp[NMAX+1][3];
int h[1+NMAX]; //this is an indication that your array is starting from index 1

int costOfHop(int from, int to) {
  return abs(h[from]-h[to]);
}

int main() {
  cin >> nStones;
  for(int i=1; i<=nStones; i++) {
    cin >> h[i];  //stones are 1..nStones
  }

  /*
    dp[i][j] = minimum cost of getting to ith stone, where last hop had length j
  */
  for(int i=0; i<=nStones; i++) {
    dp[i][1] = INF;
    dp[i][2] = INF;
  }

  //Bottom-up: we start from a subproblem that we know is optimal.
  dp[1][1] = 0; //the initial case is an abstract case
  dp[1][2] = 0;
  for(int i=1; i<=nStones; i++) {  //you start from a SOLVED problem in bottom-up
    int startingOptimalCost = min(dp[i][1], dp[i][2]);
    for(int j=1; j<=2; j++) {
      dp[i+j][j] = min(dp[i+j][j], startingOptimalCost + costOfHop(i, i+j));
    }
  }
  cout << min(dp[nStones][1], dp[nStones][2]);
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <stdlib.h>   
using namespace std;


int main() {
    
    int N, T, A;

    cin >> N >> T >> A;
    double H[1010];
    double B[1010];
    int index = 0;
    double res;
    double min = 10000000;
    
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
        B[i] = T - H[i] * 0.006; 
        res = B[i] - A;
        if (res < 0) res = -res;
        if (res < min) {
            min = res;
            index = i;
        }
    }
    cout << index + 1<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() {
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    string s,t;
    cin>>s>>t;
    for (int i = 0; i < s.length(); ++i)
    {
        if(s[i]!=t[i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";

    return 0;
}


Measured memory_bytes: 3620
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    a = kwargs["a"]
    b = kwargs["b"]
    res = a * b
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["a"], kwargs["b"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Measured memory_bytes: 31052
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

#define rep(i, n) for(int i = 0 ; i < n ; i++)

char solve(char c, int key){
  while(key--){
    if(c == 'A') c = 'z';
    else if(c == 'a') c = 'Z';
    else c--;
  }
  return c;
}

int main(){
  int n;
  while(cin >> n, n){
    vector<int> key(n);
    rep(i, n) cin >> key[i];
    
    string str;
    cin >> str;
    rep(i, str.size()){
      cout << solve(str[i], key[i%n]);
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
const ll MOD = 998244353;

int main() {
    ll n, m;;
    cin >> n >> m;
    vector<tuple<ll, ll, ll>> P(m);
    for (ll i = 0; i < m; ++i) {
        auto & p = P[i];
        cin >> get<0>(p) >> get<1>(p);
        get<2>(p) = i;
    }

    sort(P.begin(), P.end(), [&](auto & left, auto & right) -> bool {
        return get<1>(left) < get<1>(right);
    });

    map<ll, ll> counter;
    for (auto & p : P) {
        counter[get<0>(p)]++;
        get<1>(p) = counter[get<0>(p)];
    }

    sort(P.begin(), P.end(), [&](auto & left, auto & right) -> bool {
        return get<2>(left) < get<2>(right);
    });

    for (auto & p : P) {
        printf("%06lld%06lld\n", get<0>(p), get<1>(p));
    }
}


Measured memory_bytes: 10112
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){	
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			
			System.out.println(6 - A - B);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21204
import java.util.Scanner

object Main {
  def main(args:Array[String]): Unit = {
    val vowels = Array("a", "i", "u", "e", "o")
    val sc = new Scanner(System.in)

    if (vowels.contains(sc.nextLine())) {
      println("vowel")
    } else {
      println("consonant")
    }
  }
}

Measured memory_bytes: 25528
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	string s1,s2,s;
	int a,b;
	cin>>s1>>s2;
	cin>>a>>b;
	cin>>s;
	if(s==s1)
	a--;
	else if(s==s2)
	b--;
	cout<<a<<" "<<b; 
	
	
 } 

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

int main() {
	int n;
	cin>>n;
	int t[n];
	for(int i=0;i<n;i++)
	    cin>>t[i];
	int m;
	cin>>m;
	int p,x;
	for(int i=0;i<m;i++)
	{
	    cin>>p>>x;
	    ll sum=0;
	    for(int j=0;j<n;j++)
	    {
	        if(j==p-1)
	            sum+=x;
	        else
	            sum+=t[j];
	    }
	    cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void) {
	int N, T; cin >> N >> T;
	vector<int> time(1, 0);
	int tmp = T;
	while (N--) {
		int ti; cin >> ti;
		if (tmp < ti) {
			time.push_back(tmp);
			time.push_back(ti);
		}
		tmp = ti + T;
	}
	time.push_back(tmp);
	ll res = 0;
	for (int i = 0; i < time.size(); i += 2)
		res += time[i + 1] - time[i];
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 50) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    ll V[N][3];
    rep(i,0,N){
        cin >> V[i][0] >> V[i][1] >> V[i][2];
    }
    ll ans = -INF;
    rep(i,0,8){
        vector<ll> vec(N);
        rep(j,0,N){
            rep(k,0,3){
                vec[j] += V[j][k] * (i & (1 << k) ? 1 : -1);
            }
        }
        sort(vec.rbegin(), vec.rend());

        ll sum = 0;
        rep(j,0,M){
            sum += vec[j];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n=int(input())
p=[int(input())-1 for _ in range(n)]
a=[0]*n
for i in range(n):
    a[p[i]]=i
l=1
ans=1
for i in range(n-1):
    if a[i]<a[i+1]:
        l+=1
    else:
        ans=max(ans,l)
        l=1
ans=max(ans,l)
print(n-ans)

Measured memory_bytes: 18940
#include <stdio.h>
#include <stdlib.h>
struct Node{
	int key;
	struct Node *right, *left,*parent;
};

struct Node *root,*nil;

void insert(int k){
	struct Node *y=nil;
	struct Node *x=root;
	struct Node *z;
	z=(struct Node*)malloc(sizeof(struct Node));
	z->key=k;
	z->left=nil;
	z->right=nil;
	
	while(x!=nil){
		y=x;
		if(z->key<x->key){
			x=x->left;
		}
		else{
			x=x->right;
		}
	}	
	
	z->parent=y;
	if(y==nil){
		root=z;
	}
	else{
		if(z->key<y->key){
			y->left=z;
		}
		else {
			y->right=z;
		}
	}
}

void inorder(struct Node *u){
	if(u==nil){
		return;
	}
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

void preorder(struct Node *u){
	if(u==nil){
		return;
	}
	
	if(u==nil){
		return;
	}
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main(void){
	int n,i,x;
	scanf("%d",&n);
	int d;
	char string[10];
	
	for(i=0;i<n;i++){
		scanf("%s %d",string,&d);
		if(string[0]=='i'){
			insert(d);
		}
		else if(string[0]=='p'){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	
	return 0;
}


Measured memory_bytes: 25184
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n, k;
    cin >> n >> k;

    vector <double> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];

    double ans = 0.0, cur = 0.0;
    for (int i = 0; i < n; i++) {
        if (i < k) {
            cur += (1 + p[i]) / 2.0;
        } else {
            cur += (1 + p[i]) / 2.0 - (1 + p[i - k]) / 2.0;
        }

        ans = max(ans, cur);
    }

    cout << fixed << setprecision(12) << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i<n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0);
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%lld", &v[i]);
#define vstr(v,n) vector<string> v(n); REP(i,n) scanf("%lld", &v[i]);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
int k=0,n=0, m=0, l=0,r=0,a=0, b=0, c=0, d=0,e=0,ans=0,ans2=0,x=0,y=0;
string s,t,S;
signed main() {
    cin >> a >> b >> m;
    vint(A,a);
    vint(B,b);
    ans = *min_element(ALL(A))+*min_element(ALL(B));
   REP(i,m){
     cin >> a >> b >> c;
       ans = min(ans, A[a - 1] + B[b - 1] - c);
   }
 cout << ans;
}

Measured memory_bytes: 4884
#include <iostream>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cassert>

using namespace std;

int main()
{
    const int N = 100000;

    bool is_not_prime[2*N] = { true, true, false };
    
    int const lim = ceil( sqrt( 2*N ) );
    for( int i=2; i<lim; ++i ) {
        if ( !is_not_prime[i] ) {
            for( int j=i+i; j<2*N; j+=i ) {
                is_not_prime[j] = true;
            }
        }
    }

    auto is_prime = [&]( size_t const& i ){ return !is_not_prime[i]; };

    int primes[N];
    size_t const max_prime_index = [&]() mutable
    {
        size_t index = 0;
        for( int i=0; i<2*N; ++i ) {
            if ( is_prime( i ) ) {
                primes[index++] = i;
            }
        }

        return index;
    }();

    int n, p;
    while( cin >> n >> p ) {
        if ( n == -1 && p == -1 )
            break;

        int base = -1;
        for( int i=n+1; i<2*N; ++i ) {
            if ( is_prime( i ) ) {
                base = i;
                break;
            }
        }
        assert( base != -1 );
        auto it = find( primes, primes + max_prime_index, base );

        vector<int> px;
        for( int i=0; i<p; ++i ) {
            for( int j=i; j<p; ++j ) {
                px.push_back( *(it + i) + *(it + j) );
            }
        }
        sort( px.begin(), px.end() );

        cout << px[p-1] << endl;
    }
}

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

#include <utility>
typedef long long ll;
using namespace std;

string shuffle(const string& s, int h) {
    string ans = s.substr(h);
    ans += s.substr(0, h);
    return ans;
}

int main() {
    while(true) {
        string s;
        cin >> s;
        if (s == "-") break;
        int m;
        cin >> m;
        for (int i = 0; i < m; ++i) {
            int n;
            cin >> n;
            s = shuffle(s, n);
        }
        cout << s << endl;
    }
}



Measured memory_bytes: 3184
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int cnt = N / 100;
    int n = N % 100;
    //System.out.println(n);
    cnt -= n / 5;
    n %= 5;
    cnt -= n / 4;
    n %= 4;
    cnt -= n / 3;
    n %= 3;
    cnt -= n / 2;
    n %= 2;
    cnt -= n / 1;
    n %= 1;
    if (cnt - n >= 0) {
      System.out.println(1);
      return;
    }
    System.out.println(0);
  }
}

Measured memory_bytes: 35780
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18


int main(){
    int N;cin >> N;
    vector<long long> a(N);
    int ans = 0;
    rep(i,N){
        cin >> a[i];
        int cnt = 0;
        while(a[i] % 2 == 0 && a[i] > 0){
            a[i] /= 2;
            cnt++;
        }
        ans += cnt;
    }
    cout << ans << endl;

}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
    int r,g,b,n,v,ans = 0;
    scanf("%d %d %d %d",&r,&g,&b,&n);

    for (int i = 0; i <= 3000; i++)
    {
        for (int j = 0; j <= 3000; j++)
        {
            v = i * r + j * g;
            if ((n >= v) && (n - v) % b == 0)
            {
                ans ++;
            }
            
        }
        
    }
    
    printf("%d",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
multiset<string > s;
int a,b,c;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	while (a--)s.insert("a");
	while (b--)s.insert("b");
	while (c--)s.insert("c");
	while (s.size()>1)
	 {
	 	string t=*s.begin()+ *--s.end();
	 	s.erase(s.begin());
	 	s.erase(--s.end());
	 	s.insert(t);
	 }
	cout<<*s.begin();
	return 0; 
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
s=[]
for i in range(n):
  s.append(input())
a=Counter(s)
print("AC x {}".format(a["AC"]))
print("WA x {}".format(a["WA"]))
print("TLE x {}".format(a["TLE"]))
print("RE x {}".format(a["RE"]))


Measured memory_bytes: 16604
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    priority_queue<ll> q;
    vector<ll> f(n);




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

    sort(a.rbegin(),a.rend());
    sort(f.begin(),f.end());
    rep(i,n){fa[i]=a[i]*f[i];}

    ll up = 1000000000001;
    ll down = 0;
    int nibu = 0;


    while(nibu<100){
        ll kk =0;
       // cout<<up<<" "<<down<<endl;
        nibu++;
        ll med = (up+down)/2;
        bool flag= true;


       for(int j=0;j<n;j++){
            ll kai = f[j]*a[j];
            if(med<kai){
                ll hiku = a[j]-(med/f[j]);
                //ll hiku = (a[j]*f[j]-med-1)/f[j]+1;
               kk+=hiku;
               if(kk>k){
                   flag = false;
                   break;
               }
            }

        }


        if(flag){
            up = med;
        }else{

            down = med;
        }
    }
cout<<up<<endl;








    return 0;
}


Measured memory_bytes: 4992
from collections import deque

def bfs(S,W,H):
    dx=(-1,0,1,0)
    dy=(0,1,0,-1)
    queue=deque([[0,0]])
    visited=[]
    goal=False
    cnt=deque([0])
    while queue and goal==False:
        exe=queue.popleft()
        C=cnt.popleft()
        for i in range(len(dx)):
            x=exe[0]+dx[i]
            y=exe[1]+dy[i]
            if [x,y]==[W-1,H-1]:
                goal=True
            elif 0<=x<=W-1 and 0<=y<=H-1 and S[y][x]==".":
                if [x,y] not in visited:
                    queue.append([x,y])
                    visited.append([x,y])
                    cnt.append(C+1) 
    return goal,C+1

def main():
    H,W=map(int,input().strip().split())
    S=[list(input()) for _ in range(H)]
    # number of dot
    num_sharp=0
    for i in range(H):
        for j in range(W):
            if S[i][j]=="#":
                num_sharp+=1
    goal,num=bfs(S,W,H)
    if goal:
        return W*H-num_sharp-(num+1)
    else:
        return -1

if __name__=="__main__":
    print(main())


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

int main() {
    for(int i=0; i<3000; i++){
        int x, y;
        cin >> x >> y;
        if(x==0 && y==0) break;
        cout << min(x, y) << " " << max(x, y) << endl;
    }
  return 0;
}



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

int main() {
	int n;
	cin >> n;
	int ans = 1;
	for (int i = 2; i <= n; i++) {
		int t = i;
		while (t * i <= n) {
			t *= i;
			ans = max(ans, t);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3576
n=int(input())
t=list(map(int,input().split()))
v=list(map(int,input().split()))
T=[0,t[0]]
for i in range(n-1):
  T.append(T[i+1]+t[i+1])
L=[[] for i in range(2*sum(t))]
for i in range(2*sum(t)):
  for j in range(n):
    if T[j]<=i/2<=T[j+1]:
      x=v[j]
    elif i/2<T[j]:
      x=v[j]+abs(i/2-T[j])
    else:
      x=v[j]+abs(i/2-T[j+1])
    L[i].append(x)
for i in range(2*sum(t)):
  L[i].append(i/2)
  L[i].append(sum(t)-i/2)

for i in range(2*sum(t)):
  L[i]=min(L[i])
ans=0
for i in range(2*sum(t)):
  if i==2*sum(t)-1:
    ans+=L[i]*0.25
  else:
    ans+=(L[i]+L[i+1])*0.25
print(ans)

Measured memory_bytes: 135304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(int argc, char const *argv[])
{
	int a, b, k; cin >> a >> b >> k;
	int cnt = 0;
	for (int i = min(a, b); i >= 1; --i) {
		if (a % i == 0 && b % i == 0) {
			// printf("i %d\n", i);
			cnt++;
		}
		if (cnt == k) {
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}

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

using namespace std;

#define fr(i,a,b) for(int i=a;i<b;++i)
////////////////////

int const MOD = 1e9 + 7;
int const N = 1e5 + 41;

int n, a[N];
int p[N][2];

void solve(){
	int ans = 1;
	cin >> n;
	fr(i, 1, n+1){
		cin >> a[i];
		int c = n - 1;
		int lp = 1 + (c - a[i]) / 2;
		int rp = n - lp + 1;
		if(p[lp][0] == 0){
			p[lp][0] = i;
		}else if(p[lp][1] == 0){
			p[lp][1] = i;
		}else{
			ans = 0;
		}
		if(p[rp][0] == 0){
			p[rp][0] = i;
		}else if(p[rp][1] == 0){
			p[rp][1] = i;
		}else{
			ans = 0;
		}
	}

	fr(i, 0, n/2) ans = ans * 2 % MOD;

	cout << ans << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	solve();

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
const ll INF=1e10+1;
using namespace std;
#define NOT_EXIST -1

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

signed main(){
	string s;
	cin >> s;
	ll w= 0;
	rep(i,s.size()){
		if(s[i]=='o') w++;
	}
	if(w+15-s.size()>=8) cout << "YES" << endl;
	else cout << "NO" << endl; 
}

Measured memory_bytes: 256