akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <string>
using namespace std;
int main()
{
	string s, t, r;
	cin >> s >> t;
	int lens = s.size();
    int lent = t.size();
    for(int i = 0; i < lens; i++)
    {
        if(s[i] == '?' || s[i] == t[0])
        {
            string tmp = s;
            for(int j = 0; j < i; j++) if(tmp[j] == '?') tmp[j] ='a';
            bool mark = false;
            for(int j = 0; j < lent; j++)
            {
                if(tmp[i+j]!= '?' && tmp[i+j] != t[j]) 
                    break;
                tmp[i+j] = t[j];
                if(j == lent - 1) mark = true;
            }
            if(mark)
            {
                for(int j = i + lent; j < lens; j++) if(tmp[j] == '?') tmp[j] = 'a';
                r=tmp;
            }
        }
    }
    if(r.size() == 0) cout << "UNRESTORABLE" << endl;
    else cout << r << endl;
    return 0;
}

Measured memory_bytes: 3616
let id x = x

let rec iteri f s t = if s > t then () else begin f s; iteri f (s + 1) t end

let rec read n = if n <= 0 then ([],[])
                 else let x, y = Scanf.scanf "%d,%d\n" (fun x y -> (x, y)) in 
                      let (xs, ys) = read (n - 1) in (x::xs, y::ys)

let solve dp vs ws n w =
  iteri (fun i -> 
         iteri (fun j -> 
                if j >= ws.(i) then dp.(i+1).(j) <- max dp.(i).(j) (dp.(i).(j - ws.(i)) + vs.(i)) 
                else dp.(i+1).(j) <- dp.(i).(j)) 0 w) 0 (n - 1)

let rec min_w dp i j v = 
  if dp.(i).(j) = v then min_w dp i (j - 1) v else j + 1

let _ =
  let cnt = ref 0 in
  try
    while true do
      let w = Scanf.scanf "%d\n" id in
      if w = 0 then 
        raise End_of_file
      else
        let n = Scanf.scanf "%d\n" id in
        let dp = Array.make_matrix (n + 1) (w + 1) 0 in
        let vs', ws' = read n in
        let vs = Array.of_list vs' in
        let ws = Array.of_list ws' in
        solve dp vs ws n w;
        incr cnt;
        Printf.printf "Case %d:\n" !cnt;
        Printf.printf "%d\n" (dp.(n).(w));
        Printf.printf "%d\n" (min_w dp n w dp.(n).(w))
    done
  with
    End_of_file -> ()

Measured memory_bytes: 10852
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int N,t,ans;
pair<ll, int> a[100010];

