akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <map>
#include <unordered_map>
#include<queue>


const int INF = 1 << 28;
const long long MOD = 1000000007;
using namespace std;
using Graph = vector<vector<int>>;

template<class T> bool chmin(T &a, T &b) { if (a > b) { a = b; return 1; }return 0; }
template<class T> bool chmax(T &a, T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T, class U> using P = pair<T, U>;

vector<int> seen(50,-1);
int counter_for_dfs = 0;
void dfs(Graph &G, int v) {
	seen[v] = counter_for_dfs;
	counter_for_dfs++;
	for (auto v_next : G[v]) {
		if (seen[v_next]>=0)continue;

		dfs(G, v_next);
	}
}

void bfs(Graph &G) {
	vector<int> dist(G.size(), -1);
	queue<int> que;
	
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
		}
	}
	for (auto i : dist) {
		cout << i << " ";
	}
}

int counter[200005] = {};
void bfs2(Graph &G,int p,int x) {
	vector<int> dist(G.size() , -1);
	queue<int> que;
	
	dist[p] = 0;
	que.push(p);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
			counter[g] += x;
		}
	}
}
long long int gcd(long long int a, long long int b) {
	long long int c = std::min(a, b);
	a = std::max(a, b);
	b = c;
	while (true) {
		c = a % b;
		a = b;
		b = c;
		if (c == 0)break;
	}
	return a;
}
long long int factorial(int start,int end = 1) {
	if (start == 0)return 1;
	return start == end ? end : start * factorial(start - 1,end);
}
long long int npr(int n, int r) {
	return factorial(n) / factorial(n - r);
}

long long int ncr(int n, int r) {
	return npr(n, r) / factorial(r);
}

int main()
{
	std::string s;
	std::cin >> s;
	std::string rslt = "YES";
	while (s.length() > 0) {
		if (s.substr(0, 5) == "dream") {
			if (s.substr(5, 2) == "er") {
				if (s.substr(5, 5) == "erase") {
					s.erase(0, 5);
				}
				else {
					s.erase(0, 7);
				}
			}
			else {
				s.erase(0, 5);
			}
		}
		else if(s.substr(0,5) == "erase"){
			if (s.substr(5, 1) == "r") {
				s.erase(0, 6);
			}
			else {
				s.erase(0, 5);
			}
		}
		else {
			rslt = "NO";
			break;
		}
	}
	std::cout << rslt;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MAX 100001
#define SENTINEL 2000000000
pair<char,int> A[MAX],B[MAX],Q[MAX/2+2],L[MAX/2+2];

int partition_sort(int p,int r){
    int x=A[r].second;
    int i=p-1,j=p;
    for(j=p;j<=r;j++){
        if(A[j].second<=x){i++;swap(A[i],A[j]);}
    }
    return i;
}

void quick_sort(int p,int r){
    if(p<r){
    int q=partition_sort(p,r);
    quick_sort(p,q-1);
    quick_sort(q+1,r);
    }
}

void merge_sort_from(int left,int midth,int right){
    int i,j,k;
    for(i=0;i<midth-left;i++){
        Q[i]=B[left+i];
    }
    Q[midth-left].second=L[right-midth].second=SENTINEL;
    for(i=0;i<right-midth;i++){
        L[i]=B[midth+i];
    }
    i=0,j=0,k=left;
    while(i<midth-left||j<right-midth){
        if(Q[i].second>L[j].second){
            B[k]=L[j];
            j++;
        }
        else{B[k]=Q[i];i++;}
        k++;
    }
}

void merge_sort(int left,int right){
    if(left+1<right){
    int midth=(left+right)/2;
    merge_sort(left,midth);
    merge_sort(midth,right);
    merge_sort_from(left,midth,right);
    }
    return;
}

int main(){
    int n,i;
    cin>>n;
    char S[10];
    for(i=0;i<n;i++){
        scanf("%s %d",S,&A[i].second);
        A[i].first=S[0];
        B[i]=A[i];
    }
    quick_sort(0,n-1);
    merge_sort(0,n);
    int stable=1;
    for(i=0;i<n;i++){if(A[i].first!=B[i].first){stable=0;break;}}
    if(stable==1)printf("Stable\n");
    else printf("Not stable\n");
    for(i=0;i<n;i++){
        printf("%c %d\n",A[i].first,A[i].second);
    }
}


Measured memory_bytes: 5544
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000000;
const long long MOD = 1000000007;

long long f(long long N){
  long long ret = 0;
  while(N%2==0){
    N /= 2;
    ret++;
  }
  return ret;
}

int main()
{
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(),greater<char>());
  if(s<t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int n, p, i;
	int s[14] = {0}, h[14] = {0}, c[14] = {0}, d[14] = {0};
	char C;
	scanf("%d", &n);
	for(i = 0 ; i < n ; i++)
	{
		scanf(" %c %d", &C, &p);
		if(C == 'S')
		{
			s[p]++;
		}
		else if(C == 'H')
		{
			h[p]++;
		}
		else if(C == 'C')
		{
			c[p]++;
		}
		else if(C == 'D')
		{
			d[p]++;
		}
    }
	for(i = 1 ; i < 14 ; i++)
	{
		if(s[i] == 0)
		{
			printf("S %d\n", i);
		}
	}
	for(i = 1 ; i < 14 ; i++)
	{
		if(h[i] == 0)
		{
			printf("H %d\n", i);
		}
	}
	for(i = 1 ; i < 14 ; i++)
	{
		if(c[i] == 0)
		{
			printf("C %d\n", i);
		}
	}
	for(i = 1 ; i < 14 ; i++)
	{
		if(d[i] == 0)
		{
			printf("D %d\n", i);
		}
	}
	return 0;
}


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

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
int n;
int arr[3005];
ll dp[3005][3005];

ll go (int i, int j) {
    if (i > j)
        return 0;
    if (i == j)
        return arr[i];
    if (dp[i][j] != -1)
        return dp[i][j];
    ll ans = 0;
    ans = max (arr[i]-go(i+1, j), arr[j]-go(i, j-1));
    dp[i][j] = ans;
    return ans;
}

void testCase() {
    cin >> n;
    for (int i=0; i<=n; i++) {
        for (int j=0; j<=n; j++)
            dp[i][j] = -1;
    }
    for (int i=1; i<=n; i++)
        cin >> arr[i];
    cout << go (1, n) << endl;    
}

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 70912
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
      
      	int result = a * b;
      
      	if (result % 2 == 1) {
        	System.out.println("Odd");
        } else {
          	System.out.println("Even");
        }
	}
}

