akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdint>
using namespace std; // 575

const int MAX = 100;
const int MAX2 = 100001;
int main() {
	static int N, W, w[MAX], v[MAX];
	cin >> N >> W;
	for (int i = 0;i < N;++ i) cin >> w[i] >> v[i];
	static int64_t dp[MAX2];
	for (int i = 0;i <= W;++ i) dp[i] = 0;
	for (int i = 0;i < N;++ i) for (int j = W;j >= w[i];-- j) dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
	int64_t ans = 0;
	for (int i = 0;i <= W;++ i) ans = max(ans, dp[i]);
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

ナップサック問題はO(NW)だよ
*/

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


int ketasuu(int n) {
  int ans = 0;
  while(n > 0){
    ans++;
	n = n / 10;
  }
  return ans;
}

int A[7] = {1,10,100,1000,10000,100000,1000000};
int solve_loop(int n) {
  int a1, a2;
  int ans = 0;
  int k = ketasuu(n);
  if(k == 1 || k == 0) return -1;
  for(int i = 1; i < k; i++) {
    a1 = n / A[i];
	a2 = n % A[i];
	ans = max(ans,a1*a2);
  }
  return ans;
}
int solve(int num) {
  int output = 0;
  while(solve_loop(num) != -1){
    output++;
	num = solve_loop(num);
  }
  return output;
}


int main() {
  int Q, N;
  cin >> Q;
  for(int i = 0; i < Q; i++) {
    cin >> N;
	cout << solve(N) << endl;
  }
}



Measured memory_bytes: 3116
N, Q = map(int, input().split())
S=input()
A=[]
AC=[0]*100001
count=0
total=0
for i in range (Q):
    A.append(list(map(int, input().split())))

for i in range(1,N):
    if S[i]=='C' and S[i-1]=='A':
        count +=1
    AC[i]=count
#print(A)
#print(AC)

for i in range(Q):
    total+=AC[int(A[i][1])-1]-AC[int(A[i][0])-1]
    #print(AC[int(A[i][1])-2])
    #print(AC[int(A[i][0])-1])
    print(total)
    total=0

Measured memory_bytes: 30660
#include <stdio.h>


int main(void){

        int a,b,c;

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

        c = a+b;

if(a%3 == 0 || b%3 == 0 || c%3 == 0){ 
        printf("Possible\n");
}else{
        printf("Impossible\n");
}

return 0;
}

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

char s[233];

int main(){
	scanf("%s",s+1);
	int len=strlen(s+1);
	if(s[1]!='A'){
		puts("WA");
		return 0;
	}
	int cnt=0;
	for(int i=3;i<=len-1;i++)
		if(s[i]=='C'){
			cnt++; s[i]='a';	
		}
	if(cnt!=1){
		puts("WA");
		return 0;
	}
	for(int i=2;i<=len;i++)
		if(s[i]<'a' || s[i]>'z'){
			puts("WA"); return 0;
		}
	puts("AC");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include <iostream>
#include <string.h>
#include <cstdlib>

using namespace std;

#define BUF_SIZE 1024

struct Node{
	int data;
	Node* prev;
	Node* next;
};

class ConnectedList{
public:
	ConnectedList(){
		motherNode = new Node();
		motherNode->data = -1;
		motherNode->prev = motherNode;	
		motherNode->next = motherNode;
	}
	
	~ConnectedList(){
		Node* tmpNode = motherNode->next;
		Node* nextNode;
		while(tmpNode != motherNode){
			nextNode = tmpNode->next;
			delete tmpNode;
			tmpNode = nextNode;
		}
		delete motherNode;
	}
	
	void insertNode(int x){
		Node* tmpNode = motherNode->next;
		motherNode->next = new Node();
		motherNode->next->data = x;
		motherNode->next->next = tmpNode;
		motherNode->next->prev = motherNode;
		tmpNode->prev = motherNode->next;
	}
	
	void deleteNode(int x){
		Node* tmpNode = motherNode->next;
		while(tmpNode != motherNode && tmpNode->data != x){
			tmpNode = tmpNode->next;
		}
		if(tmpNode != motherNode){	
			tmpNode->prev->next = tmpNode->next;
			tmpNode->next->prev = tmpNode->prev;
			delete tmpNode;
		}
	}

	void deleteFirst(){
		Node* tmpNode = motherNode->next;
		motherNode->next = motherNode->next->next;
		motherNode->next->prev = motherNode;
		delete tmpNode;	
	}

	void deleteLast(){
		Node* tmpNode = motherNode->prev;
		motherNode->prev = motherNode->prev->prev;
		motherNode->prev->next = motherNode;
		delete tmpNode; 
	}

	void showList(){
		Node* tmpNode = motherNode->next;
		printf("%d",tmpNode->data);
		tmpNode = tmpNode->next;
		while(tmpNode != motherNode){
			printf(" %d",tmpNode->data);
			tmpNode = tmpNode->next;
		}
		printf("\n");
	}

private:
	Node* motherNode;
};


int main(){

	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));

	ConnectedList list;

	for(int i = 0; i < n; i++){

		fgets(buf,BUF_SIZE,stdin);

		if(buf[6] == 'F'){
			list.deleteFirst();
		}else if(buf[6] == 'L'){
			list.deleteLast();
		}else{
			int S = 0;
			
			if(buf[0] == 'i'){	//insert x

				for(int i = 0; buf[i] != '\0';i++){
					if(buf[i] >= '0' && buf[i] <= '9'){
						S = 10*S + (buf[i] - '0');
					}
				}
				list.insertNode(S);
			}else{	
				for(int i = 0;buf[i] != '\0';i++){
					if(buf[i] >= '0' && buf[i] <= '9'){
						S = 10*S + (buf[i] - '0');
					}
				}
				list.deleteNode(S);
			}

		}

	}

	list.showList();

}


