akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/python3

import array
from fractions import Fraction
import functools
import itertools
import math
import os
import sys


def main():
    A, B, C = read_ints()
    print(solve(A, B, C))


def solve(A, B, C):
    weekly = A * 7 + B
    weeks = C // weekly
    rest = C - weekly * weeks
    days = (rest + A - 1) // A
    if days > 7:
        days = 7
    return weeks * 7 + days


###############################################################################
# AUXILIARY FUNCTIONS

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()



Measured memory_bytes: 6916
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n; cin >> n;
    vector<int> a(n);
    int sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum ^= a[i];
    }
    rep(i, n) {
        cout << (sum ^ a[i]) << ((i==n-1)?"\n":" ");
    }
}


Measured memory_bytes: 3952
#include <cstdint>
#include <iostream>
#include <map>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); i++)

using namespace std;
using ll = int64_t;

enum Flag { OPEN = 0, CLOSE = 1 };

unordered_map<ll, vector<pair<ll, Flag>>> mymap;

ll cal_left(int i) { return (ll)(i - 1) * i / 2; }

ll cal_right(int i, int n) { return (ll)(2 * n - i - 1) * i / 2 + 1; }

int main() {
  int n;
  ll x, d;
  scanf("%d%lld%lld", &n, &x, &d);
  if (d == 0) {
    if (x == 0) {
      printf("1\n");
    } else {
      printf("%d\n", n + 1);
    }
    return 0;
  }

  if (d < 0) {
    x = -x;
    d = -d;
  }
  for (int i = 0; i <= n; i++) {
    mymap[((ll)i * x) % d].emplace_back(cal_left(i) + (ll)i * x / d, OPEN);
    mymap[((ll)i * x) % d].emplace_back(cal_right(i, n) + (ll)i * x / d, CLOSE);
  }
  ll ans = 0;
  for (auto &v : mymap) {
    sort(v.second.begin(), v.second.end());
    ll pre, cnt = 0;
    for (auto &u : v.second) {
      if (u.second == OPEN) {
        if (cnt++ == 0)
          pre = u.first;
      } else {
        if (--cnt == 0)
          ans += u.first - pre;
      }
    }
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 23676
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;

int main(){
  int n;
  string s;
  cin >> n >> s;
  rep(i,s.size()){
  s.at(i) += n;
  if('Z'<s.at(i))s.at(i) -=26;
  }
  cout << s;
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

const int Nmax=610;

struct V2{
	int y,x;
};

int n;
vector<V2> es;
bool vis[Nmax][Nmax];
void dfs(int y,int x,vector<V2>&g0,vector<V2>&g1){
	if(y<0||n*2<=y)return;
	if(x<0||n*2<=x)return;
	if(vis[y][x])return;
	vis[y][x]=true;
	g0.PB(V2{y,x});
	for(auto e:es)
		dfs(y+e.y,x+e.x,g1,g0);
}

void Sub(){
	int d=read();
	es.clear();
	REP(y,n*2)REP(x,n*2)if(Sq(y)+Sq(x)==d){
		REP(_,2){
			REP($,2){
				es.PB(V2{y,x});
				y=-y;
			}
			x=-x;
		}
	}
	vector<V2> waf;
	REP(y,n*2)REP(x,n*2)if(!vis[y][x]){
		vector<V2> g0,g1;
		dfs(y,x,g0,g1);
		if(g0.size()<g1.size())
			swap(g0,g1);
		waf.insert(waf.end(),ALL(g0));
	}
	for(auto v:waf)
		vis[v.y][v.x]=false;
}

signed main(){
	n=read();
	REP(_,2)
		Sub();
	int cnt=0;
	REP(y,n*2)REP(x,n*2)if(!vis[y][x]&&cnt++<n*n)
		print(x,2),print(y);
}


Measured memory_bytes: 39132
#include <stdio.h>

int main(void){
	int a[100],n;
	int i,temp;

	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%d",&a[i]);
	}
	for(i = 0;i <n/2;i++){
		temp = a[i];
		a[i] = a[n-1-i];
		a[n-1-i] = temp;
	}
	for(i = 0;i < n;i++){
		printf("%d",a[i]);
		if(i != n-1){
			printf(" ");
		}
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 600
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inclass in = new inclass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AAntiAdjacency solver = new AAntiAdjacency();
        solver.solve(1, in, out);
        out.close();
    }

    static class AAntiAdjacency {
        public void solve(int testNumber, inclass in, PrintWriter out) {
            int n = in.nextInt(), k = in.nextInt();
            int max = 0;
            if (n % 2 == 0) {
                max = n / 2;
            } else {
                max = n / 2 + 1;
            }
            if (k > max) {
                out.println("NO");
            } else {
                out.println("YES");
            }
        }

    }

    static class inclass {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private inclass.SpaceCharFilter filter;

        public inclass(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

bool isminus(long long i){
  return i < 0;
}

bool absmin(long long i, long long j){
  return abs(i) < abs(j);
}

long long abssum(vector<long long> &A){
  long long sum = 0LL;
  for(long long &i : A){
    sum += abs(i);
  }
  return sum;
}

int main(){
  int N;
  cin >> N;
  
  vector<long long> A(N);
  
  for(long long &i : A)
    cin >> i;
  
  int minus = count_if(A.begin(), A.end(), isminus);
  
  if(minus % 2 == 0)
    cout << abssum(A) << endl;
  else{
    long long two = 2;
    cout << abssum(A)
    	- two * abs(*min_element(A.begin(), A.end(), absmin)) << endl;
  }
}

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

int main(){
  int L,H,hits,blow;
  string trys;
  vector<int> h,b,v,ans;
  vector<string> t;

  while(cin >> L >> H, L||H){
    t.clear();
    h.clear();
    b.clear();
    ans.clear();

    for(int i=0;i<H;i++){
      cin >> trys >> hits >> blow;
      t.push_back(trys);
      h.push_back(hits);
      b.push_back(blow);
    }

    bool f1 = true;
    int comb = (1<<L) - 1;
    while(comb < (1<<10)){
      v.clear();
      for(int i=0;i<10;i++){
	if( (comb>>i) & 1)v.push_back(i);
      }

      bool f2 = true;
      for(int i=0;i<H;i++){
	int sum = 0;
	for(int j=0;j<L;j++){
	  for(int k=0;k<L;k++){
	    if(v[j] == t[i][k] - '0'){
	      sum++;
	      break;
	    }
	  }
	}
	if(sum != h[i]+b[i]){
	  f2 = false;
	  break;
	}
      }
      
      if(f2){
	do{
	  bool f3 = true;
	  for(int i=0;i<H;i++){
	    hits = 0;
	    for(int j=0;j<L;j++){
	      if(v[j] == t[i][j]-'0'){
		hits++;
		if(hits>h[i])break;
	      }
	    }
	    if(hits!=h[i]){
	      f3 = false;
	      break;
	    }
	  }
	  if(f3){
	    if(ans.size()){
	      f1 = false;
	      break;
	    }else{
	      ans = v;
	    } 
	  }
	}while(next_permutation(v.begin(),v.end()));
      }
    
      if(!f1)break;
      int x = comb & -comb, y = comb + x;
      comb = ( ( ( comb & ~y )/x )>>1 )|y;
    }
    if(f1 && ans.size()){
      for(int i=0;i<L;i++)cout << ans[i];
      cout << endl;
    }else{
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 928
// https://atcoder.jp/contests/abc107/tasks/abc107_a

#[allow(unused)]
use std::cmp::{max, min};
#[allow(unused)]
use std::collections::{HashSet, VecDeque};
use std::io;
use std::io::{BufRead, Read, Write};
use std::str::FromStr;

#[allow(unused, non_snake_case)]
pub fn solve<R: BufRead, W: Write>(mut io: Io<R, W>) {
    let N: usize = io.next();
    let i: usize = io.next();
    let res: usize = N - i + 1;
    io.println(res);
}

#[allow(dead_code)]
fn main() {
    let stdin = io::stdin();
    let stdin_lock = stdin.lock();
    let stdout = io::stdout();
    let stdout_lock = stdout.lock();

    let io = Io {
        reader: stdin_lock,
        writer: stdout_lock,
    };

    solve(io);
}

/* IO helpers */

pub struct Io<R, W>
where
    R: BufRead,
    W: Write,
{
    pub reader: R,
    pub writer: W,
}

#[allow(dead_code)]
impl<R, W> Io<R, W>
where
    R: BufRead,
    W: Write,
{
    fn println<T: std::fmt::Display>(&mut self, value: T) {
        writeln!(&mut self.writer, "{}", value).expect("Unable to write");
    }

    fn print<T: std::fmt::Display>(&mut self, value: T) {
        write!(&mut self.writer, "{}", value).expect("Unable to write");
    }

    fn debug<T: std::fmt::Debug>(&mut self, value: T) {
        writeln!(&mut self.writer, "{:?}", value).expect("Unable to write");
    }

    fn next<T: FromStr>(&mut self) -> T {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok().expect("Unable to parse")
    }

    fn nexts<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next::<T>()).collect::<Vec<T>>()
    }
}

/* Structure helpers */

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}


Measured memory_bytes: 4352
import sys
from collections import deque
sys.setrecursionlimit(10**6)


def main(input, print):
    move = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    move2 = [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2),
             (-1, -2), (-1, -1), (-1, 1), (-1, 2),
             (0, -2), (0, 2),
             (1, -2), (1, -1), (1, 1), (1, 2),
             (2, -2), (2, -1), (2, 0), (2, 1), (2, 2)]

    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    table = [input() for _ in range(H)]
    path = [[-1 for _ in range(W)] for _ in range(H)]

    que = deque()
    path[Ch-1][Cw-1] = 0
    que.append((Ch-1, Cw-1))
    while que:
        y, x = que.popleft()
        cnt = path[y][x]

        for k in range(len(move)):
            i, j = move[k]
            nx = x+i
            ny = y+j
            if ny < 0 or nx < 0 or ny >= H or nx >= W:
                continue
            if table[ny][nx] == '#':
                continue
            if path[ny][nx] == -1 or path[ny][nx] > cnt:
                path[ny][nx] = cnt
                que.appendleft((ny, nx))

        for k in range(len(move2)):
            i, j = move2[k]
            nx = x+i
            ny = y+j
            if ny < 0 or nx < 0 or ny >= H or nx >= W:
                continue
            if table[ny][nx] == '#':
                continue
            if path[ny][nx] == -1 or path[ny][nx] > cnt+1:
                path[ny][nx] = cnt+1
                que.append((ny, nx))
    if(path[Dh-1][Dw-1] == -1):
        print(-1)
    else:
        print(path[Dh-1][Dw-1])


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 86904
#include <cmath>
#include <cstdio>
#include <algorithm>
#define rg register
#define llint long long
using namespace std;
const int N=1008611;

struct ios
{
	template <typename _tp>
	inline ios operator >> (_tp &x)
	{
		x = 0;int f = 1;char c = getchar();
		for(;c<'0'||c>'9';c=getchar()) if(c=='-') f = -1;
		for(;c<='9'&&c>='0';c=getchar()) x = (x<<1)+(x<<3)+(c^48);
		x *= f;
		return *this;
	}
	template <typename _tp>
	inline ios operator << (_tp x)
	{
		char s[66];int dgt = 0;
		if(x==0) putchar('0');
		if(x<0) putchar('-'),x = -x;
		while(x) ++dgt,s[dgt] = x%10+'0',x/=10;
		while(dgt) putchar(s[dgt]),--dgt;
		return *this;
	}
	inline ios operator << (char x)
	{
		putchar(x);
		return *this;
	}
}io;

int n,d;

int main()
{
	io >> n >> d;
	io << (int)ceil(n/(d*2.0+1.0)) << '\n';
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define N 100005
#define LL long long
using namespace std;
vector<int> G[N];
LL ans,B[N],d;
int n,S,T,vis[N],A[N],C[N];
struct node{
	LL x,y; int num;
	node(LL _x=0,LL _y=0,int _num=0){ x=_x,y=_y,num=_num;}
}a[N];
bool cmp(node p,node q){ return p.x<q.x||(p.x==q.x&&p.y<q.y);}
void work(int u,int v)
{
	int i,j,p=0,q=0,l,r;
	sort(a+1,a+n+1,cmp);
	memset(A,0,sizeof(A));
	memset(C,0,sizeof(C));
	for(i=1;i<=n;i++){
		while(a[p+1].x<=a[i].x-u) p++;
		while(a[q+1].x<a[i].x-u) q++;
		l=q,r=q;
		for(j=16;j>=0;j--) if(l+(1<<j)<=p&&a[l+(1<<j)].y<a[i].y-v) l+=(1<<j);
		for(j=16;j>=0;j--) if(r+(1<<j)<=p&&a[r+(1<<j)].y<=a[i].y+v) r+=(1<<j);
		if(l>=r) continue;
		A[l+1]++,A[r]--;
		B[a[i].num]+=r-l;
		C[l+1]++,C[r+1]--;
		G[a[i].num].push_back(a[l+1].num);
		G[a[l+1].num].push_back(a[i].num);
	  }
	for(i=1;i<=n;i++)
		C[i]+=C[i-1],B[a[i].num]+=C[i];
	for(i=1;i<n;i++){
		A[i]+=A[i-1];
		if(!A[i]) continue;
		G[a[i].num].push_back(a[i+1].num);
		G[a[i+1].num].push_back(a[i].num);
	  }
}
void dfs(int t)
{
	int i; vis[t]=1,ans+=B[t];
	for(i=0;i<G[t].size();i++)
		if(!vis[G[t][i]]) dfs(G[t][i]);
}
int main()
{
	int i;
	scanf("%d %d %d",&n,&S,&T);
	for(i=1;i<=n;i++)
		scanf("%lld %lld",&a[i].x,&a[i].y),a[i].num=i;
	d=abs(a[S].x-a[T].x)+abs(a[S].y-a[T].y);
	for(i=1;i<=n;i++)
		a[i].x+=a[i].y,a[i].y=a[i].x-2*a[i].y;
	work(d,d);
	for(i=1;i<=n;i++) swap(a[i].x,a[i].y);
	work(d,d-1);
	dfs(S);
	cout<<ans/2;
	return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iterator>
using namespace std;

int main() {

	int r, c;
	cin >> r >> c;

	vector<vector<int>> mat(r);
	for (auto& row : mat) {
		copy_n(istream_iterator<int>(cin), c, back_inserter(row));
		row.push_back(accumulate(row.begin(), row.end(), 0));
	}

	vector<int> sums(c + 1);
	for (size_t i = 0; i < sums.size(); i++) {
		for (auto& row : mat) {
			sums[i] += row[i];
		}
	}
	mat.push_back(sums);

	for (auto& row : mat) {
		for (size_t i = 0; i < row.size(); i++) {
			cout << ((i == 0) ? "" : " ") << row[i];
		}
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  
  ll n;
  cin >>n;
  if(n%2 == 1){
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  for(int i=1;pow(5,i)<=n;i++){
    ans += n/(long long)(pow((long double)5,i)*2);
  }
  cout << ans << endl;
}


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

#define INF 0x3f3f3f3f

using namespace std;

int h, w, k;
int s[43][1043];
int dfs[43];
int ans = INF;

void Dfs(int d) {
  if (d == h) {
    int cnt = 0;
    for (int i = 1; i <= h; ++i) {
      cnt += dfs[i];
    }
    int sum[1043];
    memset(sum, 0, sizeof(sum));
    for (int j = 1; j <= w; ++j) {
      bool flag = false;
      int id = 1;
      for (int i = 1; i <= h; ++i) {
        sum[id] += s[i][j];
        if (dfs[i] == 1) {
          if (sum[id] > k) {
            flag = true;
            break;
          }
          ++id;
        }
      }
      if (sum[id] > k) {
        flag = true;
      }
      if (flag) {
        ++cnt;
        id = 1;
        memset(sum, 0, sizeof(sum));
        for (int i = 1; i <= h; ++i) {
          sum[id] += s[i][j];
          if (dfs[i] == 1) {
            if (sum[id] > k) {
              return;
            }
            ++id;
          }
        }
        if (sum[id] > k) {
          return;
        }
      }
    }
    ans = min(ans, cnt);
    return;
  }
  Dfs(d + 1);
  dfs[d] = 1;
  Dfs(d + 1);
  dfs[d] = 0;
}

int main(int argc, char const *argv[]) {
  cin >> h >> w >> k;
  for (int i = 1; i <= h; ++i) {
    char gar[1043];
    for (int j = 1; j <= w; ++j) {
      cin >> gar[j];
      s[i][j] = gar[j] - '0';
    }
  }

  Dfs(1);

  cout << ans << endl;

  return 0;
}


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

int solve(int *dp, int *A, int i, int k) {
    if(dp[i] >= 0) return dp[i];
    int mini = INT_MAX;
    for(int j = i-k; j < i; j++) {
        mini = min(mini, solve(dp, A, j, k) + abs(A[i]-A[j]));
    }
    dp[i] = mini;
    return dp[i];
}

int main() {
    int n, k;
    cin >> n >> k;
    int A[n], dp[n];
    for(int i = 0; i < n; i++) {
        cin >> A[i];
        dp[i] = -1;
    }
    dp[0] = 0;
    for(int i = 1; i < k && i < n; i++) {
        int mini = INT_MAX;
        for(int j = 0; j < i; j++) {
            mini = min(mini, dp[j] + abs(A[i]-A[j]));
        }
        dp[i] = mini;
    }
    cout << solve(dp, A, n-1, k);
    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define all(v) (v).begin(), (v).end()

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

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

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m,k; cin>>n>>m>>k;
  rep(i,n+1){
    rep(j,m+1){
      ll now=i*m-i*j+j*n-i*j;
      if(now==k){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin>>n;
    const int INF = 1e9;
    vector<vector<int> > h(n, vector<int> (3));
    for(int i =0; i<n; i++) 
        cin>>h[i][0]>>h[i][1]>>h[i][2];
    

    vector<vector<int> > dp(n, vector<int> (3,0));

    for(int i = 0; i< n; i++)
    {   
        for(int j = 0; j<3; j++)
        {
            if(i==0)
                dp[i][j] = h[i][j];
            
            else 
                dp[i][j] = h[i][j] + max(dp[i-1][(j+1)%3] , dp[i-1][(j+2)%3]);

        }
    }
    
    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<"\n";
}

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

int main(){
        int i,p;
        double n,k,prob_eye,prob=0;
        cin >> n >> k;
        for(i=1;i<n+1;++i){
                p = 0;
                prob_eye = 1.0/n;
                if(i<k){
                        while(i*pow(2.0,p)<k) ++p;
                        prob_eye *= 1.0/pow(2.0,p);
                }
                prob += prob_eye;
        }
        printf("%.10lf\n",prob);
        return 0;
}

Measured memory_bytes: 4172
#include <iostream>
#include<set>
#include<vector>
#include<string>
#include<iterator>
#include<iomanip>
#include<cmath>
#include<map>
#include<string.h>
#include<algorithm>

using namespace std;
void ll(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);
}
const int N = 1e3 + 3;
int main() {

	ll();
	
	int a, b, c, d,r1,r2;
	cin >> a >> b >> c >> d;
	r1 = a*b;
	r2 = c*d;
	if (r1 > r2)
		cout << r1 << endl;
	else
		cout << r2 << endl;
}

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

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

  if (N % 500 == 0) {
    cout << "Yes" << endl;
  }
  else if (N % 500 < A) {
    cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<string>
#include<vector>
int main() {
	int n;
	while (std::cin >> n)
	{
		std::vector<bool> v(n + 1 ,false);
		int c = 0;
		v[0] = true, v[1] = true;
		for (int i = 2; i * i <= n ; ++i) {
			if (!v[i]) {
				for (int j = i * i; j <= n; j += i) {
					if (!v[j])c++;
					v[j] = true;
				}
			}
		}

		std::cout << n-c-1 << std::endl;
	}
}

Measured memory_bytes: 3236
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;  
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()
          
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;

const ll   N     =  5e3+8;
const ll   mod   =  998244353;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, a, b, c, k;

void solve(){
	cin>>a>>b>>c>>k;
	int ct = 0;
	while(b <= a) b *= 2, ct++;
	while(c <= b) c *= 2, ct++;
	if(ct <= k) deb1("Yes")
	else deb1("No")
}

int main(){
    fastio;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve();
    }
    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<int, int>pi;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll dp[16][10010],ans;

int h, n, x, y;
bool b[4][10010];

int cul(int x) {
	int sum = 0;
	for (int i = 0;i < 4;i++) {
		if (b[i][x])sum += (1 << i);
	}
	return sum;
}

int main() {
	cin >> h >> n;
	for (int i = 0;i < n;i++) {
		cin >> x >> y;
		b[x][y] = 1;
	}
	for (int i = 0;i < 16;i++) {
		for (int j = 0;j < h;j++) {
			dp[i][j] = -1;
		}
	}
	dp[cul(0)][0] = 0;
	for (int i = 0;i < h - 1;i++) {
		for (int j = 0;j < 16;j++) {
			if (dp[j][i] == -1)continue;
			if (j == 6 || j == 10 || j == 5 || j == 15 || j == 7 || j == 14 || j == 11 || j == 13) {
				dp[cul(i + 1)][i + 1] = max(dp[j][i], dp[cul(i + 1)][i + 1]);
			}
			if (j == 2 || j == 3) {
				if (!b[2][i + 1] && !b[3][i + 1])dp[cul(i + 1) + 12][i + 1] = max(dp[cul(i + 1) + 12][i + 1], dp[j][i] + 1);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
			if (j == 4 || j == 12) {
				if (!b[0][i + 1] && !b[1][i + 1])dp[cul(i + 1) + 3][i + 1] = max(dp[cul(i + 1) + 3][i + 1], dp[j][i] + 1);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
			if (j == 1) {
				if (!b[1][i + 1] && !b[2][i + 1])dp[cul(i + 1) + 6][i + 1] = max(dp[cul(i + 1) + 6][i + 1], dp[j][i] + 1);
				if (!b[2][i + 1] && !b[3][i + 1])dp[cul(i + 1) + 12][i + 1] = max(dp[cul(i + 1) + 12][i + 1], dp[j][i] + 1);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
			if (j == 8) {
				if (!b[0][i + 1] && !b[1][i + 1])dp[cul(i + 1) + 3][i + 1] = max(dp[cul(i + 1) + 3][i + 1], dp[j][i] + 1);
				if (!b[1][i + 1] && !b[2][i + 1])dp[cul(i + 1) + 6][i + 1] = max(dp[cul(i + 1) + 6][i + 1], dp[j][i] + 1);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
			if (j == 9) {
				if (!b[1][i + 1] && !b[2][i + 1])dp[cul(i + 1) + 6][i + 1] = max(dp[cul(i + 1) + 6][i + 1], dp[j][i] + 1);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
			if (j == 0) {
				if (!b[0][i + 1] && !b[1][i + 1])dp[cul(i + 1) + 3][i + 1] = max(dp[cul(i + 1) + 3][i + 1], dp[j][i] + 1);
				if (!b[1][i + 1] && !b[2][i + 1])dp[cul(i + 1) + 6][i + 1] = max(dp[cul(i + 1) + 6][i + 1], dp[j][i] + 1);
				if (!b[2][i + 1] && !b[3][i + 1])dp[cul(i + 1) + 12][i + 1] = max(dp[cul(i + 1) + 12][i + 1], dp[j][i] + 1);
				if (!b[0][i + 1] && !b[1][i + 1] && !b[2][i + 1] && !b[3][i + 1])dp[15][i + 1] = max(dp[15][i + 1], dp[j][i] + 2);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
		}
	}
	for (int i = 0;i < 16;i++) {
		ans = max(ans, dp[i][h - 1]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4388
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>

using namespace std;

const int MAXN = 400 + 10;
const int MAXM = 100000 + 1000;

int n, m;
int ax[MAXM], ay[MAXM];
bitset<MAXN> s[MAXN];
bool die[MAXN];

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n >> m;
	for(int i = 1; i <= m; i++)
		cin >> ax[i] >> ay[i];
	for(int i = 1; i <= n; i++)
		s[i][i] = 1;
	for(int t = m; t >= 1; t--)
	{
		int x = ax[t], y = ay[t];
		for(int i = 1; i <= n; i++)
			if(!die[i])
			{
				if(s[i][x] && s[i][y])
					die[i] = true;
				else if(s[i][x])
					s[i][y] = true;
				else if(s[i][y])
					s[i][x] = true;
			}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
		if(!die[i])
			for(int j = i + 1; j <= n; j++)
				if(!die[j])
					if((s[i] & s[j]).count() == 0)
						ans++;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        long d = long.Parse(input[1]);

        int r = 0;
        for (int i = 0; i < n; i++)
        {
            string[] input2 = Console.ReadLine().Split(' ');
            long x = long.Parse(input2[0]);
            long y = long.Parse(input2[1]);
            long p = d * d;
            long s = x * x + y * y;
            if (p >= s)
            {
                r++;
            }
        }
        Console.WriteLine(r);
    }
}


Measured memory_bytes: 21944
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                cnt += 1
print(cnt)

Measured memory_bytes: 9108
s = list(input())
count = 0
abc = 0

a_series = 0

for i in range(len(s)):
  #print(i, abc)
  if s[i] == 'A':
    if abc != 1:
      a_series = 0
    a_series += 1
    abc = 1
  elif s[i] == 'B':
    if abc == 1:
      abc = 2
    else:
      abc = 0
      a_series = 0
  elif s[i] == 'C':
    if abc == 2:
      abc = 1
      count += a_series
    else:
      abc = 0
      a_series = 0
      
print(count)

Measured memory_bytes: 4840
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

void chmin(int &a, int b) { a = min(a, b); }

int INF = 1e+15;
int n, k;
int h[100102];
int dp[100102];

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

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int field[110][110];

int main(){
  int h,w; cin >> h >> w;
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  priority_queue<int, vector<int>, greater<int>> q;
  rep(i,n){
    rep(j,a[i]){
      q.push(i+1);
    }
  }
  rep(i,h){
    if(i%2==0){
      rep(j,w){
        field[i][j]=q.top(); q.pop();
      }
    }
    else{
      for(int j=w-1;j>=0;j--){
        field[i][j]=q.top(); q.pop();
      }
    }
  }
  rep(i,h){
    rep(j,w){
      cout << field[i][j] << " ";
    }cout << endl;
  }
}

Measured memory_bytes: 512
/**
 * auther: moririn_cocoa
 */
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
#define ll long long
#define pll pair<ll,ll>
#define pq priority_queue
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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;}

int main(int argc, const char * argv[]) {
  
  int A;
  int B;
  int C;
  int D;
  
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> D;
  
  cout << min ( A,B ) + min ( C,D ) << endl;
  
  return 0;
}


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

int main()
{
	int n, h,c=0;
  cin >> n >> h;
  	int a[n];
 
  for(int i=0;i<n;i++){
    cin >> a[i];
   	if(a[i]>=h)
      c++;}
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include<cstring>
#include<stdio.h>
using namespace std;
int Xi[115]; int Li[115];int yes[115] ;
int  main() {
	int N = 0, K = 0, S = 0;
	cin >> N >> K >> S;
	for (int i =0;i<N;i++)
	{
		if (i < K) { cout << S << " "; continue; }
		(i < N) ? (cout << 109<<" ") : (cout << endl);
	}






	return 0;

}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
int main() {
    using namespace std;
    long long n,k,a[200000];
    cin>>n>>k;
    for (long long j = 0; j < n; ++j) {
        cin>>a[j];

    }
    for (long long i = 0; i < n-k; ++i) {
        if (a[i]<a[i+k])
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 5176
#include <iostream>
#include <cstdio>
typedef long long LL;
using namespace std;

int main()
{
    LL n,k,ans;
    while(scanf("%lld%lld",&n,&k) == 2)
    {
        ans = 0;
        if(k)
        {
            for(LL i = k + 1; i <= n; i++)
            {
                LL yu = n%i - k + 1;
                ans += n/i*(i-k) + (yu>0?yu:0);
            }
        }
        printf("%lld\n",k?ans:n*n);
    }
    return 0;
}


Measured memory_bytes: 256
import math

mod = 1000000007

def solve():
    (n,m) = map(int,input().split())
    if(abs(n-m)>1):
        return 0
    if(n==m):
        return (math.factorial(n)**2 * 2) % mod
    if(n > m):
        return (math.factorial(m)**2 * n) % mod
    else:
        return (math.factorial(n)**2 * m) % mod

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


Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int N,M;
  cin>>N>>M;
  vector<string>A(N),B(M);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int i=0;i<M;i++){
    cin>>B[i];
  }
  for(int i=0;i<=N-M;i++){
    for(int j=0;j<=N-M;j++){
      bool ok=true;
      for(int p=0;p<M;p++){
        for(int q=0;q<M;q++){
          int x=i+p,y=j+q;
          if(B[p][q]!=A[y][x]){
            ok=false;
          }
        }
      }
      if(ok){cout<<"Yes"<<endl;return 0;}
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3636
a, b, h, m = gets.split.map(&:to_i)

theta = 1.0 * (60 * h - 11 * m).abs / 360
theta = 2 - theta if theta > 1
puts Math.sqrt(a ** 2 + b ** 2 - 2 * a * b * Math.cos(Math::PI * theta))



Measured memory_bytes: 14596
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
const ll mod = 1000000007;
const ll mod9 = 1000000009;
const ll MINT = -1000000007;

ll dp[55][15];
ll dp_sc[55];
ll dp_mx[55];
ll ans;
ll a_t0;
ll a_t1;
ll ans_t;
ll an_t[10];
ll n,m,q;
ll ain[55][5];

ll ssc(ll sb,ll ss,ll sm,ll abit){
    ll aa,ab;
    aa = 0,ab = 0;
    if(sb<m-1){
        abit &= ~(1<<sm);
        aa = ssc(sb+1,ss,sm+1,abit);
    }
    if(ss<n){
        abit |= (1<<sm);
        ab = ssc(sb,ss+1,sm+1,abit);
    }
    if(sm==m+n-1){
        rep(i,10) an_t[i]=0;
        a_t0 = 1;
        a_t1 = 0;
        ans_t = 0;
        rep(i,m+n-1){
            if(abit & (1<<i)){
                an_t[i-(a_t0-1)]=a_t0;
            }else{
                a_t0++;
            }
             // printf("i: %lld a_t0:%lld   ",i,a_t0);
        }
        rep(i,q){
            if(an_t[ain[i][1]-1]-an_t[ain[i][0]-1] == ain[i][2]){
                ans_t += ain[i][3];
            }
        }
        ans = ans_t;
        /* rep(j,n){
            if(!j) printf("\n");
            printf("%lld ",an_t[j]);
        }
            printf("  %lld ",abit);
            printf("ans : %lld ",ans);*/
        return ans;
    }
    return max(aa,ab); 
}

signed main(){
    cin>>n>>m>>q;
    // vector<pair<pair<ll,ll>,pair<ll,ll>>> a(q);
    rep(i,q){
        rep(j,4) {
            cin>>ain[i][j];
        }
    }
    /* rep(i,q){
        rep(j,4){
            if(!j) printf("\n");
            printf(" %lld ",ain[i][j]);
        }
    }*/
    // cout<<" "<<endl;
    ll res = ssc(0,0,0,0);    
    cout<<res<<endl;
}


Measured memory_bytes: 3608
import sys
input = sys.stdin.readline

N = int(input())
S = [input().rstrip() for _ in range(N)]

A = []
B = []

for s in S:
    a = 0
    k = 0
    for i in range(len(s)):
        if s[i] == ')':
            k += 1
        else:
            k -= 1
        a = max(a, k)
    b = 0
    k = 0
    for i in range(len(s))[::-1]:
        if s[i] == '(':
            k += 1
        else:
            k -= 1
        b = max(b, k)
    A.append(a)
    B.append(b)

L = []
R = []

for i in range(N):
    if B[i] - A[i] >= 0:
        L.append((A[i], i))
    else:
        R.append((B[i], i))

L.sort()
R.sort(reverse=True)

T = []

for a, i in L:
    T.append(S[i])

for b, i in R:
    T.append(S[i])

T = ''.join(T)

k = 0

for t in T:
    if t == '(':
        k += 1
    else:
        k -= 1
    if k < 0:
        print('No')
        break
else:
    if k == 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 238700
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++);
#define FOR(i, m, n) for(int i = m; i < n; i++);
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int length = SIZE(s);
    for(int i =0; i<length; i++){
        cout << "x";
    };
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
const int MOD=1e9+7;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
//int make_cp[25][25][25];
int if_will[25][25];
LL dp[25][2500000];
inline int func(int x) 
{ 
int countx = 0; 
while(x) 
{ 
countx ++; 
x = x&(x-1); 
} 
return countx; 
}
int main(){
	dp[0][0]=1;
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	rb(i,1,n){
		rb(j,1,n){
			cin>>if_will[i][j];
		}
	}
	int upper=(1<<n)-1;
//	rb(i,1,n){
	rb(j,0,upper){
		int i=func(j);
		rb(k,1,n){
			if((j>>(k-1))&1){
				if(if_will[i][k]){
					dp[i][j]+=dp[i-1][(j)^(1<<(k-1))];
					dp[i][j]%=MOD;
				}
			}
		}
	}
	cout<<dp[n][upper]<<endl;
	return 0;
}

Measured memory_bytes: 334080
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
const int N=1e5+5;
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;int a[N];
int main(){
	n=read();rep(i,1,n)a[read()]=i;
	rep(i,1,n)printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=1;i<=n;i++){
    
    for(int j=0;j<n;j++){
      cout<<a[j];
      if(j!=n-1)cout<<" ";
    }cout<<endl;
    
    for(int j=0;j<i;j++){
      if(a[i-j-1]>a[i-j])swap(a[i-j-1],a[i-j]);
      else break;
    }

  }
  return 0;
}

Measured memory_bytes: 3096
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j;
  int A[N+1];
  int key;
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  

  for(i=1;i<=n;i++){
    key=A[i];
    j=i-1;
    while((j>=0) && (A[j]>key)){
      A[j+1]=A[j];
      j--;
      A[j+1]=key;
    }
    trace(A, n);
  }
    
  return 0;
}

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

int main(){

    int D;
    cin >> D;

    if(D == 22) cout << "Christmas Eve Eve Eve" << endl;
    else if(D == 23) cout << "Christmas Eve Eve" << endl;
    else if(D == 24) cout << "Christmas Eve" << endl;
    else if(D == 25) cout << "Christmas" << endl;

    return 0;
}

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

const int N = 100005;
const int M = 200005;

int n, m;
vector< pair<int,int> > G[N];
bool vis[N];
int dep[N];
int deg[N];

void dfs(int u) {
	vis[u] = 1;
	for (auto e : G[u]) {
		if (!vis[e.second]) {
			dep[e.second] = dep[u] + e.first;
			dfs(e.second);
		} else {
			if (dep[e.second] != dep[u] + e.first) {
				cout << "No\n"; exit(0);
			}
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	while(m--) {
		int l, r, d; cin >> l >> r >> d;
		G[l].push_back(make_pair(d, r));
		G[r].push_back(make_pair(-d, l));
		deg[r]++;
	}

	for (int i = 1; i <= n; ++i) if (!deg[i]) {
		dfs(i);
	}

	for (int i = 1; i <= n; ++i) if (!vis[i]) {
		cout << "No\n"; return 0;
	}

	cout << "Yes\n";
}

Measured memory_bytes: 11520
{-#LANGUAGE BangPatterns#-}
import Data.Functor
import Control.Monad

main::IO ()
main=
  do
    n <- read <$> getLine::IO Int
    numList <- replicateM n (read <$> getLine)::IO [Int]
    let output=length . filter isPrime $ numList
    print output

isPrime::Integral a=>a->Bool
isPrime n=isPrime' n 2
  where
    isPrime' !a !x
      |floor (sqrt (fromIntegral a)) < x =True
      |otherwise =
        case a `mod` x of
          0->False
          _->isPrime' a (x+1)

Measured memory_bytes: 9308
# 終了状態は2種の数からなる、長さが偶数
# 長さ偶数で手番を迎え続ける側が厳しい
# 両端が異なるなら奇数側が生存確定
# 両端が同一なら偶数側が生存確定

S = input()
L = len(S)
x,y = S[0],S[-1]

odd = L&1
same = (x == y)

first = odd ^ same

answer = 'First' if first else 'Second'

print(answer)


Measured memory_bytes: 3316
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


vector<vector<ll>> edge;
ll n,k;
ll ans=0;

ll dfs(ll w,ll p){
    ll h=1;
    for(auto &I:edge[w]){
        if(I!=p){h=max(h,dfs(I,w)+1);}
    }
    if(h==k && p!=0){ans++; return 0;}
    return h;
}


int main(){
    cin>>n>>k;
    vector<ll> a(n);
    for(auto &I:a){cin>>I; I--;}
    if(a[0]!=0){ans++; a[0]=0;}
    edge.resize(n);
    for(int i=1;i<n;i++){
        edge[a[i]].push_back(i);
    }
    dfs(0,0);
    cout<<ans<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 11136
if __name__ == '__main__':
    data = input().split()
    stack = []

    for i in data:
        if i == '+':
            rhv = stack.pop()
            lhv = stack.pop()
            stack.append(lhv + rhv)
        elif i == '-':
            rhv = stack.pop()
            lhv = stack.pop()
            stack.append(lhv - rhv)
        elif i == '*':
            rhv = stack.pop()
            lhv = stack.pop()
            stack.append(lhv * rhv)
        else:
            stack.append(int(i))
    
    print(stack.pop())


Measured memory_bytes: 5596
package main

import "fmt"

type edge struct {
	from int
	to   int
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	m := make(map[edge]int, N)
	var x, y int
	for i := 0; i < M; i++ {
		fmt.Scan(&x, &y)
		e := edge{from: x, to: y}
		m[e]++
	}

	found := false
	for i := 1; i <= N; i++ {
		if i == 1 {
			if m[edge{from: 1, to: N}] != 0 {
				found = true
				break
			}
		} else {
			if m[edge{from: 1, to: i}] != 0 && m[edge{from: i, to: N}] != 0 {
				found = true
				break
			}
		}
	}

	if found {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


Measured memory_bytes: 13184
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

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

using namespace std;
int main() {
	char a, b;
	cin >> a >> b;

	if (a == b)
		cout << "H" << endl;
	else
		cout << "D" << endl;

	return 0;
}


Measured memory_bytes: 256