akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"class BIT:\n"
"    def __init__(self,n):\n"
"        self.size=n\n"
"        self.tree=[0]*-~n\n"
"    def sum(self,i):\n"
"        s=0\n"
"        while i:\n"
"            s+=self.tree[i]\n"
"            i-=i&-i\n"
"        return s\n"
"    def add(self,i,x):\n"
"        while i<=self.size:\n"
"            self.tree[i]+=x\n"
"            i+=i&-i\n"
"n,k,*a=map(int,open(0).read().split())\n"
"a=[t-k for t in a]\n"
"for i in range(1,n):\n"
"    a[i]+=a[i-1]\n"
"d={}\n"
"for i,v in enumerate(sorted(set(a+[0])),1):\n"
"    d[v]=i\n"
"for i in range(n):\n"
"    a[i]=d[a[i]]\n"
"b=BIT(max(a))\n"
"b.add(d[0],1)\n"
"c=0\n"
"for i,p in enumerate(a):\n"
"    c+=b.sum(p)\n"
"    b.add(p,1)\n"
"print(c)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 45352
NK = input().split()
d = []
boys = []
for k in range(int(NK[0])):
    boys.append(k+1)

for i in range(int(NK[1])):
    d.append(input())
    l = input().split()
    for item in l:
        if int(item) in boys:
            boys.remove(int(item))

print(len(boys))

Measured memory_bytes: 9196
function Main(input) {
	input = input.split("\n");
    var series = input[1].split(" ");
    series = series.map(str => parseInt(str, 10));
    var n = parseInt(input[0], 10);
    var smax = Math.max.apply(null, series);
    var ssum = series.reduce(function(p,c){return p+c}) - smax;
    if(ssum > smax){
        console.log("Yes");
    }else{
        console.log("No");
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import sys
def input(): return sys.stdin.readline().strip()


def main():
    g1 = [1,3,5,7,8,10,12]
    g2 = [4,6,9,11]
    g3 = [2]
    d = {}
    for x in g1: d[x] = 1
    for x in g2: d[x] = 2
    for x in g3: d[x] = 3
    x, y = map(int, input().split())
    if d[x] == d[y]:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61772
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func isPrime(a int) bool {
	for j := 2; j*j <= a; j++ {
		if a%j == 0 {
			return false
		}
	}
	return true
}

func main() {
	n, d, x := nextInt(), nextInt(), nextInt()
	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	res := x
	for i := 0; i < n; i++ {
		res += (d-1)/a[i] + 1
	}

	fmt.Println(res)
}


Measured memory_bytes: 640
"""def power(x, y): 
    res = 1
    x=x
    while (y > 0): 
        if ((y & 1) == 1) : 
            res = (res * x) 
        y = y >> 1
        x = (x * x)
    return res""" 
"""def fact(n):
    if(n==0):
        return 1
    if(n==1):
        return 1
    return fact(n-1)+fact(n-2)"""
 
import math
#import combinations
 
 
#t=int(input())
#for _ in range(t):
n=int(input())
    #s=input()
    #arr=list(map(int,input().split()))
    #b=list(map(int,input().split()))
    #d={}
    #flag=0
    #ans=0
    #n,k=map(int,input().split())
a,b=map(int,input().split())
flag=0
for i in range(a,b+1):
    if(i%n==0):
        flag=1
if(flag==1):
    print("OK")
else:
    print("NG")


Measured memory_bytes: 9216
// GRL_1_A: SSSP, nonnegative edges (Dijkstra's)

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int source = sc.nextInt();

    Map<Integer, Integer> cost = new HashMap<Integer, Integer>();
    cost.put(source, 0);

    // representing vertices as int[] with values {id, tentative cost}
    PriorityQueue<int[]> pq =
        new PriorityQueue<int[]>(
            new Comparator<int[]>() {
              public int compare(int[] v1, int[] v2) {
                return Integer.compare(v1[1], v2[1]);
              }
            });

    // populate adjacency list
    // adj[i] = list of all edges from node i
    ArrayList<ArrayList<int[]>> adj = new ArrayList<ArrayList<int[]>>();
    for (int i = 0; i < n; ++i) adj.add(new ArrayList<int[]>());
    for (int i = 0; i < m; ++i) {
      int src = sc.nextInt();
      int dst = sc.nextInt();
      int edgeCost = sc.nextInt();
      adj.get(src).add(new int[] {dst, edgeCost});
    }

    // populate priority queue with neighbors of the source node 0
    for (int[] e : adj.get(source)) {
      pq.add(new int[] {e[0], e[1]});
    }

    while (!pq.isEmpty() && cost.size() < n) {
      int[] v = pq.remove(); // cheapest vertex
      if (!cost.containsKey(v[0])) {
        cost.put(v[0], v[1]);
        for (int[] e : adj.get(v[0])) {
          pq.add(new int[] {e[0], v[1] + e[1]});
        }
      }
    }

    for (int i = 0; i < n; ++i) {
      if (cost.containsKey(i)) {
        System.out.println(cost.get(i));
      } else {
        System.out.println("INF");
      }
    }
  }
}


Measured memory_bytes: 325228
c = [list(map(int, input().split())) for _ in range(3)]
a1 = 0
b1 = c[0][0] - a1
a2 = c[1][0] - b1
b2 = c[0][1] - a1
a3 = c[2][0] - b1
b3 = c[0][2] - a1
if a2 + b2 != c[1][1]:
    print("No")
    exit()
if a2 + b3 != c[1][2]:
    print("No")
    exit()
if a3 + b2 != c[2][1]:
    print("No")
    exit()
if a3 + b3 != c[2][2]:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	for(int i = 1; i < 10; i++){
		for(int j = 1; j < 10; j++){
			printf("%dx%d=%d\n", i, j, i * j);
		}
	}
	return 0;
}