Measured memory_bytes: 34456
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int[] spots = new int[6];
    for (int i = 0; i < 6; i++) {
        spots[i] = sc.nextInt();
    }

    Dice dice = new Main().new Dice(spots);

    String op = sc.next();
    for (char c : op.toCharArray()) {
        switch (c) {
            case 'N': dice = dice.north(); break;
            case 'W': dice = dice.west();  break;
            case 'E': dice = dice.east();  break;
            case 'S': dice = dice.south(); break;
        }
    }

    System.out.println(dice.top());
  }

  class Dice {

    private int[] spots = new int[6];

    public Dice(int[] spots) {
        this.spots = spots;
    }

    public Dice north() {
        return new Dice(new int[]{
            front(),
            bottom(),
            right(),
            left(),
            top(),
            back()
        });
    }

    public Dice west() {
        return new Dice(new int[]{
            right(),
            front(),
            bottom(),
            top(),
            back(),
            left()
        });
    }

    public Dice east() {
        return new Dice(new int[]{
            left(),
            front(),
            top(),
            bottom(),
            back(),
            right()
        });

    }

    public Dice south() {
        return new Dice(new int[]{
            back(),
            top(),
            right(),
            left(),
            bottom(),
            front()
        });
    }

    public int top() {
        return spots[0];
    }

    public int bottom() {
        return spots[5];
    }

    public int front() {
        return spots[1];
    }

    public int back() {
        return spots[4];
    }

    public int left() {
        return spots[3];
    }

    public int right() {
        return spots[2];
    }

    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append("[");
        for (int i = 0; i < spots.length; i++) {
            sb.append(i + ": " + spots[i] + ", ");
        }
        sb.append("]");
        return sb.toString();
    }
  }
}


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

using namespace std;
typedef long long ll;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll cnt = 0;
    for (ll i = 0; i < n; i++) {
        if (i % 2 != 0) {
            continue;
        }
        if (a[i] % 2 == 0) {
            continue;
        }
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3620
#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];
    int max = a[0];
    int count=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]<=max)
        {
            max = a[i];
            count++;
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int n =scan.nextInt();
		ArrayList b = new ArrayList();

		for(int i = 0; i < n; i++){
			b.add(scan.nextInt());
		}
		System.out.print(b.get(n - 1));
		for (int i = 2; i < n ; i = i + 2){
			System.out.print(" " + b.get(n-1-i));
		}
		if(n%2==0){
			for (int i = 0; i < n ; i = i + 2){
				System.out.print(" " + b.get(i));
			}
		} else {
			for (int i = 1; i < n ; i = i + 2){
				System.out.print(" " + b.get(i));
			}
		}

	}
}