Measured memory_bytes: 20820
str = input().split()
N = int(str[0])
K = int(str[1])-1
S = list(input())

if(S[K] == "A"):
    S[K] = "a"
elif(S[K] == "B"):
    S[K] = "b"
elif(S[K] == "C"):
    S[K] = "c"

s = ""
for i in range(N):
    s = s + S[i]
    
print(s)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String[] tmpArray = br.readLine().split(" ");
			
			int numOfTeam = Integer.parseInt(tmpArray[0]);
			int numOfProblem = Integer.parseInt(tmpArray[1]);
			int numOfRecord = Integer.parseInt(tmpArray[2]);
			
			if(numOfTeam == 0 && numOfProblem == 0 && numOfRecord == 0){
				break;
			}
			
			Team[] teams = new Team[numOfTeam];
			for(int i = 0; i < numOfTeam ; i++){
				teams[i] = new Team(i + 1, numOfProblem);
			}
			
			for(int i = 0; i < numOfRecord ; i++){
				tmpArray = br.readLine().split(" ");
				int tmpid = Integer.parseInt(tmpArray[0]) - 1;
				int tmppid = Integer.parseInt(tmpArray[1]);
				int tmptime = Integer.parseInt(tmpArray[2]);
				
				if(tmpArray[3].equals("CORRECT")){
					teams[tmpid].solve(tmppid, tmptime);
				}
				else {
					teams[tmpid].addPenalty(tmppid);
				}
			}
			
			Arrays.sort(teams);
			
			for(int i = 0; i < numOfTeam ; i++){
				System.out.println(teams[i].id +" "+teams[i].solved + " "+ teams[i].penalty);
			}
		}
	}

}

class Team implements Comparable<Team> {
	int id;
	int solved;
	int[] mistake;
	int penalty;
	
	public Team(int id, int numOfP){
		this.id = id;
		mistake = new int[numOfP + 1];
	}
	
	public void addPenalty(int pid){
		mistake[pid]++;
	}
	
	public void solve(int pid, int time){
		solved++;
		penalty += mistake[pid]*1200 + time;
	}

	@Override
	public int compareTo(Team t) {
		// TODO Auto-generated method stub
		return this.solved == t.solved ? 
				(this.penalty == t.penalty ? (this.id == t.id ? 0 : this.id - t.id) : this.penalty - t.penalty) : t.solved - this.solved;
	}
	
	
}

Measured memory_bytes: 44528
N =26

D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(0,D,1)]
t = [int(input())-1 for i in range(0,D,1)]

last = [-1]*(N)
manzoku = 0

for i in range(0,D,1):
    manzoku += s[i][t[i]]
    last[t[i]]=i
    for j in range(0,26,1):
        manzoku -= c[j]*(i-last[j])
    print(manzoku)


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

using namespace std;

int main()
{
    int N;cin >>N;
    vector<int> v;
    for(int i=0;i<N;++i)
    {
        int t;cin >>t;
        v.push_back(t);
    }
    sort(v.begin(),v.end(),greater<int>());
    int sum=0;

    for(int i=1;i<N;++i)
    {
        sum +=v[i];
    }

    if(v[0]<sum) cout << "Yes"<<endl;
    else cout << "No" <<endl;
}

Measured memory_bytes: 256
n=gets.to_i
a=gets.split.map(&:to_i)
l=[0]*100000
c=1
a.each do |b|
  if b==0
    if l[b]==0
      c*=3
    elsif l[b]==1
      c*=2
    elsif l[b]>2
      puts 0
      exit
    end
  else
    if l[b-1]-l[b]<=0
      puts 0
      exit
    end
    c*=l[b-1]-l[b]
  end
  l[b]+=1
  c%=1000000007
end
puts c