Measured memory_bytes: 1096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int L = Integer.parseInt(sc.next());
		int R = Integer.parseInt(sc.next());
		int ans = 2019;

		if (L + 2019 < R) {
			R = L + 2019;
		}

		int i;
		int j;
		int mod;
		for (i = L; i <= R-1; i++) {
			for (j = i + 1; j <= R; j++) {
				mod = ((i % 2019) * (j % 2019)) % 2019;
				if (mod < ans) {
					ans = mod;
				}
			}

		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <bitset>
using namespace std;

int bit_search(const string s) {
    int set = -1;
    for (int bit=0;bit<(1<<4);bit++) {
        int total = (s[0] - '0');
        for (int i=0;i<3;i++) {
            //フラグが立てば+ else -
            if (bit&(1<<i)) {
                total += (s[i+1]-'0');
            } else {
                total -= (s[i+1]-'0');
            }
        }
        if (total == 7) {
            set = bit;
            break;
        }
    }
    return set;
}

int main() {
    string s;
    cin >> s;
    int set= bit_search(s);
    for(int i=0;i<3;i++) {
        if(set&(1<<i)) {
            s.insert(1+2*i, "+");
        } else {
            s.insert(1+2*i, "-");
        }
    }
    s += "=7";
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		if (N==1) {
			System.out.println(0);
			return ;
		}
		long total = Main.total(N,10);
		long tempeight[] = new long[(int)(N+1)];
		tempeight[0]=1;
		long ng =0;
		for (int i=1;i<=N;i++) {
			tempeight[i]=(tempeight[i-1]*8)%1000000007;
		}
		Main.pre_factrials((int)N);
		for (int i=0;i<N;i++) {
			long temp = Main.fastFermatComb((int)N, (int)(N-i));
			temp = (temp *tempeight[i])%1000000007;
			ng = (ng + temp)%1000000007;
		}
		ng = (ng*2)%1000000007;
		ng =( ng +tempeight[(int)N]) %1000000007;
		System.out.println((total+1000000007-ng)%1000000007);
//		total = (total + N*(N-1)/2)%1000000007;
//		System.out.println(total);
	}

	public static long total(long N, int a) {
		long re =1;
		for (int i=0;i<N;i++) {
			re = (re*10)%1000000007;
		}
		return re;
	}

	static long factorials[];
    static long factorialDivs[];
    static int mod = (int) 1e9 + 7;
    static void pre_factrials(int n) {
        factorials = new long[n + 1];
        factorialDivs = new long[n + 1];//割算の結果を格納する配列
        factorials[0] = 1;
        for (int i = 0; i < n; i++) {
            factorials[i + 1] = mul(i + 1, factorials[i]);
        }
        factorialDivs[n] = div(1, factorials[n]);//最初に1/(n!)を求める事で、1/(n-1)!からは掛け算で求める事ができる。
        for (int i = n - 1; i >= 0; i--) {
            factorialDivs[i] = mul(factorialDivs[i + 1], i + 1);
        }
    }

    static long fastFermatComb(int a, int b) {
        if (factorials.length == 0)
            System.err.println("error : factorials has not been culculated!! do [pre_factorial] method");
        long af = factorials[a];
        long bf = factorialDivs[b];
        long abf = factorialDivs[a - b];
        long res = mul(mul(af, bf), abf);
        return res;
    }

  //MOD culculations
    static long plus(long x, long y) {
        x %= mod;
        y %= mod;
        long res = (x + y) % mod;
        return res;
    }

    static long sub(long x, long y) {
        x %= mod;
        y %= mod;
        long res = (x - y + mod) % mod;
        return res;
    }

    static long mul(long x, long y) {
        x %= mod;
        y %= mod;
        long res = x * y % mod;
        return res;
    }

    static long div(long x, long y) {
        x %= mod;
        y %= mod;
        long res = x * modpow(y, mod - 2) % mod;
        return res;
    }

    static long modpow(long a, long p) {
        if (p == 0)
            return 1;
        if (p % 2 == 0) {
            long halfP = p / 2;
            long root = modpow(a, halfP);
            return root * root % mod;
        } else
            return a * modpow(a, p - 1) % mod;
    }
}

Measured memory_bytes: 66236
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b;
    cin >> a >> b ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    //*/
    
    /*
    if( a < 6 ){
        cout << 0 << endl;
    } else if (a < 13){
        cout << b / 2 << endl;
    } else {
        cout << b << endl;
    }
    //*/
    
    cout << ( a * 3 + b ) / 2 << endl;

    return 0; 
}


Measured memory_bytes: 3596
#include <stdio.h>