Measured memory_bytes: 96684
#include<bits/stdc++.h>
using namespace std;
#define int long long
int ncm(int n,int m){
  int ans=1;
  if(n<m)return 1;
  for(int i=1;i<=m;i++){
    ans*=n--;
    ans/=i;
  }
  return ans;
}
signed main(){
  int n,p,A[2]={};
  cin>>n>>p;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    A[a%2]++;
  }
  int ans1=0,ans2=pow(2,A[0]);
  for(int i=0;i*2+p<=A[1];i++)ans1+=ncm(A[1],i*2+p);
  cout<<ans1*ans2<<endl;
  return 0;
}


Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var n, cnt int
	_, _ = fmt.Scan(&n)

	for a := 1; a < n; a++ {
		for b := 1; b <= n-a; b++ {
			if c := n - (a * b); c >= 1 {
				cnt++
			} else {
				break
			}
		}
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 1792
def larger(x, y):
	if x > y:
		return x
	return y

N = int(input())
V = list(map(int, input().split()))
even = []
odd = []
for i in range(0, N):
	if i % 2 == 0:
		even.append(V[i])
	else:
		odd.append(V[i])
even.sort()
odd.sort()
evencount = [[even[0], 1]]
oddcount = [[odd[0], 1]]
for i in range(1, N//2):
	if even[i] != even[i-1]:
		evencount.append([even[i], 1])
	else:
		evencount[-1][1] += 1
	if odd[i] != odd[i-1]:
		oddcount.append([odd[i], 1])
	else:
		oddcount[-1][1] += 1
evencount.sort(key = lambda v: v[1], reverse = True)
oddcount.sort(key = lambda v: v[1], reverse = True)
ans = N - evencount[0][1] - oddcount[0][1]
if evencount[0][0] == oddcount[0][0]:
	if len(evencount) == 1 or len(oddcount) == 1:
		ans = N//2
	else:
		ans = N - larger(evencount[0][1]+oddcount[1][1], evencount[1][1]+oddcount[0][1])
print(ans)

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

int n, m, k, a[3003000], b[3003000];
char s[3003000];

stack<int>st;

void in(int *a,int n){
    cin>>s; for (int i=0;i<n;++i) a[n-i]=s[i]-'0';
}
void out(int *a){
    int p=3e6;
    while (p>1&&!a[p]) --p;
    while (p) putchar(a[p--]+'0');
    puts("");
}

void fuck(int w,int d){
    --a[w]; --b[w];
    if (w+d<st.top()){
        ++a[w+d]; ++b[w+d];
        return;
    }
    int t=st.top()-w; st.pop();
    w+=t; d-=t;
    ++a[w]; ++b[w]; int pa=w, pb=w;
    if (a[w]>=2){
        while (a[pa]) a[pa]=0, ++pa;
        a[pa]=1; a[w]=0;
    }
    if (b[w]>=2){
        while (b[pb]) b[pb]=0, ++pb;
        b[pb]=1; b[w]=0;
    }
    while (st.top()<=max(pa,pb)) st.pop();
    if (b[pa]) fuck(pa,d);
    else if (a[pb]) fuck(pb,d);
    else st.push(max(pa,pb));
    st.push(w);
}

int main(){
    cin>>n>>m>>k;
    in(a,n); in(b,m);
    st.push(1e9);
    for (int i=1e6;i;--i){
        if (a[i]&b[i]) fuck(i,k);
        if (a[i]|b[i]) st.push(i);
    }
    out(a); out(b);
}

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

int n;
vector<int> adj[100005];

vector<int> dist;
void dfs(int v, int d = 0, int p = -1) {
  dist[v] = d;
  for (int u : adj[v]) {
    if (u == p)
      continue;
    dfs(u, d + 1, v);
  }
}
vector<int> calcDist (int v) {
  dist = vector<int>(n);
  dfs(v);
  return dist;
}

int main() {
  int u, v;
  cin >> n >> u >> v;
  u--; v--;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  
  vector<int> distU = calcDist(u);
  vector<int> distV = calcDist(v);
  
  int m = 0;
  for (int i = 0; i < n; i++) {
    if (distU[i] < distV[i])
      m = max(m, distV[i]);
  }
  m--;
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 10744
class BIT:
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)
        self.MSB = 1 << (N.bit_length() - 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def bisect(self, w):
        bit, N = self.tree, self.size
        i = 0
        k = self.MSB
        while k > 0:
            if i + k <= N and bit[i + k] < w:
                w -= bit[i + k]
                i += k
            k //= 2
        return i + 1

N, *A = map(int, open(0).read().split())

memo = {a: i for i, a in enumerate(sorted(set(A)), 1)}
M = len(memo)

bit = BIT(M)
for b in (memo[a] for a in A):
    s = bit.sum(b - 1)
    if s > 0:
        i = bit.bisect(s)
        bit.add(i, -1)
    bit.add(b, 1)

print(bit.sum(M))


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

using namespace std;

int main()
{
    int c[5];
    while(true){
        if(!(cin>>c[0])) break;
        for(int i=1; i<5; i++){
            cin.ignore();
            cin>>c[i];
        }
        sort(c, c+5);
        int pair[5]={1};
        int *p=pair;
        for(int i=1; i<5; i++){
            if(c[i-1]==c[i]) ++*p;
            else *(++p)=1;
        }
        sort(pair, pair+5, greater<int>());
        if(pair[0]==4) cout<<"four card\n";
        else if(pair[0]==3&&pair[1]==2) cout<<"full house\n";
        else if(c[1]-c[0]==1&&c[2]-c[1]==1&&c[3]-c[2]==1&&c[4]-c[3]==1) cout<<"straight\n";
        else if(c[0]==1&&c[1]==10&&c[2]==11&&c[3]==12&&c[4]==13) cout<<"straight\n";
        else if(pair[0]==3) cout<<"three card\n";
        else if(pair[0]==2&&pair[1]==2) cout<<"two pair\n";
        else if(pair[0]==2) cout<<"one pair\n";
        else cout<<"null\n";
    }
    return 0;
}

Measured memory_bytes: 2956
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
#include<queue>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

struct edge {
	int to, cost;
	edge(int to_, int cost_): to(to_), cost(cost_) {}
};


int main() {
	int N;
	while(cin >> N, N) {
		vector<int> p(N), d(N);	
		vector<vector<edge>> edges(N);
		int break_bridge_cost = 0;
		int except_leaf_cost = 0;	
		int one_only_edge_cost = 0;  

		auto is_leaf = [&](int v){ return edges[v].size() == 1; };

		rep(i, N-1) {
			cin >> p[i]; --p[i];
		}
		rep(i, N-1) {
			cin >> d[i]; 
			break_bridge_cost += d[i];
		}
		
		rep(i, N-1) {
			edges[i+1].push_back(edge(p[i], d[i]));
			edges[p[i]].push_back(edge(i+1, d[i]));	
		}

		rep(i, N) {
			if(is_leaf(i)) continue; 
			for(edge &e : edges[i]) {
				if(is_leaf(e.to)) continue;	
				except_leaf_cost +=	e.cost;	
			}
		}
	
		int INF = INT_MAX / 3;
		rep(s, N) {
			if(is_leaf(s)) continue;	
			vector<int>	dist(N, INF);
			queue<int> que;	
			que.push(s);
			dist[s] = 0;

			while(!que.empty()) {
				int v = que.front(); que.pop();	
				for(edge &e : edges[v]) {
					if(is_leaf(e.to)) continue;		
					if(dist[e.to] == INF) {
						dist[e.to] = dist[v] + e.cost;
						que.push(e.to);
					}
				}
			}

			rep(i, N) {
				if(!is_leaf(i)) {
					one_only_edge_cost = max(one_only_edge_cost, dist[i]);
				}
			}
		}
		int ans = break_bridge_cost + (except_leaf_cost - one_only_edge_cost);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1272
while True:
    m, f, r = map(int, input().split())
    if m == -1\
    and f == -1\
    and r == -1:
        break

    if m == -1\
    or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50\
    or r >= 50:
        print("C")
    elif m + f >= 30:
        print("D")
    elif m + f < 30:
        print("F")

Measured memory_bytes: 7596
#include <bits/stdc++.h>
using namespace std;
const int maxn = 123456;
int seen[maxn];
int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	long long ans = 0;
	int runs = 1;
	for(int d = 1; d < n - 1; d++){
		long long sum = 0;
		int l = d, r = n - 1 - d;
		while(r > d){
			sum += a[l] + a[r];
			ans = max(ans, sum);
			l += d;
			r -= d;
			if(r <= l && r%d == 0) break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        m: usize,
        c: i64,
        b: [i64; m],
        a: [[i64; m]; n]
    }
    let mut ans = 0;
    for i in 0..n {
        let mut x = c;
        for j in 0..m {
            x += a[i][j] * b[j];
        }
        if x > 0 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
<?php

fscanf(STDIN, '%d %d', $N, $K);

$fruits = array_map(function ($e) {
    return intval($e);
}, explode(' ', fgets(STDIN)));

sort($fruits);

$ans = 0;
for ($i=0; $i < $K; $i++) {
    $ans+=$fruits[$i];
}

echo $ans;

echo PHP_EOL;


Measured memory_bytes: 16348
#include<stdio.h>
int main()
{
	int a,b,c,d;
	a=getchar()-'0';
	b=getchar()-'0';
	c=getchar()-'0';
	d=getchar()-'0';
	if(a+b+c+d>7)
	{
		if(a+b+c-d==7){printf("%d+%d+%d-%d=7\n",a,b,c,d);}else
		
		if(a+b-c+d==7){
		printf("%d+%d-%d+%d=7\n",a,b,c,d);}else
		if(a-b+c+d==7)
		{printf("%d-%d+%d+%d=7\n",a,b,c,d);}else
		if(a+b-c-d==7){
		printf("%d+%d-%d-%d=7\n",a,b,c,d);}else
		if(a-b+c-d==7){printf("%d-%d+%d-%d=7\n",a,b,c,d);}else
		if(a-b-c+d==7){printf("%d-%d-%d+%d=7\n",a,b,c,d);}else
	    if(a-b-c-d==7){printf("%d-%d-%d-%d=7\n",a,b,c,d);}
	} 
	 if(a+b+c+d==7)printf("%d+%d+%d+%d=7\n",a,b,c,d);
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<bool> vb;
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 = 1 << 30;


template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};

const int MOD = 998244353;
using mint = Fp<MOD>;


int main() 
{
    int n,k;
    cin >> n >> k;
    vector<int> l(k),r(k);
    rep(i,k) {
        cin >> l[i] >> r[i];
        l[i]--;
    }

    vector<mint> dp(n);
    vector<mint> sdp(n+1);
    dp[0] = 1; sdp[1] = 1;
    for(int i = 1; i < n; ++i) {
        rep(j,k) {
            int li = max(i-r[j],0);
            int ri = max(i-l[j],0);
            dp[i] += sdp[ri] - sdp[li];
        }
        sdp[i+1] = sdp[i] + dp[i];
    }

    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 6416
/*
 * ----------------------------------------------------------------------------
 (: Bismillahir Rahmanir Rahim :) 
 * File: /home/grim/Programming/Atcoder/D_Sum_of_Large_Numbers.cpp
 * Project: /home/grim/Programming/Atcoder
 * Created Date: Tuesday, April 21st 2020, 7:16:58 pm
 * Author: Grim Firefly :)
 * Author Mail : GrimFirefly1@gmail.com
 * -----
 * Last Modified: Tue Apr 21 2020
 * Modified By: Grim Firefly :)
 * -----
 * ----------------------------------------------------------------------------
 */

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

//constant
#define PI acos(-1.0)

//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned un;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef map<int, int> mii;
typedef map<char, char> mcc;
typedef map<char, int> mci;
typedef map<string, int> msi;
typedef map<ll, ll> mll;
typedef set<int> seti;
typedef set<ll> setl;
typedef queue<int> qui;
typedef deque<int> dqui;

//Debug Setting up
#define watch(x) cout << (#x) << " is " << x << endl
#define watchara(wow)  \
    for (auto x : wow) \
    cout << x << " "

//defining something
#define SZ 10000

//main function start
ll sumn_1(ll x)
{
    return (x * (x - 1)) / 2;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll n, k;
    scanf("%lld %lld", &n, &k);
    ll ans = 0;
    for (ll i = k; i <= n + 1; i++)
    {

        (ans += i * n - sumn_1(i) - sumn_1(i) + 1) %= 1000000007;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
	int d; cin >> d;
	if(d == 25) cout << "Christmas" << endl;
	else if(d == 24) cout << "Christmas Eve" << endl;
	else if(d == 23) cout << "Christmas Eve Eve" << endl;
	else if(d == 22) cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

int cnt[70],tot;
char c[70];

int ask(string s){
	cout<<"? "<<s<<endl;
	int ret; read(ret);
	return ret;
}

string solve(int l,int r){
	if(l==r){
		string s="";
		REP(i,cnt[l]) s=s+c[l];
		return s;
	}
	int m=(l+r)>>1;
	string L=solve(l,m);
	string R=solve(m+1,r);
	int nL=L.size(),pL=0;
	int nR=R.size(),pR=0;
	string res="";
	while(pL<nL&&pR<nR){
		string now=res;
		now=now+L[pL];
		rep(i,pR,nR-1) now=now+R[i];
		if(ask(now)==tot-now.size()){
			res=res+L[pL++];
		}
		else{
			res=res+R[pR++];
		}
	}
	while(pL<nL){
		res=res+L[pL++];
	}
	while(pR<nR){
		res=res+R[pR++];
	}
	return res;
}

int main(){
	REP(i,26){
		c[i]='a'+i;
		c[i+26]='A'+i;
	}
	REP(i,10){
		c[i+52]='0'+i;
	}
	REP(i,62){
		string s;
		REP(k,128) s=s+c[i];
		cnt[i]=128-ask(s);
		tot+=cnt[i];
	}
	string ans=solve(0,61);
	cout<<"! "<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3792
n=int(input())
a=list(map(int,input().split()))
stack=[0]*(10**5+1)
p=10**9+7
for i in a:
  stack[i]+=1
if n%2==0:
  for j in range(1,n+1,2):
    if stack[j]!=2:
      print(0)
      exit()
  print(pow(2,n//2,p))
  exit()
for j in range(0,n+1,2):
  if j==0 and stack[j]==1:
    continue
  if j!=0 and stack[j]!=2:
    print(0)
    exit()
print(pow(2,n//2,p))
exit()

Measured memory_bytes: 14008
# input 高速化
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()
m = 10 ** 10
for i in range(N-K+1):
    tmp = h[i+K-1] - h[i]
    if tmp < m:
        m = tmp
print(m)

Measured memory_bytes: 43868
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();

        String ans = "";
        for (int i = 0; i < n; i++) {
            ans += s.charAt(i);
            ans += t.charAt(i);
        }
        System.out.println(ans);

        sc.close();
    }

}


Measured memory_bytes: 22996
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

#define mod 1000000007

int main()
{
    int n, s;
    cin >> n >> s;
    int a[100001];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long long int nowsum = 0;
    int cnt = 0;
    int ans = 0;
    while(cnt < n && nowsum < s){
        nowsum += a[cnt];
        cnt++;
    }
    if(nowsum < s){
        cout << 0 << endl;
        return 0;
    }
    ans = cnt;
    for(int i = 1; i < n; i++){
        nowsum -= a[i - 1];
        cnt--;
        while(i + cnt < n && nowsum < s){
            nowsum += a[i + cnt];
            cnt++;
        }
        if(nowsum >= s){
            ans = min(ans, cnt);
        }
        // cout << i << " " << cnt << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3492
#include <iostream>
#include <queue>
#include <limits>
using namespace std;
using ll = long long;

#define out(v) cout<<v<<"\n"
#define rep(i,n) for(int i=0;i<(n);++i)

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

  int A[3*N];
  rep(i, 3 * N) {
    cin >> A[i];
  }
  priority_queue<int, vector<int>, greater<int>> q;
  ll first_sum[N+1], second_sum[N+1];
  first_sum[0] = 0; second_sum[N] = 0;
  rep(i, N) {
    first_sum[0] += A[i];
    q.push(A[i]);
  }
  rep(k, N) {
    q.push(A[N+k]);
    first_sum[k+1] = first_sum[k] + A[N+k] - q.top();
    q.pop();
  }
  while (!q.empty()) q.pop();
  rep(i, N) {
    second_sum[N] -= A[3*N-1-i];
    q.push(-A[3*N-1-i]);
  }

  rep(k, N) {
    q.push(-A[2*N-1-k]);
    second_sum[N-1-k] = second_sum[N-k] + (-A[2*N-1-k]) - q.top();
    q.pop();
  }

  ll ans = numeric_limits<ll>::min();
  rep(k, N+1) ans = max(ans, first_sum[k] + second_sum[k]);

  out(ans);

  return 0;
}


Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a > 0 && a < 10 && b > 0 && b < 10) {
            System.out.println(a * b);
        } else {
            System.out.println("-1");
        }

        sc.close();
    }

}


Measured memory_bytes: 21972
//My life was going great until I stumble upon this question ); ):

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

long long MOD = 1000000007; //1e9+7
long long INF = 1e18;
typedef long long ll;
typedef long double ld;
#define pii		pair<int, int>
#define pll		pair<long long, long long>
#define fi 		first
#define se 		second
#define fr(i,a,b) 	for(int i=a;i<b;i++)
#define out2(a,b) 	cout<<a<<" "<<b<<"\n";
#define all(v) 		v.begin(), v.end()
#define pb          	emplace_back

void solve()
{
    ll n, k;
    ll m = 998244353;
    cin>>n>>k;
    ll arr[k][2];
    vector<ll> dp(n+1, 0), pre(n+2, 0);
    for(int i=0;i<k;i++){
        cin>>arr[i][0]>>arr[i][1];
    }
    dp[1]=pre[1]=1;
    ll l, r;
    for(int i=2;i<=n;i++){
        for(int j=0;j<k;j++){
            if(i<=arr[j][0]) continue;
            l = arr[j][0];
            r = min(arr[j][1], (ll)i-1);
            dp[i] = (dp[i] + pre[i-l]-pre[i-r-1] + m)%m;
        }
        pre[i] = (pre[i-1]+dp[i])%m;
        //cout<<dp[i]<<" ";
    }
    cout<<dp[n]%m;
}

int main() {
	FIO;
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	int test;
	//cin>>test;
	test=1;
	for(int t=1;t<=test;t++){
        //cout<<"Case #"<<t<<": ";
        solve();
        //cout<<ans<<"\n";
	}
	return 0;
}


Measured memory_bytes: 6372
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

vector<LL> fact, finv, inv;

void init_nCk(int N) {
  fact.resize(N + 1);
  finv.resize(N + 1);
  inv.resize(N + 1);
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i <= N; i++) {
    fact[i] = fact[i - 1] * i % kMod;
    inv[i] = kMod - inv[kMod % i] * (kMod / i) % kMod;
    finv[i] = finv[i - 1] * inv[i] % kMod;
  }
}

LL nCk(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fact[n] * (finv[k] * finv[n - k] % kMod) % kMod;
}

int main() {
  int N, K; cin >> N >> K;
  init_nCk(N);

  for (int i = 0; i < K; ++i) {
    LL a = nCk(N-K+1, i+1);
    LL b = nCk(K-1, i);
    cout << (a * b) % kMod << endl;
  }
}


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

int main(void) {
    int N;
    cin >> N;
    string s;
    cin >> s;
    int r = 0;
    for (int i = 0; i < N; i++) {
        r += s[i] == 'R' ? 1 : 0;
    }
    cout << (r > N - r ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3492
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	double a,b,c,d,e,f;
	double x,y;
	while(cin>>a>>b>>c>>d>>e>>f)
	{
		y=((d*c)-(a*f))/((b*d)-(a*e));
		x=(c-(b*y))/a;
		if(x==0)x=0;
		if(y==0)y=0;
		printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 3164
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

// doot diddly donger cuckerino Hahahahahah
// Created by White Knife on 15/04/20.
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC target("popcnt")

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

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define F               first
#define S               second
#define all(x)          (x).begin(), (x).end()
#define sz(x)           (long long) (x).size()
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> range(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << range(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template <typename T> T gcd(T x, T y) { return (y == 0) ? x : gcd(y, x % y); }
template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template <typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
// @formatter:on


class DFloorFunction {
public:
  
  ll can(ll a, ll b, ll x) {
    ll g = gcd(x, b);
    b /= g;
    x /= g;
    ll res = 0;
    for (ll i = 0; i < a; ++i) {
      res += (x * a + i * b) / (a * b);
    }
    res -= a * (x / b);
    return res;
  }
  
  void solve(std::istream &cin, std::ostream &cout) {
    ll a, b, n;
    cin >> a >> b >> n;
    // res >= 0 and res < a always
    ll res = 0;
    mini(n, b - 1);
    res = n * a / b;
    cout << res << '\n';
  }
};

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
	DFloorFunction solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
int G[1000000]={0},h[100000];
using namespace std;


int main()
{
  int N;
  cin>>N;
  for(int i=0;i<N;i++)
  {
    cin>>h[i+1];
  }
   G[1]=0;
    G[2]=abs(h[2]-h[1]);
  //if(G[N]==0)
  //{
      for(int i=3;i<=N;i++)
      {
        G[i]=min(G[i-1]+abs(h[i]-h[i-1]),G[i-2]+abs(h[i]-h[i-2]));
    }
 
//}

  cout<<G[N];
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll sum=0;
  rep(i,n){
    cin >> a.at(i);
    sum+=a.at(i);
  }
  ll mini=3e9+7,ans=3e9+7,sum2=0;
  for(ll i=0;i<n-1;i++){
    sum2+=a.at(i);
    sum-=a.at(i);
    ans=min(ans,abs(sum2-sum));
  }
  cout << ans;
}


Measured memory_bytes: 4844
n = int(input())
l = list(map(int, input().split()))
res = 1
flag = 0
for i in l:
	res *= i
	if i == 0:
		flag = 0
		res = 0
	if(res > 1000000000000000000):
		flag = 1
		break
for i in l:
	if (i == 0):
		flag = 0
		res = 0
if flag == 1:
	print('-1')
else : print(res)


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

int n;
vector<int> a;
template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}
int ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	readVector(n, a);
	for(int i=1; i<n; ++i){
		if(a[i] == a[i-1]){
			++ans;
			++i;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b,c,tmp;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    if(b>c){
        tmp=b;
        b=c;
        c=tmp;
    }
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
int main(){
int N=0;cin>>N;
int a[N];
for(int i=0;i<N;++i){
	a[i]=0;
	cin>>a[i];
}
int dp[N];
dp[0]=0;
dp[1]=abs(a[0]-a[1]);
for(int i=2;i<N;++i){
	dp[i]=min((dp[i-2]+abs(a[i-2]-a[i])),(dp[i-1]+abs(a[i-1]-a[i])));
}
cout<<dp[N-1]<<endl;
return 0;
}

Measured memory_bytes: 1024
def abc092_b():
    n = int(input())
    d, x = map(int, input().split())
    a = [int(input()) for _ in range(n)]
    choco = x
    for i in range(n):
        choco += (d - 1) // a[i] + 1

    print(choco)


abc092_b()

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

int main(){
    string s;
    cin >> s;
    rep(i,s.length()){
        s[i]='x';
    }

    cout << s << endl;
}

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

using namespace std;

typedef long long ll;

int N, K;
const int MAXN = 1e5;
const ll INF = 1e15;
// firstに頂点、secondにコストとした隣接リスト
vector<pair<int, ll> > graph[MAXN + 1];
ll d[MAXN + 1];

void dijkstra(){
  // firstに最短距離、secondに頂点番号
  priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > PQ;
  fill(d, d + N + 1, INF);
  d[K] = 0;
  PQ.push(make_pair(0, K));

  while(!PQ.empty()){
    pair<ll, int> p = PQ.top(); PQ.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(int i=0;i<graph[v].size();i++){
      int to = graph[v][i].first;
      ll cost = graph[v][i].second;
      if(d[to] > d[v] + cost){
        d[to] = d[v] + cost;
        PQ.push(make_pair(d[to], to));
      }
    }
  }
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> N;
  for(int i=0;i<N-1;i++){
    int a, b, c; cin >> a >> b >> c;
    graph[a].push_back(make_pair(b, c));
    graph[b].push_back(make_pair(a, c));
  }
  int Q; cin >> Q;
  cin >> K;
  dijkstra();
  /*
  for(int i=1;i<=N;i++){
      cout << d[i] << endl;
  }
  */
  for(int i=0;i<Q;i++){
    int x, y; cin >> x >> y;
    cout << d[x] + d[y] << endl;
  }
}

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

int partition(int* A, int p, int r){

	int x = A[r]; // ????????¨?????????
	int i = p-1;
	for(int j=p; j<r; j++){
		if(A[j] <= x){
			i = i+1;
			int tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}

	int tmp = A[r];
	A[r] = A[i+1];
	A[i+1] = tmp;

	return i+1;
	
}

int main(){

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

	int part = partition(A, 0, n-1);

	for(int i=0; i<n; i++){
		if(i == part)
			cout << "[" << A[i] << "]";
		else
			cout << A[i];
		if(i != n-1)
			cout << " ";
	}
	cout << endl;	
	return 0;
}

Measured memory_bytes: 3460
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll gcd(ll a, ll b){//計算量はO(log(max(a,b))
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

ll kai(ll x){
  if(x == 1) return 1;
  return x * kai(x-1) % MOD;
}



int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a*b, c*d) << endl;
}


Measured memory_bytes: 256
#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>;

void solve() {
    int k;
    cin >> k;
    if (k % 2 == 0) {
        cout << -1 << endl;
        return;
    }

    int cnt = 1;
    int r = 7;
    map<int,int> check;
    while (true) {
        if (r % k == 0) break;
        if (check[r] > 0) {
            cout << -1 << endl;
            return;
        }
        check[r]++;
        r = r * 10 + 7;
        r %= k;
        cnt++;
    }

    cout << cnt << endl;
}

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


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

int main(){
    i64 n,m,sum=0;
    cin>>n>>m;
    vector<int> a(n);
    for(i64 i=0;i<n;i++) {
        cin>>a[i];
        sum+=a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    i64 b=(sum+m*4-1)/(m*4);
    cout<<(a[m-1]<b?"No":"Yes")<<endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
s = [int(input()) for _ in range(N)]
s.sort()
l = [x for x in s if x % 10 != 0]
if l == []:
    print(0)
elif sum(s) % 10 != 0:
    print(sum(s))
else:
    print(sum(s) - min(l))


Measured memory_bytes: 3060
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << std::endl;
}

using namespace std;

int main() {
    int h,w,n; cin >> h >> w >> n;
    vector<vector<int>> da(w, vector<int>(0));
    rip(i,n,0) {
        int x,y; cin >> x >> y;
        --x;--y;
        da[y].push_back(x);
    }
    rip(i,w,0) sort(all(da[i])), da[i].emplace_back(h);
    int ans = h*2, now = 0;
    rip(i,w,0) {
        rip(j,da[i].size(),0) {
            if(da[i][j] > now) {
                chmin(ans, da[i][j]);
            }
            else if(da[i][j] == now) {
                ++now;
            }
        }
        ++now;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11392
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define sz(c) c.size()
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define ppb  pop_back
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,n)   for( int i=a ; i<n ; i++)
#define U 1000000007
#define N 100005
#define ins insert
using namespace std;
int n, a[22][22];
vector<vector<int>>dp;
int lm;
int sl(int in, int mask){
        

    if(in==n) return mask==lm; 

    if(dp[in][mask]!=-1) return dp[in][mask];
    
    int c=0;
    rep(i,0,n){
        //cout<<a[in][i]<<endl;
        if(a[in][i] && ( (mask & (1<<i))==0)) 
            c+=sl(in+1,mask|(1<<i));
        
    }
    return dp[in][mask]=c%U;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin>>n;
    lm=(1<<n)-1;
    rep(i,0,n) rep(j,0,n) cin>>a[i][j];
    dp.assign(n,vector<int>(lm,-1));
    cout<<sl(0,0);

}

Measured memory_bytes: 360832
H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(input())

def bfs(start):
    already = {}
    queue = []
    counter = 0
    queue.append((start[0], start[1], 0))
    already[start] = True
    max_depth = 0
    while counter < len(queue):
        y, x, depth = queue[counter]
        if depth > max_depth:
            max_depth = depth
        for move in ((-1, 0), (0, 1), (1, 0), (0, -1)):
            new_y = y + move[0]
            new_x = x + move[1]
            if new_y >= 0 \
            and new_y < H \
            and new_x >= 0 \
            and new_x < W \
            and S[new_y][new_x] == '.' \
            and (new_y, new_x) not in already:
                already[(new_y, new_x)] = True
                queue.append((new_y, new_x, depth+1))
        counter += 1
    return max_depth

answer = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        depth = bfs((i, j))
        if answer < depth:
            answer = depth
print(answer)

Measured memory_bytes: 9108