Measured memory_bytes: 8844
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int ha, sa, hb, sb;
    cin >> ha >> sa >> hb >> sb;
    while (true)
    {
        hb -= sa;
        if (hb <= 0)
        {
            cout << "Yes";
            break;
        }
        ha -= sb;
        if (ha <= 0)
        {
            cout << "No";
            break;
        }
    }
}

Measured memory_bytes: 3588
import sys

lines = sys.stdin.readlines()

if int(lines[0]) < 2 or int(lines[0]) > 10:
    exit()

totalCount = 0
for line in lines[1:]:
    line = line.strip("\n")
    splitLine = line.split(" ")
    if splitLine[1] == "JPY":
        totalCount += int(splitLine[0])
    elif splitLine[1] == "BTC":
        totalCount += float(splitLine[0]) * 380000.0

print(totalCount)

Measured memory_bytes: 2568
//abc123 b 最後に注文するものを決める
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

//10分単位で合わせる
int maxtime(int x){
    return (x+9)/10*10;
}
//最後に提供するものを決める
int mintime(int x){
    return maxtime(x)-x;
}
int main(){
    int a,b; cin>>a>>b;
    if(max(a,b)<9) cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
    return 0;
}

Measured memory_bytes: 384
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

h, n = ril()
ls = ril()
if h <= sum(ls):
    print('Yes')
else:
    print('No')

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

using ll=long long;
int main(){
    int N,W;
    cin>>N>>W;
    vector<int> w(N),v(N);
    for(int i=0;i<N;i++) cin>>w[i]>>v[i];
    vector<vector<ll>> dp(N+1,vector<ll>(W+1));
    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            if(j+w[i]<=W) dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
        }
    }
    cout<<*max_element(dp[N].begin(),dp[N].end())<<endl;
    return 0;
}


Measured memory_bytes: 80256
#![allow(unused_mut)]

use std::io::{self, BufWriter, Write};
use std::error::Error;

// use std::num;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() -> Result<(), Box<dyn Error>> {
    let sout = io::stdout();
    let mut o = BufWriter::new(sout.lock());
  
    input! {
        // input
        n : i32,
    }

    // operate
    let sqn = (n as f64).sqrt() as usize+ 2usize;
    let mut b : Vec<i32> = Vec::with_capacity(n as usize);

    for _ in 0 .. n {
        b.push(0);
    }
    
    for x in 1 .. sqn {
        for y in 1 .. sqn {
            for z in 1 .. sqn {
                let i = x * x + y * y + z * z + x * y + y * z + z * x - 1;
                if i < n as usize {
                    b[i] = b[i] + 1;
                };
            };
        };
    };

    let ss : Vec<String> = b.iter().map(|x| x.to_string()).collect();
    let s = ss.join("\n");

    let line = format!("{}\n", s);
    o.write(line.as_bytes())?;
    Ok(())
  }


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

int main() {
  int N = 0,
      Q = 0;
  cin >> N >> Q;
  string input;
  cin >> input;
  vector<int> d(N+1,0);
  
  for(int i=0; i < N; i++) 
    d[i+1] = d[i] + (input.substr(i,2) == "AC" ? 1 : 0);
  
  for(auto i=0; i < Q; i++) {
  	int l,r;
    cin >> l >> r;
    cout << d[r-1] -d[l-1] << endl;
  }
  return 0;
}
//8 3
//ACACTACG
//3 7
//2 3
//1 8

// 2
// 0
// 3

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int n,f[1510][1510],l[1510][1510],r[1510][1510];
char a[1510][1510];
ll ans;
int main(){
	read(n);
	for(int i=1;i<=n;i++)
		cin>>a[i]+1;
	for(int i=n;i;i--)
		for(int j=n;j;j--){
			if(!isdigit(a[i][j])){
				for(int k=i;k<=n;k++)
					l[j][k]=n+1,r[j][k]=0;
				continue;
			}
			int flag1=i<n&&isdigit(a[i+1][j]);
			int flag2=j<n&&isdigit(a[i][j+1]);
			if(!flag1&&!flag2){
				f[i][j]=0;
				l[j][i]=r[j][i]=j;
				for(int k=i+1;k<=n;k++)
					l[j][k]=n+1,r[j][k]=0;
			}
			if(flag1&&!flag2){
				f[i][j]=f[i+1][j];
				l[j][i]=r[j][i]=j;
			}
			if(!flag1&&flag2){
				f[i][j]=f[i][j+1];
				l[j][i]=j;r[j][i]=r[j+1][i];
				for(int k=i+1;k<=n;k++)
					l[j][k]=l[j+1][k],r[j][k]=r[j+1][k];
			}
			if(flag1&&flag2){
				f[i][j]=f[i+1][j]+f[i][j+1];
				l[j][i]=j;r[j][i]=r[j+1][i];
				int flag=1;
				for(int k=i+1;k<=n;k++){
					if(r[j][k]>=l[j+1][k]){if(flag) f[i][j]-=f[k][l[j+1][k]],flag=0;}
					else flag=1;
					if(r[j+1][k]>r[j][k]) r[j][k]=r[j+1][k];
					if(l[j+1][k]<l[j][k]) l[j][k]=l[j+1][k];
				}
			}
			//cerr<<i<<' '<<j<<' '<<f[i][j]<<'\n';
			int val=a[i][j]-'0';
			ans+=val*f[i][j];
			f[i][j]+=val;
		}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 29312
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    double R; cin >> R;
    cout << 2 * R * M_PI << endl;

    return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

ll gcd(ll A, ll B)
{
   if (A%B == 0)
   {
       return(B);
   }
   else
   {
       return(gcd(B, A%B));
   }
}

ll lcm(ll A, ll B)
{
   return A * B / gcd(A, B);
}


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

    cout << lcm(a, b) << endl;

    return 0;
    
}