int main(void) {

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

	if(a<b){
		if(b<c){
		printf("Yes\n");
	}else {
		printf("No\n");
	}
	} else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <map>
using namespace std;

const int divisor = 1000000007;

int main(){
	vector<int> ansvec;

	// 100000!までの数をdivisorで割った余りを格納しておく
	long long* factmodary = new long long[100001];
	long long fact = 1;
	for (int i = 1; i <= 100000; i++){
		fact *= i;
		fact %= divisor;
		factmodary[i] = fact;
	}

	int* word = new int[100000] {0};

	for (;;){
		int N, R;
		cin >> N;
		if (N == 0) break;
		cin >> R;

		for (int i = 0; i < N; i++) word[i] = i + 1; //まず0番目の単語を入れておく

		for (int i = 0; i < R; i++){
			int s, t;
			cin >> s >> t;
			/* swap */
			int tmp = word[s - 1]; word[s - 1] = word[t - 1]; word[t - 1] = tmp;
		}

		//word[i]をkey, word[i]より小さい数がそれ以前にいくつ使われていたかをvalueとして格納するmap
		map<int, int> bubblehist;
		bubblehist[word[0]] = 0;

		long long ans = factmodary[N-1] * (word[0] - 1);

		for (int i = 1; i < N; i++){
			int facttime = word[i] - 1;
			int bubblenum;
			map<int, int>::iterator it = bubblehist.lower_bound(word[i]);

			if (it != bubblehist.end()){
				bubblenum = it->second;
			}
			else {
				bubblenum = bubblehist.rbegin()->second + 1;
			}
			pair<int, int> p;
			p.first = word[i];
			p.second = bubblenum;
			bubblehist.insert(--it, p);
			//word[i]より大きい数はすべてvalueが1増える
			for (map<int, int>::iterator it2 = bubblehist.upper_bound(word[i]); it2 != bubblehist.end(); it2++) ++(it2->second);

			facttime -= bubblenum;
			ans += factmodary[N - (i + 1)] * facttime;
			ans %= divisor;
		}
		ansvec.push_back((int)ans);
	}

	for (vector<int>::iterator it = ansvec.begin(); it != ansvec.end(); it++) cout << *it << "\n";

	delete[] word;
	delete[] factmodary;
	return 0;
}

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

int main(int argc, char const *argv[])
{
    int d;
    cin >> d;
    if(d == 25) {
        cout << "Christmas" << endl;
    } else if (d == 24) {
        cout << "Christmas Eve" << endl;
    } else if (d == 23) {
        cout << "Christmas Eve Eve" <<endl;
    } else {
        cout << "Christmas Eve Eve Eve" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int x, t;
	cin >> x >> t;
	cout << max(x - t, 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#define N 262147
#define ll long long
#define reg register
#define p 998244353
using namespace std;

int fa[N],a[N],b[N],sa[N],sb[N],lsh[N];
int n,cnt,ans = -1;

inline int find(int x){
    while(x!=fa[x]) x = fa[x] = fa[fa[x]];
    return x;
}

inline void merge(int u,int v){
    int fu = find(u),fv = find(v);
    if(fu!=fv) fa[fu] = fv;
}

inline int qwq(int x){
    return lower_bound(lsh+1,lsh+1+cnt,x)-lsh;
}

int main(){
    scanf("%d",&n);
    for(reg int i=1;i<=n;++i) scanf("%d",&a[i]),a[n+1] ^= a[i];
    for(reg int i=1;i<=n;++i) scanf("%d",&b[i]),b[n+1] ^= b[i];
    ++n;
    memcpy(sa+1,a+1,n<<2);
    memcpy(sb+1,b+1,n<<2);
    sort(sa+1,sa+n+1);
    sort(sb+1,sb+n+1);
    for(reg int i=1;i!=n;++i){
        if(sa[i]==sb[i]) continue;
        printf("-1");
        return 0;
    }
    for(reg int i=1;i<=n;++i){
        fa[i] = i;
        if(a[i]==b[i]&&i!=n) continue;
        lsh[++cnt] = a[i];
        lsh[++cnt] = b[i];
        ++ans;
    }
    sort(lsh+1,lsh+1+cnt);
    cnt = unique(lsh+1,lsh+1+cnt)-lsh-1;
    for(reg int i=1;i<=n;++i){
        if(a[i]==b[i]) continue;
        merge(qwq(a[i]),qwq(b[i]));
    }
    for(reg int i=1;i<=cnt;++i) ans += fa[i]==i;
    printf("%d",ans-1);
	return 0;	
}

Measured memory_bytes: 5504
(defvar N (read))

(loop repeat (read)
      with maxL = 0 
      and minR = (1+ N)
      and L and R 
      do 
      (setf L (read)
            R (read))
      (if (> L maxL) (setf maxL L))
      (if (< R minR) (setf minR R))
      finally (princ (max (1+ (- minR maxL)) 0)))

Measured memory_bytes: 57704
def bitmake(digit):#bit文字列生成（取り扱い注意）
    bit_list =list()

    for i in range(2 ** digit):
        bit = []
        for j in range(digit):  # このループが一番のポイント
            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                bit.append(j)
        bit_list.append(bit)
    return bit_list
h,w,k = map(int,input().split())
grid = [""]*h
for i in range(h):
    grid[i] = list(map(str,input()))
# print(grid)

bit_list = bitmake(h+w)
# print(bit_list)
blackh = [0]*h#横
blackw = [0]*w#縦
blacksum = 0
for i in range(h):
    for j in range(w):
        if(grid[i][j] == "#"):
            blackh[i]+=1
            blackw[j]+=1
            grid[i][j] = 1
            blacksum += 1
        else:
            grid[i][j] = 0
# print(blackh,blackw)
ans = 0
for i in range(2**(h+w)):
    bit = bit_list[i]#h:0~(h-1),w:h~(h+w)-1
    remove = 0
    hight = []
    width = []
    for j in range(len(bit)):
        l = bit[j]
        if(l <= h-1):
            remove += blackh[l]
            hight.append(l)
        else:
            ind = l - h
            remove += blackw[ind]
            width.append(ind)
    # print(hight,width)
    rid = 0
    for j in range(len(hight)):
        for l in range(len(width)):
            if(grid[hight[j]][width[l]] == 1):
                rid += 1
    
    if((blacksum - remove) + rid == k):
        # print(blacksum,remove,rid,"___",blacksum-remove+rid)  
        ans += 1
print(ans)

# 2 3 2
# ..#
# ###





Measured memory_bytes: 9524
A,B,C,x=[int(input()) for _ in range(4)]
a=x//500
b=x//100
c=x//50
ans=0
for s in range(0,a+1):
  for t in range(0,b+1):
    u=(x-500*s-100*t)//50
    if all([0<=s<=A,0<=t<=B,0<=u<=C]):
      ans+=1
print(ans)

Measured memory_bytes: 3064
use proconio::input;


fn solve(s: String, t: String) {
    let mut ans = 0;

    for i in 0..3 {
        if s[i..i+1] == t[i..i+1] {
            ans += 1
        }
    }

    println!("{}", ans);
}


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

    solve(s, t);
}


Measured memory_bytes: 2152
// AOJ 0023
#include<iostream>
#include<cmath>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

const long double EPS = 1e-7;

long double sq(long double x) {
  return x * x;
}

long double abs(long double x) {
  return (x > 0 ? x : -x);
}
/*
bool eq(long double x, long double y) {
  return abs(x - y) < EPS;
}*/

long double dist(long double xa, long double ya, long double xb, long double yb) {
  return sq(xa - xb) + sq(ya - yb);
}

int main() {
  int n;
  cin >> n;
  REP(i, n) {
    long double xa, ya, ra, xb, yb, rb;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;

    long double d = sqrt((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb));
    
    if (ra - rb > d + EPS) {
      cout << 2 << endl;
    } else if (rb - ra > d + EPS) {
      cout << -2 << endl;
    } else if (d > ra + rb + EPS) {
      cout << 0 << endl;
    } else {
      cout << 1 << endl;
    }
  }
}

Measured memory_bytes: 1236
#include<cstdio>
#include<utility>
#include<algorithm>
int const nax = 2e5 + 5, mod = 998244353;

struct P{
    int x, d;
    P () {}
    P (int x, int d) : x(x), d(d) {}
    bool operator < (const P &a) const {
        return x < a.x;
    }
    void read () {
        scanf("%d %d", &x, &d);
    }
};

inline void add (int &a, int b) {
    if ((a += b) >= mod) a -= mod;
}

int dp[nax];
int n;
std::pair<int, int> st[nax];
int top;
P p[nax];

int main () {
    scanf("%d", &n);
    for (int i = 1 ; i <= n ; ++ i)
        p[i].read();
    std::sort(p + 1, p + 1 + n);
    dp[n + 1] = 1;
    st[top = 1] = std::make_pair(n + 1, (int)2e9 + 1);
    for (int i = n ; i >= 1 ; -- i) {
        while (top > 0 && st[top].second < p[i].x + p[i].d) -- top;
        add(dp[i], dp[st[top].first]);
        add(dp[i], dp[i + 1]);
        st[++ top] = std::make_pair(i, p[i].x);
    }
    printf("%d\n", dp[1]);
}


Measured memory_bytes: 3328
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
        Stack<String> sk=new Stack<String>();
        while(s.hasNext()){
        	String st=s.next();
        	if(st.equals("0")){
        		if(sk.size()>0){System.out.println(sk.pop());}
        	}
        	else {
        		sk.add(st);
        	}
        }
	}
}
//by Tuvshee 12.05.2012
//Switching Railroad Cars

Measured memory_bytes: 12000
#include <stdio.h>
int main(void){
	int n,m,a,i,j,k,l;
	int b[1000],c[1000],d[1000];
	scanf("%d %d",&n,&m);
	for(i=1;i<=n*2;i++)b[i]=i;
	for(i=1;i<=m;i++){
		scanf("%d",&a);
		if(a==0){
			for(j=1;j<=n;j++)c[j]=b[j];
			for(k=1;k<=n;k++)d[k]=b[j+k-1];
			k=1;
			for(j=1;j<=n*2;j+=2,k++){
				b[j]=c[k];
				b[j+1]=d[k];
			}
		}
		else{
			for(j=1;j<=a;j++)c[j]=b[j];
			for(k=j,l=1;k<=n*2;k++)d[l++]=b[k];
			for(j=1;j<=l;j++)b[j]=d[j];
			for(k=1;k<=a;k++)b[l+k-1]=c[k];
		}
	}
	for(i=1;i<=n*2;i++){
		printf("%d\n",b[i]);
	}
	return 0;
}



Measured memory_bytes: 2052
import re
t = input()
#DかPD
ans = [0] * len(t)

#print(len(t))
for i in range(len(t)-1,-1,-1):
   # print(i)
    if t[i] != "?":
        ans[i] = t[i]
    else:
        if i == int(len(t)-1): #末尾
            ans[i] = "D" 
        elif ans[i+1] == "D" and t[i-1] != "P":
            ans[i] = "P"
        else:
            ans[i] = "D"

print(''.join(map(str, ans)))

Measured memory_bytes: 12916
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        for(int i=a; i<=b; i++) {
            if(i <= a+k-1 || b-k+1 <= i) System.out.println(i);
        }
    } 
}

