akhauriyash/Code-Regression huggingface dataset:
#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;

int main(void){
  int n,m; cin>> n >> m;
  int s[m],t[m];
  rep(i,m){
    cin >> s[i] >> t[i];
  }
  vector<int> check(n,0);
  vector<int> seen(n,0);
  rep(i,m){
    if(seen[s[i]-1] == 1 && t[i] != check[s[i]-1]){
      cout << -1 << endl;
      return 0;
    }
    if(seen[s[i]-1] == 0){
      check[s[i]-1] = t[i];
      seen[s[i]-1] = 1;
    }
  }
  if(seen[0] == 1 && check[0] == 0 && n != 1){
    cout << -1 << endl;
    return 0;
  }
  else{
    rep(i,n){
      if(seen[i] == 0 && i != 0 && n != 1) cout << 0;
      else if(n == 1 && seen[i] == 0) cout << 0;
      else if(seen[i] == 0 && i == 0) cout << 1;
      else cout << check[i];
    } 
    cout << endl;
  }
  return 0;
}


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

 int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int x,y;	
	x=(a+b+c+d)/60;
	y=a+b+c+d-x*60;
	cout << x << '\n' << y << '\n';
	
	return 0;
}

Measured memory_bytes: 1160
n = int(input())
other = [[s for s in input().split(" ")] for _ in range(n)]
profit = [[int(s) for s in input().split(" ")] for _ in range(n)]
for i in range(1, 1024):
  b = bin(i)[2:].zfill(10)
  l = [b[j] for j in range(10)]
  ans = 0
  for j in range(n):
    cnt = 0
    for me, othe in zip(l, other[j]):
      if me == "1" and othe == "1":
        cnt += 1
    ans += profit[j][cnt]
  if i == 1:
    final_ans = ans
  else:
    if ans > final_ans:
      final_ans = ans
      
print(final_ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
  long long int n;
  scanf("%lld",&n);
  int sum=0,tmp=n;
  while(n!=0){
    sum+=n%10;
    n/=10;
  }
  if(tmp%sum==0) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	static String[] numlist = {"3", "5", "7"};
	static Scanner sc = new Scanner(System.in);
	static long N = sc.nextLong();
	public static void main(String[] args) {
		long ans = dfs(0);
		System.out.println(ans);
		sc.close();
	}

	static long dfs(long a) {
		if (a > N) return 0;
		long res;
		// aが753なら+1する
		if (is753(a)) res = 1; else res = 0;
		// 3,5,7を末尾に足し、次の木を探索する
		for (String num : numlist) {
			String next = Long.toString(a) + num;
			res += dfs(Long.parseLong(next));
		}
		return res;
	}

	static boolean is753(long s) {
		String sStr = Long.toString(s);
		for (String num : numlist) {
			if (!sStr.contains(num)) return false;
		}
		return true;
	}
}

Measured memory_bytes: 39844
s = list(input())
cnt = 0
list = []
for i in range(len(s)):
    if s[i] in ['A','C','G','T']:
        cnt += 1
    else:
        if cnt > 0:
            list.append(cnt)
            cnt = 0
if not cnt == 0:
    list.append(cnt)
if len(list) == 0:
    list.append(0)
max = max(list)
print(max)


Measured memory_bytes: 3060
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n, m := nextInt(), nextInt()
	if n == m {
		puts("Yes")
	} else {
		puts("No")
	}
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


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