Measured memory_bytes: 256
mod = 10**9+7
def prime(n,p):
    iteral = 0
    while n%p == 0:
        n //= p
        iteral += 1
    return iteral,n
def modpow(a,n):#二乗
    if n==0:
        return 1
    elif n==1:
        return a%mod
    elif n%2==0:
        return (modpow(a,n/2)**2)%mod
    else:
        return (a*modpow(a,n-1))%mod
def modfact(l,r):#階乗
    fact=1
    for i in range(l-r+1):
        fact=fact*(r+i)%mod
    return fact
def comb(n,x):#組み合わせ
    S=modfact(n,n-x+1)
    fact=modfact(x,1)
    T=modpow(fact,mod-2)
    return S*T%mod
def main():
    N,M = map(int,input().split())
    b = {}
    for i in range(2,int(M**0.5)+10):
        if M%i==0:
            num,M = prime(M,i)
            b[i] = num
    if M > 1:
        b[M] = 1
    ans = 1
    for num in b:
        ans *= comb(b[num]+N-1,b[num])
        ans %= mod
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int mod = 1e9 + 7;

const int nax = 2e5 + 5;
int fac[nax], inv_fac[nax];

int mul(int a, int b) {
    return (ll) a * b % mod;
}
int my_pow(int a, int b) {
    int r = 1;
    while(b) {
        if(b % 2) {
            r = mul(r, a);
        }
        a = mul(a, a);
        b /= 2;
    }
    return r;
}
int my_inv(int a) {
    return my_pow(a, mod - 2);
}

int binomial(int a, int b) {
    if(a < 0 || b < 0 || b > a) {
        return 0;
    }
    return mul(fac[a], mul(inv_fac[b], inv_fac[a-b]));
}

int f(int a, int b) {
    int tmp = binomial(a + b, b);
    //~ debug() << imie(a) imie(b) imie(tmp);
    return tmp;
}

int sub(int a, int b) {
    return (a - b + mod) % mod;
}

int main() {
    fac[0] = inv_fac[0] = 1;
    for(int i = 1; i < nax; ++i) {
        fac[i] = mul(fac[i-1], i);
        inv_fac[i] = my_inv(fac[i]);
    }
    int h, w, n;
    scanf("%d%d%d", &h, &w, &n);
    vector<pair<int,int>> in(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &in[i].first, &in[i].second);
    }
    sort(in.begin(), in.end(), [&](pair<int,int> a, pair<int,int> b) {
        return a < b;
    });
    // dp[i] - the number of paths to vertex in[i] such that it's the first
    // forbidden vertex
    
    in.emplace_back(h, w);
    
    vector<int> dp(n + 1);
    for(int i = 0; i <= n; ++i) {
        int tmp = f(in[i].first - 1, in[i].second - 1);
        debug() << imie(tmp);
        for(int j = 0; j < i; ++j) {
            if(in[j].first <= in[i].first && in[j].second <= in[i].second) {
                tmp = sub(tmp, mul(dp[j], f(in[i].first - in[j].first, in[i].second-in[j].second)));
            }
        }
        dp[i] = tmp;
    }
    debug() << imie(dp);
    printf("%d\n", dp[n]);
}

Measured memory_bytes: 1920
# include <bits/stdc++.h>
typedef long long lint;
using namespace std;

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


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

  int ans;
  if(s=="RRR") { ans = 3; }
  else if(s=="RRS" || s=="SRR") { ans = 2; }
  else if(s=="SSS") { ans = 0; }
  else { ans = 1; }

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


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

using namespace std;

typedef long long ll;