int main() {
	cin >> N;
	ans = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &t);
		a[i].first = t;
		a[i].second = i;
	}
	sort(a, a + N);
	for (int i = 0; i < N; i += 2) {
		if ((i % 2) != (a[i].second % 2))ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<iomanip>
#include<array>
#include<string>
#include<vector>
using namespace std;
typedef int q;
typedef double w;
int main()
{
	
	string g;
	cin>>g;
	if(g=="SUN"){cout<<7;}
	else if(g=="MON"){cout<<6;}
	else if(g=="TUE"){cout<<5;}
	else if(g=="WED"){cout<<4;}
	else if(g=="THU"){cout<<3;}
	else if(g=="FRI"){cout<<2;}
	else if(g=="SAT"){cout<<1;}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
return 0;}

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

int main(void){
    
    cin >> N;
    int sum = 0;
    for(int i = 0; i < N; ++i){
        int temp;
        cin >> temp;
        sum += temp;
    }
    
    cout << sum - N << endl;
    
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
ans=[None]*N
flg=0

for i in range(M):
    s,c =map(int,input().split())
    if ans[s-1]==None:
        ans[s-1]=str(c)
    elif ans[s-1]==str(c):
        pass
    else:
        flg=1
        

if ans[0]==None:ans[0]=str(1)

for i in range(1,N):
    if ans[i]==None:ans[i]=str(0)
        
num=int("".join(ans))

if M==0:
    if N==1:
        print(0)
    elif N==2:
        print(10)
    else:
        print(100)
elif len(str(num))!=N or flg==1:
    print(-1)
else:
    print(num)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{

    lli n, y;
    cin>>n>>y;
    for(int i = 0; i <= 2000; i ++) {
        for(int j = 0; j <= 2000; j ++) {
            lli z = n - i - j;
            if(z < 0) {
                continue ;
            }
            lli t = i * 10000 + j * 5000 + z * 1000;
            if(t == y) {
                cout<<i<<' '<<j<<' '<<z;
                return ;
            }

        }
    }
    cout<<"-1 -1 -1";
    cout<<"\n";
    return ;
}

/*
*/

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

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


Measured memory_bytes: 256
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
typedef long long ll;
const int MYINF = 1e9+7;

static char save_suit[64];
static int  save_rank[64];
static int  save_seq[64];
static char suit[64];
static int  rank[64];
static int  seq[64];
static int N;

void swap(int i, int j) {
	int tmp;
	tmp = suit[i];
	suit[i] = suit[j];
	suit[j] = tmp;

	tmp = rank[i];
	rank[i] = rank[j];
	rank[j] = tmp;

	tmp = seq[i];
	seq[i] = seq[j];
	seq[j] = tmp;
}

void bubble_sort() {
	int i, j;
	for (i = 0; i < N; i++) {
		for (j = N - 1; j > i; j--) {
			if (rank[j] < rank[j-1]) swap(j, j-1);
		}
	}
}

void selection_sort() {
	int i, j, mini;
	for (i = 0; i < N; i++) {
		mini = i;
		for (j = i; j < N; j++) {
			if (rank[j] < rank[mini]) mini = j;
		}
		if (i != mini) swap(i, mini);
	}
}

int is_stable() {
	int i;
	for (i = 1; i < N; i++) {
		if (rank[i] > rank[i-1]) continue;
		if (seq[i] < seq[i-1]) return 0;
	}
	return 1;
}

void reset() {
	int i;
	for (i = 0; i < N; i++) {
		suit[i] = save_suit[i];
		rank[i] = save_rank[i];
		seq[i] = save_seq[i];
	}
}

void print_cards() {
	int i;
	const char *sp = "";
	for (i = 0; i < N; i++) {
		printf("%s%c%d", sp, suit[i], rank[i]);
		sp = " ";
	}
	putchar('\n');
}

int main(int argc, char **argv)
{
	int i;
	char buf[16];

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%s", buf);
		save_suit[i] = buf[0];
		save_rank[i] = buf[1] - '0';
		save_seq[i] = i;
	}

	reset();
	bubble_sort();
	print_cards();
	if (is_stable()) puts("Stable");
	else puts("Not stable");

	reset();
	selection_sort();
	print_cards();
	if (is_stable()) puts("Stable");
	else puts("Not stable");

	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

using Tree = vector<vector<int>>;

void dfs(Tree &tree, vector<int> &dis, int cur, int cnt) {
    dis[cur] = cnt;
    for(int child : tree[cur]) {
        if(dis[child] == INF) {
            dfs(tree, dis, child, cnt+1);
        }
    }
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n-1), b(n-1);
    REP(i, n-1) cin >> a[i] >> b[i];

    Tree tree(n);

    REP(i, n-1) {
        tree[a[i]-1].push_back(b[i]-1);
        tree[b[i]-1].push_back(a[i]-1);
    }

    vector<int> f_dis(n, INF), s_dis(n, INF);
    dfs(tree, f_dis, 0, 0);
    dfs(tree, s_dis, n-1, 0);

    int f_num = 0, s_num = 0;
    REP(i, n) {
        (f_dis[i] <= s_dis[i] ? f_num : s_num) += 1;
    }

    cout << (f_num > s_num ? "Fennec" : "Snuke") << endl;
}

Measured memory_bytes: 12160
#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()
#define chmin(x,y) x = min(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int N;
vector<int> x(10), y(10);

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

int main() {
    cin >> N;
    rep(i, N) cin >> x[i] >> y[i];
    double sum = 0.0;

    vector<int> v(N);
    rep(i, N) v[i] = i;
    do {
        rep(i, N-1) sum += dist(v[i], v[i+1]);
    } while(next_permutation(v.begin(), v.end()));

    int Factorial = 1;
    for (int i = 2; i <= N; i++) Factorial *= i;

    cout << fixed << setprecision(10) << sum / Factorial << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

def main():

    n,a,b = list(map(int, input().split()))
    s = input()
    yes_a = 0
    yes_b = 0
    
    for i in range(n):
        s_i = s[i]
        if (yes_a+yes_b) < (a+b):
            if s[i] == "a":
                print("Yes")
                yes_a += 1
            if s[i] == "b":
                if yes_b < b:
                    print("Yes")
                    yes_b += 1
                else:
                    print("No")
            if s[i] == "c":
                print("No")
        else:
            print("No")
        
    
if __name__ == "__main__":
    main()

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

using namespace std;

int main() {
	string s;
	cin >> s;
	int a = 0;
	int z = s.size() - 1;
	while (true) {
		if (s[a] == 'A') break;
		++a;
	}
	while (true) {
		if (s[z] == 'Z') break;
		--z;
	}
	cout << z - a+1 << endl;
}

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

int main()
{
    int n;
    cin>>n;
    int k,t;
    cin>>t>>k;
    double a[1010],b[1010];
    int l;
    double minx=9999999;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[i]=fabs((double)t-0.006*a[i]-k);
        if(minx>b[i]){
            minx=b[i];
            l=i;
        }
    }
    cout<<l<<endl;
    return 0;
}


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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

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

	ll N=in(),K=in();
	deque<ll> A(N);
	REP(i,N){
		A[i]=in();
	}
	vector<ll> H;
	map<int,int> M;
	int second=0,first=0;
	M[1]++;
	H.push_back(1);
	ll X[2],Y[2];
	int index=1;
	for(int i=0;;){
		M[A[i]]++;
		H.push_back(A[i]);
		if(M[A[i]]>1){
			X[second]=index;
			break;
		}
		i = A[i]-1;
		index++;
	}
	index=0;
	for(int Z=1;;){
		if(Z==H[X[first]]){
			Y[first]=index;
			break;
		}
		Z = A[Z-1];
		index++;
	}
	if(K-Y[0]<0){
		out(H[K]);
	}
	else{
		K -= Y[0];
		K %= (X[0]-Y[0]);
		out(H[Y[0]+K]);
	}
	return 0;
}


