akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int k, s, ans;

int main() {
    cin >> k >> s;
    for ( int i = 0; i <= k; i++ ) {
        for ( int j = 0; j <= k; j++ ) {
            if ( s - i - j >= 0 && s - i - j <= k ) ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3748
import Control.Monad
import Control.Applicative
import Data.List as List
import Data.Set as Set

maxNum :: Int
maxNum = 100000

process :: (Set Int) -> Int -> (Set Int)
process s n
    | member n s == True = Set.delete n s
    | otherwise = Set.insert n s


main :: IO()
main = do
    n <- readLn :: IO Int
    nums <- replicateM n readLn :: IO [Int]
    let s = List.foldl process Set.empty nums
    print (Set.size s)

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

int main()
{
	int num;
	cin >> num;
	string S;
	int c0 = 0, c1 = 0, c2 = 0, c3 = 0;
	for(int i=0;i<num;i++)
	{
		cin >> S;
		if (S == "AC")
			c0++;
		else if (S == "WA")
			c1++;
		else if (S == "TLE")
			c2++;
		else if (S == "RE")
			c3++;
	}
	cout << "AC x " << c0 << endl;
	cout << "WA x " << c1 << endl;
	cout << "TLE x " << c2 << endl;
	cout << "RE x " << c3 << endl;
	return 0;
}

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

main() {
    int N; cin >> N;
    ll L=1,R=1;
    rep(i,N){
        ll X,Y; cin >> X >> Y;
        if(X<L||Y<R){
            ll r=max(((L+X-1)/X),((R+Y-1)/Y));
            X*=r;Y*=r;
        }
        L=X;R=Y;
    }
    cout << L+R << endl;

    return 0;
}


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

int main(){
  
  vector<uint64_t> vecNum = {2,1};
  int intTargetNum;
  uint64_t dTemp = 0;

  cin >> intTargetNum;

  for (int i=0; i < intTargetNum+1; i++) {
    if (i > 1) {      
      dTemp = vecNum.at(0) + vecNum.at(1);
      vecNum.at(0) = vecNum.at(1);
      vecNum.at(1) = dTemp;
    }    
    // cout << vecNum.at(0) << "," << vecNum.at(1) <<  endl;
  }
  
  cout << to_string(vecNum.at(1)) << endl;
}

Measured memory_bytes: 256
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    x = int(ipt())
    if x >= 30:
        print("Yes")
    else:
        print("No")

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 68736
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

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

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

fn main() {
    let n: usize = read!(usize);

    let mut lucas = Vec::with_capacity(n + 1);
    lucas.push(2usize);
    lucas.push(1);
    if n == 1 {
        println!("1");
        return;
    }
    for i in 2..(n + 1) {
        let p1 = lucas[i - 1];
        let p2 = lucas[i - 2];
        lucas.push(p1 + p2);
    }

    println!("{}", lucas[n]);
}


Measured memory_bytes: 4352
function Main(input: string) {
  const inputs = input.split(' '),
    len = inputs.length
  let N, K

  if (len > 2 || len === 0) {
    console.log('NO')
    return
  }

  for (let i = 0; i < len; i++) {
    if (inputs[i].indexOf('.') !== -1) {
      console.log('NO')
      return
    }
  }

  try {
    N = parseInt(inputs[0], 10)
    K = parseInt(inputs[1], 10)
  } catch (e) {
    console.log('NO')
    return
  }
  const V = Math.ceil(N / 2)

  if (V >= K) {
    console.log('YES')
    return
  }

  console.log('NO')
  return
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

class Cube {
public:
	int f[6];
	Cube() {}
	void roll_z() { roll(1, 2, 4, 3); }
	void roll_y() { roll(0, 2, 5, 3); }
	void roll_x() { roll(0, 1, 5, 4); }
	void roll(int i, int j, int k, int l) {
		int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
	}
};

int getRight(Cube c1, int f1, int f2) {
	for (int i = 0; i<6; i++) {
		for (int j = 0; j<4; j++) {
			if (c1.f[0] == f1 && c1.f[1] == f2) return c1.f[2];
			c1.roll_z();
		}
		if (i % 2 == 0) c1.roll_y();
		else c1.roll_x();
	}
	return -1;
}

int main() {
	Cube c;
	int f1, f2;
	for (int i = 0; i<6; i++) cin >> c.f[i];
	int q; cin >> q;

	for (int i = 0; i<q; i++) {
		cin >> f1 >> f2;
		cout << getRight(c, f1, f2) << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		Map<Integer, List<Hen>> map = new HashMap<Integer, List<Hen>>();
		for (int i = 0; i < n - 1; i++) {
			String[] sa = br.readLine().split(" ");
			Hen hen = new Hen();
			hen.a = Integer.parseInt(sa[0]);
			hen.b = Integer.parseInt(sa[1]);
			hen.c = Integer.parseInt(sa[2]);

			List<Hen> listA = map.get(hen.a);
			if (listA == null) {
				listA = new ArrayList<Hen>();
				map.put(hen.a, listA);
			}
			listA.add(hen);

			List<Hen> listB = map.get(hen.b);
			if (listB == null) {
				listB = new ArrayList<Hen>();
				map.put(hen.b, listB);
			}
			listB.add(hen);
		}

		String[] sa = br.readLine().split(" ");
		int q = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);

		long[] d = new long[n + 1];
		Queue<Integer> que = new ArrayDeque<Integer>();
		que.add(k);
		while (!que.isEmpty()) {
			Integer cur = que.poll();
			List<Hen> list = map.get(cur);
			for (Hen o : list) {
				if (o.a == cur) {
					if (d[o.b] == 0 && o.b != k) {
						que.add(o.b);
						d[o.b] = d[o.a] + o.c; 
					}
				} else {
					if (d[o.a] == 0 && o.a != k) {
						que.add(o.a);
						d[o.a] = d[o.b] + o.c; 
					}
				}
			}
		}

		for (int i = 0; i < q; i++) {
			sa = br.readLine().split(" ");
			int x = Integer.parseInt(sa[0]);
			int y = Integer.parseInt(sa[1]);
			System.out.println(d[x] + d[y]);
		}
		br.close();
	}

	static class Hen {
		int a, b, c;
	}
}


Measured memory_bytes: 90072
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}

void solve(){
    int d, t, s;
    read(d, t, s);
    if ( s * t >= d){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}



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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}


int main(){
  int n; cin >> n;
  map<string,int> mp;
  for(int i = 0; i < n; ++i){
    string s; cin >> s;
    mp[s]++;
  }
  int m; cin >> m;
  for(int i = 0; i < m; ++i){
    string s; cin >> s;
    mp[s]--;
  }
  int ans = 0;
  for(auto e:mp){
    ChangeMax(ans,e.second);
  }
  cout << ans << endl;
} 



Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <math.h>

using namespace std;

int main()
{
    float n;
    int ans;
    cin >> n;
    ans = round(n / 2.0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

static const int INF = 1e9;

int main() {
    int n, t;
    cin >> n >> t;
    pair<int, int> ct[n];
    int x, y;
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        ct[i] = make_pair(x, y);
    }
    pair<int, int> cand[n];
    for (int i = 0; i < n; i++) {
        cand[i].first = INF;
        cand[i].second = INF;
    }
    for (int i = 0; i < n; i++) {
        if (ct[i].second <= t) {
            cand[i] = ct[i];
        }
    }
    sort(cand, cand+n);
    if (cand[0].first == INF) cout << "TLE" << endl;
    else cout << cand[0].first << endl;
}

Measured memory_bytes: 256
#include <iostream>
int main(){
	int w[10],k[10],ww=0,kk=0;
	for(int i=0;i<10;i++){
		std::cin>>w[i];
	}
	for(int i=0;i<10;i++){
		std::cin>>k[i];
	}
	for(int j=0;j<10;j++){
		int max=j;
		for(int i=j+1;i<10;i++){
			if(w[max]<w[i])max=i;
		}
		int a=w[max];
		w[max]=w[j];
		w[j]=a;
	}
	for(int j=0;j<10;j++){
		int max=j;
		for(int i=j+1;i<10;i++){
			if(k[max]<k[i])max=i;
		}
		int a=k[max];
		k[max]=k[j];
		k[j]=a;
	}
	for(int l=0;l<3;l++){
		ww+=w[l];
	}
	for(int l=0;l<3;l++){
		kk+=k[l];
	}
	std::cout<<ww<<" "<<kk<<std::endl;
	return 0;
}

Measured memory_bytes: 3088
a,b,k=map(int,input().split())
ans=[]
for i in range(a,min(a+k,b)):
    ans.append(i)
for j in range(max(a,b-k+1),b+1):
    ans.append(j)
ans=sorted(list(set(ans)))
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 3060
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <bitset>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-3
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
int Scan() {
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
const int N=105;
//Code begin...

int vis[15];

int main ()
{
    int n, x, sum=0, ans1=0, ans2=0;
    scanf("%d",&n);
    FOR(i,1,n) {
        scanf("%d",&x);
        int t=(x+400)/400;
        if (t<=8) ++vis[t];
        else ++sum;
    }
    FOR(i,1,8) if (vis[i]) ++ans1;
    if (ans1==0) {
        ans1=sum; ans2=1;
    }
    else {
        ans2=ans1; ans1=sum+ans1;
    }
    printf("%d %d\n",ans2,ans1);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1e18;

vector<char> c[15];

signed main(){
    c[1].push_back('.');
    c[1].push_back(',');
    c[1].push_back('!');
    c[1].push_back('?');
    c[1].push_back(' ');
    for(int i=2;i<=6;i++){
        for(int j=0;j<3;j++) c[i].push_back((i-2)*3+j+'a');
    }
    for(int i=0;i<4;i++) c[7].push_back(15+i+'a');
    for(int i=0;i<3;i++) c[8].push_back(19+i+'a');
    for(int i=0;i<4;i++) c[9].push_back(22+i+'a');
    int q;
    cin>>q;
    while(q--){
        string s,t;
        cin>>s;
        int m=s.size();
        int l=0;
        int cnt=0;
        while(true){
            char cc=s[l];
            int u=cc-'0';
            if(s[l]!='0'){
                while(s[l]!='0'){
                    l++;
                    cnt++;
                }
                cnt--;
                if(u==7||u==9){
                    cnt%=4;
                }else if(u==1)cnt%=5;
                else cnt%=3;
                t+=c[u][cnt];
                cnt=0;
            }else{
                l++;
            }
            if(l==m) break;
        }
        cout<<t<<endl;
    }
}


Measured memory_bytes: 3004
using System;
using System.Linq;
using System.Collections.Generic;


namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int[] nmx = sc.intarr;

            int n = nmx[0];
            int m = nmx[1];
            int x = nmx[2];

            int[] array = sc.intarr;

            int count_before = 0;
            int count_after = 0;

            for(int i=x; i>0; i--)
            {
                for(int j=0;j<m;j++)
                {
                    if(array[j] == i)
                    {
                        count_before++;
                    }
                }
            }

            for (int i = x; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    if (array[j] == i)
                    {
                        count_after++;
                    }
                }
            }

            if(count_before <= count_after)
            {
                wr.wri(count_before);
            }
            else
            {
                wr.wri(count_after);
            }

        }
    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13268
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define RG register
using namespace std;
const int N=1e5+10;
int n,m,num[N],ans,cnt[N],bck[N],cs[N],maxx[N];
inline int read(){
	char ch=getchar(); int x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	return x*f;}
inline bool cmp(int a,int b){return a%m<b%m;}
inline int mx(int a,int b){return a>b ? a : b ;}
inline int mi(int a,int b){return a<b ? a : b ;}
int main()
{
//	freopen("Pair Cards.in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(); m=read();
	for(int i=1;i<=n;i++) 
	{
		num[i]=read();//%m;
		cnt[num[i]%m]++;
		bck[num[i]]++;
	}
	ans+=cnt[0]/2;//printf("%d\n",ans);
	for(int i=1;i<m;i++)
	{
		if(i==m-i) 
		{
			ans+=cnt[i]/2;
			cnt[i]=1;
			continue;
		}
		int minn=mi(cnt[i],cnt[m-i]);
		ans+=minn;
		cnt[i]-=minn; cnt[m-i]-=minn;
	}
	for(int i=1;i<m;i++)
	{
		cnt[i]/=2;
		for(int j=i;j<=100000 && cnt[i]>0;j+=m)
		{
			ans+=mi(cnt[i], bck[j]/2);
			cnt[i]-=bck[j]/2;
		}
	}
	printf("%d\n",ans);
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
struct bit {
	int n;
	vector<ll> d;
	bit(int num) : n(num), d(num, 0) {}
	void add(int p, int x) {
		p++;
		while (p <= n) {
			d[p - 1] += x;
			p += p & -p;
		}
		return;
	}
	ll sum(int l, int r) {
		return s(r) - s(l);
	}
	ll s(int r) {
		ll res = 0;
		while (r > 0) {
			res += d[r - 1];
			r -= r & -r;
		}
		return res;
	}
};
int main() {
	int n, q;
	cin >> n >> q;
	bit bt(n);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		bt.add(i, a);
	}
	for (int i = 0; i < q; i++) {
		int t, x, y;
		cin >> t >> x >> y;
		if (t == 0)
			bt.add(x, y);
		else
			cout << bt.sum(x, y) << endl;
	}
	return 0;
}

Measured memory_bytes: 8204
#include<iostream>
#include<map>
#include<set>
using namespace std;main(){int n;string s;map<string,set<int> >z;map<string,set<int> >::iterator q;set<int>::iterator x;while(cin>>s>>n)z[s].insert(n);for(q=z.begin();q!=z.end();cout<<endl){cout<<(s=q++->first)<<endl;for(x=z[s].begin(),n=0;x!=z[s].end();cout<<*x++)if(n++)cout<<" ";}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const int MOD=1e9+7;

const int MAX_N=5002;
int n;
int a,b,c,d,e,f;
int dp[MAX_N];

int rec(){
    REP(i,n+1)dp[i]=n-i;
    if(d-a>0)for(int i=0;i+a<=n;i++)chmax(dp[i+a],dp[i]+d-a);
    if(e-b>0)for(int i=0;i+b<=n;i++)chmax(dp[i+b],dp[i]+e-b);
    if(f-c>0)for(int i=0;i+c<=n;i++)chmax(dp[i+c],dp[i]+f-c);
    return *max_element(dp,dp+n+1);
}

int newn;
int ndp[MAX_N*MAX_N];

int nrec(){
  	REP(i,newn+1)ndp[i]=newn-i;
    if(a-d>0)for(int i=0;i+d<=newn;i++)chmax(ndp[i+d],ndp[i]+a-d);
    if(b-e>0)for(int i=0;i+e<=newn;i++)chmax(ndp[i+e],ndp[i]+b-e);
    if(c-f>0)for(int i=0;i+f<=newn;i++)chmax(ndp[i+f],ndp[i]+c-f);
    return *max_element(ndp,ndp+newn+1);
}

void solve(){
    cin>>n>>a>>b>>c>>d>>e>>f;
    memset(dp,0,sizeof(dp));
    memset(ndp,0,sizeof(ndp));
    newn = rec();
    cout<<nrec()<<endl;
}

signed main(){
    solve();
}

Measured memory_bytes: 195840
#include <iostream>
#include <string>
#include <sstream>

using namespace std;
int p,q,r;
char str[100];
char *sp;

int formula(){
	char c;
	c=*sp++;
	if('0'<=c&&c<'9') return c-'0';
	if(c=='P') return p;
	if(c=='Q') return q;
	if(c=='R') return r;
	if(c=='-') return -(formula()-1)+1;
	if(c=='('){
		int left, right;
		char ope;
		left = formula();
		ope = *sp++;
		right = formula();
		sp++;
		if(ope=='*') return min(left, right);
		if(ope=='+') return max(left, right);
	}
	return 0;
}

int main(){
	while(cin>>str, *str!='.'){
		int sum=0;
		for(p=0;p<3;p++)
		for(q=0;q<3;q++)
		for(r=0;r<3;r++){
			sp = str;
			sum += formula()==2;
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 0
import math


def check(A, F, x, N, K):
    for i in range(N):
        if A[i] * F[i] > x:
            k = math.ceil(A[i] - x / F[i])
            K -= k
    if K < 0:
        return False
    else:
        return True


def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    F = list(map(int, input().split()))
    A.sort(reverse=True)
    F.sort()

    # binary search
    l = 0
    r = max(A) * max(F)
    result = None
    while l <= r:
        # print('l {}, r {}'.format(l, r))
        if l == r:
            result = l
            break
        mid = (l + r) // 2
        if check(A, F, mid, N, K):
            r = mid
        else:
            l = mid + 1

    print(result)


if __name__ == "__main__":
    resolve()


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

ifstream fin("date.in");
map <string, int> freq;

int main() {
    int n;
    string x;

    cin >> n;
    for (int i = 1; i <= n; i++)  {
        cin >> x;
        freq[x]++;
    }

    cout << "AC x " << freq["AC"] << "\nWA x " << freq["WA"] << "\nTLE x " << freq["TLE"] << "\nRE x " << freq["RE"];

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define MAX (ll)(1e6 + 7)
#define INF (ll)(1e18 + 7)
#define MOD (ll)(1e9 + 7)

using namespace std;
using ll = long long;
using cd = complex<double>;
ll mult (ll a, ll b) {
	return ((a % MOD) * (b % MOD)) % MOD;
}

ll add (ll a, ll b) {
	a += MOD;
	b += MOD;
	return (a + b) % MOD;
}

int dp[MAX];

int solve (int a) {
	if (dp[a] != -1) {
		return dp[a];
	}
	dp[a] = 0;
	for (int i = 3; i <= a; i++) {
		dp[a] = add (solve (a - i), dp[a]);
	}
	return dp[a];
}

int main () {
	int s;
	cin >> s;
	for (int i = 0; i <= s; i++) {
		dp[i] = -1;
	}
	for (int i = 0; i < 3; i++) {
		dp[i] = 0;
	}
	dp[0] = 1;
	cout << solve (s) << "\n";
}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

void solve(void){
    while (1) {
        int e; scanf("%d\n", &e);
        if (!e) break;
        int ans = INF;
        for (int z = 0; z * z * z <= e; z++) {
            for (int y = 0; y * y + z * z * z <= e; y++) {
                ans = min(ans, e - z * z * z - y * y + y + z);
            }
        }
        printf("%d\n", ans);
    }
}

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



Measured memory_bytes: 3168
import math
n, d = list(map(int, input().split()))
x = []
for i in range(n):
    x_i = list(map(int, input().split()))
    x.append(x_i)
c = 0
for i in range(n):
    for j in range(i + 1, n):
        d_ij = 0
        for k in range(d):
            d_ij += (x[i][k] - x[j][k]) ** 2
        d_ij = math.sqrt(d_ij)
        if d_ij.is_integer():
            c += 1
print(c)

Measured memory_bytes: 62192
#include <bits/stdc++.h> 
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

//ll dp[101];
ll dp[101][100005];
/*struct ks
{
    ll weight,value;
};*/

ll fun(ll w, ll n, ll weight[], ll value[])
{
    
    //Base case
    if(n==0)
    return 0;
    if(w <= 0)
    return 0;

    //Lookup
    if(dp[n][w] != -1)
    return dp[n][w];

    //Rec case
    ll op1 = (w-weight[n] >= 0) ? (value[n] + fun(w-weight[n], n-1,weight, value)) : -100;
    ll op2 = fun(w, n-1,weight,value);

    return dp[n][w] = max(op1, op2); 
}

int main()
{
    fast_io;

    ll n,w;
    cin>>n>>w;
    //vector<ks> ar;
    ll weight[n+1],value[n+1];

    for(ll i=1;i<=n;i++)
    cin>>weight[i]>>value[i];

    memset(dp,-1,sizeof(dp));
    cout<<fun(w,n,weight,value)<<endl;

    return 0;
}


Measured memory_bytes: 79232
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > P;
#define pb push_back
#define rep(i, a, b) for(ll i=(a); i<(b); i++)
const long long int mod = 1e9 + 7;
ll l[100001];
ll r[100001];

ll prime[100001];
bool is_prime[100001];

ll c[100002];

void sieve(ll n){
    ll p = 0;
    rep(i,0,n+1) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    rep(i,2,n+1){
        if(is_prime[i]){
            prime[p++] = i;
            for(ll j=2*i; j<=n; j+=i) is_prime[j] = false;
        }
    }
}

int main()
{
    ll n = 100000;
    ll Q;
    cin >> Q;
    rep(i,0,Q) cin >> l[i] >> r[i];

    sieve(n);
    for(ll i=3; i<=n; i+=2){
        if(is_prime[i] && is_prime[(i+1)/2]) c[i]++; 
    }
    for(ll i=3; i<=n; i++){
        c[i] += c[i-1];
    }
    rep(i,0,Q){
        cout << c[r[i]] - c[l[i]-1] << endl;
    }
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    int n;
    cin >> n;
    ll sum = 0;
    for (int i = 1; i <= n; ++i) {
        if (i % 3 == 0 || i % 5 == 0) {
            continue;
        }
        sum += i;
    }
    cout << sum;

    return 0;
}


Measured memory_bytes: 3608
N, X = [int(i) for i in input().split(' ')]
xs = [int(i) for i in input().split(' ')]

for idx in range(N):
	xs[idx] = abs(xs[idx]-X)

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

tmp = xs[0]
for idx in range(N-1):
	tmp = gcd(tmp, xs[idx+1])

print(tmp)

Measured memory_bytes: 14252
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int N;
    cin >> N;
    vll data(N);
    for (int i = 0; i < N; i++) {
        cin >> data[i];
    }
    sort(data.begin(), data.end());
    ll ans = 0;
    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            if (data[i] == data[j]) {
                continue;
            }
            for (int k = j + 1; k < N; k++) {
                if (data[k] == data[j]) {
                    continue;
                }
                if (data[i] + data[j] > data[k]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
import java.util.*;

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

    int n = sc.nextInt();

    int ans = 0;
    for (int i = 1; i <= n; i++) {
      if (String.valueOf(i).length() % 2 == 1) ans++;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 28500
#include<cstdio>
#include<cstdlib>
int main(void){
  int n, m, d[100010], ans = 0, a, x;
  scanf("%d %d", &n, &m);
  d[0] = 0;
  for(int i = 1;i < n; i++){
    scanf("%d", &a);
    d[i] = d[i - 1] + a;
  }
  x = 0;
  for(int i = 0;i < m; i++){
    scanf("%d", &a);
    ans = (ans + abs(d[x + a] - d[x])) % 100000;
    x = x + a;
  }
  printf("%d\n", ans);
}


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

  int count = 0, countnot = 0;
  char a[5];
  scanf("%s", a);
  for(int i= 0; i < 3; i++){
      if(a[i] == a[i + 1]){
	count++;
      }
  }
  if(count <= 0){
    printf("Good\n");
  }	else{
    printf("Bad\n");
  }
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python
# -*- conding: utf-8 -*-
import numpy as np

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
for i in range(N):
    A.append(list(map(int, input().split())))

cnt = 0
for i in range(len(A)):
    result = np.dot(A[i], B) + C
    if result > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 12488
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  string s; cin >> s;
  bool f = true;
  if(s.size() < 2 || s.size() % 2 != 0)f = false;
  for(int i = 0; i < s.size(); i++){
    if(i % 2 == 0){
      if(s[i] != 'h') f = false;
    }
    else{
      if(s[i] != 'i') f = false;
    }
  }
  if(f)cout << "Yes" << endl;
  else cout << "No" << endl;
  system("pause");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<pair<long long, long long> > XY(N);
    long long mx = 0;
    for (auto &xy : XY) cin >> xy.first >> xy.second;
    for (int i = 1; i < N; i++) {
        if (abs((XY[i].first+XY[i].second)%2) != abs((XY[i-1].first+XY[i-1].second)%2)) {
            puts("-1");
            return 0;
        }
        mx = max(mx, abs(XY[i].first)+abs(XY[i].second));
    }
    vector<long long> arms;
    long long temp = 1;
    while (temp <= mx) {
        arms.push_back(temp);
        temp <<= 1;
    }
    sort(arms.begin(), arms.end(), greater<>());
    if (mx%2 == 0 && mx != 0) arms.push_back(1);
    printf("%d\n", (int)arms.size());
    for (int i = 0; i < (int)arms.size(); i++) {
        printf("%lld%c", arms[i], i == (int)arms.size()-1 ? '\n' : ' ');
    }
    for (auto &xy : XY) {
        long long x = 0, y = 0;
        for (auto &arm : arms) {
            if (abs(x - xy.first) > abs(y - xy.second)) {
                if (x > xy.first) {
                    putchar('L');
                    x -= arm;
                } else {
                    putchar('R');
                    x += arm;
                }
            } else {
                if (y > xy.second) {
                    putchar('D');
                    y -= arm;
                } else {
                    putchar('U');
                    y += arm;
                }
            }
        }
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int a, b, m;
  cin >> a >> b >> m;
  vector<int> p(a), q(b);
  REP(i, a) cin >> p[i];
  REP(i, b) cin >> q[i];
  int ans = *min_element(ALL(p)) + *min_element(ALL(q));
  REP(i, m){
    int x, y, c;
    cin >> x >> y >> c;
    chmin(ans, p[--x]+q[--y]-c);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
from copy import deepcopy
from collections import deque
from itertools import product
import numpy as np
class Grid:
    def __init__(self, grid, w=0, h=0, function=lambda x: x):
        self.w = w = w if w else len(grid[0])
        self.h = h = h if h else len(grid)
        dtype = type(function(grid[0][0]))
        self.grid = np.empty((h, w), dtype=dtype)
        for i, row in zip(range(h), grid):
            for j, val in zip(range(w), row):
                self.grid[i][j] = function(val)
    
    def is_valid_x(self, x):
        return 0 <= x < self.w
    def is_valid_y(self, y):
        return 0 <= y < self.h
    def is_valid_xy(self, x, y):
        return self.is_valid_x(x) and self.is_valid_y(y) 
    
    def __iter__(self):
        return iter(self.grid)
    def __repr__(self):
        return '\n'.join([' '.join(map(str, row)) for row in self.grid]) + '\n'
    def __getitem__(self, x):
        return self.grid[x]
    def __setitem__(self, x, val):
        self.grid[x] = val

def longest_path(grid, root):
    def restore_path(prev, p):
        A = deque()
        while p:
            A.appendleft(p)
            p = prev[p]
        return list(A)
    
    x, y = root
    prev = {root:None}
    grid[y, x] = '!'
    queue = deque([root])
    while queue:
        x, y = queue.popleft()
        for dx, dy in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            nx, ny = x+dx, y+dy
            if grid.is_valid_xy(nx, ny) and grid[ny, nx] in 'sg.':
                prev[nx, ny] = x, y
                queue.append((nx, ny))
                grid[ny, nx] = '!'
    return restore_path(prev, (x, y))

h, w = map(int, input().split())
grid = Grid([input() for s in range(h)])
ans = 0
for y, x in product(range(h), range(w)):
    if grid[y, x] == '.':
        path = longest_path(deepcopy(grid), (x, y))
        ans = max(ans, len(path)-1)
print(ans)

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x;
    cin>>x>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);
    int pval=x,nval=x;
    int flag=1,flag1=1;
    vector<int>ans;
    while(flag1||flag)
    {

        if(!binary_search(arr,arr+n,nval)&&flag){
            ans.push_back(nval);
            flag=0;
        }else{
        nval--;
        }
        if(!binary_search(arr,arr+n,pval)&&flag1){
            ans.push_back(pval);
            flag1=0;
        }else{
        pval++;
        }
    }
    if(abs(ans[0]-x)==abs(ans[1]-x))
    {
        cout<<min(ans[0],ans[1]);
    }else{
    if(abs(ans[0]-x)>abs(ans[1]-x))
        cout<<ans[1];
    else cout<<ans[0];

    }
    return 0;
}


Measured memory_bytes: 3648
n = gets.chomp("\n").to_i
cards = gets.split(" ").map(&:to_i)

alice = 0
bob = 0
target_flag = true

while n > 0
  max = cards.max
  index = cards.index(max)
  cards.delete_at(index)
  target_flag ? alice += max : bob += max
  # 後処理
  target_flag = !target_flag
  n -= 1
end

puts alice - bob


Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 2000 + 100;

int n, m, q;
char gra[MAXN][MAXN];
int s[MAXN][MAXN], h[MAXN][MAXN], v[MAXN][MAXN];

void init(int s[MAXN][MAXN])
{
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + s[i][j];
}

int query(int s[MAXN][MAXN], int x1, int y1, int x2, int y2)
{
	return s[x2][y2] - s[x2][y1 - 1] - s[x1 - 1][y2] + s[x1 - 1][y1 - 1];
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n >> m >> q;
	for(int i = 1; i <= n; i++)
		cin >> (gra[i] + 1);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
		{
			s[i][j] = (gra[i][j] == '1');
			v[i][j] = (gra[i][j] == '1' && gra[i + 1][j] == '1');
			h[i][j] = (gra[i][j] == '1' && gra[i][j + 1] == '1');
		}

	init(s);
	init(v);
	init(h);

	for(int i = 1; i <= q; i++)
	{
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		int ans = query(s, x1, y1, x2, y2) - query(v, x1, y1, x2 - 1, y2) - query(h, x1, y1, x2, y2 - 1);
		cout << ans << endl;
	}


	return 0;
}


Measured memory_bytes: 57600
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    //cout << u << endl;
    return u;
}

ll paty_counter(ll level, ll x){
    ll size = pow(2, level+2) - 3;
    ll pmi = pow(2, level) - 1;
    if(x == 0){
        return 0;
    }else if(level == 0){    
        return 1;
    }else{
        if(x <= (size - 1)/2){
            return paty_counter(level-1, x-1);
        }else{
            return pmi + 1 + paty_counter(level-1, x - pow(2, level+1) + 3 - 2);
        }
    }

}
 
using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
static ll x;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v); // 再帰的に探索
        x ++;
    }
}

ll fr(ll n){
    ll ans = 1;
    REP(i, n){
        ans *= i+1;
        ans %= MOD;
    }
    return ans;
}

ll conb(ll n, ll k){
    return fr(n)% MOD * modinv(fr(k) * fr(n-k) % MOD, MOD) % MOD;
}

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    REP(i, n/3){
        ans += conb(n - 3 - 2 * i, i);
        ans %= MOD;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;

#define rp(i,t) for(int i=0;i<(t);i++)
#define rep(i,s,t) for(int i=(s);i<=(t);i++)
#define rsp(i,s,t) for(int i=(s);i<(t);i++)
#define rrp(i,t,s) for(int i=(t);i>=(s);i--)
#define rcp(i,s,b,d) for(int i=(s);b;d)
#define mst(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
#define N 100002

#define Dp puts("")
#define Dw printf
#define Ds printf("#")

typedef long long ll;
char ch;
int n,a[N],c[N],ans;

inline void read(int &x){x=0;do{ch=getchar();}while(ch<'0'||'9'<ch);do{x=x*10+ch-'0';ch=getchar();}while('0'<=ch&&ch<='9');}

int main(void)
{
	read(n);
	rep(i,1,n)read(a[i]),c[a[i]]++;
	rep(i,1,100000)ans=max(ans,c[i-1]+c[i]+c[i+1]);
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 1024
a,b,k=gets.split.map(&:to_i)
x=[]
s=a+k-1>b ? b : a+k-1
t=b-k+1<a ? 1 : b-k+1
if s>=t
  for i in a..b
    puts i
  end
else
  for i in a..s
    puts i
  end
  for i in t..b
    puts i
  end
end

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

int main() {
  int n, a;
  map<int, int> count;

  int ans = 0;

  cin >> n;
  rep (i, n) {
    cin >> a;

    if (count.find(a) == count.end()) {
      count[a] = 1;
    }
    else {
      count[a]++;
    }
  }

  for (pair<int, int> c : count) {
    if (c.second % 2 == 1) ans++;
  }

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



Measured memory_bytes: 4992
<?php
fscanf(STDIN, "%s", $n);
$a = substr($n, 0, 1);
$b = substr($n, 1, 1);
$c = substr($n, 2, 1);
if ($a === '1') {
    $a = '9';
} else if ($a === '9') {
    $a = '1';
}
if ($b === '1') {
    $b = '9';
} else if ($b === '9') {
    $b = '1';
}
if ($c === '1') {
    $c = '9';
} else if ($c === '9') {
    $c = '1';
}
echo $a . $b . $c;


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

int main(){
    int n , k,ans = 0;
    cin >> n >> k;
    for(int i = 1; 1 ; i++){
        if(n -k <0){
            ans = 1;
            break;
        }
        if(n - pow(k , i) < 0){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

int main(void)
{
    ll n;
    string s;
    cin >> n >> s;
    string ans, tmp;
    ll m = 0, d = 0;
    rep(i, 0, n)
    {
        d += (s[i] == '(' ? 1 : -1);
        m = min(m, d);
    }
    rep(i, 0, -m) cout << '(';
    cout << s;
    rep(i, 0, d - m) cout << ')';
    cout << endl;
}

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

using namespace std;
int main(){
	char s[19];
	cin>>s;
	char c1 =' ';
	char c2 =',';
	for(int i=0; i<19; ++i){
		if(s[i]==c2){
			s[i] = c1;
		}
	}
	cout<<s;

}

Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF=10**9

def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))
#example answer


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;

class Union_Find{
private:
    vector<int> par;
    vector<int> rank;
public:
    Union_Find(int n){
        rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
    }
    int find(int x){
        if(par.at(x)==x) return x;
        else return par.at(x)=find(par.at(x));
    }
    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank.at(x)<rank.at(y)){
            par.at(x)=y;
        }else{
            par.at(y)=x;
            if(rank.at(x)==rank.at(y)) rank.at(x)++;
        }
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
};

signed main(){
    int n,m; cin>>n>>m;
    vector<int> a(m),b(m);
    rep(i,m){
        cin>>a.at(i)>>b.at(i);
        a.at(i)--; b.at(i)--;
    }
    int ans=0;
    rep(i,m){
        Union_Find uni(n);
        rep(j,m){
            if(i!=j){
                uni.unite(a.at(j), b.at(j));
            }
        }
        if(!uni.same(a.at(i), b.at(i)))ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b;
  cin >> a >> b;
  if (a.size()>b.size()){
      cout << "GREATER" << endl;
  }else if (a.size()<b.size()){
      cout << "LESS" << endl;
  }else{
      REP(i,a.size()){
          if(a[i]>b[i]){
              cout << "GREATER" << endl;
              return 0;
          }else if(a[i]<b[i]){
              cout << "LESS" << endl;
              return 0;
          }
      }
      cout << "EQUAL" << endl;
  }
}

Measured memory_bytes: 384
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    ret = [0]*N
    for a in A:
        ret[a-1] += 1
    print(*ret, sep="\n")


if __name__ == '__main__':
    main()


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

bool ask(ll x) {
    cout << "? " << x << endl;
    string ans;
    cin >> ans;
    return ans[0] == 'Y' || ans[0] == 'y';
}

void answer(ll x) {
    cout << "! " << x << endl;
}

int main() {
    ll po = 1;
    int size = -1;
    for(int i = 0; i <= 10; i++) {
        if(!ask(po)) {
            size = i;
            break;
        }
        po *= 10;
    }
    if(size > 0) {
        ll l = po / 10, r = po - 1;
        while(r - l > 1) {
            ll m = r + l >> 1;
            bool res = ask(m * 10);
            if(res) {
                r = m;
            } else {
                l = m;
            }
        }
        if(ask(l * 10)) {
            answer(l);
        } else {
            answer(r);
        }
        return 0;
    } else {
        po = 1;
        for(int i = 0; i <= 10; i++) {
            if(ask(po * 10 -1)) {
                answer(po);
                return 0;
            }
            po *= 10;
        }
    }
    return 0;
}

Measured memory_bytes: 596
import numpy as np
n,m = map(int,input().split())
a = list()
for i in range(n):
    a.append(list(input()))
line = np.array(a)
delete_r,delete_g=list(),list()
for i in range(n):
    if "#" not in line[i]:
        delete_g.append(i)
line = np.delete(line,delete_g,0)
for i in range(m):
    if "#" not in line[:,i]:
        delete_r.append(i)
line = np.delete(line,delete_r,1)
for i in line:
    for j in i:
        print(j,end="")
    print()


Measured memory_bytes: 13908