// 
int main() {
    int X;
    cin >> X;
    if (X <= 599) {
        cout << "8";
    } else if (X <= 799) {
        cout << "7";
    } else if (X <= 999) {
        cout << "6";
    } else if (X <= 1199) {
        cout << "5";
    } else if (X <= 1399) {
        cout << "4";
    } else if (X <= 1599) {
        cout << "3";
    } else if (X <= 1799) {
        cout << "2";
    } else if (X <= 1999) {
        cout << "1";
    }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;
    ll h[n+1];
    for(ll i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    ll ans[n+1];
    ans[1]=0;
    ans[2]=abs(h[1]-h[2]);
    for(ll i=3;i<=n;i++)
    {
        ans[i]=min(ans[i-1]+abs(h[i]-h[i-1]),ans[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<ans[n]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;



int main() {
//    cout << setprecision(30);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int a, b;
    cin >> a >> b;
    if (a >= 13) cout << b;
    else if (6 <= a && a <= 12) cout << b / 2;
    else cout << 0;

}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  int ng = N;
  if (ng % 2 == 0)
    ng++;
  vector<P> vc;
  REP1(i, N)
  {
    for (int j = i + 1; j <= N; ++j)
    {
      if (i + j == ng)
        continue;
      vc.push_back(make_pair(i, j));
    }
  }
  cout << vc.size() << endl;
  for (auto a : vc)
    cout << a.first << " " << a.second << endl;
  return 0;
}

Measured memory_bytes: 512
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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, usize1) => {
        read_value!($next, usize) - 1
    };

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        s: chars,
    }
    let mut c = 0;
    for i in 0..n - 2 {
        if s[i..i + 3] == ['A', 'B', 'C'] {
            c += 1;
        }
    }
    puts!("{}\n", c);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
N, Y = map(int, input().split())
for i in range(N, -1, -1):
  if 10000 * i > Y:
    continue
  for j in range(N - i, -1, -1):
    if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
        print(i, j, N - i - j)
        exit()
print('-1 -1 -1')


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

using namespace std;

int main(int argc, const char *argv[]) {
  using ll = long long;
  ll n, m;
  cin >> n >> m;
  vector<ll> vx(m);
  for (ll i = 0; i < m; ++i) {
    cin >> vx[i];
  }

  sort(vx.begin(), vx.end());
  n--;

  vector<ll> dists;
  for (ll i = 1; i < m; ++i) {
    dists.push_back(vx[i] - vx[i - 1]);
  }

  sort(dists.begin(), dists.end(), greater<ll>());

  ll ans = 0;
  for (int i = n; i < dists.size(); ++i) {
    ans += dists[i];
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long 
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mkp make_pair
  #define pb push_back
  #define inf INT_MAX
  const long long  M=1000000007;
                     
   
  int32_t main()
  { 
  	  IOS
      int h,w;
      cin>>h>>w;
      char grid[h][w];
      int dp[h][w];
      memset(dp,0,sizeof(dp));
      //dp[i][j]=number of ways of reaching that point
      for(int i=0;i<h;i++)
      {
          for(int j=0;j<w;j++)
            {
               cin>>grid[i][j];
            }
      }
      
      dp[0][0]=1;
      for(int i=0;i<h;i++)
      {
          for(int j=0;j<w;j++)
           {
               if(grid[i][j]!='#')
               {
                   if(i-1>=0)dp[i][j]=(dp[i-1][j]%M+ dp[i][j]%M)%M;
                   if(j-1>=0)dp[i][j]=(dp[i][j]%M+ dp[i][j-1]%M)%M;
               }
               else
               continue;
           }
      }
      
      cout<<dp[h-1][w-1];
      return 0;
  }

      


Measured memory_bytes: 9088
#include<stdio.h>
#include<string.h>
const int N = 1300;
const int M = 256;
int main()
{
	char str[N];
	int ary[M] = {0};
	while(fgets(str, 1300, stdin))
	{
		for(int i = 0; i < strlen(str) - 1; i++)
		{
		 	if(str[i] >= 'A' && str[i] <= 'Z')
		 	{
		 		ary[str[i] + 32]++;
			}
			else
			{
				ary[str[i]]++;
			}
		}
		
	}
	for(int i = 'a'; i <= 'z'; i++)
	{
		printf("%c : %d\n", i, ary[i]);
	}
	return 0;
} 


Measured memory_bytes: 2692
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string

H, W = map(int, input().split())
if H > W:
    H, W = W, H
ans = None
if H == 1:
    if W == 1:
        ans = 1
    else:
        ans = W - 2
elif H == 2:
    ans = 0
else:
    ans = (H - 2) * (W - 2)
print(ans)



Measured memory_bytes: 8388
N = int(input())
e = [0 for _ in range(N + 1)]

for i in range(2, N + 1):
    for j in range(2, i + 1):
        while i % j == 0:
            e[j] += 1
            i //= j


def num(m):
    return len(tuple(filter(lambda x: x >= m - 1, e)))


ans = 0
ans += num(75)
ans += num(25) * (num(3) - 1)
ans += num(15) * (num(5) - 1)
ans += num(5) * (num(5) - 1) * (num(3) - 2) // 2

print(ans)


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N;
vector<int>G[234567];
pair<int, int>dfs(int v, int las) {
	pair<int, int>res = { 1,v };
	for (int nx : G[v]) {
		if (las == nx)continue;
		auto tmp = dfs(nx, v);
		tmp.first++;
		res = max(res, tmp);
	}
	return res;
}

int main() {
	cin >> N;
	for (int i = 1; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	auto r1 = dfs(0, -1);
	auto r2 = dfs(r1.second, -1);
	if (r2.first % 3 == 2) {
		cout << "Second" << endl;
	}
	else {
		cout << "First" << endl;
	}
	return 0;
}


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

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

    int arr[n][3];
    
    int ans[n][3]={0};
    
    for(int i=0;i<n;i++)
    {
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
        ans[i][0]=arr[i][0];
        ans[i][1]=arr[i][1];
        ans[i][2]=arr[i][2];
    }

    ans[0][0]=arr[0][0];
    ans[0][1]=arr[0][1];
    ans[0][2]=arr[0][2];

    for(int i=1;i<n;i++)
    {
        
        for(int j=0;j<3;j++)
        {
            int max=0;
            for(int k=0;k<3;k++)
            {
                if(ans[i-1][k]>=max && k!=j)
                    max=ans[i-1][k];
                
            }
            ans[i][j]+=max;
            //cout<<ans[i][j]<<" ";
            
        }
    }

    int max2=0;
    for(int i=0;i<3;i++)
    {
        //cout<<" ans"<<ans[n-1][i];
        if(ans[n-1][i]>max2)
            max2=ans[n-1][i];
    }
cout<<max2;



}

Measured memory_bytes: 2560
#include<cstdio>
#include<vector>
#include<algorithm>


using namespace std;

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


int main(){
  int N,tmpA,res,gc;
  vector<int> A,B;
  scanf("%d\n", &N);
  for(int i=0;i<N;i++){
    scanf("%d",&tmpA);
    A.push_back(tmpA);
  }
  
  gc=gcd(A[0],A[1]);
  for(int i=2;i<A.size();i++){
    gc=gcd(gc,A[i]);
  }

  printf("%d\n",gc);
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <utility>

using namespace std;

int calc(int fromx, int fromy, int tox, int toy)
{
    int cnt = 0;

    while (fromx != tox || fromy != toy) {
        if (fromx < tox && fromy < toy) {
            fromx++;
            fromy++;
        } else if (fromx > tox && fromy > toy) {
            fromx--;
            fromy--;
        } else if (fromx > tox && fromy < toy) {
            fromx--;
        } else if (fromx < tox && fromy > toy) {
            fromx++;
        } else if (fromx == tox) {
            if (fromy < toy) {
                fromy++;
            } else {
                fromy--;
            }
        } else if (fromy == toy) {
            if (fromx < tox) {
                fromx++;
            } else {
                fromx--;
            }
        }
        
        cnt++;
    }

    return cnt;
}

int main()
{
    int w, h, n; cin >> w >> h >> n;

    int a, b; cin >> a >> b;
    pair<int, int> now(a, b);

    int cnt = 0;

    for(int i = 1; i < n; ++i) {
        int x, y; cin >> x >> y;
        
        cnt += calc(now.first, now.second, x, y);  
        
        now.first = x, now.second = y;
    }

    cout << cnt << endl;
}

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

int main() {
    int n, d, x;
    cin>>n>>d>>x;
    
    int c = x;
    
    int a[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    
    for(int i=0; i<n; i++){
        int j=0;
        while(j*a[i]+1<=d){
            c++;
            j++;
        }
    }
    
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
import itertools
tmp=[]
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
for i in range(1,N+1):
  tmp.append(i)
tmp=list(itertools.permutations(tmp))
A=0
B=0
for i,seq in enumerate(tmp):
  if list(seq)==P:
    A=i
  if list(seq)==Q:
    B=i
print(abs(A-B))

Measured memory_bytes: 10100
R,C = map(int,input().split(' '))
row_column = list()
for r in range(R):
    row_column.append(list(map(int,input().split(' '))))
for c in range(C):
    vector = int(input())
    for item in row_column:
        item[c] *= vector
for item in row_column:
    print(sum(item))


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

using namespace std;
using ll = long long;

int main() {
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    ll s=0;
    for(int i = 0;i < n;++i) {cin>>a[i];s+=a[i];}
    sort(a.begin(),a.end());
    for(int i = 0;i < m;++i) {
        if(a[n-1-i]*4*m<s){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int INF=1000000000;
int main(){
int N,M,X;
  cin>>N>>M>>X;
  vector<int>C(N);
  int A[N][M];
  for(int i=0;i<N;i++){
  cin>>C.at(i);
    for(int j=0;j<M;j++)
      cin>>A[i][j];
  } int ans=INF;
  for(int bit=0;bit<(1<<N);bit++){
      int c=0;
    vector<int>B(M,0);
    for(int i=0;i<N;i++){
    if(bit &(1<<i)){
      c+=C.at(i);
      for(int j=0;j<M;j++)
        B[j]+=A[i][j];
    
    
    }
  
  }bool x=true;
    for(int j=0;j<M;j++)
      if(B[j]<X)
        x=false;
    if(x){if(c<ans) ans=c;}
  
  }if(ans==INF)
    cout<<-1<<endl;
  else
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3656
// No sorceries shall prevail. //           
import java.util.*;
import java.io.*;
public class Main {
	
	static long gcd(long a, long b) { 
	      if (b == 0) 
	        return a; 
	      return gcd(b, a % b);  
	    }
	static int gcd(int a, int b) { 
	      if (b == 0) 
	        return a; 
	      return gcd(b, a % b);  
	    }
	
	static long mod = 1000000007;
	public static void main(String args[]) {
		Scanner inp=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		
		String s=inp.next();
    	int n=s.length();
    	out.println(s.charAt(2)==s.charAt(3) && s.charAt(4)==s.charAt(5)?"Yes":"No");
		
		out.close();
		inp.close();
	}
}

Measured memory_bytes: 21716
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<b){
        cout<<"a < b"<<endl;
    }
    else if(a==b){
        cout<<"a == b"<<endl;
    }
    else{
        cout<<"a > b"<<endl;
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
int n;
int a[maxx];

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	int sum = 0;
	a[0] = a[n + 1] = 0;
	for(int i = 1; i <= n + 1; i++) sum += abs(a[i] - a[i - 1]);
	for(int i = 1; i <= n; i++) {
		int tmp = sum;
		tmp -= abs(a[i + 1] - a[i]) + abs(a[i] - a[i - 1]);
		tmp += abs(a[i + 1] - a[i - 1]);
		printf("%d\n", tmp);
	}
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>

using namespace std;

int main(void) {
	int n = 0;
	string str, maxi;
	vector<string> v;
	vector<int> mode;

	while (cin >> str) {
		v.push_back(str);
		mode.push_back(1);
		if (str.size() > maxi.size()) {
			maxi = str;
		}
	}
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v.size(); j++) {
			if (v[i] == v[j] && i != j) {
			 mode[i]++;
			}
		}
	}
	for (int i = 0; i < v.size(); i++) {
		if (mode[n] < mode[i]) {
			n = i;
		}
	}

	cout << v[n] << " " << maxi << endl;
}

Measured memory_bytes: 3156
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int> v,u1,u2;
int n,cnt,a,b;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        u1.push_back(a);
    }
    for(int i=0;i<n;i++){
        cin>>a;
        u2.push_back(a);
    }
    for(int i=1;i<=n;i++)v.push_back(i);
    do{
        cnt++;
        if(u1==v)a=cnt;
        if(u2==v)b=cnt;
    }while(next_permutation(v.begin(),v.end()));
    cout<<abs(a-b)<<endl;
}


Measured memory_bytes: 256
/*hello! guys~*/
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	int t,a,b,flag=0;
	cin>>t>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i%t==0){
		flag=1;break;}
	}
	if(flag)printf("OK\n");
	else printf("NG\n");
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define foo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(a,min(b,min(c,d)))
#define max4(a,b,c,d)       max(a,max(b,max(c,d)))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void DFS(int n);
bool isprime(ll n);
int gcd(int a,int b);
void rstgraph(int n);

const int mod = pow(10,9)+7;
const int N = 3e5, M = N;

//=======================================================================================
vi g[N];
int vis[N];
int nodes=0;

void iluzn() {
 int a,b;
 int d=6;
 cin>>a>>b;
 cout<<6-a-b;

}

 
int main() {
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t=1,i;
    // cin>>t;
     while(t--) iluzn();
    return 0;
}
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
bool isprime(ll n){
    if(n<=1)
        return false;
    if(n==2)
        return true;
    if(n%2==0)
        return false;
    ll rt = sqrt(n);
    for(ll i=3;i<rt;i+=2){
        if(n%i==0)
            return false;
    }
    return true;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
void ipgraph(int m){
  int u, v;
  while(m--){
    cin>>u>>v;
    g[u].pb(v);
    // g[v].pb(u);
  }
}

void DFS(int n)
{  ++nodes;
    vis[n] = 1;
    for(vector<int>::iterator i = g[n].begin(); i != g[n].end() ; i++)
    {
        if(!vis[*i])
            DFS(*i);
    }
}
void rstgraph(int n){
  int i;
  fo(i,n+1){
    g[i].clear();
    vis[i]=0;
  }
  nodes=0;
}

Measured memory_bytes: 10724
#include<iostream>
#include<stdio.h>
#include<vector>
#include <stdlib.h>
using namespace std;

int main() {
    int N,K;
    long long INF = 1LL << 60;
    cin >> N >> K;
    long long h[100010];
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    long long dp[100010];
    for(int i = 0; i < 100010; i++){
        dp[i] = INF;
    }

    dp[0] = 0;

    for(int i = 1; i < N; i++){
        if(dp[i] > dp[i - 1] + abs(h[i] - h[i - 1])){
            dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        }

        if(i > K){
            for(int j = 1; j < K; j++){
                if(dp[i] > dp[i - 1 - j] + abs(h[i] - h[i - 1 - j])){
                    dp[i] = dp[i - 1 - j] + abs(h[i] - h[i - 1 - j]);
                }
            }
        }else if(i > 1){
            for(int j = 1; j < i; j++){
                if(dp[i] >  dp[i - 1 - j] + abs(h[i] - h[i - 1 - j])){
                    dp[i] = dp[i - 1 - j] + abs(h[i] - h[i - 1 - j]);
                }
            }
        }
    }

        cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,a[100010],ans=0,maxn=0;

int main()
{	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=1;i<=n;++i)
	{
		while(i<=n && a[i]<=a[i-1])
			ans++,++i;
		maxn=max(maxn,ans);
		ans=0;
	}
	cout<<maxn<<endl;
	return 0;
} 

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

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  string s;
  cin >> n >> s;

  if(n%2==1)cout << "No" << endl;
  else{
    bool ok=true;
    for(ll i=0;i<n/2;i++){
      if(s[i]!=s[i+n/2])ok=false;
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
  }

}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

vector<pair<ll, ll>> factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll i = 2; (i * i) <= n; i++) {
        if (n % i) continue;
        res.emplace_back(i, 0);
        while((n % i) == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
}

ll gcd(ll a, ll b) {
    return (b ? gcd(b, a % b) : a);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll suma = accumulate(all(a), 0LL);
    vector<pair<ll, ll>> fac = factorize(suma);
    set<ll> div;
    div.insert(1);
    rep(i, sz(fac)) {
        rep(ii, fac[i].second) {
            set<ll> add;
            for(auto x : div) add.insert(x * fac[i].first);
            for(auto x : add) div.insert(x);
        }
    }
    map<ll, vector<ll>> surplus, dp;
    for(auto x : div) {
        surplus[x].resize(n);
        rep(i, n) surplus[x][i] = a[i] % x;
        sort(all(surplus[x]));
        dp[x].resize(n + 1, 0);
        rep(i, n) dp[x][i + 1] = dp[x][i] + surplus[x][i];
    }
    ll ans = a[0];
    reps(i, 1, n) ans = gcd(ans, a[i]);
    reps(i, 1, n) {
        for(auto x : div) {
            ll minus = dp[x][i];
            ll plus = (n - i) * x - (dp[x][n] - dp[x][i]);
            if (abs(minus - plus) % x != 0) continue;
            if (max(minus, plus) <= k) ans = max(ans, x);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9728
N = int(input())
A = tuple(map(int, input().split()))
lst = [0] * (N + 1)
ans = set()
for i in range(N, 0, -1):
    tmp = (sum(lst[i::i]) % 2 + A[i - 1]) % 2
    if tmp:
        ans.add(i)
    lst[i] = tmp
print(len(ans))
print(*ans)


Measured memory_bytes: 17112
N = int(input())
d = {}
for i in range(N):
    d[i] = {}

for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = [int(i) for i in input().split()]
        d[i][x-1] = y
# 整合性はどうやって取れるか？
# 人iが正直者として整合性がなりたち、その人数がmax_countを更新するなら増やす
max_i = 0
for i in range(2 ** N):
    tmp = [-1 for i in range(N)]
    counter = 0
    flag = 0
    for j in range(N):
        if ((i >> j) & 1):
            counter += 1
            tmp[j] = 1
        else:
            tmp[j] = 0
    for j in range(N):
        if ((i >> j) & 1):
            for key in d[j].keys():
                if tmp[key] != d[j][key]:
                    flag = 1

        if flag == 1:
            break
    if flag == 0 and max_i < counter:
        max_i = counter
print(max_i)
    

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

// D - RGB Triplets
int main() {
    int N;
    string S;
    cin >> N >> S;

    if (N < 3) {
        cout << 0;
        return 0;
    }

    int r = 0, g = 0, b = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') r++;
        if (S[i] == 'G') g++;
        if (S[i] == 'B') b++;
    }

    // long long all = (long long)r * g * b;

    int minus = 0;
    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            if (j + (j - i) >= N) break;
            if (S[i] != S[j] && S[i] != S[j + (j - i)] && S[j + (j - i)] != S[j]) {
                // cout << "i:" << i << S[i] << ", j:" << j << S[j] << ", k:" << j + (j - i) << S[j + (j - i)] << endl;
                minus++;
                // all--;
            }
        }
    }

    long long all = (long long)r * g * b;
    cout << all - minus;
    // cout << (long long)(r * g * b) - minus;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;
template <typename Functor>
struct fix_type
{
    Functor functor;
    template <typename... Args>
    decltype(auto) operator()(Args&&... args) const& { return functor(functor, std::forward<Args>(args)...); }
};
template <typename Functor>
fix_type<typename std::decay<Functor>::type> fix(Functor&& functor) { return {std::forward<Functor>(functor)}; }

struct Graph
{
    Graph(const int v) : V{v}, edge(v), rev_edge(v) {}
    void addEdge(const int from, const int to)
    {
        edge[from].push_back(to);
        rev_edge[to].push_back(from);
    }
    const int V;
    vector<vector<int>> edge;
    vector<vector<int>> rev_edge;
};

vector<int> diameter(const Graph& g)  // 無向木
{
    using P = pair<int, int>;
    vector<int> prev(g.V, -1);
    auto dfs1 = fix([&](auto&& self, const int s, const int p) -> P {
        P ans{0, s};
        prev[s] = p;
        for (const int to : g.edge[s]) {
            if (p == to) { continue; }
            P sub = self(self, to, s);
            sub.first++;
            ans = max(ans, sub);
        }
        return ans;
    });
    const P far = dfs1(0, -1);
    int pos = dfs1(far.second, -1).second;
    vector<int> ans;
    for (; pos >= 0; pos = prev[pos]) { ans.push_back(pos); }
    return ans;
}

int main()
{
    int N;
    cin >> N;
    Graph g(N);
    for (int i = 0; i < N - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g.addEdge(u, v);
        g.addEdge(v, u);
    }
    vector<int> d = diameter(g);
    int node = d.size();
    for (int i = 1; i < (int)d.size() - 1; i++) { node += (int)g.edge[d[i]].size() - 2; }
    if (node == N) {
        auto v = [&]() {
            vector<int> ans;
            ans.push_back(1);
            for (int i = 1, num = 2; i < d.size() - 1; i++) {
                const int p = num;
                for (int j = 0; j < g.edge[d[i]].size() - 2; j++, num++) {
                    ans.push_back(num + 1);
                }
                num++;
                ans.push_back(p);
            }
            ans.push_back(N);
            return ans;
        };
        const auto a1 = v();
        reverse(d.begin(), d.end());
        const auto a2 = v();
        const auto ans = min(a1, a2);
        for (int i = 0; i < N; i++) {
            cout << ans[i] << " ";
        }
        cout << endl;

    } else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 17652
n,k=map(int,input().split())
a=[]
for i in range(n):
    a_i,b_i=map(int,input().split())
    a.append([a_i,b_i])
a.sort()
num=0
for i in range(n):
    num+=a[i][1]
    if num>=k:
        print(a[i][0])
        break

Measured memory_bytes: 20104
#!/user/bin/env python
#pythonプログラムであることを示している

# -*- coding: utf-8 -*-
"""
このプログラムはPythonを書く際のテンプレとなっています。これをコピペしてコーディングを行なってください。
なお字下げしないこと！！
"""

__author_ = 'Maruta Yuzuha'
__version_ = '1.0.0'
__date__ = '2019/12/25'

def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = input().split()
    t = input().split()
    a = 0
    for i in range(int(s[1])):
        a += int(t[i])
    b = int(s[0])
    if b <= a:
        print('Yes')
    else:
        print('No')

    return 0

if __name__ == '__main__':
    #上記のifの記述によってこのスクリプトファイルが起動された時だけ実行する部分になる。
    #ちなみにスクリプトが "モジュールとして"インポートされた時には実行されない、

    #単体テスト:モジュールのdocstring(ドキュメンテーション文字列)に記載された全ての対話実行例が書かれている通りに動作するかを確認
    #python ファイル名 -v
    import doctest
    doctest.testmod()

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())

Measured memory_bytes: 14740
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;
int main(void){
  int n,k;
  cin >> n >> k;
  int p[n];
  rep(i,n) cin >> p[i];
  sort(p,p+n);

  int ans = 0;
  rep(i,k){
    ans += p[i];
  }

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


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

int main(void)
{
	int K,A,B,now=0;
	bool between=false;
	cin>>K>>A>>B;
	while(now<B)
	{
		now+=K;
		if(now>=A&&now<=B)
		{
			between=true;
		}
	}
	if(between)cout<<"OK";
	else cout<<"NG";
}


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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int mod = 1e9 + 7;
const int MAX = 1e5 + 1;

int main()
{
	IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		string s;
		cin >> s;
		int fw = -1, lr = -1;
		for(int i = 0; i < n; ++i)
		{
			if(s[i] == 'W')
			{
				fw = i;
				break;
			}
		}
		for(int i = n - 1; i >= 0; --i)
		{
			if(s[i] == 'R')
			{
				lr = i;
				break;
			}
		}
		//cout << "fw = " << fw << "  lr = " << lr << endl;
		if(fw == -1 || lr == -1 || (fw > lr))
		{
			//cout << "1 = ";
			cout << 0;
		}
		else
		{
			int swaps = 0;
			while(fw <= lr)
			{
				if(s[fw] == 'W' && s[lr] == 'R')
				{
					swap(s[fw], s[lr]);
					swaps += 1;
				}
				if(s[fw] != 'W') fw += 1;
				if(s[lr] != 'R') lr -= 1;
			}
			cout << swaps;
		}
	}
	return 0;
}


Measured memory_bytes: 3724
# /usr/bin/env python3
# https://atcoder.jp/contests/abc042/tasks/arc058_a

n, k = input().split()
d = input().split()
while True:
    if len(set(n) & set(d)) == 0:
        print(n)
        break
    n = str(int(n) + 1)


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


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

    ll N, K ;
    cin >> N >> K ;
    string S;
    cin >> S;

    char now = '1';
    ll cnt = 0;

    ll ans = 0;

    vector<pair<char,ll> > lst;
    rep(i, S.size()){
        if(S[i] == now)cnt ++;
        else{
            lst.pb(mp(now, cnt));
            if(now == '0') ans ++;
            now = S[i];
            cnt = 1;
        }
    }
    lst.pb(mp(now, cnt));
    if(now == '0'){
         ans ++;
         lst.pb(mp('1', 0));
     }

    if(ans <= K) {
        cout << N << endl;
        return 0;
    }

    ans = 0;
    ll l = 0;
    ll r = K * 2;
    ll cpr = 0 ;
    for(ll i = 0; i <= r ; i++) cpr += lst[i].second;

    ans = max(ans, cpr);
    while(r < lst.size()-1){
        cpr -= lst[l].second;
        cpr -= lst[l+1].second;
        l += 2;

        cpr += lst[r+1].second;
        cpr += lst[r+2].second;
        r += 2;
        ans = max(ans, cpr);
    }

    cout << ans << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=1e5+100;
const int mod=1e9+7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    int a, b;
    cin>>a>>b;
    cout<<a+b/2<<"\n";
    return 0;
}


Measured memory_bytes: 256
N,M,X=map(int,input().split())
A=[list(map(int,input().split())) for _ in range (N)]
ans=10**20

for bit in range(2**N):
    C=[0]*M
    cost=0
    for i in range(N):
        if (bit>>i)&1==1:
            cost+=A[i][0]
            for j in range(1,M+1):
                C[j-1]+=A[i][j]
    if min(C)>=X:
        ans=min(ans,cost)
print(ans if ans!=10**20 else -1)

Measured memory_bytes: 9172
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	int N; cin >> N;
	cout << (N + 1) / 2 << endl;
}





Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;
typedef std::pair<LL, LL> P;
struct edge { LL to, cost; };
 
const LL inf = 11234567890123;
LL N, M;
std::map<LL, LL>dist;
std::map<LL, std::vector<edge>>G;
 
void dijkstra(LL s)
{
	std::priority_queue<P, std::vector<P>, std::greater<P>>que;
	for (auto i : G) dist[i.first] = inf;
	dist[s] = 0;
	que.push(P(0, s));
	while (!que.empty())
	{
		P p = que.top(); que.pop();
		LL v = p.second;
		if (dist[v] < p.first) { continue; }
		rep(i, G[v].size())
		{
			edge e = G[v][i];
			if (dist[e.to] > dist[v] + e.cost)
			{
				dist[e.to] = dist[v] + e.cost;
				que.push(P(dist[e.to], e.to));
			}
		}
	}
}
 
int main()
{
	in >> N >> M;
	std::vector<LL>p(M), q(M), c(M);
	rep(i, M)
	{
		in >> p[i] >> q[i] >> c[i];
		G[p[i] + c[i] * N].push_back({ q[i] + c[i] * N,0 });
		G[q[i] + c[i] * N].push_back({ p[i] + c[i] * N,0 });
		G[p[i]].push_back({ p[i] + c[i] * N ,1 });
		G[p[i] + c[i] * N].push_back({ p[i] ,0 });
		G[q[i]].push_back({ q[i] + c[i] * N ,1 });
		G[q[i] + c[i] * N].push_back({ q[i] ,0 });
	}
	dist[N] = inf;
	dijkstra(1);
	out << (dist[N] >= inf ? -1 : dist[N]) << std::endl;
	return 0;
}

Measured memory_bytes: 110420
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    bool ok;
    int k=0;
    ll ans;
    while(k<n){
        if(k==0){
            if(s[k]==t[k]) ans=3;
            else ans=6;
        }else{
            if(ok){
                ans=ans*2%mod;
            }else{
                if(s[k]!=t[k]){
                   ans=ans*3%mod;
                }
            }
        }
        if(s[k]==t[k])ok=1;
        else ok=0;
        if(ok) k++;
        else k+=2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N,M,X = map(int, input().strip().split())

book_list = [tuple(map(int, input().strip().split())) for _ in range(N)]

most_cheep = 10**7
for pattern in range(1 << N):
    understanding_list = [0]*M
    cost_list = []
    for n_bit in range(N):
        if (pattern >> n_bit)&1:
            for m in range(M):
                understanding_list[m] += book_list[n_bit][m+1]
            cost_list.append(book_list[n_bit][0])
    for understanding in understanding_list:
        if understanding < X:
            break
    else:
        most_cheep = min(most_cheep, sum(cost_list))

if most_cheep == 10**7: most_cheep=-1

print(most_cheep)

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

using namespace std;
int main()
{
	int A,B,K;
	cin >> A >> B >> K;
	//sort(a,a+N);
	if(A+K > B-K){
		for(int i=A; i<=B; i++){
			cout << i << endl;
		}
	}else{
		for(int i=A; i<A+K; i++){
			cout << i << endl;
		}
		for(int i=B-K+1; i<=B; i++){
			cout << i << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

int main()
{
    int x = 0, y = 0;
    cin >> x >> y;
    int g = gcd(x, y);
    cout << g << endl;
    return 0;
}


Measured memory_bytes: 3100
#include<cstdio>
#include<iostream>
#include<bits/stdc++.h>

using namespace std ;
int main(){
    int n,j=0 ;
    cin>>n ;
    int ara[n] ;
    for(int i=0 ;i<n ; i++)cin>>ara[i] ;
    sort(ara,ara+n) ;
    j=ara[n-1]-ara[0] ;
    printf("%d\n",j) ;
    return 0 ;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/math/common_factor.hpp>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define endl '\n'

int main() {

    fast
    int n;cin>>n;
    int a[n];
    int cnt=0;
    for(int i=0; i<n; ++i) cin>>a[i];
    for(int i=0; i<n-2; ++i){
        int b[3];
        b[0]=a[i];b[1]=a[i+1];b[2]=a[i+2];
        sort(b,b+3);
        if(b[1]==a[i+1]) cnt++;
    }
    cout<<cnt;

#ifndef ONLINE_JUDGE
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def main():
    N = int(readline())
    A1 = list(map(int, readline().rstrip().split()))
    A2 = list(map(int, readline().rstrip().split()))
    dp = [[0, 0]  for _ in range(N)]
    dp[0][0] = A1[0]
    dp[0][1] = A1[0] + A2[0]
    for i in range(1, N):
        dp[i][0] = dp[i-1][0] + A1[i]
        dp[i][1] = max(dp[i-1][1], dp[i][0]) + A2[i]

    print(dp[N-1][1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define beg begin()
#define end end()

void _main(){
    ll a,v,b,w,t; 
    cin >> a >> v >> b >> w >> t ;
    if(abs(a-b) <= (v-w)*t) cout << "YES"<<endl;
    else cout << "NO"  << endl;

    return;
}
int main() {
    cout << fixed << setprecision(10);
    _main();
    return 0;
}
    

Measured memory_bytes: 3072
import sys
from math import gcd
from itertools import combinations


def input():
    return sys.stdin.readline().strip()


def main():

    N = int(input())
    if N == 1:
        print(1)
    elif N == 2:
        print(9)
    else:
        A = list(combinations(range(1, N + 1), 2))
        B = list(combinations(range(1, N + 1), 3))
        ans = N * (N + 1) // 2
        for a in A:
            a = list(a)
            ans += gcd(a[0], a[1]) * 6
        for b in B:
            b = list(b)
            x = gcd(b[0], b[1])
            x = gcd(x, b[2])
            ans += x * 6
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 104020
//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 107;
int n, a[N], ans;

int main() {
	rd(n), rda(a, n);
	for (int i = 1, j = 1; i <= n; i = ++j) {
		while (j < n && a[i] == a[j+1]) ++j;
		ans += (j - i + 1) >> 1;
	}
	print(ans);
	return 0;
}

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

#define INF 1e18
#define int long long

signed main() {
    int l, r; cin >> l >> r;

    int res = INF;
    for(int i = l; i <= r - 1; i++) {
        for(int j = i + 1; j <= r; j++) {
            int tmp = (i * j) % 2019;
            res = min(res, tmp);
            if(res == 0) {
                cout << res << endl;
                return 0;
            }
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


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

  string S;
  cin >> S;

  string ans = "";
  REP(i,S.length()){
    if(S[i]=='B'){
      if(ans.length()>0){
        ans.erase(ans.length()-1);
      }
    } else {
      ans += S[i];
    }
  }


  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256