Measured memory_bytes: 15576
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	vector<pll> d;
	REP(i, n){
		ll w, v;
		cin >> w >> v;
		d.eb(w, v);
	}
	ll ans = 0;
	REPS(c, n){
		ll lim = m - d[0].first * c;
		if(lim < 0) break;
		lim = min<ll>(lim, 3 * c);
		vector<vl> dp(c + 1, vl(lim + 1, -MOD));
		dp[0][0] = 0;
		REP(i, n){
			ll w, v; tie(w, v) = d[i];
			w -= d[0].first;
			RREP(j, c)RREP(k, lim + 1){
				if(k+w <= lim) chmax(dp[j+1][k+w], dp[j][k] + v);
			}
		}
		REP(j, c+1)REP(k, lim+1) ans = max(ans, dp[j][k]);
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 540
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[]) {
	LL r, g, b, n, ans = 0;
	cin >> r >> g >> b >> n;
	for (LL i = 0; i <= n; i += r) {
		for (LL j = 0; i + j <= n; j += g) {
			if (((n - i - j) % b) == 0) {
				ans += 1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/*
TODO solve
 */
public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();

        final Map<Integer, List<Integer>> tree = new HashMap<>();
        for (int i = 0; i < n - 1; i++) {
            final int a = scanner.nextInt();
            final int b = scanner.nextInt();

            tree.computeIfAbsent(a, v -> new ArrayList<>()).add(b);
            tree.computeIfAbsent(b, v -> new ArrayList<>()).add(a);
        }

        final PriorityQueue<Integer> queue = IntStream.range(0, n)
                .mapToObj(i -> scanner.nextInt())
                .sorted(Integer::compareTo)
                .collect(Collectors.toCollection(() -> new PriorityQueue<>(Comparator.comparingInt(i -> -i))));

        final int[] vertexes = new int[n + 1];
        vertexes[1] = queue.poll();
        dfs(1, tree, vertexes, queue);

        final int sum = Arrays.stream(vertexes, 2, vertexes.length)
                .sum();
        final String numbers = Arrays.stream(vertexes, 1, vertexes.length)
                .mapToObj(Integer::toString)
                .collect(Collectors.joining(" "));

        System.out.println(sum);
        System.out.println(numbers);
    }

    private static void dfs(final int current, final Map<Integer, List<Integer>> tree, final int[] vertexes, final PriorityQueue<Integer> queue) {
        final List<Integer> nextVertexes = tree.get(current);
        for (final int next : nextVertexes) {
            if (vertexes[next] == 0) {
                vertexes[next] = queue.poll();
                dfs(next, tree, vertexes, queue);
            }
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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


Measured memory_bytes: 35724
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int ans = 0;
        for(int i=0;i<3;i++){
            if(s.charAt(i)==t.charAt(i))ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
using namespace std;
int main(){
  string s;
  getline(cin,s);
  int i,j,k;
  vector<string> v;
  for(i=0;i<s.size();i++) if(s[i]==','||s[i]=='.') s[i]=' ';
  stringstream ss(s);
  while(ss>>s) v.push_back(s);
  bool f=true;
  for(i=0;i<v.size();i++){
    if(2<v[i].size()&&v[i].size()<7){
      if(f){ cout << v[i];f=false;}
      else cout << " " << v[i];
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <stdio.h>
#include <complex>
#include <cmath>
using namespace std;
#define rep(i,p) for(int i=0;i<p;i++)
typedef complex<double> xy_t;

// ??????: a.x*b.x
double dot_product(xy_t a, xy_t b) { 
  return (conj(a)*b).real(); 
}
// ??????: a.x*b.y - b.x*a.y
// ????§???¢????¬????????????¢????????????
double cross_product(xy_t a, xy_t b) { 
  return (conj(a)*b).imag(); 
}
// ?????±: ????????¨ p ??????????????´?????? b ????????±
xy_t projection(xy_t p, xy_t b) { 
  return b*dot_product(p,b)/norm(b); 
}
xy_t P[120];
const double eps = 1e-11;
double x[4], y[4];
int N;
int main() {
  cin>>N;//????????°
  for (int t=0; t<N; ++t) {
    for (int i=0; i<4; ++i)
      cin >> x[i] >> y[i]; // x0,y0..x3,y3
      xy_t a[2] = {
      xy_t(x[0],y[0]) - xy_t(x[1],y[1]),
      xy_t(x[2],y[2]) - xy_t(x[3],y[3])
      };
    bool p = abs(cross_product(a[0],a[1])/2) < eps;
    cout << (p ? "YES" : "NO") << endl;
  }
}

Measured memory_bytes: 1228
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

const int N = 55556;

int arr[N];

//エラトステネスの篩
void Eratosthenes() {
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (int j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

}

signed main() {
	Eratosthenes();

	vector<int> vok;
	for (int i = 2; i < N; i++) {
		if (arr[i] && (i - 1) % 5 == 0) {
			vok.push_back(i);
		}
	}
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		if (i < n - 1) cout << vok[i] << " ";
		else cout << vok[i] << "\n";
	}


	return 0;
}

Measured memory_bytes: 768
#include<stdio.h>

int main(void){
        while(1){
                int h, w;
                scanf("%d %d", &h, &w);
                if(h+w==0) break;

                for(int i=0; i<h; i++){
                        for(int j=0; j<w; j++){
                                if((i+j)%2) putchar('.');
                                else putchar('#');
                        }
                        puts("");
                }
                puts("");
        }
        return 0;
}


Measured memory_bytes: 2056
# 再帰で全ての組み合わせを求める
def my_loop(n_counter, my_list):
    if n_counter == N:
        bool_list = [i >= X for i in my_list[1:]]
        if all(bool_list):
            ans.append(my_list[0])
    else:
        # 要素同士を足す
        add_list = [my_list[i] + temp[n_counter][i] for i in range(M+1)]
        my_loop(n_counter+1, my_list)
        my_loop(n_counter+1, add_list)


N, M, X = map(int, input().split())
temp = []
ans = []
for _ in range(N):
    temp.append(list(map(int, input().split())))

my_loop(0, [0]*(M+1))
print(min(ans) if len(ans) != 0 else '-1')

Measured memory_bytes: 9324
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
typedef long long ll;
clock_t time_ini = clock();
 
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, day=0, count=0, aite;
  bool shiai=1;
  cin>>n;
  vector<vector<int>> a(n,vector<int>(n-1));
  vector<bool> f(n,0);
  vector<int> memo(n,0);  
  REP(i,n) REP(j,n-1) cin>>a.at(i).at(j);

  while(shiai){
    shiai=0;
    REP(i,n) f.at(i)=0;
    REP(i,n){
      if(f.at(i) || memo.at(i)==n-1) continue;
      aite = a.at(i).at(memo.at(i));
      if(i == a.at(aite-1).at(memo.at(aite-1))-1 && !(f.at(aite-1))){
        if(!shiai) day++;
        shiai=1;        
        count++;
        f.at(i)=f.at(aite-1)=1;
        memo.at(i) += 1;
        memo.at(aite-1) += 1;
      }
    }
    if(time_diff()>1990){
      day=count=n*(n-1)/2;
	  break;
    }
  }
  
  if(count != n*(n-1)/2) day=-1;
  cout<<day;
}

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

int main(){
  int t,r;
  int a,b;
  cin >> t >> r;
  vector<int> townRoad(t);
  for(int i = 0;i < r;i++){
    cin >> a >> b;
    townRoad.at(a-1) += 1;
    townRoad.at(b-1) += 1;
  }
  for(int i = 0;i < t;i++){
    cout << townRoad.at(i) << endl;
  }
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N,K;
    cin >> N >> K;
    vector<ll> vec(N);
    REP(i,N) cin >> vec[i];
    ll ans = INF;
    REP(i,N-K+1) {
        // -座標にのみ行くルート
        if (vec[i]<0 && vec[i+K-1]<=0) {
            chmin(ans,abs(vec[i]));
            continue;
        }
        // ＋座標にのみ行くルート
        if (vec[i]>=0 && vec[i+K-1]>0) {
            chmin(ans,vec[i+K-1]);
            continue;
        }
        // プラス座標とマイナス座標両方行くルート
        auto miner=min(abs(vec[i]),abs(vec[i+K-1]));
        auto maxer=max(abs(vec[i]),abs(vec[i+K-1]));
        chmin(ans,(2*miner)+maxer);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K,X,Y;
int a,b,c,d;
string S,T;
vector<int> A,B;
//=============================
void input()
{
    cin>>S;
}
//=============================
void func(){}
/*
 - 樹形図をかく
*/
//=============================
void solve()
{
    int gcount=0;
    int pcount=0;
    int maxdif = 0;
    for(auto x : S){
        if (x == 'g')gcount++;
        else pcount++;

        maxdif = max(maxdif,gcount-pcount);
    }
    N = S.size();

    // cout<<gcount-pcount<<endl;
    // cout<<maxdif<<endl;

    int ans = gcount-pcount;
    ans /= 2;
    cout<<ans<<endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	A.push_back(0);
	N = A.size();
	while (true) {
		bool ok = false;
		for (int i = 0; i < N; i++) {
			if (i > 0 && A[i] == 0 && A[i - 1] != 0) {
				res++;
			}
		}
		for (int i = 0; i < N; i++) {
			if (A[i] > 0) {
				A[i]--;
				ok = true;
			}
			
		}
		if (!ok)break;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <cmath>
#include<queue>
#define PI 3.141592653589793238
#define INF -1
using namespace std;

int main()
{
	int x;

	cin >> x;

	if (x == 7 || x == 5 || x == 3) {
		printf("YES");
	} else {
		printf("NO");
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i,j,k,H,W,n;
    for ( k = 0; k < 300; k++ ){

    scanf("%d",&H);
    scanf("%d",&W);
    if(H == 0&&W == 0)break;
    for ( i = 0; i < H; i++ ){
        for ( j = 0; j < W; j++ ){
            if((i+j)%2==0)
            printf("#");
    else
    printf(".");
    }
    printf("\n");
  }
    printf("\n");
}
return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    bool flag = true;
    string s;
    cin >> s;
    int n = s.length()/2;
    rep(i,n)
    {
        if (s[i]!=s[2*n-i]) flag = false;
    }
    rep(i,n/2)
    {
        if (s[i]!=s[n-1-i]) flag = false;
    }
    rep(i,n/2)
    {
        if (s[n+1+i]!=s[n*2-i]) flag = false;
    }
    if(flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
    
}




Measured memory_bytes: 256
#include<iostream>

using namespace std;

struct ste {

	int at;
	int tairyoku;
};

int main() {
	
	ste takahasi;
	ste aoki;

	cin >> takahasi.tairyoku >> takahasi.at >> aoki.tairyoku >> aoki.at;

	int ans1;
	int ans2;
	int ans3;
	int ans4;

	ans1 = ((int)aoki.tairyoku / takahasi.at);
	ans2 = ((int)takahasi.tairyoku / aoki.at);
	ans3 = (aoki.tairyoku % takahasi.at);
	ans4 = (takahasi.tairyoku % aoki.at);

	ans3 == 0 ? ans3 = 0 : ans3 = 1;
	ans4 == 0 ? ans4 = 0 : ans4 = 1;

	ans1 += ans3;
	ans2 += ans4;

	if (ans1 <= ans2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int A[101010][3], dp[101010][3];
int main(){
  int N;
  cin >> N;
  rep(i, 0, N) rep(j, 0, 3) cin >> A[i][j];
  rep(i, 0, N) {
    rep(j, 0, 3) {
      rep(k, 0, 3) {
        if(j != k) chmax(dp[i + 1][k], dp[i][j] + A[i][j]);
      }
    }
  }
  int ans = 0;
  rep(i, 0, 3) chmax(ans, dp[N][i]);
  cout << ans << endl;
  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int N = sc.nextInt();
		int X = N * 100 / 108;
		int ret = 0;
		for (int i = X - 5; i <= X + 5; i++) {
			int VN = (int) (i * 1.08);
			if (VN == N) {
				ret = i;
				break;
			}
		}

		if (ret != 0) {
			System.out.println(ret);
		} else {
			System.out.println(":(");
		}

	}

}

class FScanner {
	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 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: 22740
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	int N,M;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		N = nextInt();
		M = nextInt();

		String [][]A = new String[M][2];
		for(int i = 0; i < M; i++) {
			A[i][0] = next();
			A[i][1] = next();
		}

		int[] waCnt = new int[N+1];
		int[] acFlag = new int[N+1];
		for(int i=0;i<M;i++) {
			int index = Integer.parseInt(A[i][0]);
			if(acFlag[index] == 1)continue;

			if(A[i][1].equals("AC")) {
				acFlag[index] = 1;
			}else if(A[i][1].equals("WA")){
				waCnt[index]++;
			}
		}
		int acSum = 0;
		int waSum = 0;
		for(int i=0;i<N+1;i++) {
			acSum += acFlag[i]==1?1:0;
			waSum += acFlag[i]==1?waCnt[i]:0;
		}

		out.println(acSum + " " + waSum);
	}


	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}

	long lcm(long m, long n) {
	        return m * n / gcd(m, n);
	}
}

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

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

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> b(n);
    rep(i, n) cin >> b[i];

    vector<int> diff(n);
    rep(i, n) diff[i] = b[i] - a[i];
    sort(diff.begin(), diff.end(), greater<int>());

    long long need_score = 0, cnt = 0;
    rep(i, n) {
        if (diff[i] <= 0) break;
        need_score += diff[i];
        cnt++;
    }

    for (int i = n - 1; i >= 0; i--) {
        if (need_score <= 0) break;
        need_score += diff[i];
        cnt++;
    }

    long long a_sum = accumulate(a.begin(), a.end(), 0LL);
    long long b_sum = accumulate(b.begin(), b.end(), 0LL);

    cout << (a_sum < b_sum ? -1 : cnt) << endl;
    
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
int main(void)
{

  int k;
  int a;
  int b;
  int x;
  int flag = 0;

  scanf("%d%d%d", &k, &a, &b);

  for (x = a; x <= b; x++){
    if (x % k == 0) flag = 1;
  }

  if (flag == 1) printf("OK\n");
  else printf("NG\n");

  return 0;

}


Measured memory_bytes: 2084
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int cnt[200005];
int n,k;
int main()
{
	read(n);
	read(k);
	int a;
	for(int i=1;i<=n;i++)
	{
		read(a);
		cnt[a]++;
	}
	sort(cnt+1,cnt+1+n);
	int ans=n;
	for(int i=n;i>n-k;i--)
		ans-=cnt[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define l long long
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int count=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='A'&&s[i+1]=='B')
		{
			if(s[i+2]=='C'){
				count++;
				i+=2;
			}
			else
				i+=1;
				
		}
		
	}
	cout<<count<<endl;
  return 0;
}

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

int main(){
  ll h,n; cin >> h >> n;
  string ret="No";
  rep(i,n){
    ll a; cin >> a;
    h-=a;
  }
  if(h<=0) ret="Yes";
  cout << ret;

}

Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) { res = res * a%MOD; }
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int n, k[100005], ans;
int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) { cin >> k[i]; }
	for (int i = 1; i <= n; i++) {
		if (k[k[i]] == i) {
			++ans;
		}
	}
	cout << ans / 2 << endl;
}

Measured memory_bytes: 640
/* 
chirag11032000
Chirag Thakur
*/

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

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void testCase();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	int n, k;
	cin >> n >> k;
	db prob = 0;
	int prev = 0;
	db mul = 1;
	for (int r = n; r >= 1; --r) {
		if (r < k) {
			int p = ceil(log2((1. * k) / r));
			while (prev != p) {
				mul *= 0.5;
				++prev;
			}
			prob += mul / n;
		} else {
			prob += 1. / n;
		}
	}
	cout << fixed << setprecision(16) << prob << "\n";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define   nl   <<'\n'
#define   pi   acos(-1.0);
#define   ll   long long
#define   pb   push_back
#define   eb   emplace_back
#define   tc   int t; cin>>t; while(t--)
#define   fio  ios_base::sync_with_stdio(0); cin.tie(0)

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n%2) cout<<"No\n";
    else 
    {
        for(int i=0; i<n/2; i++)
        {
            if(s[i]!=s[n/2+i])
            {
                cout<<"No\n";
                return 0;
            }
        }
        cout<<"Yes\n";
    }
}  

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

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

    vector<vector<ll>> item(r + 1, vector<ll>(c + 1));

    rep(i, k){
        int ri, ci;
        ll v;
        cin >> ri >> ci >> v;
        item[ri][ci] = v;
    }

    //dp[r][c][その行で取ったitemの数]
    vector<vector<vector<ll>>> dp(r + 1, vector<vector<ll>>(c + 1, vector<ll>(4)));
    dp[1][1][1] = item[1][1];

    for(int i = 1; i <= r; i++){
        for(int j = 1; j <= c; j++){
            for(int l = 0; l < 4; l++){
                if(l == 0){
                    //上と左から
                    rep(m, 4){
                        dp[i][j][l] = max(dp[i][j][l], dp[i - 1][j][m]);
                    }
                    dp[i][j][0] = max(dp[i][j][0], dp[i][j - 1][0]);

                }else if(l == 1){
                    //上とそのマス、左の0こから

                    rep(m, 4){
                        dp[i][j][l] = max(dp[i][j][l], dp[i - 1][j][m] + item[i][j]);
                    }
                    dp[i][j][l] = max(dp[i][j][l], dp[i][j - 1][l]);
                    
                    dp[i][j][l] = max(dp[i][j][l], dp[i][j - 1][l - 1] + item[i][j]);
                }else{
                    dp[i][j][l] = max(dp[i][j][l], dp[i][j - 1][l]);
                    dp[i][j][l] = max(dp[i][j][l], dp[i][j - 1][l - 1] + item[i][j]);
                }
            }
        }
    }

    ll ans = 0;

    rep(i, 4){
        ans = max(ans, dp[r][c][i]);
    }

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

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

int main(int argc, const char *argv[])
{
    int a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0)
    {
        cout << "Zero" << endl;
    }
    else if (a > 0 || (b - a + 1) % 2 == 0)
    {
        cout << "Positive" << endl;
    }
    else
    {
        cout << "Negative" << endl;
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

int dp[1000000][5];

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		memset(dp,0,sizeof(dp));

		dp[0][0] = 1;
		for(int i=1;i*i<=n;i++){
			for(int k=1;k<=4;k++){
				for(int j=1;j<=n;j++){
					if(j-i*i<0) continue;
					dp[j][k] += dp[j-i*i][k-1];
				}
			}
		}

		printf("%d\n",dp[n][4] + dp[n][3] + dp[n][2] + dp[n][1]);
	}
}

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


int main()
{
	ll n,d,i,j,x,y,ans=0;
	cin >> n >> d;
	
	for(i=0;i<n;i++)
	{
		cin >> x >> y;
		j = ceil(sqrt((x*x)+(y*y)));
		if(j<=d)  ans++;
	}
	
	cout << ans;
}



Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	if((s[0]==s[1]&& s[1]== s[2])||(s[1]==s[2] && s[2] == s[3]))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 100000;

int n;
vector<pair<int, int> > adj[MAXN];
ll s[MAXN];

bool alive[MAXN];
int w[MAXN];
int deg[MAXN];

int q[MAXN], qhead, qtail;

ll ans[MAXN - 1];

void run() {
	scanf("%d", &n); REP(i, n - 1) { int a, b; scanf("%d%d", &a, &b); --a, --b; adj[a].PB(MP(b, i)); adj[b].PB(MP(a, i)); } REP(i, n) scanf("%lld", &s[i]);

	REP(i, n) w[i] = 1, deg[i] = SZ(adj[i]), alive[i] = true;
	qhead = qtail = 0; REP(i, n) if (2 * w[i] < n&&deg[i] == 1) q[qhead++] = i;
	ll sub = 0; REP(i, n - 1) ans[i] = -1;
	while (qtail < qhead) {
		int at = q[qtail++];
		int to = -1, toid = -1; REPSZ(i, adj[at]) { int tmp = adj[at][i].first; if (!alive[tmp]) continue; assert(to == -1); to = tmp, toid = adj[at][i].second; } assert(to != -1);
		ll diff = s[at] - s[to]; int den = (n - 2 * w[at]); assert(diff >= 0 && diff%den == 0); ans[toid] = diff / den; sub += w[at] * ans[toid];
		alive[at] = false; --deg[to]; w[to] += w[at]; if (2 * w[to] < n&&deg[to] == 1) q[qhead++] = to;
	}
	REP(at, n) if (alive[at]) REPSZ(i, adj[at]) {
		int to = adj[at][i].first, toid = adj[at][i].second; if (!alive[at] || !alive[to]) continue;
		assert(2 * w[at] == n && 2 * w[to] == n && s[at] == s[to]);
		ll diff = s[at] - sub; int den = w[at]; assert(diff >= 0 && diff%den == 0); ans[toid] = diff / den; sub += w[at] * ans[toid];
		alive[at] = alive[to] = false;
	}
	REP(i, n - 1) assert(ans[i] != -1);
	REP(i, n - 1) printf("%lld\n", ans[i]);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 10100
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

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

void fastIO() {
	std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
}

#define FOR(i,f,t) for(int i=f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=f; i>(int)t; i--)
#define FORE(i,c) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void mxze(T &x, U y) { if(x < y) x = y; }

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(_i, (x)) cerr <<*_i <<", "; cerr <<"\n"; }}
#define debuga(x, sz) {{cerr <<#x <<" = "; FOR(_i, 0, sz) cerr << x[_i] <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////

const int MAXN = 2e5+5;

int n, Q, a[MAXN];

int covered, on[MAXN], cnt[MAXN];

void add(int p){
	cnt[p]++;
	int x=p-cnt[p];
	if(x>-1){
		if(!on[x]) covered++;
		on[x]++;
	}
}
void remove(int p){
	int x=p-cnt[p];
	if(x>-1){
		on[x]--;
		if(!on[x]) covered--;
	}
	cnt[p]--;
}

int main(){
	scan(n,Q);
	FOR(i,0,n) scan(a[i]);
	FOR(i,0,n) add(a[i]);
	while(Q--){
		int x,y; scan(x,y); x--;
		remove(a[x]);
		a[x]=y;
		add(a[x]);
		printf("%d\n",n-covered);
	}
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);


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

long long lcm(long long a, long long b) {
    long long tmp = max(a,b)/gcd(a,b);
   return min(a,b)*tmp;
}

int main() {
    int N;
    cin >> N;
    ll ans;
    
    rep(i,N) {
        ll t;
        cin >> t;
        if (i==0) {
            ans = t;
        }
        else if (ans%t==0) {
            continue;
        }
        else if (t%ans==0) {
            ans = t;
        }
        else {
            ans = lcm(ans,t);
        }
    }
    cout << ans <<  endl;

}

Measured memory_bytes: 256