Measured memory_bytes: 23252
import numpy as np

N = int(input())

array = np.arange(N)+1

n1=np.count_nonzero(array<10)
n2=np.count_nonzero((100<=array)&(array<1000))
n3=np.count_nonzero((10000<=array)&(array<100000))
ans=n1+n2+n3
print(ans)

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a > b) swap(a,b);
  if(b < c) swap(b,c);
  int ab = b-a;
  int bc = b-c;
  if((ab + bc)%2 == 0){
    cout << (ab+bc)/2 << endl;
  }else{
    cout << (ab+bc+3)/2 << endl;
  }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def f(l, r, kousa=1):
    n = (r - l) // kousa
    return (r + l) * (n + 1) // 2

def solve():
    N = II()

    ans = 0
    for i in range(1, N+1):
        mx = i * (N // i)
        if mx == 0: mx = i
        # print(i, mx, f(i, mx, i))
        ans = ans + f(i, mx, i)

    print(ans)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9260
using namespace std;

#include <iostream>

int main(
){
    int     X = 0;
    int     Pleasure = 0;
    std::cin >> X;
    
    while( X >= 500){
        Pleasure = Pleasure + 1000;
        X = X - 500;
    }

    while( X >= 5){
        Pleasure = Pleasure + 5;
        X = X-5;
    }

    std::cout << Pleasure << std::endl;
    return 0;
    
}


Measured memory_bytes: 256
n = int(input())
s = input()
ans = ""
for i in range(len(s)):
    num = ord(s[i])
    if num + n > 90:
        num1 = (num+n)-90+64
    if num + n <= 90:
        num1 = num + n
    ans += chr(num1)
print(ans)

Measured memory_bytes: 9184
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>
#include <map>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

const ll mod = 1e9+7;

int main() {
	string s;
	cin >> s;
	char a = s[0];
	bool good = true;
	FOR(i, 1, 4) {
		if (a == s[i]) {
			good = false;
		}
		a = s[i];
	}
	if (good) {
		cout << "Good" << endl;
	}
	else {
		cout << "Bad" << endl;
	}
}

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

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

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

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll n; 
vvll G(10005);
vll c;

vll ans(10005);
ll ki=1;
ll score=0;

void dfs(ll v, ll p){
  if(ki>=n) return;
  for(auto nv: G[v]){
    if(nv==p) continue;
    ans[nv]=c[ki];
    score+=min(ans[v],ans[nv]);
    ki++;
    dfs(nv,v);
  }
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n;
  rep(i,n-1){
    ll a,b; cin>>a>>b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  c.resize(n);
  rep(i,n) cin>>c[i];
  sort(c.rbegin(),c.rend());
  ans[0]=c[0];
  dfs(0,-1);
  
  cout<<score<<endl;
  rep(i,n){
    cout<<ans[i]<<endl;
  }
  
}

Measured memory_bytes: 1536
#include <stdio.h>

int main(void)
{
	int day;
	int ja, ma;
	int max_ja, max_ma;
	int cnt_ja = 0, cnt_ma = 0;
	
	scanf("%d", &day);
	scanf("%d%d", &ja, &ma);
	scanf("%d%d", &max_ja, &max_ma);
	
	while (1){
		ja -= max_ja;
		cnt_ja++;
		if (ja <= 0){
			break;
		}
		
	}
	
	//printf("cnt_ja=%d\n", cnt_ja);
	
	while (1){
		ma -= max_ma;
		cnt_ma++;
		if (ma <= 0){
			break;
		}
	}
	
	//printf("cnt_ma=%d\n", cnt_ma);
	
	if (cnt_ja >= cnt_ma){
		day -= cnt_ja;
	}
	else {
		day -= cnt_ma;
	}
	
	printf("%d\n", day);
	
	return (0);
}

Measured memory_bytes: 596
#include<stdio.h>
typedef long long ll;
int main(){
    ll N;
    scanf("%lld",&N);
    ll sum = 0;
    for(int i=1;i<=N;i++){
        if(!(i%5==0 || i%3==0))
            sum += i;
    }
    printf("%lld",sum);
}


Measured memory_bytes: 1728
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	long T;
	cin >> N >> T;

	long ans = 0;
	long t = 0;
	for (int i = 0; i < N; i++) {
		long ti;
		cin >> ti;
		if (t > ti) ans -= t - ti;
		ans += T;
		t = ti + T;
	}

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


Measured memory_bytes: 256
import fractions

def prime(n):
    jdg=True
    for i in range(2,round(n**0.5)+1):
        if n%i==0:
            jdg=False
    return jdg

def md(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

A,B=map(int,input().split())
G=fractions.gcd(A,B)
Gd=md(G)
l=[]
ans=0
for g in Gd:
    if prime(g):
        l.append(g)
        ans+=1
print(ans)

Measured memory_bytes: 66540
#include <bits/stdc++.h>
using namespace std;
vector <long long int> v;
vector <double> vd;

vector <char> vc;
vector <string> vs;
map <string,int> sm;
map <int,int> mp;
map <char,int>cm;
set <int> st;
#define soort(v) sort(v.begin(),v.end())
#define foor(i,n) for(int i=1; i<n; i++)



int main(){
    int a,b,c,n;
    string s,p;
    char ch;
    
    cin >> a >> b;
    
    if(b==a)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n,ans=0;
    scanf("%d",&n);
    ans+=n/25;
    n%=25;
    ans+=n/10;
    n%=10;
    ans+=n/5;
    n%=5;
    ans+=n;
    printf("%d\n",ans);
}


Measured memory_bytes: 2732
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	string s;
	ll k;
	cin >> s;
	cin >> k;
	if(k==1){
		cout << s[0] << endl;
		return 0;
	}else{
		rep(i,s.size()){
			if(s[i]!='1'){
				cout << s[i] << endl;
				return 0;
			}
			if(i+1==k){
				cout << s[i] << endl;
				return 0;
			}
		}
	}
	return 0;
}

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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  
  vector<char> S(N)
  ;for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  
  int countb = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'b' && countb < B){
      S.at(i) = 'a';
      countb++;
    }
  }
      
  int counta = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'a' && counta < A + B){
      counta++;
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 768
n, k = gets.split.map(&:to_i)
count1, count2, count3 = 0, 0, 0
if k.odd?
	1.upto(n) do |i|
		if i % k == 0
			count1 += 1
		end
	end
	puts count1 ** 3
else
	1.upto(n) do |i|
		if i % k == k / 2
			count2 += 1
		elsif i % k == 0
			count3 += 1
		end
	end
	puts count2 ** 3 + count3 ** 3
end


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

const int table[10] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

int main() {
	const int INF = 1e8;
	int N, M;
	cin >> N >> M;
	vector<int> A(M);
	for (int i = 0; i < M; i++) { 
        cin >> A[i]; 
    }
    sort(A.rbegin(), A.rend());
	vector<int> dp(N + 1, -INF);
	dp[0] = 0;
	for (int i = 0; i < M; i++) {
		int cost = table[A[i]];
		for (int j = 0; j <= N; j++) {
			if (dp[j] < 0) { 
                continue; 
            }
			if (j + cost > N) { 
                break; 
            }
			dp[j + cost] = max(dp[j + cost], dp[j] + 1);
		}
	}
    /*
    for (int i = 0; i <= N; i++) {
        cout << "マッチをちょうど"<< i << "本使ってできる最大桁数" << dp[i] << endl;
    }
    */
	string res = "";
	int num = N;
	int idx = 0;
	while (num > 0) {
		int cost = table[A[idx]];
		if ((num >= cost) && (dp[num] == dp[num - cost] + 1)) {
			res += to_string(A[idx]);
			num -= cost;
		} 
        else {
			idx++;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

ans = 1
left = Array.new(n,0)
right = Array.new(n,0)
left[0] = a.first
right[n-1] = a.last

1.upto(n-1).each do |i|
  left[i] = left[i-1].gcd(a[i])
end
(n-2).downto(0).each do |i|
  right[i] = right[i+1].gcd(a[i])
end

ans = 0
1.upto(n-2) do |i|
  # p [left[i-1], right[i+1]]
  ans = [ans, left[i-1].gcd(right[i+1])].max
end

puts [ans, left[n-2], right[1]].max

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

int main(){
	string S;
	cin >> S;
	string s1 = S.substr(0, 2), s2 = S.substr(2, 2);
	if(s1 == "00"){
		if(s2 > "12" || s2 == "00") cout << "NA" << endl;
		else cout << "YYMM" << endl;
	}else if(s2 == "00"){
		if(s1 > "12" || s1 == "00") cout << "NA" << endl;
		else cout << "MMYY" << endl;
	}else if(s1 > "12" && s2 > "12"){
		cout << "NA" << endl;
	}else if(s1 > "12"){
		cout << "YYMM" << endl;
	}else if(s2 > "12"){
		cout << "MMYY" << endl;
	}else{
		cout << "AMBIGUOUS" << endl;
	}
	return 0;
}


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

int n,k,mod=1e9+7,ans=0;
int a[100005];

int quick_power(int a,int b)
{
	int res=1;
	for (;b;b=b>>1,a=(a*a)%mod)
	{
		if (b&1)  res=(res*a)%mod;
	}
	return res;
}

signed main()
{
	cin>>n>>k;
	for (int i=k;i>=1;i--)
	{
		a[i]=quick_power(k/i,n)%mod;
		for (int j=2*i;j<=k;j+=i)  a[i]=((a[i]-a[j])%mod+mod)%mod;
	}
	for (int i=1;i<=k;i++)  ans=(ans+a[i]*i)%mod;
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 4384
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//----------------------------------------------------------------------

#define MAX 110000

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

  RFOR(i, t.length() - 1, s.length()) {
	flag = true;
	FOR(j, 0, t.length()) {
	  if (!(s[i - j] == '?' || s[i - j] == t[t.length() - j - 1])) {
		flag = false;
		break;
	  }
	}
	if (flag) {
	  FOR(j, 0, t.length()) {
		s[i - j] = t[t.length() - j - 1];
	  }
	  break;
	}
  }

  FOR(i, 0, s.length()) {
	if (s[i] == '?') s[i] = 'a';
  }

  if (flag && s.length() >= t.length()) {
	cout << s << endl;
  }
  else {
	cout << "UNRESTORABLE" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  bool exist = false;
  bool unexist = true;
  int N, Y, thou,five,ten;
  cin >> N>> Y;
  for(int a=0;a<=N;++a){
    for(int b=0;a+b<=N;++b){
      int c = N-a-b;
      int sum = 1000*a+5000*b+10000*c;
      if(Y==sum){
        exist = true;
        unexist = false;
        thou = a;
        five = b;
        ten = c;
      }
    }
  }
  if(exist){
    cout<<ten<<" "<<five<<" "<<thou<<endl;
  }
  if(unexist){
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
  }
}

Measured memory_bytes: 3636
s = int(input())
m = 1
ans = 0

def func(n) :
    if n%2==0 :
        return n//2
    else :
        return 3*n+1

if s==1 or s==2:
    ans = 4
    
else :

    while s!=1 :
        s = func(s) + 0
        m += 1

    ans = m+1

print(ans)

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

const ll INF = 1001001001;

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

int main(){
  ll a,b;
  cin>>a>>b;
  ll c=gcd(a,b);
  cout<<a*b/c<<endl;
  
  
}



Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n,k = lr()
ans = 0
for b in range(k+1,n+1):
    count = b-k
    num = n//b
    amari = n%b
    if k == 0:
        amari-=1
    ans+=(count*num+max(0,amari-k+1))
print(ans)

Measured memory_bytes: 77592
# 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() {
  int x; cin >> x;
  if(x>=30) { cout << "Yes" << endl; }
  else { cout << "No" << endl; }

  return 0;
}


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

int n, ans, cnt_even, f[100001];
int main() {
	scanf("%d",&n);
	for(int i = 0,x; i < n; i++) scanf("%d",&x), f[x]++;
	for(int x = 1; x <= 1e5; x++) if(f[x] >= 2) {
		ans += (f[x]/2-bool(!(f[x]%2)))*2;
		f[x] -= (f[x]/2-bool(!(f[x]%2)))*2;
		cnt_even += bool(!(f[x]%2));
	}
	ans += cnt_even+bool(cnt_even%2);
	assert(n >= ans);
	printf("%d", n-ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define fi first
#define se second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define sz size()
#define PQ priority_queue
#define len length()
#define mll map<ll,ll>
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define mp(x,y)  make_pair(x,y)
#define pb push_back
#define pf push_front
#define ALL(v) v.begin(),v.end()
#define LAPAK ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

const ll MOD = 1000000007;

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

/*            *          *******        *       *     *
             * *            *          * *       *   *
coded by    *****           *         *****       * *
           *     *      *   *        *     *       *
          *       *      * *        *       *      *
*/


Measured memory_bytes: 1792
n,m,x,y = map(int, input().split())
x_city = sorted(list(map(int, input().split())))
y_city = sorted(list(map(int, input().split())))

if x_city[len(x_city)-1] < y_city[0] and (x < y_city[0] <= y):
    print("No War")
else:
    print("War")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007


int findBitSize(int a){
  int ans=0;
  while(a>0){
    a/=2;
    ans++;
  }
  return ans;
}

vector<int> findBitRepresent(int a,int bitSize){
  vector<int>answer;
  while(a>0){
    answer.push_back(a%2);
    a/=2;
  }
  int i;
  int temp=answer.size();
  for(i=0;i<bitSize-temp;i++){
    answer.push_back(0);
  }
  reverse(answer.begin(),answer.end());
  return answer;
}

int main(){
  FIO;
  // ifstream cin("input");
  int n,m,x;
  cin>>n>>m>>x;
  int a[n][m];
  int i,j;
  int c[n];
  for(i=0;i<n;i++){
    cin>>c[i];
    for(j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  int totalNumbers = pow(2,n);
  int ans=INT_MAX;
  int learning[m];
  for(i=1;i<totalNumbers;i++){
    for(int k=0;k<m;k++){
      learning[k]=0;
    }
    int temp=0;
    vector<int> bitRepresent = findBitRepresent(i,n);
    for(j=0;j<bitRepresent.size();j++){
      if(bitRepresent[j]==1){
        temp+=c[j];
        for(int k=0;k<m;k++){
          learning[k]+=a[j][k];
        }
      }
    }
    int flag=0;
    for(int k=0;k<m;k++){
      if(learning[k]<x){
        flag=1;
      }
    }
    if(flag==0){
      ans=min(ans,temp);
    }
  }
  if(ans==INT_MAX){
    cout<<-1<<endl;
    return 0;
  }
  cout<<ans<<endl;
  return 0;  
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
  int n,cnt=0;cin>>n;
  vector<int> v(n);rep(i,n)cin>>v[i];

  sort(all(v));

  for(int i=1;i < n;i++)
  {
    if(v[i]==v[i-1])cnt++;
  }

  cout<<n-((cnt+1)/2 *2)<<endl;
}


Measured memory_bytes: 640
S = input()
N = len(S)
hantei = [False]*N
check = True
for i in range(1, N+1):
    if i % 2 :
        if (S[i-1] == "R") | (S[i-1] == "U") | (S[i-1] == "D") :
            hantei[i-1] = True
        else:
            hantei[i-1] = False
    else:
        if (S[i-1] == "L") | (S[i-1] == "U") | (S[i-1] == "D") :
            hantei[i-1] = True
        else:
            hantei[i-1] = False

for i in range(N):
    if hantei[i] == False:
        check = False
            
if check :
    print('Yes')
else:
    print('No')
    
        


Measured memory_bytes: 3064
<>;
@y=map-$t+($t=$_),glob<>;
($M,$K)=glob<>;
for$i(0..59){
	@s=???0..$#y:@s[@s];
	map@s[$_-1,$_]=@s[$_,$_-1],glob<>;
	@y=@y[@s]if$K>>$i&1
}
print$z+=$_,$/for@y


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

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

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <bitset>


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

    int n; std::cin >> n;
    std::cout << (n+2-1)/2 << std::endl;

    return 0;
}


Measured memory_bytes: 256
#(1,0)と(1,1)が敗戦の最終状態。そこから遷移する状態を考える。
#(2,0),(3,0)は勝利状態。
#(2,1),(2,2)はどう遷移しても上記勝利状態に遷移してしまうので、敗北状態。
#(3,1),(4,0),(4,1),(5,0)...などが上記敗北状態に遷移できる状態なので勝利状態。
#実験を重ねると|X-Y|<=1が敗戦状態ではないか、という仮説が立つ。
#少し考えると、|X-Y|<=1からの遷移は必ず|X'-Y'|>1にならざるを得なくて
#|X-Y|>1からは必ず|X'-Y'|<=1となる遷移が存在することが分かる。
#最終的には|X-Y|<=1の状態は2N手後に(1,0)と(1,1)へと収斂するので、勝利条件が確定する。

X,Y=map(int,input().split())
if abs(X-Y)<=1:
  print("Brown")
else:
  print("Alice")

Measured memory_bytes: 2940
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <bitset>
#include <vector>
#include <string>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define rep(i, x, y)  for(int i = (int)x; i <= (int)y; i ++)
#define fi first
#define se second
#define pb push_back
#define mk make_pair
using namespace std;
typedef long long LL;
const	int N = 100005;
const	int P = (int)1e9 + 7;
int st[N<<1], deg[N], d[N], n, vis[N], a[N], tot, ct[N], sz[N], ans=1, fac[N], inv[N];

int power(int x, int y){
	int an = 1;
	for(; y; y >>= 1, x = (LL)x * x % P) if(y & 1) an = (LL)an * x % P;
	return an;
}

int C(int x, int y){
	if(x < 0 || y < 0 || x < y) return 0;
	return (LL)fac[x] * inv[y] % P * inv[x - y] % P;
}

void renew(int &x, const int y){
	x += y;
	if(x < 0) x += P;
	if(x >= P) x -= P;
}

void init(){
	fac[0] = inv[0] = fac[1] = inv[1] = 1;
	rep(i, 2, n){
		fac[i] = (LL)fac[i - 1] * i % P;
		inv[i] = power(fac[i], P - 2);
	}
}

int getdp(){
	int fr = 0;
	rep(i, 1, tot) st[i + tot] = st[i];
	rep(i, 1, tot) if(sz[st[i]]){
		fr = i;
		break;
	}
	reverse(st + fr + 1, st + fr + tot);
	int a = fr + sz[st[fr]] - 1, b = a + 1, c = 1;
	rep(i, fr + 1, fr + tot - 1)if(sz[st[i]]){
		int na = i + sz[st[i]] - 1, nb = na + 1, cc = 0;
		if(a < i) renew(cc, c);
		if(b < i) renew(cc, c);
		a = na;
		b = nb;
		c = cc;
	}
	int ans = 0;
	if(a < fr + tot) renew(ans, c);
	if(b < fr + tot) renew(ans, c);
	return ans;
}

int que[N], t;
int main(){
	scanf("%d", &n);
	rep(i, 1, n) scanf("%d", a + i);
	rep(i, 1, n){
		deg[a[i]] ++;
		if(deg[a[i]] > 2){ puts("0"); exit(0); }
	}
	rep(i, 1, n) d[i] = deg[i];
	rep(i, 1, n) if(!d[i]) que[++t] = i;
	rep(h, 1, t){
		int u = que[h];
		--d[a[u]];
		vis[u] = 1;
		if(!d[a[u]]) que[++t] = a[u];
	}
	rep(i, 1, n) if(vis[i] && deg[i] >= 2){
		puts("0");
		exit(0);
	}
	rep(i, 1, n) if(vis[i] && !deg[i]){
		int x = i, cnt = 0;
		for(x = i; vis[x]; x = a[x])cnt++;
		sz[x] = cnt;
	}
	init();
	ans=1;
	rep(i, 1, n)if(!vis[i])
	{
		int u = i, cu = 1;
		tot = 0;
		int res = 0;
		do{
			st[++tot] = u;
			cu &= !sz[u];
			vis[u] = 1;
			u = a[u];
		}while(u != i);
		if(cu){
			ct[tot] ++;
			res = 1;
		}else{
			res = getdp();		
		}
		ans = (LL)ans * res % P;
	}
	rep(i, 1, n) if(ct[i])
	{
		int tot = ct[i];
		int res = 0;
		for(int x = 0; x <= tot; x += 2){
			int cb = 1;
			cb = (LL)cb * power(i, (x >> 1)) % P;
			cb = (LL)cb * C(tot, x) % P;
			cb = (LL)cb * fac[x] % P;
			cb = (LL)cb * inv[x >> 1] % P;
			cb = (LL)cb * power((P + 1) >> 1, x >> 1) % P;
			if((i > 1) && (i & 1)){
				cb = (LL)cb * power(2, tot - x) % P;
			}
			renew(res, cb);
		}
		ans = (LL)ans * res % P;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
typedef long long LL;
int m; LL v[N];

int n,nn,T;
pair<LL,LL> p[N];
bool cmp(pair<LL,LL> A,pair<LL,LL> B){
	return A.first*(B.second+1)>B.first*(A.second+1);
}
LL dp[N][50];
LL trans(LL t,pair<LL,LL> pr){
	if(t >= (LL)(1e12+pr.first)/(pr.first+1)) return 1e18;
	//printf("## %lld\n", (pr.first+1)*t + pr.first + pr.second);
	return (pr.first+1)*t + pr.first + pr.second + 1;
}
int query(LL x){
	for(int i=m;i>=0;i--) if(v[i]<=x) return i;
	return 0;
}
int main() {
	scanf("%d%d",&n,&T);
	//n=1,T=1;
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&p[i].first,&p[i].second);
		//p[i].first=1, p[i].second=0;
	}
	/*
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				if(i!=j&&i!=k&&j!=k){
					LL t=0;
					t=trans(t,p[i]);
					t=trans(t,p[j]);
					t=trans(t,p[k]);
					if(t<=57){
						printf("t=%lld %d %d %d\n", t,i,j,k);
					}
				}
			}
		}
	}
	*/
	for(int i=1;i<=n;i++){
		if(p[i].first==0){
			v[++m]=p[i].second+1;
		}else{
			p[++nn]=p[i];
		}
	}
	sort(v+1,v+1+m);
	for(int i=1;i<=m;i++){
		v[i]=v[i-1]+v[i];
	}
	n=nn;
	sort(p+1,p+1+n,cmp);
	/*
	for(int i=1;i<=n;i++){
		printf("a=%d, b=%d\n", p[i].first,p[i].second);
	}
	*/
	for(int i=0;i<N;i++)for(int j=0;j<50;j++)dp[i][j]=1e18;
	dp[0][0]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<50;j++){
			if(dp[i][j]<=T){
				//printf("dp[%d][%d]=%lld\n", i,j,dp[i][j]);
				dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
				dp[i+1][j+1]=min(dp[i+1][j+1],trans(dp[i][j],p[i+1]));
			}
		}
	}
	int ans=0;
	for(int j=0;j<50;j++){
		if(dp[n][j]<=T){
			//printf("j=%d\n", j);
			int tmp=j+query(T-dp[n][j]);
			ans=max(ans,tmp);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 83072
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    bool flag = true;
    cin>>str;
    for(int i = 0 ; i < str.length() ; i++)
    {
        if((i+1)%2 == 0)
        {
            if(str[i] =='R')
            {	
            flag = false;
        	break;}

        }
		if((i+1)%2 != 0)
        {
            if(str[i] == 'L')
            {flag = false;
        	break;}
        }
    }
    if(flag)
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
    return 0;
}


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

int dp[1<<16];


int main(){
  int n;
  int t[16][17];

  while(1){
    cin >> n;
    if(!n)break;

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

    for(int i=0;i<(1<<n);i++)dp[i] = (1<<31) - 1;
    dp[0] = 0;

    for(int i=1;i<(1<<n);i++){
      for(int j=0;j<n;j++){
	if( (i>>j) & 1 ){
	  int tmp = t[j][0];
	  for(int k=0;k<n;k++){
	    if( j!=k && ((i>>k) & 1) )tmp = min(tmp,t[j][k+1]);
	  }
	  dp[i] = min(dp[i] , dp[i - (1<<j)] + tmp);
	}
      }
    }

    cout << dp[(1<<n) - 1] << endl;
  }
}

Measured memory_bytes: 1120