int main() {
    ll n, k;

    cin >> n >> k;

    vector<ll> w(n+1, INT_MAX), v(n+1, INT_MAX);

    vector<vector<ll>> sol(n+1, vector<ll>(k+1, INT_MIN));

    for (ll i=1; i<=n; i++) {
        cin >> w[i] >> v[i];
    }

    for (ll i=0; i<=n; i++) {
        sol[i][0] = 0;
    }

    for (ll i=0; i<=k; i++) {
        sol[0][i] = 0;
    }

    for (ll i=1; i<=n; i++) {
        for (ll j=1; j<=k; j++) {
            if (w[i] > j) {
                sol[i][j] = sol[i-1][j];
            } else {
                sol[i][j] = max(sol[i-1][j], v[i] + sol[i-1][j-w[i]]);
            }
        }
    }

    cout << sol[n][k] << endl;
    
    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  vector<ll> x(N), y(N), h(N);
  ll t;
  REP(i, N) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] > 0) t = i;
  }

  REP(cx, 101) REP(cy, 101) {
    bool ok = true;
    ll H = h[t] + abs(x[t] - cx) + abs(y[t] - cy);
    REP(i, N) {
      ll h_tmp = max(H - abs(x[i] - cx) - abs(y[i] - cy), 0LL);
      if (h_tmp != h[i]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << cx << " " << cy << " " << H;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char a,b;
	scanf("%c %c",&a,&b);
	if(a=='H' || a=='D' && b=='H' || b=='D')
	{
		if(a=='H' && b=='H')
		{
			printf("H\n");
		}
		else if(a=='H' && b=='D')
		{
			printf("D\n");
		}
		else if(a=='D' && b=='D')
		{
			printf("H\n");
		}
		else if(a=='D' && b=='H')
		{
			printf("D\n");
		}
	}
	return 0;
}

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

int main(){
	char est[1300000];
	for(int i = 2; i < 1300000; i++){
		est[i] = '1';
	}
	for(int i = 2; i * i <= 1300000; i++){
		for(int k = 2; k * i < 1300000; k++){
			est[i*k] = '0';
		}
	}
	int n;
	while(cin >> n){
		if(n == 0) break;
		int i = n, j = n;
		while(est[i] == '0') i--;
		while(est[j] == '0') j++;
		cout << j - i << endl;
	}
	return 0;
}

Measured memory_bytes: 2068
#include<stdio.h>
int main(){
int a[4],b[4],j,k,m,n;
while(scanf("%d%d%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])!=EOF){
m=0;
n=0;
for(j=0;j<4;j++)
for(k=0;k<4;k++){
if(j==k&&a[j]==b[k])
m++;
if(j!=k&&a[j]==b[k])
n++;
}
printf("%d %d\n",m,n);
}
return 0;
}

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

int main(){
  string st;
  cin>>st;
  bool n=false,s=false,w=false,e=false;
  for(int i=0;i<st.size();i++){
    if(st.at(i)=='N') n=true;
    else if(st.at(i)=='S') s=true;
    else if(st.at(i)=='W') w=true;
    else e=true;
  }
  if(n&&s&&e&&w) cout<<"Yes";
  else if(n&&s&&!e&&!w) cout<<"Yes";
  else if(!n&&!s&&e&&w) cout<<"Yes";
  else cout<<"No";
  cout<<endl;
}


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

int main(){
    int n, mx = 0, ans = 0;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];

    for(int i = 0; i < n; i++){
        if(h[i] < mx - 1) break;
        mx = max(mx, h[i]);
        if(i == n-1) ans = 1;
    }

    cout << (ans == 1 ? "Yes" : "No") << endl;
    return 0;
}


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

const int INF = 1000000007;

int main(){
    int n, W;
    int v[100], w[100];
    scanf("%d%d", &n, &W);
    for(int i = 0; i < n; i++){
        scanf("%d%d", v + i, w + i);
    }
    int dp[100][10001];
    for(int i = 0; i < n; i++){
        fill(dp[i], dp[i] + W + 1, 0);
    }
    fill(dp[0] + w[0], dp[0] + W + 1, v[0]);
    for(int i = 1; i < n; i++){
        for(int j = 0; j <= W; j++){
            dp[i][j] = dp[i-1][j];
            if(j >= w[i]){
                dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i <= W; i++){
        ans = max(ans, dp[n-1][i]);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 5096
#include <stdio.h>

int main()
{
    char s[5];
    scanf("%s",&s);
    int a[2]={};
    char b[2]={};
        for(int i=0;i<4;i++){
        if(b[0]==0){
            b[0]=s[i];
            a[0]++;
            continue;
        }
        if(s[i]==b[0]){
            a[0]++;
            continue;
        }
        if(b[1]==0){
            a[1]++;
            b[1]=s[i];
            continue;
        }
        if(s[i]==b[1]){
            a[1]++;
            continue;
        }
        printf("No\n");
        return 0;
        
    }
    if(a[0]==2&&a[1]==2) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>

#define N 1000000
#define INFTY 2000000000
 
int A[N], count=0;
 
void merge(int, int, int);
void mergeSort(int, int);
int main()
{
  int n,i;
   
  scanf("%d",&n);
   
  for(i=0; i<n; i++)
    scanf("%d",&A[i]);
 
  mergeSort(0,n);
 
  for(i=0;i<n;i++){
    printf("%d", A[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n%d\n", count);
   
  return 0;
}
 
void merge(int left, int mid, int right)
{
  int n1, n2, i, j, k, L[N], R[N];

  n1 = mid - left;
  n2 = right - mid;

  for(i=0; i<=n1-1; i++)
    L[i] = A[left + i];

  for(i=0; i<=n2-1; i++)
    R[i] = A[mid + i];

  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;

  for(k=left; k<=right-1; k++)
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
      count++;
    } 
    else {
      A[k] = R[j];
      j = j + 1;
      count++;
    }
}

void mergeSort(int left, int right)
{
  int mid;

  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);
  }
}

Measured memory_bytes: 5872
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

string s;

int main(){
    cin >> s;
    for(int i=0;i<s.size();i++){
        string ss = s.substr(i,2);
        if(ss=="AC"){
            cout << "Yes" << endl; 
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1e9;
const int MOD = 1000000007;
vector<ll> ans;

void dfs(int i,int d,ll now){
        if(i==d) ans.push_back(now);
        else{
                int before = now%10;
                if(before == 0){
                        dfs(i+1,d,now*10);
                        dfs(i+1,d,now*10+1);
                }else if(before ==9){
                        dfs(i+1,d,now*10+9);
                        dfs(i+1,d,now*10+8);
                }
                else{
                        dfs(i+1,d,now*10+before-1);
                        dfs(i+1,d,now*10+before);
                        dfs(i+1,d,now*10+before+1);
                }
        }
}

int main(){
        int k;
        cin >> k;
        for(int i=1;i<=10;i++){
                rep(j,10){
                        dfs(1,i,j);
                }
        }
        sort(ans.begin(),ans.end());
        ans.erase(unique(ans.begin(),ans.end()),ans.end());
        //rep(i,k) cout << ans[i] << endl;
        int i = 0;
        while(ans[i]==0) i++;
        cout << ans[i+k-1] << endl;
}

Measured memory_bytes: 2420
#include<stdio.h>

#define Max 100001

int main(){
  int i, j, n, A[Max], a1, a2, x;

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

  i = -1;
  for(j = 0; j < n-1; j++){
    x = A[n-1];
    if(A[j] <= x){
      i++;
      a1 = A[i];
      A[i] = A[j];
      A[j] = a1;
    }
 
  }

  a2 = A[i + 1];
  A[i + 1] = A[n - 1];
  A[n - 1] = a2;

  for(j = 0; j < n-1; j++){
    if(j == i+1) printf("[%d] ",A[j]);
    else printf("%d ", A[j]);
  }
  printf("%d\n",A[n-1]);

  return 0;
}

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

int main(){
  int N;
  cin>>N;
  int num=N;
  int sum=0;
  while(num>=10){
    sum+=num%10;
    num=num/10;
  }
  sum+=num;
  string ans="No";
  if(N%sum==0){
    ans="Yes";
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3564
#include<stdio.h>
#include<stdlib.h>
#define N 100
#define STILL 0
#define CONTE 1
#define FINISH 2
#define INFINITY 2000000000
#define Q_SIZE 10000

void search(int);
void enqueue(int);
int dequeue(void);

int n;
int G[N+1][N+1],state[N+1],dis[N+1],Q[Q_SIZE];
int head=0, tail=0;

int main(){
  int u,k,v,i,j;

  scanf("%d",&n);

  //初期化
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      G[i][j]=0;
    }
  }

  //辺を繋げる
  for(i=1;i<=n;i++){
    scanf("%d %d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      G[u][v]=1;
    }
  }

  search(1);


  return 0;
  
  
}

void search(int u){
  
  int i,v;
  
  //すべての頂点を見つけていない状態にする
  for(i=1;i<=n;i++){
    state[i]=STILL;
    dis[i]=INFINITY;
  }
  
  state[u]=CONTE;
  dis[u]=0;
  enqueue(u);
 

  while(1){
   
    if(head==tail) break;
    i=dequeue();
    for(v=1;v<=n;v++){
      if(G[i][v] && state[v]==STILL){
	state[v]=CONTE;
	dis[v]=dis[i]+1;
	enqueue(v);
	
      }
    }//for
    state[i]=FINISH;
  }//while
 
 for(i=1;i<=n;i++){
     if(dis[i]==INFINITY) dis[i]=-1;
     printf("%d %d\n",i,dis[i]);
 }
 
}

void enqueue(int x){

  if(head == (tail + 1)%N){
    printf("over flow\n");
    exit(1);
  }

  Q[tail] = x;
  if(tail + 1 == N) tail = 0;
  else tail++;
  
}

int dequeue(){

  int x;

  if(head == tail){
    printf("over flow\n");
    exit(1);
  }

  x = Q[head];
  if(head + 1 == N) head = 0;
  else head++;

  return x;
  
}



Measured memory_bytes: 2108
N, P = map(int, input().split())
A = map(int, input().split())

n_even = len(list(filter(lambda x: x % 2 == 0, A)))
n_odd = N - n_even
ans = (2 ** max(0, n_odd - 1)) * (2 ** n_even)
if P == 1 and n_odd == 0:
    print(0)
else:
    print(ans)




Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
#include<math.h>
using namespace std;
#define ll long long
int main(){
  int N,T;
  cin >> N >> T;
  int min=2000;
  int i;
  int t,c;
  for(i=0;i<N;i++){
    cin >> c >> t;
    if((c<min)&&(t<=T)){
      min = c;
    }
  }
  if(min==2000){
    cout << "TLE";
  }else{
    cout << min;
  }
  return 0;
}


Measured memory_bytes: 256
x, k, d = map(int, input().split())

if x >=0:
    A=int(x/d)
    if A<k:
        x-=A*d
        k-=A
        if k % 2 ==1:
            x-=d
    else:
        x-=d*k
else:
    A = int((x / d)*-1)
    if A<k:
        x+=A*d
        k-=A
        if k % 2 ==1:
            x+=d
    else:
        x+=d*k
print(abs(x))
        

Measured memory_bytes: 61908
import java.util.Scanner;
public class Main {

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

		  int H = sc.nextInt();
		  int W = sc.nextInt();
		  char[][] a = new char[H][W];
		  char[][] ans = new char[H][W];
		  char[][] ans2 = new char[H][W];
		  int ansi = 0;
		  int ansj = 0;

		  for(int i = 0; i < H ; i++) {
			  a[i] = sc.next().toCharArray();
		  }
		  //白行を見つける
		  for(int i = 0; i < H; i++) {
			  int count = 0;
			  for(int j = 0; j < W ; j ++) {
				  if(a[i][j]=='.') count++;
				  }
			  if(count != W) {
				  for(int j = 0; j < W ; j++) {
					  ans[ansi][j] = a[i][j];
				  }
				  ansi++;
			  }
		  }
		  for(int j = 0; j < W; j++) {
			  int count = 0;
			  for(int i = 0; i < ansi ; i ++) {
				  if(ans[i][j]=='.') count++;
				  }
			  if(count != ansi) {
				  for(int i = 0; i < ansi ; i++) {
					  ans2[i][ansj] = ans[i][j];
				  }
				  ansj++;
			  }
		  }
		  //白列を削除する

		  //出力する
		  for(int i = 0; i < ansi; i++) {
			  for(int j = 0; j < ansj; j++) {
				  System.out.print(ans2[i][j]);
			  }
			  if(i!=ansi-1) System.out.println("");
		  }

		  sc.close();
	  }
}

Measured memory_bytes: 23868
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <random>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int main () {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int k;
    string s;
    cin >> s;
    cin >> k;
    unordered_set<string> hs;
    vector<string> vs;
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < k + 1; ++j) {
            if (s.size() > (i + j)) {
                hs.emplace(s.substr(i, j));
            } else {
                hs.emplace(s.substr(i, j - ((i + j) - s.size())));
            }
        }
    }
    for (auto &i : hs) { vs.emplace_back(i); }
    sort(vs.begin(), vs.end());
    cout << vs[k] << endl;
    
    return 0;
}



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

int main()
{
  int n;
  cin>>n;
  int p[n];
  int i,j=0;
  for(i=0;i<n;i++){
    cin>>p[i];
    if(p[i]!=i+1){
      j++;
    }
  }
  string ans;
  if(j==0||j==2){
    ans="YES";
  }
  else{
    ans="NO";
  }
  cout<<ans<<endl;
  return 0;
}


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

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


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int n,m,i,j,a[300005],x;
int main(){
	cin>>m>>n;
	if (m&1){
		x=n;
		for(i=1;i<=n;i++) a[i]=(m+1)/2;
		for(i=1;i<=n/2;i++){
			if (a[x]==1){
				a[x]=m;
				x--;
			}
			else{
				a[x]--;
				x=n;
			}
		}
		for (i=1;i<=x;i++) cout<<a[i]<<' ';
	}
	else{
		cout<<m/2;
		for(i=1;i<n;i++) cout<<' '<<m;
	}
	return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int a, b;
	cin >> a >> b;
	
	if(a == 1) a += 13;
	if(b == 1) b += 13;

	if(a == b){
		puts("Draw");
	}else if(a > b){
		puts("Alice");
	}else{
		puts("Bob");
	}
	
	return 0;
}


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

using namespace std;

bool cmp(pair<int,int> a,pair<int,int> b) {
    return a.second < b.second;
}

int main(void) {
    int n,m;
    vector<pair<int,int>> a;
    vector<pair<int,int>> d;
    cin >> n >> m;
    for(int i = 0;i < m;i++) {
        int t[2];
        cin >> t[0] >> t[1];
        a.push_back(make_pair(t[0],t[1]));
    }
    int last = -1;
    int count = 0;
    sort(a.begin(),a.end(),cmp);
    for(const auto& e:a) {
        if(e.first <= last && e.second > last) {

        }
        else
        {
            last = e.second-1;
            count++;
        }
    }
    cout << count << endl;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int x, a, b;
  cin >> x >> a >> b;

  x -= a;
  x -= (x / b) * b;

  cout << x << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define p 3.14159265359

int main()
{
	double r;

	while (1)
	{
		scanf("%lf", &r);
		if (0 < r&&r < 10000)
			break;
	}

	printf("%.6lf %.6lf\n", (r*r)*p, (r * 2) * p);

	return 0;
}

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

signed main() {
  int S; cin >> S;
  
  int s = ceil(sqrt(S));
  
  int d = s*s - S;
  
  cout << "0 0 " << s << " 1 " << d << " " << s << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int64_t n;
    cin >> n;
    int64_t sum = 0;
    for (int64_t i = 1; i <= n; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            sum += i;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  while(cin >> s, s!="0") {
    int a = count(s.begin()+1,s.end(),'A');
    int b = count(s.begin()+1,s.end(),'B');
    if(a>b) a++;
    else b++;
    cout << a << ' ' << b << endl;
  }
  return 0;
}

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

int main(){
	int n ;
	cin >> n ;
	int t[2][20] ;
	for (int i=0 ; i<n ; i++){
		cin >> t[0][i] ;
	}
	for (int i=0 ; i<n ; i++){
		cin >> t[1][i] ;
	}
	int s = 0 ;
	for (int i=0 ; i<n ; i++){
		if(t[0][i] > t[1][i])  s += t[0][i] - t[1][i] ;
		
	}
	cout << s ;
}

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


int main(void){

	int priceA, priceB, priceAB;
	std::cin >> priceA >> priceB >> priceAB;

	int reqA, reqB;
	std::cin >> reqA >> reqB;

	long long cost = 0;

	// ABピザのことは考えずに必要数買う
	cost += priceA * reqA;
	cost += priceB * reqB;

	// AB < A + B なら重複しない分だけ買う
	if(priceAB * 2 < (priceA + priceB)){

		int num = (reqA < reqB) ? reqA : reqB;
		int diff = (priceA + priceB) - priceAB * 2;
		cost -= diff * num;
	}

	// 重複させて買う必要があるかどうか
	int overNum = std::abs(reqA - reqB);
	if( (reqA > reqB) && (priceAB * 2 < priceA) ){

		cost -= overNum * (priceA - priceAB * 2);
	}
	else if( (reqB > reqA) && (priceAB * 2 < priceB) ){

		cost -= overNum * (priceB - priceAB * 2);
	}

	std::cout << cost << std::endl;

	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=sorted(A)[::-1]
cnt=1
a=0
C=[]
for i in B:
  if a==i:
    cnt+=1
    if cnt==2:
      cnt=0
      C.append(a)
    if len(C)==2:
      print(C[0]*C[1])
      exit()
  else:
    a=i
    cnt=1
print(0)
      

Measured memory_bytes: 14252
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

template<typename T>
T minT(T a, T b) {
	if (a < b) return a;
	else return b;
}

template<typename T>
T maxT(T a, T b) {
	if (a > b) return a;
	else return b;
}

template<typename T>
T absT(T a) {
	if (a < 0) a *= -1;
	return a;
}

template<typename T>
T powT(T a, T x) {
	T res = 1;
	while (x > 0) {
		if (x & 1) res = res*a;
		a = a*a;
		x >>= 1;
	}
	return res;
}

ll StoLL(string str) {
	ll ret = 0, ini = 0;
	if (str[0] == '-') ini = 1;
	repi(i, ini, str.length()) {
		ret *= 10;
		ret += (ll)(str[i] - '0');
	}
	if (ini) ret *= -1;
	return ret;
}

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

ll N, ans = MAX_10p18, tmin, tmax;
ll A[MAX_10p5 * 2], sumA[MAX_10p5 * 2];

void calc(ll l, ll r) {
	ll m = sumA[l] - A[l] + (sumA[r] - sumA[l] + A[l]) / 2;
	ll *pos = upper_bound(sumA, sumA + N, m);
	ll idx = distance(sumA, pos);
	ll t1, t2;
	if (idx == l) {
		t1 = A[l];
		t2 = sumA[r] - sumA[l];
	}
	else if (idx == r) {
		t1 = sumA[r - 1] - sumA[l] + A[l];
		t2 = A[r];
	}
	else {
		t1 = sumA[idx - 1] - sumA[l] + A[l];
		t2 = sumA[r] - sumA[idx];
		if (t1 < t2) t1 += A[idx];
		else t2 += A[idx];
	}
	tmin = min(t1, t2);
	tmax = max(t1, t2);
	return;
}

int main() {
	rd(N);
	repi(i, 0, N) {
		rd(A[i]);
		if (i == 0) sumA[i] = A[i];
		else sumA[i] = sumA[i - 1] + A[i];
	}

	repi(i, 1, N - 2) {
		calc(0, i);
		ll lmin = tmin, lmax = tmax;
		calc(i + 1, N - 1);
		ll rmin = tmin, rmax = tmax;
		tmin = min(lmin, rmin);
		tmax = max(lmax, rmax);
		ans = min(ans, tmax - tmin);
	}

	wrln(ans);

	return 0;
}


Measured memory_bytes: 3328
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

use std::cmp;

fn main() {
    input! {
        s: chars,
        t: chars,
    }

    let mut dp = vec![vec![0; 3001]; 3001];
    let s_len = s.len();
    let t_len = t.len();
    for i in 1..s_len+1 {
        for j in 1..t_len+1 {
            if s[i-1] == t[j-1] {
                dp[i][j] = dp[i-1][j-1] + 1;
            } else {
                dp[i][j] = cmp::max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }


    //復元フェイズ
    let mut i = s_len;
    let mut j = t_len;
    let mut st = String::new();

    while i > 0 && j > 0 {
        if dp[i][j] == dp[i-1][j] {
            i = i -1;
        } else if dp[i][j] == dp[i][j-1] {
            j = j - 1;
        } else {
            st.push(s[i-1]);
            i = i- 1;
            j = j -1;
        }
    }

    for ch in st.chars().rev() {
        print!("{}", ch);
    }
    println!("");
    //println!("{}", dp[s_len][t_len]);

}


Measured memory_bytes: 41340
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a,b,c = map(int,input().split())
print(c,a,b)

Measured memory_bytes: 38516